Advertisements

get_plugin_files

Definition:
function get_plugin_files($plugin) {}

Get a list of a plugin’s files.

Parameters

  • string $plugin: Plugin ID

Return values

returns:List of files relative to the plugin root.

Source code

function get_plugin_files($plugin) {

	$plugin_file = WP_PLUGIN_DIR . '/' . $plugin;

	$dir = dirname($plugin_file);

	$plugin_files = array($plugin);

	if ( is_dir($dir) && $dir != WP_PLUGIN_DIR ) {

		$plugins_dir = @ opendir( $dir );

		if ( $plugins_dir ) {

			while (($file = readdir( $plugins_dir ) ) !== false ) {

				if ( substr($file, 0, 1) == '.' )

					continue;

				if ( is_dir( $dir . '/' . $file ) ) {

					$plugins_subdir = @ opendir( $dir . '/' . $file );

					if ( $plugins_subdir ) {

						while (($subfile = readdir( $plugins_subdir ) ) !== false ) {

							if ( substr($subfile, 0, 1) == '.' )

								continue;

							$plugin_files[] = plugin_basename("$dir/$file/$subfile");

						}

						@closedir( $plugins_subdir );

					}

				} else {

					if ( plugin_basename("$dir/$file") != $plugin )

						$plugin_files[] = plugin_basename("$dir/$file");

				}

			}

			@closedir( $plugins_dir );

		}

	}



	return $plugin_files;

}

1560

Advertisements

No comments yet... Be the first to leave a reply!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: