web/wp-admin/includes/plugin.php
changeset 204 09a1c134465b
parent 194 32102edaa81b
equal deleted inserted replaced
203:f507feede89a 204:09a1c134465b
   571  * parameter.
   571  * parameter.
   572  *
   572  *
   573  * @since 2.5.0
   573  * @since 2.5.0
   574  *
   574  *
   575  * @param string|array $plugins Single plugin or list of plugins to deactivate.
   575  * @param string|array $plugins Single plugin or list of plugins to deactivate.
       
   576  * @param bool $silent Prevent calling deactivation hooks. Default is false.
   576  * @param mixed $network_wide Whether to deactivate the plugin for all sites in the network.
   577  * @param mixed $network_wide Whether to deactivate the plugin for all sites in the network.
   577  * 	A value of null (the default) will deactivate plugins for both the site and the network.
   578  * 	A value of null (the default) will deactivate plugins for both the site and the network.
   578  * @param bool $silent Prevent calling deactivation hooks. Default is false.
       
   579  */
   579  */
   580 function deactivate_plugins( $plugins, $silent = false, $network_wide = null ) {
   580 function deactivate_plugins( $plugins, $silent = false, $network_wide = null ) {
   581 	if ( is_multisite() )
   581 	if ( is_multisite() )
   582 		$network_current = get_site_option( 'active_sitewide_plugins', array() );
   582 		$network_current = get_site_option( 'active_sitewide_plugins', array() );
   583 	$current = get_option( 'active_plugins', array() );
   583 	$current = get_option( 'active_plugins', array() );
   604 
   604 
   605 		if ( true !== $network_wide ) {
   605 		if ( true !== $network_wide ) {
   606 			$key = array_search( $plugin, $current );
   606 			$key = array_search( $plugin, $current );
   607 			if ( false !== $key ) {
   607 			if ( false !== $key ) {
   608 				$do_blog = true;
   608 				$do_blog = true;
   609 				array_splice( $current, $key, 1 );
   609 				unset( $current[ $key ] );
   610 			}
   610 			}
   611 		}
   611 		}
   612 
   612 
   613 		if ( ! $silent ) {
   613 		if ( ! $silent ) {
   614 			do_action( 'deactivate_' . $plugin, $network_deactivating );
   614 			do_action( 'deactivate_' . $plugin, $network_deactivating );
   882  * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
   882  * @param string $page_title The text to be displayed in the title tags of the page when the menu is selected
   883  * @param string $menu_title The text to be used for the menu
   883  * @param string $menu_title The text to be used for the menu
   884  * @param string $capability The capability required for this menu to be displayed to the user.
   884  * @param string $capability The capability required for this menu to be displayed to the user.
   885  * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
   885  * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu)
   886  * @param callback $function The function to be called to output the content for this page.
   886  * @param callback $function The function to be called to output the content for this page.
   887  * @param string $icon_url The url to the icon to be used for this menu
   887  * @param string $icon_url The url to the icon to be used for this menu. Using 'none' would leave div.wp-menu-image empty
       
   888  *                         so an icon can be added as background with CSS.
   888  * @param int $position The position in the menu order this one should appear
   889  * @param int $position The position in the menu order this one should appear
   889  *
   890  *
   890  * @return string The resulting page's hook_suffix
   891  * @return string The resulting page's hook_suffix
   891  */
   892  */
   892 function add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '', $position = null ) {
   893 function add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function = '', $icon_url = '', $position = null ) {
   899 	$hookname = get_plugin_page_hookname( $menu_slug, '' );
   900 	$hookname = get_plugin_page_hookname( $menu_slug, '' );
   900 
   901 
   901 	if ( !empty( $function ) && !empty( $hookname ) && current_user_can( $capability ) )
   902 	if ( !empty( $function ) && !empty( $hookname ) && current_user_can( $capability ) )
   902 		add_action( $hookname, $function );
   903 		add_action( $hookname, $function );
   903 
   904 
   904 	if ( empty($icon_url) )
   905 	if ( empty($icon_url) ) {
   905 		$icon_url = esc_url( admin_url( 'images/generic.png' ) );
   906 		$icon_url = 'none';
   906 	elseif ( is_ssl() && 0 === strpos($icon_url, 'http://') )
   907 		$icon_class = 'menu-icon-generic ';
   907 		$icon_url = 'https://' . substr($icon_url, 7);
   908 	} else {
   908 
   909 		$icon_url = set_url_scheme( $icon_url );
   909 	$new_menu = array( $menu_title, $capability, $menu_slug, $page_title, 'menu-top ' . $hookname, $hookname, $icon_url );
   910 		$icon_class = '';
       
   911 	}
       
   912 
       
   913 	$new_menu = array( $menu_title, $capability, $menu_slug, $page_title, 'menu-top ' . $icon_class . $hookname, $hookname, $icon_url );
   910 
   914 
   911 	if ( null === $position )
   915 	if ( null === $position )
   912 		$menu[] = $new_menu;
   916 		$menu[] = $new_menu;
   913 	else
   917 	else
   914 		$menu[$position] = $new_menu;
   918 		$menu[$position] = $new_menu;
  1622  */
  1626  */
  1623 function register_setting( $option_group, $option_name, $sanitize_callback = '' ) {
  1627 function register_setting( $option_group, $option_name, $sanitize_callback = '' ) {
  1624 	global $new_whitelist_options;
  1628 	global $new_whitelist_options;
  1625 
  1629 
  1626 	if ( 'misc' == $option_group ) {
  1630 	if ( 'misc' == $option_group ) {
  1627 		_deprecated_argument( __FUNCTION__, '3.0', __( 'The miscellaneous options group has been removed. Use another settings group.' ) );
  1631 		_deprecated_argument( __FUNCTION__, '3.0', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'misc' ) );
  1628 		$option_group = 'general';
  1632 		$option_group = 'general';
       
  1633 	}
       
  1634 
       
  1635 	if ( 'privacy' == $option_group ) {
       
  1636 		_deprecated_argument( __FUNCTION__, '3.5', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'privacy' ) );
       
  1637 		$option_group = 'reading';
  1629 	}
  1638 	}
  1630 
  1639 
  1631 	$new_whitelist_options[ $option_group ][] = $option_name;
  1640 	$new_whitelist_options[ $option_group ][] = $option_name;
  1632 	if ( $sanitize_callback != '' )
  1641 	if ( $sanitize_callback != '' )
  1633 		add_filter( "sanitize_option_{$option_name}", $sanitize_callback );
  1642 		add_filter( "sanitize_option_{$option_name}", $sanitize_callback );
  1645  */
  1654  */
  1646 function unregister_setting( $option_group, $option_name, $sanitize_callback = '' ) {
  1655 function unregister_setting( $option_group, $option_name, $sanitize_callback = '' ) {
  1647 	global $new_whitelist_options;
  1656 	global $new_whitelist_options;
  1648 
  1657 
  1649 	if ( 'misc' == $option_group ) {
  1658 	if ( 'misc' == $option_group ) {
  1650 		_deprecated_argument( __FUNCTION__, '3.0', __( 'The miscellaneous options group has been removed. Use another settings group.' ) );
  1659 		_deprecated_argument( __FUNCTION__, '3.0', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'misc' ) );
  1651 		$option_group = 'general';
  1660 		$option_group = 'general';
       
  1661 	}
       
  1662 
       
  1663 	if ( 'privacy' == $option_group ) {
       
  1664 		_deprecated_argument( __FUNCTION__, '3.5', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'privacy' ) );
       
  1665 		$option_group = 'reading';
  1652 	}
  1666 	}
  1653 
  1667 
  1654 	$pos = array_search( $option_name, (array) $new_whitelist_options );
  1668 	$pos = array_search( $option_name, (array) $new_whitelist_options );
  1655 	if ( $pos !== false )
  1669 	if ( $pos !== false )
  1656 		unset( $new_whitelist_options[ $option_group ][ $pos ] );
  1670 		unset( $new_whitelist_options[ $option_group ][ $pos ] );