本文整理汇总了PHP中WPSEO_Meta::replace_meta方法的典型用法代码示例。如果您正苦于以下问题:PHP WPSEO_Meta::replace_meta方法的具体用法?PHP WPSEO_Meta::replace_meta怎么用?PHP WPSEO_Meta::replace_meta使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WPSEO_Meta
的用法示例。
在下文中一共展示了WPSEO_Meta::replace_meta方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: import_post_metas
/**
* Import the post meta values to Yoast SEO by replacing the wpSEO fields by Yoast SEO fields
*/
private function import_post_metas()
{
WPSEO_Meta::replace_meta('_wpseo_edit_title', WPSEO_Meta::$meta_prefix . 'title', $this->replace);
WPSEO_Meta::replace_meta('_wpseo_edit_description', WPSEO_Meta::$meta_prefix . 'metadesc', $this->replace);
WPSEO_Meta::replace_meta('_wpseo_edit_keywords', WPSEO_Meta::$meta_prefix . 'keywords', $this->replace);
WPSEO_Meta::replace_meta('_wpseo_edit_canonical', WPSEO_Meta::$meta_prefix . 'canonical', $this->replace);
$this->import_post_robots();
}
示例2: import_headspace
/**
* Import HeadSpace SEO settings
*/
public function import_headspace()
{
global $wpdb;
WPSEO_Meta::replace_meta('_headspace_description', WPSEO_Meta::$meta_prefix . 'metadesc', $this->replace);
WPSEO_Meta::replace_meta('_headspace_keywords', WPSEO_Meta::$meta_prefix . 'metakeywords', $this->replace);
WPSEO_Meta::replace_meta('_headspace_page_title', WPSEO_Meta::$meta_prefix . 'title', $this->replace);
/**
* @todo [JRF => whomever] verify how headspace sets these metas ( 'noindex', 'nofollow', 'noarchive', 'noodp', 'noydir' )
* and if the values saved are concurrent with the ones we use (i.e. 0/1/2)
*/
WPSEO_Meta::replace_meta('_headspace_noindex', WPSEO_Meta::$meta_prefix . 'meta-robots-noindex', $this->replace);
WPSEO_Meta::replace_meta('_headspace_nofollow', WPSEO_Meta::$meta_prefix . 'meta-robots-nofollow', $this->replace);
/*
* @todo - [JRF => whomever] check if this can be done more efficiently by querying only the meta table
* possibly directly changing it using concat on the existing values
*/
$posts = $wpdb->get_results("SELECT ID FROM {$wpdb->posts}");
if (is_array($posts) && $posts !== array()) {
foreach ($posts as $post) {
$custom = get_post_custom($post->ID);
$robotsmeta_adv = '';
if (isset($custom['_headspace_noarchive'])) {
$robotsmeta_adv .= 'noarchive,';
}
if (isset($custom['_headspace_noodp'])) {
$robotsmeta_adv .= 'noodp,';
}
if (isset($custom['_headspace_noydir'])) {
$robotsmeta_adv .= 'noydir';
}
$robotsmeta_adv = preg_replace('`,$`', '', $robotsmeta_adv);
WPSEO_Meta::set_value('meta-robots-adv', $robotsmeta_adv, $post->ID);
}
}
if ($this->replace) {
$hs_meta = array('noarchive', 'noodp', 'noydir');
foreach ($hs_meta as $meta) {
delete_post_meta_by_key('_headspace_' . $meta);
}
unset($hs_meta, $meta);
}
$this->set_msg(__('HeadSpace2 data successfully imported', 'wordpress-seo'));
}
示例3: replace_meta
/**
* Used for imports, both in dashboard and import settings pages, this functions either copies
* $old_metakey into $new_metakey or just plain replaces $old_metakey with $new_metakey
*
* @deprecated 1.5.0
* @deprecated use WPSEO_Meta::replace_meta()
* @see WPSEO_Meta::replace_meta()
*
* @param string $old_metakey The old name of the meta value.
* @param string $new_metakey The new name of the meta value, usually the WP SEO name.
* @param bool $replace Whether to replace or to copy the values.
*/
function replace_meta($old_metakey, $new_metakey, $replace = false)
{
_deprecated_function(__FUNCTION__, 'WPSEO 1.5.0', 'WPSEO_Meta::replace_meta()');
WPSEO_Meta::replace_meta($old_metakey, $new_metakey, $replace);
}
示例4: unset
}
unset($meta);
}
$msg .= __('HeadSpace2 data successfully imported', 'wordpress-seo');
}
// @todo [JRF => whomever] how does this correlate with the routine on the dashboard page ? isn't one superfluous ?
if (isset($_POST['wpseo']['importaioseo']) || isset($_GET['importaioseo'])) {
WPSEO_Meta::replace_meta('_aioseop_description', WPSEO_Meta::$meta_prefix . 'metadesc', $replace);
WPSEO_Meta::replace_meta('_aioseop_keywords', WPSEO_Meta::$meta_prefix . 'metakeywords', $replace);
WPSEO_Meta::replace_meta('_aioseop_title', WPSEO_Meta::$meta_prefix . 'title', $replace);
$msg .= __(sprintf('All in One SEO data successfully imported. Would you like to %sdisable the All in One SEO plugin%s.', '<a href="' . esc_url(admin_url('admin.php?page=wpseo_import&deactivate_aioseo=1')) . '">', '</a>'), 'wordpress-seo');
}
if (isset($_POST['wpseo']['importaioseoold'])) {
WPSEO_Meta::replace_meta('description', WPSEO_Meta::$meta_prefix . 'metadesc', $replace);
WPSEO_Meta::replace_meta('keywords', WPSEO_Meta::$meta_prefix . 'metakeywords', $replace);
WPSEO_Meta::replace_meta('title', WPSEO_Meta::$meta_prefix . 'title', $replace);
$msg .= __('All in One SEO (Old version) data successfully imported.', 'wordpress-seo');
}
if (isset($_POST['wpseo']['importrobotsmeta']) || isset($_GET['importrobotsmeta'])) {
$posts = $wpdb->get_results("SELECT ID, robotsmeta FROM {$wpdb->posts}");
if (is_array($posts) && $posts !== array()) {
foreach ($posts as $post) {
// sync all possible settings
if ($post->robotsmeta) {
$pieces = explode(',', $post->robotsmeta);
foreach ($pieces as $meta) {
switch ($meta) {
case 'noindex':
WPSEO_Meta::set_value('meta-robots-noindex', '1', $post->ID);
break;
case 'index':
示例5: import_metas
/**
* Import All In One SEO meta values
*/
private function import_metas()
{
WPSEO_Meta::replace_meta('_aioseop_description', WPSEO_Meta::$meta_prefix . 'metadesc', $this->replace);
WPSEO_Meta::replace_meta('_aioseop_keywords', WPSEO_Meta::$meta_prefix . 'metakeywords', $this->replace);
WPSEO_Meta::replace_meta('_aioseop_title', WPSEO_Meta::$meta_prefix . 'title', $this->replace);
}
示例6: import_metas
/**
* Import meta values if they're applicable
*/
private function import_metas()
{
WPSEO_Meta::replace_meta('seo_follow', WPSEO_Meta::$meta_prefix . 'meta-robots-nofollow', $this->replace);
WPSEO_Meta::replace_meta('seo_noindex', WPSEO_Meta::$meta_prefix . 'meta-robots-noindex', $this->replace);
// If WooSEO is set to use the Woo titles, import those.
if ('true' == get_option('seo_woo_wp_title')) {
WPSEO_Meta::replace_meta('seo_title', WPSEO_Meta::$meta_prefix . 'title', $this->replace);
}
// If WooSEO is set to use the Woo meta descriptions, import those.
if ('b' == get_option('seo_woo_meta_single_desc')) {
WPSEO_Meta::replace_meta('seo_description', WPSEO_Meta::$meta_prefix . 'metadesc', $this->replace);
}
// If WooSEO is set to use the Woo meta keywords, import those.
if ('b' == get_option('seo_woo_meta_single_key')) {
WPSEO_Meta::replace_meta('seo_keywords', WPSEO_Meta::$meta_prefix . 'metakeywords', $this->replace);
}
foreach (array('seo_woo_wp_title', 'seo_woo_meta_single_desc', 'seo_woo_meta_single_key') as $option) {
$this->perhaps_delete($option);
}
}