diff --git a/includes/class-tni-core-custom-fields.php b/includes/class-tni-core-custom-fields.php index b9606c2..879ba0f 100644 --- a/includes/class-tni-core-custom-fields.php +++ b/includes/class-tni-core-custom-fields.php @@ -208,10 +208,10 @@ public function register_field_groups() { 'fields' => array ( array ( 'key' => 'field_seo_description', - 'label' => __( 'SEO Description', 'tni-core' ), + 'label' => __( 'Facebook Description', 'tni-core' ), 'name' => 'seo_description', 'type' => 'textarea', - 'instructions' => __( 'Text that appears with article when shared on social networks.', 'tni' ), + 'instructions' => __( 'Text that appears with article when shared on Facebook.', 'tni-core' ), 'required' => 0, 'conditional_logic' => 0, 'wrapper' => array ( @@ -225,6 +225,49 @@ public function register_field_groups() { 'rows' => '', 'new_lines' => 'wpautop', ), + array ( + 'key' => 'field_seo_description_twitter', + 'label' => __( 'Twitter Description', 'tni-core' ), + 'name' => 'seo_description_twitter', + 'type' => 'textarea', + 'instructions' => __( 'Text that appears with article when shared on Twitter.', 'tni-core' ), + 'required' => 0, + 'conditional_logic' => 0, + 'wrapper' => array ( + 'width' => '', + 'class' => '', + 'id' => '', + ), + 'default_value' => '', + 'placeholder' => '', + 'maxlength' => '', + 'rows' => '', + 'new_lines' => 'wpautop', + ), + array ( + 'key' => 'field_seo_image', + 'label' => __( 'SEO Image', 'tni-core' ), + 'name' => 'seo_image', + 'type' => 'image', + 'instructions' => __( 'Image that appears with article when shared on social networks.', 'tni-core' ), + 'required' => 0, + 'conditional_logic' => 0, + 'wrapper' => array ( + 'width' => '', + 'class' => '', + 'id' => '', + ), + 'return_format' => 'url', + 'preview_size' => 'thumbnail', + 'library' => 'all', + 'min_width' => '', + 'min_height' => '', + 'min_size' => '', + 'max_width' => '', + 'max_height' => '', + 'max_size' => '', + 'mime_types' => '', + ), ), 'location' => array ( array ( diff --git a/includes/jetpack-customization.php b/includes/jetpack-customization.php index 0b71b0a..011b1eb 100644 --- a/includes/jetpack-customization.php +++ b/includes/jetpack-customization.php @@ -15,6 +15,7 @@ * If `seo_description` doesn't exist for a post/page, do not modify `og:description`. * * @since 1.1.1 + * @since 1.3.1 * * @uses jetpack_open_graph_tags filter * @uses get_post_meta @@ -23,10 +24,28 @@ * @return {array} $tags */ function tni_core_og_description( $tags ) { - $seo_description = get_post_meta( get_the_id(), 'seo_description', true ); - if( $seo_description ) { - $tags['og:description'] = esc_attr__( $seo_description, 'tni-core' ); + if( $seo_description_facebook = get_post_meta( get_the_id(), 'seo_description', true ) ) { + $tags['og:description'] = esc_attr__( $seo_description_facebook, 'tni-core' ); + } + if( $seo_description_twitter = get_post_meta( get_the_id(), 'seo_description_twitter', true ) ) { + $tags['twitter:description'] = esc_attr__( $seo_description_twitter, 'tni-core' ); + } + if( $seo_image = get_post_meta( get_the_id(), 'seo_image', true ) ) { + unset( $tags['twitter:image'] ); + unset( $tags['og:image'] ); + $image_obj = wp_get_attachment_image_src( (int) $seo_image, 'seo' ); + $tags['twitter:image'] = esc_url( $image_obj[0] ); + $tags['og:image'] = esc_url( $image_obj[0] ); } return $tags; } -add_filter( 'jetpack_open_graph_tags', 'tni_core_og_description' ); +add_filter( 'jetpack_open_graph_tags', 'tni_core_og_description', 99 ); + +/** + * Add SEO Image Size + * + * @since 1.3.1 + * + * @link https://developers.facebook.com/docs/sharing/best-practices/#images + */ +add_image_size( 'seo', 1200, 1200, array( 'center', 'top' ) ); diff --git a/readme.txt b/readme.txt index a972e3f..9caafe4 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: misfist Tags: custom Requires at least: 4.7 Tested up to: 4.8.2 -Version: 1.3.0 +Version: 1.3.1 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -22,6 +22,13 @@ This section describes how to install the plugin and get it working. == Changelog == += 1.3.1 October 30, 2017 = +* #95 SEO customization for JetPack @link https://github.com/thenewinquiry/tni-theme/issues/95 + * Added Twitter Description (`seo_description_twitter`) field + * Added SEO Image (`seo_image`) field + * Added filter to display custom meta if data provided + * Added seo image size + = 1.3.0 October 29, 2017 = * #40 Post bundles * Added Bundles taxonomy diff --git a/tni-core-functionality.php b/tni-core-functionality.php index 97df608..1fd9828 100644 --- a/tni-core-functionality.php +++ b/tni-core-functionality.php @@ -10,7 +10,7 @@ * Text Domain: tni-core * Domain Path: /languages * - * Version: 1.3.0 + * Version: 1.3.1 * * @package Tni_Core_Functionality */ @@ -52,7 +52,7 @@ * @return object Tni_Core */ function Tni_Core() { - $instance = Tni_Core::instance( __FILE__, 'l.3.0' ); + $instance = Tni_Core::instance( __FILE__, 'l.3.1' ); return $instance; }