updated plugin GP Premium version 2.5.2

This commit is contained in:
KawaiiPunk 2025-04-29 21:19:14 +00:00 committed by Gitium
parent c53f9e0e50
commit eb9181b250
14 changed files with 470 additions and 21 deletions

View File

@ -0,0 +1 @@
<?php return array('dependencies' => array('wp-hooks', 'wp-i18n'), 'version' => 'bfbc5254c52ffe55aa92');

View File

@ -0,0 +1 @@
(()=>{"use strict";const s=window.wp.i18n,e=window.wp.hooks;(0,e.addFilter)("generateblocks.dynamicTags.sourceOptions","generatepress-pro/dynamicTags/set-adjacent-post-options",(function(e,{dynamicTagType:t}){return"post"!==t||(e.push({value:"next-post",label:(0,s.__)("Next Post","gp-premium")}),e.push({value:"previous-post",label:(0,s.__)("Previous Post","gp-premium")})),e})),(0,e.addFilter)("generateblocks.dynamicTags.sourcesInOptions","generatepress-pro/dynamicTags/set-adjacent-sources-in-options",(function(s){return s.push("next-post"),s.push("previous-post"),s}))})();

View File

@ -80,3 +80,7 @@ button.close-choose-element-type svg {
font-size: 11px;
border-radius: 2px;
}
.wrap #generate_premium_elements.closed .inside {
display: block;
}

View File

