[wp-trac] [WordPress Trac] #49684: Why the wp_die() method corresponds to different styles in different topics?

WordPress Trac noreply at wordpress.org
Mon Mar 23 18:41:41 UTC 2020


#49684: Why the wp_die() method corresponds to different styles in different
topics?
-------------------------------------------------+-------------------------
 Reporter:  shenyanzhi                           |       Owner:  (none)
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  Awaiting
                                                 |  Review
Component:  General                              |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  reporter-feedback needs-screenshots  |     Focuses:
-------------------------------------------------+-------------------------
Changes (by SergeyBiryukov):

 * keywords:  dev-feedback => reporter-feedback needs-screenshots


Old description:

> I used wp_die () in the plugin, but I get user feedback and the styles
> are inconsistent. Why?
>
> The theme I use uses wp_die () to prompt a pop-up window, and the theme
> of other users is the default error page. I tested the default theme and
> the default error page.
>
> ```php
> // check comment
> function bdtc_refused_comments($comment_data)
> {
>     $option = get_option('BaiduTextCensor');
>     if ($option['check_me'] && !is_user_logged_in()) {
>         require_once dirname(__FILE__) . '/src/AipBase.php';
>         $client = new \Luffy\TextCensor\AipBase($option['app_id'],
> $option['api_key'], $option['secret_key']);
>         $res =
> $client->textCensorUserDefined($comment_data['comment_content']);
>         if ($res['conclusionType'] == 2) {
>             wp_die("评论内容" . $res['data'][0]['msg'] . ",请重新评论");
>         } elseif (in_array($res['conclusionType'], [3, 4])) {
>             add_filter( 'pre_comment_approved' , '__return_zero');
>         }
>     }
>     return( $comment_data );
> }
> add_filter('preprocess_comment', 'bdtc_refused_comments');
> ```

New description:

 I used wp_die () in the plugin, but I get user feedback and the styles are
 inconsistent. Why?

 The theme I use uses wp_die () to prompt a pop-up window, and the theme of
 other users is the default error page. I tested the default theme and the
 default error page.

 {{{
 // check comment
 function bdtc_refused_comments($comment_data)
 {
     $option = get_option('BaiduTextCensor');
     if ($option['check_me'] && !is_user_logged_in()) {
         require_once dirname(__FILE__) . '/src/AipBase.php';
         $client = new \Luffy\TextCensor\AipBase($option['app_id'],
 $option['api_key'], $option['secret_key']);
         $res =
 $client->textCensorUserDefined($comment_data['comment_content']);
         if ($res['conclusionType'] == 2) {
             wp_die("评论内容" . $res['data'][0]['msg'] . ",请重新评论");
         } elseif (in_array($res['conclusionType'], [3, 4])) {
             add_filter( 'pre_comment_approved' , '__return_zero');
         }
     }
     return( $comment_data );
 }
 add_filter('preprocess_comment', 'bdtc_refused_comments');
 }}}

--

Comment:

 Hi there, welcome to WordPress Trac! Thanks for the report.

 Could you provide the steps to reproduce the issue on a clean install?

 It's not quite clear what the issue is, or what is the expected result.
 Some screenshots would also be helpful.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/49684#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list