updated plugin GP Premium version 2.0.3

This commit is contained in:
2021-07-25 23:25:02 +00:00
committed by Gitium
parent d7964b08bd
commit 3ef36355e9
154 changed files with 6153 additions and 9541 deletions

View File

@ -239,24 +239,20 @@ class GeneratePress_External_CSS_File {
if ( defined( 'DOMAIN_MAPPING' ) && DOMAIN_MAPPING ) {
if ( function_exists( 'domain_mapping_siteurl' ) && function_exists( 'get_original_url' ) ) {
$mapped_domain = domain_mapping_siteurl( false );
$mapped_domain = str_replace( 'https://', '//', $domain_mapping );
$mapped_domain = str_replace( 'http://', '//', $mapped_domain );
$original_domain = get_original_url( 'siteurl' );
$original_domain = str_replace( 'https://', '//', $original_domain );
$original_domain = str_replace( 'http://', '//', $original_domain );
$content = str_replace( $original_domain, $mapped_domain, $content );
}
}
// Strip protocols.
$content = str_replace( 'https://', '//', $content );
$content = str_replace( 'http://', '//', $content );
if ( is_writable( $this->file( 'path' ) ) || ( ! file_exists( $this->file( 'path' ) ) && is_writable( dirname( $this->file( 'path' ) ) ) ) ) {
$chmod_file = 0644;
if ( ! $wp_filesystem->put_contents( $this->file( 'path' ), wp_strip_all_tags( $content ), FS_CHMOD_FILE ) ) {
if ( defined( 'FS_CHMOD_FILE' ) ) {
$chmod_file = FS_CHMOD_FILE;
}
if ( ! $wp_filesystem->put_contents( $this->file( 'path' ), wp_strip_all_tags( $content ), $chmod_file ) ) {
// Fail!
return false;
@ -279,7 +275,7 @@ class GeneratePress_External_CSS_File {
global $blog_id;
// Get the upload directory for this site.
$upload_dir = wp_upload_dir();
$upload_dir = wp_get_upload_dir();
// If this is a multisite installation, append the blogid to the filename.
$css_blog_id = ( is_multisite() && $blog_id > 1 ) ? '_blog-' . $blog_id : null;
@ -335,7 +331,7 @@ class GeneratePress_External_CSS_File {
global $blog_id;
// Get the upload directory for this site.
$upload_dir = wp_upload_dir();
$upload_dir = wp_get_upload_dir();
// If this is a multisite installation, append the blogid to the filename.
$css_blog_id = ( is_multisite() && $blog_id > 1 ) ? '_blog-' . $blog_id : null;
@ -360,9 +356,7 @@ class GeneratePress_External_CSS_File {
}
}
// Strip protocols.
$css_uri = str_replace( 'https://', '//', $css_uri );
$css_uri = str_replace( 'http://', '//', $css_uri );
$css_uri = set_url_scheme( $css_uri );
if ( 'path' === $target ) {
return $file_path;

View File

@ -0,0 +1,81 @@
<?php
/**
* This file adds global scripts.
*
* @since 2.0.0
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
add_action( 'enqueue_block_editor_assets', 'generate_premium_enqueue_editor_scripts' );
/**
* Add scripts to the non-Elements block editor.
*
* @since 2.0.0
*/
function generate_premium_enqueue_editor_scripts() {
global $pagenow;
$deps = array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-editor' );
if ( 'widgets.php' === $pagenow ) {
unset( $deps[3] );
}
wp_enqueue_script(
'gp-premium-editor',
GP_PREMIUM_DIR_URL . 'dist/editor.js',
$deps,
filemtime( GP_PREMIUM_DIR_PATH . 'dist/editor.js' ),
true
);
wp_set_script_translations( 'gp-premium-editor', 'gp-premium', GP_PREMIUM_DIR_PATH . 'langs' );
global $generate_elements;
$active_elements = array();
if ( class_exists( 'GeneratePress_Elements_Helper' ) && ! empty( $generate_elements ) ) {
foreach ( (array) $generate_elements as $key => $data ) {
$type = esc_html( GeneratePress_Elements_Helper::get_element_type_label( $data['type'] ) );
$active_elements[] = array(
'type' => $type,
'name' => get_the_title( $data['id'] ),
'url' => get_edit_post_link( $data['id'] ),
);
}
}
$post_type_is_public = false;
if ( get_post_type() ) {
$post_type = get_post_type_object( get_post_type() );
if ( is_object( $post_type ) && ! empty( $post_type->public ) ) {
$post_type_is_public = true;
}
}
wp_localize_script(
'gp-premium-editor',
'gpPremiumEditor',
array(
'isBlockElement' => 'gp_elements' === get_post_type(),
'activeElements' => $active_elements,
'elementsUrl' => esc_url( admin_url( 'edit.php?post_type=gp_elements' ) ),
'postTypeIsPublic' => $post_type_is_public,
)
);
wp_enqueue_style(
'gp-premium-editor',
GP_PREMIUM_DIR_URL . 'dist/editor.css',
array( 'wp-edit-blocks' ),
filemtime( GP_PREMIUM_DIR_PATH . 'dist/editor.css' )
);
}