Edit File by line
/home/barbar84/public_h.../wp-admin/includes
File: plugin.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* WordPress Plugin Administration API
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage Administration
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
/**
[8] Fix | Delete
* Parses the plugin contents to retrieve plugin's metadata.
[9] Fix | Delete
*
[10] Fix | Delete
* All plugin headers must be on their own line. Plugin description must not have
[11] Fix | Delete
* any newlines, otherwise only parts of the description will be displayed.
[12] Fix | Delete
* The below is formatted for printing.
[13] Fix | Delete
*
[14] Fix | Delete
* /*
[15] Fix | Delete
* Plugin Name: Name of the plugin.
[16] Fix | Delete
* Plugin URI: The home page of the plugin.
[17] Fix | Delete
* Description: Plugin description.
[18] Fix | Delete
* Author: Plugin author's name.
[19] Fix | Delete
* Author URI: Link to the author's website.
[20] Fix | Delete
* Version: Plugin version.
[21] Fix | Delete
* Text Domain: Optional. Unique identifier, should be same as the one used in
[22] Fix | Delete
* load_plugin_textdomain().
[23] Fix | Delete
* Domain Path: Optional. Only useful if the translations are located in a
[24] Fix | Delete
* folder above the plugin's base path. For example, if .mo files are
[25] Fix | Delete
* located in the locale folder then Domain Path will be "/locale/" and
[26] Fix | Delete
* must have the first slash. Defaults to the base folder the plugin is
[27] Fix | Delete
* located in.
[28] Fix | Delete
* Network: Optional. Specify "Network: true" to require that a plugin is activated
[29] Fix | Delete
* across all sites in an installation. This will prevent a plugin from being
[30] Fix | Delete
* activated on a single site when Multisite is enabled.
[31] Fix | Delete
* Requires at least: Optional. Specify the minimum required WordPress version.
[32] Fix | Delete
* Requires PHP: Optional. Specify the minimum required PHP version.
[33] Fix | Delete
* * / # Remove the space to close comment.
[34] Fix | Delete
*
[35] Fix | Delete
* The first 8 KB of the file will be pulled in and if the plugin data is not
[36] Fix | Delete
* within that first 8 KB, then the plugin author should correct their plugin
[37] Fix | Delete
* and move the plugin data headers to the top.
[38] Fix | Delete
*
[39] Fix | Delete
* The plugin file is assumed to have permissions to allow for scripts to read
[40] Fix | Delete
* the file. This is not checked however and the file is only opened for
[41] Fix | Delete
* reading.
[42] Fix | Delete
*
[43] Fix | Delete
* @since 1.5.0
[44] Fix | Delete
* @since 5.3.0 Added support for `Requires at least` and `Requires PHP` headers.
[45] Fix | Delete
*
[46] Fix | Delete
* @param string $plugin_file Absolute path to the main plugin file.
[47] Fix | Delete
* @param bool $markup Optional. If the returned data should have HTML markup applied.
[48] Fix | Delete
* Default true.
[49] Fix | Delete
* @param bool $translate Optional. If the returned data should be translated. Default true.
[50] Fix | Delete
* @return array {
[51] Fix | Delete
* Plugin data. Values will be empty if not supplied by the plugin.
[52] Fix | Delete
*
[53] Fix | Delete
* @type string $Name Name of the plugin. Should be unique.
[54] Fix | Delete
* @type string $Title Title of the plugin and link to the plugin's site (if set).
[55] Fix | Delete
* @type string $Description Plugin description.
[56] Fix | Delete
* @type string $Author Author's name.
[57] Fix | Delete
* @type string $AuthorURI Author's website address (if set).
[58] Fix | Delete
* @type string $Version Plugin version.
[59] Fix | Delete
* @type string $TextDomain Plugin textdomain.
[60] Fix | Delete
* @type string $DomainPath Plugins relative directory path to .mo files.
[61] Fix | Delete
* @type bool $Network Whether the plugin can only be activated network-wide.
[62] Fix | Delete
* @type string $RequiresWP Minimum required version of WordPress.
[63] Fix | Delete
* @type string $RequiresPHP Minimum required version of PHP.
[64] Fix | Delete
* }
[65] Fix | Delete
*/
[66] Fix | Delete
function get_plugin_data( $plugin_file, $markup = true, $translate = true ) {
[67] Fix | Delete
[68] Fix | Delete
$default_headers = array(
[69] Fix | Delete
'Name' => 'Plugin Name',
[70] Fix | Delete
'PluginURI' => 'Plugin URI',
[71] Fix | Delete
'Version' => 'Version',
[72] Fix | Delete
'Description' => 'Description',
[73] Fix | Delete
'Author' => 'Author',
[74] Fix | Delete
'AuthorURI' => 'Author URI',
[75] Fix | Delete
'TextDomain' => 'Text Domain',
[76] Fix | Delete
'DomainPath' => 'Domain Path',
[77] Fix | Delete
'Network' => 'Network',
[78] Fix | Delete
'RequiresWP' => 'Requires at least',
[79] Fix | Delete
'RequiresPHP' => 'Requires PHP',
[80] Fix | Delete
// Site Wide Only is deprecated in favor of Network.
[81] Fix | Delete
'_sitewide' => 'Site Wide Only',
[82] Fix | Delete
);
[83] Fix | Delete
[84] Fix | Delete
$plugin_data = get_file_data( $plugin_file, $default_headers, 'plugin' );
[85] Fix | Delete
[86] Fix | Delete
// Site Wide Only is the old header for Network.
[87] Fix | Delete
if ( ! $plugin_data['Network'] && $plugin_data['_sitewide'] ) {
[88] Fix | Delete
/* translators: 1: Site Wide Only: true, 2: Network: true */
[89] Fix | Delete
_deprecated_argument( __FUNCTION__, '3.0.0', sprintf( __( 'The %1$s plugin header is deprecated. Use %2$s instead.' ), '<code>Site Wide Only: true</code>', '<code>Network: true</code>' ) );
[90] Fix | Delete
$plugin_data['Network'] = $plugin_data['_sitewide'];
[91] Fix | Delete
}
[92] Fix | Delete
$plugin_data['Network'] = ( 'true' === strtolower( $plugin_data['Network'] ) );
[93] Fix | Delete
unset( $plugin_data['_sitewide'] );
[94] Fix | Delete
[95] Fix | Delete
// If no text domain is defined fall back to the plugin slug.
[96] Fix | Delete
if ( ! $plugin_data['TextDomain'] ) {
[97] Fix | Delete
$plugin_slug = dirname( plugin_basename( $plugin_file ) );
[98] Fix | Delete
if ( '.' !== $plugin_slug && false === strpos( $plugin_slug, '/' ) ) {
[99] Fix | Delete
$plugin_data['TextDomain'] = $plugin_slug;
[100] Fix | Delete
}
[101] Fix | Delete
}
[102] Fix | Delete
[103] Fix | Delete
if ( $markup || $translate ) {
[104] Fix | Delete
$plugin_data = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup, $translate );
[105] Fix | Delete
} else {
[106] Fix | Delete
$plugin_data['Title'] = $plugin_data['Name'];
[107] Fix | Delete
$plugin_data['AuthorName'] = $plugin_data['Author'];
[108] Fix | Delete
}
[109] Fix | Delete
[110] Fix | Delete
return $plugin_data;
[111] Fix | Delete
}
[112] Fix | Delete
[113] Fix | Delete
/**
[114] Fix | Delete
* Sanitizes plugin data, optionally adds markup, optionally translates.
[115] Fix | Delete
*
[116] Fix | Delete
* @since 2.7.0
[117] Fix | Delete
*
[118] Fix | Delete
* @see get_plugin_data()
[119] Fix | Delete
*
[120] Fix | Delete
* @access private
[121] Fix | Delete
*
[122] Fix | Delete
* @param string $plugin_file Path to the main plugin file.
[123] Fix | Delete
* @param array $plugin_data An array of plugin data. See `get_plugin_data()`.
[124] Fix | Delete
* @param bool $markup Optional. If the returned data should have HTML markup applied.
[125] Fix | Delete
* Default true.
[126] Fix | Delete
* @param bool $translate Optional. If the returned data should be translated. Default true.
[127] Fix | Delete
* @return array {
[128] Fix | Delete
* Plugin data. Values will be empty if not supplied by the plugin.
[129] Fix | Delete
*
[130] Fix | Delete
* @type string $Name Name of the plugin. Should be unique.
[131] Fix | Delete
* @type string $Title Title of the plugin and link to the plugin's site (if set).
[132] Fix | Delete
* @type string $Description Plugin description.
[133] Fix | Delete
* @type string $Author Author's name.
[134] Fix | Delete
* @type string $AuthorURI Author's website address (if set).
[135] Fix | Delete
* @type string $Version Plugin version.
[136] Fix | Delete
* @type string $TextDomain Plugin textdomain.
[137] Fix | Delete
* @type string $DomainPath Plugins relative directory path to .mo files.
[138] Fix | Delete
* @type bool $Network Whether the plugin can only be activated network-wide.
[139] Fix | Delete
* }
[140] Fix | Delete
*/
[141] Fix | Delete
function _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup = true, $translate = true ) {
[142] Fix | Delete
[143] Fix | Delete
// Sanitize the plugin filename to a WP_PLUGIN_DIR relative path.
[144] Fix | Delete
$plugin_file = plugin_basename( $plugin_file );
[145] Fix | Delete
[146] Fix | Delete
// Translate fields.
[147] Fix | Delete
if ( $translate ) {
[148] Fix | Delete
$textdomain = $plugin_data['TextDomain'];
[149] Fix | Delete
if ( $textdomain ) {
[150] Fix | Delete
if ( ! is_textdomain_loaded( $textdomain ) ) {
[151] Fix | Delete
if ( $plugin_data['DomainPath'] ) {
[152] Fix | Delete
load_plugin_textdomain( $textdomain, false, dirname( $plugin_file ) . $plugin_data['DomainPath'] );
[153] Fix | Delete
} else {
[154] Fix | Delete
load_plugin_textdomain( $textdomain, false, dirname( $plugin_file ) );
[155] Fix | Delete
}
[156] Fix | Delete
}
[157] Fix | Delete
} elseif ( 'hello.php' === basename( $plugin_file ) ) {
[158] Fix | Delete
$textdomain = 'default';
[159] Fix | Delete
}
[160] Fix | Delete
if ( $textdomain ) {
[161] Fix | Delete
foreach ( array( 'Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version' ) as $field ) {
[162] Fix | Delete
// phpcs:ignore WordPress.WP.I18n.LowLevelTranslationFunction,WordPress.WP.I18n.NonSingularStringLiteralText,WordPress.WP.I18n.NonSingularStringLiteralDomain
[163] Fix | Delete
$plugin_data[ $field ] = translate( $plugin_data[ $field ], $textdomain );
[164] Fix | Delete
}
[165] Fix | Delete
}
[166] Fix | Delete
}
[167] Fix | Delete
[168] Fix | Delete
// Sanitize fields.
[169] Fix | Delete
$allowed_tags_in_links = array(
[170] Fix | Delete
'abbr' => array( 'title' => true ),
[171] Fix | Delete
'acronym' => array( 'title' => true ),
[172] Fix | Delete
'code' => true,
[173] Fix | Delete
'em' => true,
[174] Fix | Delete
'strong' => true,
[175] Fix | Delete
);
[176] Fix | Delete
[177] Fix | Delete
$allowed_tags = $allowed_tags_in_links;
[178] Fix | Delete
$allowed_tags['a'] = array(
[179] Fix | Delete
'href' => true,
[180] Fix | Delete
'title' => true,
[181] Fix | Delete
);
[182] Fix | Delete
[183] Fix | Delete
// Name is marked up inside <a> tags. Don't allow these.
[184] Fix | Delete
// Author is too, but some plugins have used <a> here (omitting Author URI).
[185] Fix | Delete
$plugin_data['Name'] = wp_kses( $plugin_data['Name'], $allowed_tags_in_links );
[186] Fix | Delete
$plugin_data['Author'] = wp_kses( $plugin_data['Author'], $allowed_tags );
[187] Fix | Delete
[188] Fix | Delete
$plugin_data['Description'] = wp_kses( $plugin_data['Description'], $allowed_tags );
[189] Fix | Delete
$plugin_data['Version'] = wp_kses( $plugin_data['Version'], $allowed_tags );
[190] Fix | Delete
[191] Fix | Delete
$plugin_data['PluginURI'] = esc_url( $plugin_data['PluginURI'] );
[192] Fix | Delete
$plugin_data['AuthorURI'] = esc_url( $plugin_data['AuthorURI'] );
[193] Fix | Delete
[194] Fix | Delete
$plugin_data['Title'] = $plugin_data['Name'];
[195] Fix | Delete
$plugin_data['AuthorName'] = $plugin_data['Author'];
[196] Fix | Delete
[197] Fix | Delete
// Apply markup.
[198] Fix | Delete
if ( $markup ) {
[199] Fix | Delete
if ( $plugin_data['PluginURI'] && $plugin_data['Name'] ) {
[200] Fix | Delete
$plugin_data['Title'] = '<a href="' . $plugin_data['PluginURI'] . '">' . $plugin_data['Name'] . '</a>';
[201] Fix | Delete
}
[202] Fix | Delete
[203] Fix | Delete
if ( $plugin_data['AuthorURI'] && $plugin_data['Author'] ) {
[204] Fix | Delete
$plugin_data['Author'] = '<a href="' . $plugin_data['AuthorURI'] . '">' . $plugin_data['Author'] . '</a>';
[205] Fix | Delete
}
[206] Fix | Delete
[207] Fix | Delete
$plugin_data['Description'] = wptexturize( $plugin_data['Description'] );
[208] Fix | Delete
[209] Fix | Delete
if ( $plugin_data['Author'] ) {
[210] Fix | Delete
$plugin_data['Description'] .= sprintf(
[211] Fix | Delete
/* translators: %s: Plugin author. */
[212] Fix | Delete
' <cite>' . __( 'By %s.' ) . '</cite>',
[213] Fix | Delete
$plugin_data['Author']
[214] Fix | Delete
);
[215] Fix | Delete
}
[216] Fix | Delete
}
[217] Fix | Delete
[218] Fix | Delete
return $plugin_data;
[219] Fix | Delete
}
[220] Fix | Delete
[221] Fix | Delete
/**
[222] Fix | Delete
* Get a list of a plugin's files.
[223] Fix | Delete
*
[224] Fix | Delete
* @since 2.8.0
[225] Fix | Delete
*
[226] Fix | Delete
* @param string $plugin Path to the plugin file relative to the plugins directory.
[227] Fix | Delete
* @return string[] Array of file names relative to the plugin root.
[228] Fix | Delete
*/
[229] Fix | Delete
function get_plugin_files( $plugin ) {
[230] Fix | Delete
$plugin_file = WP_PLUGIN_DIR . '/' . $plugin;
[231] Fix | Delete
$dir = dirname( $plugin_file );
[232] Fix | Delete
[233] Fix | Delete
$plugin_files = array( plugin_basename( $plugin_file ) );
[234] Fix | Delete
[235] Fix | Delete
if ( is_dir( $dir ) && WP_PLUGIN_DIR !== $dir ) {
[236] Fix | Delete
[237] Fix | Delete
/**
[238] Fix | Delete
* Filters the array of excluded directories and files while scanning the folder.
[239] Fix | Delete
*
[240] Fix | Delete
* @since 4.9.0
[241] Fix | Delete
*
[242] Fix | Delete
* @param string[] $exclusions Array of excluded directories and files.
[243] Fix | Delete
*/
[244] Fix | Delete
$exclusions = (array) apply_filters( 'plugin_files_exclusions', array( 'CVS', 'node_modules', 'vendor', 'bower_components' ) );
[245] Fix | Delete
[246] Fix | Delete
$list_files = list_files( $dir, 100, $exclusions );
[247] Fix | Delete
$list_files = array_map( 'plugin_basename', $list_files );
[248] Fix | Delete
[249] Fix | Delete
$plugin_files = array_merge( $plugin_files, $list_files );
[250] Fix | Delete
$plugin_files = array_values( array_unique( $plugin_files ) );
[251] Fix | Delete
}
[252] Fix | Delete
[253] Fix | Delete
return $plugin_files;
[254] Fix | Delete
}
[255] Fix | Delete
[256] Fix | Delete
/**
[257] Fix | Delete
* Check the plugins directory and retrieve all plugin files with plugin data.
[258] Fix | Delete
*
[259] Fix | Delete
* WordPress only supports plugin files in the base plugins directory
[260] Fix | Delete
* (wp-content/plugins) and in one directory above the plugins directory
[261] Fix | Delete
* (wp-content/plugins/my-plugin). The file it looks for has the plugin data
[262] Fix | Delete
* and must be found in those two locations. It is recommended to keep your
[263] Fix | Delete
* plugin files in their own directories.
[264] Fix | Delete
*
[265] Fix | Delete
* The file with the plugin data is the file that will be included and therefore
[266] Fix | Delete
* needs to have the main execution for the plugin. This does not mean
[267] Fix | Delete
* everything must be contained in the file and it is recommended that the file
[268] Fix | Delete
* be split for maintainability. Keep everything in one file for extreme
[269] Fix | Delete
* optimization purposes.
[270] Fix | Delete
*
[271] Fix | Delete
* @since 1.5.0
[272] Fix | Delete
*
[273] Fix | Delete
* @param string $plugin_folder Optional. Relative path to single plugin folder.
[274] Fix | Delete
* @return array[] Array of arrays of plugin data, keyed by plugin file name. See `get_plugin_data()`.
[275] Fix | Delete
*/
[276] Fix | Delete
function get_plugins( $plugin_folder = '' ) {
[277] Fix | Delete
[278] Fix | Delete
$cache_plugins = wp_cache_get( 'plugins', 'plugins' );
[279] Fix | Delete
if ( ! $cache_plugins ) {
[280] Fix | Delete
$cache_plugins = array();
[281] Fix | Delete
}
[282] Fix | Delete
[283] Fix | Delete
if ( isset( $cache_plugins[ $plugin_folder ] ) ) {
[284] Fix | Delete
return $cache_plugins[ $plugin_folder ];
[285] Fix | Delete
}
[286] Fix | Delete
[287] Fix | Delete
$wp_plugins = array();
[288] Fix | Delete
$plugin_root = WP_PLUGIN_DIR;
[289] Fix | Delete
if ( ! empty( $plugin_folder ) ) {
[290] Fix | Delete
$plugin_root .= $plugin_folder;
[291] Fix | Delete
}
[292] Fix | Delete
[293] Fix | Delete
// Files in wp-content/plugins directory.
[294] Fix | Delete
$plugins_dir = @ opendir( $plugin_root );
[295] Fix | Delete
$plugin_files = array();
[296] Fix | Delete
[297] Fix | Delete
if ( $plugins_dir ) {
[298] Fix | Delete
while ( ( $file = readdir( $plugins_dir ) ) !== false ) {
[299] Fix | Delete
if ( '.' === substr( $file, 0, 1 ) ) {
[300] Fix | Delete
continue;
[301] Fix | Delete
}
[302] Fix | Delete
[303] Fix | Delete
if ( is_dir( $plugin_root . '/' . $file ) ) {
[304] Fix | Delete
$plugins_subdir = @ opendir( $plugin_root . '/' . $file );
[305] Fix | Delete
[306] Fix | Delete
if ( $plugins_subdir ) {
[307] Fix | Delete
while ( ( $subfile = readdir( $plugins_subdir ) ) !== false ) {
[308] Fix | Delete
if ( '.' === substr( $subfile, 0, 1 ) ) {
[309] Fix | Delete
continue;
[310] Fix | Delete
}
[311] Fix | Delete
[312] Fix | Delete
if ( '.php' === substr( $subfile, -4 ) ) {
[313] Fix | Delete
$plugin_files[] = "$file/$subfile";
[314] Fix | Delete
}
[315] Fix | Delete
}
[316] Fix | Delete
[317] Fix | Delete
closedir( $plugins_subdir );
[318] Fix | Delete
}
[319] Fix | Delete
} else {
[320] Fix | Delete
if ( '.php' === substr( $file, -4 ) ) {
[321] Fix | Delete
$plugin_files[] = $file;
[322] Fix | Delete
}
[323] Fix | Delete
}
[324] Fix | Delete
}
[325] Fix | Delete
[326] Fix | Delete
closedir( $plugins_dir );
[327] Fix | Delete
}
[328] Fix | Delete
[329] Fix | Delete
if ( empty( $plugin_files ) ) {
[330] Fix | Delete
return $wp_plugins;
[331] Fix | Delete
}
[332] Fix | Delete
[333] Fix | Delete
foreach ( $plugin_files as $plugin_file ) {
[334] Fix | Delete
if ( ! is_readable( "$plugin_root/$plugin_file" ) ) {
[335] Fix | Delete
continue;
[336] Fix | Delete
}
[337] Fix | Delete
[338] Fix | Delete
// Do not apply markup/translate as it will be cached.
[339] Fix | Delete
$plugin_data = get_plugin_data( "$plugin_root/$plugin_file", false, false );
[340] Fix | Delete
[341] Fix | Delete
if ( empty( $plugin_data['Name'] ) ) {
[342] Fix | Delete
continue;
[343] Fix | Delete
}
[344] Fix | Delete
[345] Fix | Delete
$wp_plugins[ plugin_basename( $plugin_file ) ] = $plugin_data;
[346] Fix | Delete
}
[347] Fix | Delete
[348] Fix | Delete
uasort( $wp_plugins, '_sort_uname_callback' );
[349] Fix | Delete
[350] Fix | Delete
$cache_plugins[ $plugin_folder ] = $wp_plugins;
[351] Fix | Delete
wp_cache_set( 'plugins', $cache_plugins, 'plugins' );
[352] Fix | Delete
[353] Fix | Delete
return $wp_plugins;
[354] Fix | Delete
}
[355] Fix | Delete
[356] Fix | Delete
/**
[357] Fix | Delete
* Check the mu-plugins directory and retrieve all mu-plugin files with any plugin data.
[358] Fix | Delete
*
[359] Fix | Delete
* WordPress only includes mu-plugin files in the base mu-plugins directory (wp-content/mu-plugins).
[360] Fix | Delete
*
[361] Fix | Delete
* @since 3.0.0
[362] Fix | Delete
* @return array[] Array of arrays of mu-plugin data, keyed by plugin file name. See `get_plugin_data()`.
[363] Fix | Delete
*/
[364] Fix | Delete
function get_mu_plugins() {
[365] Fix | Delete
$wp_plugins = array();
[366] Fix | Delete
$plugin_files = array();
[367] Fix | Delete
[368] Fix | Delete
if ( ! is_dir( WPMU_PLUGIN_DIR ) ) {
[369] Fix | Delete
return $wp_plugins;
[370] Fix | Delete
}
[371] Fix | Delete
[372] Fix | Delete
// Files in wp-content/mu-plugins directory.
[373] Fix | Delete
$plugins_dir = @opendir( WPMU_PLUGIN_DIR );
[374] Fix | Delete
if ( $plugins_dir ) {
[375] Fix | Delete
while ( ( $file = readdir( $plugins_dir ) ) !== false ) {
[376] Fix | Delete
if ( '.php' === substr( $file, -4 ) ) {
[377] Fix | Delete
$plugin_files[] = $file;
[378] Fix | Delete
}
[379] Fix | Delete
}
[380] Fix | Delete
} else {
[381] Fix | Delete
return $wp_plugins;
[382] Fix | Delete
}
[383] Fix | Delete
[384] Fix | Delete
closedir( $plugins_dir );
[385] Fix | Delete
[386] Fix | Delete
if ( empty( $plugin_files ) ) {
[387] Fix | Delete
return $wp_plugins;
[388] Fix | Delete
}
[389] Fix | Delete
[390] Fix | Delete
foreach ( $plugin_files as $plugin_file ) {
[391] Fix | Delete
if ( ! is_readable( WPMU_PLUGIN_DIR . "/$plugin_file" ) ) {
[392] Fix | Delete
continue;
[393] Fix | Delete
}
[394] Fix | Delete
[395] Fix | Delete
// Do not apply markup/translate as it will be cached.
[396] Fix | Delete
$plugin_data = get_plugin_data( WPMU_PLUGIN_DIR . "/$plugin_file", false, false );
[397] Fix | Delete
[398] Fix | Delete
if ( empty( $plugin_data['Name'] ) ) {
[399] Fix | Delete
$plugin_data['Name'] = $plugin_file;
[400] Fix | Delete
}
[401] Fix | Delete
[402] Fix | Delete
$wp_plugins[ $plugin_file ] = $plugin_data;
[403] Fix | Delete
}
[404] Fix | Delete
[405] Fix | Delete
if ( isset( $wp_plugins['index.php'] ) && filesize( WPMU_PLUGIN_DIR . '/index.php' ) <= 30 ) {
[406] Fix | Delete
// Silence is golden.
[407] Fix | Delete
unset( $wp_plugins['index.php'] );
[408] Fix | Delete
}
[409] Fix | Delete
[410] Fix | Delete
uasort( $wp_plugins, '_sort_uname_callback' );
[411] Fix | Delete
[412] Fix | Delete
return $wp_plugins;
[413] Fix | Delete
}
[414] Fix | Delete
[415] Fix | Delete
/**
[416] Fix | Delete
* Callback to sort array by a 'Name' key.
[417] Fix | Delete
*
[418] Fix | Delete
* @since 3.1.0
[419] Fix | Delete
*
[420] Fix | Delete
* @access private
[421] Fix | Delete
*
[422] Fix | Delete
* @param array $a array with 'Name' key.
[423] Fix | Delete
* @param array $b array with 'Name' key.
[424] Fix | Delete
* @return int Return 0 or 1 based on two string comparison.
[425] Fix | Delete
*/
[426] Fix | Delete
function _sort_uname_callback( $a, $b ) {
[427] Fix | Delete
return strnatcasecmp( $a['Name'], $b['Name'] );
[428] Fix | Delete
}
[429] Fix | Delete
[430] Fix | Delete
/**
[431] Fix | Delete
* Check the wp-content directory and retrieve all drop-ins with any plugin data.
[432] Fix | Delete
*
[433] Fix | Delete
* @since 3.0.0
[434] Fix | Delete
* @return array[] Array of arrays of dropin plugin data, keyed by plugin file name. See `get_plugin_data()`.
[435] Fix | Delete
*/
[436] Fix | Delete
function get_dropins() {
[437] Fix | Delete
$dropins = array();
[438] Fix | Delete
$plugin_files = array();
[439] Fix | Delete
[440] Fix | Delete
$_dropins = _get_dropins();
[441] Fix | Delete
[442] Fix | Delete
// Files in wp-content directory.
[443] Fix | Delete
$plugins_dir = @opendir( WP_CONTENT_DIR );
[444] Fix | Delete
if ( $plugins_dir ) {
[445] Fix | Delete
while ( ( $file = readdir( $plugins_dir ) ) !== false ) {
[446] Fix | Delete
if ( isset( $_dropins[ $file ] ) ) {
[447] Fix | Delete
$plugin_files[] = $file;
[448] Fix | Delete
}
[449] Fix | Delete
}
[450] Fix | Delete
} else {
[451] Fix | Delete
return $dropins;
[452] Fix | Delete
}
[453] Fix | Delete
[454] Fix | Delete
closedir( $plugins_dir );
[455] Fix | Delete
[456] Fix | Delete
if ( empty( $plugin_files ) ) {
[457] Fix | Delete
return $dropins;
[458] Fix | Delete
}
[459] Fix | Delete
[460] Fix | Delete
foreach ( $plugin_files as $plugin_file ) {
[461] Fix | Delete
if ( ! is_readable( WP_CONTENT_DIR . "/$plugin_file" ) ) {
[462] Fix | Delete
continue;
[463] Fix | Delete
}
[464] Fix | Delete
[465] Fix | Delete
// Do not apply markup/translate as it will be cached.
[466] Fix | Delete
$plugin_data = get_plugin_data( WP_CONTENT_DIR . "/$plugin_file", false, false );
[467] Fix | Delete
[468] Fix | Delete
if ( empty( $plugin_data['Name'] ) ) {
[469] Fix | Delete
$plugin_data['Name'] = $plugin_file;
[470] Fix | Delete
}
[471] Fix | Delete
[472] Fix | Delete
$dropins[ $plugin_file ] = $plugin_data;
[473] Fix | Delete
}
[474] Fix | Delete
[475] Fix | Delete
uksort( $dropins, 'strnatcasecmp' );
[476] Fix | Delete
[477] Fix | Delete
return $dropins;
[478] Fix | Delete
}
[479] Fix | Delete
[480] Fix | Delete
/**
[481] Fix | Delete
* Returns drop-ins that WordPress uses.
[482] Fix | Delete
*
[483] Fix | Delete
* Includes Multisite drop-ins only when is_multisite()
[484] Fix | Delete
*
[485] Fix | Delete
* @since 3.0.0
[486] Fix | Delete
* @return array[] Key is file name. The value is an array, with the first value the
[487] Fix | Delete
* purpose of the drop-in and the second value the name of the constant that must be
[488] Fix | Delete
* true for the drop-in to be used, or true if no constant is required.
[489] Fix | Delete
*/
[490] Fix | Delete
function _get_dropins() {
[491] Fix | Delete
$dropins = array(
[492] Fix | Delete
'advanced-cache.php' => array( __( 'Advanced caching plugin.' ), 'WP_CACHE' ), // WP_CACHE
[493] Fix | Delete
'db.php' => array( __( 'Custom database class.' ), true ), // Auto on load.
[494] Fix | Delete
'db-error.php' => array( __( 'Custom database error message.' ), true ), // Auto on error.
[495] Fix | Delete
'install.php' => array( __( 'Custom installation script.' ), true ), // Auto on installation.
[496] Fix | Delete
'maintenance.php' => array( __( 'Custom maintenance message.' ), true ), // Auto on maintenance.
[497] Fix | Delete
'object-cache.php' => array( __( 'External object cache.' ), true ), // Auto on load.
[498] Fix | Delete
'php-error.php' => array( __( 'Custom PHP error message.' ), true ), // Auto on error.
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function