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)); } } }
/** * Exports the current site's WP SEO settings. */ private function export_settings() { $this->export_header(); foreach (WPSEO_Options::get_option_names() as $opt_group) { $this->write_opt_group($opt_group); } $this->taxonomy_metadata(); if (!$this->write_settings_file()) { $this->error = __('Could not write settings to file.', 'wordpress-seo'); return; } if ($this->zip_file()) { // Just exit, because there is a download being served. exit; } }
/** * Exports the current site's WP SEO settings. * * @return boolean|string $return true when success, error when failed. */ private function export_settings() { $this->export_header(); foreach (WPSEO_Options::get_option_names() as $opt_group) { $this->write_opt_group($opt_group, $this->export); } $this->taxonomy_metadata(); if ($this->write_file()) { if ($this->zip_file()) { return true; } else { $this->error = __('Could not zip settings-file.', 'wordpress-seo'); return false; } } $this->error = __('Could not write settings to file.', 'wordpress-seo'); return false; }
/** * Retrieve an array of all the options the plugin uses. It can't use only one due to limitations of the options API. * * @deprecated 1.5.0 * @deprecated use WPSEO_Options::get_option_names() * @see WPSEO_Options::get_option_names() * * @return array of options. */ function get_wpseo_options_arr() { _deprecated_function(__FUNCTION__, 'WPSEO 1.5.0', 'WPSEO_Options::get_option_names()'); return WPSEO_Options::get_option_names(); }
/** * Exports the current site's WP SEO settings. * * @param bool $include_taxonomy Whether to include the taxonomy metadata the plugin creates. * * @return bool|string $return False when failed, the URL to the export file when succeeded. */ function export_settings($include_taxonomy) { $content = '; ' . __('This is a settings export file for the WordPress SEO plugin by Yoast.com', 'wordpress-seo') . " - https://yoast.com/wordpress/plugins/seo/ \r\n"; $optarr = WPSEO_Options::get_option_names(); 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)) { $elm_count = count($elem); for ($i = 0; $i < $elm_count; $i++) { $content .= $key . '[] = "' . $elem[$i] . "\"\n"; } } elseif (is_string($elem) && $elem == '') { $content .= $key . " = \n"; } elseif (is_bool($elem)) { $content .= $key . ' = "' . ($elem === true ? 'on' : 'off') . "\"\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); chdir($dir['path']); $zip = new PclZip('./settings.zip'); if ($zip->create('./settings.ini') == 0) { return false; } return $dir['url'] . '/settings.zip'; }
/** * 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); }