/**
 * Test whether force rewrite should be enabled or not.
 */
function wpseo_title_test()
{
    $options = get_option('wpseo_titles');
    $options['forcerewritetitle'] = false;
    $options['title_test'] = 1;
    update_option('wpseo_titles', $options);
    // Setting title_test to > 0 forces the plugin to output the title below through a filter in class-frontend.php
    $expected_title = 'This is a Yoast Test Title';
    WPSEO_Options::clear_cache();
    global $wp_version;
    $args = array('user-agent' => "WordPress/{$wp_version}; " . get_site_url() . ' - Yoast');
    $resp = wp_remote_get(get_bloginfo('url'), $args);
    // echo '<pre>'.$resp['body'].'</pre>';
    if ($resp && !is_wp_error($resp) && (200 == $resp['response']['code'] && isset($resp['body']))) {
        $res = preg_match('`<title>([^<]+)</title>`im', $resp['body'], $matches);
        if ($res && strcmp($matches[1], $expected_title) !== 0) {
            $options['forcerewritetitle'] = true;
            $resp = wp_remote_get(get_bloginfo('url'), $args);
            $res = false;
            if ($resp && !is_wp_error($resp) && (200 == $resp['response']['code'] && isset($resp['body']))) {
                $res = preg_match('`/<title>([^>]+)</title>`im', $resp['body'], $matches);
            }
        }
        if (!$res || $matches[1] != $expected_title) {
            $options['forcerewritetitle'] = false;
        }
    } else {
        // If that dies, let's make sure the titles are correct and force the output.
        $options['forcerewritetitle'] = true;
    }
    $options['title_test'] = 0;
    update_option('wpseo_titles', $options);
}
Esempio n. 2
0
/**
 * On deactivation, flush the rewrite rules so XML sitemaps stop working.
 */
function wpseo_deactivate()
{
    require_once WPSEO_PATH . 'inc/wpseo-functions.php';
    flush_rewrite_rules();
    wpseo_remove_capabilities();
    // Force unschedule
    WPSEO_Options::schedule_yoast_tracking(null, get_option('wpseo'), true);
    // Clear cache so the changes are obvious.
    WPSEO_Options::clear_cache();
    do_action('wpseo_deactivate');
}
Esempio n. 3
0
 /**
  * Clears the cache
  *
  * @deprecated 1.5.0
  * @deprecated use WPSEO_Options::clear_cache()
  * @see        WPSEO_Options::clear_cache()
  */
 function clear_cache()
 {
     _deprecated_function(__METHOD__, 'WPSEO 1.5.0', 'WPSEO_Options::clear_cache()');
     WPSEO_Options::clear_cache();
 }