updated plugin GP Premium version 2.4.0

This commit is contained in:
2024-02-08 12:31:36 +00:00
committed by Gitium
parent c93ddc8e7a
commit ce653dd56c
59 changed files with 214 additions and 103 deletions

View File

@ -978,6 +978,10 @@ class GeneratePress_Block_Elements {
$custom_field = $block['attrs']['gpDynamicTextBefore'] . $custom_field;
}
add_filter( 'wp_kses_allowed_html', [ 'GeneratePress_Elements_Helper', 'expand_allowed_html' ], 10, 2 );
$custom_field = wp_kses_post( $custom_field );
remove_filter( 'wp_kses_allowed_html', [ 'GeneratePress_Elements_Helper', 'expand_allowed_html' ], 10, 2 );
$custom_field = apply_filters( 'generate_dynamic_element_text_output', $custom_field, $block );
$block_content = str_replace( $text_to_replace, $custom_field, $block_content );
} else {

View File

@ -85,16 +85,15 @@ class GeneratePress_Conditions {
);
// Add the post type archive.
if ( 'post' === $post_type_slug || ! empty( $post_type_object->has_archive ) ) {
$types[ $post_type_slug . '_archive' ] = array(
// We add this regardless of `has_archive` as we deal with that after taxonomies are added.
$types[ $post_type_slug . '_archive' ] = array(
/* translators: post type name */
'label' => sprintf( esc_html_x( '%s Archives', '%s is a singular post type name', 'gp-premium' ), $post_type->labels->singular_name ),
'locations' => array(
/* translators: post type name */
'label' => sprintf( esc_html_x( '%s Archives', '%s is a singular post type name', 'gp-premium' ), $post_type->labels->singular_name ),
'locations' => array(
/* translators: post type name */
'archive:' . $post_type_slug => sprintf( esc_html_x( '%s Archive', '%s is a singular post type name', 'gp-premium' ), $post_type->labels->singular_name ),
),
);
}
'archive:' . $post_type_slug => sprintf( esc_html_x( '%s Archive', '%s is a singular post type name', 'gp-premium' ), $post_type->labels->singular_name ),
),
);
// Add the taxonomies for the post type.
$taxonomies = get_object_taxonomies( $post_type_slug, 'objects' );
@ -127,6 +126,16 @@ class GeneratePress_Conditions {
$types[ $post_type_slug ]['locations'][ $post_type_slug . ':taxonomy:' . $taxonomy_slug ] = esc_html( $post_type->labels->singular_name . ' ' . $label );
}
}
// Remove the archives location if `has_archive` is set to false.
if ( 'post' !== $post_type_slug && empty( $post_type_object->has_archive ) ) {
unset( $types[ $post_type_slug . '_archive' ]['locations'][ 'archive:' . $post_type_slug ] );
}
// Remove the entire item if no locations exist.
if ( 0 === count( (array) $types[ $post_type_slug . '_archive' ]['locations'] ) ) {
unset( $types[ $post_type_slug . '_archive' ] );
}
}
return $types;

View File

@ -500,4 +500,28 @@ class GeneratePress_Elements_Helper {
return apply_filters( 'generate_hooks_list', $hooks );
}
/**
* Expand the wp_kses_post sanitization function to allow iframe HTML tags
*
* @param array $tags The allowed tags, attributes, and/or attribute values.
* @param string $context Context to judge allowed tags by. Allowed values are 'post'.
* @return array
*/
public static function expand_allowed_html( $tags, $context ) {
if ( ! isset( $tags['iframe'] ) ) {
$tags['iframe'] = [
'src' => true,
'height' => true,
'width' => true,
'frameborder' => true,
'allowfullscreen' => true,
'title' => true,
];
}
$tags = apply_filters( 'generate_dynamic_content_allowed_html', $tags, $context );
return $tags;
}
}

View File

@ -997,7 +997,11 @@ class GeneratePress_Hero {
foreach ( $matches[1] as $match ) {
if ( null !== get_post_meta( get_the_ID(), $match, true ) && '_thumbnail_id' !== $match ) {
$search[] = '{{custom_field.' . $match . '}}';
$replace[] = get_post_meta( get_the_ID(), $match, true );
$value = get_post_meta( get_the_ID(), $match, true );
add_filter( 'wp_kses_allowed_html', [ 'GeneratePress_Elements_Helper', 'expand_allowed_html' ], 10, 2 );
$value = wp_kses_post( $value );
remove_filter( 'wp_kses_allowed_html', [ 'GeneratePress_Elements_Helper', 'expand_allowed_html' ], 10, 2 );
$replace[] = $value;
}
}