updated plugin GP Premium version 2.5.0

This commit is contained in:
2024-10-09 12:44:25 +00:00
committed by Gitium
parent 627ec103fe
commit a35dc419bc
45 changed files with 2109 additions and 52 deletions

View File

@ -108,6 +108,12 @@ class GeneratePress_Pro_Dashboard {
'key' => 'generate_package_elements',
'isActive' => 'activated' === get_option( 'generate_package_elements', false ),
),
'Font Library' => array(
'title' => __( 'Font Library', 'gp-premium' ),
'description' => __( 'Download and localize fonts from the Google Fonts library.', 'gp-premium' ),
'key' => 'generate_package_font_library',
'isActive' => 'activated' === get_option( 'generate_package_font_library', false ),
),
'Hooks' => array(
'title' => __( 'Hooks', 'gp-premium' ),
'description' => __( 'This module has been deprecated. Please use Elements instead.', 'gp-premium' ),
@ -298,10 +304,10 @@ class GeneratePress_Pro_Dashboard {
if ( $license_key && strlen( $license_key ) > 4 ) {
$hidden_length = strlen( $license_key ) - 4;
$safe_part = substr( $license_key, 0, 4 );
$hidden_part = implode('', array_fill( 0, $hidden_length, '*' ) );
$safe_part = substr( $license_key, -4 );
$hidden_part = implode( '', array_fill( 0, $hidden_length, '*' ) );
return $safe_part . $hidden_part;
return $hidden_part . $safe_part;
}
return $license_key;
@ -318,7 +324,16 @@ class GeneratePress_Pro_Dashboard {
$dashboard_pages = GeneratePress_Dashboard::get_pages();
$current_screen = get_current_screen();
if ( in_array( $current_screen->id, $dashboard_pages ) ) {
$packages_info = generate_premium_get_enqueue_assets( 'packages' );
wp_enqueue_style(
'generatepress-pro-packages',
GP_PREMIUM_DIR_URL . 'dist/packages.css',
array(),
$packages_info['version']
);
wp_enqueue_style(
'generate-pro-dashboard',
GP_PREMIUM_DIR_URL . 'dist/style-dashboard.css',
@ -343,6 +358,7 @@ class GeneratePress_Pro_Dashboard {
array(
'modules' => self::get_modules(),
'exportableModules' => self::get_exportable_modules(),
'fontLibraryUrl' => admin_url( 'themes.php?page=generatepress-font-library' ),
'siteLibraryUrl' => admin_url( 'themes.php?page=generatepress-library' ),
'elementsUrl' => admin_url( 'edit.php?post_type=gp_elements' ),
'hasWooCommerce' => class_exists( 'WooCommerce' ),

View File

@ -0,0 +1,58 @@
<?php
/**
* GenerateBlocks Pro singleton class.
*
* @package Generateblocks
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* The Singleton class.
*/
abstract class GeneratePress_Pro_Singleton {
/**
* Instance.
*
* @access private
* @var array Instances
*/
private static $instances = array();
/**
* The Singleton's constructor should always be private to prevent direct
* construction calls with the `new` operator.
*/
protected function __construct() { }
/**
* Singletons should not be cloneable.
*/
protected function __clone() { }
/**
* Singletons should not be restorable from strings.
*
* @throws Exception Cannot unserialize a singleton.
*/
public function __wakeup() {
throw new Exception( 'Cannot unserialize a singleton.' );
}
/**
* Initiator.
*
* @return object initialized object of class.
*/
public static function get_instance() {
$cls = static::class;
if ( ! isset( self::$instances[ $cls ] ) ) {
self::$instances[ $cls ] = new static();
}
return self::$instances[ $cls ];
}
}

View File

@ -150,3 +150,34 @@ function generate_premium_get_wp_filesystem() {
return $wp_filesystem;
}
/**
* Get our script dependencies and version.
*
* @param string $filename The filename to use.
* @param array $fallback_assets The assets to fallback to.
*/
function generate_premium_get_enqueue_assets(
$filename = '',
$fallback_assets = array(
'dependencies' => array(),
'version' => '',
)
) {
if ( ! $filename ) {
return $fallback_assets;
}
$assets_file = GP_PREMIUM_DIR_PATH . 'dist/' . $filename . '.asset.php';
$compiled_assets = file_exists( $assets_file )
? require $assets_file
: false;
$assets =
isset( $compiled_assets['dependencies'] ) &&
isset( $compiled_assets['version'] )
? $compiled_assets
: $fallback_assets;
return $assets;
}