Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hook into the admin_notices action for required message #110

Merged
merged 11 commits into from
Dec 30, 2020
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: MT Code Review
name: Code Review
on:
pull_request:
paths-ignore:
Expand All @@ -12,6 +12,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: moderntribe/action-tribe-phpcs@master
- uses: the-events-calendar/action-tribe-phpcs@master
with:
github-bot-token: ${{ secrets.GH_BOT_TOKEN }}
8 changes: 4 additions & 4 deletions classes/class-pods-beaver-page-data.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,16 @@ public static function get_current_pod_info() {
if ( $queried_object ) {
$id_lookup = true;

if ( isset( $queried_object->post_type ) ) {
if ( $queried_object instanceof WP_Post ) {
// Post Type Singular
$info['pod'] = $queried_object->post_type;
} elseif ( isset( $queried_object->taxonomy ) ) {
} elseif ( $queried_object instanceof WP_Term ) {
// Term Archive
$info['pod'] = $queried_object->taxonomy;
} elseif ( isset( $queried_object->user_login ) ) {
} elseif ( $queried_object instanceof WP_User ) {
// Author Archive
$info['pod'] = 'user';
} elseif ( isset( $queried_object->public ) && isset( $queried_object->name ) ) {
} elseif ( $queried_object instanceof WP_Post_Type ) {
// Post Type Archive
$info['pod'] = $queried_object->name;

Expand Down
39 changes: 23 additions & 16 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.3
* Version: 1.3.4
* 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.3' );
define( 'PODS_BEAVER_VERSION', '1.3.4' );
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 @@ -52,8 +52,9 @@ function pods_beaver_init() {

PodsBeaverPageData::init();

// Beaver Themer sets up a "virtual reality" fake being in the Loop #15 for any module using FLBuilderLoop::query()
add_action( 'fl_builder_loop_before_query', 'pods_beaver_fake_loop_add_actions');
// 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 @@ -83,14 +84,14 @@ function pods_beaver_admin_nag() {

if ( is_admin() && ( ! class_exists( 'FLBuilder' ) || ! defined( 'PODS_VERSION' ) ) ) {
printf(
'<div id="message" class="error"><p>%s</p></div>',
'<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' )
);
}

}

add_action( 'plugins_loaded', 'pods_beaver_admin_nag' );
add_action( 'admin_notices', 'pods_beaver_admin_nag' );

/**
* Post modules: JS for setting data_source to custom_query if a relationship field is selected as source
Expand All @@ -109,14 +110,24 @@ function pods_beaver_enqueue_assets() {
}

/**
* Register functions to fake the loop.
* Register function to start the fake loop.
*
* @since 1.1.1
* @since 1.3.3
*/
function pods_beaver_fake_loop_add_actions() {
function pods_beaver_fake_loop_start() {

add_action( 'loop_start', 'pods_beaver_fake_loop_true');
add_action( 'loop_end', 'pods_beaver_fake_loop_false');
add_action( 'fl_builder_loop_before_query', 'pods_beaver_fake_loop_true');

}

/**
* Register function to end the fake loop.
*
* @since 1.3.3
*/
function pods_beaver_fake_loop_end() {

add_action( 'fl_builder_loop_after_query', 'pods_beaver_fake_loop_false');

}

Expand All @@ -132,7 +143,7 @@ function pods_beaver_fake_loop_true() {

global $wp_query;

// Fake being in the loop.
// Fake being in the loop.
$wp_query->in_the_loop = true;

}
Expand All @@ -152,10 +163,6 @@ function pods_beaver_fake_loop_false() {
// Stop faking being in the loop.
$wp_query->in_the_loop = false;

// cleanup - keep fake as close to beaver as possible
remove_action( 'loop_start', 'pods_beaver_fake_loop_true');
remove_action( 'loop_end', 'pods_beaver_fake_loop_false');

}

/**
Expand Down
8 changes: 6 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ Contributors: quasel, sc0ttkclark, jimtrue, smarterdigitalltd
Donate link: https://pods.io/friends-of-pods/
Tags: pods, beaver builder, beaver themer
Requires at least: 4.4
Tested up to: 5.4
Tested up to: 5.6
Requires PHP: 5.4
Stable tag: 1.3.3
Stable tag: 1.3.4
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

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

== Changelog ==

= 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

= 1.3.3 - March 26th, 2020 =
* Added: Now requiring PHP 5.4+
* Added: Freemius support when running Pods 2.7.17
Expand Down