From c2388bb84914963d5e46ada52f86c63d5ce052d2 Mon Sep 17 00:00:00 2001 From: Scott Kingsley Clark Date: Wed, 13 Nov 2019 17:13:03 -0600 Subject: [PATCH 1/2] Update version --- README.md | 4 ++-- init.php | 4 ++-- package.json | 2 +- readme.txt | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d2f1a9d95e..6548f8398f 100644 --- a/README.md +++ b/README.md @@ -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/) diff --git a/init.php b/init.php index b1682af9d5..2e56cf12d4 100644 --- a/init.php +++ b/init.php @@ -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 @@ -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' ); diff --git a/package.json b/package.json index 21f0420ba2..e931cb3627 100644 --- a/package.json +++ b/package.json @@ -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/", diff --git a/readme.txt b/readme.txt index b7b5d1d3f1..e163c0d8c0 100644 --- a/readme.txt +++ b/readme.txt @@ -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 From 0514e8cc09e45bb464ca6f3aeb576ff4d2fd8fa3 Mon Sep 17 00:00:00 2001 From: Scott Kingsley Clark Date: Wed, 13 Nov 2019 18:14:07 -0600 Subject: [PATCH 2/2] Revert "Re Issue #3962: Make auto templates for a Taxonomy Pod behave sensibly" --- ...Pods_Templates_Auto_Template_Front_End.php | 117 ++++-------------- .../Pods_Templates_Auto_Template_Settings.php | 50 +++----- 2 files changed, 40 insertions(+), 127 deletions(-) diff --git a/components/Templates/includes/auto-template/Pods_Templates_Auto_Template_Front_End.php b/components/Templates/includes/auto-template/Pods_Templates_Auto_Template_Front_End.php index 2d09b92da3..7547e65f3c 100644 --- a/components/Templates/includes/auto-template/Pods_Templates_Auto_Template_Front_End.php +++ b/components/Templates/includes/auto-template/Pods_Templates_Auto_Template_Front_End.php @@ -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. */ @@ -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' ) ); - } } /** @@ -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; } @@ -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 @@ -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. @@ -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 ) ) { @@ -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']; } diff --git a/components/Templates/includes/auto-template/Pods_Templates_Auto_Template_Settings.php b/components/Templates/includes/auto-template/Pods_Templates_Auto_Template_Settings.php index dece87b3cb..c3d68aeff4 100644 --- a/components/Templates/includes/auto-template/Pods_Templates_Auto_Template_Settings.php +++ b/components/Templates/includes/auto-template/Pods_Templates_Auto_Template_Settings.php @@ -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 * @@ -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, @@ -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 @@ -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 @@ -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;