Skip to content

Commit

Permalink
Revert 5289 feature/4768 pr work (#5531)
Browse files Browse the repository at this point in the history
Revert 5289 feature/4768 pr work
  • Loading branch information
sc0ttkclark authored Nov 14, 2019
2 parents 7c871c0 + 0514e8c commit bb5cbcf
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 133 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# [Pods Framework](https://pods.io) #
[![Travis](https://secure.travis-ci.org/pods-framework/pods.png?branch=master)](http://travis-ci.org/pods-framework/pods)
[![License](https://img.shields.io/badge/license-GPL--2.0%2B-green.svg)](https://github.com/pods-framework/pods/blob/master/license.txt)
[![Travis](https://secure.travis-ci.org/pods-framework/pods.png?branch=2.x)](http://travis-ci.org/pods-framework/pods)
[![License](https://img.shields.io/badge/license-GPL--2.0%2B-green.svg)](https://github.com/pods-framework/pods/blob/2.x/license.txt)

[![WordPress Plugin version](https://img.shields.io/wordpress/plugin/v/pods.svg?style=flat)](https://wordpress.org/plugins/pods/)
[![WordPress Plugin WP tested version](https://img.shields.io/wordpress/v/pods.svg?style=flat)](https://wordpress.org/plugins/pods/)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,6 @@
*/
class Pods_Templates_Auto_Template_Front_End {

/**
* Currently filtered content functions.
*
* @var array
*
* @since 2.7.16
*/
private $filtered_content = array();

/**
* Pods_Templates_Auto_Template_Front_End constructor.
*/
Expand Down Expand Up @@ -87,35 +78,12 @@ public function hook_content(){
define( 'PFAT_USE_ON_EXCERPT', false );
}

if ( PFAT_USE_ON_EXCERPT ) {
$this->filtered_content['the_excerpt'] = 10;
}

$this->install_hooks();
}
add_filter( $filter, array( $this, 'front' ), 10.5 );

/**
* Install the hooks specified by the filtered_content member
*
* @since 2.7.16
*/
public function install_hooks() {

foreach ( $this->filtered_content as $filter => $priority ) {
add_filter( $filter, array( $this, 'front' ), $priority );
if ( PFAT_USE_ON_EXCERPT ) {
add_filter( 'the_excerpt', array( $this, 'front' ) );
}
}

/**
* Remove the hooks specified by the filtered_content member
*
* @since 2.7.16
*/
public function remove_hooks() {

foreach ( $this->filtered_content as $filter => $priority ) {
remove_filter( $filter, array( $this, 'front' ) );
}
}

/**
Expand Down Expand Up @@ -289,12 +257,6 @@ public function current_post_type() {
$current_post_type = false;
}

// Once we are in the loop, fair game to use the post itself to
// help determine the current post type
if ( ( ! $current_post_type || is_array( $current_post_type ) ) && in_the_loop() ) {
$current_post_type = get_post_type();
}

return $current_post_type;
}

Expand Down Expand Up @@ -335,49 +297,29 @@ public function front( $content ) {

// build Pods object for current item
global $post;
$pod_name = $current_post_type;
$pod_item = $post->ID;
if ( in_the_loop() ) {
$pod_name = $post->post_type;
} else {
// Outside the loop in a taxonomy, we want the term
if ( is_tax() ) {
$obj = get_queried_object();
$pod_name = $obj->slug;
$pod_item = $obj->term_id;
}
}

$pod_name_and_item = array( $pod_name, $pod_item );
/**
* Change which pod and item to run the template against. The
* default pod is the the post type of the post about to be
* displayed, the default item is the post about to be displayed,
* except outside the loop in a taxonomy archive, in which case it
* is the term the archive is for.
*
* @since 2.7.16
*
* @param string $pod_name_and_item An array of the name of the pod to run the template against and the item (ID or slug) of the item in that pod to use.
* @param string $template_source The name of the pod from which the template was selected.
* @param Post $post The Post object that is about to be displayed.
*/
$pod_name_and_item = apply_filters( 'pods_auto_template_pod_name_and_item', $pod_name_and_item, $current_post_type, $post );
$pods = pods( $pod_name_and_item[0], $pod_name_and_item[1] );

// Heuristically decide if this is single or archive
$s_or_a = 'archive';
$s_or_a_filter = 'archive_filter';
$s_or_a_append = 'archive_append';
if ( ! in_the_loop() || is_singular() ) {
$s_or_a = 'single';
$s_or_a_filter = 'single_filter';
$s_or_a_append = 'single_append';
}
$pods = pods( $current_post_type, $post->ID );

if ( $this_pod[ $s_or_a ] && current_filter() == $this_pod[ $s_or_a_filter ] ) {
if ( $this_pod['single'] && is_singular( $current_post_type ) ) {
// load the template
$content = $this->load_template( $this_pod['single'], $content, $pods, $this_pod['single_append'] );
} //end if
// check if we are on an archive of the post type
elseif ( $this_pod['archive'] && is_post_type_archive( $current_post_type ) ) {
// load the template
$content = $this->load_template( $this_pod[ $s_or_a ], $content, $pods, $this_pod[ $s_or_a_append ] );
$content = $this->load_template( $this_pod['archive'], $content, $pods, $this_pod['archive_append'] );

} elseif ( is_home() && $this_pod['archive'] && $current_post_type === 'post' ) {
// if pfat_archive was set and we're in the blog index, try to append template
// append the template
$content = $this->load_template( $this_pod['archive'], $content, $pods, $this_pod['archive_append'] );

} elseif ( is_tax( $current_post_type ) ) {
// if is taxonomy archive of the selected taxonomy
// if pfat_single was set try to use that template
if ( $this_pod['archive'] ) {
// append the template
$content = $this->load_template( $this_pod['archive'], $content, $pods, $this_pod['archive_append'] );
}
}
}//end if

Expand All @@ -402,11 +344,7 @@ public function front( $content ) {
public function load_template( $template_name, $content, $pods, $append = true ) {

// prevent infinite loops caused by this method acting on post_content
$this->remove_hooks();

// Allow template chosen to depend on post type or content via magic
// tags
$template_name = $pods->do_magic_tags( $template_name );
remove_filter( 'the_content', array( $this, 'front' ) );

/**
* Change which template -- by name -- to be used.
Expand All @@ -420,9 +358,7 @@ public function load_template( $template_name, $content, $pods, $append = true )
$template_name = apply_filters( 'pods_auto_template_template_name', $template_name, $pods, $append );

$template = $pods->template( $template_name );

// Restore the hooks for subsequent posts
$this->install_hooks();
add_filter( 'the_content', array( $this, 'front' ) );

// check if we have a valid template
if ( ! is_null( $template ) ) {
Expand Down Expand Up @@ -495,7 +431,6 @@ public function set_frontier_style_script() {
$meta = get_post_meta( $template_post['id'], 'view_template', true );

$frontier = new Pods_Frontier();

if ( ! empty( $meta['css'] ) ) {
$frontier_styles .= $meta['css'];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ public function tab( $tabs, $pod, $addtl_args ) {
/**
* Adds options for this plugin under the Frontier Auto Template tab.
*
* @param array $options Tab options.
* @param array $pod Pod options.
* @param array $options
* @param array $pod
*
* @return array
*
Expand Down Expand Up @@ -168,8 +168,8 @@ public function options( $options, $pod ) {
if ( $pod['type'] === 'taxonomy' ) {
$options['pods-pfat'] = array(
'pfat_enable' => array(
'label' => __( 'Enable Automatic Pods Templates for this Taxonomy Pod?', 'pods' ),
'help' => __( 'When enabled you can specify the names of a Pods Template to be used to display information about this taxonomy and/or posts in this taxonomy in the front-end.', 'pods' ),
'label' => __( 'Enable Automatic Pods Templates for this Pod?', 'pods' ),
'help' => __( 'When enabled you can specify the names of a Pods Template to be used to display items in this Pod in the front-end.', 'pods' ),
'type' => 'boolean',
'default' => false,
'dependency' => true,
Expand All @@ -183,44 +183,18 @@ public function options( $options, $pod ) {
'depends-on' => array( 'pfat_enable' => true ),
'boolean_yes_label' => '',
),
'pfat_single' => array(
'label' => __( 'Taxonomy Template', 'pods' ),
'help' => __( 'Name of Pods template to use to present this taxonomy object itself.', 'pods' ),
'type' => 'text',
'default' => false,
'depends-on' => array( 'pfat_enable' => true ),
),
'pfat_append_single' => array(
'label' => __( 'Template Location', 'pods' ),
'help' => __( 'Whether the template will go before, after or in place of the post content.', 'pods' ),
'depends-on' => array( 'pfat_enable' => true ),
),
'pfat_filter_single' => array(
'label' => __( 'Taxonomy Template Filter', 'pods' ),
'help' => __( 'Which filter to use for taxonomy view.', 'pods' ),
'default' => 'get_the_archive_description',
'type' => 'text',
'depends-on' => array( 'pfat_enable' => true ),
),
'pfat_archive' => array(
'label' => __( 'Taxonomy Archive Template', 'pods' ),
'help' => __( 'Name of Pods template to use for posts in this taxonomy.', 'pods' ),
'label' => __( 'Taxonomy Template', 'pods' ),
'help' => __( 'Name of Pods template to use for this taxonomy.', 'pods' ),
'type' => 'text',
'default' => false,
'depends-on' => array( 'pfat_enable' => true ),
),
'pfat_append_archive' => array(
'label' => __( 'Archive Template Location', 'pods' ),
'label' => __( 'Template Location', 'pods' ),
'help' => __( 'Whether the template will go before, after or in place of the post content.', 'pods' ),
'depends-on' => array( 'pfat_enable' => true ),
),
'pfat_filter_archive' => array(
'label' => __( 'Archive Template Filter', 'pods' ),
'help' => __( 'Which filter to use for archives.', 'pods' ),
'default' => 'the_content',
'type' => 'text',
'depends-on' => array( 'pfat_enable' => true ),
),
);
}//end if

Expand All @@ -245,9 +219,8 @@ public function options( $options, $pod ) {

}

$template_titles = array_combine( $this->get_template_titles(), $this->get_template_titles() );
$options['pods-pfat']['pfat_archive']['data'] = array( null => __( 'No Archive view template', 'pods' ) ) + $template_titles;
$options['pods-pfat']['pfat_single']['data'] = array( null => __( 'No view template', 'pods' ) ) + $template_titles;
$options['pods-pfat']['pfat_archive']['data'] = array( null => __( 'No Archive view template', 'pods' ) ) + ( array_combine( $this->get_template_titles(), $this->get_template_titles() ) );
$options['pods-pfat']['pfat_single']['data'] = array_combine( $this->get_template_titles(), $this->get_template_titles() );
}

// Add data to $pick for template location
Expand All @@ -265,6 +238,11 @@ public function options( $options, $pod ) {
$options['pods-pfat'][ $k ] = array_merge( $option, $pick );
}
}

// remove single from taxonomy
if ( 'taxonomy' === $pod['type'] ) {
unset( $options['pods-pfat']['pfat_single'] );
}
}//end if

return $options;
Expand Down
4 changes: 2 additions & 2 deletions init.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Pods - Custom Content Types and Fields
Plugin URI: https://pods.io/
Description: Pods is a framework for creating, managing, and deploying customized content types and fields
Version: 2.7.16
Version: 2.7.17-a-1
Author: Pods Framework Team
Author URI: https://pods.io/about/
Text Domain: pods
Expand Down Expand Up @@ -36,7 +36,7 @@
add_action( 'init', 'pods_deactivate_pods_ui' );
} else {
// Current version
define( 'PODS_VERSION', '2.7.16' );
define( 'PODS_VERSION', '2.7.17-a-1' );

// Version tracking between DB updates themselves
define( 'PODS_DB_VERSION', '2.3.5' );
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pods",
"version": "2.7.16",
"version": "2.7.17-a-1",
"description": "Pods is a development framework for creating, extending, managing, and deploying customized content types in WordPress.",
"author": "Pods Foundation, Inc",
"homepage": "https://pods.io/",
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Tags: pods, custom post types, custom taxonomies, content types, custom fields,
Requires at least: 4.5
Tested up to: 5.3
Requires PHP: 5.3
Stable tag: 2.7.16
Stable tag: 2.7.17-a-1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down

0 comments on commit bb5cbcf

Please sign in to comment.