Yoast SEO
[Plugin: WordPress SEO by Yoast] WordPress SEO causes $GLOBALS error when bootstrap is added (1 post)

  1. mikevoermans
    Posted 3 years ago #

    WordPress version: 3.4.2
    WordPress SEO version:

    I did this: I created a form processing class where I include the wordpress bootstrap.

    require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-config.php');

    I expected the plugin to do this: Nothing?

    Instead it did this: Caused an error setting Globals that weren't an object

    $GLOBALS['wp']->add_query_var( 'sitemap' );
    $GLOBALS['wp']->add_query_var( 'sitemap_n' );
    add_rewrite_rule( 'sitemap_index\.xml$', 'index.php?sitemap=1', 'top' );
    add_rewrite_rule( '([^/]+?)-sitemap([0-9]+)?\.xml$', 'index.php?sitemap=$matches[1]&sitemap_n=$matches[2]', 'top' );

    Wrapping the 2 occurrences (class-sitemaps.php and wpseo-functions.php) of that code with: if ( is_object($GLOBALS['wp']) ) { fixed the problem. Perhaps it could be done in a better way.


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Yoast SEO
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic