WordPress.org

Forums

Facebook Open Graph, Google+ and Twitter Card Tags
[resolved] [PATCH] Huge list of PHP warnings (4 posts)

  1. flynsarmy
    Member
    Posted 2 years ago #

    I've got two relatively simple changes to remove a huge number of PHP warnings when WP_DEBUG is turned on:

    Notice: Undefined index: fb_app_id in /wp-content/plugins/wonderm00ns-simple-facebook-open-graph-tags/includes/settings-page.php on line 59
    Notice: Undefined index: fb_admin_id in /wp-content/plugins/wonderm00ns-simple-facebook-open-graph-tags/includes/settings-page.php on line 59
    Notice: Undefined index: fb_locale in /wp-content/plugins/wonderm00ns-simple-facebook-open-graph-tags/includes/settings-page.php on line 59
    Notice: Undefined index: fb_title_show_schema in /wp-content/plugins/wonderm00ns-simple-facebook-open-graph-tags/includes/settings-page.php on line 59
    Notice: Undefined index: fb_desc_show_meta in /wp-content/plugins/wonderm00ns-simple-facebook-open-graph-tags/includes/settings-page.php on line 59
    Notice: Undefined index: fb_desc_show_schema in /wp-content/plugins/wonderm00ns-simple-facebook-open-graph-tags/includes/settings-page.php on line 59
    Notice: Undefined index: fb_desc_homepage in /wp-content/plugins/wonderm00ns-simple-facebook-open-graph-tags/includes/settings-page.php on line 59
    Notice: Undefined index: fb_desc_homepage_customtext in /wp-content/plugins/wonderm00ns-simple-facebook-open-graph-tags/includes/settings-page.php on line 59
    Notice: Undefined index: fb_image_show_schema in /wp-content/plugins/wonderm00ns-simple-facebook-open-graph-tags/includes/settings-page.php on line 59
    Notice: Undefined index: fb_show_subheading in /wp-content/plugins/wonderm00ns-simple-facebook-open-graph-tags/includes/settings-page.php on line 59
    Notice: Undefined index: fb_show_businessdirectoryplugin in /wp-content/plugins/wonderm00ns-simple-facebook-open-graph-tags/includes/settings-page.php on line 59

    These are all caused by this line:

    if ($defaults[$key]!='') {

    simply replace it with:

    if ( !empty($defaults[$key]) ) {

    Secondly, when clicking 'Save Changes' I get

    Notice: Undefined index: fb_app_id_show in /plugins/wonderm00ns-simple-facebook-open-graph-tags/includes/settings-page.php on line 16
    Notice: Undefined index: fb_admin_id_show in /plugins/wonderm00ns-simple-facebook-open-graph-tags/includes/settings-page.php on line 18
    Notice: Undefined index: fb_title_show_schema in /plugins/wonderm00ns-simple-facebook-open-graph-tags/includes/settings-page.php on line 24
    Notice: Undefined index: fb_url_add_trailing in /plugins/wonderm00ns-simple-facebook-open-graph-tags/includes/settings-page.php on line 27
    Notice: Undefined index: fb_desc_show_meta in /plugins/wonderm00ns-simple-facebook-open-graph-tags/includes/settings-page.php on line 31
    Notice: Undefined index: fb_desc_show_schema in /plugins/wonderm00ns-simple-facebook-open-graph-tags/includes/settings-page.php on line 32
    Notice: Undefined index: fb_image_show_schema in /plugins/wonderm00ns-simple-facebook-open-graph-tags/includes/settings-page.php on line 37
    Notice: Undefined index: fb_image_rss in /plugins/wonderm00ns-simple-facebook-open-graph-tags/includes/settings-page.php on line 39
    Notice: Undefined index: fb_show_subheading in /plugins/wonderm00ns-simple-facebook-open-graph-tags/includes/settings-page.php on line 44
    Notice: Undefined index: fb_show_businessdirectoryplugin in /plugins/wonderm00ns-simple-facebook-open-graph-tags/includes/settings-page.php on line 45

    This is caused by a whole slew of lines looking like this:

    update_option('wonderm00n_open_graph_fb_app_id_show', intval($_POST['fb_app_id_show']));

    I created a function

    function wonderm00n_post($var, $default='')
    {
    	return isset($var) ? $var : $default;
    }

    and dropped it into wonderm00n-open-graph.php then updated each of the lines above to look like
    update_option('wonderm00n_open_graph_fb_app_id_show', intval(wonderm00n_post('fb_app_id_show')));

    All warnings are gone!

    http://wordpress.org/extend/plugins/wonderm00ns-simple-facebook-open-graph-tags/

  2. flynsarmy
    Member
    Posted 2 years ago #

    Discovered another undefined warning in /includes/settings-page.php on line 133. Replace

    if (intval($_GET['localeOnline'])==1) {

    with

    if ( !empty($_GET['localeOnline']) && intval($_GET['localeOnline'])==1) {
  3. flynsarmy
    Member
    Posted 2 years ago #

    Ahh dammit sorry, I implimented the first patch above inorrectly. It should be:

    function wonderm00n_post($var, $default='')
    {
    	return isset($_POST[$var]) ? $_POST[$var] : $default;
    }

    and call with

    update_option('wonderm00n_open_graph_fb_app_id_show', intval(wonderm00n_post('fb_app_id_show')));
  4. wonderm00n
    Member
    Plugin Author

    Posted 1 year ago #

    All the patches in the new version to be launched very soon.

    Thank you flynsarmy

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Facebook Open Graph, Google+ and Twitter Card Tags
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.