• Resolved netzgestaltung

    (@netzgestaltung)


    Hi there,

    i get PHP warnings in Query Monitor regarding your Plugin:

    Undefined index: shownav wp-content/plugins/wp-post-comment-rating/inc/function.php:176
    Undefined index: wpcr_social wp-content/plugins/wp-post-comment-rating/inc/function.php:177

    Its regarding to the content filter in that file, while i have both options not active, the seem to be undefined with your method of getting options.

    global $wpdb, $post;
    $results = $wpdb->get_results( "SELECT option_value FROM ".$wpdb->prefix."options WHERE option_name = 'wpcr_settings'");
    $getval = unserialize($results[0]->option_value);
    $navval = $getval['shownav'];
    $wpcr_socialshare = $getval['wpcr_social'];

    you should check for existance of the array values befor accessing it:

    global $wpdb, $post;
    $results = $wpdb->get_results( "SELECT option_value FROM ".$wpdb->prefix."options WHERE option_name = 'wpcr_settings'");
    $getval = unserialize($results[0]->option_value);
    $navval = isset($getval['shownav']) ? $getval['shownav'] : false;
    $wpcr_socialshare = isset($getval['wpcr_social']) ? $getval['wpcr_social'] : false;

    as alternative you can get options the “normal” way so you could remove the global $wpdb:

    $wpcr_options = get_option('wpcr_settings');
    $navval = isset($wpcr_options['shownav']) ? $wpcr_options['shownav'] : false;
    $wpcr_socialshare = isset($wpcr_options['wpcr_social']) ? $wpcr_options['wpcr_social'] : false;
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author shoaib88

    (@shoaib88)

    Hi,
    I removed all the PHP warnings by updated codes and also removed $wpdb query to get options.

    Hope it will work fine now.
    If you see any issue, please let me know.

    Thanks

    Thread Starter netzgestaltung

    (@netzgestaltung)

    Yes looks better now.

    Instead i currently get one new warning on every page backend/frontend:

    Warning	Trying to get property 'query_vars' of non-object	1	
    
        wp-includes/template.php:712
        load_template('wp-content/plugins/wp-post-comment-rating/inc/admin-setting.php')
        wp-content/plugins/wp-post-comment-rating/wpcr-comment-rating.php:99

    You can test yourself with the plugin Query Monitor

    Plugin Author shoaib88

    (@shoaib88)

    Hello @netzgestaltung ,
    I hope you will be fine.I need your help to create a widget for top rated post.Here is the link where I already asked question about this but not found any help.

    https://wordpress.stackexchange.com/questions/356102/load-taxonomy-terms-based-on-post-type-selection

    Please help to achieve this.
    Thanks

    • This reply was modified 3 years, 11 months ago by shoaib88.
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘PHP Warnings’ is closed to new replies.