@ -385,7 +385,7 @@ class GeneratePress_Pro_Font_Library_Rest extends WP_REST_Controller {
// Generate the font CSS.
$generate_css = $this->build_css_file();
if ( false === $generate_css->success ) {
if ( false === $generate_css->data['success'] ) {
return $this->error( 500, __( 'CSS Generation failed', 'gp-premium' ) );
}

View File

@ -3,7 +3,7 @@
* Plugin Name: GP Premium
* Plugin URI: https://generatepress.com
* Description: The entire collection of GeneratePress premium modules.
* Version: 2.5.0
* Version: 2.5.2
* Requires at least: 6.1
* Requires PHP: 7.2
* Author: Tom Usborne
@ -19,7 +19,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
define( 'GP_PREMIUM_VERSION', '2.5.0' );
define( 'GP_PREMIUM_VERSION', '2.5.2' );
define( 'GP_PREMIUM_DIR_PATH', plugin_dir_path( __FILE__ ) );
define( 'GP_PREMIUM_DIR_URL', plugin_dir_url( __FILE__ ) );
define( 'GP_LIBRARY_DIRECTORY', plugin_dir_path( __FILE__ ) . 'library/' );
@ -53,16 +53,6 @@ if ( ! function_exists( 'generatepress_is_module_active' ) ) {
}
}
if ( ! function_exists( 'generate_package_setup' ) ) {
add_action( 'plugins_loaded', 'generate_package_setup' );
/**
* Set up our translations
**/
function generate_package_setup() {
load_plugin_textdomain( 'gp-premium', false, 'gp-premium/langs/' );
}
}
if ( generatepress_is_module_active( 'generate_package_backgrounds', 'GENERATE_BACKGROUNDS' ) ) {
require_once GP_PREMIUM_DIR_PATH . 'backgrounds/generate-backgrounds.php';
}
@ -81,6 +71,8 @@ if ( generatepress_is_module_active( 'generate_package_disable_elements', 'GENER
if ( generatepress_is_module_active( 'generate_package_elements', 'GENERATE_ELEMENTS' ) ) {
require_once GP_PREMIUM_DIR_PATH . 'elements/elements.php';
require_once GP_PREMIUM_DIR_PATH . 'inc/class-register-dynamic-tags.php';
require_once GP_PREMIUM_DIR_PATH . 'inc/class-adjacent-posts.php';
}
if ( generatepress_is_module_active( 'generate_package_secondary_nav', 'GENERATE_SECONDARY_NAV' ) ) {
@ -132,6 +124,8 @@ function generate_premium_load_modules() {
if ( version_compare( generate_premium_get_theme_version(), '3.1.0-alpha.1', '<' ) && generatepress_is_module_active( 'generate_package_colors', 'GENERATE_COLORS' ) ) {
require_once GP_PREMIUM_DIR_PATH . 'colors/generate-colors.php';
}
load_plugin_textdomain( 'gp-premium', false, 'gp-premium/langs/' );
}
// General functionality.
@ -160,11 +154,8 @@ if ( generatepress_is_module_active( 'generate_package_font_library', 'GENERATE_
require_once GP_PREMIUM_DIR_PATH . 'font-library/class-font-library.php';
require_once GP_PREMIUM_DIR_PATH . 'font-library/class-font-library-rest.php';
require_once GP_PREMIUM_DIR_PATH . 'font-library/class-font-library-optimize.php';
if ( is_admin() ) {
require_once GP_PREMIUM_DIR_PATH . 'font-library/class-font-library-cpt.php';
}
}
if ( ! function_exists( 'generate_premium_updater' ) ) {
add_action( 'admin_init', 'generate_premium_updater', 0 );

View File

@ -0,0 +1,84 @@
<?php
/**
* The class to integrate adjacent post dynamic tags.
*
* @package GeneratePress/Extend/DynamicTags
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* GeneratePress Pro adjacted post dynamic tags.
*
* @since 1.4.0
*/
class GeneratePress_Pro_Dynamic_Tags_Adjacent_Posts extends GeneratePress_Pro_Singleton {
/**
* Init.
*/
public function init() {
add_action( 'init', array( $this, 'setup' ) );
}
public function setup() {
// Bail out if GenerateBlocks Pro is active.
if ( class_exists( 'GenerateBlocks_Pro_Dynamic_Tags_Adjacent_Posts' ) ) {
return;
}
add_filter( 'generateblocks_dynamic_tag_id', array( $this, 'set_adjacent_post_ids' ), 10, 2 );
add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_scripts' ) );
}
public function enqueue_scripts() {
$editor_assets = generate_premium_get_enqueue_assets( 'adjacent-posts' );
wp_enqueue_script(
'generatepress-pro-adjacent-posts',
GP_PREMIUM_DIR_URL . 'dist/adjacent-posts.js',
$editor_assets['dependencies'],
$editor_assets['version'],
true
);
}
/**
* Set adjacent post ids.
*
* @param int $id The post id.
* @param array $options The options.
*/
public function set_adjacent_post_ids( $id, $options ) {
$source = $options['source'] ?? '';
if ( 'next-post' === $source ) {
$in_same_term = $options['inSameTerm'] ?? false;
$term_taxonomy = $options['sameTermTaxonomy'] ?? 'category';
$next_post = get_next_post( $in_same_term, '' );
if ( ! is_object( $next_post ) ) {
return false;
}
return $next_post->ID;
}
if ( 'previous-post' === $source ) {
$in_same_term = $options['inSameTerm'] ?? false;
$term_taxonomy = $options['sameTermTaxonomy'] ?? 'category';
$previous_post = get_previous_post( $in_same_term, '', $term_taxonomy );
if ( ! is_object( $previous_post ) ) {
return false;
}
return $previous_post->ID;
}
return $id;
}
}
GeneratePress_Pro_Dynamic_Tags_Adjacent_Posts::get_instance()->init();

View File

@ -0,0 +1,306 @@
<?php
/**
* The Dynamic Tags class file.
*
* @package GeneratePress_Pro\Dynamic_Tags
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Class for handling dynamic tags.
*
* @since 2.0.0
*/
class GeneratePress_Pro_Dynamic_Tags_Register extends GeneratePress_Pro_Singleton {
/**
* Initialize all hooks.
*
* @return void
*/
public function init() {
add_action( 'init', [ $this, 'register' ] );
}
/**
* Register the tags.
*
* @return void
*/
public function register() {
// Don't register these tags if we don't have the registration class, or if GenerateBlocks Pro is already registering them.
if ( ! class_exists( 'GenerateBlocks_Register_Dynamic_Tag' ) || class_exists( 'GenerateBlocks_Pro_Dynamic_Tags_Register' ) ) {
return;
}
new GenerateBlocks_Register_Dynamic_Tag(
[
'title' => __( 'Archive Title', 'gp-premium' ),
'tag' => 'archive_title',
'type' => 'archive',
'supports' => [],
'description' => __( 'Get the title for the current archive being viewed.', 'gp-premium' ),
'return' => [ $this, 'get_archive_title' ],
]
);
new GenerateBlocks_Register_Dynamic_Tag(
[
'title' => __( 'Archive Description', 'gp-premium' ),
'tag' => 'archive_description',
'type' => 'archive',
'supports' => [],
'description' => __( 'Get the description for the current archive being viewed.', 'gp-premium' ),
'return' => [ $this, 'get_archive_description' ],
]
);
new GenerateBlocks_Register_Dynamic_Tag(
[
'title' => __( 'Term Meta', 'gp-premium' ),
'tag' => 'term_meta',
'type' => 'term',
'supports' => [ 'meta', 'source' ],
'description' => __( 'Access term meta by key for the specified term. Return value must be a string.', 'gp-premium' ),
'return' => [ $this, 'get_term_meta' ],
]
);
new GenerateBlocks_Register_Dynamic_Tag(
[
'title' => __( 'Current year', 'gp-premium' ),
'tag' => 'current_year',
'type' => 'site',
'supports' => [],
'return' => [ $this, 'get_current_year' ],
]
);
new GenerateBlocks_Register_Dynamic_Tag(
[
'title' => __( 'Previous Posts URL', 'gp-premium' ),
'tag' => 'previous_posts_page_url',
'type' => 'post',
'supports' => [ 'source', 'instant-pagination' ],
'return' => [ $this, 'get_previous_posts_page_url' ],
]
);
new GenerateBlocks_Register_Dynamic_Tag(
[
'title' => __( 'Next Posts URL', 'gp-premium' ),
'tag' => 'next_posts_page_url',
'type' => 'post',
'supports' => [ 'source', 'instant-pagination' ],
'return' => [ $this, 'get_next_posts_page_url' ],
]
);
}
/**
* Get the archive title.
*
* @param array $options The options.
* @param object $block The block.
* @param object $instance The block instance.
* @return string
*/
public static function get_archive_title( $options, $block, $instance ) {
$output = '';
$id = $options['id'] ?? 0;
if ( is_category() ) {
$output = single_cat_title( '', false );
} elseif ( is_tag() ) {
$output = single_tag_title( '', false );
} elseif ( is_author() ) {
$output = get_the_author();
} elseif ( is_post_type_archive() ) {
$output = post_type_archive_title( '', false );
} elseif ( is_tax() ) {
$output = single_term_title( '', false );
} elseif ( is_home() ) {
$page = get_option( 'page_for_posts' ) ?? 0;
if ( $page ) {
$output = get_the_title( $page );
} else {
$output = __( 'Blog', 'generateblocks-pro' );
}
} elseif ( is_search() ) {
$output = get_search_query();
} elseif ( $id ) {
if ( term_exists( (int) $id ) ) {
$term = get_term( $id );
$output = $term->name;
} elseif ( is_string( $id ) ) {
// Assume it's a post type archive title.
$post_type_obj = get_post_type_object( $id );
$title = $post_type_obj->labels->name ?? '';
if ( $title ) {
/**
* Core Filter. Filters the post type archive title.
*
* @param string $post_type_name Post type 'name' label.
* @param string $post_type Post type.
*/
$output = apply_filters( 'post_type_archive_title', $title, $id );
}
}
}
return GenerateBlocks_Dynamic_Tag_Callbacks::output( $output, $options, $instance );
}
/**
* Get the archive description.
*
* @param array $options The options.
* @param object $block The block.
* @param object $instance The block instance.
* @return string
*/
public static function get_archive_description( $options, $block, $instance ) {
$output = get_the_archive_description();
return GenerateBlocks_Dynamic_Tag_Callbacks::output( $output, $options, $instance );
}
/**
* Get the term meta.
*
* @param array $options The options.
* @param array $block The block.
* @param object $instance The block instance.
* @return string
*/
public static function get_term_meta( $options, $block, $instance ) {
$id = GenerateBlocks_Dynamic_Tags::get_id( $options, 'term', $instance );
if ( ! $id ) {
return GenerateBlocks_Dynamic_Tag_Callbacks::output( '', $options, $instance );
}
$key = $options['key'] ?? '';
$output = '';
if ( empty( $key ) ) {
return GenerateBlocks_Dynamic_Tag_Callbacks::output( $output, $options, $instance );
}
$value = GenerateBlocks_Meta_Handler::get_term_meta( $id, $key, true );
if ( ! $value ) {
return GenerateBlocks_Dynamic_Tag_Callbacks::output( $output, $options, $instance );
}
add_filter( 'wp_kses_allowed_html', [ 'GenerateBlocks_Dynamic_Tags', 'expand_allowed_html' ], 10, 2 );
$output = wp_kses_post( $value );
remove_filter( 'wp_kses_allowed_html', [ 'GenerateBlocks_Dynamic_Tags', 'expand_allowed_html' ], 10, 2 );
return GenerateBlocks_Dynamic_Tag_Callbacks::output( $output, $options, $instance );
}
/**
* Get the current year.
*
* @param array $options The options.
* @param array $block The block.
* @param object $instance The block instance.
*
* @return string
*/
public static function get_current_year( $options, $block, $instance ) {
$output = wp_date( 'Y' );
return GenerateBlocks_Dynamic_Tag_Callbacks::output( $output, $options, $instance );
}
/**
* Get the previous post page URL.
*
* @param array $options The options.
* @param object $block The block.
* @param object $instance The block instance.
* @return string
*/
public static function get_previous_posts_page_url( $options, $block, $instance ) {
$page_key = isset( $instance->context['generateblocks/queryId'] ) ? 'query-' . $instance->context['generateblocks/queryId'] . '-page' : 'query-page';
$page = empty( $_GET[ $page_key ] ) ? 1 : (int) $_GET[ $page_key ]; // phpcs:ignore -- No data processing happening.
$inherit_query = $instance->context['generateblocks/inheritQuery'] ?? false;
$output = '';
if ( $inherit_query ) {
global $paged;
if ( $paged > 1 ) {
$output = previous_posts( false );
}
} elseif ( 1 !== $page ) {
$output = esc_url( add_query_arg( $page_key, $page - 1 ) );
}
return GenerateBlocks_Dynamic_Tag_Callbacks::output( $output, $options, $instance );
}
/**
* Get the next post page URL.
*
* @param array $options The options.
* @param object $block The block.
* @param object $instance The block instance.
* @return string
*/
public static function get_next_posts_page_url( $options, $block, $instance ) {
$page_key = isset( $instance->context['generateblocks/queryId'] ) ? 'query-' . $instance->context['generateblocks/queryId'] . '-page' : 'query-page';
$page = empty( $_GET[ $page_key ] ) ? 1 : (int) $_GET[ $page_key ]; // phpcs:ignore -- No data processing happening.
$args = $instance->context['generateblocks/query'] ?? [];
$inherit_query = $instance->context['generateblocks/inheritQuery'] ?? false;
$per_page = $args['per_page'] ?? apply_filters( 'generateblocks_query_per_page_default', 10, $args );
$output = '';
if ( $inherit_query ) {
global $wp_query, $paged;
if ( ! $paged ) {
$paged = 1; // phpcs:ignore -- Need to overrite global here.
}
$next_page = (int) $paged + 1;
if ( $next_page <= $wp_query->max_num_pages ) {
$output = next_posts( $wp_query->max_num_pages, false );
}
} else {
$query_data = $instance->context['generateblocks/queryData'] ?? null;
$query_type = $instance->context['generateblocks/queryType'] ?? GenerateBlocks_Block_Query::TYPE_WP_QUERY;
$is_wp_query = GenerateBlocks_Block_Query::TYPE_WP_QUERY === $query_type;
if ( ! $query_data || ( ! $is_wp_query && ! is_array( $query_data ) ) ) {
return GenerateBlocks_Dynamic_Tag_Callbacks::output( $output, $options, $instance );
}
$next_page = $page + 1;
$custom_query_max_pages = $is_wp_query
? (int) $query_data->max_num_pages
: ceil( count( $query_data ) / $per_page );
if ( $custom_query_max_pages < $next_page ) {
return GenerateBlocks_Dynamic_Tag_Callbacks::output( $output, $options, $instance );
}
if ( $custom_query_max_pages && $custom_query_max_pages !== $page ) {
$output = esc_url( add_query_arg( $page_key, $page + 1 ) );
}
wp_reset_postdata(); // Restore original Post Data.
}
return GenerateBlocks_Dynamic_Tag_Callbacks::output( $output, $options, $instance );
}
}
GeneratePress_Pro_Dynamic_Tags_Register::get_instance()->init();

View File

@ -716,3 +716,13 @@ if ( ! function_exists( 'generate_hidden_secondary_navigation' ) && function_exi
}
}
}
if ( ! function_exists( 'generate_package_setup' ) ) {
add_action( 'plugins_loaded', 'generate_package_setup' );
/**
* Set up our translations
**/
function generate_package_setup() {
// No longer needed.
}
}

View File

@ -14,6 +14,10 @@ class GeneratePress_Information_Customize_Control extends WP_Customize_Control {
public $description = '';
public $notice = '';
public function enqueue() {
wp_enqueue_style( 'gp-info-control', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'css/information-control.css', false, GP_PREMIUM_VERSION );
}
public function to_json() {
parent::to_json();
$this->json['description'] = $this->description;
@ -23,7 +27,7 @@ class GeneratePress_Information_Customize_Control extends WP_Customize_Control {
public function content_template() {
?>
<# if ( data.notice ) { #>
<div class="notice notice-info">
<div class="gp-info-notice gp-info-notice-info">
<# } #>
<# if ( data.label ) { #>

View File

@ -0,0 +1,12 @@
.gp-info-notice {
background: #fff;
border: 1px solid #c3c4c7;
border-left-width: 4px;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
margin: 0;
padding: 1px 12px;
}
.gp-info-notice-info {
border-left-color: #72aee6;
}

View File

@ -3,9 +3,9 @@ Contributors: edge22
Donate link: https://generatepress.com
Tags: generatepress
Requires at least: 6.1
Tested up to: 6.6
Tested up to: 6.8
Requires PHP: 7.2
Stable tag: 2.5.0
Stable tag: 2.5.2
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
@ -27,6 +27,15 @@ In most cases, #1 will work fine and is way easier.
== Changelog ==
= 2.5.2 =
* Fix: Customizer notice placements
= 2.5.1 =
* Feature: Serve new GenerateBlocks 2.0 sites in the Site Library
* Feature: Add more GenerateBlocks 2.0 dynamic tags if GB Pro is not active
* Feature: Add support for Font Library when importing starter sites
* Fix: Missing Elements Display Rules in some configurations
= 2.5.0 =
* Feature: Font Library
* Feature: Install Google Fonts locally

View File

@ -949,6 +949,7 @@ class GeneratePress_Site_Library_Helper {
'Spacing' => 'generate_package_spacing',
'Typography' => 'generate_package_typography',
'WooCommerce' => 'generate_package_woocommerce',
'Font Library' => 'generate_package_font_library',
);
}

View File

@ -188,7 +188,15 @@ class GeneratePress_Site_Library_Rest extends WP_REST_Controller {
if ( $force_refresh || empty( $sites ) || $sites_expire < $time_now ) {
$sites = array();
$data = wp_safe_remote_get( 'https://gpsites.co/wp-json/wp/v2/sites?per_page=100' );
$url = 'https://sites.generatepress.com/wp-json/gp-starter-sites/v1/sites';
if ( defined( 'GENERATEBLOCKS_VERSION' ) ) {
if ( ! function_exists( 'generateblocks_use_v1_blocks' ) || generateblocks_use_v1_blocks() ) {
$url = 'https://gpsites.co/wp-json/wp/v2/sites?per_page=100';
}
}
$data = wp_safe_remote_get( $url );
if ( is_wp_error( $data ) ) {
update_option( 'generatepress_sites', 'no results', false );
@ -549,6 +557,11 @@ class GeneratePress_Site_Library_Rest extends WP_REST_Controller {
add_action( 'wxr_importer.processed.post', array( 'GeneratePress_Site_Library_Helper', 'track_post' ) );
add_action( 'wxr_importer.processed.term', array( 'GeneratePress_Site_Library_Helper', 'track_term' ) );
if ( class_exists( 'GeneratePress_Pro_Font_Library' ) ) {
$font_instance = GeneratePress_Pro_Font_Library::get_instance();
add_action( 'import_post_meta', array( $font_instance, 'update_post_meta' ), 100, 3 );
}
// Disables generation of multiple image sizes (thumbnails) in the content import step.
if ( ! apply_filters( 'generate_sites_regen_thumbnails', true ) ) {
add_filter( 'intermediate_image_sizes_advanced', '__return_null' );
@ -560,6 +573,18 @@ class GeneratePress_Site_Library_Rest extends WP_REST_Controller {
GeneratePress_Site_Library_Helper::import_xml( $xml_path, $site_slug );
if ( class_exists( 'GeneratePress_Pro_Font_Library' ) ) {
GeneratePress_Pro_Font_Library::build_css_file();
}
if ( class_exists( 'GenerateBlocks_Pro_Enqueue_Styles' ) ) {
$instance = GenerateBlocks_Pro_Enqueue_Styles::get_instance();
if ( $instance && method_exists( $instance, 'build_css' ) ) {
$instance->build_css();
}
}
return $this->success( 'Content imported' );
}

View File

@ -21,6 +21,7 @@ module.exports = {
dashboard: './src/dashboard.js',
editor: './src/editor.js',
packages: './src/packages.scss',
'adjacent-posts': './src/adjacent-posts.js',
},
output: {
...defaultConfig.output,