Skip to content

Commit

Permalink
Merge pull request #42 from thenewinquiry/1.3.1
Browse files Browse the repository at this point in the history
1.3.1 - SEO customization for JetPack
  • Loading branch information
frnsys authored Oct 30, 2017
2 parents 207d2d0 + 41f7e74 commit 5550f99
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 9 deletions.
47 changes: 45 additions & 2 deletions includes/class-tni-core-custom-fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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 (
Expand Down
27 changes: 23 additions & 4 deletions includes/jetpack-customization.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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' ) );
9 changes: 8 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tni-core-functionality.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Text Domain: tni-core
* Domain Path: /languages
*
* Version: 1.3.0
* Version: 1.3.1
*
* @package Tni_Core_Functionality
*/
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 5550f99

Please sign in to comment.