updated plugin GP Premium
version 2.2.0
This commit is contained in:
@ -41,7 +41,7 @@ class GeneratePress_Block_Elements {
|
||||
public function __construct() {
|
||||
add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_assets' ), 8 );
|
||||
|
||||
if ( version_compare( $GLOBALS['wp_version'], '5.8-alpha-1', '<' ) ) {
|
||||
if ( version_compare( $GLOBALS['wp_version'], '5.8', '<' ) ) {
|
||||
add_filter( 'block_categories', array( $this, 'add_block_category' ) );
|
||||
} else {
|
||||
add_filter( 'block_categories_all', array( $this, 'add_block_category' ) );
|
||||
@ -586,16 +586,18 @@ class GeneratePress_Block_Elements {
|
||||
$url = get_permalink( $id );
|
||||
}
|
||||
|
||||
if ( 'post-meta' === $link_type ) {
|
||||
$url = get_post_meta( $id, $block['attrs']['gpDynamicLinkCustomField'], true );
|
||||
}
|
||||
if ( isset( $block['attrs']['gpDynamicLinkCustomField'] ) ) {
|
||||
if ( 'post-meta' === $link_type ) {
|
||||
$url = get_post_meta( $id, $block['attrs']['gpDynamicLinkCustomField'], true );
|
||||
}
|
||||
|
||||
if ( 'user-meta' === $link_type ) {
|
||||
$url = $this->get_user_data( $author_id, $block['attrs']['gpDynamicLinkCustomField'] );
|
||||
}
|
||||
if ( 'user-meta' === $link_type ) {
|
||||
$url = $this->get_user_data( $author_id, $block['attrs']['gpDynamicLinkCustomField'] );
|
||||
}
|
||||
|
||||
if ( 'term-meta' === $link_type ) {
|
||||
$url = get_term_meta( get_queried_object_id(), $block['attrs']['gpDynamicTextCustomField'], true );
|
||||
if ( 'term-meta' === $link_type ) {
|
||||
$url = get_term_meta( get_queried_object_id(), $block['attrs']['gpDynamicLinkCustomField'], true );
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'author-archives' === $link_type ) {
|
||||
@ -1132,8 +1134,8 @@ class GeneratePress_Block_Elements {
|
||||
}
|
||||
|
||||
if ( 'user-meta' === $settings['gpDynamicImageBg'] ) {
|
||||
$author_id = $this->get_author_id( $source, $block['attrs'] );
|
||||
$custom_field = $this->get_user_data( $author_id, $block['attrs']['gpDynamicImageCustomField'] );
|
||||
$author_id = $this->get_author_id( $source, $settings );
|
||||
$custom_field = $this->get_user_data( $author_id, $settings['gpDynamicImageCustomField'] );
|
||||
}
|
||||
|
||||
if ( 'featured-image' === $settings['gpDynamicImageBg'] && has_post_thumbnail( $id ) ) {
|
||||
@ -1180,8 +1182,8 @@ class GeneratePress_Block_Elements {
|
||||
}
|
||||
|
||||
if ( 'user-meta' === $settings['gpDynamicImageBg'] ) {
|
||||
$author_id = $this->get_author_id( $source, $block['attrs'] );
|
||||
$custom_field = $this->get_user_data( $author_id, $block['attrs']['gpDynamicImageCustomField'] );
|
||||
$author_id = $this->get_author_id( $source, $settings );
|
||||
$custom_field = $this->get_user_data( $author_id, $settings['gpDynamicImageCustomField'] );
|
||||
}
|
||||
|
||||
if ( 'featured-image' === $settings['gpDynamicImageBg'] && has_post_thumbnail( $id ) ) {
|
||||
|
@ -128,6 +128,10 @@ class GeneratePress_Block_Element {
|
||||
case 'content-template':
|
||||
$hook = 'generate_before_do_template_part';
|
||||
break;
|
||||
|
||||
case 'loop-template':
|
||||
$hook = 'generate_before_main_content';
|
||||
break;
|
||||
}
|
||||
|
||||
if ( 'custom' === $hook && $custom_hook ) {
|
||||
@ -170,6 +174,13 @@ class GeneratePress_Block_Element {
|
||||
add_filter( 'generate_do_template_part', array( $this, 'do_template_part' ) );
|
||||
}
|
||||
|
||||
if ( 'loop-template' === $this->type ) {
|
||||
add_filter( 'generate_has_default_loop', '__return_false' );
|
||||
add_filter( 'generate_blog_columns', '__return_false' );
|
||||
add_filter( 'option_generate_blog_settings', array( $this, 'filter_blog_settings' ) );
|
||||
add_filter( 'post_class', array( $this, 'post_classes' ) );
|
||||
}
|
||||
|
||||
add_action( 'wp', array( $this, 'remove_elements' ), 100 );
|
||||
add_action( esc_attr( $hook ), array( $this, 'build_hook' ), absint( $priority ) );
|
||||
add_filter( 'generateblocks_do_content', array( $this, 'do_block_content' ) );
|
||||
@ -231,6 +242,33 @@ class GeneratePress_Block_Element {
|
||||
return $widgets;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter some of our blog settings.
|
||||
*
|
||||
* @param array $settings Existing blog settings.
|
||||
*/
|
||||
public function filter_blog_settings( $settings ) {
|
||||
if ( 'loop-template' === $this->type ) {
|
||||
$settings['infinite_scroll'] = false;
|
||||
$settings['read_more_button'] = false;
|
||||
}
|
||||
|
||||
return $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add class to our loop template item posts.
|
||||
*
|
||||
* @param array $classes Post classes.
|
||||
*/
|
||||
public function post_classes( $classes ) {
|
||||
if ( 'loop-template' === $this->type && is_main_query() ) {
|
||||
$classes[] = 'is-loop-template-item';
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove existing elements.
|
||||
*
|
||||
|
@ -53,6 +53,7 @@ class GeneratePress_Conditions {
|
||||
'general:search' => esc_attr__( 'Search Results', 'gp-premium' ),
|
||||
'general:no_results' => esc_attr__( 'No Search Results', 'gp-premium' ),
|
||||
'general:404' => esc_attr__( '404 Template', 'gp-premium' ),
|
||||
'general:is_paged' => esc_attr__( 'Paginated Results', 'gp-premium' ),
|
||||
),
|
||||
),
|
||||
);
|
||||
@ -249,7 +250,6 @@ class GeneratePress_Conditions {
|
||||
}
|
||||
|
||||
if ( $post_id ) {
|
||||
|
||||
// Get the location string.
|
||||
$front_page_id = get_option( 'page_on_front' );
|
||||
$blog_id = get_option( 'page_for_posts' );
|
||||
@ -265,6 +265,8 @@ class GeneratePress_Conditions {
|
||||
|
||||
$object = $post_id;
|
||||
}
|
||||
} elseif ( isset( $_GET['post_type'] ) ) { // phpcs:ignore -- Just checking if it's set.
|
||||
$location = 'post:' . esc_attr( $_GET['post_type'] ); // phpcs:ignore -- No data processing going on.
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -339,6 +341,8 @@ class GeneratePress_Conditions {
|
||||
} elseif ( is_front_page() && is_home() && ( in_array( 'general:blog', $conditional ) || in_array( 'general:front_page', $conditional ) ) ) {
|
||||
// If the home page is the blog, both of general:blog and general:front_page apply.
|
||||
$show = true;
|
||||
} elseif ( in_array( 'general:is_paged', $conditional ) && is_paged() ) {
|
||||
$show = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -367,6 +371,8 @@ class GeneratePress_Conditions {
|
||||
} elseif ( is_front_page() && is_home() && ( in_array( 'general:blog', $conditional ) || in_array( 'general:front_page', $conditional ) ) ) {
|
||||
// If the home page is the blog, both of general:blog and general:front_page apply.
|
||||
$show = false;
|
||||
} elseif ( in_array( 'general:is_paged', $conditional ) && is_paged() ) {
|
||||
$show = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -148,6 +148,13 @@ class GeneratePress_Elements_Helper {
|
||||
$block_element->post_content = str_replace( '{{current_year}}', date( 'Y' ), $block_element->post_content ); // phpcs:ignore -- Prefer date().
|
||||
}
|
||||
|
||||
// Handle embeds for block elements.
|
||||
global $wp_embed;
|
||||
|
||||
if ( is_object( $wp_embed ) && method_exists( $wp_embed, 'autoembed' ) ) {
|
||||
$block_element->post_content = $wp_embed->autoembed( $block_element->post_content );
|
||||
}
|
||||
|
||||
return apply_filters( 'generate_do_block_element_content', do_blocks( $block_element->post_content ) );
|
||||
}
|
||||
|
||||
|
@ -341,6 +341,14 @@ class GeneratePress_Site_Layout {
|
||||
if ( $this->disable_content_title ) {
|
||||
add_filter( 'generate_block_editor_show_content_title', '__return_false' );
|
||||
}
|
||||
|
||||
if ( $this->content_area ) {
|
||||
add_filter( 'generate_block_editor_content_area_type', array( $this, 'set_editor_content_area' ) );
|
||||
}
|
||||
|
||||
if ( $this->content_width ) {
|
||||
add_filter( 'generate_block_editor_container_width', array( $this, 'set_editor_content_width' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -355,22 +363,20 @@ class GeneratePress_Site_Layout {
|
||||
if ( is_admin() ) {
|
||||
$admin_css = '';
|
||||
|
||||
if ( 'full-width' === $this->content_area ) {
|
||||
$admin_css .= 'html .editor-styles-wrapper .wp-block{max-width: 100%}';
|
||||
if ( version_compare( generate_premium_get_theme_version(), '3.2.0-alpha.1', '<' ) ) {
|
||||
if ( 'full-width' === $this->content_area ) {
|
||||
$admin_css .= 'html .editor-styles-wrapper .wp-block{max-width: 100%}';
|
||||
}
|
||||
|
||||
if ( $this->content_width ) {
|
||||
$admin_css .= 'html .editor-styles-wrapper .wp-block{max-width: ' . absint( $this->content_width ) . 'px;}';
|
||||
}
|
||||
}
|
||||
|
||||
if ( $this->content_area ) {
|
||||
$admin_css .= '#generate-layout-page-builder-container {opacity: 0.5;pointer-events: none;}';
|
||||
}
|
||||
|
||||
if ( $this->disable_content_title ) {
|
||||
$admin_css .= '.content-title-visibility{display: none !important;}label[for="meta-generate-disable-headline"] {opacity: 0.5;pointer-events: none;}';
|
||||
}
|
||||
|
||||
if ( $this->content_width ) {
|
||||
$admin_css .= 'html .editor-styles-wrapper .wp-block{max-width: ' . absint( $this->content_width ) . 'px;}';
|
||||
}
|
||||
|
||||
if ( $admin_css ) {
|
||||
wp_add_inline_style( 'wp-edit-blocks', $admin_css );
|
||||
}
|
||||
@ -460,6 +466,36 @@ class GeneratePress_Site_Layout {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the content area type in the editor.
|
||||
*
|
||||
* @param string $area Content area type.
|
||||
*/
|
||||
public function set_editor_content_area( $area ) {
|
||||
if ( 'full-width' === $this->content_area ) {
|
||||
$area = 'true';
|
||||
}
|
||||
|
||||
if ( 'contained-container' === $this->content_area ) {
|
||||
$area = 'contained';
|
||||
}
|
||||
|
||||
return $area;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the content width in the editor.
|
||||
*
|
||||
* @param string $width Content width with unit.
|
||||
*/
|
||||
public function set_editor_content_width( $width ) {
|
||||
if ( $this->content_width ) {
|
||||
$width = absint( $this->content_width ) . 'px';
|
||||
}
|
||||
|
||||
return $width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable the Secondary Navigation if set.
|
||||
*
|
||||
|
@ -128,8 +128,13 @@ class GeneratePress_Elements_Metabox {
|
||||
public function scripts( $hook ) {
|
||||
if ( in_array( $hook, array( 'post.php', 'post-new.php' ) ) ) {
|
||||
if ( 'gp_elements' === get_post_type() ) {
|
||||
// Autosave won't save Element type, so we can't have it.
|
||||
wp_dequeue_script( 'autosave' );
|
||||
$element_type = get_post_meta( get_the_ID(), '_generate_element_type', true );
|
||||
|
||||
// Remove autosave when dealing with non-content Elements.
|
||||
// phpcs:ignore -- No data processing happening.
|
||||
if ( 'block' !== $element_type || ( isset( $_GET['element_type'] ) && 'block' !== $_GET['element_type'] ) ) {
|
||||
wp_dequeue_script( 'autosave' );
|
||||
}
|
||||
|
||||
$deps = array( 'jquery' );
|
||||
|
||||
|
@ -95,7 +95,7 @@ class GeneratePress_Elements_Post_Type {
|
||||
|
||||
$args = array(
|
||||
'labels' => $labels,
|
||||
'supports' => array( 'title', 'editor', 'thumbnail', 'custom-fields', 'page-attributes' ),
|
||||
'supports' => array( 'title', 'editor', 'thumbnail', 'custom-fields', 'page-attributes', 'revisions' ),
|
||||
'hierarchical' => true,
|
||||
'public' => false,
|
||||
'show_ui' => true,
|
||||
@ -142,7 +142,7 @@ class GeneratePress_Elements_Post_Type {
|
||||
}
|
||||
|
||||
if ( 'block' === $type ) {
|
||||
$args['supports'] = array( 'title', 'editor', 'custom-fields', 'page-attributes' );
|
||||
$args['supports'] = array( 'title', 'editor', 'custom-fields', 'page-attributes', 'revisions' );
|
||||
}
|
||||
|
||||
if ( 'layout' === $type ) {
|
||||
|
Reference in New Issue
Block a user