/** * Test whether force rewrite should be enabled or not. */ function YMBESEO_title_test() { $options = get_option('YMBESEO_titles'); $options['forcerewritetitle'] = false; $options['title_test'] = 1; update_option('YMBESEO_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'; YMBESEO_Utils::clear_cache(); $args = array('user-agent' => sprintf('WordPress/%1$s; %2$s - Yoast', $GLOBALS['wp_version'], get_site_url())); $resp = wp_remote_get(get_bloginfo('url'), $args); 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('YMBESEO_titles', $options); }
/** * Clears the WP or W3TC cache depending on which is used * * @deprecated 1.5.6.1 * @deprecated use YMBESEO_Utils::clear_cache() * @see YMBESEO_Utils::clear_cache() */ public static function clear_cache() { _deprecated_function(__METHOD__, 'WPSEO 1.5.6.1', 'YMBESEO_Utils::clear_cache()'); YMBESEO_Utils::clear_cache(); }
/** * On deactivation, flush the rewrite rules so XML sitemaps stop working. */ function _YMBESEO_deactivate() { require_once YMBESEO_PATH . 'inc/ymbeseo-functions.php'; add_action('shutdown', 'flush_rewrite_rules'); YMBESEO_remove_capabilities(); // Clear cache so the changes are obvious. YMBESEO_Utils::clear_cache(); do_action('YMBESEO_deactivate'); }