Changes in trunk/wp-admin/includes/plugin.php [18951:20555]
- File:
-
- 1 edited
-
trunk/wp-admin/includes/plugin.php (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/plugin.php
r18951 r20555 66 66 * 67 67 * @param string $plugin_file Path to the plugin file 68 * @param bool $markup If the returned data should have HTML markup applied69 * @param bool $translate If the returned data should be translated68 * @param bool $markup Optional. If the returned data should have HTML markup applied. Defaults to true. 69 * @param bool $translate Optional. If the returned data should be translated. Defaults to true. 70 70 * @return array See above for description. 71 71 */ … … 89 89 90 90 // Site Wide Only is the old header for Network 91 if ( empty( $plugin_data['Network'] ) && ! empty( $plugin_data['_sitewide'] )) {91 if ( ! $plugin_data['Network'] && $plugin_data['_sitewide'] ) { 92 92 _deprecated_argument( __FUNCTION__, '3.0', sprintf( __( 'The <code>%1$s</code> plugin header is deprecated. Use <code>%2$s</code> instead.' ), 'Site Wide Only: true', 'Network: true' ) ); 93 93 $plugin_data['Network'] = $plugin_data['_sitewide']; … … 96 96 unset( $plugin_data['_sitewide'] ); 97 97 98 //For backward compatibility by default Title is the same as Name. 99 $plugin_data['Title'] = $plugin_data['Name']; 100 101 if ( $markup || $translate ) 98 if ( $markup || $translate ) { 102 99 $plugin_data = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup, $translate ); 103 else 100 } else { 101 $plugin_data['Title'] = $plugin_data['Name']; 104 102 $plugin_data['AuthorName'] = $plugin_data['Author']; 103 } 105 104 106 105 return $plugin_data; 107 106 } 108 107 109 function _get_plugin_data_markup_translate($plugin_file, $plugin_data, $markup = true, $translate = true) { 110 111 //Translate fields 112 if ( $translate && ! empty($plugin_data['TextDomain']) ) { 113 if ( ! empty( $plugin_data['DomainPath'] ) ) 114 load_plugin_textdomain($plugin_data['TextDomain'], false, dirname($plugin_file). $plugin_data['DomainPath']); 115 else 116 load_plugin_textdomain($plugin_data['TextDomain'], false, dirname($plugin_file)); 117 118 foreach ( array('Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version') as $field ) 119 $plugin_data[ $field ] = translate($plugin_data[ $field ], $plugin_data['TextDomain']); 120 } 121 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(), 108 /** 109 * Sanitizes plugin data, optionally adds markup, optionally translates. 110 * 111 * @since 2.7.0 112 * @access private 113 * @see get_plugin_data() 114 */ 115 function _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup = true, $translate = true ) { 116 117 // Translate fields 118 if ( $translate ) { 119 if ( $textdomain = $plugin_data['TextDomain'] ) { 120 if ( $plugin_data['DomainPath'] ) 121 load_plugin_textdomain( $textdomain, false, dirname( $plugin_file ) . $plugin_data['DomainPath'] ); 122 else 123 load_plugin_textdomain( $textdomain, false, dirname( $plugin_file ) ); 124 } elseif ( in_array( basename( $plugin_file ), array( 'hello.php', 'akismet.php' ) ) ) { 125 $textdomain = 'default'; 126 } 127 if ( $textdomain ) { 128 foreach ( array( 'Name', 'PluginURI', 'Description', 'Author', 'AuthorURI', 'Version' ) as $field ) 129 $plugin_data[ $field ] = translate( $plugin_data[ $field ], $textdomain ); 130 } 131 } 132 133 // Sanitize fields 134 $allowed_tags = $allowed_tags_in_links = array( 135 'abbr' => array( 'title' => true ), 136 'acronym' => array( 'title' => true ), 137 'code' => true, 138 'em' => true, 139 'strong' => true, 129 140 ); 130 131 $plugin_data['AuthorName'] = $plugin_data['Author'] = wp_kses( $plugin_data['Author'], $plugins_allowedtags ); 132 133 //Apply Markup 141 $allowed_tags['a'] = array( 'href' => true, 'title' => true ); 142 143 // Name is marked up inside <a> tags. Don't allow these. 144 // Author is too, but some plugins have used <a> here (omitting Author URI). 145 $plugin_data['Name'] = wp_kses( $plugin_data['Name'], $allowed_tags_in_links ); 146 $plugin_data['Author'] = wp_kses( $plugin_data['Author'], $allowed_tags ); 147 148 $plugin_data['Description'] = wp_kses( $plugin_data['Description'], $allowed_tags ); 149 $plugin_data['Version'] = wp_kses( $plugin_data['Version'], $allowed_tags ); 150 151 $plugin_data['PluginURI'] = esc_url( $plugin_data['PluginURI'] ); 152 $plugin_data['AuthorURI'] = esc_url( $plugin_data['AuthorURI'] ); 153 154 $plugin_data['Title'] = $plugin_data['Name']; 155 $plugin_data['AuthorName'] = $plugin_data['Author']; 156 157 // Apply markup 134 158 if ( $markup ) { 135 if ( ! empty($plugin_data['PluginURI']) && ! empty($plugin_data['Name']))159 if ( $plugin_data['PluginURI'] && $plugin_data['Name'] ) 136 160 $plugin_data['Title'] = '<a href="' . $plugin_data['PluginURI'] . '" title="' . esc_attr__( 'Visit plugin homepage' ) . '">' . $plugin_data['Name'] . '</a>'; 137 else 138 $plugin_data['Title'] = $plugin_data['Name']; 139 140 if ( ! empty($plugin_data['AuthorURI']) && ! empty($plugin_data['Author']) ) 161 162 if ( $plugin_data['AuthorURI'] && $plugin_data['Author'] ) 141 163 $plugin_data['Author'] = '<a href="' . $plugin_data['AuthorURI'] . '" title="' . esc_attr__( 'Visit author homepage' ) . '">' . $plugin_data['Author'] . '</a>'; 142 164 143 165 $plugin_data['Description'] = wptexturize( $plugin_data['Description'] ); 144 if ( ! empty($plugin_data['Author']) ) 145 $plugin_data['Description'] .= ' <cite>' . sprintf( __('By %s'), $plugin_data['Author'] ) . '.</cite>'; 146 } 147 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 ); 166 167 if ( $plugin_data['Author'] ) 168 $plugin_data['Description'] .= ' <cite>' . sprintf( __('By %s.'), $plugin_data['Author'] ) . '</cite>'; 169 } 153 170 154 171 return $plugin_data; … … 556 573 * 557 574 * @param string|array $plugins Single plugin or list of plugins to deactivate. 575 * @param mixed $network_wide Whether to deactivate the plugin for all sites in the network. 576 * A value of null (the default) will deactivate plugins for both the site and the network. 558 577 * @param bool $silent Prevent calling deactivation hooks. Default is false. 559 578 */ 560 function deactivate_plugins( $plugins, $silent = false ) {579 function deactivate_plugins( $plugins, $silent = false, $network_wide = null ) { 561 580 if ( is_multisite() ) 562 581 $network_current = get_site_option( 'active_sitewide_plugins', array() ); … … 569 588 continue; 570 589 571 $network_ wide =is_plugin_active_for_network( $plugin );590 $network_deactivating = false !== $network_wide && is_plugin_active_for_network( $plugin ); 572 591 573 592 if ( ! $silent ) 574 do_action( 'deactivate_plugin', $plugin, $network_wide ); 575 576 if ( $network_wide ) { 577 $do_network = true; 578 unset( $network_current[ $plugin ] ); 579 } else { 593 do_action( 'deactivate_plugin', $plugin, $network_deactivating ); 594 595 if ( false !== $network_wide ) { 596 if ( is_plugin_active_for_network( $plugin ) ) { 597 $do_network = true; 598 unset( $network_current[ $plugin ] ); 599 } elseif ( $network_wide ) { 600 continue; 601 } 602 } 603 604 if ( true !== $network_wide ) { 580 605 $key = array_search( $plugin, $current ); 581 606 if ( false !== $key ) { … … 586 611 587 612 if ( ! $silent ) { 588 do_action( 'deactivate_' . $plugin, $network_ wide);589 do_action( 'deactivated_plugin', $plugin, $network_ wide);613 do_action( 'deactivate_' . $plugin, $network_deactivating ); 614 do_action( 'deactivated_plugin', $plugin, $network_deactivating ); 590 615 } 591 616 } … … 864 889 * @return string The resulting page's hook_suffix 865 890 */ 866 function add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '', $position = NULL) {891 function add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '', $position = null ) { 867 892 global $menu, $admin_page_hooks, $_registered_pages, $_parent_pages; 868 893 … … 883 908 $new_menu = array( $menu_title, $capability, $menu_slug, $page_title, 'menu-top ' . $hookname, $hookname, $icon_url ); 884 909 885 if ( null === $position )910 if ( null === $position ) 886 911 $menu[] = $new_menu; 887 912 else … … 986 1011 987 1012 // If the parent doesn't already have a submenu, add a link to the parent 988 // as the first item in the submenu. If the submenu file is the same as the989 // parent file someone is trying to link back to the parent manually. In1013 // as the first item in the submenu. If the submenu file is the same as the 1014 // parent file someone is trying to link back to the parent manually. In 990 1015 // this case, don't automatically add a link back to avoid duplication. 991 if (!isset( $submenu[$parent_slug] ) && $menu_slug != $parent_slug ) {1016 if (!isset( $submenu[$parent_slug] ) && $menu_slug != $parent_slug ) { 992 1017 foreach ( (array)$menu as $parent_menu ) { 993 1018 if ( $parent_menu[2] == $parent_slug && current_user_can( $parent_menu[1] ) ) … … 1003 1028 1004 1029 $_registered_pages[$hookname] = true; 1005 // backwards-compatibility for plugins using add_management page. See wp-admin/admin.php for redirect from edit.php to tools.php1030 // backwards-compatibility for plugins using add_management page. See wp-admin/admin.php for redirect from edit.php to tools.php 1006 1031 if ( 'tools.php' == $parent_slug ) 1007 1032 $_registered_pages[get_plugin_page_hookname( $menu_slug, 'edit.php')] = true; … … 1246 1271 return add_submenu_page( 'edit-comments.php', $page_title, $menu_title, $capability, $menu_slug, $function ); 1247 1272 } 1248 1249 1273 1250 1274 /** … … 1590 1614 * @since 2.7.0 1591 1615 * 1592 * @param string $option_group A settings group name. Should correspond to a whitelisted option key name.1616 * @param string $option_group A settings group name. Should correspond to a whitelisted option key name. 1593 1617 * Default whitelisted option key names include "general," "discussion," and "reading," among others. 1594 1618 * @param string $option_name The name of an option to sanitize and save. … … 1716 1740 * @since 2.7.0 1717 1741 * 1718 * @param string $option_group A settings group name. This should match the group name used in register_setting().1742 * @param string $option_group A settings group name. This should match the group name used in register_setting(). 1719 1743 */ 1720 1744 function settings_fields($option_group) { … … 1723 1747 wp_nonce_field("$option_group-options"); 1724 1748 } 1725 1726 ?>
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)