Skip to content

Commit

Permalink
Merge pull request #18 from thenewinquiry/1.1.1
Browse files Browse the repository at this point in the history
#17 Added ability to customize text used for post description
  • Loading branch information
misfist authored May 3, 2017
2 parents b8d3ccb + 31353f6 commit 71a643b
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 3 deletions.
64 changes: 64 additions & 0 deletions includes/class-tni-core-custom-fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,70 @@ public function register_field_groups() {
'menu_order' => 0,
));

acf_add_local_field_group( array(
'key' => 'group_seo_info',
'title' => 'SEO Information',
'fields' => array (
array (
'key' => 'field_seo_description',
'label' => __( 'SEO Description', 'tni-core' ),
'name' => 'seo_description',
'type' => 'textarea',
'instructions' => __( 'Text that appears with article when shared on social networks.', 'tni' ),
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array (
'width' => '',
'class' => '',
'id' => '',
),
'default_value' => '',
'placeholder' => '',
'maxlength' => '',
'rows' => '',
'new_lines' => 'wpautop',
),
),
'location' => array (
array (
array (
'param' => 'post_type',
'operator' => '==',
'value' => 'post',
),
),
array (
array (
'param' => 'post_type',
'operator' => '==',
'value' => 'page',
),
),
array (
array (
'param' => 'post_type',
'operator' => '==',
'value' => 'magazines',
),
),
array (
array (
'param' => 'post_type',
'operator' => '==',
'value' => 'blogs',
),
),
),
'menu_order' => 0,
'position' => 'normal',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => '',
'active' => 1,
'description' => '',
));

register_field_group( array (
'id' => 'acf_magazine',
'title' => __( 'Magazine Details', 'tni-core' ),
Expand Down
32 changes: 32 additions & 0 deletions includes/jetpack-customization.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
/**
* Tni Core JetPack Customization
*
* @package Tni_Core
* @subpackage Tni_Core\Includes
* @since 1.1.1
* @license GPL-2.0+
*/

/**
* Custom Description
* Replace `og:description` with `seo_description` custom field, if it exists
*
* If `seo_description` doesn't exist for a post/page, do not modify `og:description`.
*
* @since 1.1.1
*
* @uses jetpack_open_graph_tags filter
* @uses get_post_meta
*
* @param {array} $tags
* @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' );
}
return $tags;
}
add_filter( 'jetpack_open_graph_tags', 'tni_core_og_description' );
7 changes: 6 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.7.4
Version: 1.1.0
Version: 1.1.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand All @@ -22,6 +22,11 @@ This section describes how to install the plugin and get it working.

== Changelog ==

= 1.1.1 May 2, 2017 =
* #17 Added ability to customize text used for post description
* Added `seo_description` field
* Added `jetpack_open_graph_tags` filter to set `og:description` to `seo_description`, if it exists

= 1.1.0 April 27, 2017 =
* Added featured post settings page

Expand Down
6 changes: 4 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.1.0
* Version: 1.1.1
*
* @package Tni_Core_Functionality
*/
Expand All @@ -37,6 +37,8 @@
require_once( 'includes/class-tni-core-authorization.php' );
require_once( 'includes/authorization-functions.php' );

require_once( 'includes/jetpack-customization.php' );

// Load admin files
require_once( 'admin/class-tni-core-admin.php' );

Expand All @@ -47,7 +49,7 @@
* @return object Tni_Core
*/
function Tni_Core() {
$instance = Tni_Core::instance( __FILE__, '1.1.0' );
$instance = Tni_Core::instance( __FILE__, '1.1.1' );

return $instance;
}
Expand Down

0 comments on commit 71a643b

Please sign in to comment.