Skip to content

Commit

Permalink
add meta title, descirption, and robots support. (a previous commit w…
Browse files Browse the repository at this point in the history
…as mislabeled; only supported social title/description previously.)
  • Loading branch information
Tim Gieseking committed Jun 6, 2019
1 parent 2b1ff6e commit aed71fe
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions distributor-yoast-sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
/**
* Plugin Name: Distributor / Yoast Sync
* Plugin URI: https://github.com/timstl/distributor-yoast-sync
* Description: Sync social images, meta titles and descriptions from Yoast SEO when post is pushed or pulled by Distributor plugin.
* Version: 1.0.2
* Description: Sync social images, titles and descriptions and meta information from Yoast SEO when post is pushed or pulled by Distributor plugin.
* Version: 1.0.3
* Author: Tim Gieseking, [email protected]
* Author URI: http://timgweb.com/
* License: GPL-2.0+
Expand Down Expand Up @@ -40,10 +40,14 @@ function dty_yoast_meta_keys( $prepend = '_' ) {
array(
'yoast_wpseo_opengraph-image' => 'image',
'yoast_wpseo_twitter-image' => 'image',
'yoast_wpseo_title' => 'text',
'yoast_wpseo_opengraph-title' => 'text',
'yoast_wpseo_twitter-title' => 'text',
'yoast_wpseo_metadesc' => 'textarea',
'yoast_wpseo_opengraph-description' => 'textarea',
'yoast_wpseo_twitter-description' => 'textarea',
'yoast_wpseo_meta-robots-noindex' => 'int',
'yoast_wpseo_meta-robots-nofollow' => 'int',
)
);

Expand Down Expand Up @@ -165,6 +169,20 @@ function dty_fix_opengraph_meta_on_update( $post_body, $post ) {
unset( $post_body['post_data']['distributor_meta'][ '_' . $yoast_meta_key ] );
}
}
} elseif ( 'int' === $type ) {
/**
* Sanitize integers (robot settings);
*/
if ( isset( $_POST[ $yoast_meta_key ] ) ) {
$post_body['post_data']['distributor_meta'][ '_' . $yoast_meta_key ][0] = intval( $_POST[ $yoast_meta_key ] );
} else {
/**
* Delete
*/
if ( isset( $post_body['post_data']['distributor_meta'][ '_' . $yoast_meta_key ] ) ) {
unset( $post_body['post_data']['distributor_meta'][ '_' . $yoast_meta_key ] );
}
}
}
}

Expand Down

0 comments on commit aed71fe

Please sign in to comment.