Changes from trunk/wp-admin/includes/plugin.php at r17310 to branches/3.0/wp-admin/includes/plugin.php at r15745
- File:
-
- 1 edited
-
branches/3.0/wp-admin/includes/plugin.php (modified) (50 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/3.0/wp-admin/includes/plugin.php
r17310 r15745 101 101 if ( $markup || $translate ) 102 102 $plugin_data = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup, $translate ); 103 else104 $plugin_data['AuthorName'] = $plugin_data['Author'];105 103 106 104 return $plugin_data; … … 109 107 function _get_plugin_data_markup_translate($plugin_file, $plugin_data, $markup = true, $translate = true) { 110 108 111 //Translate fields 109 //Translate fields30 112 110 if ( $translate && ! empty($plugin_data['TextDomain']) ) { 113 111 if ( ! empty( $plugin_data['DomainPath'] ) ) … … 120 118 } 121 119 122 $plugins_allowedtags = array(123 'a' => array( 'href' => array(), 'title' => array() ),124 'abbr' => array( 'title' => array() ),125 'acronym' => array( 'title' => array() ),126 'code' => array(),127 'em' => array(),128 'strong' => array(),129 );130 131 $plugin_data['AuthorName'] = $plugin_data['Author'] = wp_kses( $plugin_data['Author'], $plugins_allowedtags );132 133 120 //Apply Markup 134 121 if ( $markup ) { 135 122 if ( ! empty($plugin_data['PluginURI']) && ! empty($plugin_data['Name']) ) 136 $plugin_data['Title'] = '<a href="' . $plugin_data['PluginURI'] . '" title="' . esc_attr__( 'Visit plugin homepage' ) . '">' . $plugin_data['Name'] . '</a>';123 $plugin_data['Title'] = '<a href="' . $plugin_data['PluginURI'] . '" title="' . __( 'Visit plugin homepage' ) . '">' . $plugin_data['Name'] . '</a>'; 137 124 else 138 125 $plugin_data['Title'] = $plugin_data['Name']; 139 126 140 127 if ( ! empty($plugin_data['AuthorURI']) && ! empty($plugin_data['Author']) ) 141 $plugin_data['Author'] = '<a href="' . $plugin_data['AuthorURI'] . '" title="' . esc_attr__( 'Visit author homepage' ) . '">' . $plugin_data['Author'] . '</a>';128 $plugin_data['Author'] = '<a href="' . $plugin_data['AuthorURI'] . '" title="' . __( 'Visit author homepage' ) . '">' . $plugin_data['Author'] . '</a>'; 142 129 143 130 $plugin_data['Description'] = wptexturize( $plugin_data['Description'] ); … … 146 133 } 147 134 148 // Sanitize all displayed data. Author and AuthorName sanitized above. 149 $plugin_data['Title'] = wp_kses( $plugin_data['Title'], $plugins_allowedtags ); 150 $plugin_data['Version'] = wp_kses( $plugin_data['Version'], $plugins_allowedtags ); 151 $plugin_data['Description'] = wp_kses( $plugin_data['Description'], $plugins_allowedtags ); 152 $plugin_data['Name'] = wp_kses( $plugin_data['Name'], $plugins_allowedtags ); 135 $plugins_allowedtags = array('a' => array('href' => array(),'title' => array()),'abbr' => array('title' => array()),'acronym' => array('title' => array()),'code' => array(),'em' => array(),'strong' => array()); 136 137 // Sanitize all displayed data 138 $plugin_data['Title'] = wp_kses($plugin_data['Title'], $plugins_allowedtags); 139 $plugin_data['Version'] = wp_kses($plugin_data['Version'], $plugins_allowedtags); 140 $plugin_data['Description'] = wp_kses($plugin_data['Description'], $plugins_allowedtags); 141 $plugin_data['Author'] = wp_kses($plugin_data['Author'], $plugins_allowedtags); 153 142 154 143 return $plugin_data; … … 210 199 * optimization purposes. 211 200 * 212 * @since 1.5.0201 * @since unknown 213 202 * 214 203 * @param string $plugin_folder Optional. Relative path to single plugin folder. … … 272 261 } 273 262 274 uasort( $wp_plugins, '_sort_uname_callback');263 uasort( $wp_plugins, create_function( '$a, $b', 'return strnatcasecmp( $a["Name"], $b["Name"] );' )); 275 264 276 265 $cache_plugins[ $plugin_folder ] = $wp_plugins; … … 324 313 unset( $wp_plugins['index.php'] ); 325 314 326 uasort( $wp_plugins, '_sort_uname_callback');315 uasort( $wp_plugins, create_function( '$a, $b', 'return strnatcasecmp( $a["Name"], $b["Name"] );' )); 327 316 328 317 return $wp_plugins; 329 }330 331 /**332 * Callback to sort array by a 'Name' key.333 *334 * @since 3.1.0335 * @access private336 */337 function _sort_uname_callback( $a, $b ) {338 return strnatcasecmp( $a['Name'], $b['Name'] );339 318 } 340 319 … … 375 354 } 376 355 377 uksort( $dropins, 'strnatcasecmp');356 uksort( $dropins, create_function( '$a, $b', 'return strnatcasecmp( $a, $b );' )); 378 357 379 358 return $dropins; … … 423 402 424 403 /** 425 * Check whether the plugin is inactive.426 *427 * Reverse of is_plugin_active(). Used as a callback.428 *429 * @since 3.1.0430 * @see is_plugin_active()431 *432 * @param string $plugin Base plugin path from plugins directory.433 * @return bool True if inactive. False if active.434 */435 function is_plugin_inactive( $plugin ) {436 return ! is_plugin_active( $plugin );437 }438 439 /**440 404 * Check whether the plugin is active for the entire network. 441 405 * … … 465 429 * @since 3.0.0 466 430 * 467 * @param string $pluginPlugin to check468 * @return bool True if plugin is network only, false otherwise.431 * @param $file Plugin to check 432 * $return bool True if plugin is network only, false otherwise. 469 433 */ 470 434 function is_network_only_plugin( $plugin ) { … … 493 457 * ensure that the success redirection will update the error redirection. 494 458 * 495 * @since 2.5.0459 * @since unknown 496 460 * 497 461 * @param string $plugin Plugin path to main plugin file with plugin data. 498 462 * @param string $redirect Optional. URL to redirect to. 499 * @param bool $network_wide Whether to enable the plugin for all sites in the 500 * network or just the current site. Multisite only. Default is false. 501 * @param bool $silent Prevent calling activation hooks. Optional, default is false. 463 * @param bool $network_wide Whether to enable the plugin for all sites in the network or just the current site. Multisite only. Default is false. 502 464 * @return WP_Error|null WP_Error on invalid file or null on success. 503 465 */ 504 function activate_plugin( $plugin, $redirect = '', $network_wide = false , $silent = false) {505 $plugin = plugin_basename( trim( $plugin ) );466 function activate_plugin( $plugin, $redirect = '', $network_wide = false) { 467 $plugin = plugin_basename( trim( $plugin ) ); 506 468 507 469 if ( is_multisite() && ( $network_wide || is_network_only_plugin($plugin) ) ) { … … 520 482 wp_redirect(add_query_arg('_error_nonce', wp_create_nonce('plugin-activation-error_' . $plugin), $redirect)); // we'll override this later if the plugin can be included without fatal error 521 483 ob_start(); 522 include_once(WP_PLUGIN_DIR . '/' . $plugin); 523 524 if ( ! $silent ) { 525 do_action( 'activate_plugin', $plugin, $network_wide ); 526 do_action( 'activate_' . $plugin, $network_wide ); 527 } 528 484 include(WP_PLUGIN_DIR . '/' . $plugin); 485 do_action( 'activate_plugin', trim( $plugin) ); 486 do_action( 'activate_' . trim( $plugin ) ); 529 487 if ( $network_wide ) { 530 488 $current[$plugin] = time(); … … 535 493 update_option('active_plugins', $current); 536 494 } 537 538 if ( ! $silent ) { 539 do_action( 'activated_plugin', $plugin, $network_wide ); 540 } 541 495 do_action( 'activated_plugin', trim( $plugin) ); 542 496 if ( ob_get_length() > 0 ) { 543 497 $output = ob_get_clean(); … … 556 510 * parameter. 557 511 * 558 * @since 2.5.0512 * @since unknown 559 513 * 560 514 * @param string|array $plugins Single plugin or list of plugins to deactivate. 561 * @param bool $silent Prevent calling deactivation hooks. Default is false.515 * @param bool $silent Optional, default is false. Prevent calling deactivate hook. 562 516 */ 563 517 function deactivate_plugins( $plugins, $silent = false ) { 564 if ( is_multisite() ) 565 $network_current = get_site_option( 'active_sitewide_plugins', array() ); 518 $network_current = get_site_option( 'active_sitewide_plugins', array() ); 566 519 $current = get_option( 'active_plugins', array() ); 567 520 $do_blog = $do_network = false; 568 521 569 522 foreach ( (array) $plugins as $plugin ) { 570 $plugin = plugin_basename( trim( $plugin ));523 $plugin = plugin_basename($plugin); 571 524 if ( ! is_plugin_active($plugin) ) 572 525 continue; 573 574 $network_wide = is_plugin_active_for_network( $plugin );575 576 526 if ( ! $silent ) 577 do_action( 'deactivate_plugin', $plugin, $network_wide ); 578 579 if ( $network_wide ) { 527 do_action( 'deactivate_plugin', trim( $plugin ) ); 528 529 if ( is_plugin_active_for_network($plugin) ) { 530 // Deactivate network wide 580 531 $do_network = true; 581 532 unset( $network_current[ $plugin ] ); 582 533 } else { 583 $key = array_search( $plugin, $current ); 534 // Deactivate for this blog only 535 $key = array_search( $plugin, (array) $current ); 584 536 if ( false !== $key ) { 585 537 $do_blog = true; … … 588 540 } 589 541 542 //Used by Plugin updater to internally deactivate plugin, however, not to notify plugins of the fact to prevent plugin output. 590 543 if ( ! $silent ) { 591 do_action( 'deactivate_' . $plugin, $network_wide);592 do_action( 'deactivated_plugin', $plugin, $network_wide);544 do_action( 'deactivate_' . trim( $plugin ) ); 545 do_action( 'deactivated_plugin', trim( $plugin ) ); 593 546 } 594 547 } … … 608 561 * The execution will be halted as soon as one of the plugins has an error. 609 562 * 610 * @since 2.6.0563 * @since unknown 611 564 * 612 565 * @param string|array $plugins 613 566 * @param string $redirect Redirect to page after successful activation. 614 567 * @param bool $network_wide Whether to enable the plugin for all sites in the network. 615 * @param bool $silent Prevent calling activation hooks. Default is false.616 568 * @return bool|WP_Error True when finished or WP_Error if there were errors during a plugin activation. 617 569 */ 618 function activate_plugins( $plugins, $redirect = '', $network_wide = false, $silent = false) {570 function activate_plugins($plugins, $redirect = '', $network_wide) { 619 571 if ( !is_array($plugins) ) 620 572 $plugins = array($plugins); 621 573 622 574 $errors = array(); 623 foreach ( $plugins as $plugin ) {575 foreach ( (array) $plugins as $plugin ) { 624 576 if ( !empty($redirect) ) 625 577 $redirect = add_query_arg('plugin', $plugin, $redirect); 626 $result = activate_plugin($plugin, $redirect, $network_wide , $silent);578 $result = activate_plugin($plugin, $redirect, $network_wide); 627 579 if ( is_wp_error($result) ) 628 580 $errors[$plugin] = $result; … … 641 593 * completed. 642 594 * 643 * @since 2.6.0595 * @since unknown 644 596 * 645 597 * @param array $plugins List of plugin … … 658 610 659 611 ob_start(); 660 $url = wp_nonce_url('plugins.php?action=delete-selected&verify-delete=1&' . implode('&', $checked), 'bulk- plugins');612 $url = wp_nonce_url('plugins.php?action=delete-selected&verify-delete=1&' . implode('&', $checked), 'bulk-manage-plugins'); 661 613 if ( false === ($credentials = request_filesystem_credentials($url)) ) { 662 614 $data = ob_get_contents(); … … 733 685 * returns an array of deactivated ones. 734 686 * 735 * @since 2.5.0687 * @since unknown 736 688 * @return array invalid plugins, plugin as key, error as value 737 689 */ … … 770 722 * Checks that the file exists and {@link validate_file() is valid file}. 771 723 * 772 * @since 2.5.0724 * @since unknown 773 725 * 774 726 * @param string $plugin Plugin Path … … 864 816 * @param string $icon_url The url to the icon to be used for this menu 865 817 * @param int $position The position in the menu order this one should appear 866 *867 * @return string The resulting page's hook_suffix868 818 */ 869 819 function add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '', $position = NULL ) { … … 914 864 * @param callback $function The function to be called to output the content for this page. 915 865 * @param string $icon_url The url to the icon to be used for this menu 916 *917 * @return string The resulting page's hook_suffix918 866 */ 919 867 function add_object_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '') { … … 940 888 * @param callback $function The function to be called to output the content for this page. 941 889 * @param string $icon_url The url to the icon to be used for this menu 942 *943 * @return string The resulting page's hook_suffix944 890 */ 945 891 function add_utility_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '') { … … 966 912 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu) 967 913 * @param callback $function The function to be called to output the content for this page. 968 *969 * @return string The resulting page's hook_suffix970 914 */ 971 915 function add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { … … 1018 962 /** 1019 963 * Add sub menu page to the tools main menu. 1020 *964 * 1021 965 * This function takes a capability which will be used to determine whether 1022 966 * or not a page is included in the menu. … … 1030 974 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu) 1031 975 * @param callback $function The function to be called to output the content for this page. 1032 *1033 * @return string The resulting page's hook_suffix1034 976 */ 1035 977 function add_management_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { … … 1039 981 /** 1040 982 * Add sub menu page to the options main menu. 1041 *983 * 1042 984 * This function takes a capability which will be used to determine whether 1043 985 * or not a page is included in the menu. … … 1051 993 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu) 1052 994 * @param callback $function The function to be called to output the content for this page. 1053 *1054 * @return string The resulting page's hook_suffix1055 995 */ 1056 996 function add_options_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { … … 1060 1000 /** 1061 1001 * Add sub menu page to the themes main menu. 1062 *1002 * 1063 1003 * This function takes a capability which will be used to determine whether 1064 1004 * or not a page is included in the menu. … … 1072 1012 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu) 1073 1013 * @param callback $function The function to be called to output the content for this page. 1074 *1075 * @return string The resulting page's hook_suffix1076 1014 */ 1077 1015 function add_theme_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { … … 1081 1019 /** 1082 1020 * Add sub menu page to the plugins main menu. 1083 *1021 * 1084 1022 * This function takes a capability which will be used to determine whether 1085 1023 * or not a page is included in the menu. … … 1093 1031 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu) 1094 1032 * @param callback $function The function to be called to output the content for this page. 1095 *1096 * @return string The resulting page's hook_suffix1097 1033 */ 1098 1034 function add_plugins_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { … … 1102 1038 /** 1103 1039 * Add sub menu page to the Users/Profile main menu. 1104 *1040 * 1105 1041 * This function takes a capability which will be used to determine whether 1106 1042 * or not a page is included in the menu. … … 1114 1050 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu) 1115 1051 * @param callback $function The function to be called to output the content for this page. 1116 *1117 * @return string The resulting page's hook_suffix1118 1052 */ 1119 1053 function add_users_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { … … 1126 1060 /** 1127 1061 * Add sub menu page to the Dashboard main menu. 1128 *1062 * 1129 1063 * This function takes a capability which will be used to determine whether 1130 1064 * or not a page is included in the menu. … … 1138 1072 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu) 1139 1073 * @param callback $function The function to be called to output the content for this page. 1140 *1141 * @return string The resulting page's hook_suffix1142 1074 */ 1143 1075 function add_dashboard_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { … … 1147 1079 /** 1148 1080 * Add sub menu page to the posts main menu. 1149 *1081 * 1150 1082 * This function takes a capability which will be used to determine whether 1151 1083 * or not a page is included in the menu. … … 1159 1091 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu) 1160 1092 * @param callback $function The function to be called to output the content for this page. 1161 *1162 * @return string The resulting page's hook_suffix1163 1093 */ 1164 1094 function add_posts_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { … … 1168 1098 /** 1169 1099 * Add sub menu page to the media main menu. 1170 *1100 * 1171 1101 * This function takes a capability which will be used to determine whether 1172 1102 * or not a page is included in the menu. … … 1180 1110 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu) 1181 1111 * @param callback $function The function to be called to output the content for this page. 1182 *1183 * @return string The resulting page's hook_suffix1184 1112 */ 1185 1113 function add_media_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { … … 1189 1117 /** 1190 1118 * Add sub menu page to the links main menu. 1191 *1119 * 1192 1120 * This function takes a capability which will be used to determine whether 1193 1121 * or not a page is included in the menu. … … 1201 1129 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu) 1202 1130 * @param callback $function The function to be called to output the content for this page. 1203 *1204 * @return string The resulting page's hook_suffix1205 1131 */ 1206 1132 function add_links_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { … … 1210 1136 /** 1211 1137 * Add sub menu page to the pages main menu. 1212 *1138 * 1213 1139 * This function takes a capability which will be used to determine whether 1214 1140 * or not a page is included in the menu. … … 1222 1148 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu) 1223 1149 * @param callback $function The function to be called to output the content for this page. 1224 * 1225 * @return string The resulting page's hook_suffix 1226 */ 1150 */ 1227 1151 function add_pages_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { 1228 1152 return add_submenu_page( 'edit.php?post_type=page', $page_title, $menu_title, $capability, $menu_slug, $function ); … … 1231 1155 /** 1232 1156 * Add sub menu page to the comments main menu. 1233 *1157 * 1234 1158 * This function takes a capability which will be used to determine whether 1235 1159 * or not a page is included in the menu. … … 1243 1167 * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu) 1244 1168 * @param callback $function The function to be called to output the content for this page. 1245 * 1246 * @return string The resulting page's hook_suffix 1247 */ 1169 */ 1248 1170 function add_comments_page( $page_title, $menu_title, $capability, $menu_slug, $function = '' ) { 1249 1171 return add_submenu_page( 'edit-comments.php', $page_title, $menu_title, $capability, $menu_slug, $function ); 1250 }1251 1252 1253 /**1254 * Remove a top level admin menu1255 *1256 * @since 3.1.01257 *1258 * @param string $menu_slug The slug of the menu1259 * @return array|bool The removed menu on success, False if not found1260 */1261 function remove_menu_page( $menu_slug ) {1262 global $menu;1263 1264 foreach ( $menu as $i => $item ) {1265 if ( $menu_slug == $item[2] ) {1266 unset( $menu[$i] );1267 return $item;1268 }1269 }1270 1271 return false;1272 }1273 1274 /**1275 * Remove an admin submenu1276 *1277 * @since 3.1.01278 *1279 * @param string $menu_slug The slug for the parent menu1280 * @param string $submenu_slug The slug of the submenu1281 * @return array|bool The removed submenu on success, False if not found1282 */1283 function remove_submenu_page( $menu_slug, $submenu_slug ) {1284 global $submenu;1285 1286 if ( !isset( $submenu[$menu_slug] ) )1287 return false;1288 1289 foreach ( $submenu[$menu_slug] as $i => $item ) {1290 if ( $submenu_slug == $item[2] ) {1291 unset( $submenu[$menu_slug][$i] );1292 return $item;1293 }1294 }1295 1296 return false;1297 1172 } 1298 1173 … … 1312 1187 1313 1188 if ( isset( $_parent_pages[$menu_slug] ) ) { 1314 $parent_slug = $_parent_pages[$menu_slug]; 1315 if ( $parent_slug && ! isset( $_parent_pages[$parent_slug] ) ) { 1316 $url = admin_url( add_query_arg( 'page', $menu_slug, $parent_slug ) ); 1189 if ( $_parent_pages[$menu_slug] ) { 1190 $url = admin_url( add_query_arg( 'page', $menu_slug, $_parent_pages[$menu_slug] ) ); 1317 1191 } else { 1318 $url = admin_url( 'admin.php?page=' . $menu_slug);1192 $url = admin_url('admin.php?page=' . $menu_slug); 1319 1193 } 1320 1194 } else { … … 1640 1514 * {@internal Missing Short Description}} 1641 1515 * 1642 * @since 2.7.01516 * @since unknown 1643 1517 * 1644 1518 * @param unknown_type $options … … 1658 1532 * {@internal Missing Short Description}} 1659 1533 * 1660 * @since 2.7.01534 * @since unknown 1661 1535 * 1662 1536 * @param unknown_type $new_options … … 1689 1563 * {@internal Missing Short Description}} 1690 1564 * 1691 * @since 2.7.01565 * @since unknown 1692 1566 * 1693 1567 * @param unknown_type $del_options
Note: See TracChangeset
for help on using the changeset viewer.