Make WordPress Core

Ticket #44142: 44142.2.diff

File 44142.2.diff, 3.1 KB (added by azaozz, 7 years ago)
  • src/wp-admin/includes/misc.php

     
    202202                return;
    203203        }
    204204
     205        if ( ! is_admin() ) {
     206                _doing_it_wrong( __FUNCTION__, __( 'Rewrite rules should only be updated in wp-admin context.' ), '4.9.7' );
     207        }
     208
     209        /** Ensure get_home_path is declared. */
     210        require_once( ABSPATH . 'wp-admin/includes/file.php' );
     211
    205212        global $wp_rewrite;
    206213
    207214        $home_path     = get_home_path();
     
    236243                return;
    237244        }
    238245
     246        if ( ! is_admin() ) {
     247                _doing_it_wrong( __FUNCTION__, __( 'Rewrite rules should only be updated in wp-admin context.' ), '4.9.7' );
     248        }
     249
     250        /** Ensure get_home_path is declared. */
     251        require_once( ABSPATH . 'wp-admin/includes/file.php' );
     252
    239253        global $wp_rewrite;
    240254
    241255        $home_path       = get_home_path();
  • src/wp-admin/includes/plugin.php

     
    20162016}
    20172017
    20182018/**
    2019  * Helper function for adding content to the postbox shown when editing the privacy policy.
     2019 * Helper function for adding content to the Privacy Policy Guide.
    20202020 *
    20212021 * Plugins and themes should suggest text for inclusion in the site's privacy policy.
    20222022 * The suggested text should contain information about any functionality that affects user privacy,
    2023  * and will be shown in the Suggested Privacy Policy Content postbox.
     2023 * and will be shown on the Privacy Policy Guide screen.
    20242024 *
    20252025 * A plugin or theme can use this function multiple times as long as it will help to better present
    20262026 * the suggested policy content. For example modular plugins such as WooCommerse or Jetpack
    20272027 * can add or remove suggested content depending on the modules/extensions that are enabled.
     2028 * For more information see the Plugins Handbook:
     2029 * https://developer.wordpress.org/plugins/privacy/suggesting-text-for-the-site-privacy-policy/.
    20282030 *
    20292031 * Intended for use with the `'admin_init'` action.
    20302032 *
     
    20322034 *
    20332035 * @param string $plugin_name The name of the plugin or theme that is suggesting content for the site's privacy policy.
    20342036 * @param string $policy_text The suggested content for inclusion in the policy.
    2035  *                            For more information see the Plugins Handbook https://developer.wordpress.org/plugins/.
    20362037 */
    20372038function wp_add_privacy_policy_content( $plugin_name, $policy_text ) {
     2039        if ( ! is_admin() ) {
     2040                _doing_it_wrong( __FUNCTION__, __( 'The suggested privacy policy content should be added only in wp-admin by using the "admin_init" (or later) action.' ), '4.9.7' );
     2041                return;
     2042        } elseif ( ! doing_action( 'admin_init' ) && ! did_action( 'admin_init' ) ) {
     2043                _doing_it_wrong( __FUNCTION__, __( 'The suggested privacy policy content should be added by using the "admin_init" (or later) action. Please see the inline documentation.' ), '4.9.7' );
     2044                return;
     2045        }
     2046
    20382047        if ( ! class_exists( 'WP_Privacy_Policy_Content' ) ) {
    20392048                require_once( ABSPATH . 'wp-admin/includes/misc.php' );
    20402049        }