~canonical-sysadmins/wordpress/4.7.2

« back to all changes in this revision

Viewing changes to wp-admin/includes/plugin.php

  • Committer: Barry Price
  • Date: 2016-08-17 04:50:12 UTC
  • mfrom: (1.1.18 upstream)
  • Revision ID: barry.price@canonical.com-20160817045012-qfui81zhqnqv2ba9
Merge WP4.6 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
86
86
        // Site Wide Only is the old header for Network
87
87
        if ( ! $plugin_data['Network'] && $plugin_data['_sitewide'] ) {
88
88
                /* translators: 1: Site Wide Only: true, 2: Network: true */
89
 
                _deprecated_argument( __FUNCTION__, '3.0', sprintf( __( 'The %1$s plugin header is deprecated. Use %2$s instead.' ), '<code>Site Wide Only: true</code>', '<code>Network: true</code>' ) );
 
89
                _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
90
                $plugin_data['Network'] = $plugin_data['_sitewide'];
91
91
        }
92
92
        $plugin_data['Network'] = ( 'true' == strtolower( $plugin_data['Network'] ) );
93
93
        unset( $plugin_data['_sitewide'] );
94
94
 
 
95
        // If no text domain is defined fall back to the plugin slug.
 
96
        if ( ! $plugin_data['TextDomain'] ) {
 
97
                $plugin_slug = dirname( plugin_basename( $plugin_file ) );
 
98
                if ( '.' !== $plugin_slug && false === strpos( $plugin_slug, '/' ) ) {
 
99
                        $plugin_data['TextDomain'] = $plugin_slug;
 
100
                }
 
101
        }
 
102
 
95
103
        if ( $markup || $translate ) {
96
104
                $plugin_data = _get_plugin_data_markup_translate( $plugin_file, $plugin_data, $markup, $translate );
97
105
        } else {
487
495
 * be activated only as a network wide plugin. The plugin would also work
488
496
 * when Multisite is not enabled.
489
497
 *
490
 
 * Checks for "Site Wide Only: true" for backwards compatibility.
 
498
 * Checks for "Site Wide Only: true" for backward compatibility.
491
499
 *
492
500
 * @since 3.0.0
493
501
 *
570
578
                        /**
571
579
                         * Fires as a specific plugin is being activated.
572
580
                         *
573
 
                         * This hook is the "activation" hook used internally by
574
 
                         * {@see register_activation_hook()}. The dynamic portion of the
575
 
                         * hook name, `$plugin`, refers to the plugin basename.
 
581
                         * This hook is the "activation" hook used internally by register_activation_hook().
 
582
                         * The dynamic portion of the hook name, `$plugin`, refers to the plugin basename.
576
583
                         *
577
 
                         * If a plugin is silently activated (such as during an update),
578
 
                         * this hook does not fire.
 
584
                         * If a plugin is silently activated (such as during an update), this hook does not fire.
579
585
                         *
580
586
                         * @since 2.0.0
581
587
                         *
685
691
                        /**
686
692
                         * Fires as a specific plugin is being deactivated.
687
693
                         *
688
 
                         * This hook is the "deactivation" hook used internally by
689
 
                         * {@see register_deactivation_hook()}. The dynamic portion of the
690
 
                         * hook name, `$plugin`, refers to the plugin basename.
 
694
                         * This hook is the "deactivation" hook used internally by register_deactivation_hook().
 
695
                         * The dynamic portion of the hook name, `$plugin`, refers to the plugin basename.
691
696
                         *
692
 
                         * If a plugin is silently deactivated (such as during an update),
693
 
                         * this hook does not fire.
 
697
                         * If a plugin is silently deactivated (such as during an update), this hook does not fire.
694
698
                         *
695
699
                         * @since 2.0.0
696
700
                         *
778
782
        foreach ( $plugins as $plugin )
779
783
                $checked[] = 'checked[]=' . $plugin;
780
784
 
 
785
        $url = wp_nonce_url('plugins.php?action=delete-selected&verify-delete=1&' . implode('&', $checked), 'bulk-plugins');
 
786
 
781
787
        ob_start();
782
 
        $url = wp_nonce_url('plugins.php?action=delete-selected&verify-delete=1&' . implode('&', $checked), 'bulk-plugins');
783
 
        if ( false === ($credentials = request_filesystem_credentials($url)) ) {
784
 
                $data = ob_get_clean();
 
788
        $credentials = request_filesystem_credentials( $url );
 
789
        $data = ob_get_clean();
785
790
 
 
791
        if ( false === $credentials ) {
786
792
                if ( ! empty($data) ){
787
793
                        include_once( ABSPATH . 'wp-admin/admin-header.php');
788
794
                        echo $data;
792
798
                return;
793
799
        }
794
800
 
795
 
        if ( ! WP_Filesystem($credentials) ) {
796
 
                request_filesystem_credentials($url, '', true); //Failed to connect, Error and request again
 
801
        if ( ! WP_Filesystem( $credentials ) ) {
 
802
                ob_start();
 
803
                request_filesystem_credentials( $url, '', true ); // Failed to connect, Error and request again.
797
804
                $data = ob_get_clean();
798
805
 
799
806
                if ( ! empty($data) ){
814
821
        // Get the base plugin folder.
815
822
        $plugins_dir = $wp_filesystem->wp_plugins_dir();
816
823
        if ( empty( $plugins_dir ) ) {
817
 
                return new WP_Error( 'fs_no_plugins_dir', __( 'Unable to locate WordPress Plugin directory.' ) );
 
824
                return new WP_Error( 'fs_no_plugins_dir', __( 'Unable to locate WordPress plugin directory.' ) );
818
825
        }
819
826
 
820
827
        $plugins_dir = trailingslashit( $plugins_dir );
933
940
/**
934
941
 * Validate the plugin path.
935
942
 *
936
 
 * Checks that the file exists and {@link validate_file() is valid file}.
 
943
 * Checks that the file exists and is a valid file. See validate_file().
937
944
 *
938
945
 * @since 2.5.0
939
946
 *
940
 
 * @param string $plugin Plugin Path
 
947
 * @param string $plugin Plugin Path.
941
948
 * @return WP_Error|int 0 on success, WP_Error on failure.
942
949
 */
943
950
function validate_plugin($plugin) {
1003
1010
                unset($uninstallable_plugins);
1004
1011
 
1005
1012
                define('WP_UNINSTALL_PLUGIN', $file);
1006
 
                wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . dirname( $file ) );
 
1013
                wp_register_plugin_realpath( WP_PLUGIN_DIR . '/' . $file );
1007
1014
                include( WP_PLUGIN_DIR . '/' . dirname($file) . '/uninstall.php' );
1008
1015
 
1009
1016
                return true;
1024
1031
                 * Fires in uninstall_plugin() once the plugin has been uninstalled.
1025
1032
                 *
1026
1033
                 * The action concatenates the 'uninstall_' prefix with the basename of the
1027
 
                 * plugin passed to {@see uninstall_plugin()} to create a dynamically-named action.
 
1034
                 * plugin passed to uninstall_plugin() to create a dynamically-named action.
1028
1035
                 *
1029
1036
                 * @since 2.7.0
1030
1037
                 */
1773
1780
        global $new_whitelist_options;
1774
1781
 
1775
1782
        if ( 'misc' == $option_group ) {
1776
 
                _deprecated_argument( __FUNCTION__, '3.0', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'misc' ) );
 
1783
                _deprecated_argument( __FUNCTION__, '3.0.0', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'misc' ) );
