致命错误:在第1822行调用/wp-admin/includes/misc.php中的未定义函数wp_add_Privacy_Policy_Content()

时间:2018-08-09 作者:harshal

/**
     * Add the suggested privacy policy text to the policy postbox.
     *
     * @since 4.9.6
     */
    public static function add_suggested_content() {
        $content = self::get_default_content( true );
        wp_add_privacy_policy_content( __( \'WordPress\' ), $content );
    }
我看到该功能是从wordpress版本4.9.6添加的,而我的wordpress版本是4.9.8,会有什么问题?

1 个回复
最合适的回答,由SO网友:harshal 整理而成

我发现函数是在中定义的wp-admin/includes/plugin.php 如本文所述https://wpseek.com/function/wp_add_privacy_policy_content/当我打开plugin.php 我发现一个干净的wordpress 4.9.8版本的文件中已经定义了wp\\u add\\u privacy\\u policy\\u content()函数,而在我的wordpress 4.9.8版本中它丢失了,所以我又重新添加了它Kindly make sure the function is defined in plugin.php

/**
 * Helper function for adding content to the Privacy Policy Guide.
 *
 * Plugins and themes should suggest text for inclusion in the site\'s privacy policy.
 * The suggested text should contain information about any functionality that affects user privacy,
 * and will be shown on the Privacy Policy Guide screen.
 *
 * A plugin or theme can use this function multiple times as long as it will help to better present
 * the suggested policy content. For example modular plugins such as WooCommerse or Jetpack
 * can add or remove suggested content depending on the modules/extensions that are enabled.
 * For more information see the Plugin Handbook:
 * https://developer.wordpress.org/plugins/privacy/suggesting-text-for-the-site-privacy-policy/.
 *
 * Intended for use with the `\'admin_init\'` action.
 *
 * @since 4.9.6
 *
 * @param string $plugin_name The name of the plugin or theme that is suggesting content for the site\'s privacy policy.
 * @param string $policy_text The suggested content for inclusion in the policy.
 */
function wp_add_privacy_policy_content( $plugin_name, $policy_text ) {
    if ( ! is_admin() ) {
        _doing_it_wrong(
            __FUNCTION__,
            sprintf(
                /* translators: %s: admin_init */
                __( \'The suggested privacy policy content should be added only in wp-admin by using the %s (or later) action.\' ),
                \'<code>admin_init</code>\'
            ),
            \'4.9.7\'
        );
        return;
    } elseif ( ! doing_action( \'admin_init\' ) && ! did_action( \'admin_init\' ) ) {
        _doing_it_wrong(
            __FUNCTION__,
            sprintf(
                /* translators: %s: admin_init */
                __( \'The suggested privacy policy content should be added by using the %s (or later) action. Please see the inline documentation.\' ),
                \'<code>admin_init</code>\'
            ),
            \'4.9.7\'
        );
        return;
    }

    if ( ! class_exists( \'WP_Privacy_Policy_Content\' ) ) {
        require_once( ABSPATH . \'wp-admin/includes/misc.php\' );
    }

    WP_Privacy_Policy_Content::add( $plugin_name, $policy_text );
}

结束

相关推荐

Privacy in WordPress

我想用WordPress建立一个私人社区。要求如下:用户可以在某个地方“注册”,管理员会“批准”他们,用户会收到一封电子邮件“您已被批准”,然后用户可以登录并访问该网站,并可以发布帖子和回复内容,一些插件可以帮助实现这一点:Private, Private WP, User Roles, 但没有任何组合能产生我想要的。有没有办法用WordPress做到这一点?