/** * Retrieve all the options for the SEO plugin in one go. * * @return array of options */ function get_wpseo_options() { $options = array(); foreach (get_wpseo_options_arr() as $opt) { $options = array_merge($options, (array) get_option($opt)); } return $options; }
public function wpseo_translate_options() { if (defined('WPSEO_VERSION') && !PLL_ADMIN && did_action('wp_loaded')) { global $wpseo_front; $options = version_compare(WPSEO_VERSION, '1.5', '<') ? get_wpseo_options_arr() : WPSEO_Options::get_option_names(); foreach ($options as $opt) { $wpseo_front->options = array_merge($wpseo_front->options, (array) get_option($opt)); } } }
/** * Retrieve all the options for the SEO plugin in one go. * * @return array of options */ function get_wpseo_options() { static $options; if (!isset($options)) { $options = array(); foreach (get_wpseo_options_arr() as $opt) { $options = array_merge($options, (array) get_option($opt)); } } return $options; }
function multisite_defaults() { $option = get_option('wpseo'); if (function_exists('is_multisite') && is_multisite() && !is_array($option)) { $options = get_site_option('wpseo_ms'); if (is_array($options) && isset($options['defaultblog']) && !empty($options['defaultblog']) && $options['defaultblog'] != 0) { foreach (get_wpseo_options_arr() as $option) { update_option($option, get_blog_option($options['defaultblog'], $option)); } } $option['ms_defaults_set'] = true; update_option('wpseo', $option); } }
function wpseo_export_settings($include_taxonomy) { $content = "; This is a settings export file for the WordPress SEO plugin by Yoast.com - http://yoast.com/wordpress/seo/\r\n"; $optarr = get_wpseo_options_arr(); foreach ($optarr as $optgroup) { $content .= "\n" . '[' . $optgroup . ']' . "\n"; $options = get_option($optgroup); if (!is_array($options)) { continue; } foreach ($options as $key => $elem) { if (is_array($elem)) { for ($i = 0; $i < count($elem); $i++) { $content .= $key . "[] = \"" . $elem[$i] . "\"\n"; } } else { if ($elem == "") { $content .= $key . " = \n"; } else { $content .= $key . " = \"" . $elem . "\"\n"; } } } } if ($include_taxonomy) { $content .= "\r\n\r\n[wpseo_taxonomy_meta]\r\n"; $content .= "wpseo_taxonomy_meta = \"" . urlencode(json_encode(get_option('wpseo_taxonomy_meta'))) . "\""; } $dir = wp_upload_dir(); if (!($handle = fopen($dir['path'] . '/settings.ini', 'w'))) { die; } if (!fwrite($handle, $content)) { die; } fclose($handle); require_once ABSPATH . 'wp-admin/includes/class-pclzip.php'; chdir($dir['path']); $zip = new PclZip('./settings.zip'); if ($zip->create('./settings.ini') == 0) { return false; } return $dir['url'] . '/settings.zip'; }
function network_config_page() { $options = get_site_option('wpseo_ms'); if (isset($_POST['wpseo_submit'])) { foreach (array('access', 'defaultblog') as $opt) { $options[$opt] = $_POST['wpseo_ms'][$opt]; } update_site_option('wpseo_ms', $options); echo '<div id="message" class="updated">' . __('Settings Updated.') . '</div>'; } if (isset($_POST['wpseo_restore_blog'])) { if (isset($_POST['wpseo_ms']['restoreblog']) && is_numeric($_POST['wpseo_ms']['restoreblog'])) { $blog = get_blog_details($_POST['wpseo_ms']['restoreblog']); if ($blog) { foreach (get_wpseo_options_arr() as $option) { $new_options = get_blog_option($options['defaultblog'], $option); if (count($new_options) > 0) { update_blog_option($_POST['wpseo_ms']['restoreblog'], $option, $new_options); } } echo '<div id="message" class="updated"><p>' . $blog->blogname . ' ' . __('restored to default SEO settings.') . '</p></div>'; } } } $this->admin_header('MultiSite Settings', false, false); $content = '<form method="post">'; $content .= $this->select('access', __('Who should have access to the WordPress SEO settings'), array('admin' => 'Site Admins (default)', 'superadmin' => 'Super Admins only'), 'wpseo_ms'); $content .= $this->textinput('defaultblog', __('New blogs get the SEO settings from this blog'), 'wpseo_ms'); $content .= '<p>' . __('Enter the Blog ID for the site whose settings you want to use as default for all sites that are added to your network. Leave empty for none.') . '</p>'; $content .= '<input type="submit" name="wpseo_submit" class="button-primary" value="' . __('Save MultiSite Settings') . '"/>'; $content .= '</form>'; $this->postbox('wpseo_export', __('MultiSite Settings', 'yoast-wpseo'), $content); $content = '<form method="post">'; $content .= '<p>' . __('Using this form you can reset a site to the default SEO settings.') . '</p>'; $content .= $this->textinput('restoreblog', __('Blog ID'), 'wpseo_ms'); $content .= '<input type="submit" name="wpseo_restore_blog" value="' . __('Restore site to defaults') . '" class="button"/>'; $content .= '</form>'; $this->postbox('wpseo_export', __('Restore site to default settings', 'yoast-wpseo'), $content); $this->admin_footer('Restore to Default', false); }
/** * Yoast SEO * Translate options and add specific filters and actions * * @since 1.6.4 */ public function wpseo_init() { if (!defined('WPSEO_VERSION') || PLL_ADMIN) { return; } // Reloads options once the language has been defined to enable translations // Useful only when the language is set from content if (did_action('wp_loaded')) { if (version_compare(WPSEO_VERSION, '1.7.2', '<')) { global $wpseo_front; } else { $wpseo_front = WPSEO_Frontend::get_instance(); } $options = version_compare(WPSEO_VERSION, '1.5', '<') ? get_wpseo_options_arr() : WPSEO_Options::get_option_names(); foreach ($options as $opt) { $wpseo_front->options = array_merge($wpseo_front->options, (array) get_option($opt)); } } // One sitemap per language when using multiple domains or subdomains // because WPSEO does not accept several domains or subdomains in one sitemap if (PLL()->options['force_lang'] > 1) { add_filter('wpseo_enable_xml_sitemap_transient_caching', '__return_false'); // disable cache! otherwise WPSEO keeps only one domain (thanks to Junaid Bhura) add_filter('home_url', array(&$this, 'wpseo_home_url'), 10, 2); // fix home_url add_filter('wpseo_posts_join', array(&$this, 'wpseo_posts_join'), 10, 2); add_filter('wpseo_posts_where', array(&$this, 'wpseo_posts_where'), 10, 2); add_filter('wpseo_typecount_join', array(&$this, 'wpseo_posts_join'), 10, 2); add_filter('wpseo_typecount_where', array(&$this, 'wpseo_posts_where'), 10, 2); } else { add_filter('get_terms_args', array(&$this, 'wpseo_remove_terms_filter')); // Add the homepages for all languages to the sitemap when the front page displays posts if (!get_option('page_on_front')) { add_filter('wpseo_sitemap_post_content', array(&$this, 'add_language_home_urls')); } } add_filter('pll_home_url_white_list', array(&$this, 'wpseo_home_url_white_list')); add_action('wpseo_opengraph', array(&$this, 'wpseo_ogp'), 2); add_filter('wpseo_canonical', array(&$this, 'wpseo_canonical')); }
public function wpseo_init() { global $polylang; if (!defined('WPSEO_VERSION') || PLL_ADMIN) { return; } // reloads options once the language has been defined to enable translations // useful only when the language is set from content if (did_action('wp_loaded')) { if (version_compare(WPSEO_VERSION, '1.7.2', '<')) { global $wpseo_front; } else { $wpseo_front = WPSEO_Frontend::get_instance(); } $options = version_compare(WPSEO_VERSION, '1.5', '<') ? get_wpseo_options_arr() : WPSEO_Options::get_option_names(); foreach ($options as $opt) { $wpseo_front->options = array_merge($wpseo_front->options, (array) get_option($opt)); } } // one sitemap per language when using multiple domains or subdomains // because WPSEO does not accept several domains or subdomains in one sitemap if ($polylang->options['force_lang'] > 1) { add_filter('wpseo_enable_xml_sitemap_transient_caching', '__return_false'); // disable cache! otherwise WPSEO keeps only one domain add_filter('home_url', array(&$this, 'wpseo_home_url'), 10, 2); // fix home_url add_filter('wpseo_posts_join', array(&$this, 'wpseo_posts_join'), 10, 2); add_filter('wpseo_posts_where', array(&$this, 'wpseo_posts_where'), 10, 2); add_filter('wpseo_typecount_join', array(&$this, 'wpseo_posts_join'), 10, 2); add_filter('wpseo_typecount_where', array(&$this, 'wpseo_posts_where'), 10, 2); } else { add_filter('get_terms_args', array(&$this, 'wpseo_remove_terms_filter')); } add_filter('pll_home_url_white_list', create_function('$arr', "return array_merge(\$arr, array(array('file' => 'wordpress-seo')));")); add_action('wpseo_opengraph', array(&$this, 'wpseo_ogp'), 2); }
global $wpseo_admin_pages; $options = get_site_option('wpseo_ms'); if (isset($_POST['wpseo_submit'])) { check_admin_referer('wpseo-network-settings'); foreach (array('access', 'defaultblog') as $opt) { $options[$opt] = $_POST['wpseo_ms'][$opt]; } update_site_option('wpseo_ms', $options); echo '<div id="message" class="updated"><p>' . __('Settings Updated.', 'wordpress-seo') . '</p></div>'; } if (isset($_POST['wpseo_restore_blog'])) { check_admin_referer('wpseo-network-restore'); if (isset($_POST['wpseo_ms']['restoreblog']) && is_numeric($_POST['wpseo_ms']['restoreblog'])) { $blog = get_blog_details($_POST['wpseo_ms']['restoreblog']); if ($blog) { foreach (get_wpseo_options_arr() as $option) { $new_options = get_blog_option($options['defaultblog'], $option); if (count($new_options) > 0) { update_blog_option($_POST['wpseo_ms']['restoreblog'], $option, $new_options); } } echo '<div id="message" class="updated"><p>' . $blog->blogname . ' ' . __('restored to default SEO settings.', 'wordpress-seo') . '</p></div>'; } } } $wpseo_admin_pages->admin_header('MultiSite Settings', false); $content = '<form method="post">'; $content .= wp_nonce_field('wpseo-network-settings', '_wpnonce', true, false); $content .= $wpseo_admin_pages->select('access', __('Who should have access to the WordPress SEO settings', 'wordpress-seo'), array('admin' => __('Site Admins (default)', 'wordpress-seo'), 'superadmin' => __('Super Admins only', 'wordpress-seo')), 'wpseo_ms'); $content .= $wpseo_admin_pages->textinput('defaultblog', __('New blogs get the SEO settings from this blog', 'wordpress-seo'), 'wpseo_ms'); $content .= '<p>' . __('Enter the Blog ID for the site whose settings you want to use as default for all sites that are added to your network. Leave empty for none.', 'wordpress-seo') . '</p>';