@@ -1008,14 +1008,18 @@ public function register( $plugin ) {
10081008 );
10091009
10101010 // Prepare the received data
1011- $ plugin = wp_parse_args ( $ plugin , $ defaults );
1012- $ plugin ['file_path ' ] = $ this ->_get_plugin_basename_from_slug ( $ plugin ['slug ' ] );
1011+ $ plugin = wp_parse_args ( $ plugin , $ defaults );
10131012
10141013 // Forgive users for using string versions of booleans or floats for version nr
1015- $ plugin ['version ' ] = (string ) $ plugin ['version ' ];
1016- $ plugin ['required ' ] = TGM_Utils::validate_bool ( $ plugin ['required ' ] );
1017- $ plugin ['force_activation ' ] = TGM_Utils::validate_bool ( $ plugin ['force_activation ' ] );
1018- $ plugin ['force_deactivation ' ] = TGM_Utils::validate_bool ( $ plugin ['force_deactivation ' ] );
1014+ $ plugin ['version ' ] = (string ) $ plugin ['version ' ];
1015+ $ plugin ['source ' ] = empty ( $ plugin ['source ' ] ) ? 'repo ' : $ plugin ['source ' ];
1016+ $ plugin ['required ' ] = TGM_Utils::validate_bool ( $ plugin ['required ' ] );
1017+ $ plugin ['force_activation ' ] = TGM_Utils::validate_bool ( $ plugin ['force_activation ' ] );
1018+ $ plugin ['force_deactivation ' ] = TGM_Utils::validate_bool ( $ plugin ['force_deactivation ' ] );
1019+
1020+ // Enrich the received data
1021+ $ plugin ['file_path ' ] = $ this ->_get_plugin_basename_from_slug ( $ plugin ['slug ' ] );
1022+ $ plugin ['type ' ] = $ this ->get_plugin_type ( $ plugin ['source ' ] );
10191023
10201024 // Set the class properties
10211025 $ this ->plugins [ $ plugin ['slug ' ] ] = $ plugin ;
@@ -1032,6 +1036,29 @@ public function register( $plugin ) {
10321036 }
10331037 }
10341038
1039+ /**
1040+ * Determine what type of source the plugin comes from.
1041+ *
1042+ * @param string $source The source of the plugin as provided, either empty (= WP repo), a file path
1043+ * (= bundled) or an external url.
1044+ * @return string 'repo', 'external', or 'bundled'
1045+ */
1046+ protected function get_plugin_type ( $ source ) {
1047+
1048+ // Is this a WP repo plugin ?
1049+ if ( 'repo ' === $ source || preg_match ( self ::WP_REPO_REGEX , $ source ) ) {
1050+ return 'repo ' ;
1051+ }
1052+ // Is this an external package url ?
1053+ elseif ( preg_match ( self ::IS_URL_REGEX , $ source ) ) {
1054+ return 'external ' ;
1055+ }
1056+ // This must be a bundled/pre-packaged plugin.
1057+ else {
1058+ return 'bundled ' ;
1059+ }
1060+ }
1061+
10351062 /**
10361063 * Amend default configuration settings.
10371064 *
0 commit comments