1777
1784
                $option_group = 'general';
1778
1785
        }
1779
1786
 
1780
1787
        if ( 'privacy' == $option_group ) {
1781
 
                _deprecated_argument( __FUNCTION__, '3.5', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'privacy' ) );
 
1788
                _deprecated_argument( __FUNCTION__, '3.5.0', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'privacy' ) );
1782
1789
                $option_group = 'reading';
1783
1790
        }
1784
1791
 
1802
1809
        global $new_whitelist_options;
1803
1810
 
1804
1811
        if ( 'misc' == $option_group ) {
1805
 
                _deprecated_argument( __FUNCTION__, '3.0', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'misc' ) );
 
1812
                _deprecated_argument( __FUNCTION__, '3.0.0', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'misc' ) );
1806
1813
                $option_group = 'general';
1807
1814
        }
1808
1815
 
1809
1816
        if ( 'privacy' == $option_group ) {
1810
 
                _deprecated_argument( __FUNCTION__, '3.5', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'privacy' ) );
 
1817
                _deprecated_argument( __FUNCTION__, '3.5.0', sprintf( __( 'The "%s" options group has been removed. Use another settings group.' ), 'privacy' ) );
1811
1818
                $option_group = 'reading';
1812
1819
        }
1813
1820
 
1819
1826
}
1820
1827
 
1821
1828
/**
1822
 
 * Refreshes the value of the options whitelist available via the 'whitelist_options' filter.
 
1829
 * Refreshes the value of the options whitelist available via the 'whitelist_options' hook.
 
1830
 *
 
1831
 * See the {@see 'whitelist_options'} filter.
1823
1832
 *
1824
1833
 * @since 2.7.0
1825
1834
 *