Skip to content

Commit

Permalink
Merge pull request #112 from pods-framework/release/1.3.5
Browse files Browse the repository at this point in the history
1.3.5 - January 8th, 2021
  • Loading branch information
sc0ttkclark committed Jan 8, 2021
2 parents 0cc14c4 + 8aca2b3 commit dbf995f
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 19 deletions.
41 changes: 37 additions & 4 deletions classes/class-pods-beaver-page-data.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ final class PodsBeaverPageData {
*/
static $pods = array();

/**
* Track the state similar to $query->fl_builder_loop, in_the_loop().
*
* @var array
*
* @since 1.3.5
*/
static private $pods_beaver_loop;

/**
* Add Beaver Builder group for Pods.
*
Expand All @@ -26,9 +35,28 @@ public static function init() {
FLPageData::add_group( 'pods', array(
'label' => __( 'Pods Field from:', 'pods-beaver-builder-themer-add-on' ),
) );

self::pods_beaver_loop_false();
}

/**
* Set $pods_beaver_loop
*
* @since 1.3.5
*/
public static function pods_beaver_loop_true() {
self::$pods_beaver_loop = true;
}

/**
* Set $pods_beaver_loop
*
* @since 1.3.5
*/
public static function pods_beaver_loop_false() {
self::$pods_beaver_loop = false;
}

/**
* Get current pod info.
*
Expand All @@ -44,6 +72,15 @@ public static function get_current_pod_info() {
'pod' => null,
'id' => null,
);

if ( self::$pods_beaver_loop ) {
// We are in a loop not caused by FLThemeBuilderFieldConnections::connect_all_layout_settings to trigger connect_settings()
$info = array(
'pod' => get_post_type(),
'id' => get_the_ID(),
);
return $info;
}

$queried_object = get_queried_object();

Expand Down Expand Up @@ -155,10 +192,6 @@ public static function get_pod( $settings = array() ) {
break;
}
}
} elseif ( 'fl_builder_node_settings' !== current_filter() && in_the_loop() ) {
// We are in a loop not caused by FLThemeBuilderFieldConnections::connect_all_layout_settings to trigger connect_settings()
$pod_name = get_post_type();
$item_id = get_the_ID();
} else {
$info = self::get_current_pod_info();

Expand Down
27 changes: 14 additions & 13 deletions pods-beaver-themer.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Plugin Name: Pods Beaver Themer Add-On
* Plugin URI: http://pods.io/
* Description: Integration with Beaver Builder Themer (https://www.wpbeaverbuilder.com). Provides a UI for mapping Field Connections with Pods
* Version: 1.3.4
* Version: 1.3.5
* Author: Quasel, Pods Framework Team
* Author URI: http://pods.io/about/
* Text Domain: pods-beaver-builder-themer-add-on
Expand All @@ -30,7 +30,7 @@
* @package Pods\Beaver Themer
*/

define( 'PODS_BEAVER_VERSION', '1.3.4' );
define( 'PODS_BEAVER_VERSION', '1.3.5' );
define( 'PODS_BEAVER_FILE', __FILE__ );
define( 'PODS_BEAVER_DIR', plugin_dir_path( PODS_BEAVER_FILE ) );
define( 'PODS_BEAVER_URL', plugin_dir_url( PODS_BEAVER_FILE ) );
Expand All @@ -54,7 +54,6 @@ function pods_beaver_init() {

// Fake being "in the loop" for any module using FLBuilderLoop::query() (see #15)
add_action( 'fl_builder_loop_before_query', 'pods_beaver_fake_loop_start');
add_action( 'fl_builder_loop_after_query', 'pods_beaver_fake_loop_end');

// Priority 0 to run before FLThemeBuilderRulesLocation::set_preview_query() - Beaver Themer
// add_action( 'wp_enqueue_scripts', 'pods_beaver_enqueue_assets', 0 );
Expand Down Expand Up @@ -82,10 +81,10 @@ function pods_beaver_init() {
*/
function pods_beaver_admin_nag() {

if ( is_admin() && ( ! class_exists( 'FLBuilder' ) || ! defined( 'PODS_VERSION' ) ) ) {
if ( ! class_exists( 'FLBuilder' ) || ! defined( 'PODS_VERSION' ) || version_compare( PODS_VERSION, '2.7.26', '<' ) ) {
printf(
'<div class="notice notice-error"><p>%s</p></div>',
esc_html__( 'Pods Beaver Themer requires that the Pods and Beaver Builder Themer plugins be installed and activated.', 'pods-beaver-builder-themer-add-on' )
esc_html__( 'Pods Beaver Themer requires that the Pods (2.7.26+) and Beaver Builder Themer plugins be installed and activated.', 'pods-beaver-builder-themer-add-on' )
);
}

Expand All @@ -110,25 +109,26 @@ function pods_beaver_enqueue_assets() {
}

/**
* Register function to start the fake loop.
* Register function to tell Pods shortcodes to start detecting from the current post.
*
* @since 1.3.3
*/
function pods_beaver_fake_loop_start() {
add_filter( 'pods_shortcode_detect_from_current_post', '__return_true', 9 );
PodsBeaverPageData::pods_beaver_loop_true();

add_action( 'fl_builder_loop_before_query', 'pods_beaver_fake_loop_true');

// Remove the hook after the end of the loop.
add_action( 'loop_end', 'pods_beaver_fake_loop_end' );
}

/**
* Register function to end the fake loop.
* Register function to tell Pods shortcodes to stop detecting from the current post.
*
* @since 1.3.3
*/
function pods_beaver_fake_loop_end() {

add_action( 'fl_builder_loop_after_query', 'pods_beaver_fake_loop_false');

remove_filter( 'pods_shortcode_detect_from_current_post', '__return_true', 9 );
PodsBeaverPageData::pods_beaver_loop_false();
}

/**
Expand All @@ -138,6 +138,7 @@ function pods_beaver_fake_loop_end() {
* add_action( 'loop_start', 'pods_beaver_fake_loop_true' );
*
* @since 1.0
* @deprecated since version 1.3.5
*/
function pods_beaver_fake_loop_true() {

Expand All @@ -155,6 +156,7 @@ function pods_beaver_fake_loop_true() {
* add_action( 'loop_end', 'pods_beaver_fake_loop_false' );
*
* @since 1.0
* @deprecated since version 1.3.5
*/
function pods_beaver_fake_loop_false() {

Expand Down Expand Up @@ -533,4 +535,3 @@ function pods_beaver_freemius() {
}
}
add_action( 'pods_freemius_init', 'pods_beaver_freemius' );

9 changes: 7 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
=== Pods Beaver Themer Add-On ===
Contributors: quasel, sc0ttkclark, jimtrue, smarterdigitalltd
Contributors: quasel, sc0ttkclark, jimtrue, smarterdigitalltd, keraweb, nicdford,
Donate link: https://pods.io/friends-of-pods/
Tags: pods, beaver builder, beaver themer
Requires at least: 4.4
Tested up to: 5.6
Requires PHP: 5.4
Stable tag: 1.3.4
Stable tag: 1.3.5
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -72,6 +72,11 @@ You can use [GitHub Updater](https://github.com/afragen/github-updater). A simpl

== Changelog ==

= 1.3.5 - January 8th, 2021 =
* Required: This add-on now requires Pods 2.7.26+ in order to function fully with the latest fixes.
* Fixed: Properly hook into the Beaver Themer loop functionality to tell the Pods shortcode to reference the current post in the loop. #112 (@sc0ttkclark)
* Updated: Fixed Branch for Afragen Github Updater.

= 1.3.4 - December 30th, 2020 =
* Fixed: Admin notices are now using the correct action for showing the message that Pods and Beaver Themer plugins (if not available) are required to use this plugin. #110
* Fixed: Properly set post type parameter (if we have it) to fix issues with Polylang and other plugin compatibility. #109
Expand Down

0 comments on commit dbf995f

Please sign in to comment.