WordPress.org

Make WordPress Core

Ticket #44142: 44142.3.diff

File 44142.3.diff, 3.3 KB (added by kraftbj, 5 weeks ago)

doing_it_wrong on any non-admin flush

  • src/wp-admin/includes/misc.php

     
    202202                return;
    203203        }
    204204
     205        /** Ensure get_home_path is declared. */
     206        require_once( ABSPATH . 'wp-admin/includes/file.php' );
     207
    205208        global $wp_rewrite;
    206209
    207210        $home_path     = get_home_path();
     
    236239                return;
    237240        }
    238241
     242        /** Ensure get_home_path is declared. */
     243        require_once( ABSPATH . 'wp-admin/includes/file.php' );
     244
    239245        global $wp_rewrite;
    240246
    241247        $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        }
  • src/wp-includes/rewrite.php

     
    273273 */
    274274function flush_rewrite_rules( $hard = true ) {
    275275        global $wp_rewrite;
     276
     277        if ( ! is_admin() ) {
     278                _doing_it_wrong( __FUNCTION__, __( 'Rewrite rules should only be updated in wp-admin context.' ), '4.9.7' );
     279        }
     280
    276281        $wp_rewrite->flush_rules( $hard );
    277282}
    278283