updated plugin GP Premium version 1.11.2

This commit is contained in:
2020-08-13 14:53:39 +00:00
committed by Gitium
parent 3f0f8d3ac9
commit 885bbdd113
151 changed files with 11329 additions and 6954 deletions

View File

@ -1,16 +1,28 @@
<?php
/**
* This file sets up our Elements module.
*
* @since 1.7.0
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
require plugin_dir_path( __FILE__ ) . 'class-elements-helper.php';
require plugin_dir_path( __FILE__ ) . 'class-hooks.php';
require plugin_dir_path( __FILE__ ) . 'class-hero.php';
require plugin_dir_path( __FILE__ ) . 'class-layout.php';
require plugin_dir_path( __FILE__ ) . 'class-conditions.php';
require plugin_dir_path( __FILE__ ) . 'class-post-type.php';
$elements_dir = plugin_dir_path( __FILE__ );
require $elements_dir . 'class-conditions.php';
require $elements_dir . 'class-elements-helper.php';
require $elements_dir . 'class-hooks.php';
require $elements_dir . 'class-hero.php';
require $elements_dir . 'class-layout.php';
require $elements_dir . 'class-block.php';
require $elements_dir . 'class-post-type.php';
add_action( 'wp', 'generate_premium_do_elements' );
add_action( 'current_screen', 'generate_premium_do_elements' );
/**
* Execute our Elements.
*
@ -18,20 +30,15 @@ add_action( 'wp', 'generate_premium_do_elements' );
*/
function generate_premium_do_elements() {
$args = array(
'post_type' => 'gp_elements',
'no_found_rows' => true,
'post_status' => 'publish',
'numberposts' => 500,
'fields' => 'ids',
'suppress_filters' => false,
'post_type' => 'gp_elements',
'no_found_rows' => true,
'post_status' => 'publish',
'numberposts' => 500, // phpcs:ignore
'fields' => 'ids',
'order' => 'ASC',
'suppress_filters' => false,
);
$custom_args = apply_filters( 'generate_elements_custom_args', array(
'order' => 'ASC',
) );
$args = array_merge( $args, $custom_args );
// Prevent Polylang from altering the query.
if ( function_exists( 'pll_get_post_language' ) ) {
$args['lang'] = '';
@ -54,6 +61,10 @@ function generate_premium_do_elements() {
if ( 'layout' === $type ) {
new GeneratePress_Site_Layout( $post_id );
}
if ( 'block' === $type ) {
new GeneratePress_Block_Element( $post_id );
}
}
}
@ -83,7 +94,7 @@ add_filter( 'generate_element_post_id', 'generate_elements_ignore_languages' );
*
* @since 1.8
*
* @param int $post_id
* @param int $post_id The current post ID.
* @return bool|int
*/
function generate_elements_ignore_languages( $post_id ) {
@ -95,10 +106,77 @@ function generate_elements_ignore_languages( $post_id ) {
return $post_id;
}
if ( $language && $language !== pll_current_language( 'locale' ) ) {
if ( $language && $language !== pll_current_language( 'locale' ) ) { // phpcs:ignore -- Using Yoda check I am.
return false;
}
}
return $post_id;
}
add_action( 'save_post_wp_block', 'generate_elements_wp_block_update', 10, 2 );
/**
* Regenerate the GenerateBlocks CSS file when a re-usable block is saved.
*
* @since 1.11.0
* @param int $post_id The post ID.
* @param object $post The post object.
*/
function generate_elements_wp_block_update( $post_id, $post ) {
$is_autosave = wp_is_post_autosave( $post_id );
$is_revision = wp_is_post_revision( $post_id );
if ( $is_autosave || $is_revision || ! current_user_can( 'edit_post', $post_id ) ) {
return $post_id;
}
if ( isset( $post->post_content ) ) {
if ( strpos( $post->post_content, 'wp:generateblocks' ) !== false ) {
global $wpdb;
$option = get_option( 'generateblocks_dynamic_css_posts', array() );
$posts = $wpdb->get_col( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_generateblocks_reusable_blocks'" );
foreach ( (array) $posts as $id ) {
$display_conditions = get_post_meta( $id, '_generate_element_display_conditions', true );
if ( $display_conditions ) {
foreach ( (array) $display_conditions as $condition ) {
if ( 'general:site' === $condition['rule'] ) {
$option = array();
break;
}
if ( $condition['object'] && isset( $option[ $condition['object'] ] ) ) {
unset( $option[ $condition['object'] ] );
}
}
}
}
update_option( 'generateblocks_dynamic_css_posts', $option );
}
}
}
add_filter( 'generate_do_block_element_content', 'generate_add_block_element_content_filters' );
/**
* Apply content filters to our block elements.
*
* @since 1.11.0
* @param string $content The block element content.
*/
function generate_add_block_element_content_filters( $content ) {
$content = shortcode_unautop( $content );
$content = do_shortcode( $content );
if ( function_exists( 'wp_filter_content_tags' ) ) {
$content = wp_filter_content_tags( $content );
} elseif ( function_exists( 'wp_make_content_images_responsive' ) ) {
$content = wp_make_content_images_responsive( $content );
}
return $content;
}