modified file wp-piwik
This commit is contained in:
@ -0,0 +1,134 @@
|
||||
<?php
|
||||
/**
|
||||
* This file creates a class to build our CSS.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'GeneratePress_Backgrounds_CSS' ) ) {
|
||||
/**
|
||||
* Generate our background CSS.
|
||||
*/
|
||||
class GeneratePress_Backgrounds_CSS {
|
||||
|
||||
/**
|
||||
* The css selector that you're currently adding rules to
|
||||
*
|
||||
* @access protected
|
||||
* @var string
|
||||
*/
|
||||
protected $_selector = ''; // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore
|
||||
|
||||
/**
|
||||
* Stores the final css output with all of its rules for the current selector.
|
||||
*
|
||||
* @access protected
|
||||
* @var string
|
||||
*/
|
||||
protected $_selector_output = ''; // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore
|
||||
|
||||
/**
|
||||
* Stores all of the rules that will be added to the selector
|
||||
*
|
||||
* @access protected
|
||||
* @var string
|
||||
*/
|
||||
protected $_css = ''; // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore
|
||||
|
||||
/**
|
||||
* The string that holds all of the css to output
|
||||
*
|
||||
* @access protected
|
||||
* @var string
|
||||
*/
|
||||
protected $_output = ''; // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore
|
||||
|
||||
/**
|
||||
* Sets a selector to the object and changes the current selector to a new one
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
*
|
||||
* @param string $selector - the css identifier of the html that you wish to target.
|
||||
* @return $this
|
||||
*/
|
||||
public function set_selector( $selector = '' ) {
|
||||
// Render the css in the output string everytime the selector changes.
|
||||
if ( '' !== $this->_selector ) {
|
||||
$this->add_selector_rules_to_output();
|
||||
}
|
||||
|
||||
$this->_selector = $selector;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a css property with value to the css output
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
*
|
||||
* @param string $property - the css property.
|
||||
* @param string $value - the value to be placed with the property.
|
||||
* @param string $url Whether we need to generate URL in the string.
|
||||
* @return $this
|
||||
*/
|
||||
public function add_property( $property, $value, $url = '' ) {
|
||||
// If we don't have a value or our value is the same as our og default, bail.
|
||||
if ( empty( $value ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set up our background image URL param if needed.
|
||||
$url_start = ( '' !== $url ) ? "url('" : ""; // phpcs:ignore -- need double quotes.
|
||||
$url_end = ( '' !== $url ) ? "')" : ""; // phpcs:ignore -- need double quotes.
|
||||
|
||||
$this->_css .= $property . ':' . $url_start . $value . $url_end . ';';
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the current selector rules to the output variable
|
||||
*
|
||||
* @access private
|
||||
* @since 1.0
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
private function add_selector_rules_to_output() {
|
||||
if ( ! empty( $this->_css ) ) {
|
||||
$this->_selector_output = $this->_selector;
|
||||
$selector_output = sprintf( '%1$s{%2$s}', $this->_selector_output, $this->_css );
|
||||
|
||||
$this->_output .= $selector_output;
|
||||
|
||||
// Reset the css.
|
||||
$this->_css = '';
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minified css in the $_output variable
|
||||
*
|
||||
* @access public
|
||||
* @since 1.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function css_output() {
|
||||
// Add current selector's rules to output.
|
||||
$this->add_selector_rules_to_output();
|
||||
|
||||
// Output minified css.
|
||||
return $this->_output;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,420 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles Secondary Nav background images.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_backgrounds_secondary_nav_customizer' ) ) {
|
||||
add_action( 'customize_register', 'generate_backgrounds_secondary_nav_customizer', 1000 );
|
||||
/**
|
||||
* Adds our Secondary Nav background image options
|
||||
*
|
||||
* These options are in their own function so we can hook it in late to
|
||||
* make sure Secondary Nav is activated.
|
||||
*
|
||||
* 1000 priority is there to make sure Secondary Nav is registered (999)
|
||||
* as we check to see if the layout control exists.
|
||||
*
|
||||
* Secondary Nav now uses 100 as a priority.
|
||||
*
|
||||
* @param object $wp_customize Our Customizer object.
|
||||
*/
|
||||
function generate_backgrounds_secondary_nav_customizer( $wp_customize ) {
|
||||
if ( ! function_exists( 'generate_secondary_nav_get_defaults' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! $wp_customize->get_section( 'secondary_nav_section' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$defaults = generate_secondary_nav_get_defaults();
|
||||
|
||||
if ( method_exists( $wp_customize, 'register_control_type' ) ) {
|
||||
$wp_customize->register_control_type( 'GeneratePress_Section_Shortcut_Control' );
|
||||
}
|
||||
|
||||
require_once GP_LIBRARY_DIRECTORY . 'customizer-helpers.php';
|
||||
|
||||
$wp_customize->add_section(
|
||||
'secondary_bg_images_section',
|
||||
array(
|
||||
'title' => __( 'Secondary Navigation', 'gp-premium' ),
|
||||
'capability' => 'edit_theme_options',
|
||||
'description' => '',
|
||||
'panel' => 'generate_backgrounds_panel',
|
||||
'priority' => 21,
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Section_Shortcut_Control(
|
||||
$wp_customize,
|
||||
'generate_secondary_navigation_background_image_shortcuts',
|
||||
array(
|
||||
'section' => 'secondary_bg_images_section',
|
||||
'element' => __( 'Secondary Navigation', 'gp-premium' ),
|
||||
'shortcuts' => array(
|
||||
'layout' => 'secondary_nav_section',
|
||||
'colors' => 'secondary_navigation_color_section',
|
||||
'typography' => 'secondary_font_section',
|
||||
),
|
||||
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
|
||||
'priority' => 1,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_secondary_nav_settings[nav_image]',
|
||||
array(
|
||||
'default' => $defaults['nav_image'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'esc_url_raw',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Image_Control(
|
||||
$wp_customize,
|
||||
'generate_secondary_backgrounds-nav-image',
|
||||
array(
|
||||
'section' => 'secondary_bg_images_section',
|
||||
'settings' => 'generate_secondary_nav_settings[nav_image]',
|
||||
'priority' => 750,
|
||||
'label' => __( 'Navigation', 'gp-premium' ),
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_secondary_nav_settings[nav_repeat]',
|
||||
array(
|
||||
'default' => $defaults['nav_repeat'],
|
||||
'type' => 'option',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_choices',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
'generate_secondary_nav_settings[nav_repeat]',
|
||||
array(
|
||||
'type' => 'select',
|
||||
'section' => 'secondary_bg_images_section',
|
||||
'choices' => array(
|
||||
'' => __( 'Repeat', 'gp-premium' ),
|
||||
'repeat-x' => __( 'Repeat x', 'gp-premium' ),
|
||||
'repeat-y' => __( 'Repeat y', 'gp-premium' ),
|
||||
'no-repeat' => __( 'No Repeat', 'gp-premium' ),
|
||||
),
|
||||
'settings' => 'generate_secondary_nav_settings[nav_repeat]',
|
||||
'priority' => 800,
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_secondary_nav_settings[nav_item_image]',
|
||||
array(
|
||||
'default' => $defaults['nav_item_image'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'esc_url_raw',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Image_Control(
|
||||
$wp_customize,
|
||||
'generate_secondary_backgrounds-nav-item-image',
|
||||
array(
|
||||
'section' => 'secondary_bg_images_section',
|
||||
'settings' => 'generate_secondary_nav_settings[nav_item_image]',
|
||||
'priority' => 950,
|
||||
'label' => __( 'Navigation Item', 'gp-premium' ),
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_secondary_nav_settings[nav_item_repeat]',
|
||||
array(
|
||||
'default' => $defaults['nav_item_repeat'],
|
||||
'type' => 'option',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_choices',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
'generate_secondary_nav_settings[nav_item_repeat]',
|
||||
array(
|
||||
'type' => 'select',
|
||||
'section' => 'secondary_bg_images_section',
|
||||
'choices' => array(
|
||||
'' => __( 'Repeat', 'gp-premium' ),
|
||||
'repeat-x' => __( 'Repeat x', 'gp-premium' ),
|
||||
'repeat-y' => __( 'Repeat y', 'gp-premium' ),
|
||||
'no-repeat' => __( 'No Repeat', 'gp-premium' ),
|
||||
),
|
||||
'settings' => 'generate_secondary_nav_settings[nav_item_repeat]',
|
||||
'priority' => 1000,
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_secondary_nav_settings[nav_item_hover_image]',
|
||||
array(
|
||||
'default' => $defaults['nav_item_hover_image'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'esc_url_raw',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Image_Control(
|
||||
$wp_customize,
|
||||
'generate_secondary_backgrounds-nav-item-hover-image',
|
||||
array(
|
||||
'section' => 'secondary_bg_images_section',
|
||||
'settings' => 'generate_secondary_nav_settings[nav_item_hover_image]',
|
||||
'priority' => 1150,
|
||||
'label' => __( 'Navigation Item Hover', 'gp-premium' ),
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_secondary_nav_settings[nav_item_hover_repeat]',
|
||||
array(
|
||||
'default' => $defaults['nav_item_hover_repeat'],
|
||||
'type' => 'option',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_choices',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
'generate_secondary_nav_settings[nav_item_hover_repeat]',
|
||||
array(
|
||||
'type' => 'select',
|
||||
'section' => 'secondary_bg_images_section',
|
||||
'choices' => array(
|
||||
'' => __( 'Repeat', 'gp-premium' ),
|
||||
'repeat-x' => __( 'Repeat x', 'gp-premium' ),
|
||||
'repeat-y' => __( 'Repeat y', 'gp-premium' ),
|
||||
'no-repeat' => __( 'No Repeat', 'gp-premium' ),
|
||||
),
|
||||
'settings' => 'generate_secondary_nav_settings[nav_item_hover_repeat]',
|
||||
'priority' => 1200,
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_secondary_nav_settings[nav_item_current_image]',
|
||||
array(
|
||||
'default' => $defaults['nav_item_current_image'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'esc_url_raw',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Image_Control(
|
||||
$wp_customize,
|
||||
'generate_secondary_backgrounds-nav-item-current-image',
|
||||
array(
|
||||
'section' => 'secondary_bg_images_section',
|
||||
'settings' => 'generate_secondary_nav_settings[nav_item_current_image]',
|
||||
'priority' => 1350,
|
||||
'label' => __( 'Navigation Item Current', 'gp-premium' ),
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_secondary_nav_settings[nav_item_current_repeat]',
|
||||
array(
|
||||
'default' => $defaults['nav_item_current_repeat'],
|
||||
'type' => 'option',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_choices',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
'generate_secondary_nav_settings[nav_item_current_repeat]',
|
||||
array(
|
||||
'type' => 'select',
|
||||
'section' => 'secondary_bg_images_section',
|
||||
'choices' => array(
|
||||
'' => __( 'Repeat', 'gp-premium' ),
|
||||
'repeat-x' => __( 'Repeat x', 'gp-premium' ),
|
||||
'repeat-y' => __( 'Repeat y', 'gp-premium' ),
|
||||
'no-repeat' => __( 'No Repeat', 'gp-premium' ),
|
||||
),
|
||||
'settings' => 'generate_secondary_nav_settings[nav_item_current_repeat]',
|
||||
'priority' => 1400,
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_section(
|
||||
'secondary_subnav_bg_images_section',
|
||||
array(
|
||||
'title' => __( 'Secondary Sub-Navigation', 'gp-premium' ),
|
||||
'capability' => 'edit_theme_options',
|
||||
'description' => '',
|
||||
'panel' => 'generate_backgrounds_panel',
|
||||
'priority' => 22,
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_secondary_nav_settings[sub_nav_item_image]',
|
||||
array(
|
||||
'default' => $defaults['sub_nav_item_image'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'esc_url_raw',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Image_Control(
|
||||
$wp_customize,
|
||||
'generate_secondary_backgrounds-sub-nav-item-image',
|
||||
array(
|
||||
'section' => 'secondary_subnav_bg_images_section',
|
||||
'settings' => 'generate_secondary_nav_settings[sub_nav_item_image]',
|
||||
'priority' => 1700,
|
||||
'label' => __( 'Sub-Navigation Item', 'gp-premium' ),
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_secondary_nav_settings[sub_nav_item_repeat]',
|
||||
array(
|
||||
'default' => $defaults['sub_nav_item_repeat'],
|
||||
'type' => 'option',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_choices',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
'generate_secondary_nav_settings[sub_nav_item_repeat]',
|
||||
array(
|
||||
'type' => 'select',
|
||||
'section' => 'secondary_subnav_bg_images_section',
|
||||
'choices' => array(
|
||||
'' => __( 'Repeat', 'gp-premium' ),
|
||||
'repeat-x' => __( 'Repeat x', 'gp-premium' ),
|
||||
'repeat-y' => __( 'Repeat y', 'gp-premium' ),
|
||||
'no-repeat' => __( 'No Repeat', 'gp-premium' ),
|
||||
),
|
||||
'settings' => 'generate_secondary_nav_settings[sub_nav_item_repeat]',
|
||||
'priority' => 1800,
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_secondary_nav_settings[sub_nav_item_hover_image]',
|
||||
array(
|
||||
'default' => $defaults['sub_nav_item_hover_image'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'esc_url_raw',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Image_Control(
|
||||
$wp_customize,
|
||||
'generate_secondary_backgrounds-sub-nav-item-hover-image',
|
||||
array(
|
||||
'section' => 'secondary_subnav_bg_images_section',
|
||||
'settings' => 'generate_secondary_nav_settings[sub_nav_item_hover_image]',
|
||||
'priority' => 2000,
|
||||
'label' => __( 'Sub-Navigation Item Hover', 'gp-premium' ),
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_secondary_nav_settings[sub_nav_item_hover_repeat]',
|
||||
array(
|
||||
'default' => $defaults['sub_nav_item_hover_repeat'],
|
||||
'type' => 'option',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_choices',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
'generate_secondary_nav_settings[sub_nav_item_hover_repeat]',
|
||||
array(
|
||||
'type' => 'select',
|
||||
'section' => 'secondary_subnav_bg_images_section',
|
||||
'choices' => array(
|
||||
'' => __( 'Repeat', 'gp-premium' ),
|
||||
'repeat-x' => __( 'Repeat x', 'gp-premium' ),
|
||||
'repeat-y' => __( 'Repeat y', 'gp-premium' ),
|
||||
'no-repeat' => __( 'No Repeat', 'gp-premium' ),
|
||||
),
|
||||
'settings' => 'generate_secondary_nav_settings[sub_nav_item_hover_repeat]',
|
||||
'priority' => 2100,
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_secondary_nav_settings[sub_nav_item_current_image]',
|
||||
array(
|
||||
'default' => $defaults['sub_nav_item_current_image'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'esc_url_raw',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Image_Control(
|
||||
$wp_customize,
|
||||
'generate_secondary_backgrounds-sub-nav-item-current-image',
|
||||
array(
|
||||
'section' => 'secondary_subnav_bg_images_section',
|
||||
'settings' => 'generate_secondary_nav_settings[sub_nav_item_current_image]',
|
||||
'priority' => 2300,
|
||||
'label' => __( 'Sub-Navigation Item Current', 'gp-premium' ),
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_secondary_nav_settings[sub_nav_item_current_repeat]',
|
||||
array(
|
||||
'default' => $defaults['sub_nav_item_current_repeat'],
|
||||
'type' => 'option',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_choices',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
'generate_secondary_nav_settings[sub_nav_item_current_repeat]',
|
||||
array(
|
||||
'type' => 'select',
|
||||
'section' => 'secondary_subnav_bg_images_section',
|
||||
'choices' => array(
|
||||
'' => __( 'Repeat', 'gp-premium' ),
|
||||
'repeat-x' => __( 'Repeat x', 'gp-premium' ),
|
||||
'repeat-y' => __( 'Repeat y', 'gp-premium' ),
|
||||
'no-repeat' => __( 'No Repeat', 'gp-premium' ),
|
||||
),
|
||||
'settings' => 'generate_secondary_nav_settings[sub_nav_item_current_repeat]',
|
||||
'priority' => 2400,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* Backgrounds module.
|
||||
*
|
||||
* @since 1.1.0
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
// Define the version. This used to be a standalone plugin, so we need to keep this constant.
|
||||
if ( ! defined( 'GENERATE_BACKGROUNDS_VERSION' ) ) {
|
||||
define( 'GENERATE_BACKGROUNDS_VERSION', GP_PREMIUM_VERSION );
|
||||
}
|
||||
|
||||
require plugin_dir_path( __FILE__ ) . 'functions/functions.php';
|
||||
@ -0,0 +1,169 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles column-related functionality.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_blog_get_columns' ) ) {
|
||||
/**
|
||||
* Initiate columns.
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_blog_get_columns() {
|
||||
$generate_blog_settings = wp_parse_args(
|
||||
get_option( 'generate_blog_settings', array() ),
|
||||
generate_blog_get_defaults()
|
||||
);
|
||||
|
||||
// If columns are enabled, set to true.
|
||||
$columns = ( $generate_blog_settings['column_layout'] ) ? true : false;
|
||||
|
||||
// If we're not dealing with posts, set it to false.
|
||||
// Check for is_home() to prevent bug in Yoast that throws off the post type check.
|
||||
$columns = ( 'post' === get_post_type() || is_search() || is_home() ) ? $columns : false;
|
||||
|
||||
// If masonry is enabled via filter, enable columns.
|
||||
// phpcs:ignore -- Non-strict comparison allowed.
|
||||
$columns = ( 'true' == apply_filters( 'generate_blog_masonry', 'false' ) ) ? true : $columns;
|
||||
|
||||
// If we're on a singular post or page, disable.
|
||||
$columns = ( is_singular() ) ? false : $columns;
|
||||
|
||||
// Turn off columns if we're on a WooCommerce search page.
|
||||
if ( function_exists( 'is_woocommerce' ) ) {
|
||||
$columns = ( is_woocommerce() && is_search() ) ? false : $columns;
|
||||
}
|
||||
|
||||
// Bail if there's no search results.
|
||||
if ( is_search() ) {
|
||||
global $wp_query;
|
||||
|
||||
// phpcs:ignore -- non-strict comparison allowed.
|
||||
if ( 0 == $wp_query->post_count ) {
|
||||
$columns = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Return the result.
|
||||
return apply_filters( 'generate_blog_columns', $columns );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_blog_get_masonry' ) ) {
|
||||
/**
|
||||
* Check if masonry is enabled.
|
||||
* This function is a mess with strings as bools etc.. Will re-write in a big upate to get lots of testing.
|
||||
*/
|
||||
function generate_blog_get_masonry() {
|
||||
$generate_blog_settings = wp_parse_args(
|
||||
get_option( 'generate_blog_settings', array() ),
|
||||
generate_blog_get_defaults()
|
||||
);
|
||||
|
||||
// If masonry is enabled via option or filter, enable it.
|
||||
// phpcs:ignore -- non-strict comparison allowed.
|
||||
if ( $generate_blog_settings['masonry'] || 'true' == apply_filters( 'generate_blog_masonry', 'false' ) ) {
|
||||
$masonry = 'true';
|
||||
} else {
|
||||
$masonry = 'false';
|
||||
}
|
||||
|
||||
// Allow masonry to be turned off using a boolean.
|
||||
if ( false === apply_filters( 'generate_blog_masonry', 'false' ) ) {
|
||||
$masonry = 'false';
|
||||
}
|
||||
|
||||
return $masonry;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_blog_add_columns_container' ) ) {
|
||||
add_action( 'generate_before_main_content', 'generate_blog_add_columns_container' );
|
||||
/**
|
||||
* Add columns container
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
function generate_blog_add_columns_container() {
|
||||
if ( ! generate_blog_get_columns() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$columns = generate_blog_get_column_count();
|
||||
|
||||
printf(
|
||||
'<div class="generate-columns-container %1$s">%2$s',
|
||||
'false' !== generate_blog_get_masonry() ? 'masonry-container are-images-unloaded' : '',
|
||||
'false' !== generate_blog_get_masonry() ? '<div class="grid-sizer grid-' . esc_attr( $columns ) . ' tablet-grid-50 mobile-grid-100"></div>' : '' // phpcs:ignore -- no escaping needed.
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_blog_add_ending_columns_container' ) ) {
|
||||
add_action( 'generate_after_main_content', 'generate_blog_add_ending_columns_container' );
|
||||
/**
|
||||
* Add closing columns container
|
||||
*
|
||||
* @since 1.0
|
||||
*/
|
||||
function generate_blog_add_ending_columns_container() {
|
||||
if ( ! generate_blog_get_columns() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
echo '</div><!-- .generate-columns-contaier -->';
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_blog_columns_css' ) ) {
|
||||
/**
|
||||
* Add inline CSS
|
||||
*/
|
||||
function generate_blog_columns_css() {
|
||||
$generate_blog_settings = wp_parse_args(
|
||||
get_option( 'generate_blog_settings', array() ),
|
||||
generate_blog_get_defaults()
|
||||
);
|
||||
|
||||
if ( function_exists( 'generate_spacing_get_defaults' ) ) {
|
||||
$spacing_settings = wp_parse_args(
|
||||
get_option( 'generate_spacing_settings', array() ),
|
||||
generate_spacing_get_defaults()
|
||||
);
|
||||
}
|
||||
|
||||
$separator = ( function_exists( 'generate_spacing_get_defaults' ) ) ? absint( $spacing_settings['separator'] ) : 20;
|
||||
|
||||
$return = '';
|
||||
if ( generate_blog_get_columns() ) {
|
||||
$return .= '.generate-columns {margin-bottom: ' . $separator . 'px;padding-left: ' . $separator . 'px;}';
|
||||
$return .= '.generate-columns-container {margin-left: -' . $separator . 'px;}';
|
||||
$return .= '.page-header {margin-bottom: ' . $separator . 'px;margin-left: ' . $separator . 'px}';
|
||||
$return .= '.generate-columns-container > .paging-navigation {margin-left: ' . $separator . 'px;}';
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_blog_get_column_count' ) ) {
|
||||
/**
|
||||
* Get our column grid class
|
||||
*/
|
||||
function generate_blog_get_column_count() {
|
||||
$generate_blog_settings = wp_parse_args(
|
||||
get_option( 'generate_blog_settings', array() ),
|
||||
generate_blog_get_defaults()
|
||||
);
|
||||
|
||||
$count = $generate_blog_settings['columns'];
|
||||
|
||||
return apply_filters( 'generate_blog_get_column_count', $count );
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,149 @@
|
||||
.masonry-enabled .page-header {
|
||||
position: relative !important;
|
||||
}
|
||||
|
||||
.separate-containers .site-main > .generate-columns-container {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.masonry-container.are-images-unloaded,
|
||||
.load-more.are-images-unloaded,
|
||||
.masonry-enabled #nav-below {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
/* columns */
|
||||
.generate-columns-container:not(.masonry-container) {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.generate-columns .inside-article {
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.generate-columns-activated.post-image-aligned-left .generate-columns-container article:not(.featured-column) .post-image,
|
||||
.generate-columns-activated.post-image-aligned-right .generate-columns-container article:not(.featured-column) .post-image {
|
||||
float: none;
|
||||
text-align: center;
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.generate-columns-container .paging-navigation,
|
||||
.generate-columns-container .page-header {
|
||||
flex: 1 1 100%;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.generate-columns-container .paging-navigation {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.load-more:not(.has-svg-icon) .button.loading:before {
|
||||
content: "\e900";
|
||||
display: inline-block;
|
||||
font-family: "GP Premium";
|
||||
font-style: normal;
|
||||
font-weight: normal;
|
||||
font-variant: normal;
|
||||
text-transform: none;
|
||||
line-height: 1;
|
||||
animation: spin 2s infinite linear;
|
||||
margin-right: 7px;
|
||||
}
|
||||
|
||||
.load-more .button:not(.loading) .gp-icon {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.load-more .gp-icon svg {
|
||||
animation: spin 2s infinite linear;
|
||||
margin-right: 7px;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
0% {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
100% {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
.generate-columns {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.generate-columns.grid-20,
|
||||
.grid-sizer.grid-20 {
|
||||
width: 20%;
|
||||
}
|
||||
|
||||
.generate-columns.grid-25,
|
||||
.grid-sizer.grid-25 {
|
||||
width: 25%;
|
||||
}
|
||||
|
||||
.generate-columns.grid-33,
|
||||
.grid-sizer.grid-33 {
|
||||
width: 33.3333%;
|
||||
}
|
||||
|
||||
.generate-columns.grid-50,
|
||||
.grid-sizer.grid-50 {
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.generate-columns.grid-60,
|
||||
.grid-sizer.grid-60 {
|
||||
width: 60%;
|
||||
}
|
||||
|
||||
.generate-columns.grid-66,
|
||||
.grid-sizer.grid-66 {
|
||||
width: 66.66667%;
|
||||
}
|
||||
|
||||
.generate-columns.grid-100,
|
||||
.grid-sizer.grid-100 {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) and (max-width: 1024px) {
|
||||
.generate-columns.tablet-grid-50,
|
||||
.grid-sizer.tablet-grid-50 {
|
||||
width: 50%;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.generate-columns-activated .generate-columns-container {
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
}
|
||||
.generate-columns-container > *,
|
||||
.generate-columns-container .generate-columns {
|
||||
padding-left: 0;
|
||||
}
|
||||
.generate-columns-container .page-header {
|
||||
margin-left: 0;
|
||||
}
|
||||
.generate-columns.mobile-grid-100,
|
||||
.grid-sizer.mobile-grid-100 {
|
||||
width: 100%;
|
||||
}
|
||||
.generate-columns-container > .paging-navigation {
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.load-more {
|
||||
display: block;
|
||||
text-align: center;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
1
wp-content/upgrade-temp-backup/plugins/gp-premium/blog/functions/css/columns.min.css
vendored
Normal file
1
wp-content/upgrade-temp-backup/plugins/gp-premium/blog/functions/css/columns.min.css
vendored
Normal file
@ -0,0 +1 @@
|
||||
.masonry-enabled .page-header{position:relative!important}.separate-containers .site-main>.generate-columns-container{margin-bottom:0}.load-more.are-images-unloaded,.masonry-container.are-images-unloaded,.masonry-enabled #nav-below{opacity:0}.generate-columns-container:not(.masonry-container){display:flex;flex-wrap:wrap;align-items:stretch}.generate-columns .inside-article{height:100%;box-sizing:border-box}.generate-columns-activated.post-image-aligned-left .generate-columns-container article:not(.featured-column) .post-image,.generate-columns-activated.post-image-aligned-right .generate-columns-container article:not(.featured-column) .post-image{float:none;text-align:center;margin-left:0;margin-right:0}.generate-columns-container .page-header,.generate-columns-container .paging-navigation{flex:1 1 100%;clear:both}.generate-columns-container .paging-navigation{margin-bottom:0}.load-more:not(.has-svg-icon) .button.loading:before{content:"\e900";display:inline-block;font-family:"GP Premium";font-style:normal;font-weight:400;font-variant:normal;text-transform:none;line-height:1;animation:spin 2s infinite linear;margin-right:7px}.load-more .button:not(.loading) .gp-icon{display:none}.load-more .gp-icon svg{animation:spin 2s infinite linear;margin-right:7px}@keyframes spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}.generate-columns{box-sizing:border-box}.generate-columns.grid-20,.grid-sizer.grid-20{width:20%}.generate-columns.grid-25,.grid-sizer.grid-25{width:25%}.generate-columns.grid-33,.grid-sizer.grid-33{width:33.3333%}.generate-columns.grid-50,.grid-sizer.grid-50{width:50%}.generate-columns.grid-60,.grid-sizer.grid-60{width:60%}.generate-columns.grid-66,.grid-sizer.grid-66{width:66.66667%}.generate-columns.grid-100,.grid-sizer.grid-100{width:100%}@media (min-width:768px) and (max-width:1024px){.generate-columns.tablet-grid-50,.grid-sizer.tablet-grid-50{width:50%}}@media (max-width:767px){.generate-columns-activated .generate-columns-container{margin-left:0;margin-right:0}.generate-columns-container .generate-columns,.generate-columns-container>*{padding-left:0}.generate-columns-container .page-header{margin-left:0}.generate-columns.mobile-grid-100,.grid-sizer.mobile-grid-100{width:100%}.generate-columns-container>.paging-navigation{margin-left:0}}@media (max-width:768px){.load-more{display:block;text-align:center;margin-bottom:0}}
|
||||
@ -0,0 +1,104 @@
|
||||
.post-image-above-header .inside-article .post-image,
|
||||
.post-image-above-header .inside-article .featured-image {
|
||||
margin-top: 0;
|
||||
margin-bottom: 2em;
|
||||
}
|
||||
|
||||
.post-image-aligned-left .inside-article .post-image,
|
||||
.post-image-aligned-left .inside-article .featured-image {
|
||||
margin-top: 0;
|
||||
margin-right: 2em;
|
||||
float: left;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.post-image-aligned-center .post-image,
|
||||
.post-image-aligned-center .featured-image {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.post-image-aligned-right .inside-article .post-image,
|
||||
.post-image-aligned-right .inside-article .featured-image {
|
||||
margin-top: 0;
|
||||
margin-left: 2em;
|
||||
float: right;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.post-image-below-header.post-image-aligned-right .inside-article .post-image,
|
||||
.post-image-below-header.post-image-aligned-right .inside-article .featured-image,
|
||||
.post-image-below-header.post-image-aligned-center .inside-article .featured-image,
|
||||
.post-image-below-header.post-image-aligned-left .inside-article .post-image,
|
||||
.post-image-below-header.post-image-aligned-left .inside-article .featured-image {
|
||||
margin-top: 2em;
|
||||
}
|
||||
|
||||
.post-image-aligned-left > .featured-image,
|
||||
.post-image-aligned-right > .featured-image {
|
||||
float: none;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.post-image-aligned-left .featured-image {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.post-image-aligned-right .featured-image {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.post-image-aligned-left .inside-article:before,
|
||||
.post-image-aligned-left .inside-article:after,
|
||||
.post-image-aligned-right .inside-article:before,
|
||||
.post-image-aligned-right .inside-article:after {
|
||||
content: "";
|
||||
display: table;
|
||||
}
|
||||
|
||||
.post-image-aligned-left .inside-article:after,
|
||||
.post-image-aligned-right .inside-article:after {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.one-container.post-image-above-header .page-header + .no-featured-image-padding .inside-article .post-image,
|
||||
.one-container.post-image-above-header .no-featured-image-padding.generate-columns .inside-article .post-image {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.one-container.right-sidebar.post-image-aligned-center .no-featured-image-padding .post-image,
|
||||
.one-container.right-sidebar.post-image-aligned-center .no-featured-image-padding .featured-image,
|
||||
.one-container.both-right.post-image-aligned-center .no-featured-image-padding .post-image,
|
||||
.one-container.both-right.post-image-aligned-center .no-featured-image-padding .featured-image {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.one-container.left-sidebar.post-image-aligned-center .no-featured-image-padding .post-image,
|
||||
.one-container.left-sidebar.post-image-aligned-center .no-featured-image-padding .featured-image,
|
||||
.one-container.both-left.post-image-aligned-center .no-featured-image-padding .post-image,
|
||||
.one-container.both-left.post-image-aligned-center .no-featured-image-padding .featured-image {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.one-container.both-sidebars.post-image-aligned-center .no-featured-image-padding .post-image,
|
||||
.one-container.both-sidebars.post-image-aligned-center .no-featured-image-padding .featured-image {
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.one-container.post-image-aligned-center .no-featured-image-padding.generate-columns .post-image,
|
||||
.one-container.post-image-aligned-center .no-featured-image-padding.generate-columns .featured-image {
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
body:not(.post-image-aligned-center) .inside-article .post-image,
|
||||
body:not(.post-image-aligned-center) .featured-image,
|
||||
body:not(.post-image-aligned-center) .inside-article .featured-image {
|
||||
margin-right: 0;
|
||||
margin-left: 0;
|
||||
float: none;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
1
wp-content/upgrade-temp-backup/plugins/gp-premium/blog/functions/css/featured-images.min.css
vendored
Normal file
1
wp-content/upgrade-temp-backup/plugins/gp-premium/blog/functions/css/featured-images.min.css
vendored
Normal file
@ -0,0 +1 @@
|
||||
.post-image-above-header .inside-article .featured-image,.post-image-above-header .inside-article .post-image{margin-top:0;margin-bottom:2em}.post-image-aligned-left .inside-article .featured-image,.post-image-aligned-left .inside-article .post-image{margin-top:0;margin-right:2em;float:left;text-align:left}.post-image-aligned-center .featured-image,.post-image-aligned-center .post-image{text-align:center}.post-image-aligned-right .inside-article .featured-image,.post-image-aligned-right .inside-article .post-image{margin-top:0;margin-left:2em;float:right;text-align:right}.post-image-below-header.post-image-aligned-center .inside-article .featured-image,.post-image-below-header.post-image-aligned-left .inside-article .featured-image,.post-image-below-header.post-image-aligned-left .inside-article .post-image,.post-image-below-header.post-image-aligned-right .inside-article .featured-image,.post-image-below-header.post-image-aligned-right .inside-article .post-image{margin-top:2em}.post-image-aligned-left>.featured-image,.post-image-aligned-right>.featured-image{float:none;margin-left:auto;margin-right:auto}.post-image-aligned-left .featured-image{text-align:left}.post-image-aligned-right .featured-image{text-align:right}.post-image-aligned-left .inside-article:after,.post-image-aligned-left .inside-article:before,.post-image-aligned-right .inside-article:after,.post-image-aligned-right .inside-article:before{content:"";display:table}.post-image-aligned-left .inside-article:after,.post-image-aligned-right .inside-article:after{clear:both}.one-container.post-image-above-header .no-featured-image-padding.generate-columns .inside-article .post-image,.one-container.post-image-above-header .page-header+.no-featured-image-padding .inside-article .post-image{margin-top:0}.one-container.both-right.post-image-aligned-center .no-featured-image-padding .featured-image,.one-container.both-right.post-image-aligned-center .no-featured-image-padding .post-image,.one-container.right-sidebar.post-image-aligned-center .no-featured-image-padding .featured-image,.one-container.right-sidebar.post-image-aligned-center .no-featured-image-padding .post-image{margin-right:0}.one-container.both-left.post-image-aligned-center .no-featured-image-padding .featured-image,.one-container.both-left.post-image-aligned-center .no-featured-image-padding .post-image,.one-container.left-sidebar.post-image-aligned-center .no-featured-image-padding .featured-image,.one-container.left-sidebar.post-image-aligned-center .no-featured-image-padding .post-image{margin-left:0}.one-container.both-sidebars.post-image-aligned-center .no-featured-image-padding .featured-image,.one-container.both-sidebars.post-image-aligned-center .no-featured-image-padding .post-image{margin-left:0;margin-right:0}.one-container.post-image-aligned-center .no-featured-image-padding.generate-columns .featured-image,.one-container.post-image-aligned-center .no-featured-image-padding.generate-columns .post-image{margin-left:0;margin-right:0}@media (max-width:768px){body:not(.post-image-aligned-center) .featured-image,body:not(.post-image-aligned-center) .inside-article .featured-image,body:not(.post-image-aligned-center) .inside-article .post-image{margin-right:0;margin-left:0;float:none;text-align:center}}
|
||||
@ -0,0 +1,254 @@
|
||||
.post-image-above-header .inside-article .post-image,
|
||||
.post-image-above-header .inside-article .featured-image {
|
||||
margin-top: 0;
|
||||
margin-bottom: 2em;
|
||||
}
|
||||
|
||||
.post-image-aligned-left .inside-article .post-image,
|
||||
.post-image-aligned-left .inside-article .featured-image {
|
||||
margin-top: 0;
|
||||
margin-right: 2em;
|
||||
float: left;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.post-image-aligned-center .post-image,
|
||||
.post-image-aligned-center .featured-image {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.post-image-aligned-right .inside-article .post-image,
|
||||
.post-image-aligned-right .inside-article .featured-image {
|
||||
margin-top: 0;
|
||||
margin-left: 2em;
|
||||
float: right;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.post-image-below-header.post-image-aligned-right .inside-article .post-image,
|
||||
.post-image-below-header.post-image-aligned-right .inside-article .featured-image,
|
||||
.post-image-below-header.post-image-aligned-center .inside-article .featured-image,
|
||||
.post-image-below-header.post-image-aligned-left .inside-article .post-image,
|
||||
.post-image-below-header.post-image-aligned-left .inside-article .featured-image {
|
||||
margin-top: 2em;
|
||||
}
|
||||
|
||||
.post-image-aligned-left > .featured-image,
|
||||
.post-image-aligned-right > .featured-image {
|
||||
float: none;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.post-image-aligned-left .featured-image {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.post-image-aligned-right .featured-image {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.post-image-aligned-left .inside-article:before,
|
||||
.post-image-aligned-left .inside-article:after,
|
||||
.post-image-aligned-right .inside-article:before,
|
||||
.post-image-aligned-right .inside-article:after {
|
||||
content: "";
|
||||
display: table;
|
||||
}
|
||||
|
||||
.post-image-aligned-left .inside-article:after,
|
||||
.post-image-aligned-right .inside-article:after {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.one-container.post-image-above-header .page-header + .no-featured-image-padding .inside-article .post-image,
|
||||
.one-container.post-image-above-header .no-featured-image-padding.generate-columns .inside-article .post-image {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.one-container.right-sidebar.post-image-aligned-center .no-featured-image-padding .post-image,
|
||||
.one-container.right-sidebar.post-image-aligned-center .no-featured-image-padding .featured-image,
|
||||
.one-container.both-right.post-image-aligned-center .no-featured-image-padding .post-image,
|
||||
.one-container.both-right.post-image-aligned-center .no-featured-image-padding .featured-image {
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.one-container.left-sidebar.post-image-aligned-center .no-featured-image-padding .post-image,
|
||||
.one-container.left-sidebar.post-image-aligned-center .no-featured-image-padding .featured-image,
|
||||
.one-container.both-left.post-image-aligned-center .no-featured-image-padding .post-image,
|
||||
.one-container.both-left.post-image-aligned-center .no-featured-image-padding .featured-image {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
.one-container.both-sidebars.post-image-aligned-center .no-featured-image-padding .post-image,
|
||||
.one-container.both-sidebars.post-image-aligned-center .no-featured-image-padding .featured-image {
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.one-container.post-image-aligned-center .no-featured-image-padding.generate-columns .post-image,
|
||||
.one-container.post-image-aligned-center .no-featured-image-padding.generate-columns .featured-image {
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
body:not(.post-image-aligned-center) .inside-article .post-image,
|
||||
body:not(.post-image-aligned-center) .featured-image,
|
||||
body:not(.post-image-aligned-center) .inside-article .featured-image {
|
||||
margin-right: 0;
|
||||
margin-left: 0;
|
||||
float: none;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
.masonry-enabled .page-header {
|
||||
position: relative !important;
|
||||
}
|
||||
|
||||
.separate-containers .site-main > .generate-columns-container {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.masonry-container.are-images-unloaded,
|
||||
.load-more.are-images-unloaded,
|
||||
.masonry-enabled #nav-below {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
/* columns */
|
||||
.generate-columns-container:not(.masonry-container) {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.generate-columns .inside-article {
|
||||
height: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.generate-columns-activated.post-image-aligned-left .generate-columns-container article:not(.featured-column) .post-image,
|
||||
.generate-columns-activated.post-image-aligned-right .generate-columns-container article:not(.featured-column) .post-image {
|
||||
float: none;
|
||||
text-align: center;
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
}
|
||||
|
||||
.generate-columns-container .paging-navigation,
|
||||
.generate-columns-container .page-header {
|
||||
flex: 1 1 100%;
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.generate-columns-container .paging-navigation {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.load-more:not(.has-svg-icon) .button.loading:before {
|
||||
content: "\e900";
|
||||
display: inline-block;
|
||||
font-family: "GP Premium";
|
||||
font-style: normal;
|
||||
font-weight: normal;
|
||||
font-variant: normal;
|
||||
text-transform: none;
|
||||
line-height: 1;
|
||||
animation: spin 2s infinite linear;
|
||||
margin-right: 7px;
|
||||
}
|
||||
|
||||
.load-more .button:not(.loading) .gp-icon {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.load-more .gp-icon svg {
|
||||
animation: spin 2s infinite linear;
|
||||
margin-right: 7px;
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
0% {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
100% {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
.generate-columns {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.generate-columns.grid-20,
|
||||
.grid-sizer.grid-20 {
|
||||
width: 20%;
|
||||
}
|
||||
|
||||
.generate-columns.grid-25,
|
||||
.grid-sizer.grid-25 {
|
||||
width: 25%;
|
||||
}
|
||||
|
||||
.generate-columns.grid-33,
|
||||
.grid-sizer.grid-33 {
|
||||
width: 33.3333%;
|
||||
}
|
||||
|
||||
.generate-columns.grid-50,
|
||||
.grid-sizer.grid-50 {
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
.generate-columns.grid-60,
|
||||
.grid-sizer.grid-60 {
|
||||
width: 60%;
|
||||
}
|
||||
|
||||
.generate-columns.grid-66,
|
||||
.grid-sizer.grid-66 {
|
||||
width: 66.66667%;
|
||||
}
|
||||
|
||||
.generate-columns.grid-100,
|
||||
.grid-sizer.grid-100 {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@media (min-width: 768px) and (max-width: 1024px) {
|
||||
.generate-columns.tablet-grid-50,
|
||||
.grid-sizer.tablet-grid-50 {
|
||||
width: 50%;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
.generate-columns-activated .generate-columns-container {
|
||||
margin-left: 0;
|
||||
margin-right: 0;
|
||||
}
|
||||
.generate-columns-container > *,
|
||||
.generate-columns-container .generate-columns {
|
||||
padding-left: 0;
|
||||
}
|
||||
.generate-columns-container .page-header {
|
||||
margin-left: 0;
|
||||
}
|
||||
.generate-columns.mobile-grid-100,
|
||||
.grid-sizer.mobile-grid-100 {
|
||||
width: 100%;
|
||||
}
|
||||
.generate-columns-container > .paging-navigation {
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.load-more {
|
||||
display: block;
|
||||
text-align: center;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
1
wp-content/upgrade-temp-backup/plugins/gp-premium/blog/functions/css/style.min.css
vendored
Normal file
1
wp-content/upgrade-temp-backup/plugins/gp-premium/blog/functions/css/style.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
defined( 'WPINC' ) or die;
|
||||
|
||||
if ( ! function_exists( 'generate_blog_get_defaults' ) ) {
|
||||
/**
|
||||
* Set our defaults
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_blog_get_defaults() {
|
||||
$generate_blog_defaults = array(
|
||||
'excerpt_length' => '55',
|
||||
'read_more' => __( 'Read more', 'gp-premium' ),
|
||||
'read_more_button' => false,
|
||||
'masonry' => false,
|
||||
'masonry_load_more' => __( '+ More', 'gp-premium' ),
|
||||
'masonry_loading' => __( 'Loading...', 'gp-premium' ),
|
||||
'infinite_scroll' => false,
|
||||
'infinite_scroll_button' => false,
|
||||
'post_image' => true,
|
||||
'post_image_position' => '',
|
||||
'post_image_alignment' => 'post-image-aligned-center',
|
||||
'post_image_size' => 'full',
|
||||
'post_image_width' => '',
|
||||
'post_image_height' => '',
|
||||
'post_image_padding' => true,
|
||||
'single_post_image' => true,
|
||||
'single_post_image_position' => 'inside-content',
|
||||
'single_post_image_alignment' => 'center',
|
||||
'single_post_image_size' => 'full',
|
||||
'single_post_image_width' => '',
|
||||
'single_post_image_height' => '',
|
||||
'single_post_image_padding' => true,
|
||||
'page_post_image' => true,
|
||||
'page_post_image_position' => 'above-content',
|
||||
'page_post_image_alignment' => 'center',
|
||||
'page_post_image_size' => 'full',
|
||||
'page_post_image_width' => '',
|
||||
'page_post_image_height' => '',
|
||||
'page_post_image_padding' => true,
|
||||
'date' => true,
|
||||
'author' => true,
|
||||
'categories' => true,
|
||||
'tags' => true,
|
||||
'comments' => true,
|
||||
'single_date' => true,
|
||||
'single_author' => true,
|
||||
'single_categories' => true,
|
||||
'single_tags' => true,
|
||||
'single_post_navigation' => true,
|
||||
'column_layout' => false,
|
||||
'columns' => '50',
|
||||
'featured_column' => false,
|
||||
);
|
||||
|
||||
return apply_filters( 'generate_blog_option_defaults', $generate_blog_defaults );
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,754 @@
|
||||
<?php
|
||||
defined( 'WPINC' ) or die;
|
||||
|
||||
// Pull in our defaults and functions
|
||||
require plugin_dir_path( __FILE__ ) . 'defaults.php';
|
||||
require plugin_dir_path( __FILE__ ) . 'images.php';
|
||||
require plugin_dir_path( __FILE__ ) . 'columns.php';
|
||||
require plugin_dir_path( __FILE__ ) . 'customizer.php';
|
||||
require plugin_dir_path( __FILE__ ) . 'migrate.php';
|
||||
|
||||
if ( ! function_exists( 'generate_blog_scripts' ) ) {
|
||||
add_action( 'wp_enqueue_scripts', 'generate_blog_scripts', 50 );
|
||||
/**
|
||||
* Enqueue scripts and styles
|
||||
*/
|
||||
function generate_blog_scripts() {
|
||||
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
||||
|
||||
$settings = wp_parse_args(
|
||||
get_option( 'generate_blog_settings', array() ),
|
||||
generate_blog_get_defaults()
|
||||
);
|
||||
|
||||
wp_add_inline_style( 'generate-style', generate_blog_css() );
|
||||
wp_add_inline_style( 'generate-style', generate_blog_columns_css() );
|
||||
|
||||
$deps = array();
|
||||
|
||||
if ( 'true' == generate_blog_get_masonry() && generate_blog_get_columns() ) {
|
||||
$deps[] = 'masonry';
|
||||
$deps[] = 'imagesloaded';
|
||||
}
|
||||
|
||||
if ( $settings[ 'infinite_scroll' ] && ! is_singular() && ! is_404() && ! is_post_type_archive( 'product' ) ) {
|
||||
$deps[] = 'infinite-scroll';
|
||||
wp_enqueue_script( 'infinite-scroll', plugin_dir_url( __FILE__ ) . 'js/infinite-scroll.pkgd.min.js', array(), '3.0.6', true );
|
||||
|
||||
$font_icons = true;
|
||||
|
||||
if ( function_exists( 'generate_get_option' ) ) {
|
||||
if ( 'font' !== generate_get_option( 'icons' ) ) {
|
||||
$font_icons = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $settings['infinite_scroll_button'] && $font_icons ) {
|
||||
wp_enqueue_style( 'gp-premium-icons' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ( 'true' == generate_blog_get_masonry() && generate_blog_get_columns() ) || ( $settings[ 'infinite_scroll' ] && ! is_singular() && ! is_404() && ! is_post_type_archive( 'product' ) ) ) {
|
||||
wp_enqueue_script( 'generate-blog', plugin_dir_url( __FILE__ ) . "js/scripts{$suffix}.js", $deps, GENERATE_BLOG_VERSION, true );
|
||||
|
||||
wp_localize_script(
|
||||
'generate-blog',
|
||||
'generateBlog',
|
||||
array(
|
||||
'more' => $settings['masonry_load_more'],
|
||||
'loading' => $settings['masonry_loading'],
|
||||
'icon' => function_exists( 'generate_get_svg_icon' ) ? generate_get_svg_icon( 'spinner' ) : '',
|
||||
'masonryInit' => apply_filters(
|
||||
'generate_blog_masonry_init',
|
||||
array(
|
||||
'columnWidth' => '.grid-sizer',
|
||||
'itemSelector' => '.masonry-post',
|
||||
'stamp' => '.page-header',
|
||||
'percentPosition' => true,
|
||||
'stagger' => 30,
|
||||
'visibleStyle' => array(
|
||||
'transform' => 'translateY(0)',
|
||||
'opacity' => 1,
|
||||
),
|
||||
'hiddenStyle' => array(
|
||||
'transform' => 'translateY(5px)',
|
||||
'opacity' => 0,
|
||||
),
|
||||
)
|
||||
),
|
||||
'infiniteScrollInit' => apply_filters(
|
||||
'generate_blog_infinite_scroll_init',
|
||||
array(
|
||||
'path' => '.infinite-scroll-path a',
|
||||
'append' => '#main .infinite-scroll-item',
|
||||
'history' => false,
|
||||
'loadOnScroll' => $settings['infinite_scroll_button'] ? false : true,
|
||||
'button' => $settings['infinite_scroll_button'] ? '.load-more a' : null,
|
||||
'scrollThreshold' => $settings['infinite_scroll_button'] ? false : 600,
|
||||
)
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$needs_columns_css = false;
|
||||
$needs_featured_image_css = false;
|
||||
|
||||
if ( generate_blog_get_columns() || $settings['infinite_scroll'] ) {
|
||||
$needs_columns_css = true;
|
||||
}
|
||||
|
||||
if ( ! is_singular() ) {
|
||||
if ( $settings['post_image'] ) {
|
||||
$needs_featured_image_css = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_page() && has_post_thumbnail() ) {
|
||||
if ( $settings['page_post_image'] ) {
|
||||
$needs_featured_image_css = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_single() && has_post_thumbnail() ) {
|
||||
if ( $settings['single_post_image'] ) {
|
||||
$needs_featured_image_css = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $needs_columns_css && $needs_featured_image_css ) {
|
||||
wp_enqueue_style( 'generate-blog', plugin_dir_url( __FILE__ ) . "css/style{$suffix}.css", array(), GENERATE_BLOG_VERSION );
|
||||
} elseif ( $needs_columns_css ) {
|
||||
wp_enqueue_style( 'generate-blog-columns', plugin_dir_url( __FILE__ ) . "css/columns{$suffix}.css", array(), GENERATE_BLOG_VERSION );
|
||||
} elseif ( $needs_featured_image_css ) {
|
||||
wp_enqueue_style( 'generate-blog-images', plugin_dir_url( __FILE__ ) . "css/featured-images{$suffix}.css", array(), GENERATE_BLOG_VERSION );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_blog_post_classes' ) ) {
|
||||
add_filter( 'post_class', 'generate_blog_post_classes' );
|
||||
/**
|
||||
* Adds custom classes to the content container
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_blog_post_classes( $classes ) {
|
||||
// Don't add these classes to the GB Query Loop block items.
|
||||
if ( in_array( 'gb-query-loop-item', $classes ) ) {
|
||||
return $classes;
|
||||
}
|
||||
|
||||
global $wp_query;
|
||||
$paged = get_query_var( 'paged' );
|
||||
$paged = $paged ? $paged : 1;
|
||||
|
||||
// Get our options
|
||||
$settings = wp_parse_args(
|
||||
get_option( 'generate_blog_settings', array() ),
|
||||
generate_blog_get_defaults()
|
||||
);
|
||||
|
||||
if ( $settings['infinite_scroll'] ) {
|
||||
$classes[] = 'infinite-scroll-item';
|
||||
}
|
||||
|
||||
// Set our masonry class
|
||||
if ( 'true' == generate_blog_get_masonry() && generate_blog_get_columns() ) {
|
||||
$classes[] = 'masonry-post';
|
||||
}
|
||||
|
||||
// Set our column classes
|
||||
if ( generate_blog_get_columns() && ! is_singular() ) {
|
||||
$classes[] = 'generate-columns';
|
||||
$classes[] = 'tablet-grid-50';
|
||||
$classes[] = 'mobile-grid-100';
|
||||
$classes[] = 'grid-parent';
|
||||
|
||||
// Set our featured column class
|
||||
if ( $wp_query->current_post == 0 && $paged == 1 && $settings['featured_column'] ) {
|
||||
if ( 50 == generate_blog_get_column_count() ) {
|
||||
$classes[] = 'grid-100';
|
||||
}
|
||||
|
||||
if ( 33 == generate_blog_get_column_count() ) {
|
||||
$classes[] = 'grid-66';
|
||||
}
|
||||
|
||||
if ( 25 == generate_blog_get_column_count() ) {
|
||||
$classes[] = 'grid-50';
|
||||
}
|
||||
|
||||
if ( 20 == generate_blog_get_column_count() ) {
|
||||
$classes[] = 'grid-60';
|
||||
}
|
||||
$classes[] = 'featured-column';
|
||||
} else {
|
||||
$classes[] = 'grid-' . generate_blog_get_column_count();
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $settings['post_image_padding'] && ! is_singular() ) {
|
||||
$classes[] = 'no-featured-image-padding';
|
||||
}
|
||||
|
||||
$location = generate_blog_get_singular_template();
|
||||
|
||||
if ( ! $settings[$location . '_post_image_padding'] && is_singular() ) {
|
||||
$classes[] = 'no-featured-image-padding';
|
||||
}
|
||||
|
||||
$atts = generate_get_blog_image_attributes();
|
||||
|
||||
if ( ! is_singular() && has_post_thumbnail() && ! empty( $atts ) ) {
|
||||
$values = array(
|
||||
$atts['width'],
|
||||
$atts['height'],
|
||||
$atts['crop'],
|
||||
);
|
||||
|
||||
$image_src = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID(), 'full' ), $values );
|
||||
|
||||
if ( $image_src && ( ! $image_src[3] || ! apply_filters( 'generate_use_featured_image_size_match', true ) ) ) {
|
||||
$classes[] = 'resize-featured-image';
|
||||
}
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_blog_body_classes' ) ) {
|
||||
add_filter( 'body_class', 'generate_blog_body_classes' );
|
||||
/**
|
||||
* Adds custom classes to the body
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_blog_body_classes( $classes ) {
|
||||
// Get theme options
|
||||
$settings = wp_parse_args(
|
||||
get_option( 'generate_blog_settings', array() ),
|
||||
generate_blog_get_defaults()
|
||||
);
|
||||
|
||||
if ( is_singular() ) {
|
||||
$location = generate_blog_get_singular_template();
|
||||
|
||||
if ( 'below-title' == $settings[$location . '_post_image_position'] ) {
|
||||
$classes[] = 'post-image-below-header';
|
||||
}
|
||||
|
||||
if ( 'inside-content' == $settings[$location . '_post_image_position'] ) {
|
||||
$classes[] = 'post-image-above-header';
|
||||
}
|
||||
|
||||
$classes[] = ( ! empty( $settings[$location . '_post_image_alignment'] ) ) ? 'post-image-aligned-' . $settings[$location . '_post_image_alignment'] : 'post-image-aligned-center';
|
||||
} else {
|
||||
$classes[] = ( '' == $settings['post_image_position'] ) ? 'post-image-below-header' : 'post-image-above-header';
|
||||
$classes[] = ( ! empty( $settings['post_image_alignment'] ) ) ? $settings['post_image_alignment'] : 'post-image-aligned-center';
|
||||
}
|
||||
|
||||
if ( 'true' == generate_blog_get_masonry() && generate_blog_get_columns() ) {
|
||||
$classes[] = 'masonry-enabled';
|
||||
}
|
||||
|
||||
if ( generate_blog_get_columns() && ! is_singular() ) {
|
||||
$classes[] = 'generate-columns-activated';
|
||||
}
|
||||
|
||||
if ( $settings[ 'infinite_scroll' ] && ! is_singular() ) {
|
||||
$classes[] = 'infinite-scroll';
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_excerpt_length' ) ) {
|
||||
add_filter( 'excerpt_length', 'generate_excerpt_length', 15 );
|
||||
/**
|
||||
* Set our excerpt length
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_excerpt_length( $length ) {
|
||||
$generate_settings = wp_parse_args(
|
||||
get_option( 'generate_blog_settings', array() ),
|
||||
generate_blog_get_defaults()
|
||||
);
|
||||
return absint( apply_filters( 'generate_excerpt_length', $generate_settings['excerpt_length'] ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_blog_css' ) ) {
|
||||
/**
|
||||
* Build our inline CSS
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_blog_css() {
|
||||
global $post;
|
||||
$return = '';
|
||||
|
||||
$settings = wp_parse_args(
|
||||
get_option( 'generate_blog_settings', array() ),
|
||||
generate_blog_get_defaults()
|
||||
);
|
||||
|
||||
if ( ! defined( 'GENERATE_VERSION' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( version_compare( GENERATE_VERSION, '3.0.0-alpha.1', '<' ) ) {
|
||||
// Get disable headline meta.
|
||||
$disable_headline = ( isset( $post ) ) ? get_post_meta( $post->ID, '_generate-disable-headline', true ) : '';
|
||||
|
||||
if ( ! $settings['categories'] && ! $settings['comments'] && ! $settings['tags'] && ! is_singular() ) {
|
||||
$return .= '.blog footer.entry-meta, .archive footer.entry-meta {display:none;}';
|
||||
}
|
||||
|
||||
if ( ! $settings['single_date'] && ! $settings['single_author'] && $disable_headline && is_singular() ) {
|
||||
$return .= '.single .entry-header{display:none;}.single .entry-content {margin-top:0;}';
|
||||
}
|
||||
|
||||
if ( ! $settings['date'] && ! $settings['author'] && ! is_singular() ) {
|
||||
$return .= '.entry-header .entry-meta {display:none;}';
|
||||
}
|
||||
|
||||
if ( ! $settings['single_date'] && ! $settings['single_author'] && is_singular() ) {
|
||||
$return .= '.entry-header .entry-meta {display:none;}';
|
||||
}
|
||||
|
||||
if ( ! $settings['single_post_navigation'] && is_singular() ) {
|
||||
$return .= '.post-navigation {display:none;}';
|
||||
}
|
||||
|
||||
if ( ! $settings['single_categories'] && ! $settings['single_post_navigation'] && ! $settings['single_tags'] && is_singular() ) {
|
||||
$return .= '.single footer.entry-meta {display:none;}';
|
||||
}
|
||||
}
|
||||
|
||||
$separator = 20;
|
||||
$content_padding_top = 40;
|
||||
$content_padding_right = 40;
|
||||
$content_padding_left = 40;
|
||||
$mobile_content_padding_top = 30;
|
||||
$mobile_content_padding_right = 30;
|
||||
$mobile_content_padding_left = 30;
|
||||
|
||||
if ( function_exists( 'generate_spacing_get_defaults' ) ) {
|
||||
$spacing_settings = wp_parse_args(
|
||||
get_option( 'generate_spacing_settings', array() ),
|
||||
generate_spacing_get_defaults()
|
||||
);
|
||||
|
||||
$separator = absint( $spacing_settings['separator'] );
|
||||
$content_padding_top = absint( $spacing_settings['content_top'] );
|
||||
$content_padding_right = absint( $spacing_settings['content_right'] );
|
||||
$content_padding_left = absint( $spacing_settings['content_left'] );
|
||||
$mobile_content_padding_top = absint( $spacing_settings['mobile_content_top'] );
|
||||
$mobile_content_padding_right = absint( $spacing_settings['mobile_content_right'] );
|
||||
$mobile_content_padding_left = absint( $spacing_settings['mobile_content_left'] );
|
||||
}
|
||||
|
||||
if ( 'true' == generate_blog_get_masonry() && generate_blog_get_columns() ) {
|
||||
$return .= '.page-header {margin-bottom: ' . $separator . 'px;margin-left: ' . $separator . 'px}';
|
||||
}
|
||||
|
||||
if ( $settings[ 'infinite_scroll' ] && ! is_singular() ) {
|
||||
$return .= '#nav-below {display:none;}';
|
||||
}
|
||||
|
||||
if ( ! $settings['post_image_padding'] && 'post-image-aligned-center' == $settings['post_image_alignment'] && ! is_singular() ) {
|
||||
$return .= '.no-featured-image-padding .post-image {margin-left:-' . $content_padding_left . 'px;margin-right:-' . $content_padding_right . 'px;}';
|
||||
$return .= '.post-image-above-header .no-featured-image-padding .inside-article .post-image {margin-top:-' . $content_padding_top . 'px;}';
|
||||
}
|
||||
|
||||
$location = generate_blog_get_singular_template();
|
||||
|
||||
if ( ! $settings[$location . '_post_image_padding'] && 'center' == $settings[$location . '_post_image_alignment'] && is_singular() ) {
|
||||
$return .= '.no-featured-image-padding .featured-image {margin-left:-' . $content_padding_left . 'px;margin-right:-' . $content_padding_right . 'px;}';
|
||||
$return .= '.post-image-above-header .no-featured-image-padding .inside-article .featured-image {margin-top:-' . $content_padding_top . 'px;}';
|
||||
}
|
||||
|
||||
if ( ! $settings['page_post_image_padding'] || ! $settings['single_post_image_padding'] || ! $settings['post_image_padding'] ) {
|
||||
$return .= '@media ' . generate_premium_get_media_query( 'mobile' ) . '{';
|
||||
if ( ! $settings['post_image_padding'] && 'post-image-aligned-center' == $settings['post_image_alignment'] && ! is_singular() ) {
|
||||
$return .= '.no-featured-image-padding .post-image {margin-left:-' . $mobile_content_padding_left . 'px;margin-right:-' . $mobile_content_padding_right . 'px;}';
|
||||
$return .= '.post-image-above-header .no-featured-image-padding .inside-article .post-image {margin-top:-' . $mobile_content_padding_top . 'px;}';
|
||||
}
|
||||
|
||||
if ( ! $settings[$location . '_post_image_padding'] && 'center' == $settings[$location . '_post_image_alignment'] && is_singular() ) {
|
||||
$return .= '.no-featured-image-padding .featured-image {margin-left:-' . $mobile_content_padding_left . 'px;margin-right:-' . $mobile_content_padding_right . 'px;}';
|
||||
$return .= '.post-image-above-header .no-featured-image-padding .inside-article .featured-image {margin-top:-' . $mobile_content_padding_top . 'px;}';
|
||||
}
|
||||
$return .= '}';
|
||||
}
|
||||
|
||||
$atts = generate_get_blog_image_attributes();
|
||||
|
||||
if ( ! empty( $atts ) ) {
|
||||
$image_width = $atts['width'] && 9999 !== $atts['width'] ? 'width: ' . $atts['width'] . 'px;' : '';
|
||||
$image_height = $atts['height'] && 9999 !== $atts['height'] ? 'height: ' . $atts['height'] . 'px;' : '';
|
||||
$image_crop = $atts['crop'] ? '-o-object-fit: cover;object-fit: cover;' : '';
|
||||
|
||||
if ( ! $image_width && $image_height ) {
|
||||
$image_crop = '-o-object-fit: cover;object-fit: cover;';
|
||||
}
|
||||
|
||||
if ( ! is_singular() ) {
|
||||
$return .= '.resize-featured-image .post-image img {' . $image_width . $image_height . $image_crop . '}';
|
||||
}
|
||||
|
||||
if ( is_single() || is_page() ) {
|
||||
$values = array(
|
||||
$atts['width'],
|
||||
$atts['height'],
|
||||
$atts['crop'],
|
||||
);
|
||||
|
||||
$image_src = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID(), 'full' ), $values );
|
||||
|
||||
if ( $image_src && ( ! $image_src[3] || ! apply_filters( 'generate_use_featured_image_size_match', true ) ) ) {
|
||||
$return .= '.featured-image img {' . $image_width . $image_height . $image_crop . '}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
add_filter( 'generate_excerpt_more_text', 'generate_blog_set_read_more_text' );
|
||||
/**
|
||||
* Set the read more text with our Customizer setting.
|
||||
*
|
||||
* @param string $text The read more text.
|
||||
*/
|
||||
function generate_blog_set_read_more_text( $text ) {
|
||||
$settings = wp_parse_args(
|
||||
get_option( 'generate_blog_settings', array() ),
|
||||
generate_blog_get_defaults()
|
||||
);
|
||||
|
||||
if ( $settings['read_more'] ) {
|
||||
return wp_kses_post( $settings['read_more'] );
|
||||
}
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_blog_excerpt_more' ) ) {
|
||||
add_filter( 'excerpt_more', 'generate_blog_excerpt_more', 15 );
|
||||
/**
|
||||
* Prints the read more HTML
|
||||
*/
|
||||
function generate_blog_excerpt_more( $more ) {
|
||||
$generate_settings = wp_parse_args(
|
||||
get_option( 'generate_blog_settings', array() ),
|
||||
generate_blog_get_defaults()
|
||||
);
|
||||
|
||||
if ( '' == $generate_settings['read_more'] ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// We don't need to overwrite the entire element just to change its text.
|
||||
// If we can filter the text, stop here.
|
||||
if ( function_exists( 'generate_get_read_more_text' ) ) {
|
||||
return $more;
|
||||
}
|
||||
|
||||
return apply_filters(
|
||||
'generate_excerpt_more_output',
|
||||
sprintf(
|
||||
' ... <a title="%1$s" class="read-more" href="%2$s" aria-label="%4$s">%3$s</a>',
|
||||
the_title_attribute( 'echo=0' ),
|
||||
esc_url( get_permalink( get_the_ID() ) ),
|
||||
wp_kses_post( $generate_settings['read_more'] ),
|
||||
sprintf(
|
||||
/* translators: Aria-label describing the read more button */
|
||||
_x( 'More on %s', 'more on post title', 'gp-premium' ),
|
||||
the_title_attribute( 'echo=0' )
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_blog_content_more' ) ) {
|
||||
add_filter( 'the_content_more_link', 'generate_blog_content_more', 15 );
|
||||
/**
|
||||
* Prints the read more HTML
|
||||
*/
|
||||
function generate_blog_content_more( $more ) {
|
||||
$generate_settings = wp_parse_args(
|
||||
get_option( 'generate_blog_settings', array() ),
|
||||
generate_blog_get_defaults()
|
||||
);
|
||||
|
||||
if ( '' == $generate_settings['read_more'] ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
// We don't need to overwrite the entire element just to change its text.
|
||||
// If we can filter the text, stop here.
|
||||
if ( function_exists( 'generate_get_read_more_text' ) ) {
|
||||
return $more;
|
||||
}
|
||||
|
||||
return apply_filters(
|
||||
'generate_content_more_link_output',
|
||||
sprintf(
|
||||
'<p class="read-more-container"><a title="%1$s" class="read-more content-read-more" href="%2$s" aria-label="%4$s">%3$s</a></p>',
|
||||
the_title_attribute( 'echo=0' ),
|
||||
esc_url( get_permalink( get_the_ID() ) . apply_filters( 'generate_more_jump', '#more-' . get_the_ID() ) ),
|
||||
wp_kses_post( $generate_settings['read_more'] ),
|
||||
sprintf(
|
||||
/* translators: Aria-label describing the read more button */
|
||||
_x( 'More on %s', 'more on post title', 'gp-premium' ),
|
||||
the_title_attribute( 'echo=0' )
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the setting and returns false if $thing is disabled
|
||||
*
|
||||
* @since 1.4
|
||||
*
|
||||
* @param String $data The original data, passed through if not disabled
|
||||
* @param String $thing The name of the thing to check
|
||||
* @return String|False The original data, or false (if disabled)
|
||||
*/
|
||||
function generate_disable_post_thing( $data, $thing ) {
|
||||
$generate_blog_settings = wp_parse_args(
|
||||
get_option( 'generate_blog_settings', array() ),
|
||||
generate_blog_get_defaults()
|
||||
);
|
||||
|
||||
if ( ! $generate_blog_settings[$thing] ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_disable_post_date' ) ) {
|
||||
add_filter( 'generate_post_date', 'generate_disable_post_date' );
|
||||
/**
|
||||
* Remove the post date if set
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_disable_post_date( $date ) {
|
||||
if ( is_singular() ) {
|
||||
return generate_disable_post_thing( $date, 'single_date' );
|
||||
} else {
|
||||
return generate_disable_post_thing( $date, 'date' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_disable_post_author' ) ) {
|
||||
add_filter( 'generate_post_author', 'generate_disable_post_author' );
|
||||
/**
|
||||
* Set the author if set
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_disable_post_author( $author ) {
|
||||
if ( is_singular() ) {
|
||||
return generate_disable_post_thing( $author, 'single_author' );
|
||||
} else {
|
||||
return generate_disable_post_thing( $author, 'author' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_disable_post_categories' ) ) {
|
||||
add_filter( 'generate_show_categories', 'generate_disable_post_categories' );
|
||||
/**
|
||||
* Remove the categories if set
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_disable_post_categories( $categories ) {
|
||||
if ( is_singular() ) {
|
||||
return generate_disable_post_thing( $categories, 'single_categories' );
|
||||
} else {
|
||||
return generate_disable_post_thing( $categories, 'categories' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_disable_post_tags' ) ) {
|
||||
add_filter( 'generate_show_tags', 'generate_disable_post_tags' );
|
||||
/**
|
||||
* Remove the tags if set
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_disable_post_tags( $tags ) {
|
||||
if ( is_singular() ) {
|
||||
return generate_disable_post_thing( $tags, 'single_tags' );
|
||||
} else {
|
||||
return generate_disable_post_thing( $tags, 'tags' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_disable_post_comments_link' ) ) {
|
||||
add_filter( 'generate_show_comments', 'generate_disable_post_comments_link' );
|
||||
/**
|
||||
* Remove the link to comments if set
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_disable_post_comments_link( $comments_link ) {
|
||||
return generate_disable_post_thing( $comments_link, 'comments' );
|
||||
}
|
||||
}
|
||||
|
||||
add_filter( 'generate_show_post_navigation', 'generate_disable_post_navigation' );
|
||||
/**
|
||||
* Remove the single post navigation
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
function generate_disable_post_navigation( $navigation ) {
|
||||
if ( is_singular() ) {
|
||||
return generate_disable_post_thing( $navigation, 'single_post_navigation' );
|
||||
} else {
|
||||
return $navigation;
|
||||
}
|
||||
}
|
||||
|
||||
add_filter( 'generate_excerpt_more_output', 'generate_blog_read_more_button' );
|
||||
add_filter( 'generate_content_more_link_output', 'generate_blog_read_more_button' );
|
||||
/**
|
||||
* Add the button class to our read more link if set.
|
||||
*
|
||||
* @since 1.5
|
||||
*
|
||||
* @param string $output Our existing read more link.
|
||||
*/
|
||||
function generate_blog_read_more_button( $output ) {
|
||||
$settings = wp_parse_args(
|
||||
get_option( 'generate_blog_settings', array() ),
|
||||
generate_blog_get_defaults()
|
||||
);
|
||||
|
||||
if ( ! $settings['read_more_button'] ) {
|
||||
return $output;
|
||||
}
|
||||
|
||||
$aria_label = function_exists( 'generate_get_read_more_aria_label' )
|
||||
? generate_get_read_more_aria_label()
|
||||
: sprintf(
|
||||
/* translators: Aria-label describing the read more button */
|
||||
_x( 'More on %s', 'more on post title', 'gp-premium' ),
|
||||
the_title_attribute( 'echo=0' )
|
||||
);
|
||||
|
||||
return sprintf(
|
||||
'%5$s<p class="read-more-container"><a title="%1$s" class="read-more button" href="%2$s" aria-label="%4$s">%3$s</a></p>',
|
||||
the_title_attribute( 'echo=0' ),
|
||||
esc_url( get_permalink( get_the_ID() ) . apply_filters( 'generate_more_jump', '#more-' . get_the_ID() ) ),
|
||||
wp_kses_post( $settings['read_more'] ),
|
||||
$aria_label,
|
||||
'generate_excerpt_more_output' === current_filter() ? ' ... ' : ''
|
||||
);
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_blog_load_more' ) ) {
|
||||
add_action( 'generate_after_main_content', 'generate_blog_load_more', 20 );
|
||||
/**
|
||||
* Build our load more button
|
||||
*/
|
||||
function generate_blog_load_more() {
|
||||
// Get theme options
|
||||
$settings = wp_parse_args(
|
||||
get_option( 'generate_blog_settings', array() ),
|
||||
generate_blog_get_defaults()
|
||||
);
|
||||
|
||||
if ( ( ! $settings[ 'infinite_scroll_button' ] || ! $settings[ 'infinite_scroll' ] ) || is_singular() || is_404() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
global $wp_query;
|
||||
|
||||
if ( $wp_query->max_num_pages < 2 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( is_post_type_archive( 'product' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( is_tax( 'product_cat' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$icon = '';
|
||||
|
||||
if ( function_exists( 'generate_get_svg_icon' ) ) {
|
||||
$icon = generate_get_svg_icon( 'spinner' );
|
||||
}
|
||||
|
||||
printf(
|
||||
'<div class="masonry-load-more load-more %1$s %2$s">
|
||||
<a class="button" href="#">%3$s%4$s</a>
|
||||
</div>',
|
||||
$icon ? 'has-svg-icon' : '',
|
||||
( 'true' == generate_blog_get_masonry() && generate_blog_get_columns() ) ? 'are-images-unloaded' : '',
|
||||
$icon,
|
||||
wp_kses_post( $settings['masonry_load_more'] )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see whether we're getting page or single post options.
|
||||
*
|
||||
* @since 1.5
|
||||
*
|
||||
* @return string Name of our singular template
|
||||
*/
|
||||
function generate_blog_get_singular_template() {
|
||||
$template = 'single';
|
||||
|
||||
if ( is_page() ) {
|
||||
$template = 'page';
|
||||
}
|
||||
|
||||
return $template;
|
||||
}
|
||||
|
||||
add_action( 'generate_after_footer', 'generate_blog_do_infinite_scroll_path', 500 );
|
||||
/**
|
||||
* Add a next page of posts link for infinite scroll.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
function generate_blog_do_infinite_scroll_path() {
|
||||
if ( function_exists( 'is_woocommerce' ) && is_woocommerce() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$settings = wp_parse_args(
|
||||
get_option( 'generate_blog_settings', array() ),
|
||||
generate_blog_get_defaults()
|
||||
);
|
||||
|
||||
if ( $settings['infinite_scroll'] && ! is_singular() && ! is_404() ) {
|
||||
printf(
|
||||
'<div class="infinite-scroll-path" aria-hidden="true" style="display: none;">%s</div>',
|
||||
get_next_posts_link()
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,369 @@
|
||||
<?php
|
||||
/**
|
||||
* Functions specific to featured images.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
/**
|
||||
* Collects all available image sizes which we use in the Customizer.
|
||||
*
|
||||
* @since 1.10.0
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function generate_blog_get_image_sizes() {
|
||||
$sizes = get_intermediate_image_sizes();
|
||||
|
||||
$new_sizes = array(
|
||||
'full' => 'full',
|
||||
);
|
||||
|
||||
foreach ( $sizes as $key => $name ) {
|
||||
$new_sizes[ $name ] = $name;
|
||||
}
|
||||
|
||||
return $new_sizes;
|
||||
}
|
||||
|
||||
add_filter( 'generate_page_header_default_size', 'generate_blog_set_featured_image_size' );
|
||||
/**
|
||||
* Set our featured image sizes.
|
||||
*
|
||||
* @since 1.10.0
|
||||
*
|
||||
* @param string $size The existing size.
|
||||
* @return string The new size.
|
||||
*/
|
||||
function generate_blog_set_featured_image_size( $size ) {
|
||||
$settings = wp_parse_args(
|
||||
get_option( 'generate_blog_settings', array() ),
|
||||
generate_blog_get_defaults()
|
||||
);
|
||||
|
||||
if ( ! is_singular() ) {
|
||||
$size = $settings['post_image_size'];
|
||||
}
|
||||
|
||||
if ( is_single() ) {
|
||||
$size = $settings['single_post_image_size'];
|
||||
}
|
||||
|
||||
if ( is_page() ) {
|
||||
$size = $settings['page_post_image_size'];
|
||||
}
|
||||
|
||||
$atts = generate_get_blog_image_attributes();
|
||||
|
||||
if ( ! empty( $atts ) ) {
|
||||
$values = array(
|
||||
$atts['width'],
|
||||
$atts['height'],
|
||||
$atts['crop'],
|
||||
);
|
||||
|
||||
$image_src = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID(), 'full' ), $values );
|
||||
|
||||
if ( $image_src && $image_src[3] && apply_filters( 'generate_use_featured_image_size_match', true ) ) {
|
||||
return $values;
|
||||
} else {
|
||||
return $size;
|
||||
}
|
||||
}
|
||||
|
||||
return $size;
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_get_blog_image_attributes' ) ) {
|
||||
/**
|
||||
* Build our image attributes
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_get_blog_image_attributes() {
|
||||
$settings = wp_parse_args(
|
||||
get_option( 'generate_blog_settings', array() ),
|
||||
generate_blog_get_defaults()
|
||||
);
|
||||
|
||||
if ( is_singular() ) {
|
||||
if ( is_singular( 'page' ) ) {
|
||||
$single = 'page_';
|
||||
} else {
|
||||
$single = 'single_';
|
||||
}
|
||||
} else {
|
||||
$single = '';
|
||||
}
|
||||
|
||||
$ignore_crop = array( '', '0', '9999' );
|
||||
|
||||
$atts = array(
|
||||
'width' => ( in_array( $settings[ "{$single}post_image_width" ], $ignore_crop ) ) ? 9999 : absint( $settings[ "{$single}post_image_width" ] ),
|
||||
'height' => ( in_array( $settings[ "{$single}post_image_height" ], $ignore_crop ) ) ? 9999 : absint( $settings[ "{$single}post_image_height" ] ),
|
||||
'crop' => ( in_array( $settings[ "{$single}post_image_width" ], $ignore_crop ) || in_array( $settings[ "{$single}post_image_height" ], $ignore_crop ) ) ? false : true,
|
||||
);
|
||||
|
||||
// If there's no height or width, empty the array.
|
||||
if ( 9999 == $atts['width'] && 9999 == $atts['height'] ) { // phpcs:ignore
|
||||
$atts = array();
|
||||
}
|
||||
|
||||
return apply_filters( 'generate_blog_image_attributes', $atts );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_blog_setup' ) ) {
|
||||
add_action( 'wp', 'generate_blog_setup', 50 );
|
||||
/**
|
||||
* Setup our blog functions and actions
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_blog_setup() {
|
||||
$settings = wp_parse_args(
|
||||
get_option( 'generate_blog_settings', array() ),
|
||||
generate_blog_get_defaults()
|
||||
);
|
||||
|
||||
// Move our featured images to above the title.
|
||||
if ( 'post-image-above-header' === $settings['post_image_position'] ) {
|
||||
remove_action( 'generate_after_entry_header', 'generate_post_image' );
|
||||
add_action( 'generate_before_content', 'generate_post_image' );
|
||||
|
||||
// If we're using the Page Header add-on, move those as well.
|
||||
if ( function_exists( 'generate_page_header_post_image' ) ) {
|
||||
remove_action( 'generate_after_entry_header', 'generate_page_header_post_image' );
|
||||
add_action( 'generate_before_content', 'generate_page_header_post_image' );
|
||||
}
|
||||
}
|
||||
|
||||
$page_header_content = false;
|
||||
if ( function_exists( 'generate_page_header_get_options' ) ) {
|
||||
$options = generate_page_header_get_options();
|
||||
|
||||
if ( $options && '' !== $options['content'] ) {
|
||||
$page_header_content = true;
|
||||
}
|
||||
|
||||
// If our Page Header has no content, remove it.
|
||||
// This will allow the Blog add-on to add an image for us.
|
||||
if ( ! $page_header_content && is_singular() ) {
|
||||
remove_action( 'generate_before_content', 'generate_page_header' );
|
||||
remove_action( 'generate_after_entry_header', 'generate_page_header' );
|
||||
remove_action( 'generate_after_header', 'generate_page_header' );
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the core theme featured image.
|
||||
// I would like to filter instead one day.
|
||||
remove_action( 'generate_after_header', 'generate_featured_page_header' );
|
||||
remove_action( 'generate_before_content', 'generate_featured_page_header_inside_single' );
|
||||
|
||||
$location = generate_blog_get_singular_template();
|
||||
|
||||
if ( $settings[ $location . '_post_image' ] && is_singular() && ! $page_header_content ) {
|
||||
if ( 'below-title' === $settings[ $location . '_post_image_position' ] ) {
|
||||
add_action( 'generate_after_entry_header', 'generate_blog_single_featured_image' );
|
||||
}
|
||||
|
||||
if ( 'inside-content' === $settings[ $location . '_post_image_position' ] ) {
|
||||
add_action( 'generate_before_content', 'generate_blog_single_featured_image' );
|
||||
}
|
||||
|
||||
if ( 'above-content' === $settings[ $location . '_post_image_position' ] ) {
|
||||
add_action( 'generate_after_header', 'generate_blog_single_featured_image' );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
add_filter( 'generate_featured_image_output', 'generate_blog_featured_image' );
|
||||
/**
|
||||
* Remove featured image if set or using WooCommerce.
|
||||
*
|
||||
* @since 1.5
|
||||
* @param string $output The existing output.
|
||||
* @return string The image HTML
|
||||
*/
|
||||
function generate_blog_featured_image( $output ) {
|
||||
$settings = wp_parse_args(
|
||||
get_option( 'generate_blog_settings', array() ),
|
||||
generate_blog_get_defaults()
|
||||
);
|
||||
|
||||
if ( ( function_exists( 'is_woocommerce' ) && is_woocommerce() ) || ! $settings['post_image'] ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build our featured images for single posts and pages.
|
||||
*
|
||||
* This function is way more complicated than it could be so it can
|
||||
* ensure compatibility with the Page Header add-on.
|
||||
*
|
||||
* @since 1.5
|
||||
*
|
||||
* @return string The image HTML
|
||||
*/
|
||||
function generate_blog_single_featured_image() {
|
||||
$settings = wp_parse_args(
|
||||
get_option( 'generate_blog_settings', array() ),
|
||||
generate_blog_get_defaults()
|
||||
);
|
||||
|
||||
$image_id = get_post_thumbnail_id( get_the_ID(), 'full' );
|
||||
|
||||
if ( function_exists( 'generate_page_header_get_image' ) && generate_page_header_get_image( 'ID' ) ) {
|
||||
if ( intval( $image_id ) !== generate_page_header_get_image( 'ID' ) ) {
|
||||
$image_id = generate_page_header_get_image( 'ID' );
|
||||
}
|
||||
}
|
||||
|
||||
$location = generate_blog_get_singular_template();
|
||||
|
||||
if ( ( function_exists( 'is_woocommerce' ) && is_woocommerce() ) || ! $settings[ $location . '_post_image' ] || ! $image_id ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$attrs = array(
|
||||
'itemprop' => 'image',
|
||||
);
|
||||
|
||||
if ( function_exists( 'generate_get_schema_type' ) ) {
|
||||
if ( 'microdata' !== generate_get_schema_type() ) {
|
||||
$attrs = array();
|
||||
}
|
||||
}
|
||||
|
||||
$attrs['loading'] = false;
|
||||
$attrs = apply_filters( 'generate_single_featured_image_attrs', $attrs );
|
||||
|
||||
$image_html = apply_filters(
|
||||
'post_thumbnail_html', // phpcs:ignore -- Core filter.
|
||||
wp_get_attachment_image(
|
||||
$image_id,
|
||||
apply_filters( 'generate_page_header_default_size', 'full' ),
|
||||
'',
|
||||
$attrs
|
||||
),
|
||||
get_the_ID(),
|
||||
$image_id,
|
||||
apply_filters( 'generate_page_header_default_size', 'full' ),
|
||||
''
|
||||
);
|
||||
|
||||
$location = generate_blog_get_singular_template();
|
||||
|
||||
$classes = array(
|
||||
is_page() ? 'page-header-image' : null,
|
||||
is_singular() && ! is_page() ? 'page-header-image-single' : null,
|
||||
'above-content' === $settings[ $location . '_post_image_position' ] ? 'grid-container grid-parent' : null,
|
||||
);
|
||||
|
||||
$image_html = apply_filters( 'generate_single_featured_image_html', $image_html );
|
||||
|
||||
// phpcs:ignore -- No need to escape here.
|
||||
echo apply_filters(
|
||||
'generate_single_featured_image_output',
|
||||
sprintf(
|
||||
'<div class="featured-image %2$s">
|
||||
%1$s
|
||||
</div>',
|
||||
$image_html,
|
||||
implode( ' ', $classes )
|
||||
),
|
||||
$image_html
|
||||
);
|
||||
}
|
||||
|
||||
add_filter( 'generate_blog_image_attributes', 'generate_blog_page_header_image_atts' );
|
||||
/**
|
||||
* Filter our image attributes in case we're using differents atts in our Page Header
|
||||
*
|
||||
* @since 1.5
|
||||
*
|
||||
* @param array $atts Our existing image attributes.
|
||||
* @return array Image attributes
|
||||
*/
|
||||
function generate_blog_page_header_image_atts( $atts ) {
|
||||
if ( ! function_exists( 'generate_page_header_get_options' ) ) {
|
||||
return $atts;
|
||||
}
|
||||
|
||||
if ( ! is_singular() ) {
|
||||
return $atts;
|
||||
}
|
||||
|
||||
$options = generate_page_header_get_options();
|
||||
|
||||
if ( $options && 'enable' === $options['image_resize'] ) {
|
||||
$ignore_crop = array( '', '0', '9999' );
|
||||
|
||||
$atts = array(
|
||||
'width' => ( in_array( $options['image_width'], $ignore_crop ) ) ? 9999 : absint( $options['image_width'] ),
|
||||
'height' => ( in_array( $options['image_height'], $ignore_crop ) ) ? 9999 : absint( $options['image_height'] ),
|
||||
'crop' => ( in_array( $options['image_width'], $ignore_crop ) || in_array( $options['image_height'], $ignore_crop ) ) ? false : true,
|
||||
);
|
||||
}
|
||||
|
||||
return $atts;
|
||||
}
|
||||
|
||||
add_filter( 'generate_single_featured_image_html', 'generate_blog_page_header_link' );
|
||||
/**
|
||||
* Add our Page Header link to our featured image if set.
|
||||
*
|
||||
* @since 1.5
|
||||
*
|
||||
* @param string $image_html Our existing image HTML.
|
||||
* @return string Our new image HTML.
|
||||
*/
|
||||
function generate_blog_page_header_link( $image_html ) {
|
||||
if ( ! function_exists( 'generate_page_header_get_options' ) ) {
|
||||
return $image_html;
|
||||
}
|
||||
|
||||
$options = generate_page_header_get_options();
|
||||
|
||||
if ( ! empty( $options['image_link'] ) ) {
|
||||
return '<a href="' . esc_url( $options['image_link'] ) . '"' . apply_filters( 'generate_page_header_link_target', '' ) . '>' . $image_html . '</a>';
|
||||
} else {
|
||||
return $image_html;
|
||||
}
|
||||
}
|
||||
|
||||
add_filter( 'body_class', 'generate_blog_remove_featured_image_class', 20 );
|
||||
/**
|
||||
* Remove the featured image classes if they're disabled.
|
||||
*
|
||||
* @since 2.1.0
|
||||
* @param array $classes The body classes.
|
||||
*/
|
||||
function generate_blog_remove_featured_image_class( $classes ) {
|
||||
if ( is_singular() ) {
|
||||
$settings = wp_parse_args(
|
||||
get_option( 'generate_blog_settings', array() ),
|
||||
generate_blog_get_defaults()
|
||||
);
|
||||
|
||||
if ( is_single() ) {
|
||||
$disable_single_featured_image = ! $settings['single_post_image'];
|
||||
$classes = generate_premium_remove_featured_image_class( $classes, $disable_single_featured_image );
|
||||
}
|
||||
|
||||
if ( is_page() && ! $settings['page_post_image'] ) {
|
||||
$disable_page_featured_image = ! $settings['page_post_image'];
|
||||
$classes = generate_premium_remove_featured_image_class( $classes, $disable_page_featured_image );
|
||||
}
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
98
wp-content/upgrade-temp-backup/plugins/gp-premium/blog/functions/js/controls.js
vendored
Normal file
98
wp-content/upgrade-temp-backup/plugins/gp-premium/blog/functions/js/controls.js
vendored
Normal file
@ -0,0 +1,98 @@
|
||||
jQuery( function( $ ) {
|
||||
// Featured image controls
|
||||
var featuredImageArchiveControls = [
|
||||
'generate_blog_settings-post_image',
|
||||
'generate_blog_settings-post_image_padding',
|
||||
'generate_blog_settings-post_image_position',
|
||||
'generate_blog_settings-post_image_alignment',
|
||||
'generate_blog_settings-post_image_size',
|
||||
'generate_blog_settings-post_image_width',
|
||||
'generate_blog_settings-post_image_height',
|
||||
'generate_regenerate_images_notice',
|
||||
];
|
||||
|
||||
$.each( featuredImageArchiveControls, function( index, value ) {
|
||||
$( '#customize-control-' + value ).attr( 'data-control-section', 'featured-image-archives' );
|
||||
} );
|
||||
|
||||
var featuredImageSingleControls = [
|
||||
'generate_blog_settings-single_post_image',
|
||||
'generate_blog_settings-single_post_image_padding',
|
||||
'generate_blog_settings-single_post_image_position',
|
||||
'generate_blog_settings-single_post_image_alignment',
|
||||
'generate_blog_settings-single_post_image_size',
|
||||
'generate_blog_settings-single_post_image_width',
|
||||
'generate_blog_settings-single_post_image_height',
|
||||
'generate_regenerate_single_post_images_notice',
|
||||
];
|
||||
|
||||
$.each( featuredImageSingleControls, function( index, value ) {
|
||||
$( '#customize-control-' + value ).attr( 'data-control-section', 'featured-image-single' ).css( {
|
||||
visibility: 'hidden',
|
||||
height: '0',
|
||||
width: '0',
|
||||
margin: '0',
|
||||
overflow: 'hidden',
|
||||
} );
|
||||
} );
|
||||
|
||||
var featuredImagePageControls = [
|
||||
'generate_blog_settings-page_post_image',
|
||||
'generate_blog_settings-page_post_image_padding',
|
||||
'generate_blog_settings-page_post_image_position',
|
||||
'generate_blog_settings-page_post_image_alignment',
|
||||
'generate_blog_settings-page_post_image_size',
|
||||
'generate_blog_settings-page_post_image_width',
|
||||
'generate_blog_settings-page_post_image_height',
|
||||
'generate_regenerate_page_images_notice',
|
||||
];
|
||||
|
||||
$.each( featuredImagePageControls, function( index, value ) {
|
||||
$( '#customize-control-' + value ).attr( 'data-control-section', 'featured-image-page' ).css( {
|
||||
visibility: 'hidden',
|
||||
height: '0',
|
||||
width: '0',
|
||||
margin: '0',
|
||||
overflow: 'hidden',
|
||||
} );
|
||||
} );
|
||||
|
||||
// Post meta controls
|
||||
var postMetaArchiveControls = [
|
||||
'generate_settings-post_content',
|
||||
'generate_blog_settings-excerpt_length',
|
||||
'generate_blog_settings-read_more',
|
||||
'generate_blog_settings-read_more_button',
|
||||
'generate_blog_settings-date',
|
||||
'generate_blog_settings-author',
|
||||
'generate_blog_settings-categories',
|
||||
'generate_blog_settings-tags',
|
||||
'generate_blog_settings-comments',
|
||||
'generate_blog_settings-infinite_scroll',
|
||||
'generate_blog_settings-infinite_scroll_button',
|
||||
'blog_masonry_load_more_control',
|
||||
'blog_masonry_loading_control',
|
||||
];
|
||||
|
||||
$.each( postMetaArchiveControls, function( index, value ) {
|
||||
$( '#customize-control-' + value ).attr( 'data-control-section', 'post-meta-archives' );
|
||||
} );
|
||||
|
||||
var postMetaSingleControls = [
|
||||
'generate_blog_settings-single_date',
|
||||
'generate_blog_settings-single_author',
|
||||
'generate_blog_settings-single_categories',
|
||||
'generate_blog_settings-single_tags',
|
||||
'generate_blog_settings-single_post_navigation',
|
||||
];
|
||||
|
||||
$.each( postMetaSingleControls, function( index, value ) {
|
||||
$( '#customize-control-' + value ).attr( 'data-control-section', 'post-meta-single' ).css( {
|
||||
visibility: 'hidden',
|
||||
height: '0',
|
||||
width: '0',
|
||||
margin: '0',
|
||||
overflow: 'hidden',
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
@ -0,0 +1,76 @@
|
||||
/**
|
||||
* Theme Customizer enhancements for a better user experience.
|
||||
*
|
||||
* Contains handlers to make Theme Customizer preview reload changes asynchronously.
|
||||
*/
|
||||
|
||||
( function( $ ) {
|
||||
// Container width
|
||||
wp.customize( 'generate_settings[container_width]', function( value ) {
|
||||
value.bind( function() {
|
||||
if ( $( '.masonry-container' )[ 0 ] ) {
|
||||
jQuery( '.masonry-container' ).imagesLoaded( function() {
|
||||
$container = jQuery( '.masonry-container' );
|
||||
if ( jQuery( $container ).length ) {
|
||||
$container.masonry( {
|
||||
columnWidth: '.grid-sizer',
|
||||
itemSelector: '.masonry-post',
|
||||
stamp: '.page-header',
|
||||
} );
|
||||
}
|
||||
} );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
$( 'body' ).on( 'generate_spacing_updated', function() {
|
||||
if ( $( '.masonry-container' )[ 0 ] ) {
|
||||
jQuery( '.masonry-container' ).imagesLoaded( function() {
|
||||
$container = jQuery( '.masonry-container' );
|
||||
if ( jQuery( $container ).length ) {
|
||||
$container.masonry( {
|
||||
columnWidth: '.grid-sizer',
|
||||
itemSelector: '.masonry-post',
|
||||
stamp: '.page-header',
|
||||
} );
|
||||
}
|
||||
} );
|
||||
}
|
||||
} );
|
||||
|
||||
/**
|
||||
* The first infinite scroll load in the Customizer misses article classes if they've been
|
||||
* added or removed in the previous refresh.
|
||||
*
|
||||
* This is totally hacky, but I'm just happy I finally got it working!
|
||||
*/
|
||||
var $container = $( '.infinite-scroll-item' ).first().parent();
|
||||
$container.on( 'load.infiniteScroll', function( event, response ) {
|
||||
var $posts = $( response ).find( 'article' );
|
||||
if ( wp.customize.value( 'generate_blog_settings[column_layout]' )() ) {
|
||||
$posts.addClass( 'generate-columns' );
|
||||
$posts.addClass( 'grid-parent' );
|
||||
$posts.addClass( 'grid-' + wp.customize.value( 'generate_blog_settings[columns]' )() );
|
||||
$posts.addClass( 'tablet-grid-50' );
|
||||
$posts.addClass( 'mobile-grid-100' );
|
||||
} else {
|
||||
$posts.removeClass( 'generate-columns' );
|
||||
$posts.removeClass( 'grid-parent' );
|
||||
$posts.removeClass( 'grid-' + wp.customize.value( 'generate_blog_settings[columns]' )() );
|
||||
$posts.removeClass( 'tablet-grid-50' );
|
||||
$posts.removeClass( 'mobile-grid-100' );
|
||||
}
|
||||
|
||||
if ( wp.customize.value( 'generate_blog_settings[masonry]' )() ) {
|
||||
$posts.addClass( 'masonry-post' );
|
||||
} else {
|
||||
$posts.removeClass( 'masonry-post' );
|
||||
}
|
||||
|
||||
if ( ! wp.customize.value( 'generate_blog_settings[post_image_padding]' )() ) {
|
||||
$posts.addClass( 'no-featured-image-padding' );
|
||||
} else {
|
||||
$posts.removeClass( 'no-featured-image-padding' );
|
||||
}
|
||||
} );
|
||||
}( jQuery ) );
|
||||
12
wp-content/upgrade-temp-backup/plugins/gp-premium/blog/functions/js/infinite-scroll.pkgd.min.js
vendored
Normal file
12
wp-content/upgrade-temp-backup/plugins/gp-premium/blog/functions/js/infinite-scroll.pkgd.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -0,0 +1,100 @@
|
||||
document.addEventListener( 'DOMContentLoaded', function() {
|
||||
var msnryContainer = document.querySelector( '.masonry-container' );
|
||||
|
||||
if ( msnryContainer ) {
|
||||
// eslint-disable-next-line no-undef -- Masonry is a dependency.
|
||||
var msnry = new Masonry( msnryContainer, generateBlog.masonryInit ),
|
||||
navBelow = document.querySelector( '#nav-below' ),
|
||||
loadMore = document.querySelector( '.load-more' );
|
||||
|
||||
// eslint-disable-next-line no-undef -- imagesLoaded is a dependency.
|
||||
imagesLoaded( msnryContainer, function() {
|
||||
msnry.layout();
|
||||
msnryContainer.classList.remove( 'are-images-unloaded' );
|
||||
|
||||
if ( loadMore ) {
|
||||
loadMore.classList.remove( 'are-images-unloaded' );
|
||||
}
|
||||
|
||||
if ( navBelow ) {
|
||||
navBelow.style.opacity = 1;
|
||||
}
|
||||
} );
|
||||
|
||||
if ( navBelow ) {
|
||||
msnryContainer.parentNode.insertBefore( navBelow, msnryContainer.nextSibling );
|
||||
}
|
||||
|
||||
window.addEventListener( 'orientationchange', function() {
|
||||
msnry.layout();
|
||||
} );
|
||||
}
|
||||
|
||||
var hasInfiniteScroll = document.querySelector( '.infinite-scroll' ),
|
||||
nextLink = document.querySelector( '.infinite-scroll-path a' );
|
||||
|
||||
if ( hasInfiniteScroll && nextLink ) {
|
||||
var infiniteItems = document.querySelectorAll( '.infinite-scroll-item' ),
|
||||
container = infiniteItems[ 0 ].parentNode,
|
||||
button = document.querySelector( '.load-more a' ),
|
||||
svgIcon = '';
|
||||
|
||||
if ( generateBlog.icon ) {
|
||||
svgIcon = generateBlog.icon;
|
||||
}
|
||||
|
||||
var infiniteScrollInit = generateBlog.infiniteScrollInit;
|
||||
|
||||
infiniteScrollInit.outlayer = msnry;
|
||||
|
||||
// eslint-disable-next-line no-undef -- InfiniteScroll is a dependency.
|
||||
var infiniteScroll = new InfiniteScroll( container, infiniteScrollInit );
|
||||
|
||||
if ( button ) {
|
||||
button.addEventListener( 'click', function( e ) {
|
||||
document.activeElement.blur();
|
||||
e.target.innerHTML = svgIcon + generateBlog.loading;
|
||||
e.target.classList.add( 'loading' );
|
||||
} );
|
||||
}
|
||||
|
||||
infiniteScroll.on( 'append', function( response, path, items ) {
|
||||
if ( button && ! document.querySelector( '.generate-columns-container' ) ) {
|
||||
container.appendChild( button.parentNode );
|
||||
}
|
||||
|
||||
items.forEach( function( element ) {
|
||||
var images = element.querySelectorAll( 'img' );
|
||||
|
||||
if ( images ) {
|
||||
images.forEach( function( image ) {
|
||||
var imgOuterHTML = image.outerHTML;
|
||||
image.outerHTML = imgOuterHTML;
|
||||
} );
|
||||
}
|
||||
} );
|
||||
|
||||
if ( msnryContainer && msnry ) {
|
||||
// eslint-disable-next-line no-undef -- ImagesLoaded is a dependency.
|
||||
imagesLoaded( msnryContainer, function() {
|
||||
msnry.layout();
|
||||
} );
|
||||
}
|
||||
|
||||
if ( button ) {
|
||||
button.innerHTML = svgIcon + generateBlog.more;
|
||||
button.classList.remove( 'loading' );
|
||||
}
|
||||
|
||||
document.body.dispatchEvent( new Event( 'post-load' ) );
|
||||
} );
|
||||
|
||||
infiniteScroll.on( 'last', function() {
|
||||
var loadMoreElement = document.querySelector( '.load-more' );
|
||||
|
||||
if ( loadMoreElement ) {
|
||||
loadMoreElement.style.display = 'none';
|
||||
}
|
||||
} );
|
||||
}
|
||||
} );
|
||||
1
wp-content/upgrade-temp-backup/plugins/gp-premium/blog/functions/js/scripts.min.js
vendored
Normal file
1
wp-content/upgrade-temp-backup/plugins/gp-premium/blog/functions/js/scripts.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
document.addEventListener("DOMContentLoaded",function(){var t,e,n,r,a,i,l=document.querySelector(".masonry-container"),o=(l&&(t=new Masonry(l,generateBlog.masonryInit),e=document.querySelector("#nav-below"),n=document.querySelector(".load-more"),imagesLoaded(l,function(){t.layout(),l.classList.remove("are-images-unloaded"),n&&n.classList.remove("are-images-unloaded"),e&&(e.style.opacity=1)}),e&&l.parentNode.insertBefore(e,l.nextSibling),window.addEventListener("orientationchange",function(){t.layout()})),document.querySelector(".infinite-scroll")),c=document.querySelector(".infinite-scroll-path a");o&&c&&(r=document.querySelectorAll(".infinite-scroll-item")[0].parentNode,a=document.querySelector(".load-more a"),i="",generateBlog.icon&&(i=generateBlog.icon),(o=generateBlog.infiniteScrollInit).outlayer=t,c=new InfiniteScroll(r,o),a&&a.addEventListener("click",function(e){document.activeElement.blur(),e.target.innerHTML=i+generateBlog.loading,e.target.classList.add("loading")}),c.on("append",function(e,n,o){a&&!document.querySelector(".generate-columns-container")&&r.appendChild(a.parentNode),o.forEach(function(e){e=e.querySelectorAll("img");e&&e.forEach(function(e){var n=e.outerHTML;e.outerHTML=n})}),l&&t&&imagesLoaded(l,function(){t.layout()}),a&&(a.innerHTML=i+generateBlog.more,a.classList.remove("loading")),document.body.dispatchEvent(new Event("post-load"))}),c.on("last",function(){var e=document.querySelector(".load-more");e&&(e.style.display="none")}))});
|
||||
@ -0,0 +1,122 @@
|
||||
<?php
|
||||
defined( 'WPINC' ) or die;
|
||||
|
||||
add_action( 'admin_init', 'generate_blog_update_visibility_settings' );
|
||||
/**
|
||||
* Migrates our old Blog settings so we can use checkboxes instead.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
function generate_blog_update_visibility_settings() {
|
||||
// Get our migration settings
|
||||
$settings = get_option( 'generate_migration_settings', array() );
|
||||
|
||||
// If we've already ran this function, bail
|
||||
if ( isset( $settings[ 'blog_visibility_updated' ] ) && 'true' == $settings[ 'blog_visibility_updated' ] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// A lot of the defaults changed, so lets put the old defaults here
|
||||
$defaults = array(
|
||||
'masonry' => 'false',
|
||||
'masonry_width' => 'width2',
|
||||
'masonry_most_recent_width' => 'width4',
|
||||
'post_image' => 'true',
|
||||
'date' => 'true',
|
||||
'author' => 'true',
|
||||
'categories' => 'true',
|
||||
'tags' => 'true',
|
||||
'comments' => 'true',
|
||||
);
|
||||
|
||||
// Get our spacing settings
|
||||
$blog_settings = wp_parse_args(
|
||||
get_option( 'generate_blog_settings', array() ),
|
||||
$defaults
|
||||
);
|
||||
|
||||
$new_settings = array();
|
||||
|
||||
// These options use to be a select input with false + true values
|
||||
// This will make the false values empty so the options can be checkboxes
|
||||
$keys = array( 'date', 'author', 'categories', 'tags', 'comments', 'masonry', 'post_image' );
|
||||
foreach ( $keys as $key ) {
|
||||
if ( is_string( $blog_settings[ $key ] ) ) {
|
||||
if ( 'false' == $blog_settings[ $key ] ) {
|
||||
$new_settings[ $key ] = false;
|
||||
} elseif ( 'true' == $blog_settings[ $key ] ) {
|
||||
$new_settings[ $key ] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set the single post meta options to whatever the blog options are
|
||||
$new_settings[ 'single_date' ] = isset( $new_settings[ 'date' ] ) ? $new_settings[ 'date' ] : true;
|
||||
$new_settings[ 'single_author' ] = isset( $new_settings[ 'author' ] ) ? $new_settings[ 'author' ] : true;
|
||||
$new_settings[ 'single_categories' ] = isset( $new_settings[ 'categories' ] ) ? $new_settings[ 'categories' ] : true;
|
||||
$new_settings[ 'single_tags' ] = isset( $new_settings[ 'tags' ] ) ? $new_settings[ 'tags' ] : true;
|
||||
|
||||
if ( isset( $new_settings[ 'masonry' ] ) && $new_settings[ 'masonry' ] ) {
|
||||
$new_settings[ 'column_layout' ] = true;
|
||||
$new_settings[ 'infinite_scroll' ] = true;
|
||||
$new_settings[ 'infinite_scroll_button' ] = true;
|
||||
|
||||
if ( 'width2' == $blog_settings['masonry_width'] ) {
|
||||
$new_settings[ 'columns' ] = '33';
|
||||
}
|
||||
|
||||
if ( 'width4' == $blog_settings['masonry_width'] ) {
|
||||
$new_settings[ 'columns' ] = '50';
|
||||
}
|
||||
|
||||
if ( 'width6' == $blog_settings['masonry_width'] ) {
|
||||
$new_settings[ 'columns' ] = '100';
|
||||
}
|
||||
|
||||
if ( 'width2' == $blog_settings[ 'masonry_width' ] ) {
|
||||
if ( 'width2' !== $blog_settings[ 'masonry_most_recent_width' ] ) {
|
||||
$new_settings[ 'featured_column' ] = true;
|
||||
} else {
|
||||
$new_settings[ 'featured_column' ] = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'width4' == $blog_settings[ 'masonry_width' ] ) {
|
||||
if ( 'width6' == $blog_settings[ 'masonry_most_recent_width' ] ) {
|
||||
$new_settings[ 'featured_column' ] = true;
|
||||
} else {
|
||||
$new_settings[ 'featured_column' ] = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'width6' == $blog_settings[ 'masonry_width' ] ) {
|
||||
$new_settings[ 'featured_column' ] = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( function_exists( 'generate_page_header_get_defaults' ) ) {
|
||||
$page_header_settings = wp_parse_args(
|
||||
get_option( 'generate_page_header_settings', array() ),
|
||||
generate_page_header_get_defaults()
|
||||
);
|
||||
|
||||
if ( 'hide' == $page_header_settings[ 'post_header_position' ] ) {
|
||||
$new_settings[ 'single_post_image' ] = false;
|
||||
} else {
|
||||
$new_settings[ 'single_post_image_position' ] = $page_header_settings[ 'post_header_position' ];
|
||||
}
|
||||
|
||||
$new_settings[ 'page_post_image_position' ] = $page_header_settings[ 'page_header_position' ];
|
||||
}
|
||||
|
||||
unset( $blog_settings['masonry_width'] );
|
||||
unset( $blog_settings['masonry_most_recent_width'] );
|
||||
|
||||
$update_settings = wp_parse_args( $new_settings, $blog_settings );
|
||||
update_option( 'generate_blog_settings', $update_settings );
|
||||
|
||||
// Update our migration option so we don't need to run this again
|
||||
$updated[ 'blog_visibility_updated' ] = 'true';
|
||||
$migration_settings = wp_parse_args( $updated, $settings );
|
||||
update_option( 'generate_migration_settings', $migration_settings );
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* Blog module.
|
||||
*
|
||||
* @since 1.1.0
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
// Define the version. This used to be a standalone plugin, so we need to keep this constant.
|
||||
if ( ! defined( 'GENERATE_BLOG_VERSION' ) ) {
|
||||
define( 'GENERATE_BLOG_VERSION', GP_PREMIUM_VERSION );
|
||||
}
|
||||
|
||||
// Include functions identical between standalone addon and GP Premium.
|
||||
require plugin_dir_path( __FILE__ ) . 'functions/generate-blog.php';
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,620 @@
|
||||
/**
|
||||
* Theme Customizer enhancements for a better user experience.
|
||||
*
|
||||
* Contains handlers to make Theme Customizer preview reload changes asynchronously.
|
||||
*/
|
||||
function generate_colors_live_update( id, selector, property, default_value, get_value, settings ) {
|
||||
default_value = typeof default_value !== 'undefined' ? default_value : 'initial';
|
||||
get_value = typeof get_value !== 'undefined' ? get_value : '';
|
||||
settings = typeof settings !== 'undefined' ? settings : 'generate_settings';
|
||||
wp.customize( settings + '[' + id + ']', function( value ) {
|
||||
value.bind( function( newval ) {
|
||||
|
||||
// Stop the header link color from applying to the site title.
|
||||
if ( 'header_link_color' === id || 'header_link_color' === id ) {
|
||||
jQuery( '.site-header a' ).addClass( 'header-link' );
|
||||
jQuery( '.site-header .main-title a' ).removeClass( 'header-link' );
|
||||
}
|
||||
|
||||
if ( 'content_link_color' === id || 'content_link_color_hover' === id || 'entry_meta_link_color' === id || 'blog_post_title_color' === id ) {
|
||||
var content_link = jQuery( '.inside-article a' );
|
||||
var meta = jQuery( '.entry-meta a' );
|
||||
var title = jQuery( '.entry-title a' );
|
||||
|
||||
content_link.attr( 'data-content-link-color', true );
|
||||
|
||||
if ( '' !== wp.customize.value('generate_settings[entry_meta_link_color]')() ) {
|
||||
meta.attr( 'data-content-link-color', '' );
|
||||
} else {
|
||||
meta.attr( 'data-content-link-color', true );
|
||||
}
|
||||
|
||||
if ( '' !== wp.customize.value('generate_settings[blog_post_title_color]')() ) {
|
||||
title.attr( 'data-content-link-color', '' );
|
||||
} else {
|
||||
title.attr( 'data-content-link-color', true );
|
||||
}
|
||||
}
|
||||
|
||||
default_value = ( '' !== get_value ) ? wp.customize.value('generate_settings[' + get_value + ']')() : default_value;
|
||||
newval = ( '' !== newval ) ? newval : default_value;
|
||||
var unique_id = ( 'generate_secondary_nav_settings' == settings ) ? 'secondary_' : '';
|
||||
if ( jQuery( 'style#' + unique_id + id ).length ) {
|
||||
jQuery( 'style#' + unique_id + id ).html( selector + '{' + property + ':' + newval + ';}' );
|
||||
} else {
|
||||
jQuery( 'head' ).append( '<style id="' + unique_id + id + '">' + selector + '{' + property + ':' + newval + '}</style>' );
|
||||
setTimeout(function() {
|
||||
jQuery( 'style#' + id ).not( ':last' ).remove();
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
} );
|
||||
} );
|
||||
}
|
||||
|
||||
/**
|
||||
* Header background color
|
||||
* Empty: transparent
|
||||
*/
|
||||
generate_colors_live_update( 'top_bar_background_color', '.top-bar', 'background-color', 'transparent' );
|
||||
|
||||
/**
|
||||
* Header text color
|
||||
* Empty: text_color
|
||||
*/
|
||||
generate_colors_live_update( 'top_bar_text_color', '.top-bar', 'color', '', 'text_color' );
|
||||
|
||||
/**
|
||||
* Header link color
|
||||
* Empty: link_color
|
||||
*/
|
||||
generate_colors_live_update( 'top_bar_link_color', '.top-bar a, .top-bar a:visited', 'color', '', 'link_color' );
|
||||
|
||||
/**
|
||||
* Header link color hover
|
||||
* Empty: link_color_hover
|
||||
*/
|
||||
generate_colors_live_update( 'top_bar_link_color_hover', '.top-bar a:hover', 'color', '', 'link_color_hover' );
|
||||
|
||||
|
||||
/**
|
||||
* Header background color
|
||||
* Empty: transparent
|
||||
*/
|
||||
generate_colors_live_update( 'header_background_color', '.site-header', 'background-color', 'transparent' );
|
||||
|
||||
/**
|
||||
* Header text color
|
||||
* Empty: text_color
|
||||
*/
|
||||
generate_colors_live_update( 'header_text_color', '.site-header', 'color', '', 'text_color' );
|
||||
|
||||
/**
|
||||
* Header link color
|
||||
* Empty: link_color
|
||||
*/
|
||||
generate_colors_live_update( 'header_link_color', '.site-header a.header-link, .site-header a.header-link:visited', 'color', '', 'link_color' );
|
||||
|
||||
/**
|
||||
* Header link color hover
|
||||
* Empty: link_color_hover
|
||||
*/
|
||||
generate_colors_live_update( 'header_link_hover_color', '.site-header a.header-link:hover', 'color', '', 'link_color_hover' );
|
||||
|
||||
/**
|
||||
* Site title color
|
||||
* Empty: link_color
|
||||
*/
|
||||
generate_colors_live_update( 'site_title_color', '.main-title a,.main-title a:hover,.main-title a:visited,.header-wrap .navigation-stick .main-title a, .header-wrap .navigation-stick .main-title a:hover, .header-wrap .navigation-stick .main-title a:visited', 'color', '', 'link_color' );
|
||||
|
||||
/**
|
||||
* Site tagline color
|
||||
* Empty: text_color
|
||||
*/
|
||||
generate_colors_live_update( 'site_tagline_color', '.site-description', 'color', '', 'text_color' );
|
||||
|
||||
/**
|
||||
* Main navigation background
|
||||
* Empty: transparent
|
||||
*/
|
||||
generate_colors_live_update( 'navigation_background_color', '.main-navigation', 'background-color', 'transparent' );
|
||||
|
||||
/**
|
||||
* Primary navigation text color
|
||||
* Empty: link_color
|
||||
*/
|
||||
generate_colors_live_update( 'navigation_text_color',
|
||||
'.main-navigation .main-nav ul li a,\
|
||||
.menu-toggle,button.menu-toggle:hover,\
|
||||
button.menu-toggle:focus,\
|
||||
.main-navigation .mobile-bar-items a,\
|
||||
.main-navigation .mobile-bar-items a:hover,\
|
||||
.main-navigation .mobile-bar-items a:focus,\
|
||||
.main-navigation .menu-bar-items',
|
||||
'color', '', 'link_color'
|
||||
);
|
||||
|
||||
/**
|
||||
* Primary navigation text color hover
|
||||
* Empty: link_color_hover
|
||||
*/
|
||||
generate_colors_live_update( 'navigation_text_hover_color',
|
||||
'.navigation-search input[type="search"],\
|
||||
.navigation-search input[type="search"]:active,\
|
||||
.navigation-search input[type="search"]:focus,\
|
||||
.main-navigation .main-nav ul li:hover > a,\
|
||||
.main-navigation .main-nav ul li:focus > a,\
|
||||
.main-navigation .main-nav ul li.sfHover > a,\
|
||||
.main-navigation .menu-bar-item:hover a',
|
||||
'color', '', 'link_color_hover'
|
||||
);
|
||||
|
||||
/**
|
||||
* Primary navigation menu item hover
|
||||
* Empty: link_color_hover
|
||||
*/
|
||||
generate_colors_live_update( 'navigation_background_hover_color',
|
||||
'.navigation-search input[type="search"],\
|
||||
.navigation-search input[type="search"]:focus,\
|
||||
.main-navigation .main-nav ul li:hover > a,\
|
||||
.main-navigation .main-nav ul li:focus > a,\
|
||||
.main-navigation .main-nav ul li.sfHover > a,\
|
||||
.main-navigation .menu-bar-item:hover a',
|
||||
'background-color', 'transparent'
|
||||
);
|
||||
|
||||
/**
|
||||
* Primary sub-navigation color
|
||||
* Empty: transparent
|
||||
*/
|
||||
generate_colors_live_update( 'subnavigation_background_color', '.main-navigation ul ul', 'background-color', 'transparent' );
|
||||
|
||||
/**
|
||||
* Primary sub-navigation text color
|
||||
* Empty: link_color
|
||||
*/
|
||||
generate_colors_live_update( 'subnavigation_text_color', '.main-navigation .main-nav ul ul li a', 'color', 'link_color' );
|
||||
|
||||
/**
|
||||
* Primary sub-navigation hover
|
||||
*/
|
||||
var subnavigation_hover = '.main-navigation .main-nav ul ul li:hover > a, \
|
||||
.main-navigation .main-nav ul ul li:focus > a, \
|
||||
.main-navigation .main-nav ul ul li.sfHover > a';
|
||||
|
||||
/**
|
||||
* Primary sub-navigation text hover
|
||||
* Empty: link_color_hover
|
||||
*/
|
||||
generate_colors_live_update( 'subnavigation_text_hover_color', subnavigation_hover, 'color', '', 'link_color_hover' );
|
||||
|
||||
/**
|
||||
* Primary sub-navigation background hover
|
||||
* Empty: transparent
|
||||
*/
|
||||
generate_colors_live_update( 'subnavigation_background_hover_color', subnavigation_hover, 'background-color', 'transparent' );
|
||||
|
||||
/**
|
||||
* Navigation current selectors
|
||||
*/
|
||||
var navigation_current = '.main-navigation .main-nav ul li[class*="current-menu-"] > a, \
|
||||
.main-navigation .main-nav ul li[class*="current-menu-"]:hover > a, \
|
||||
.main-navigation .main-nav ul li[class*="current-menu-"].sfHover > a';
|
||||
|
||||
/**
|
||||
* Primary navigation current text
|
||||
* Empty: link_color
|
||||
*/
|
||||
generate_colors_live_update( 'navigation_text_current_color', navigation_current, 'color', '', 'link_color' );
|
||||
|
||||
/**
|
||||
* Primary navigation current text
|
||||
* Empty: transparent
|
||||
*/
|
||||
generate_colors_live_update( 'navigation_background_current_color', navigation_current, 'background-color', 'transparent' );
|
||||
|
||||
/**
|
||||
* Primary sub-navigation current selectors
|
||||
*/
|
||||
var subnavigation_current = '.main-navigation .main-nav ul ul li[class*="current-menu-"] > a,\
|
||||
.main-navigation .main-nav ul ul li[class*="current-menu-"]:hover > a, \
|
||||
.main-navigation .main-nav ul ul li[class*="current-menu-"].sfHover > a';
|
||||
|
||||
/**
|
||||
* Primary sub-navigation current text
|
||||
* Empty: link_color
|
||||
*/
|
||||
generate_colors_live_update( 'subnavigation_text_current_color', subnavigation_current, 'color', '', 'link_color' );
|
||||
|
||||
/**
|
||||
* Primary navigation current item background
|
||||
* Empty: transparent
|
||||
*/
|
||||
generate_colors_live_update( 'subnavigation_background_current_color', subnavigation_current, 'background-color', 'transparent' );
|
||||
|
||||
/**
|
||||
* Secondary navigation background
|
||||
* Empty: transparent
|
||||
*/
|
||||
generate_colors_live_update( 'navigation_background_color', '.secondary-navigation', 'background-color', 'transparent', '', 'generate_secondary_nav_settings' );
|
||||
|
||||
/**
|
||||
* Secondary navigation text color
|
||||
* Empty: link_color
|
||||
*/
|
||||
generate_colors_live_update( 'navigation_text_color',
|
||||
'.secondary-navigation .main-nav ul li a,\
|
||||
.secondary-navigation .menu-toggle,\
|
||||
button.secondary-menu-toggle:hover,\
|
||||
button.secondary-menu-toggle:focus, \
|
||||
.secondary-navigation .top-bar, \
|
||||
.secondary-navigation .top-bar a,\
|
||||
.secondary-menu-bar-items,\
|
||||
.secondary-menu-bar-items .menu-bar-item > a',
|
||||
'color', '', 'link_color', 'generate_secondary_nav_settings'
|
||||
);
|
||||
|
||||
/**
|
||||
* Navigation search
|
||||
*/
|
||||
wp.customize( 'generate_settings[navigation_search_background_color]', function( value ) {
|
||||
value.bind( function( newval ) {
|
||||
if ( jQuery( 'style#navigation_search_background_color' ).length ) {
|
||||
jQuery( 'style#navigation_search_background_color' ).html( '.navigation-search input[type="search"],.navigation-search input[type="search"]:active, .navigation-search input[type="search"]:focus, .main-navigation .main-nav ul li.search-item.active > a, .main-navigation .menu-bar-items .search-item.active > a{background-color:' + newval + ';}' );
|
||||
} else {
|
||||
jQuery( 'head' ).append( '<style id="navigation_search_background_color">.navigation-search input[type="search"],.navigation-search input[type="search"]:active, .navigation-search input[type="search"]:focus, .main-navigation .main-nav ul li.search-item.active > a, .main-navigation .menu-bar-items .search-item.active > a{background-color:' + newval + ';}</style>' );
|
||||
setTimeout(function() {
|
||||
jQuery( 'style#navigation_search_background_color' ).not( ':last' ).remove();
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
if ( jQuery( 'style#navigation_search_background_opacity' ).length ) {
|
||||
if ( newval ) {
|
||||
jQuery( 'style#navigation_search_background_opacity' ).html( '.navigation-search input{opacity: 1;}' );
|
||||
} else {
|
||||
jQuery( 'style#navigation_search_background_opacity' ).html( '.navigation-search input{opacity: 0.9;}' );
|
||||
}
|
||||
} else {
|
||||
if ( newval ) {
|
||||
jQuery( 'head' ).append( '<style id="navigation_search_background_opacity">.navigation-search input{opacity: 1;}</style>' );
|
||||
}
|
||||
|
||||
setTimeout(function() {
|
||||
jQuery( 'style#navigation_search_background_opacity' ).not( ':last' ).remove();
|
||||
}, 1000);
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
generate_colors_live_update( 'navigation_search_text_color', '.navigation-search input[type="search"],.navigation-search input[type="search"]:active, .navigation-search input[type="search"]:focus, .main-navigation .main-nav ul li.search-item.active > a, .main-navigation .menu-bar-items .search-item.active > a', 'color', '' );
|
||||
|
||||
/**
|
||||
* Secondary navigation text color hover
|
||||
* Empty: link_color_hover
|
||||
*/
|
||||
generate_colors_live_update( 'navigation_text_hover_color',
|
||||
'.secondary-navigation .main-nav ul li:hover > a, \
|
||||
.secondary-navigation .main-nav ul li:focus > a, \
|
||||
.secondary-navigation .main-nav ul li.sfHover > a,\
|
||||
.secondary-menu-bar-items .menu-bar-item:hover > a',
|
||||
'color', '', 'link_color_hover', 'generate_secondary_nav_settings'
|
||||
);
|
||||
|
||||
/**
|
||||
* Secondary navigation menu item hover
|
||||
* Empty: link_color_hover
|
||||
*/
|
||||
generate_colors_live_update( 'navigation_background_hover_color',
|
||||
'.secondary-navigation .main-nav ul li:hover > a, \
|
||||
.secondary-navigation .main-nav ul li:focus > a, \
|
||||
.secondary-navigation .main-nav ul li.sfHover > a, \
|
||||
.secondary-menu-bar-items .menu-bar-item:hover > a',
|
||||
'background-color', 'transparent', '', 'generate_secondary_nav_settings'
|
||||
);
|
||||
|
||||
/**
|
||||
* Secondary navigation top bar link hover
|
||||
*/
|
||||
wp.customize( 'generate_secondary_nav_settings[navigation_background_hover_color]', function( value ) {
|
||||
value.bind( function( newval ) {
|
||||
if ( jQuery( 'style#secondary_nav_top_bar_hover' ).length ) {
|
||||
jQuery( 'style#secondary_nav_top_bar_hover' ).html( '.secondary-navigation .top-bar a:hover,.secondary-navigation .top-bar a:focus{color:' + newval + ';}' );
|
||||
} else {
|
||||
jQuery( 'head' ).append( '<style id="secondary_nav_top_bar_hover">.secondary-navigation .top-bar a:hover,.secondary-navigation .top-bar a:focus{color:' + newval + ';}</style>' );
|
||||
setTimeout(function() {
|
||||
jQuery( 'style#secondary_nav_top_bar_hover' ).not( ':last' ).remove();
|
||||
}, 1000);
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
generate_colors_live_update( 'navigation_top_bar_hover_color',
|
||||
'.secondary-navigation .top-bar a:hover, \
|
||||
.secondary-navigation .top-bar a:focus',
|
||||
'color', 'transparent', '', 'generate_secondary_nav_settings'
|
||||
);
|
||||
|
||||
/**
|
||||
* Secondary sub-navigation color
|
||||
* Empty: transparent
|
||||
*/
|
||||
generate_colors_live_update( 'subnavigation_background_color', '.secondary-navigation ul ul', 'background-color', 'transparent', '', 'generate_secondary_nav_settings' );
|
||||
|
||||
/**
|
||||
* Secondary sub-navigation text color
|
||||
* Empty: link_color
|
||||
*/
|
||||
generate_colors_live_update( 'subnavigation_text_color', '.secondary-navigation .main-nav ul ul li a', 'color', '', 'link_color', 'generate_secondary_nav_settings' );
|
||||
|
||||
/**
|
||||
* Secondary sub-navigation hover
|
||||
*/
|
||||
var secondary_subnavigation_hover = '.secondary-navigation .main-nav ul ul li > a:hover, \
|
||||
.secondary-navigation .main-nav ul ul li:focus > a, \
|
||||
.secondary-navigation .main-nav ul ul li.sfHover > a';
|
||||
|
||||
/**
|
||||
* Secondary sub-navigation text hover
|
||||
* Empty: link_color_hover
|
||||
*/
|
||||
generate_colors_live_update( 'subnavigation_text_hover_color', secondary_subnavigation_hover, 'color', '', 'link_color_hover', 'generate_secondary_nav_settings' );
|
||||
|
||||
/**
|
||||
* Secondary sub-navigation background hover
|
||||
* Empty: transparent
|
||||
*/
|
||||
generate_colors_live_update( 'subnavigation_background_hover_color', secondary_subnavigation_hover, 'background-color', 'transparent', '', 'generate_secondary_nav_settings' );
|
||||
|
||||
/**
|
||||
* Secondary navigation current selectors
|
||||
*/
|
||||
var secondary_navigation_current = '.secondary-navigation .main-nav ul li[class*="current-menu-"] > a, \
|
||||
.secondary-navigation .main-nav ul li[class*="current-menu-"]:hover > a, \
|
||||
.secondary-navigation .main-nav ul li[class*="current-menu-"].sfHover > a';
|
||||
|
||||
/**
|
||||
* Secondary navigation current text
|
||||
* Empty: link_color
|
||||
*/
|
||||
generate_colors_live_update( 'navigation_text_current_color', secondary_navigation_current, 'color', '', 'link_color', 'generate_secondary_nav_settings' );
|
||||
|
||||
/**
|
||||
* Secondary navigation current text
|
||||
* Empty: transparent
|
||||
*/
|
||||
generate_colors_live_update( 'navigation_background_current_color', secondary_navigation_current, 'background-color', 'transparent', '', 'generate_secondary_nav_settings' );
|
||||
|
||||
/**
|
||||
* Secondary sub-navigation current selectors
|
||||
*/
|
||||
var secondary_subnavigation_current = '.secondary-navigation .main-nav ul ul li[class*="current-menu-"] > a,\
|
||||
.secondary-navigation .main-nav ul ul li[class*="current-menu-"]:hover > a, \
|
||||
.secondary-navigation .main-nav ul ul li[class*="current-menu-"].sfHover > a';
|
||||
|
||||
/**
|
||||
* Secondary sub-navigation current text
|
||||
* Empty: link_color
|
||||
*/
|
||||
generate_colors_live_update( 'subnavigation_text_current_color', secondary_subnavigation_current, 'color', '', 'link_color', 'generate_secondary_nav_settings' );
|
||||
|
||||
/**
|
||||
* Primary navigation current item background
|
||||
* Empty: transparent
|
||||
*/
|
||||
generate_colors_live_update( 'subnavigation_background_current_color', secondary_subnavigation_current, 'background-color', 'transparent', '', 'generate_secondary_nav_settings' );
|
||||
|
||||
/**
|
||||
* Content selectors
|
||||
*/
|
||||
var content = '.separate-containers .inside-article,\
|
||||
.separate-containers .comments-area,\
|
||||
.separate-containers .page-header,\
|
||||
.one-container .container,\
|
||||
.separate-containers .paging-navigation,\
|
||||
.inside-page-header';
|
||||
|
||||
/**
|
||||
* Content background
|
||||
* Empty: transparent
|
||||
*/
|
||||
generate_colors_live_update( 'content_background_color', content, 'background-color', 'transparent' );
|
||||
|
||||
/**
|
||||
* Content text color
|
||||
* Empty: text_color
|
||||
*/
|
||||
generate_colors_live_update( 'content_text_color', content, 'color', '', 'text_color' );
|
||||
|
||||
/**
|
||||
* Content links
|
||||
* Empty: link_color
|
||||
*/
|
||||
generate_colors_live_update( 'content_link_color',
|
||||
'.inside-article a:not(.button):not(.wp-block-button__link)[data-content-link-color=true], \
|
||||
.inside-article a:not(.button):not(.wp-block-button__link)[data-content-link-color=true]:visited,\
|
||||
.paging-navigation a,\
|
||||
.paging-navigation a:visited,\
|
||||
.comments-area a,\
|
||||
.comments-area a:visited,\
|
||||
.page-header a,\
|
||||
.page-header a:visited',
|
||||
'color', '', 'link_color'
|
||||
);
|
||||
|
||||
/**
|
||||
* Content links on hover
|
||||
* Empty: link_color_hover
|
||||
*/
|
||||
generate_colors_live_update( 'content_link_hover_color',
|
||||
'.inside-article a:not(.button):not(.wp-block-button__link)[data-content-link-color=true]:hover,\
|
||||
.paging-navigation a:hover,\
|
||||
.comments-area a:hover,\
|
||||
.page-header a:hover',
|
||||
'color', '', 'link_color_hover'
|
||||
);
|
||||
|
||||
generate_colors_live_update( 'content_title_color', '.entry-header h1,.page-header h1', 'color', 'inherit', 'text_color' );
|
||||
generate_colors_live_update( 'blog_post_title_color', '.entry-title a,.entry-title a:visited', 'color', '', 'link_color' );
|
||||
generate_colors_live_update( 'blog_post_title_hover_color', '.entry-title a:hover', 'color', '', 'link_color_hover' );
|
||||
generate_colors_live_update( 'entry_meta_text_color', '.entry-meta', 'color', '', 'text_color' );
|
||||
generate_colors_live_update( 'entry_meta_link_color', '.entry-meta a, .entry-meta a:visited', 'color', '', 'link_color' );
|
||||
generate_colors_live_update( 'entry_meta_link_color_hover', '.entry-meta a:hover', 'color', '', 'link_color_hover' );
|
||||
generate_colors_live_update( 'h1_color', 'h1', 'color', '', 'text_color' );
|
||||
generate_colors_live_update( 'h2_color', 'h2', 'color', '', 'text_color' );
|
||||
generate_colors_live_update( 'h3_color', 'h3', 'color', '', 'text_color' );
|
||||
generate_colors_live_update( 'h4_color', 'h4', 'color', '', 'text_color' );
|
||||
generate_colors_live_update( 'h5_color', 'h5', 'color', '', 'text_color' );
|
||||
generate_colors_live_update( 'sidebar_widget_background_color', '.sidebar .widget', 'background-color', 'transparent' );
|
||||
generate_colors_live_update( 'sidebar_widget_text_color', '.sidebar .widget', 'color', '', 'text_color' );
|
||||
generate_colors_live_update( 'sidebar_widget_link_color', '.sidebar .widget a, .sidebar .widget a:visited', 'color', '', 'link_color' );
|
||||
generate_colors_live_update( 'sidebar_widget_link_hover_color', '.sidebar .widget a:hover', 'color', '', 'link_color_hover' );
|
||||
generate_colors_live_update( 'sidebar_widget_title_color', '.sidebar .widget .widget-title', 'color', '', 'text_color' );
|
||||
generate_colors_live_update( 'footer_widget_background_color', '.footer-widgets', 'background-color', 'transparent' );
|
||||
generate_colors_live_update( 'footer_widget_text_color', '.footer-widgets', 'color', '', 'text_color' );
|
||||
generate_colors_live_update( 'footer_widget_link_color', '.footer-widgets a, .footer-widgets a:visited', 'color', '', 'link_color' );
|
||||
generate_colors_live_update( 'footer_widget_link_hover_color', '.footer-widgets a:hover', 'color', '', 'link_color_hover' );
|
||||
generate_colors_live_update( 'footer_widget_title_color', '.footer-widgets .widget-title', 'color', '', 'text_color' );
|
||||
generate_colors_live_update( 'footer_background_color', '.site-info', 'background-color', 'transparent' );
|
||||
generate_colors_live_update( 'footer_text_color', '.site-info', 'color', '', 'text_color' );
|
||||
generate_colors_live_update( 'footer_link_color', '.site-info a, .site-info a:visited', 'color', '', 'link_color' );
|
||||
generate_colors_live_update( 'footer_link_hover_color', '.site-info a:hover', 'color', '', 'link_color_hover' );
|
||||
|
||||
/**
|
||||
* Form selectors
|
||||
*/
|
||||
var forms = 'input[type="text"], \
|
||||
input[type="email"], \
|
||||
input[type="url"], \
|
||||
input[type="password"], \
|
||||
input[type="search"], \
|
||||
input[type="number"], \
|
||||
input[type="tel"], \
|
||||
textarea, \
|
||||
select';
|
||||
|
||||
/**
|
||||
* Form background
|
||||
* Empty: inherit
|
||||
*/
|
||||
generate_colors_live_update( 'form_background_color', forms, 'background-color', 'inherit' );
|
||||
|
||||
/**
|
||||
* Border color
|
||||
* Empty: inherit
|
||||
*/
|
||||
generate_colors_live_update( 'form_border_color', forms, 'border-color' );
|
||||
|
||||
/**
|
||||
* Form text color
|
||||
* Empty: text_color
|
||||
*/
|
||||
generate_colors_live_update( 'form_text_color', forms, 'color', '', 'text_color' );
|
||||
|
||||
/**
|
||||
* Form background on focus selectors
|
||||
* Empty: inherit
|
||||
*/
|
||||
var forms_focus = 'input[type="text"]:focus, \
|
||||
input[type="email"]:focus, \
|
||||
input[type="url"]:focus, \
|
||||
input[type="password"]:focus, \
|
||||
input[type="search"]:focus,\
|
||||
input[type="number"]:focus,\
|
||||
input[type="tel"]:focus, \
|
||||
textarea:focus, \
|
||||
select:focus';
|
||||
|
||||
/**
|
||||
* Form background color on focus
|
||||
* Empty: initial
|
||||
*/
|
||||
generate_colors_live_update( 'form_background_color_focus', forms_focus, 'background-color' );
|
||||
|
||||
/**
|
||||
* Form text color on focus
|
||||
* Empty: initial
|
||||
*/
|
||||
generate_colors_live_update( 'form_text_color_focus', forms_focus, 'color' );
|
||||
|
||||
/**
|
||||
* Form border color on focus
|
||||
* Empty: initial
|
||||
*/
|
||||
generate_colors_live_update( 'form_border_color_focus', forms_focus, 'border-color' );
|
||||
|
||||
/**
|
||||
* Button selectors
|
||||
*/
|
||||
var button = 'button, \
|
||||
html input[type="button"], \
|
||||
input[type="reset"], \
|
||||
input[type="submit"],\
|
||||
a.button,\
|
||||
a.button:visited,\
|
||||
a.wp-block-button__link:not(.has-background)';
|
||||
|
||||
/**
|
||||
* Button background
|
||||
* Empty: initial
|
||||
*/
|
||||
generate_colors_live_update( 'form_button_background_color', button, 'background-color' );
|
||||
|
||||
/**
|
||||
* Button text
|
||||
* Empty: initial
|
||||
*/
|
||||
generate_colors_live_update( 'form_button_text_color', button, 'color' );
|
||||
|
||||
/**
|
||||
* Button on hover/focus selectors
|
||||
* Empty: initial
|
||||
*/
|
||||
var button_hover = 'button:hover, \
|
||||
html input[type="button"]:hover, \
|
||||
input[type="reset"]:hover, \
|
||||
input[type="submit"]:hover,\
|
||||
a.button:hover,\
|
||||
button:focus, \
|
||||
html input[type="button"]:focus, \
|
||||
input[type="reset"]:focus, \
|
||||
input[type="submit"]:focus,\
|
||||
a.button:focus,\
|
||||
a.wp-block-button__link:not(.has-background):active,\
|
||||
a.wp-block-button__link:not(.has-background):focus,\
|
||||
a.wp-block-button__link:not(.has-background):hover';
|
||||
|
||||
/**
|
||||
* Button color on hover
|
||||
* Empty: initial
|
||||
*/
|
||||
generate_colors_live_update( 'form_button_background_color_hover', button_hover, 'background-color' );
|
||||
|
||||
/**
|
||||
* Button text color on hover
|
||||
* Empty: initial
|
||||
*/
|
||||
generate_colors_live_update( 'form_button_text_color_hover', button_hover, 'color' );
|
||||
|
||||
/**
|
||||
* Back to top background color
|
||||
* Empty: transparent
|
||||
*/
|
||||
generate_colors_live_update( 'back_to_top_background_color', 'a.generate-back-to-top', 'background-color', 'transparent' );
|
||||
|
||||
/**
|
||||
* Back to top text color
|
||||
* Empty: text_color
|
||||
*/
|
||||
generate_colors_live_update( 'back_to_top_text_color', 'a.generate-back-to-top', 'color', '', 'text_color' );
|
||||
|
||||
/**
|
||||
* Back to top background color hover
|
||||
* Empty: transparent
|
||||
*/
|
||||
generate_colors_live_update( 'back_to_top_background_color_hover', 'a.generate-back-to-top:hover,a.generate-back-to-top:focus', 'background-color', 'transparent' );
|
||||
|
||||
/**
|
||||
* Back to top text color hover
|
||||
* Empty: text_color
|
||||
*/
|
||||
generate_colors_live_update( 'back_to_top_text_color_hover', 'a.generate-back-to-top:hover,a.generate-back-to-top:focus', 'color', '', 'text_color' );
|
||||
@ -0,0 +1,102 @@
|
||||
/**
|
||||
* Main navigation background
|
||||
* Empty: transparent
|
||||
*/
|
||||
generate_colors_live_update( 'slideout_background_color', '.main-navigation.slideout-navigation', 'background-color', '' );
|
||||
|
||||
/**
|
||||
* Primary navigation text color
|
||||
* Empty: link_color
|
||||
*/
|
||||
generate_colors_live_update( 'slideout_text_color', '.slideout-navigation.main-navigation .main-nav ul li a, .slideout-navigation a, .slideout-navigation', 'color', '' );
|
||||
|
||||
/**
|
||||
* Primary navigation text color hover
|
||||
* Empty: link_color_hover
|
||||
*/
|
||||
generate_colors_live_update( 'slideout_text_hover_color',
|
||||
'.slideout-navigation.main-navigation .main-nav ul li:hover > a,\
|
||||
.slideout-navigation.main-navigation .main-nav ul li:focus > a,\
|
||||
.slideout-navigation.main-navigation .main-nav ul li.sfHover > a',
|
||||
'color', ''
|
||||
);
|
||||
|
||||
/**
|
||||
* Primary navigation menu item hover
|
||||
* Empty: link_color_hover
|
||||
*/
|
||||
generate_colors_live_update( 'slideout_background_hover_color',
|
||||
'.slideout-navigation.main-navigation .main-nav ul li:hover > a,\
|
||||
.slideout-navigation.main-navigation .main-nav ul li:focus > a,\
|
||||
.slideout-navigation.main-navigation .main-nav ul li.sfHover > a',
|
||||
'background-color', 'transparent'
|
||||
);
|
||||
|
||||
/**
|
||||
* Primary sub-navigation color
|
||||
* Empty: transparent
|
||||
*/
|
||||
generate_colors_live_update( 'slideout_submenu_background_color', '.slideout-navigation.main-navigation ul ul', 'background-color', '' );
|
||||
|
||||
/**
|
||||
* Primary sub-navigation text color
|
||||
* Empty: link_color
|
||||
*/
|
||||
generate_colors_live_update( 'slideout_submenu_text_color', '.slideout-navigation.main-navigation .main-nav ul ul li a', 'color', '' );
|
||||
|
||||
/**
|
||||
* Primary sub-navigation hover
|
||||
*/
|
||||
var slideout_submenu_hover = '.slideout-navigation.main-navigation .main-nav ul ul li:hover > a,\
|
||||
.slideout-navigation.main-navigation .main-nav ul ul li:focus > a,\
|
||||
.slideout-navigation.main-navigation .main-nav ul ul li.sfHover > a';
|
||||
|
||||
/**
|
||||
* Primary sub-navigation text hover
|
||||
* Empty: link_color_hover
|
||||
*/
|
||||
generate_colors_live_update( 'slideout_submenu_text_hover_color', slideout_submenu_hover, 'color', '' );
|
||||
|
||||
/**
|
||||
* Primary sub-navigation background hover
|
||||
* Empty: transparent
|
||||
*/
|
||||
generate_colors_live_update( 'slideout_submenu_background_hover_color', slideout_submenu_hover, 'background-color', '' );
|
||||
|
||||
/**
|
||||
* Navigation current selectors
|
||||
*/
|
||||
var slideout_current = '.slideout-navigation.main-navigation .main-nav ul li[class*="current-menu-"] > a,\
|
||||
.slideout-navigation.main-navigation .main-nav ul li[class*="current-menu-"] > a:hover,\
|
||||
.slideout-navigation.main-navigation .main-nav ul li[class*="current-menu-"].sfHover > a';
|
||||
|
||||
/**
|
||||
* Primary navigation current text
|
||||
* Empty: link_color
|
||||
*/
|
||||
generate_colors_live_update( 'slideout_text_current_color', slideout_current, 'color', '' );
|
||||
|
||||
/**
|
||||
* Primary navigation current text
|
||||
* Empty: transparent
|
||||
*/
|
||||
generate_colors_live_update( 'slideout_background_current_color', slideout_current, 'background-color' );
|
||||
|
||||
/**
|
||||
* Primary sub-navigation current selectors
|
||||
*/
|
||||
var slideout_submenu_current = '.slideout-navigation.main-navigation .main-nav ul ul li[class*="current-menu-"] > a,\
|
||||
.slideout-navigation.main-navigation .main-nav ul ul li[class*="current-menu-"] > a:hover,\
|
||||
.slideout-navigation.main-navigation .main-nav ul ul li[class*="current-menu-"].sfHover > a';
|
||||
|
||||
/**
|
||||
* Primary sub-navigation current text
|
||||
* Empty: link_color
|
||||
*/
|
||||
generate_colors_live_update( 'slideout_submenu_text_current_color', slideout_submenu_current, 'color', '' );
|
||||
|
||||
/**
|
||||
* Primary navigation current item background
|
||||
* Empty: transparent
|
||||
*/
|
||||
generate_colors_live_update( 'slideout_submenu_background_current_color', slideout_submenu_current, 'background-color' );
|
||||
@ -0,0 +1,161 @@
|
||||
/**
|
||||
* WooCommerce link color
|
||||
*/
|
||||
generate_colors_live_update( 'wc_product_title_color', '.woocommerce ul.products li.product .woocommerce-LoopProduct-link', 'color', '', 'link_color' );
|
||||
generate_colors_live_update( 'wc_product_title_color_hover', '.woocommerce ul.products li.product .woocommerce-LoopProduct-link:hover', 'color', '', 'link_color_hover' );
|
||||
|
||||
/**
|
||||
* WooCommerce primary button
|
||||
*/
|
||||
var wc_button = '.woocommerce #respond input#submit, .woocommerce a.button, .woocommerce button.button, .woocommerce input.button, button, \
|
||||
html input[type="button"], \
|
||||
input[type="reset"], \
|
||||
input[type="submit"],\
|
||||
.button,\
|
||||
.button:visited';
|
||||
generate_colors_live_update( 'form_button_background_color', wc_button, 'background-color' );
|
||||
generate_colors_live_update( 'form_button_text_color', wc_button, 'color' );
|
||||
|
||||
/**
|
||||
* WooCommerce primary button hover
|
||||
*/
|
||||
var wc_button_hover = '.woocommerce #respond input#submit:hover, .woocommerce a.button:hover, .woocommerce button.button:hover, .woocommerce input.button:hover,button:hover, \
|
||||
html input[type="button"]:hover, \
|
||||
input[type="reset"]:hover, \
|
||||
input[type="submit"]:hover,\
|
||||
.button:hover,\
|
||||
button:focus, \
|
||||
html input[type="button"]:focus, \
|
||||
input[type="reset"]:focus, \
|
||||
input[type="submit"]:focus,\
|
||||
.button:focus';
|
||||
generate_colors_live_update( 'form_button_background_color_hover', wc_button_hover, 'background-color' );
|
||||
generate_colors_live_update( 'form_button_text_color_hover', wc_button_hover, 'color' );
|
||||
|
||||
/**
|
||||
* WooCommerce alt button
|
||||
*/
|
||||
var wc_alt_button = '.woocommerce #respond input#submit.alt, .woocommerce a.button.alt, .woocommerce button.button.alt, .woocommerce input.button.alt';
|
||||
generate_colors_live_update( 'wc_alt_button_background', wc_alt_button, 'background-color' );
|
||||
generate_colors_live_update( 'wc_alt_button_text', wc_alt_button, 'color' );
|
||||
|
||||
/**
|
||||
* WooCommerce alt button hover
|
||||
*/
|
||||
var wc_alt_button_hover = '.woocommerce #respond input#submit.alt:hover, .woocommerce a.button.alt:hover, .woocommerce button.button.alt:hover, .woocommerce input.button.alt:hover';
|
||||
generate_colors_live_update( 'wc_alt_button_background_hover', wc_alt_button_hover, 'background-color' );
|
||||
generate_colors_live_update( 'wc_alt_button_text_hover', wc_alt_button_hover, 'color' );
|
||||
|
||||
/**
|
||||
* WooCommerce star ratings
|
||||
*/
|
||||
var wc_stars = '.woocommerce .star-rating span:before, .woocommerce .star-rating:before';
|
||||
generate_colors_live_update( 'wc_rating_stars', wc_stars, 'color' );
|
||||
|
||||
/**
|
||||
* WooCommerce sale sticker
|
||||
*/
|
||||
var wc_sale_sticker = '.woocommerce span.onsale';
|
||||
generate_colors_live_update( 'wc_sale_sticker_background', wc_sale_sticker, 'background-color' );
|
||||
generate_colors_live_update( 'wc_sale_sticker_text', wc_sale_sticker, 'color' );
|
||||
|
||||
/**
|
||||
* WooCommerce price
|
||||
*/
|
||||
var wc_price = '.woocommerce ul.products li.product .price, .woocommerce div.product p.price';
|
||||
generate_colors_live_update( 'wc_price_color', wc_price, 'color' );
|
||||
|
||||
/**
|
||||
* WooCommerce product tab text
|
||||
*/
|
||||
var wc_product_tab = '.woocommerce div.product .woocommerce-tabs ul.tabs li a';
|
||||
generate_colors_live_update( 'wc_product_tab', wc_product_tab, 'color' );
|
||||
|
||||
/**
|
||||
* WooCommerce product tab text highlight/active
|
||||
*/
|
||||
var wc_product_tab_active = '.woocommerce div.product .woocommerce-tabs ul.tabs li a:hover, .woocommerce div.product .woocommerce-tabs ul.tabs li.active a';
|
||||
generate_colors_live_update( 'wc_product_tab_highlight', wc_product_tab_active, 'color' );
|
||||
|
||||
/**
|
||||
* WooCommerce success message
|
||||
*/
|
||||
var wc_success_message = '.woocommerce-message';
|
||||
generate_colors_live_update( 'wc_success_message_background', wc_success_message, 'background-color' );
|
||||
generate_colors_live_update( 'wc_success_message_text', wc_success_message + ', div.woocommerce-message a.button, div.woocommerce-message a.button:focus, div.woocommerce-message a.button:hover, div.woocommerce-message a, div.woocommerce-message a:focus, div.woocommerce-message a:hover', 'color' );
|
||||
|
||||
/**
|
||||
* WooCommerce info message
|
||||
*/
|
||||
var wc_info_message = '.woocommerce-info';
|
||||
generate_colors_live_update( 'wc_info_message_background', wc_info_message, 'background-color' );
|
||||
generate_colors_live_update( 'wc_info_message_text', wc_info_message + ', div.woocommerce-info a.button, div.woocommerce-info a.button:focus, div.woocommerce-info a.button:hover, div.woocommerce-info a, div.woocommerce-info a:focus, div.woocommerce-info a:hover', 'color' );
|
||||
|
||||
/**
|
||||
* WooCommerce error message
|
||||
*/
|
||||
var wc_error_message = '.woocommerce-error';
|
||||
generate_colors_live_update( 'wc_error_message_background', wc_error_message, 'background-color' );
|
||||
generate_colors_live_update( 'wc_error_message_text', wc_error_message + ', div.woocommerce-error a.button, div.woocommerce-error a.button:focus, div.woocommerce-error a.button:hover, div.woocommerce-error a, div.woocommerce-error a:focus, div.woocommerce-error a:hover', 'color' );
|
||||
|
||||
/**
|
||||
* Menu Mini Cart
|
||||
*/
|
||||
generate_colors_live_update( 'wc_mini_cart_background_color', '#wc-mini-cart', 'background-color' );
|
||||
generate_colors_live_update( 'wc_mini_cart_text_color', '#wc-mini-cart,#wc-mini-cart a:not(.button), #wc-mini-cart a.remove', 'color' );
|
||||
|
||||
generate_colors_live_update( 'wc_mini_cart_button_background', '#wc-mini-cart .button.checkout', 'background-color' );
|
||||
generate_colors_live_update( 'wc_mini_cart_button_text', '#wc-mini-cart .button.checkout', 'color' );
|
||||
|
||||
generate_colors_live_update( 'wc_mini_cart_button_background_hover', '#wc-mini-cart .button.checkout:hover, #wc-mini-cart .button.checkout:focus, #wc-mini-cart .button.checkout:active', 'background-color' );
|
||||
generate_colors_live_update( 'wc_mini_cart_button_text_hover', '#wc-mini-cart .button.checkout:hover, #wc-mini-cart .button.checkout:focus, #wc-mini-cart .button.checkout:active', 'color' );
|
||||
|
||||
/**
|
||||
* Sticky panel cart button
|
||||
*/
|
||||
generate_colors_live_update( 'wc_panel_cart_background_color', '.add-to-cart-panel', 'background-color' );
|
||||
generate_colors_live_update( 'wc_panel_cart_text_color', '.add-to-cart-panel, .add-to-cart-panel a:not(.button)', 'color' );
|
||||
|
||||
generate_colors_live_update( 'wc_panel_cart_button_background', '#wc-sticky-cart-panel .button', 'background-color' );
|
||||
generate_colors_live_update( 'wc_panel_cart_button_text', '#wc-sticky-cart-panel .button', 'color' );
|
||||
|
||||
generate_colors_live_update( 'wc_panel_cart_button_background_hover', '#wc-sticky-cart-panel .button:hover, #wc-sticky-cart-panel .button:focus, #wc-sticky-cart-panel .button:active', 'background-color' );
|
||||
generate_colors_live_update( 'wc_panel_cart_button_text_hover', '#wc-sticky-cart-panel .button:hover, #wc-sticky-cart-panel .button:focus, #wc-sticky-cart-panel .button:active', 'color' );
|
||||
|
||||
/**
|
||||
* Price slider bar
|
||||
*/
|
||||
generate_colors_live_update( 'wc_price_slider_background_color', '.woocommerce .widget_price_filter .price_slider_wrapper .ui-widget-content', 'background-color' );
|
||||
generate_colors_live_update( 'wc_price_slider_bar_color', '.woocommerce .widget_price_filter .ui-slider .ui-slider-range, .woocommerce .widget_price_filter .ui-slider .ui-slider-handle', 'background-color' );
|
||||
|
||||
// Archive product description text
|
||||
wp.customize( 'generate_settings[text_color]', function( value ) {
|
||||
value.bind( function( newval ) {
|
||||
if ( ! wp.customize.value('generate_settings[content_text_color]')() ) {
|
||||
if ( jQuery( 'style#wc_desc_color' ).length ) {
|
||||
jQuery( 'style#wc_desc_color' ).html( '.woocommerce-product-details__short-description{color:' + newval + ';}' );
|
||||
} else {
|
||||
jQuery( 'head' ).append( '<style id="wc_desc_color">.woocommerce-product-details__short-description{color:' + newval + ';}</style>' );
|
||||
setTimeout(function() {
|
||||
jQuery( 'style#wc_desc_color' ).not( ':last' ).remove();
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
wp.customize( 'generate_settings[content_text_color]', function( value ) {
|
||||
value.bind( function( newval ) {
|
||||
if ( '' == newval ) {
|
||||
newval = wp.customize.value('generate_settings[text_color]')();
|
||||
}
|
||||
if ( jQuery( 'style#wc_desc_color' ).length ) {
|
||||
jQuery( 'style#wc_desc_color' ).html( '.woocommerce-product-details__short-description{color:' + newval + ';}' );
|
||||
} else {
|
||||
jQuery( 'head' ).append( '<style id="wc_desc_color">.woocommerce-product-details__short-description{color:' + newval + ';}</style>' );
|
||||
setTimeout(function() {
|
||||
jQuery( 'style#wc_desc_color' ).not( ':last' ).remove();
|
||||
}, 1000);
|
||||
}
|
||||
} );
|
||||
} );
|
||||
@ -0,0 +1,403 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the Customizer options for the Secondary Nav module.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_colors_secondary_nav_customizer' ) ) {
|
||||
add_action( 'customize_register', 'generate_colors_secondary_nav_customizer', 1000 );
|
||||
/**
|
||||
* Adds our Secondary Nav color options
|
||||
*
|
||||
* These options are in their own function so we can hook it in late to
|
||||
* make sure Secondary Nav is activated.
|
||||
*
|
||||
* 1000 priority is there to make sure Secondary Nav is registered (999)
|
||||
* as we check to see if the layout control exists.
|
||||
*
|
||||
* Secondary Nav now uses 100 as a priority.
|
||||
*
|
||||
* @param object $wp_customize The Customizer object.
|
||||
*/
|
||||
function generate_colors_secondary_nav_customizer( $wp_customize ) {
|
||||
// Bail if Secondary Nav isn't activated.
|
||||
if ( ! $wp_customize->get_section( 'secondary_nav_section' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Bail if we don't have our color defaults.
|
||||
if ( ! function_exists( 'generate_secondary_nav_get_defaults' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Add our controls.
|
||||
require_once GP_LIBRARY_DIRECTORY . 'customizer-helpers.php';
|
||||
|
||||
// Get our defaults.
|
||||
$defaults = generate_secondary_nav_get_defaults();
|
||||
|
||||
// Add control types so controls can be built using JS.
|
||||
if ( method_exists( $wp_customize, 'register_control_type' ) ) {
|
||||
$wp_customize->register_control_type( 'GeneratePress_Alpha_Color_Customize_Control' );
|
||||
$wp_customize->register_control_type( 'GeneratePress_Title_Customize_Control' );
|
||||
$wp_customize->register_control_type( 'GeneratePress_Section_Shortcut_Control' );
|
||||
}
|
||||
|
||||
// Get our palettes.
|
||||
$palettes = generate_get_default_color_palettes();
|
||||
|
||||
// Add Secondary Navigation section.
|
||||
$wp_customize->add_section(
|
||||
'secondary_navigation_color_section',
|
||||
array(
|
||||
'title' => __( 'Secondary Navigation', 'gp-premium' ),
|
||||
'capability' => 'edit_theme_options',
|
||||
'priority' => 71,
|
||||
'panel' => 'generate_colors_panel',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Section_Shortcut_Control(
|
||||
$wp_customize,
|
||||
'generate_secondary_navigation_color_shortcuts',
|
||||
array(
|
||||
'section' => 'secondary_navigation_color_section',
|
||||
'element' => __( 'Secondary Navigation', 'gp-premium' ),
|
||||
'shortcuts' => array(
|
||||
'layout' => 'secondary_nav_section',
|
||||
'typography' => 'secondary_font_section',
|
||||
'backgrounds' => 'secondary_bg_images_section',
|
||||
),
|
||||
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
|
||||
'priority' => 1,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Title_Customize_Control(
|
||||
$wp_customize,
|
||||
'generate_secondary_navigation_items',
|
||||
array(
|
||||
'section' => 'secondary_navigation_color_section',
|
||||
'type' => 'generatepress-customizer-title',
|
||||
'title' => __( 'Parent Items', 'gp-premium' ),
|
||||
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Background.
|
||||
$wp_customize->add_setting(
|
||||
'generate_secondary_nav_settings[navigation_background_color]',
|
||||
array(
|
||||
'default' => $defaults['navigation_background_color'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_rgba',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Alpha_Color_Customize_Control(
|
||||
$wp_customize,
|
||||
'secondary_navigation_background_color',
|
||||
array(
|
||||
'label' => __( 'Background', 'gp-premium' ),
|
||||
'section' => 'secondary_navigation_color_section',
|
||||
'settings' => 'generate_secondary_nav_settings[navigation_background_color]',
|
||||
'palette' => $palettes,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Text.
|
||||
$wp_customize->add_setting(
|
||||
'generate_secondary_nav_settings[navigation_text_color]',
|
||||
array(
|
||||
'default' => $defaults['navigation_text_color'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
'secondary_navigation_text_color',
|
||||
array(
|
||||
'label' => __( 'Text', 'gp-premium' ),
|
||||
'section' => 'secondary_navigation_color_section',
|
||||
'settings' => 'generate_secondary_nav_settings[navigation_text_color]',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Background hover.
|
||||
$wp_customize->add_setting(
|
||||
'generate_secondary_nav_settings[navigation_background_hover_color]',
|
||||
array(
|
||||
'default' => $defaults['navigation_background_hover_color'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_rgba',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Alpha_Color_Customize_Control(
|
||||
$wp_customize,
|
||||
'secondary_navigation_background_hover_color',
|
||||
array(
|
||||
'label' => __( 'Background Hover', 'gp-premium' ),
|
||||
'section' => 'secondary_navigation_color_section',
|
||||
'settings' => 'generate_secondary_nav_settings[navigation_background_hover_color]',
|
||||
'palette' => $palettes,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Text hover.
|
||||
$wp_customize->add_setting(
|
||||
'generate_secondary_nav_settings[navigation_text_hover_color]',
|
||||
array(
|
||||
'default' => $defaults['navigation_text_hover_color'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
'secondary_navigation_text_hover_color',
|
||||
array(
|
||||
'label' => __( 'Text Hover', 'gp-premium' ),
|
||||
'section' => 'secondary_navigation_color_section',
|
||||
'settings' => 'generate_secondary_nav_settings[navigation_text_hover_color]',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Background current.
|
||||
$wp_customize->add_setting(
|
||||
'generate_secondary_nav_settings[navigation_background_current_color]',
|
||||
array(
|
||||
'default' => $defaults['navigation_background_current_color'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_rgba',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Alpha_Color_Customize_Control(
|
||||
$wp_customize,
|
||||
'secondary_navigation_background_current_color',
|
||||
array(
|
||||
'label' => __( 'Background Current', 'gp-premium' ),
|
||||
'section' => 'secondary_navigation_color_section',
|
||||
'settings' => 'generate_secondary_nav_settings[navigation_background_current_color]',
|
||||
'palette' => $palettes,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Text current.
|
||||
$wp_customize->add_setting(
|
||||
'generate_secondary_nav_settings[navigation_text_current_color]',
|
||||
array(
|
||||
'default' => $defaults['navigation_text_current_color'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
'secondary_navigation_text_current_color',
|
||||
array(
|
||||
'label' => __( 'Text Current', 'gp-premium' ),
|
||||
'section' => 'secondary_navigation_color_section',
|
||||
'settings' => 'generate_secondary_nav_settings[navigation_text_current_color]',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Title_Customize_Control(
|
||||
$wp_customize,
|
||||
'generate_secondary_navigation_sub_menu_items',
|
||||
array(
|
||||
'section' => 'secondary_navigation_color_section',
|
||||
'type' => 'generatepress-customizer-title',
|
||||
'title' => __( 'Sub-Menu Items', 'gp-premium' ),
|
||||
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Background.
|
||||
$wp_customize->add_setting(
|
||||
'generate_secondary_nav_settings[subnavigation_background_color]',
|
||||
array(
|
||||
'default' => $defaults['subnavigation_background_color'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_rgba',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Alpha_Color_Customize_Control(
|
||||
$wp_customize,
|
||||
'secondary_subnavigation_background_color',
|
||||
array(
|
||||
'label' => __( 'Background', 'gp-premium' ),
|
||||
'section' => 'secondary_navigation_color_section',
|
||||
'settings' => 'generate_secondary_nav_settings[subnavigation_background_color]',
|
||||
'palette' => $palettes,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Text.
|
||||
$wp_customize->add_setting(
|
||||
'generate_secondary_nav_settings[subnavigation_text_color]',
|
||||
array(
|
||||
'default' => $defaults['subnavigation_text_color'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
'secondary_subnavigation_text_color',
|
||||
array(
|
||||
'label' => __( 'Text', 'gp-premium' ),
|
||||
'section' => 'secondary_navigation_color_section',
|
||||
'settings' => 'generate_secondary_nav_settings[subnavigation_text_color]',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Background hover.
|
||||
$wp_customize->add_setting(
|
||||
'generate_secondary_nav_settings[subnavigation_background_hover_color]',
|
||||
array(
|
||||
'default' => $defaults['subnavigation_background_hover_color'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_rgba',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Alpha_Color_Customize_Control(
|
||||
$wp_customize,
|
||||
'secondary_subnavigation_background_hover_color',
|
||||
array(
|
||||
'label' => __( 'Background Hover', 'gp-premium' ),
|
||||
'section' => 'secondary_navigation_color_section',
|
||||
'settings' => 'generate_secondary_nav_settings[subnavigation_background_hover_color]',
|
||||
'palette' => $palettes,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Text hover.
|
||||
$wp_customize->add_setting(
|
||||
'generate_secondary_nav_settings[subnavigation_text_hover_color]',
|
||||
array(
|
||||
'default' => $defaults['subnavigation_text_hover_color'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
'secondary_subnavigation_text_hover_color',
|
||||
array(
|
||||
'label' => __( 'Text Hover', 'gp-premium' ),
|
||||
'section' => 'secondary_navigation_color_section',
|
||||
'settings' => 'generate_secondary_nav_settings[subnavigation_text_hover_color]',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Background current.
|
||||
$wp_customize->add_setting(
|
||||
'generate_secondary_nav_settings[subnavigation_background_current_color]',
|
||||
array(
|
||||
'default' => $defaults['subnavigation_background_current_color'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_rgba',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Alpha_Color_Customize_Control(
|
||||
$wp_customize,
|
||||
'secondary_subnavigation_background_current_color',
|
||||
array(
|
||||
'label' => __( 'Background Current', 'gp-premium' ),
|
||||
'section' => 'secondary_navigation_color_section',
|
||||
'settings' => 'generate_secondary_nav_settings[subnavigation_background_current_color]',
|
||||
'palette' => $palettes,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Text current.
|
||||
$wp_customize->add_setting(
|
||||
'generate_secondary_nav_settings[subnavigation_text_current_color]',
|
||||
array(
|
||||
'default' => $defaults['subnavigation_text_current_color'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
'secondary_subnavigation_text_current_color',
|
||||
array(
|
||||
'label' => __( 'Text Current', 'gp-premium' ),
|
||||
'section' => 'secondary_navigation_color_section',
|
||||
'settings' => 'generate_secondary_nav_settings[subnavigation_text_current_color]',
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,400 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the Customizer options for the Off-Canvas Panel.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
add_action( 'customize_preview_init', 'generate_menu_plus_live_preview_scripts', 20 );
|
||||
/**
|
||||
* Add live preview JS to the Customizer.
|
||||
*/
|
||||
function generate_menu_plus_live_preview_scripts() {
|
||||
wp_enqueue_script( 'generate-menu-plus-colors-customizer' );
|
||||
}
|
||||
|
||||
add_action( 'customize_register', 'generate_slideout_navigation_color_controls', 150 );
|
||||
/**
|
||||
* Adds our Slideout Nav color options
|
||||
*
|
||||
* @since 1.6
|
||||
* @param object $wp_customize The Customizer object.
|
||||
*/
|
||||
function generate_slideout_navigation_color_controls( $wp_customize ) {
|
||||
// Bail if Secondary Nav isn't activated.
|
||||
if ( ! $wp_customize->get_section( 'menu_plus_slideout_menu' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Bail if we don't have our color defaults.
|
||||
if ( ! function_exists( 'generate_get_color_defaults' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Add our controls.
|
||||
require_once GP_LIBRARY_DIRECTORY . 'customizer-helpers.php';
|
||||
|
||||
// Get our defaults.
|
||||
$defaults = generate_get_color_defaults();
|
||||
|
||||
// Add control types so controls can be built using JS.
|
||||
if ( method_exists( $wp_customize, 'register_control_type' ) ) {
|
||||
$wp_customize->register_control_type( 'GeneratePress_Alpha_Color_Customize_Control' );
|
||||
$wp_customize->register_control_type( 'GeneratePress_Section_Shortcut_Control' );
|
||||
}
|
||||
|
||||
// Get our palettes.
|
||||
$palettes = generate_get_default_color_palettes();
|
||||
|
||||
// Add Secondary Navigation section.
|
||||
$wp_customize->add_section(
|
||||
'slideout_color_section',
|
||||
array(
|
||||
'title' => __( 'Off Canvas Panel', 'gp-premium' ),
|
||||
'capability' => 'edit_theme_options',
|
||||
'priority' => 73,
|
||||
'panel' => 'generate_colors_panel',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Section_Shortcut_Control(
|
||||
$wp_customize,
|
||||
'generate_off_canvas_color_shortcuts',
|
||||
array(
|
||||
'section' => 'slideout_color_section',
|
||||
'element' => __( 'Off Canvas Panel', 'gp-premium' ),
|
||||
'shortcuts' => array(
|
||||
'layout' => 'menu_plus_slideout_menu',
|
||||
'typography' => 'generate_slideout_typography',
|
||||
),
|
||||
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
|
||||
'priority' => 1,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Title_Customize_Control(
|
||||
$wp_customize,
|
||||
'generate_slideout_navigation_items',
|
||||
array(
|
||||
'section' => 'slideout_color_section',
|
||||
'type' => 'generatepress-customizer-title',
|
||||
'title' => __( 'Parent Menu Items', 'gp-premium' ),
|
||||
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Background.
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[slideout_background_color]',
|
||||
array(
|
||||
'default' => $defaults['slideout_background_color'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_rgba',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Alpha_Color_Customize_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[slideout_background_color]',
|
||||
array(
|
||||
'label' => __( 'Background', 'gp-premium' ),
|
||||
'section' => 'slideout_color_section',
|
||||
'settings' => 'generate_settings[slideout_background_color]',
|
||||
'palette' => $palettes,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Text.
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[slideout_text_color]',
|
||||
array(
|
||||
'default' => $defaults['slideout_text_color'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[slideout_text_color]',
|
||||
array(
|
||||
'label' => __( 'Text', 'gp-premium' ),
|
||||
'section' => 'slideout_color_section',
|
||||
'settings' => 'generate_settings[slideout_text_color]',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Background hover.
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[slideout_background_hover_color]',
|
||||
array(
|
||||
'default' => $defaults['slideout_background_hover_color'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_rgba',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Alpha_Color_Customize_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[slideout_background_hover_color]',
|
||||
array(
|
||||
'label' => __( 'Background Hover', 'gp-premium' ),
|
||||
'section' => 'slideout_color_section',
|
||||
'settings' => 'generate_settings[slideout_background_hover_color]',
|
||||
'palette' => $palettes,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Text hover.
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[slideout_text_hover_color]',
|
||||
array(
|
||||
'default' => $defaults['slideout_text_hover_color'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[slideout_text_hover_color]',
|
||||
array(
|
||||
'label' => __( 'Text Hover', 'gp-premium' ),
|
||||
'section' => 'slideout_color_section',
|
||||
'settings' => 'generate_settings[slideout_text_hover_color]',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Background current.
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[slideout_background_current_color]',
|
||||
array(
|
||||
'default' => $defaults['slideout_background_current_color'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_rgba',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Alpha_Color_Customize_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[slideout_background_current_color]',
|
||||
array(
|
||||
'label' => __( 'Background Current', 'gp-premium' ),
|
||||
'section' => 'slideout_color_section',
|
||||
'settings' => 'generate_settings[slideout_background_current_color]',
|
||||
'palette' => $palettes,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Text current.
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[slideout_text_current_color]',
|
||||
array(
|
||||
'default' => $defaults['slideout_text_current_color'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[slideout_text_current_color]',
|
||||
array(
|
||||
'label' => __( 'Text Current', 'gp-premium' ),
|
||||
'section' => 'slideout_color_section',
|
||||
'settings' => 'generate_settings[slideout_text_current_color]',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Title_Customize_Control(
|
||||
$wp_customize,
|
||||
'generate_slideout_navigation_sub_menu_items',
|
||||
array(
|
||||
'section' => 'slideout_color_section',
|
||||
'type' => 'generatepress-customizer-title',
|
||||
'title' => __( 'Sub-Menu Items', 'gp-premium' ),
|
||||
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Background.
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[slideout_submenu_background_color]',
|
||||
array(
|
||||
'default' => $defaults['slideout_submenu_background_color'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_rgba',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Alpha_Color_Customize_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[slideout_submenu_background_color]',
|
||||
array(
|
||||
'label' => __( 'Background', 'gp-premium' ),
|
||||
'section' => 'slideout_color_section',
|
||||
'settings' => 'generate_settings[slideout_submenu_background_color]',
|
||||
'palette' => $palettes,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Text.
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[slideout_submenu_text_color]',
|
||||
array(
|
||||
'default' => $defaults['slideout_submenu_text_color'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[slideout_submenu_text_color]',
|
||||
array(
|
||||
'label' => __( 'Text', 'gp-premium' ),
|
||||
'section' => 'slideout_color_section',
|
||||
'settings' => 'generate_settings[slideout_submenu_text_color]',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Background hover.
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[slideout_submenu_background_hover_color]',
|
||||
array(
|
||||
'default' => $defaults['slideout_submenu_background_hover_color'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_rgba',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Alpha_Color_Customize_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[slideout_submenu_background_hover_color]',
|
||||
array(
|
||||
'label' => __( 'Background Hover', 'gp-premium' ),
|
||||
'section' => 'slideout_color_section',
|
||||
'settings' => 'generate_settings[slideout_submenu_background_hover_color]',
|
||||
'palette' => $palettes,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Text hover.
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[slideout_submenu_text_hover_color]',
|
||||
array(
|
||||
'default' => $defaults['slideout_submenu_text_hover_color'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[slideout_submenu_text_hover_color]',
|
||||
array(
|
||||
'label' => __( 'Text Hover', 'gp-premium' ),
|
||||
'section' => 'slideout_color_section',
|
||||
'settings' => 'generate_settings[slideout_submenu_text_hover_color]',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Background current.
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[slideout_submenu_background_current_color]',
|
||||
array(
|
||||
'default' => $defaults['slideout_submenu_background_current_color'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_rgba',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Alpha_Color_Customize_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[slideout_submenu_background_current_color]',
|
||||
array(
|
||||
'label' => __( 'Background Current', 'gp-premium' ),
|
||||
'section' => 'slideout_color_section',
|
||||
'settings' => 'generate_settings[slideout_submenu_background_current_color]',
|
||||
'palette' => $palettes,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Text current.
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[slideout_submenu_text_current_color]',
|
||||
array(
|
||||
'default' => $defaults['slideout_submenu_text_current_color'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[slideout_submenu_text_current_color]',
|
||||
array(
|
||||
'label' => __( 'Text Current', 'gp-premium' ),
|
||||
'section' => 'slideout_color_section',
|
||||
'settings' => 'generate_settings[slideout_submenu_text_current_color]',
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -0,0 +1,911 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the Customizer options for the WooCommerce module.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_colors_wc_customizer' ) ) {
|
||||
add_action( 'customize_register', 'generate_colors_wc_customizer', 100 );
|
||||
/**
|
||||
* Adds our WooCommerce color options
|
||||
*
|
||||
* @param object $wp_customize The Customizer object.
|
||||
*/
|
||||
function generate_colors_wc_customizer( $wp_customize ) {
|
||||
// Bail if WooCommerce isn't activated.
|
||||
if ( ! $wp_customize->get_section( 'generate_woocommerce_colors' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_get_color_defaults' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Add our controls.
|
||||
require_once GP_LIBRARY_DIRECTORY . 'customizer-helpers.php';
|
||||
|
||||
// Get our defaults.
|
||||
$defaults = generate_get_color_defaults();
|
||||
|
||||
// Add control types so controls can be built using JS.
|
||||
if ( method_exists( $wp_customize, 'register_control_type' ) ) {
|
||||
$wp_customize->register_control_type( 'GeneratePress_Alpha_Color_Customize_Control' );
|
||||
$wp_customize->register_control_type( 'GeneratePress_Title_Customize_Control' );
|
||||
$wp_customize->register_control_type( 'GeneratePress_Information_Customize_Control' );
|
||||
$wp_customize->register_control_type( 'GeneratePress_Section_Shortcut_Control' );
|
||||
}
|
||||
|
||||
// Get our palettes.
|
||||
$palettes = generate_get_default_color_palettes();
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Section_Shortcut_Control(
|
||||
$wp_customize,
|
||||
'generate_woocommerce_color_shortcuts',
|
||||
array(
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'element' => __( 'WooCommerce', 'gp-premium' ),
|
||||
'shortcuts' => array(
|
||||
'layout' => 'generate_woocommerce_layout',
|
||||
'typography' => 'generate_woocommerce_typography',
|
||||
),
|
||||
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
|
||||
'priority' => 0,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Title_Customize_Control(
|
||||
$wp_customize,
|
||||
'generate_woocommerce_button_title',
|
||||
array(
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'type' => 'generatepress-customizer-title',
|
||||
'title' => __( 'Buttons', 'gp-premium' ),
|
||||
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Information_Customize_Control(
|
||||
$wp_customize,
|
||||
'generate_woocommerce_primary_button_message',
|
||||
array(
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'label' => __( 'Primary Button Colors', 'gp-premium' ),
|
||||
'description' => __( 'Primary button colors can be set <a href="#">here</a>.', 'gp-premium' ),
|
||||
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[wc_alt_button_background]',
|
||||
array(
|
||||
'default' => $defaults['wc_alt_button_background'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_rgba',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Alpha_Color_Customize_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[wc_alt_button_background]',
|
||||
array(
|
||||
'label' => __( 'Alt Button Background', 'gp-premium' ),
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'settings' => 'generate_settings[wc_alt_button_background]',
|
||||
'palette' => $palettes,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[wc_alt_button_background_hover]',
|
||||
array(
|
||||
'default' => $defaults['wc_alt_button_background_hover'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_rgba',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Alpha_Color_Customize_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[wc_alt_button_background_hover]',
|
||||
array(
|
||||
'label' => __( 'Alt Button Background Hover', 'gp-premium' ),
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'settings' => 'generate_settings[wc_alt_button_background_hover]',
|
||||
'palette' => $palettes,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[wc_alt_button_text]',
|
||||
array(
|
||||
'default' => $defaults['wc_alt_button_text'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[wc_alt_button_text]',
|
||||
array(
|
||||
'label' => __( 'Alt Button Text', 'gp-premium' ),
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'settings' => 'generate_settings[wc_alt_button_text]',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[wc_alt_button_text_hover]',
|
||||
array(
|
||||
'default' => $defaults['wc_alt_button_text_hover'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[wc_alt_button_text_hover]',
|
||||
array(
|
||||
'label' => __( 'Alt Button Text Hover', 'gp-premium' ),
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'settings' => 'generate_settings[wc_alt_button_text_hover]',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Title_Customize_Control(
|
||||
$wp_customize,
|
||||
'generate_woocommerce_product_title',
|
||||
array(
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'type' => 'generatepress-customizer-title',
|
||||
'title' => __( 'Products', 'gp-premium' ),
|
||||
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[wc_product_title_color]',
|
||||
array(
|
||||
'default' => $defaults['wc_product_title_color'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[wc_product_title_color]',
|
||||
array(
|
||||
'label' => __( 'Product Title', 'gp-premium' ),
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'settings' => 'generate_settings[wc_product_title_color]',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[wc_product_title_color_hover]',
|
||||
array(
|
||||
'default' => $defaults['wc_product_title_color_hover'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[wc_product_title_color_hover]',
|
||||
array(
|
||||
'label' => __( 'Product Title Hover', 'gp-premium' ),
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'settings' => 'generate_settings[wc_product_title_color_hover]',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[wc_rating_stars]',
|
||||
array(
|
||||
'default' => $defaults['wc_rating_stars'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'transport' => '',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_rgba',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Alpha_Color_Customize_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[wc_rating_stars]',
|
||||
array(
|
||||
'label' => __( 'Star Ratings', 'gp-premium' ),
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'settings' => 'generate_settings[wc_rating_stars]',
|
||||
'palette' => $palettes,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[wc_sale_sticker_background]',
|
||||
array(
|
||||
'default' => $defaults['wc_sale_sticker_background'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_rgba',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Alpha_Color_Customize_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[wc_sale_sticker_background]',
|
||||
array(
|
||||
'label' => __( 'Sale Sticker Background', 'gp-premium' ),
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'settings' => 'generate_settings[wc_sale_sticker_background]',
|
||||
'palette' => $palettes,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[wc_sale_sticker_text]',
|
||||
array(
|
||||
'default' => $defaults['wc_sale_sticker_text'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[wc_sale_sticker_text]',
|
||||
array(
|
||||
'label' => __( 'Sale Sticker Text', 'gp-premium' ),
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'settings' => 'generate_settings[wc_sale_sticker_text]',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[wc_price_color]',
|
||||
array(
|
||||
'default' => $defaults['wc_price_color'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[wc_price_color]',
|
||||
array(
|
||||
'label' => __( 'Price', 'gp-premium' ),
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'settings' => 'generate_settings[wc_price_color]',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Title_Customize_Control(
|
||||
$wp_customize,
|
||||
'generate_woocommerce_panel_cart_title',
|
||||
array(
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'type' => 'generatepress-customizer-title',
|
||||
'title' => __( 'Sticky Panel Cart', 'gp-premium' ),
|
||||
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[wc_panel_cart_background_color]',
|
||||
array(
|
||||
'default' => $defaults['wc_panel_cart_background_color'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_rgba',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Alpha_Color_Customize_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[wc_panel_cart_background_color]',
|
||||
array(
|
||||
'label' => __( 'Background Color', 'gp-premium' ),
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'settings' => 'generate_settings[wc_panel_cart_background_color]',
|
||||
'palette' => $palettes,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[wc_panel_cart_text_color]',
|
||||
array(
|
||||
'default' => $defaults['wc_panel_cart_text_color'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[wc_panel_cart_text_color]',
|
||||
array(
|
||||
'label' => __( 'Text Color', 'gp-premium' ),
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'settings' => 'generate_settings[wc_panel_cart_text_color]',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[wc_panel_cart_button_background]',
|
||||
array(
|
||||
'default' => $defaults['wc_panel_cart_button_background'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[wc_panel_cart_button_background]',
|
||||
array(
|
||||
'label' => __( 'Button Background', 'gp-premium' ),
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'settings' => 'generate_settings[wc_panel_cart_button_background]',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[wc_panel_cart_button_background_hover]',
|
||||
array(
|
||||
'default' => $defaults['wc_panel_cart_button_background_hover'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[wc_panel_cart_button_background_hover]',
|
||||
array(
|
||||
'label' => __( 'Button Background Hover', 'gp-premium' ),
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'settings' => 'generate_settings[wc_panel_cart_button_background_hover]',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[wc_panel_cart_button_text]',
|
||||
array(
|
||||
'default' => $defaults['wc_panel_cart_button_text'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[wc_panel_cart_button_text]',
|
||||
array(
|
||||
'label' => __( 'Button Text', 'gp-premium' ),
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'settings' => 'generate_settings[wc_panel_cart_button_text]',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[wc_panel_cart_button_text_hover]',
|
||||
array(
|
||||
'default' => $defaults['wc_panel_cart_button_text_hover'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[wc_panel_cart_button_text_hover]',
|
||||
array(
|
||||
'label' => __( 'Button Text Hover', 'gp-premium' ),
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'settings' => 'generate_settings[wc_panel_cart_button_text_hover]',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Title_Customize_Control(
|
||||
$wp_customize,
|
||||
'generate_woocommerce_mini_cart_title',
|
||||
array(
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'type' => 'generatepress-customizer-title',
|
||||
'title' => __( 'Menu Mini Cart', 'gp-premium' ),
|
||||
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[wc_mini_cart_background_color]',
|
||||
array(
|
||||
'default' => $defaults['wc_mini_cart_background_color'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_rgba',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Alpha_Color_Customize_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[wc_mini_cart_background_color]',
|
||||
array(
|
||||
'label' => __( 'Cart Background Color', 'gp-premium' ),
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'settings' => 'generate_settings[wc_mini_cart_background_color]',
|
||||
'palette' => $palettes,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[wc_mini_cart_text_color]',
|
||||
array(
|
||||
'default' => $defaults['wc_mini_cart_text_color'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[wc_mini_cart_text_color]',
|
||||
array(
|
||||
'label' => __( 'Cart Text Color', 'gp-premium' ),
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'settings' => 'generate_settings[wc_mini_cart_text_color]',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[wc_mini_cart_button_background]',
|
||||
array(
|
||||
'default' => $defaults['wc_mini_cart_button_background'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[wc_mini_cart_button_background]',
|
||||
array(
|
||||
'label' => __( 'Button Background', 'gp-premium' ),
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'settings' => 'generate_settings[wc_mini_cart_button_background]',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[wc_mini_cart_button_background_hover]',
|
||||
array(
|
||||
'default' => $defaults['wc_mini_cart_button_background_hover'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[wc_mini_cart_button_background_hover]',
|
||||
array(
|
||||
'label' => __( 'Button Background Hover', 'gp-premium' ),
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'settings' => 'generate_settings[wc_mini_cart_button_background_hover]',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[wc_mini_cart_button_text]',
|
||||
array(
|
||||
'default' => $defaults['wc_mini_cart_button_text'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[wc_mini_cart_button_text]',
|
||||
array(
|
||||
'label' => __( 'Button Text', 'gp-premium' ),
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'settings' => 'generate_settings[wc_mini_cart_button_text]',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[wc_mini_cart_button_text_hover]',
|
||||
array(
|
||||
'default' => $defaults['wc_mini_cart_button_text_hover'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[wc_mini_cart_button_text_hover]',
|
||||
array(
|
||||
'label' => __( 'Button Text Hover', 'gp-premium' ),
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'settings' => 'generate_settings[wc_mini_cart_button_text_hover]',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Title_Customize_Control(
|
||||
$wp_customize,
|
||||
'generate_woocommerce_price_slider_title',
|
||||
array(
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'type' => 'generatepress-customizer-title',
|
||||
'title' => __( 'Price Slider Widget', 'gp-premium' ),
|
||||
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[wc_price_slider_background_color]',
|
||||
array(
|
||||
'default' => $defaults['wc_price_slider_background_color'],
|
||||
'type' => 'option',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[wc_price_slider_background_color]',
|
||||
array(
|
||||
'label' => __( 'Slider Background Color', 'gp-premium' ),
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'settings' => 'generate_settings[wc_price_slider_background_color]',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[wc_price_slider_bar_color]',
|
||||
array(
|
||||
'default' => $defaults['wc_price_slider_bar_color'],
|
||||
'type' => 'option',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[wc_price_slider_bar_color]',
|
||||
array(
|
||||
'label' => __( 'Slider Bar Color', 'gp-premium' ),
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'settings' => 'generate_settings[wc_price_slider_bar_color]',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Title_Customize_Control(
|
||||
$wp_customize,
|
||||
'generate_woocommerce_product_tabs_title',
|
||||
array(
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'type' => 'generatepress-customizer-title',
|
||||
'title' => __( 'Product Tabs', 'gp-premium' ),
|
||||
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[wc_product_tab]',
|
||||
array(
|
||||
'default' => $defaults['wc_product_tab'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[wc_product_tab]',
|
||||
array(
|
||||
'label' => __( 'Product Tab Text', 'gp-premium' ),
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'settings' => 'generate_settings[wc_product_tab]',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[wc_product_tab_highlight]',
|
||||
array(
|
||||
'default' => $defaults['wc_product_tab_highlight'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[wc_product_tab_highlight]',
|
||||
array(
|
||||
'label' => __( 'Product Tab Active', 'gp-premium' ),
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'settings' => 'generate_settings[wc_product_tab_highlight]',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Title_Customize_Control(
|
||||
$wp_customize,
|
||||
'generate_woocommerce_messages_title',
|
||||
array(
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'type' => 'generatepress-customizer-title',
|
||||
'title' => __( 'Messages', 'gp-premium' ),
|
||||
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[wc_success_message_background]',
|
||||
array(
|
||||
'default' => $defaults['wc_success_message_background'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_rgba',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Alpha_Color_Customize_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[wc_success_message_background]',
|
||||
array(
|
||||
'label' => __( 'Success Message Background', 'gp-premium' ),
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'settings' => 'generate_settings[wc_success_message_background]',
|
||||
'palette' => $palettes,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[wc_success_message_text]',
|
||||
array(
|
||||
'default' => $defaults['wc_success_message_text'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[wc_success_message_text]',
|
||||
array(
|
||||
'label' => __( 'Success Message Text', 'gp-premium' ),
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'settings' => 'generate_settings[wc_success_message_text]',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[wc_info_message_background]',
|
||||
array(
|
||||
'default' => $defaults['wc_info_message_background'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_rgba',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Alpha_Color_Customize_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[wc_info_message_background]',
|
||||
array(
|
||||
'label' => __( 'Info Message Background', 'gp-premium' ),
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'settings' => 'generate_settings[wc_info_message_background]',
|
||||
'palette' => $palettes,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[wc_info_message_text]',
|
||||
array(
|
||||
'default' => $defaults['wc_info_message_text'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[wc_info_message_text]',
|
||||
array(
|
||||
'label' => __( 'Info Message Text', 'gp-premium' ),
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'settings' => 'generate_settings[wc_info_message_text]',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[wc_error_message_background]',
|
||||
array(
|
||||
'default' => $defaults['wc_error_message_background'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'transport' => 'postMessage',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_rgba',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Alpha_Color_Customize_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[wc_error_message_background]',
|
||||
array(
|
||||
'label' => __( 'Error Message Background', 'gp-premium' ),
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'settings' => 'generate_settings[wc_error_message_background]',
|
||||
'palette' => $palettes,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[wc_error_message_text]',
|
||||
array(
|
||||
'default' => $defaults['wc_error_message_text'],
|
||||
'type' => 'option',
|
||||
'capability' => 'edit_theme_options',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
'generate_settings[wc_error_message_text]',
|
||||
array(
|
||||
'label' => __( 'Error Message Text', 'gp-premium' ),
|
||||
'section' => 'generate_woocommerce_colors',
|
||||
'settings' => 'generate_settings[wc_error_message_text]',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* The Colors module.
|
||||
*
|
||||
* @since 1.1.0
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
// Define the version. This used to be a standalone plugin, so we need to keep this constant.
|
||||
if ( ! defined( 'GENERATE_COLORS_VERSION' ) ) {
|
||||
define( 'GENERATE_COLORS_VERSION', GP_PREMIUM_VERSION );
|
||||
}
|
||||
|
||||
// Include functions identical between standalone addon and GP Premium.
|
||||
require plugin_dir_path( __FILE__ ) . 'functions/functions.php';
|
||||
@ -0,0 +1,223 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the Copyright functionality.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_copyright_customize_register' ) ) {
|
||||
add_action( 'customize_register', 'generate_copyright_customize_register' );
|
||||
/**
|
||||
* Add our copyright options to the Customizer.
|
||||
*
|
||||
* @param object $wp_customize The Customizer object.
|
||||
*/
|
||||
function generate_copyright_customize_register( $wp_customize ) {
|
||||
// Get our custom control.
|
||||
require_once GP_LIBRARY_DIRECTORY . 'customizer-helpers.php';
|
||||
|
||||
// Register our custom control.
|
||||
if ( method_exists( $wp_customize, 'register_control_type' ) ) {
|
||||
$wp_customize->register_control_type( 'GeneratePress_Copyright_Customize_Control' );
|
||||
}
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_copyright',
|
||||
array(
|
||||
'default' => '',
|
||||
'type' => 'theme_mod',
|
||||
'sanitize_callback' => 'wp_kses_post',
|
||||
'transport' => 'postMessage',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Copyright_Customize_Control(
|
||||
$wp_customize,
|
||||
'generate_copyright',
|
||||
array(
|
||||
'label' => __( 'Copyright', 'gp-premium' ),
|
||||
'section' => 'generate_layout_footer',
|
||||
'settings' => 'generate_copyright',
|
||||
'priority' => 500,
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Initiate selective refresh.
|
||||
if ( isset( $wp_customize->selective_refresh ) ) {
|
||||
$wp_customize->selective_refresh->add_partial(
|
||||
'generate_copyright',
|
||||
array(
|
||||
'selector' => '.copyright-bar',
|
||||
'settings' => array( 'generate_copyright' ),
|
||||
'render_callback' => 'generate_copyright_selective_refresh',
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_copyright_selective_refresh' ) ) {
|
||||
/**
|
||||
* Return our copyright on selective refresh
|
||||
*/
|
||||
function generate_copyright_selective_refresh() {
|
||||
$options = array(
|
||||
'%current_year%',
|
||||
'%copy%',
|
||||
);
|
||||
|
||||
$replace = array(
|
||||
date( 'Y' ), // phpcs:ignore -- prefer date().
|
||||
'©',
|
||||
);
|
||||
|
||||
$new_copyright = get_theme_mod( 'generate_copyright' );
|
||||
$new_copyright = str_replace( $options, $replace, get_theme_mod( 'generate_copyright' ) );
|
||||
|
||||
return do_shortcode( $new_copyright );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_copyright_remove_default' ) ) {
|
||||
add_action( 'wp', 'generate_copyright_remove_default' );
|
||||
/**
|
||||
* Remove the default copyright.
|
||||
*
|
||||
* @since 0.1
|
||||
* @deprecated GP 1.3.42
|
||||
*/
|
||||
function generate_copyright_remove_default() {
|
||||
// As of 1.3.42, we no longer need to do this.
|
||||
// We use a nice little filter instead.
|
||||
if ( ! function_exists( 'generate_add_login_attribution' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( get_theme_mod( 'generate_copyright' ) && '' !== get_theme_mod( 'generate_copyright' ) ) {
|
||||
remove_action( 'generate_credits', 'generate_add_footer_info' );
|
||||
remove_action( 'generate_copyright_line', 'generate_add_login_attribution' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_copyright_add_custom' ) ) {
|
||||
add_action( 'generate_credits', 'generate_copyright_add_custom' );
|
||||
/**
|
||||
* Add the custom copyright.
|
||||
*
|
||||
* @since 0.1
|
||||
* @deprecated GP 1.3.42
|
||||
*/
|
||||
function generate_copyright_add_custom() {
|
||||
// As of 1.3.42, we no longer need to do this.
|
||||
// We use a nice little filter instead.
|
||||
if ( ! function_exists( 'generate_add_login_attribution' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$options = array(
|
||||
'%current_year%',
|
||||
'%copy%',
|
||||
);
|
||||
|
||||
$replace = array(
|
||||
date( 'Y' ), // phpcs:ignore -- prefer date().
|
||||
'©',
|
||||
);
|
||||
|
||||
$new_copyright = get_theme_mod( 'generate_copyright' );
|
||||
$new_copyright = str_replace( $options, $replace, get_theme_mod( 'generate_copyright' ) );
|
||||
|
||||
if ( get_theme_mod( 'generate_copyright' ) && '' !== get_theme_mod( 'generate_copyright' ) ) {
|
||||
echo do_shortcode( $new_copyright );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_apply_custom_copyright' ) ) {
|
||||
add_filter( 'generate_copyright', 'generate_apply_custom_copyright' );
|
||||
/**
|
||||
* Add the custom copyright
|
||||
*
|
||||
* @since 1.2.92
|
||||
* @param string $copyright The copyright value.
|
||||
*/
|
||||
function generate_apply_custom_copyright( $copyright ) {
|
||||
// This will only work if GP >= 1.3.42 and the below function doesn't exist.
|
||||
if ( function_exists( 'generate_add_login_attribution' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$options = array(
|
||||
'%current_year%',
|
||||
'%copy%',
|
||||
);
|
||||
|
||||
$replace = array(
|
||||
date( 'Y' ), // phpcs:ignore -- prefer date().
|
||||
'©',
|
||||
);
|
||||
|
||||
$new_copyright = get_theme_mod( 'generate_copyright' );
|
||||
$new_copyright = str_replace( $options, $replace, get_theme_mod( 'generate_copyright' ) );
|
||||
|
||||
if ( get_theme_mod( 'generate_copyright' ) && '' !== get_theme_mod( 'generate_copyright' ) ) {
|
||||
return do_shortcode( $new_copyright );
|
||||
}
|
||||
|
||||
return $copyright;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_copyright_customizer_live_preview' ) ) {
|
||||
add_action( 'customize_preview_init', 'generate_copyright_customizer_live_preview' );
|
||||
/**
|
||||
* Add our live preview
|
||||
*/
|
||||
function generate_copyright_customizer_live_preview() {
|
||||
wp_enqueue_script(
|
||||
'generate-copyright-customizer',
|
||||
plugin_dir_url( __FILE__ ) . 'js/customizer.js',
|
||||
array( 'jquery', 'customize-preview' ),
|
||||
GENERATE_COPYRIGHT_VERSION,
|
||||
true
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_update_copyright' ) ) {
|
||||
add_action( 'admin_init', 'generate_update_copyright' );
|
||||
/**
|
||||
* Our copyright use to have it's own setting
|
||||
* If we have the old setting, move it into our theme_mod
|
||||
*/
|
||||
function generate_update_copyright() {
|
||||
// If we already have a custom logo, bail.
|
||||
if ( get_theme_mod( 'generate_copyright' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the old logo value.
|
||||
$old_value = get_option( 'gen_custom_copyright' );
|
||||
|
||||
// If there's no old value, bail.
|
||||
if ( empty( $old_value ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Now let's update the new logo setting with our ID.
|
||||
set_theme_mod( 'generate_copyright', $old_value );
|
||||
|
||||
// Got our custom logo? Time to delete the old value.
|
||||
if ( get_theme_mod( 'generate_copyright' ) ) {
|
||||
delete_option( 'gen_custom_copyright' );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Theme Customizer enhancements for a better user experience.
|
||||
*
|
||||
* Contains handlers to make Theme Customizer preview reload changes asynchronously.
|
||||
*/
|
||||
|
||||
( function( $ ) {
|
||||
// Update the site title in real time...
|
||||
wp.customize( 'generate_copyright', function( value ) {
|
||||
value.bind( function( newval ) {
|
||||
if ( $( '.copyright-bar' ).length ) {
|
||||
$( '.copyright-bar' ).html( newval );
|
||||
} else {
|
||||
$( '.inside-site-info' ).html( newval );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
}( jQuery ) );
|
||||
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* The Copyright module.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
// Define the version.
|
||||
if ( ! defined( 'GENERATE_COPYRIGHT_VERSION' ) ) {
|
||||
define( 'GENERATE_COPYRIGHT_VERSION', GP_PREMIUM_VERSION );
|
||||
}
|
||||
|
||||
// Include functions identical between standalone addon and GP Premium.
|
||||
require plugin_dir_path( __FILE__ ) . 'functions/functions.php';
|
||||
@ -0,0 +1,426 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the Disable Elements functionality.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
define( 'GENERATE_DE_LAYOUT_META_BOX', true );
|
||||
|
||||
if ( ! function_exists( 'generate_disable_elements' ) ) {
|
||||
/**
|
||||
* Remove the default disable_elements.
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_disable_elements() {
|
||||
// Don't run the function unless we're on a page it applies to.
|
||||
if ( ! is_singular() ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
global $post;
|
||||
|
||||
// Prevent PHP notices.
|
||||
if ( isset( $post ) ) {
|
||||
$disable_header = get_post_meta( $post->ID, '_generate-disable-header', true );
|
||||
$disable_nav = get_post_meta( $post->ID, '_generate-disable-nav', true );
|
||||
$disable_secondary_nav = get_post_meta( $post->ID, '_generate-disable-secondary-nav', true );
|
||||
$disable_post_image = get_post_meta( $post->ID, '_generate-disable-post-image', true );
|
||||
$disable_headline = get_post_meta( $post->ID, '_generate-disable-headline', true );
|
||||
$disable_footer = get_post_meta( $post->ID, '_generate-disable-footer', true );
|
||||
}
|
||||
|
||||
$return = '';
|
||||
|
||||
if ( ! empty( $disable_header ) && false !== $disable_header ) {
|
||||
$return = '.site-header {display:none}';
|
||||
}
|
||||
|
||||
if ( ! empty( $disable_nav ) && false !== $disable_nav ) {
|
||||
$return .= '#site-navigation,.navigation-clone, #mobile-header {display:none !important}';
|
||||
}
|
||||
|
||||
if ( ! empty( $disable_secondary_nav ) && false !== $disable_secondary_nav ) {
|
||||
$return .= '#secondary-navigation {display:none}';
|
||||
}
|
||||
|
||||
if ( ! empty( $disable_post_image ) && false !== $disable_post_image ) {
|
||||
$return .= '.generate-page-header, .page-header-image, .page-header-image-single {display:none}';
|
||||
}
|
||||
|
||||
$need_css_removal = true;
|
||||
|
||||
if ( defined( 'GENERATE_VERSION' ) && version_compare( GENERATE_VERSION, '3.0.0-alpha.1', '>=' ) ) {
|
||||
$need_css_removal = false;
|
||||
}
|
||||
|
||||
if ( $need_css_removal && ! empty( $disable_headline ) && false !== $disable_headline && ! is_single() ) {
|
||||
$return .= '.entry-header {display:none} .page-content, .entry-content, .entry-summary {margin-top:0}';
|
||||
}
|
||||
|
||||
if ( ! empty( $disable_footer ) && false !== $disable_footer ) {
|
||||
$return .= '.site-footer {display:none}';
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_de_scripts' ) ) {
|
||||
add_action( 'wp_enqueue_scripts', 'generate_de_scripts', 50 );
|
||||
/**
|
||||
* Enqueue scripts and styles
|
||||
*/
|
||||
function generate_de_scripts() {
|
||||
wp_add_inline_style( 'generate-style', generate_disable_elements() );
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_add_de_meta_box' ) ) {
|
||||
add_action( 'add_meta_boxes', 'generate_add_de_meta_box', 50 );
|
||||
/**
|
||||
* Generate the layout metabox.
|
||||
*
|
||||
* @since 0.1
|
||||
*/
|
||||
function generate_add_de_meta_box() {
|
||||
// Set user role - make filterable.
|
||||
$allowed = apply_filters( 'generate_metabox_capability', 'edit_theme_options' );
|
||||
|
||||
// If not an administrator, don't show the metabox.
|
||||
if ( ! current_user_can( $allowed ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( defined( 'GENERATE_LAYOUT_META_BOX' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$args = array( 'public' => true );
|
||||
$post_types = get_post_types( $args );
|
||||
foreach ( $post_types as $type ) {
|
||||
if ( 'attachment' !== $type ) {
|
||||
add_meta_box(
|
||||
'generate_de_meta_box',
|
||||
__( 'Disable Elements', 'gp-premium' ),
|
||||
'generate_show_de_meta_box',
|
||||
$type,
|
||||
'side',
|
||||
'default'
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_show_de_meta_box' ) ) {
|
||||
/**
|
||||
* Outputs the content of the metabox.
|
||||
*
|
||||
* @param object $post The post object.
|
||||
*/
|
||||
function generate_show_de_meta_box( $post ) {
|
||||
wp_nonce_field( basename( __FILE__ ), 'generate_de_nonce' );
|
||||
$stored_meta = get_post_meta( $post->ID );
|
||||
$stored_meta['_generate-disable-header'][0] = ( isset( $stored_meta['_generate-disable-header'][0] ) ) ? $stored_meta['_generate-disable-header'][0] : '';
|
||||
$stored_meta['_generate-disable-nav'][0] = ( isset( $stored_meta['_generate-disable-nav'][0] ) ) ? $stored_meta['_generate-disable-nav'][0] : '';
|
||||
$stored_meta['_generate-disable-secondary-nav'][0] = ( isset( $stored_meta['_generate-disable-secondary-nav'][0] ) ) ? $stored_meta['_generate-disable-secondary-nav'][0] : '';
|
||||
$stored_meta['_generate-disable-post-image'][0] = ( isset( $stored_meta['_generate-disable-post-image'][0] ) ) ? $stored_meta['_generate-disable-post-image'][0] : '';
|
||||
$stored_meta['_generate-disable-headline'][0] = ( isset( $stored_meta['_generate-disable-headline'][0] ) ) ? $stored_meta['_generate-disable-headline'][0] : '';
|
||||
$stored_meta['_generate-disable-footer'][0] = ( isset( $stored_meta['_generate-disable-footer'][0] ) ) ? $stored_meta['_generate-disable-footer'][0] : '';
|
||||
$stored_meta['_generate-disable-top-bar'][0] = ( isset( $stored_meta['_generate-disable-top-bar'][0] ) ) ? $stored_meta['_generate-disable-top-bar'][0] : '';
|
||||
?>
|
||||
|
||||
<p>
|
||||
<div class="generate_disable_elements">
|
||||
<?php if ( function_exists( 'generate_top_bar' ) ) : ?>
|
||||
<label for="meta-generate-disable-top-bar" style="display:block;margin-bottom:3px;" title="<?php _e( 'Top Bar', 'gp-premium' ); ?>">
|
||||
<input type="checkbox" name="_generate-disable-top-bar" id="meta-generate-disable-top-bar" value="true" <?php checked( $stored_meta['_generate-disable-top-bar'][0], 'true' ); ?>>
|
||||
<?php _e( 'Top Bar', 'gp-premium' ); ?>
|
||||
</label>
|
||||
<?php endif; ?>
|
||||
|
||||
<label for="meta-generate-disable-header" style="display:block;margin-bottom:3px;" title="<?php _e( 'Header', 'gp-premium' ); ?>">
|
||||
<input type="checkbox" name="_generate-disable-header" id="meta-generate-disable-header" value="true" <?php checked( $stored_meta['_generate-disable-header'][0], 'true' ); ?>>
|
||||
<?php _e( 'Header', 'gp-premium' ); ?>
|
||||
</label>
|
||||
|
||||
<label for="meta-generate-disable-nav" style="display:block;margin-bottom:3px;" title="<?php _e( 'Primary Navigation', 'gp-premium' ); ?>">
|
||||
<input type="checkbox" name="_generate-disable-nav" id="meta-generate-disable-nav" value="true" <?php checked( $stored_meta['_generate-disable-nav'][0], 'true' ); ?>>
|
||||
<?php _e( 'Primary Navigation', 'gp-premium' ); ?>
|
||||
</label>
|
||||
|
||||
<?php if ( function_exists( 'generate_secondary_nav_setup' ) ) : ?>
|
||||
<label for="meta-generate-disable-secondary-nav" style="display:block;margin-bottom:3px;" title="<?php _e( 'Secondary Navigation', 'gp-premium' ); ?>">
|
||||
<input type="checkbox" name="_generate-disable-secondary-nav" id="meta-generate-disable-secondary-nav" value="true" <?php checked( $stored_meta['_generate-disable-secondary-nav'][0], 'true' ); ?>>
|
||||
<?php _e( 'Secondary Navigation', 'gp-premium' ); ?>
|
||||
</label>
|
||||
<?php endif; ?>
|
||||
|
||||
<label for="meta-generate-disable-post-image" style="display:block;margin-bottom:3px;" title="<?php _e( 'Featured Image', 'gp-premium' ); ?>">
|
||||
<input type="checkbox" name="_generate-disable-post-image" id="meta-generate-disable-post-image" value="true" <?php checked( $stored_meta['_generate-disable-post-image'][0], 'true' ); ?>>
|
||||
<?php _e( 'Featured Image', 'gp-premium' ); ?>
|
||||
</label>
|
||||
|
||||
<label for="meta-generate-disable-headline" style="display:block;margin-bottom:3px;" title="<?php _e( 'Content Title', 'gp-premium' ); ?>">
|
||||
<input type="checkbox" name="_generate-disable-headline" id="meta-generate-disable-headline" value="true" <?php checked( $stored_meta['_generate-disable-headline'][0], 'true' ); ?>>
|
||||
<?php _e( 'Content Title', 'gp-premium' ); ?>
|
||||
</label>
|
||||
|
||||
<label for="meta-generate-disable-footer" style="display:block;margin-bottom:3px;" title="<?php _e( 'Footer', 'gp-premium' ); ?>">
|
||||
<input type="checkbox" name="_generate-disable-footer" id="meta-generate-disable-footer" value="true" <?php checked( $stored_meta['_generate-disable-footer'][0], 'true' ); ?>>
|
||||
<?php _e( 'Footer', 'gp-premium' ); ?>
|
||||
</label>
|
||||
</div>
|
||||
</p>
|
||||
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_save_de_meta' ) ) {
|
||||
add_action( 'save_post', 'generate_save_de_meta' );
|
||||
/**
|
||||
* Save our options.
|
||||
*
|
||||
* @param int $post_id The post ID.
|
||||
*/
|
||||
function generate_save_de_meta( $post_id ) {
|
||||
|
||||
if ( defined( 'GENERATE_LAYOUT_META_BOX' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Checks save status.
|
||||
$is_autosave = wp_is_post_autosave( $post_id );
|
||||
$is_revision = wp_is_post_revision( $post_id );
|
||||
$is_valid_nonce = ( isset( $_POST['generate_de_nonce'] ) && wp_verify_nonce( $_POST['generate_de_nonce'], basename( __FILE__ ) ) ) ? true : false;
|
||||
|
||||
// Exits script depending on save status.
|
||||
if ( $is_autosave || $is_revision || ! $is_valid_nonce ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check that the logged in user has permission to edit this post.
|
||||
if ( ! current_user_can( 'edit_post', $post_id ) ) {
|
||||
return $post_id;
|
||||
}
|
||||
|
||||
$options = array(
|
||||
'_generate-disable-top-bar',
|
||||
'_generate-disable-header',
|
||||
'_generate-disable-nav',
|
||||
'_generate-disable-secondary-nav',
|
||||
'_generate-disable-headline',
|
||||
'_generate-disable-footer',
|
||||
'_generate-disable-post-image',
|
||||
);
|
||||
|
||||
foreach ( $options as $key ) {
|
||||
$value = isset( $_POST[ $key ] )
|
||||
? sanitize_text_field( wp_unslash( $_POST[ $key ] ) )
|
||||
: '';
|
||||
|
||||
if ( $value ) {
|
||||
update_post_meta( $post_id, $key, $value );
|
||||
} else {
|
||||
delete_post_meta( $post_id, $key );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'generate_disable_elements_setup' ) ) {
|
||||
add_action( 'wp', 'generate_disable_elements_setup', 50 );
|
||||
/**
|
||||
* Disable the things.
|
||||
*/
|
||||
function generate_disable_elements_setup() {
|
||||
// Don't run the function unless we're on a page it applies to.
|
||||
if ( ! is_singular() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the current post.
|
||||
global $post;
|
||||
|
||||
// Grab our values.
|
||||
if ( isset( $post ) ) {
|
||||
$disable_top_bar = get_post_meta( $post->ID, '_generate-disable-top-bar', true );
|
||||
$disable_header = get_post_meta( $post->ID, '_generate-disable-header', true );
|
||||
$disable_mobile_header = get_post_meta( $post->ID, '_generate-disable-mobile-header', true );
|
||||
$disable_nav = get_post_meta( $post->ID, '_generate-disable-nav', true );
|
||||
$disable_headline = get_post_meta( $post->ID, '_generate-disable-headline', true );
|
||||
$disable_footer = get_post_meta( $post->ID, '_generate-disable-footer', true );
|
||||
}
|
||||
|
||||
// Remove the top bar.
|
||||
if ( ! empty( $disable_top_bar ) && false !== $disable_top_bar && function_exists( 'generate_top_bar' ) ) {
|
||||
remove_action( 'generate_before_header', 'generate_top_bar', 5 );
|
||||
remove_action( 'generate_inside_secondary_navigation', 'generate_secondary_nav_top_bar_widget', 5 );
|
||||
}
|
||||
|
||||
// Remove the header.
|
||||
if ( ! empty( $disable_header ) && false !== $disable_header && function_exists( 'generate_construct_header' ) ) {
|
||||
remove_action( 'generate_header', 'generate_construct_header' );
|
||||
}
|
||||
|
||||
// Remove the mobile header.
|
||||
if ( ! empty( $disable_mobile_header ) && false !== $disable_mobile_header && function_exists( 'generate_menu_plus_mobile_header' ) ) {
|
||||
remove_action( 'generate_after_header', 'generate_menu_plus_mobile_header', 5 );
|
||||
}
|
||||
|
||||
// Remove the navigation.
|
||||
if ( ! empty( $disable_nav ) && false !== $disable_nav && function_exists( 'generate_get_navigation_location' ) ) {
|
||||
add_filter( 'generate_navigation_location', '__return_false', 20 );
|
||||
add_filter( 'generate_disable_mobile_header_menu', '__return_true' );
|
||||
}
|
||||
|
||||
// Remove the title.
|
||||
if ( ! empty( $disable_headline ) && false !== $disable_headline && function_exists( 'generate_show_title' ) ) {
|
||||
add_filter( 'generate_show_title', '__return_false' );
|
||||
}
|
||||
|
||||
// Remove the footer.
|
||||
if ( ! empty( $disable_footer ) && false !== $disable_footer ) {
|
||||
if ( function_exists( 'generate_construct_footer_widgets' ) ) {
|
||||
remove_action( 'generate_footer', 'generate_construct_footer_widgets', 5 );
|
||||
}
|
||||
|
||||
if ( function_exists( 'generate_construct_footer' ) ) {
|
||||
remove_action( 'generate_footer', 'generate_construct_footer' );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
add_action( 'generate_layout_disable_elements_section', 'generate_premium_disable_elements_options' );
|
||||
/**
|
||||
* Add the meta box options to the Layout meta box in the new GP
|
||||
*
|
||||
* @since 1.4
|
||||
* @param array $stored_meta Existing meta data.
|
||||
*/
|
||||
function generate_premium_disable_elements_options( $stored_meta ) {
|
||||
$stored_meta['_generate-disable-header'][0] = ( isset( $stored_meta['_generate-disable-header'][0] ) ) ? $stored_meta['_generate-disable-header'][0] : '';
|
||||
$stored_meta['_generate-disable-mobile-header'][0] = ( isset( $stored_meta['_generate-disable-mobile-header'][0] ) ) ? $stored_meta['_generate-disable-mobile-header'][0] : '';
|
||||
$stored_meta['_generate-disable-nav'][0] = ( isset( $stored_meta['_generate-disable-nav'][0] ) ) ? $stored_meta['_generate-disable-nav'][0] : '';
|
||||
$stored_meta['_generate-disable-secondary-nav'][0] = ( isset( $stored_meta['_generate-disable-secondary-nav'][0] ) ) ? $stored_meta['_generate-disable-secondary-nav'][0] : '';
|
||||
$stored_meta['_generate-disable-post-image'][0] = ( isset( $stored_meta['_generate-disable-post-image'][0] ) ) ? $stored_meta['_generate-disable-post-image'][0] : '';
|
||||
$stored_meta['_generate-disable-headline'][0] = ( isset( $stored_meta['_generate-disable-headline'][0] ) ) ? $stored_meta['_generate-disable-headline'][0] : '';
|
||||
$stored_meta['_generate-disable-footer'][0] = ( isset( $stored_meta['_generate-disable-footer'][0] ) ) ? $stored_meta['_generate-disable-footer'][0] : '';
|
||||
$stored_meta['_generate-disable-top-bar'][0] = ( isset( $stored_meta['_generate-disable-top-bar'][0] ) ) ? $stored_meta['_generate-disable-top-bar'][0] : '';
|
||||
?>
|
||||
<div class="generate_disable_elements">
|
||||
<?php if ( function_exists( 'generate_top_bar' ) ) : ?>
|
||||
<label for="meta-generate-disable-top-bar" style="display:block;margin-bottom:3px;" title="<?php _e( 'Top Bar', 'gp-premium' ); ?>">
|
||||
<input type="checkbox" name="_generate-disable-top-bar" id="meta-generate-disable-top-bar" value="true" <?php checked( $stored_meta['_generate-disable-top-bar'][0], 'true' ); ?>>
|
||||
<?php _e( 'Top Bar', 'gp-premium' ); ?>
|
||||
</label>
|
||||
<?php endif; ?>
|
||||
|
||||
<label for="meta-generate-disable-header" style="display:block;margin-bottom:3px;" title="<?php _e( 'Header', 'gp-premium' ); ?>">
|
||||
<input type="checkbox" name="_generate-disable-header" id="meta-generate-disable-header" value="true" <?php checked( $stored_meta['_generate-disable-header'][0], 'true' ); ?>>
|
||||
<?php _e( 'Header', 'gp-premium' ); ?>
|
||||
</label>
|
||||
|
||||
<?php
|
||||
if ( function_exists( 'generate_menu_plus_get_defaults' ) ) :
|
||||
$menu_plus_settings = wp_parse_args(
|
||||
get_option( 'generate_menu_plus_settings', array() ),
|
||||
generate_menu_plus_get_defaults()
|
||||
);
|
||||
|
||||
if ( 'enable' === $menu_plus_settings['mobile_header'] ) :
|
||||
?>
|
||||
<label for="meta-generate-disable-mobile-header" style="display:block;margin-bottom:3px;" title="<?php esc_attr_e( 'Mobile Header', 'gp-premium' ); ?>">
|
||||
<input type="checkbox" name="_generate-disable-mobile-header" id="meta-generate-disable-mobile-header" value="true" <?php checked( $stored_meta['_generate-disable-mobile-header'][0], 'true' ); ?>>
|
||||
<?php esc_html_e( 'Mobile Header', 'gp-premium' ); ?>
|
||||
</label>
|
||||
<?php
|
||||
endif;
|
||||
endif;
|
||||
?>
|
||||
|
||||
<label for="meta-generate-disable-nav" style="display:block;margin-bottom:3px;" title="<?php _e( 'Primary Navigation', 'gp-premium' ); ?>">
|
||||
<input type="checkbox" name="_generate-disable-nav" id="meta-generate-disable-nav" value="true" <?php checked( $stored_meta['_generate-disable-nav'][0], 'true' ); ?>>
|
||||
<?php _e( 'Primary Navigation', 'gp-premium' ); ?>
|
||||
</label>
|
||||
|
||||
<?php if ( function_exists( 'generate_secondary_nav_setup' ) ) : ?>
|
||||
<label for="meta-generate-disable-secondary-nav" style="display:block;margin-bottom:3px;" title="<?php _e( 'Secondary Navigation', 'gp-premium' ); ?>">
|
||||
<input type="checkbox" name="_generate-disable-secondary-nav" id="meta-generate-disable-secondary-nav" value="true" <?php checked( $stored_meta['_generate-disable-secondary-nav'][0], 'true' ); ?>>
|
||||
<?php _e( 'Secondary Navigation', 'gp-premium' ); ?>
|
||||
</label>
|
||||
<?php endif; ?>
|
||||
|
||||
<label for="meta-generate-disable-post-image" style="display:block;margin-bottom:3px;" title="<?php _e( 'Featured Image', 'gp-premium' ); ?>">
|
||||
<input type="checkbox" name="_generate-disable-post-image" id="meta-generate-disable-post-image" value="true" <?php checked( $stored_meta['_generate-disable-post-image'][0], 'true' ); ?>>
|
||||
<?php _e( 'Featured Image', 'gp-premium' ); ?>
|
||||
</label>
|
||||
|
||||
<label for="meta-generate-disable-headline" style="display:block;margin-bottom:3px;" title="<?php _e( 'Content Title', 'gp-premium' ); ?>">
|
||||
<input type="checkbox" name="_generate-disable-headline" id="meta-generate-disable-headline" value="true" <?php checked( $stored_meta['_generate-disable-headline'][0], 'true' ); ?>>
|
||||
<?php _e( 'Content Title', 'gp-premium' ); ?>
|
||||
</label>
|
||||
|
||||
<label for="meta-generate-disable-footer" style="display:block;margin-bottom:3px;" title="<?php _e( 'Footer', 'gp-premium' ); ?>">
|
||||
<input type="checkbox" name="_generate-disable-footer" id="meta-generate-disable-footer" value="true" <?php checked( $stored_meta['_generate-disable-footer'][0], 'true' ); ?>>
|
||||
<?php _e( 'Footer', 'gp-premium' ); ?>
|
||||
</label>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
add_action( 'generate_layout_meta_box_save', 'generate_premium_save_disable_elements_meta' );
|
||||
/**
|
||||
* Save the Disable Elements meta box values
|
||||
*
|
||||
* @since 1.4
|
||||
* @param int $post_id The post ID.
|
||||
*/
|
||||
function generate_premium_save_disable_elements_meta( $post_id ) {
|
||||
$options = array(
|
||||
'_generate-disable-top-bar',
|
||||
'_generate-disable-header',
|
||||
'_generate-disable-mobile-header',
|
||||
'_generate-disable-nav',
|
||||
'_generate-disable-secondary-nav',
|
||||
'_generate-disable-headline',
|
||||
'_generate-disable-footer',
|
||||
'_generate-disable-post-image',
|
||||
);
|
||||
|
||||
foreach ( $options as $key ) {
|
||||
$value = isset( $_POST[ $key ] ) // phpcs:ignore -- Nonce exists within `generate_layout_meta_box_save` hook.
|
||||
? sanitize_text_field( wp_unslash( $_POST[ $key ] ) ) // phpcs:ignore -- Nonce exists within `generate_layout_meta_box_save` hook.
|
||||
: '';
|
||||
|
||||
if ( $value ) {
|
||||
update_post_meta( $post_id, $key, $value );
|
||||
} else {
|
||||
delete_post_meta( $post_id, $key );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
add_filter( 'body_class', 'generate_disable_elements_body_classes', 20 );
|
||||
/**
|
||||
* Remove body classes if certain elements are disabled.
|
||||
*
|
||||
* @since 2.1.0
|
||||
* @param array $classes Our body classes.
|
||||
*/
|
||||
function generate_disable_elements_body_classes( $classes ) {
|
||||
if ( is_singular() ) {
|
||||
$disable_featured_image = get_post_meta( get_the_ID(), '_generate-disable-post-image', true );
|
||||
$classes = generate_premium_remove_featured_image_class( $classes, $disable_featured_image );
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* The Disable Elements module.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
// Define the version.
|
||||
if ( ! defined( 'GENERATE_DE_VERSION' ) ) {
|
||||
define( 'GENERATE_DE_VERSION', GP_PREMIUM_VERSION );
|
||||
}
|
||||
|
||||
// Include functions identical between standalone addon and GP Premium.
|
||||
require plugin_dir_path( __FILE__ ) . 'functions/functions.php';
|
||||
1
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/adjacent-posts.asset.php
vendored
Normal file
1
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/adjacent-posts.asset.php
vendored
Normal file
@ -0,0 +1 @@
|
||||
<?php return array('dependencies' => array('wp-hooks', 'wp-i18n'), 'version' => 'bfbc5254c52ffe55aa92');
|
||||
1
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/adjacent-posts.js
vendored
Normal file
1
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/adjacent-posts.js
vendored
Normal 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}))})();
|
||||
7
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/block-elements-rtl.css
vendored
Normal file
7
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/block-elements-rtl.css
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
.inline-post-meta-area.block-editor-block-list__layout,.inline-post-meta-area>.gb-inside-container.block-editor-block-list__layout,.inline-post-meta-area>.gb-inside-container>.block-editor-inner-blocks>.block-editor-block-list__layout{align-items:center;display:flex}.inline-post-meta-area.block-editor-block-list__layout>.wp-block.block-list-appender,.inline-post-meta-area>.gb-inside-container.block-editor-block-list__layout>.wp-block.block-list-appender,.inline-post-meta-area>.gb-inside-container>.block-editor-inner-blocks>.block-editor-block-list__layout>.wp-block.block-list-appender{margin-right:20px}.inline-post-meta-area.block-editor-block-list__layout>.wp-block-image,.inline-post-meta-area>.gb-inside-container.block-editor-block-list__layout>.wp-block-image,.inline-post-meta-area>.gb-inside-container>.block-editor-inner-blocks>.block-editor-block-list__layout>.wp-block-image{line-height:0}.inline-post-meta-area.block-editor-block-list__layout>.wp-block-image figcaption,.inline-post-meta-area>.gb-inside-container.block-editor-block-list__layout>.wp-block-image figcaption,.inline-post-meta-area>.gb-inside-container>.block-editor-inner-blocks>.block-editor-block-list__layout>.wp-block-image figcaption{display:none}.inline-post-meta-area .wp-block{margin-right:0;margin-left:0}.gpp-dynamic-container-bg-dropdown .components-popover__content{width:275px}.gpp-dynamic-container-bg-dropdown .components-popover__content .components-base-control:not(:last-child){margin-bottom:20px}.gpp-dynamic-container-bg-dropdown .components-popover__content .components-base-control:last-child .components-base-control__field{margin-bottom:0}.gpp-dynamic-container-bg-dropdown .components-popover__content .components-base-control:last-child .components-base-control__help{margin-top:3px}
|
||||
.gpp-dynamic-headline-text-dropdown .components-popover__content{width:275px}.gpp-dynamic-headline-text-dropdown .components-popover__content .components-base-control:not(:last-child){margin-bottom:20px}.gpp-dynamic-headline-text-dropdown .components-popover__content .components-base-control:last-child .components-base-control__field{margin-bottom:0}.gpp-dynamic-headline-text-dropdown .components-popover__content .components-base-control:last-child .components-base-control__help{margin-top:3px}.gpp-blocks-dynamic-text-replace-field{display:none}.gpp-block-dynamic-year .components-base-control__help{margin-top:2px}
|
||||
.wp-block[data-type="generatepress/dynamic-content"]{margin-bottom:0;margin-top:0}
|
||||
.wp-block[data-type="generatepress/dynamic-image"]{color:#fff;margin-bottom:0;margin-top:0}.wp-block[data-type="generatepress/dynamic-image"] .components-gpp-dynamic-image-placeholder__label{align-items:center;bottom:0;color:#fff;display:flex;font-size:1em;justify-content:center;right:0;position:absolute;left:0;top:0}.wp-block[data-type="generatepress/dynamic-image"] .components-gpp-dynamic-image-placeholder__label>.gpp-dynamic-featured-image__label{margin-right:10px}.wp-block[data-type="generatepress/dynamic-image"] .gpp-dynamic-image-placeholder{background:#000;vertical-align:middle}.wp-block[data-type="generatepress/dynamic-image"] .components-placeholder{width:100%}.wp-block[data-type="generatepress/dynamic-image"] .gpp-dynamic-image-preview{display:inline-block;position:relative}.wp-block[data-type="generatepress/dynamic-image"] .dynamic-author-image-rounded{border-radius:100%}
|
||||
.components-generatepress-units-control-header__units{align-items:center;display:flex;justify-content:space-between;margin-bottom:5px}.components-generatepress-control__units .components-generatepress-control-buttons__units button.components-button{background:#fff;border:0;border-radius:0!important;box-shadow:none!important;color:#929da7;font-size:10px;height:auto;line-height:20px;padding:0 5px;position:relative;text-align:center;text-shadow:none}.components-generatepress-control__units .components-generatepress-control-buttons__units button.components-button.is-primary{background:#fff!important;color:#000!important;cursor:default;font-weight:700;z-index:1}
|
||||
.editor-styles-wrapper .is-root-container>.wp-block{margin-right:auto;margin-left:auto;max-width:var(--gp-block-element-width)}.left-sidebar-block-type div:not(.block-editor-inner-blocks)>.block-editor-block-list__layout,.right-sidebar-block-type div:not(.block-editor-inner-blocks)>.block-editor-block-list__layout{padding:10px}.gpp-block-element-panel>.components-base-control{margin-bottom:20px}.gpp-block-element-panel .components-notice,.gpp-block-element-panel .components-notice .components-notice__content{margin:0}.gpp-element-panel-label .components-panel__body-toggle.components-button{display:flex;flex-direction:row-reverse;justify-content:flex-end}.gpp-element-panel-label .components-panel__body-toggle.components-button svg.components-panel__icon{margin:0 0 0 10px}button.gpp-block-elements-template-button{background:#fff;border:1px solid #ddd;border-radius:5px;cursor:pointer;margin:0 0 10px;padding:5px}button.gpp-block-elements-template-button:hover{border-color:var(--wp-admin-theme-color)}button.gpp-block-elements-template-button .gpp-block-template-label{color:#888;font-size:13px;padding:5px}.element-has-parent #generate_premium_elements{display:none}.gpp-block-element-template-panel{background:#fafafa}
|
||||
.gp-select-search .select-search-container{--select-search-background:#fff;--select-search-border:#949494;--select-search-selected:var(--wp-admin-theme-color);--select-search-text:#2c3338;--select-search-subtle-text:#6c6f85;--select-search-inverted-text:var(--select-search-background);--select-search-highlight:#eff1f5;box-sizing:border-box;color:var(--select-search-text);font-family:var(--select-search-font);position:relative;width:100%}.gp-select-search .select-search-container *,.gp-select-search .select-search-container :after,.gp-select-search .select-search-container :before{box-sizing:inherit}.gp-select-search .select-search-input{-webkit-appearance:none;border:1px solid var(--select-search-border);border-radius:3px;color:var(--select-search-text);display:block;font-size:13px;height:30px;letter-spacing:.01rem;line-height:30px;outline:none;padding:0 8px 0 26px;position:relative;text-align:right;text-overflow:ellipsis;width:100%;z-index:1;-webkit-font-smoothing:antialiased;background:var(--select-search-background) url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20width%3D%2220%22%20height%3D%2220%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M5%206l5%205%205-5%202%201-7%207-7-7%202-1z%22%20fill%3D%22%23555%22%2F%3E%3C%2Fsvg%3E") no-repeat left 5px top 55%;background-size:13px 13px}.gp-select-search .select-search-is-multiple .select-search-input{border-radius:3px 3px 0 0;margin-bottom:-2px}.gp-select-search .select-search-input::-webkit-search-cancel-button,.gp-select-search .select-search-input::-webkit-search-decoration,.gp-select-search .select-search-input::-webkit-search-results-button,.gp-select-search .select-search-input::-webkit-search-results-decoration{-webkit-appearance:none}.gp-select-search .select-search-input[readonly]{cursor:pointer}.gp-select-search .select-search-is-disabled .select-search-input{cursor:not-allowed}.gp-select-search .select-search-container:not(.select-search-is-disabled) .select-search-input:hover,.gp-select-search .select-search-container:not(.select-search-is-disabled).select-search-has-focus .select-search-input{border-color:var(--select-search-selected)}.gp-select-search .select-search-select{background:var(--select-search-background);border:1px solid var(--select-search-border);box-shadow:0 .0625rem .125rem #00000026;max-height:360px;overflow:auto}.gp-select-search .select-search-container:not(.select-search-is-multiple) .select-search-select{border-radius:3px;display:none;right:0;position:absolute;left:0;top:35px;z-index:2}.gp-select-search .select-search-container:not(.select-search-is-multiple).select-search-has-focus .select-search-select{display:block}.gp-select-search .select-search-has-focus .select-search-select{border-color:var(--select-search-selected)}.gp-select-search .select-search-options{list-style:none}.gp-select-search .select-search-not-found,.gp-select-search .select-search-option{background:var(--select-search-background);border:none;color:var(--select-search-text);cursor:pointer;display:block;font-family:monospace;font-size:11px;height:30px;letter-spacing:.01rem;outline:none;padding:0 8px;text-align:right;width:100%;-webkit-font-smoothing:antialiased}.gp-select-search .select-search-option:disabled{background:#0000!important;cursor:not-allowed;opacity:.5}.gp-select-search .select-search-is-highlighted,.gp-select-search .select-search-option:not(.select-search-is-selected):hover{background:var(--select-search-highlight)}.gp-select-search .select-search-is-selected{color:var(--select-search-selected);font-weight:700}.gp-select-search .select-search-group-header{font-size:12px;font-weight:700;letter-spacing:.1rem;padding:10px 8px;text-transform:uppercase}
|
||||
1
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/block-elements.asset.php
vendored
Normal file
1
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/block-elements.asset.php
vendored
Normal file
@ -0,0 +1 @@
|
||||
<?php return array('dependencies' => array('lodash', 'react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-dom-ready', 'wp-edit-post', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-server-side-render'), 'version' => '3e4b04d9f2c101e0232f');
|
||||
7
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/block-elements.css
vendored
Normal file
7
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/block-elements.css
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
.inline-post-meta-area.block-editor-block-list__layout,.inline-post-meta-area>.gb-inside-container.block-editor-block-list__layout,.inline-post-meta-area>.gb-inside-container>.block-editor-inner-blocks>.block-editor-block-list__layout{align-items:center;display:flex}.inline-post-meta-area.block-editor-block-list__layout>.wp-block.block-list-appender,.inline-post-meta-area>.gb-inside-container.block-editor-block-list__layout>.wp-block.block-list-appender,.inline-post-meta-area>.gb-inside-container>.block-editor-inner-blocks>.block-editor-block-list__layout>.wp-block.block-list-appender{margin-left:20px}.inline-post-meta-area.block-editor-block-list__layout>.wp-block-image,.inline-post-meta-area>.gb-inside-container.block-editor-block-list__layout>.wp-block-image,.inline-post-meta-area>.gb-inside-container>.block-editor-inner-blocks>.block-editor-block-list__layout>.wp-block-image{line-height:0}.inline-post-meta-area.block-editor-block-list__layout>.wp-block-image figcaption,.inline-post-meta-area>.gb-inside-container.block-editor-block-list__layout>.wp-block-image figcaption,.inline-post-meta-area>.gb-inside-container>.block-editor-inner-blocks>.block-editor-block-list__layout>.wp-block-image figcaption{display:none}.inline-post-meta-area .wp-block{margin-left:0;margin-right:0}.gpp-dynamic-container-bg-dropdown .components-popover__content{width:275px}.gpp-dynamic-container-bg-dropdown .components-popover__content .components-base-control:not(:last-child){margin-bottom:20px}.gpp-dynamic-container-bg-dropdown .components-popover__content .components-base-control:last-child .components-base-control__field{margin-bottom:0}.gpp-dynamic-container-bg-dropdown .components-popover__content .components-base-control:last-child .components-base-control__help{margin-top:3px}
|
||||
.gpp-dynamic-headline-text-dropdown .components-popover__content{width:275px}.gpp-dynamic-headline-text-dropdown .components-popover__content .components-base-control:not(:last-child){margin-bottom:20px}.gpp-dynamic-headline-text-dropdown .components-popover__content .components-base-control:last-child .components-base-control__field{margin-bottom:0}.gpp-dynamic-headline-text-dropdown .components-popover__content .components-base-control:last-child .components-base-control__help{margin-top:3px}.gpp-blocks-dynamic-text-replace-field{display:none}.gpp-block-dynamic-year .components-base-control__help{margin-top:2px}
|
||||
.wp-block[data-type="generatepress/dynamic-content"]{margin-bottom:0;margin-top:0}
|
||||
.wp-block[data-type="generatepress/dynamic-image"]{color:#fff;margin-bottom:0;margin-top:0}.wp-block[data-type="generatepress/dynamic-image"] .components-gpp-dynamic-image-placeholder__label{align-items:center;bottom:0;color:#fff;display:flex;font-size:1em;justify-content:center;left:0;position:absolute;right:0;top:0}.wp-block[data-type="generatepress/dynamic-image"] .components-gpp-dynamic-image-placeholder__label>.gpp-dynamic-featured-image__label{margin-left:10px}.wp-block[data-type="generatepress/dynamic-image"] .gpp-dynamic-image-placeholder{background:#000;vertical-align:middle}.wp-block[data-type="generatepress/dynamic-image"] .components-placeholder{width:100%}.wp-block[data-type="generatepress/dynamic-image"] .gpp-dynamic-image-preview{display:inline-block;position:relative}.wp-block[data-type="generatepress/dynamic-image"] .dynamic-author-image-rounded{border-radius:100%}
|
||||
.components-generatepress-units-control-header__units{align-items:center;display:flex;justify-content:space-between;margin-bottom:5px}.components-generatepress-control__units .components-generatepress-control-buttons__units button.components-button{background:#fff;border:0;border-radius:0!important;box-shadow:none!important;color:#929da7;font-size:10px;height:auto;line-height:20px;padding:0 5px;position:relative;text-align:center;text-shadow:none}.components-generatepress-control__units .components-generatepress-control-buttons__units button.components-button.is-primary{background:#fff!important;color:#000!important;cursor:default;font-weight:700;z-index:1}
|
||||
.editor-styles-wrapper .is-root-container>.wp-block{margin-left:auto;margin-right:auto;max-width:var(--gp-block-element-width)}.left-sidebar-block-type div:not(.block-editor-inner-blocks)>.block-editor-block-list__layout,.right-sidebar-block-type div:not(.block-editor-inner-blocks)>.block-editor-block-list__layout{padding:10px}.gpp-block-element-panel>.components-base-control{margin-bottom:20px}.gpp-block-element-panel .components-notice,.gpp-block-element-panel .components-notice .components-notice__content{margin:0}.gpp-element-panel-label .components-panel__body-toggle.components-button{display:flex;flex-direction:row-reverse;justify-content:flex-end}.gpp-element-panel-label .components-panel__body-toggle.components-button svg.components-panel__icon{margin:0 10px 0 0}button.gpp-block-elements-template-button{background:#fff;border:1px solid #ddd;border-radius:5px;cursor:pointer;margin:0 0 10px;padding:5px}button.gpp-block-elements-template-button:hover{border-color:var(--wp-admin-theme-color)}button.gpp-block-elements-template-button .gpp-block-template-label{color:#888;font-size:13px;padding:5px}.element-has-parent #generate_premium_elements{display:none}.gpp-block-element-template-panel{background:#fafafa}
|
||||
.gp-select-search .select-search-container{--select-search-background:#fff;--select-search-border:#949494;--select-search-selected:var(--wp-admin-theme-color);--select-search-text:#2c3338;--select-search-subtle-text:#6c6f85;--select-search-inverted-text:var(--select-search-background);--select-search-highlight:#eff1f5;box-sizing:border-box;color:var(--select-search-text);font-family:var(--select-search-font);position:relative;width:100%}.gp-select-search .select-search-container *,.gp-select-search .select-search-container :after,.gp-select-search .select-search-container :before{box-sizing:inherit}.gp-select-search .select-search-input{-webkit-appearance:none;border:1px solid var(--select-search-border);border-radius:3px;color:var(--select-search-text);display:block;font-size:13px;height:30px;letter-spacing:.01rem;line-height:30px;outline:none;padding:0 26px 0 8px;position:relative;text-align:left;text-overflow:ellipsis;width:100%;z-index:1;-webkit-font-smoothing:antialiased;background:var(--select-search-background) url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20width%3D%2220%22%20height%3D%2220%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M5%206l5%205%205-5%202%201-7%207-7-7%202-1z%22%20fill%3D%22%23555%22%2F%3E%3C%2Fsvg%3E") no-repeat right 5px top 55%;background-size:13px 13px}.gp-select-search .select-search-is-multiple .select-search-input{border-radius:3px 3px 0 0;margin-bottom:-2px}.gp-select-search .select-search-input::-webkit-search-cancel-button,.gp-select-search .select-search-input::-webkit-search-decoration,.gp-select-search .select-search-input::-webkit-search-results-button,.gp-select-search .select-search-input::-webkit-search-results-decoration{-webkit-appearance:none}.gp-select-search .select-search-input[readonly]{cursor:pointer}.gp-select-search .select-search-is-disabled .select-search-input{cursor:not-allowed}.gp-select-search .select-search-container:not(.select-search-is-disabled) .select-search-input:hover,.gp-select-search .select-search-container:not(.select-search-is-disabled).select-search-has-focus .select-search-input{border-color:var(--select-search-selected)}.gp-select-search .select-search-select{background:var(--select-search-background);border:1px solid var(--select-search-border);box-shadow:0 .0625rem .125rem #00000026;max-height:360px;overflow:auto}.gp-select-search .select-search-container:not(.select-search-is-multiple) .select-search-select{border-radius:3px;display:none;left:0;position:absolute;right:0;top:35px;z-index:2}.gp-select-search .select-search-container:not(.select-search-is-multiple).select-search-has-focus .select-search-select{display:block}.gp-select-search .select-search-has-focus .select-search-select{border-color:var(--select-search-selected)}.gp-select-search .select-search-options{list-style:none}.gp-select-search .select-search-not-found,.gp-select-search .select-search-option{background:var(--select-search-background);border:none;color:var(--select-search-text);cursor:pointer;display:block;font-family:monospace;font-size:11px;height:30px;letter-spacing:.01rem;outline:none;padding:0 8px;text-align:left;width:100%;-webkit-font-smoothing:antialiased}.gp-select-search .select-search-option:disabled{background:#0000!important;cursor:not-allowed;opacity:.5}.gp-select-search .select-search-is-highlighted,.gp-select-search .select-search-option:not(.select-search-is-selected):hover{background:var(--select-search-highlight)}.gp-select-search .select-search-is-selected{color:var(--select-search-selected);font-weight:700}.gp-select-search .select-search-group-header{font-size:12px;font-weight:700;letter-spacing:.1rem;padding:10px 8px;text-transform:uppercase}
|
||||
3
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/block-elements.js
vendored
Normal file
3
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/block-elements.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/customizer.asset.php
vendored
Normal file
1
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/customizer.asset.php
vendored
Normal file
@ -0,0 +1 @@
|
||||
<?php return array('dependencies' => array('wp-hooks', 'wp-i18n'), 'version' => '542c4e5db7eed60770ec');
|
||||
1
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/customizer.js
vendored
Normal file
1
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/customizer.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
(()=>{"use strict";const e=window.wp.hooks,o=window.wp.i18n;(0,e.addFilter)("generate_typography_element_groups","generatepress-pro/customizer/add-typography-groups",(function(e){const a={};return gpCustomizerControls.hasSecondaryNav&&(a.secondaryNavigation=(0,o.__)("Secondary Navigation","gp-premium")),gpCustomizerControls.hasMenuPlus&&(a.offCanvasPanel=(0,o.__)("Off-Canvas Panel","gp-premium")),gpCustomizerControls.hasWooCommerce&&(a.wooCommerce=(0,o.__)("WooCommerce","gp-premium")),{...e,...a}})),(0,e.addFilter)("generate_typography_elements","generatepress-pro/customizer/add-typography-elements",(function(e){const a={};return gpCustomizerControls.hasSecondaryNav&&(a["secondary-nav-menu-items"]={module:"secondary-nav",group:"secondaryNavigation",label:(0,o.__)("Secondary Menu Items","gp-premium"),placeholders:{fontSize:{value:"13",min:6,max:30,step:1}}},a["secondary-nav-sub-menu-items"]={module:"secondary-nav",group:"secondaryNavigation",label:(0,o.__)("Secondary Sub-Menu Items","gp-premium"),placeholders:{fontSize:{value:"12",min:6,max:30,step:1}}},a["secondary-nav-menu-toggle"]={module:"secondary-nav",group:"secondaryNavigation",label:(0,o.__)("Secondary Mobile Menu Toggle","gp-premium"),placeholders:{fontSize:{value:"13",min:6,max:30,step:1}}}),gpCustomizerControls.hasMenuPlus&&(a["off-canvas-panel-menu-items"]={module:"off-canvas-panel",group:"offCanvasPanel",label:(0,o.__)("Off-Canvas Menu Items","gp-premium"),placeholders:{fontSize:{value:"",min:6,max:30,step:1}}},a["off-canvas-panel-sub-menu-items"]={module:"off-canvas-panel",group:"offCanvasPanel",label:(0,o.__)("Off-Canvas Sub-Menu Items","gp-premium"),placeholders:{fontSize:{value:"",min:6,max:30,step:1}}}),gpCustomizerControls.hasWooCommerce&&(a["woocommerce-catalog-product-titles"]={module:"woocommerce",group:"wooCommerce",label:(0,o.__)("Catalog Product Titles","gp-premium"),placeholders:{fontSize:{value:"",min:6,max:50,step:1}}},a["woocommerce-related-product-titles"]={module:"woocommerce",group:"wooCommerce",label:(0,o.__)("Related/Upsell Product Titles","gp-premium"),placeholders:{fontSize:{value:"",min:6,max:50,step:1}}}),{...e,...a}}))})();
|
||||
1
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/dashboard.asset.php
vendored
Normal file
1
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/dashboard.asset.php
vendored
Normal file
@ -0,0 +1 @@
|
||||
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-components', 'wp-element', 'wp-i18n'), 'version' => '6a732fdaaa86f685bd9f');
|
||||
1
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/dashboard.js
vendored
Normal file
1
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/dashboard.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/editor-rtl.css
vendored
Normal file
1
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/editor-rtl.css
vendored
Normal file
@ -0,0 +1 @@
|
||||
.gpp-active-element-type{color:#555;font-size:11px;text-transform:uppercase}
|
||||
1
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/editor.asset.php
vendored
Normal file
1
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/editor.asset.php
vendored
Normal file
@ -0,0 +1 @@
|
||||
<?php return array('dependencies' => array('react', 'wp-edit-post', 'wp-element', 'wp-html-entities', 'wp-i18n', 'wp-plugins'), 'version' => '81f036c27194ee54b73d');
|
||||
1
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/editor.css
vendored
Normal file
1
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/editor.css
vendored
Normal file
@ -0,0 +1 @@
|
||||
.gpp-active-element-type{color:#555;font-size:11px;text-transform:uppercase}
|
||||
1
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/editor.js
vendored
Normal file
1
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/editor.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
(()=>{"use strict";const e=window.React,t=window.wp.i18n,n=window.wp.plugins,l=window.wp.editPost,i=window.wp.element,m=window.wp.htmlEntities;class s extends i.Component{render(){const n=gpPremiumEditor.activeElements;return!n||n.length<1?null:gpPremiumEditor.postTypeIsPublic?(0,e.createElement)(l.PluginDocumentSettingPanel,{name:"generatepress-elements-info",title:(0,t.__)("Active Elements","gp-premium"),className:"gpp-element-info-panel gpp-element-panel-label"},(0,e.createElement)(i.Fragment,null,(0,e.createElement)("ul",{className:"gpp-active-elements"},Object.keys(n).map(((t,l)=>(0,e.createElement)("li",{key:`gpp-active-block-element-${l}`},(0,e.createElement)("a",{href:n[t].url+"&action=edit"},(0,m.decodeEntities)(n[t].name))," ",(0,e.createElement)("span",{className:"gpp-active-element-type"},"- ",n[t].type))))),(0,e.createElement)("a",{href:gpPremiumEditor.elementsUrl,className:"components-button is-secondary"},(0,t.__)("All Elements","gp-premium")))):null}}(0,n.registerPlugin)("generatepress-elements-info-panel",{icon:null,render:s})})();
|
||||
1
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/font-library-rtl.css
vendored
Normal file
1
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/font-library-rtl.css
vendored
Normal file
@ -0,0 +1 @@
|
||||
.gp-font-library{box-sizing:border-box;margin:40px auto 0;max-width:1200px;padding:0 20px}.gp-font-library .components-tab-panel__tabs{background-color:#fff;border-bottom:1px solid #e7e7e7}.gp-font-library .components-tab-panel__tabs .components-tab-panel__tabs-item{padding:30px 20px}.gp-font-library .components-tab-panel__tabs .components-tab-panel__tabs-item.active-tab{color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9))}.gp-font-library .components-tab-panel__tabs .components-tab-panel__tabs-item:first-child{margin-right:20px}.gp-font-library .components-tab-panel__tabs .gp-tab-header{font-size:14px}.gp-font-library .components-tab-panel__tab-content{background-color:#fff;box-sizing:border-box;margin:0 auto;max-width:1200px;min-height:600px;padding:30px 40px}.gp-font-library .components-tab-panel__tab-content h2{font-size:20px;line-height:1.2em;margin-bottom:20px;margin-top:0}.gp-font-library__text{max-width:700px}.gp-font-library__list{font-size:16px}.gp-font-library__list li{margin-bottom:0}.gp-font-library__list li+li{margin-top:-1px}.gp-font-library__notice{margin-bottom:30px}.gp-font-library__results li{align-items:center;display:flex;gap:2px}.gp-font-library__result--success svg{fill:#4ab866}.gp-font-library__result--failure svg{fill:#cc1818}.gp-font-library-authorize-fonts{border:1px solid #aaa;border-radius:3px;margin:50px auto 0;max-width:350px;padding:25px}.gp-font-library-authorize-fonts h3{font-size:1.5em;margin-top:10px}.gp-font-library-authorize-fonts .components-button{margin:10px 0}.gp-font-library-variant{padding:30px}.gp-font-library-variant__header{display:flex;justify-content:space-between}.gp-font-library-variant__label{color:#777;font-size:14px}.gp-font-library-card{align-items:center;border:1px solid #e0e0e0;display:flex;font-style:italic;gap:10px;height:auto;padding:16px;text-align:right;width:100%}.gp-font-library-card :where(input,label),.gp-font-library-card:where(button,a){cursor:pointer}.gp-font-library-card+.gp-font-library-card{margin-top:-1px}.gp-font-library-card__variants{align-items:center;display:flex;gap:10px;margin-right:auto}.gp-font-library-card__categories{margin:auto;min-width:7.69em;text-transform:capitalize}.gp-font-library-card .gp-font-library-preview{min-width:25%}.gp-font-library-card:hover img{filter:invert(39%) sepia(67%) saturate(7078%) hue-rotate(213deg) brightness(96%) contrast(98%)}.gp-font-library-preview{align-items:center;display:flex;font-style:normal}.gp-font-library-preview__image{display:block;max-width:100%}.gp-font-library-preview__fallback{font-size:19px}.gp-font-library-edit h3{margin-top:20px}.gp-font-library-edit__control-notice{max-width:500px}.gp-font-library-edit__control label{display:block}.gp-font-library-edit__control .components-input-control__container,.gp-font-library-edit__control input[type=text]{max-width:250px!important}.gp-font-library-edit__footer{margin-top:40px}.gp-font-library-edit__variants{list-style:none;padding-right:0;width:250px}.gp-font-library-edit__variant{align-items:center;display:flex;justify-content:space-between}.gp-font-library-edit__variant .components-checkbox-control{--checkbox-input-size:24px}.gp-font-library-edit__variant .components-checkbox-control .components-base-control__field{align-items:center;display:flex}.gp-font-library-edit__variant--delete .components-checkbox-control{opacity:.5;text-decoration:line-through}.gp-font-library-edit__advanced{margin-bottom:20px}.gp-font-library-edit__advanced>.gb-stack{margin-top:20px}.gp-font-library-google__header-container{container-type:inline-size}.gp-font-library-google__header{align-items:flex-start;display:flex;margin-bottom:30px}.gp-font-library-google__header-content{flex-grow:1}.gp-font-library-google__header-content>:last-child{margin-bottom:0}.gp-font-library-google__header-content h2{margin-top:0}.gp-font-library-google__description{width:100%}.gp-font-library-google__filters{display:flex;flex-wrap:wrap;gap:10px;justify-content:space-between;margin-bottom:10px}.gp-font-library-google__filters select{height:40px!important}.gp-font-library-google__results{font-size:12px;font-style:italic;font-weight:500}.gp-font-library-google__results .components-button{margin-right:1em}.gp-font-library-google__pagination{align-items:flex-end;display:flex;gap:10px}.gp-font-library-google__pagination-numbers{align-items:center;display:flex;gap:10px;margin-left:auto}.gp-font-library-google__footer{align-items:center;display:flex;flex-wrap:wrap;gap:10px}.gp-font-library-settings{width:500px}.gp-font-library-settings__controls{margin-bottom:40px}.gp-font-library-settings__controls .components-base-control>:last-child{margin-bottom:0}.gp-font-library-settings__auth{background-color:#cc181833;border:1px solid #cc1818;border-radius:4px;font-size:14px;padding:10px}.gp-font-library-settings__auth :first-child{margin-top:0}.gp-font-library-settings__auth :last-child{margin-bottom:0}
|
||||
1
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/font-library.asset.php
vendored
Normal file
1
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/font-library.asset.php
vendored
Normal file
@ -0,0 +1 @@
|
||||
<?php return array('dependencies' => array('lodash', 'react', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => '70fe87ecb0efc8fb0659');
|
||||
1
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/font-library.css
vendored
Normal file
1
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/font-library.css
vendored
Normal file
@ -0,0 +1 @@
|
||||
.gp-font-library{box-sizing:border-box;margin:40px auto 0;max-width:1200px;padding:0 20px}.gp-font-library .components-tab-panel__tabs{background-color:#fff;border-bottom:1px solid #e7e7e7}.gp-font-library .components-tab-panel__tabs .components-tab-panel__tabs-item{padding:30px 20px}.gp-font-library .components-tab-panel__tabs .components-tab-panel__tabs-item.active-tab{color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9))}.gp-font-library .components-tab-panel__tabs .components-tab-panel__tabs-item:first-child{margin-left:20px}.gp-font-library .components-tab-panel__tabs .gp-tab-header{font-size:14px}.gp-font-library .components-tab-panel__tab-content{background-color:#fff;box-sizing:border-box;margin:0 auto;max-width:1200px;min-height:600px;padding:30px 40px}.gp-font-library .components-tab-panel__tab-content h2{font-size:20px;line-height:1.2em;margin-bottom:20px;margin-top:0}.gp-font-library__text{max-width:700px}.gp-font-library__list{font-size:16px}.gp-font-library__list li{margin-bottom:0}.gp-font-library__list li+li{margin-top:-1px}.gp-font-library__notice{margin-bottom:30px}.gp-font-library__results li{align-items:center;display:flex;gap:2px}.gp-font-library__result--success svg{fill:#4ab866}.gp-font-library__result--failure svg{fill:#cc1818}.gp-font-library-authorize-fonts{border:1px solid #aaa;border-radius:3px;margin:50px auto 0;max-width:350px;padding:25px}.gp-font-library-authorize-fonts h3{font-size:1.5em;margin-top:10px}.gp-font-library-authorize-fonts .components-button{margin:10px 0}.gp-font-library-variant{padding:30px}.gp-font-library-variant__header{display:flex;justify-content:space-between}.gp-font-library-variant__label{color:#777;font-size:14px}.gp-font-library-card{align-items:center;border:1px solid #e0e0e0;display:flex;font-style:italic;gap:10px;height:auto;padding:16px;text-align:left;width:100%}.gp-font-library-card :where(input,label),.gp-font-library-card:where(button,a){cursor:pointer}.gp-font-library-card+.gp-font-library-card{margin-top:-1px}.gp-font-library-card__variants{align-items:center;display:flex;gap:10px;margin-left:auto}.gp-font-library-card__categories{margin:auto;min-width:7.69em;text-transform:capitalize}.gp-font-library-card .gp-font-library-preview{min-width:25%}.gp-font-library-card:hover img{filter:invert(39%) sepia(67%) saturate(7078%) hue-rotate(213deg) brightness(96%) contrast(98%)}.gp-font-library-preview{align-items:center;display:flex;font-style:normal}.gp-font-library-preview__image{display:block;max-width:100%}.gp-font-library-preview__fallback{font-size:19px}.gp-font-library-edit h3{margin-top:20px}.gp-font-library-edit__control-notice{max-width:500px}.gp-font-library-edit__control label{display:block}.gp-font-library-edit__control .components-input-control__container,.gp-font-library-edit__control input[type=text]{max-width:250px!important}.gp-font-library-edit__footer{margin-top:40px}.gp-font-library-edit__variants{list-style:none;padding-left:0;width:250px}.gp-font-library-edit__variant{align-items:center;display:flex;justify-content:space-between}.gp-font-library-edit__variant .components-checkbox-control{--checkbox-input-size:24px}.gp-font-library-edit__variant .components-checkbox-control .components-base-control__field{align-items:center;display:flex}.gp-font-library-edit__variant--delete .components-checkbox-control{opacity:.5;text-decoration:line-through}.gp-font-library-edit__advanced{margin-bottom:20px}.gp-font-library-edit__advanced>.gb-stack{margin-top:20px}.gp-font-library-google__header-container{container-type:inline-size}.gp-font-library-google__header{align-items:flex-start;display:flex;margin-bottom:30px}.gp-font-library-google__header-content{flex-grow:1}.gp-font-library-google__header-content>:last-child{margin-bottom:0}.gp-font-library-google__header-content h2{margin-top:0}.gp-font-library-google__description{width:100%}.gp-font-library-google__filters{display:flex;flex-wrap:wrap;gap:10px;justify-content:space-between;margin-bottom:10px}.gp-font-library-google__filters select{height:40px!important}.gp-font-library-google__results{font-size:12px;font-style:italic;font-weight:500}.gp-font-library-google__results .components-button{margin-left:1em}.gp-font-library-google__pagination{align-items:flex-end;display:flex;gap:10px}.gp-font-library-google__pagination-numbers{align-items:center;display:flex;gap:10px;margin-right:auto}.gp-font-library-google__footer{align-items:center;display:flex;flex-wrap:wrap;gap:10px}.gp-font-library-settings{width:500px}.gp-font-library-settings__controls{margin-bottom:40px}.gp-font-library-settings__controls .components-base-control>:last-child{margin-bottom:0}.gp-font-library-settings__auth{background-color:#cc181833;border:1px solid #cc1818;border-radius:4px;font-size:14px;padding:10px}.gp-font-library-settings__auth :first-child{margin-top:0}.gp-font-library-settings__auth :last-child{margin-bottom:0}
|
||||
11
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/font-library.js
vendored
Normal file
11
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/font-library.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/packages-rtl.css
vendored
Normal file
2
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/packages-rtl.css
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
.mnc9nIWbe_UvWqh_EGSg{position:relative;width:100%}.lvIdqq0VcOc4Fsgp6edt{display:flex;gap:0 4px}.JQD57VZha1Nz_puhbEGL{flex-grow:1;position:relative}.uPu9muJa3zAmugfyIwKm[type=text]{appearance:none;border-color:#8c8f94;border-radius:3px;box-shadow:none;color:#2c3338;cursor:pointer;font-size:16px;line-height:2;min-height:30px;min-width:0;padding:0 8px 0 24px;vertical-align:middle;width:100%}@media(min-width:600px){.uPu9muJa3zAmugfyIwKm[type=text]{font-size:13px}}.uPu9muJa3zAmugfyIwKm[type=text].WNS5v6eZssWgR0abiuiV{outline-offset:2px}.uPu9muJa3zAmugfyIwKm[type=text].MgYZFTRJHzGT5kJMx1EN{padding-left:44px}.BI9El7N6XuVkzJ0yYqjN{display:block;height:12px;width:12px}.FIMlw2_F2weKvrhreh8G{background:#0000;border:none;box-shadow:none;height:100%;left:0;top:0}.FIMlw2_F2weKvrhreh8G,.HfEDCyNjbWPw8DWxXwEJ{position:absolute}.HfEDCyNjbWPw8DWxXwEJ{background-color:#fff;border:1px solid #d3d6d9;color:#0b0c0c;margin:8px 0 0;max-height:342px;overflow-x:hidden;padding:0;transform:translateZ(0);width:calc(100% - 2px);z-index:200}.HfEDCyNjbWPw8DWxXwEJ.GguvZjj87n5NGDn8J2P6{display:block}.HfEDCyNjbWPw8DWxXwEJ.BJaSrnsPhERUxtRDC6Vu{display:none}.GzNl93gsU8KelMCsQSyZ{border-bottom:1px solid #d3d6d9;border-right-width:0;border-left-width:0;border-top-width:1px;cursor:pointer;display:block;margin:0;padding:7px;position:relative}.GzNl93gsU8KelMCsQSyZ>*{pointer-events:none}.GzNl93gsU8KelMCsQSyZ:first-of-type{border-top-width:0}.GzNl93gsU8KelMCsQSyZ:last-of-type{border-bottom-width:0;margin-bottom:0}.GzNl93gsU8KelMCsQSyZ:where(:nth-child(odd)){background-color:#fafafa}.GzNl93gsU8KelMCsQSyZ.WNS5v6eZssWgR0abiuiV,.GzNl93gsU8KelMCsQSyZ:hover{background-color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9));border-color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9));color:#fff;outline:0}.kUveEVlY9D_n5Zmz_dXD{height:30px!important;min-width:16px!important;padding:0!important;position:absolute;left:24px;top:0;width:16px!important}@media(-ms-high-contrast:active),(forced-colors:active){.HfEDCyNjbWPw8DWxXwEJ{border-color:FieldText}.GzNl93gsU8KelMCsQSyZ{background-color:Field;color:FieldText}.GzNl93gsU8KelMCsQSyZ:hover,.HKlvLGhxs7ir32hUBNzQ{background-color:SelectedItem;border-color:SelectedItem;color:SelectedItemText;forced-color-adjust:none;outline-color:SelectedItemText}}.Uy2rTDWqjs4vgNH0aeBm .components-base-control__field{align-items:center;display:flex}.Uy2rTDWqjs4vgNH0aeBm .components-base-control__field .components-base-control__label{flex:1;margin:0}.qLXIpwst_CtGTtmsg3mN{height:auto;min-height:auto;padding:4px}.UVmA1eywUsKVQzLMDooq{background:linear-gradient(45deg,#0000 48%,#0003 0,#0003 52%,#0000 0);border:1px solid #0003;border-radius:50%;height:25px;width:25px}.eTonGpRD1VuB2tbLNegK .components-popover__content{max-width:365px;min-width:max-content;padding:15px}.eTonGpRD1VuB2tbLNegK .components-popover__content>div{padding:0}.eTonGpRD1VuB2tbLNegK .components-base-control__field{margin-bottom:0}.eTonGpRD1VuB2tbLNegK .react-colorful{width:100%!important}.eTonGpRD1VuB2tbLNegK .react-colorful .react-colorful__pointer{height:20px;width:20px}.eTonGpRD1VuB2tbLNegK .react-colorful .react-colorful__saturation{height:150px}.eTonGpRD1VuB2tbLNegK .components-circular-option-picker__option-wrapper{height:25px;width:25px}.nc5TMqH__oA5bcPGTm0D{display:flex;margin-top:15px}.nc5TMqH__oA5bcPGTm0D ._ubMuvqZvhc0awiEVNAL{flex:1}.nc5TMqH__oA5bcPGTm0D .f5wwshdAOOkfChALEoo2{height:auto}.nc5TMqH__oA5bcPGTm0D .components-base-control__field{margin-bottom:0}.OhNX_C7EMJcWKe5tqpKQ{margin-top:15px}.OhNX_C7EMJcWKe5tqpKQ .components-circular-option-picker{display:flex;flex-wrap:wrap}.OhNX_C7EMJcWKe5tqpKQ .components-circular-option-picker .components-circular-option-picker__swatches{display:flex;flex-wrap:wrap;gap:6px}.OhNX_C7EMJcWKe5tqpKQ .components-circular-option-picker .components-circular-option-picker__swatches .components-circular-option-picker__option-wrapper{margin:0}.mos6VIbAjooq2LMyKr88{display:flex;margin-top:15px}.mos6VIbAjooq2LMyKr88 .components-range-control{flex-grow:1;padding-right:5px}.UFXv660XisMp2k7oIkOA{margin:0}.cuno_GtO4bhcM59n00B2{--icon-size:1rem;display:grid;gap:.625rem;grid-template-columns:36px minmax(0,1fr);position:relative}.cuno_GtO4bhcM59n00B2 .components-button svg{display:block;height:var(--icon-size);width:var(--icon-size)}.fOOS92b6g0h9pAqn_2JI{border-radius:0;height:100%;position:relative;z-index:2}.rDe4XxEMyRee1hSKKXzn{display:flex;flex-wrap:wrap;gap:var(--gap,10px)}.Yg1nkwz9mFYMuk6zv1DW.b6i6J_7eUIspcsEZ3Qia>*+*{margin-inline-start:var(--gap,10px)}.dfG8sfdNVPzQp7pqgYJQ.b6i6J_7eUIspcsEZ3Qia>*+*{margin-block-start:var(--gap,10px)}.dfG8sfdNVPzQp7pqgYJQ.rDe4XxEMyRee1hSKKXzn{flex-direction:column}.l03h0IHl5WOI4XvelHt3{border-collapse:collapse;width:100%}.l03h0IHl5WOI4XvelHt3 td,.l03h0IHl5WOI4XvelHt3 th{box-sizing:border-box}.l03h0IHl5WOI4XvelHt3.pz9cxM_c8wpWcOh3bw5v tr:nth-child(2n){background-color:rgba(var(--wp-admin-theme-color--rgb),.04)}
|
||||
|
||||
1
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/packages.asset.php
vendored
Normal file
1
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/packages.asset.php
vendored
Normal file
@ -0,0 +1 @@
|
||||
<?php return array('dependencies' => array(), 'version' => '50ca20852d9e1cd8d9dc');
|
||||
2
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/packages.css
vendored
Normal file
2
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/packages.css
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
.mnc9nIWbe_UvWqh_EGSg{position:relative;width:100%}.lvIdqq0VcOc4Fsgp6edt{display:flex;gap:0 4px}.JQD57VZha1Nz_puhbEGL{flex-grow:1;position:relative}.uPu9muJa3zAmugfyIwKm[type=text]{appearance:none;border-color:#8c8f94;border-radius:3px;box-shadow:none;color:#2c3338;cursor:pointer;font-size:16px;line-height:2;min-height:30px;min-width:0;padding:0 24px 0 8px;vertical-align:middle;width:100%}@media(min-width:600px){.uPu9muJa3zAmugfyIwKm[type=text]{font-size:13px}}.uPu9muJa3zAmugfyIwKm[type=text].WNS5v6eZssWgR0abiuiV{outline-offset:2px}.uPu9muJa3zAmugfyIwKm[type=text].MgYZFTRJHzGT5kJMx1EN{padding-right:44px}.BI9El7N6XuVkzJ0yYqjN{display:block;height:12px;width:12px}.FIMlw2_F2weKvrhreh8G{background:#0000;border:none;box-shadow:none;height:100%;right:0;top:0}.FIMlw2_F2weKvrhreh8G,.HfEDCyNjbWPw8DWxXwEJ{position:absolute}.HfEDCyNjbWPw8DWxXwEJ{background-color:#fff;border:1px solid #d3d6d9;color:#0b0c0c;margin:8px 0 0;max-height:342px;overflow-x:hidden;padding:0;transform:translateZ(0);width:calc(100% - 2px);z-index:200}.HfEDCyNjbWPw8DWxXwEJ.GguvZjj87n5NGDn8J2P6{display:block}.HfEDCyNjbWPw8DWxXwEJ.BJaSrnsPhERUxtRDC6Vu{display:none}.GzNl93gsU8KelMCsQSyZ{border-bottom:1px solid #d3d6d9;border-left-width:0;border-right-width:0;border-top-width:1px;cursor:pointer;display:block;margin:0;padding:7px;position:relative}.GzNl93gsU8KelMCsQSyZ>*{pointer-events:none}.GzNl93gsU8KelMCsQSyZ:first-of-type{border-top-width:0}.GzNl93gsU8KelMCsQSyZ:last-of-type{border-bottom-width:0;margin-bottom:0}.GzNl93gsU8KelMCsQSyZ:where(:nth-child(odd)){background-color:#fafafa}.GzNl93gsU8KelMCsQSyZ.WNS5v6eZssWgR0abiuiV,.GzNl93gsU8KelMCsQSyZ:hover{background-color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9));border-color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9));color:#fff;outline:0}.kUveEVlY9D_n5Zmz_dXD{height:30px!important;min-width:16px!important;padding:0!important;position:absolute;right:24px;top:0;width:16px!important}@media(-ms-high-contrast:active),(forced-colors:active){.HfEDCyNjbWPw8DWxXwEJ{border-color:FieldText}.GzNl93gsU8KelMCsQSyZ{background-color:Field;color:FieldText}.GzNl93gsU8KelMCsQSyZ:hover,.HKlvLGhxs7ir32hUBNzQ{background-color:SelectedItem;border-color:SelectedItem;color:SelectedItemText;forced-color-adjust:none;outline-color:SelectedItemText}}.Uy2rTDWqjs4vgNH0aeBm .components-base-control__field{align-items:center;display:flex}.Uy2rTDWqjs4vgNH0aeBm .components-base-control__field .components-base-control__label{flex:1;margin:0}.qLXIpwst_CtGTtmsg3mN{height:auto;min-height:auto;padding:4px}.UVmA1eywUsKVQzLMDooq{background:linear-gradient(-45deg,#0000 48%,#0003 0,#0003 52%,#0000 0);border:1px solid #0003;border-radius:50%;height:25px;width:25px}.eTonGpRD1VuB2tbLNegK .components-popover__content{max-width:365px;min-width:max-content;padding:15px}.eTonGpRD1VuB2tbLNegK .components-popover__content>div{padding:0}.eTonGpRD1VuB2tbLNegK .components-base-control__field{margin-bottom:0}.eTonGpRD1VuB2tbLNegK .react-colorful{width:100%!important}.eTonGpRD1VuB2tbLNegK .react-colorful .react-colorful__pointer{height:20px;width:20px}.eTonGpRD1VuB2tbLNegK .react-colorful .react-colorful__saturation{height:150px}.eTonGpRD1VuB2tbLNegK .components-circular-option-picker__option-wrapper{height:25px;width:25px}.nc5TMqH__oA5bcPGTm0D{display:flex;margin-top:15px}.nc5TMqH__oA5bcPGTm0D ._ubMuvqZvhc0awiEVNAL{flex:1}.nc5TMqH__oA5bcPGTm0D .f5wwshdAOOkfChALEoo2{height:auto}.nc5TMqH__oA5bcPGTm0D .components-base-control__field{margin-bottom:0}.OhNX_C7EMJcWKe5tqpKQ{margin-top:15px}.OhNX_C7EMJcWKe5tqpKQ .components-circular-option-picker{display:flex;flex-wrap:wrap}.OhNX_C7EMJcWKe5tqpKQ .components-circular-option-picker .components-circular-option-picker__swatches{display:flex;flex-wrap:wrap;gap:6px}.OhNX_C7EMJcWKe5tqpKQ .components-circular-option-picker .components-circular-option-picker__swatches .components-circular-option-picker__option-wrapper{margin:0}.mos6VIbAjooq2LMyKr88{display:flex;margin-top:15px}.mos6VIbAjooq2LMyKr88 .components-range-control{flex-grow:1;padding-left:5px}.UFXv660XisMp2k7oIkOA{margin:0}.cuno_GtO4bhcM59n00B2{--icon-size:1rem;display:grid;gap:.625rem;grid-template-columns:36px minmax(0,1fr);position:relative}.cuno_GtO4bhcM59n00B2 .components-button svg{display:block;height:var(--icon-size);width:var(--icon-size)}.fOOS92b6g0h9pAqn_2JI{border-radius:0;height:100%;position:relative;z-index:2}.rDe4XxEMyRee1hSKKXzn{display:flex;flex-wrap:wrap;gap:var(--gap,10px)}.Yg1nkwz9mFYMuk6zv1DW.b6i6J_7eUIspcsEZ3Qia>*+*{margin-inline-start:var(--gap,10px)}.dfG8sfdNVPzQp7pqgYJQ.b6i6J_7eUIspcsEZ3Qia>*+*{margin-block-start:var(--gap,10px)}.dfG8sfdNVPzQp7pqgYJQ.rDe4XxEMyRee1hSKKXzn{flex-direction:column}.l03h0IHl5WOI4XvelHt3{border-collapse:collapse;width:100%}.l03h0IHl5WOI4XvelHt3 td,.l03h0IHl5WOI4XvelHt3 th{box-sizing:border-box}.l03h0IHl5WOI4XvelHt3.pz9cxM_c8wpWcOh3bw5v tr:nth-child(2n){background-color:rgba(var(--wp-admin-theme-color--rgb),.04)}
|
||||
|
||||
0
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/packages.js
vendored
Normal file
0
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/packages.js
vendored
Normal file
1
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/site-library-rtl.css
vendored
Normal file
1
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/site-library-rtl.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/site-library.asset.php
vendored
Normal file
1
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/site-library.asset.php
vendored
Normal file
@ -0,0 +1 @@
|
||||
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-components', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => 'a6719ff1717f5c4541f7');
|
||||
1
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/site-library.css
vendored
Normal file
1
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/site-library.css
vendored
Normal file
File diff suppressed because one or more lines are too long
6
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/site-library.js
vendored
Normal file
6
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/site-library.js
vendored
Normal file
File diff suppressed because one or more lines are too long
4
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/style-dashboard-rtl.css
vendored
Normal file
4
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/style-dashboard-rtl.css
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
.generatepress-module-action{display:inline-block;font-size:12px;font-weight:400;line-height:1;margin-right:10px;text-decoration:none}.generatepress-dashboard__section-item-settings{align-items:center;display:flex}.generatepress-dashboard__section-item-settings button{font-size:11px;height:30px;justify-content:center!important}.generatepress-dashboard__section-item-settings button .components-spinner{margin-top:0}.generatepress-dashboard__section-item-settings button svg{height:20px;margin:0!important;width:20px}.generatepress-dashboard__section-item-settings button:not(:last-child){margin-left:5px}
|
||||
.generatepress-license-key-area .generatepress-dashboard__section-item-message{background:#fff}.generatepress-license-key-area .generatepress-dashboard__section-item{flex-wrap:wrap;justify-content:flex-start}.generatepress-license-key-area .generatepress-dashboard__section-license-key{display:flex;flex:1}.generatepress-license-key-area .generatepress-dashboard__section-license-key .components-base-control{flex:1}.generatepress-license-key-area .generatepress-dashboard__section-license-key button{height:31px;margin-right:8px}.generatepress-license-key-area .generatepress-dashboard__section-beta-tester{align-items:center;display:flex;flex-basis:100%;margin-top:30px}.generatepress-license-key-area .generatepress-dashboard__section-license-notice{flex-basis:100%;margin:0 0 20px}.generatepress-license-key-area .components-base-control__field,.generatepress-license-key-area .components-base-control__help{margin-bottom:0}
|
||||
.generatepress-dashboard__section-item-action input[type=file]{border:1px solid #ddd;padding:5px}.generatepress-dashboard__section-item-export-popover .components-popover__content{padding:20px}
|
||||
.generatepress-dashboard__section-item-modules{margin-top:20px}
|
||||
4
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/style-dashboard.css
vendored
Normal file
4
wp-content/upgrade-temp-backup/plugins/gp-premium/dist/style-dashboard.css
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
.generatepress-module-action{display:inline-block;font-size:12px;font-weight:400;line-height:1;margin-left:10px;text-decoration:none}.generatepress-dashboard__section-item-settings{align-items:center;display:flex}.generatepress-dashboard__section-item-settings button{font-size:11px;height:30px;justify-content:center!important}.generatepress-dashboard__section-item-settings button .components-spinner{margin-top:0}.generatepress-dashboard__section-item-settings button svg{height:20px;margin:0!important;width:20px}.generatepress-dashboard__section-item-settings button:not(:last-child){margin-right:5px}
|
||||
.generatepress-license-key-area .generatepress-dashboard__section-item-message{background:#fff}.generatepress-license-key-area .generatepress-dashboard__section-item{flex-wrap:wrap;justify-content:flex-start}.generatepress-license-key-area .generatepress-dashboard__section-license-key{display:flex;flex:1}.generatepress-license-key-area .generatepress-dashboard__section-license-key .components-base-control{flex:1}.generatepress-license-key-area .generatepress-dashboard__section-license-key button{height:31px;margin-left:8px}.generatepress-license-key-area .generatepress-dashboard__section-beta-tester{align-items:center;display:flex;flex-basis:100%;margin-top:30px}.generatepress-license-key-area .generatepress-dashboard__section-license-notice{flex-basis:100%;margin:0 0 20px}.generatepress-license-key-area .components-base-control__field,.generatepress-license-key-area .components-base-control__help{margin-bottom:0}
|
||||
.generatepress-dashboard__section-item-action input[type=file]{border:1px solid #ddd;padding:5px}.generatepress-dashboard__section-item-export-popover .components-popover__content{padding:20px}
|
||||
.generatepress-dashboard__section-item-modules{margin-top:20px}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 138 B |
Binary file not shown.
|
After Width: | Height: | Size: 44 KiB |
@ -0,0 +1,211 @@
|
||||
button[data-balloon] {
|
||||
overflow: visible; }
|
||||
|
||||
[data-balloon] {
|
||||
position: relative;
|
||||
cursor: pointer; }
|
||||
[data-balloon]:after {
|
||||
filter: alpha(opacity=0);
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
|
||||
-moz-opacity: 0;
|
||||
-khtml-opacity: 0;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transition: all 0.18s ease-out 0.18s;
|
||||
font-weight: normal !important;
|
||||
font-style: normal !important;
|
||||
text-shadow: none !important;
|
||||
font-size: 12px !important;
|
||||
background: rgba(17, 17, 17, 0.9);
|
||||
border-radius: 4px;
|
||||
color: #fff;
|
||||
content: attr(data-balloon);
|
||||
padding: .5em 1em;
|
||||
position: absolute;
|
||||
white-space: nowrap;
|
||||
z-index: 10; }
|
||||
[data-balloon]:before {
|
||||
background: no-repeat url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20width%3D%2236px%22%20height%3D%2212px%22%3E%3Cpath%20fill%3D%22rgba(17, 17, 17, 0.9)%22%20transform%3D%22rotate(0)%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E");
|
||||
background-size: 100% auto;
|
||||
width: 18px;
|
||||
height: 6px;
|
||||
filter: alpha(opacity=0);
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
|
||||
-moz-opacity: 0;
|
||||
-khtml-opacity: 0;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transition: all 0.18s ease-out 0.18s;
|
||||
content: '';
|
||||
position: absolute;
|
||||
z-index: 10; }
|
||||
[data-balloon]:hover:before, [data-balloon]:hover:after, [data-balloon][data-balloon-visible]:before, [data-balloon][data-balloon-visible]:after {
|
||||
filter: alpha(opacity=100);
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
|
||||
-moz-opacity: 1;
|
||||
-khtml-opacity: 1;
|
||||
opacity: 1;
|
||||
pointer-events: auto; }
|
||||
[data-balloon].font-awesome:after {
|
||||
font-family: FontAwesome; }
|
||||
[data-balloon][data-balloon-break]:after {
|
||||
white-space: pre; }
|
||||
[data-balloon][data-balloon-blunt]:before, [data-balloon][data-balloon-blunt]:after {
|
||||
transition: none; }
|
||||
[data-balloon][data-balloon-pos="up"]:after {
|
||||
bottom: 100%;
|
||||
left: 50%;
|
||||
margin-bottom: 11px;
|
||||
transform: translate(-50%, 10px);
|
||||
transform-origin: top; }
|
||||
[data-balloon][data-balloon-pos="up"]:before {
|
||||
bottom: 100%;
|
||||
left: 50%;
|
||||
margin-bottom: 5px;
|
||||
transform: translate(-50%, 10px);
|
||||
transform-origin: top; }
|
||||
[data-balloon][data-balloon-pos="up"]:hover:after, [data-balloon][data-balloon-pos="up"][data-balloon-visible]:after {
|
||||
transform: translate(-50%, 0); }
|
||||
[data-balloon][data-balloon-pos="up"]:hover:before, [data-balloon][data-balloon-pos="up"][data-balloon-visible]:before {
|
||||
transform: translate(-50%, 0); }
|
||||
[data-balloon][data-balloon-pos="up-left"]:after {
|
||||
bottom: 100%;
|
||||
left: 0;
|
||||
margin-bottom: 11px;
|
||||
transform: translate(0, 10px);
|
||||
transform-origin: top; }
|
||||
[data-balloon][data-balloon-pos="up-left"]:before {
|
||||
bottom: 100%;
|
||||
left: 5px;
|
||||
margin-bottom: 5px;
|
||||
transform: translate(0, 10px);
|
||||
transform-origin: top; }
|
||||
[data-balloon][data-balloon-pos="up-left"]:hover:after, [data-balloon][data-balloon-pos="up-left"][data-balloon-visible]:after {
|
||||
transform: translate(0, 0); }
|
||||
[data-balloon][data-balloon-pos="up-left"]:hover:before, [data-balloon][data-balloon-pos="up-left"][data-balloon-visible]:before {
|
||||
transform: translate(0, 0); }
|
||||
[data-balloon][data-balloon-pos="up-right"]:after {
|
||||
bottom: 100%;
|
||||
right: 0;
|
||||
margin-bottom: 11px;
|
||||
transform: translate(0, 10px);
|
||||
transform-origin: top; }
|
||||
[data-balloon][data-balloon-pos="up-right"]:before {
|
||||
bottom: 100%;
|
||||
right: 5px;
|
||||
margin-bottom: 5px;
|
||||
transform: translate(0, 10px);
|
||||
transform-origin: top; }
|
||||
[data-balloon][data-balloon-pos="up-right"]:hover:after, [data-balloon][data-balloon-pos="up-right"][data-balloon-visible]:after {
|
||||
transform: translate(0, 0); }
|
||||
[data-balloon][data-balloon-pos="up-right"]:hover:before, [data-balloon][data-balloon-pos="up-right"][data-balloon-visible]:before {
|
||||
transform: translate(0, 0); }
|
||||
[data-balloon][data-balloon-pos='down']:after {
|
||||
left: 50%;
|
||||
margin-top: 11px;
|
||||
top: 100%;
|
||||
transform: translate(-50%, -10px); }
|
||||
[data-balloon][data-balloon-pos='down']:before {
|
||||
background: no-repeat url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20width%3D%2236px%22%20height%3D%2212px%22%3E%3Cpath%20fill%3D%22rgba(17, 17, 17, 0.9)%22%20transform%3D%22rotate(180 18 6)%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E");
|
||||
background-size: 100% auto;
|
||||
width: 18px;
|
||||
height: 6px;
|
||||
left: 50%;
|
||||
margin-top: 5px;
|
||||
top: 100%;
|
||||
transform: translate(-50%, -10px); }
|
||||
[data-balloon][data-balloon-pos='down']:hover:after, [data-balloon][data-balloon-pos='down'][data-balloon-visible]:after {
|
||||
transform: translate(-50%, 0); }
|
||||
[data-balloon][data-balloon-pos='down']:hover:before, [data-balloon][data-balloon-pos='down'][data-balloon-visible]:before {
|
||||
transform: translate(-50%, 0); }
|
||||
[data-balloon][data-balloon-pos='down-left']:after {
|
||||
left: 0;
|
||||
margin-top: 11px;
|
||||
top: 100%;
|
||||
transform: translate(0, -10px); }
|
||||
[data-balloon][data-balloon-pos='down-left']:before {
|
||||
background: no-repeat url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20width%3D%2236px%22%20height%3D%2212px%22%3E%3Cpath%20fill%3D%22rgba(17, 17, 17, 0.9)%22%20transform%3D%22rotate(180 18 6)%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E");
|
||||
background-size: 100% auto;
|
||||
width: 18px;
|
||||
height: 6px;
|
||||
left: 5px;
|
||||
margin-top: 5px;
|
||||
top: 100%;
|
||||
transform: translate(0, -10px); }
|
||||
[data-balloon][data-balloon-pos='down-left']:hover:after, [data-balloon][data-balloon-pos='down-left'][data-balloon-visible]:after {
|
||||
transform: translate(0, 0); }
|
||||
[data-balloon][data-balloon-pos='down-left']:hover:before, [data-balloon][data-balloon-pos='down-left'][data-balloon-visible]:before {
|
||||
transform: translate(0, 0); }
|
||||
[data-balloon][data-balloon-pos='down-right']:after {
|
||||
right: 0;
|
||||
margin-top: 11px;
|
||||
top: 100%;
|
||||
transform: translate(0, -10px); }
|
||||
[data-balloon][data-balloon-pos='down-right']:before {
|
||||
background: no-repeat url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20width%3D%2236px%22%20height%3D%2212px%22%3E%3Cpath%20fill%3D%22rgba(17, 17, 17, 0.9)%22%20transform%3D%22rotate(180 18 6)%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E");
|
||||
background-size: 100% auto;
|
||||
width: 18px;
|
||||
height: 6px;
|
||||
right: 5px;
|
||||
margin-top: 5px;
|
||||
top: 100%;
|
||||
transform: translate(0, -10px); }
|
||||
[data-balloon][data-balloon-pos='down-right']:hover:after, [data-balloon][data-balloon-pos='down-right'][data-balloon-visible]:after {
|
||||
transform: translate(0, 0); }
|
||||
[data-balloon][data-balloon-pos='down-right']:hover:before, [data-balloon][data-balloon-pos='down-right'][data-balloon-visible]:before {
|
||||
transform: translate(0, 0); }
|
||||
[data-balloon][data-balloon-pos='left']:after {
|
||||
margin-right: 11px;
|
||||
right: 100%;
|
||||
top: 50%;
|
||||
transform: translate(10px, -50%); }
|
||||
[data-balloon][data-balloon-pos='left']:before {
|
||||
background: no-repeat url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20width%3D%2212px%22%20height%3D%2236px%22%3E%3Cpath%20fill%3D%22rgba(17, 17, 17, 0.9)%22%20transform%3D%22rotate(-90 18 18)%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E");
|
||||
background-size: 100% auto;
|
||||
width: 6px;
|
||||
height: 18px;
|
||||
margin-right: 5px;
|
||||
right: 100%;
|
||||
top: 50%;
|
||||
transform: translate(10px, -50%); }
|
||||
[data-balloon][data-balloon-pos='left']:hover:after, [data-balloon][data-balloon-pos='left'][data-balloon-visible]:after {
|
||||
transform: translate(0, -50%); }
|
||||
[data-balloon][data-balloon-pos='left']:hover:before, [data-balloon][data-balloon-pos='left'][data-balloon-visible]:before {
|
||||
transform: translate(0, -50%); }
|
||||
[data-balloon][data-balloon-pos='right']:after {
|
||||
left: 100%;
|
||||
margin-left: 11px;
|
||||
top: 50%;
|
||||
transform: translate(-10px, -50%); }
|
||||
[data-balloon][data-balloon-pos='right']:before {
|
||||
background: no-repeat url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20width%3D%2212px%22%20height%3D%2236px%22%3E%3Cpath%20fill%3D%22rgba(17, 17, 17, 0.9)%22%20transform%3D%22rotate(90 6 6)%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E");
|
||||
background-size: 100% auto;
|
||||
width: 6px;
|
||||
height: 18px;
|
||||
left: 100%;
|
||||
margin-left: 5px;
|
||||
top: 50%;
|
||||
transform: translate(-10px, -50%); }
|
||||
[data-balloon][data-balloon-pos='right']:hover:after, [data-balloon][data-balloon-pos='right'][data-balloon-visible]:after {
|
||||
transform: translate(0, -50%); }
|
||||
[data-balloon][data-balloon-pos='right']:hover:before, [data-balloon][data-balloon-pos='right'][data-balloon-visible]:before {
|
||||
transform: translate(0, -50%); }
|
||||
[data-balloon][data-balloon-length='small']:after {
|
||||
white-space: normal;
|
||||
width: 80px; }
|
||||
[data-balloon][data-balloon-length='medium']:after {
|
||||
white-space: normal;
|
||||
width: 150px; }
|
||||
[data-balloon][data-balloon-length='large']:after {
|
||||
white-space: normal;
|
||||
width: 260px; }
|
||||
[data-balloon][data-balloon-length='xlarge']:after {
|
||||
white-space: normal;
|
||||
width: 380px; }
|
||||
@media screen and (max-width: 768px) {
|
||||
[data-balloon][data-balloon-length='xlarge']:after {
|
||||
white-space: normal;
|
||||
width: 90vw; } }
|
||||
[data-balloon][data-balloon-length='fit']:after {
|
||||
white-space: normal;
|
||||
width: 100%; }
|
||||
@ -0,0 +1,86 @@
|
||||
.choose-element-type-parent:before {
|
||||
content: "";
|
||||
position: fixed;
|
||||
left: 0;
|
||||
top: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background: rgba(0,0,0,0.5);
|
||||
z-index: 9991;
|
||||
}
|
||||
|
||||
.choose-element-type {
|
||||
position: fixed;
|
||||
width: 500px;
|
||||
background: #fff;
|
||||
left: 50%;
|
||||
padding: 30px;
|
||||
box-sizing: border-box;
|
||||
box-shadow: 0 0 20px rgba(0,0,0,0.05);
|
||||
border: 1px solid #ddd;
|
||||
z-index: 9992;
|
||||
transform: translate(-50%, -50%);
|
||||
top: 50%;
|
||||
}
|
||||
|
||||
.choose-element-type h2 {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
select.select-type {
|
||||
position: relative;
|
||||
padding: 10px 15px;
|
||||
margin: 0;
|
||||
background-color: #fff;
|
||||
box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
height: auto;
|
||||
border: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
select.select-type:hover {
|
||||
background-color: #fafafa;
|
||||
}
|
||||
|
||||
.dark-mode select.select-type:hover {
|
||||
background-color: #23282d;
|
||||
}
|
||||
|
||||
.choose-element-type button.button {
|
||||
font-size: 17px;
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.select-type-container {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
button.close-choose-element-type {
|
||||
position: absolute;
|
||||
top: 10px;
|
||||
right: 10px;
|
||||
background: transparent;
|
||||
border: 0;
|
||||
box-shadow: 0 0 0;
|
||||
cursor: pointer;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
button.close-choose-element-type svg {
|
||||
height: 20px;
|
||||
width: 20px;
|
||||
}
|
||||
|
||||
.hook-location {
|
||||
background: #efefef;
|
||||
padding: 2px 5px;
|
||||
font-family: monospace;
|
||||
font-size: 11px;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
.wrap #generate_premium_elements.closed .inside {
|
||||
display: block;
|
||||
}
|
||||
@ -0,0 +1,29 @@
|
||||
jQuery( function( $ ) {
|
||||
$( '.post-type-gp_elements .page-title-action:not(.legacy-button)' ).on( 'click', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
$( '.choose-element-type-parent' ).show();
|
||||
$( '.choose-element-type .select-type' ).focus();
|
||||
} );
|
||||
|
||||
$( '.close-choose-element-type' ).on( 'click', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
$( '.choose-element-type-parent' ).hide();
|
||||
$( '.page-title-action' ).focus();
|
||||
} );
|
||||
|
||||
$( '.post-type-gp_elements' ).on( 'keyup', function( e ) {
|
||||
const $element = $( '.choose-element-type-parent' );
|
||||
|
||||
if ( e.key === 'Escape' && $element.is( ':visible' ) ) {
|
||||
$element.hide();
|
||||
$( '.page-title-action' ).focus();
|
||||
}
|
||||
} );
|
||||
|
||||
// Don't allow Elements to quick edit parents.
|
||||
$( '.inline-edit-gp_elements select#post_parent, .inline-edit-gp_elements .inline-edit-menu-order-input, .bulk-edit-gp_elements select#post_parent' ).each( function() {
|
||||
$( this ).closest( 'label' ).remove();
|
||||
} );
|
||||
} );
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 200 B |
@ -0,0 +1,400 @@
|
||||
#generate_premium_elements {
|
||||
background-color: transparent;
|
||||
border: 0;
|
||||
box-shadow: 0 0 0;
|
||||
}
|
||||
|
||||
#generate_premium_elements .inside {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#generate_premium_elements .CodeMirror {
|
||||
position: relative;
|
||||
padding: 0;
|
||||
background: white;
|
||||
box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
tr.generate-element-row td {
|
||||
border-bottom: 1px solid #f0f0f0;
|
||||
zoom: 1;
|
||||
}
|
||||
|
||||
td.generate-element-row-heading {
|
||||
background: #F9F9F9;
|
||||
border-right: 1px solid #E1E1E1;
|
||||
padding: 13px 15px;
|
||||
width: 24%;
|
||||
}
|
||||
|
||||
td.generate-element-row-heading label {
|
||||
display: inline-block;
|
||||
font-size: 13px;
|
||||
line-height: 1.4em;
|
||||
font-weight: bold;
|
||||
padding: 0;
|
||||
margin: 0 0 3px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
td.generate-element-row-content {
|
||||
padding: 13px 15px;
|
||||
position: relative;
|
||||
width: 75%;
|
||||
}
|
||||
|
||||
.metabox-holder #generate_premium_elements .handlediv,
|
||||
.metabox-holder #generate_premium_elements .hndle,
|
||||
.metabox-holder #generate_premium_elements .postbox-header {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#generate_premium_elements .inside {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#generate_premium_elements select,
|
||||
#generate_premium_elements input[type="number"],
|
||||
#generate_premium_elements input[type="text"] {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#generate_premium_elements .condition select.condition-object-select + .select2 {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#generate_premium_elements .condition.generate-elements-rule-objects-visible select.condition-select + .select2 {
|
||||
margin-right: 5px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#generate_premium_elements .condition.generate-elements-rule-objects-visible select.condition-object-select + .select2 {
|
||||
display: inline-block;
|
||||
margin-left: 5px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#generate_premium_elements .condition {
|
||||
display: flex;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
#generate_premium_elements .condition .select2 {
|
||||
flex-grow: 1;
|
||||
}
|
||||
|
||||
button.remove-condition {
|
||||
background: transparent;
|
||||
border: 0;
|
||||
line-height: 1;
|
||||
width: 30px;
|
||||
font-size: 20px;
|
||||
cursor: pointer;
|
||||
opacity: 0.5;
|
||||
position: relative;
|
||||
bottom: -3px;
|
||||
}
|
||||
|
||||
button.add-condition {
|
||||
margin-top: 10px !important;
|
||||
}
|
||||
|
||||
button.remove-condition:before {
|
||||
content: "\f153";
|
||||
font-family: dashicons;
|
||||
}
|
||||
|
||||
table.generate-elements-settings {
|
||||
position: relative;
|
||||
padding: 0;
|
||||
background: white;
|
||||
box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.generate-element-row-loading {
|
||||
background-color: rgba(255,255,255,0.9);
|
||||
background-image: url('spinner.gif');
|
||||
background-position: center center;
|
||||
background-repeat: no-repeat;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
ul.element-metabox-tabs {
|
||||
position: relative;
|
||||
padding: 0;
|
||||
margin: 0 0 20px;
|
||||
background: white;
|
||||
box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3;
|
||||
display: flex;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.edit-post-layout__metaboxes ul.element-metabox-tabs {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
ul.element-metabox-tabs li {
|
||||
width: auto;
|
||||
flex: none;
|
||||
border-bottom: 2px solid transparent;
|
||||
border-top: none;
|
||||
text-align: center;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
ul.element-metabox-tabs li a {
|
||||
display: block;
|
||||
width: auto;
|
||||
padding: 16px 16px 14px 16px;
|
||||
color: #0087be;
|
||||
font-weight: 400;
|
||||
text-decoration: none;
|
||||
box-shadow: 0 0 0;
|
||||
}
|
||||
|
||||
ul.element-metabox-tabs li a:hover {
|
||||
color: #00a0d2;
|
||||
}
|
||||
|
||||
ul.element-metabox-tabs li.is-selected {
|
||||
border-bottom-color: #2e4453;
|
||||
}
|
||||
|
||||
ul.element-metabox-tabs li.is-selected a {
|
||||
color: #2e4453;
|
||||
}
|
||||
|
||||
#generate-element-content,
|
||||
#generate-element-content + .CodeMirror {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.element-metabox-tabs li:not([data-tab="display-rules"]):not([data-tab="internal-notes"]),
|
||||
.generate-elements-settings:not([data-tab="display-rules"]):not([data-tab="internal-notes"]) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.element-settings.header .element-metabox-tabs li[data-type="header"],
|
||||
.element-settings.hook .element-metabox-tabs li[data-type="hook"],
|
||||
.element-settings.block .element-metabox-tabs li[data-type="hook"],
|
||||
.element-settings.layout .element-metabox-tabs li[data-type="layout"] {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.element-settings.header:not(.has-page-hero) table[data-tab="site-header"],
|
||||
.element-settings.header.has-page-hero table[data-tab="hero"],
|
||||
.element-settings.hook table[data-tab="hook-settings"],
|
||||
.element-settings.block table[data-tab="hook-settings"],
|
||||
.element-settings.layout table[data-tab="sidebars"] {
|
||||
display: table;
|
||||
}
|
||||
|
||||
.element-settings.header:not(.has-page-hero) #generate-element-content {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.element-settings.header:not(.has-page-hero) #generate-element-content + .CodeMirror:not(.gpp-elements-show-codemirror) {
|
||||
height: 0;
|
||||
overflow: hidden;
|
||||
opacity: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.padding-container {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.single-value-padding-container {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.single-value-padding-container input[type="number"] {
|
||||
width: 60px !important;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.padding-element-options {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.padding-element span.unit {
|
||||
border: 1px solid #ddd;
|
||||
display: inline-block;
|
||||
line-height: 26px;
|
||||
padding: 0 10px;
|
||||
margin-left: -5px;
|
||||
vertical-align: middle;
|
||||
border-left: 0;
|
||||
}
|
||||
|
||||
.padding-element input {
|
||||
width: 60px !important;
|
||||
min-height: 30px;
|
||||
}
|
||||
|
||||
.padding-element select {
|
||||
width: auto !important;
|
||||
position: relative;
|
||||
left: -5px;
|
||||
min-height: 30px;
|
||||
}
|
||||
|
||||
.padding-element span {
|
||||
display: block;
|
||||
font-size: 90%;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.generate-element-row-content .responsive-controls.single-responsive-value {
|
||||
padding: 8px 15px 7px 0;
|
||||
}
|
||||
|
||||
.generate-element-row-content .responsive-controls.checkbox-responsive-value {
|
||||
padding: 2px 15px 0 0;
|
||||
}
|
||||
|
||||
#postimagediv {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.image-preview img {
|
||||
height: 30px;
|
||||
width: auto;
|
||||
vertical-align: middle;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.gp-media-preview img {
|
||||
vertical-align: middle;
|
||||
background-color: #efefef;
|
||||
border-radius: 5px;
|
||||
height: 30px;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.media-container,
|
||||
.change-featured-image,
|
||||
.set-featured-image {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.media-container > input,
|
||||
.media-container .gp-media-preview img,
|
||||
.change-featured-image > *,
|
||||
.set-featured-image > * {
|
||||
margin-right: 10px !important;
|
||||
}
|
||||
|
||||
.generate-element-row-content .responsive-controls {
|
||||
float: left;
|
||||
padding: 15px 15px 15px 0;
|
||||
}
|
||||
|
||||
.generate-element-row-content .responsive-controls a {
|
||||
text-decoration: none;
|
||||
color: #222;
|
||||
opacity: 0.5;
|
||||
outline: 0;
|
||||
box-shadow: 0 0 0;
|
||||
}
|
||||
|
||||
.generate-element-row-content .responsive-controls a.is-selected {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.generate-element-row-content .responsive-controls a span {
|
||||
font-size: 14px;
|
||||
width: auto;
|
||||
height: auto;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
|
||||
#generate-element-content {
|
||||
width: 100%;
|
||||
height: 300px;
|
||||
}
|
||||
|
||||
.layout-radio-item {
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
|
||||
.layout-radio-item:first-child {
|
||||
margin-bottom: 15px;
|
||||
}
|
||||
|
||||
span.tip {
|
||||
display: inline-block;
|
||||
float: right;
|
||||
background: #b3b3b3;
|
||||
height: 15px;
|
||||
width: 15px;
|
||||
text-align: center;
|
||||
line-height: 15px;
|
||||
color: #fff;
|
||||
border-radius: 50%;
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
body:not(.header-element-type) #generate_page_hero_template_tags,
|
||||
.header-element-type:not(.element-has-page-hero) #generate_page_hero_template_tags {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#_generate_element_internal_notes {
|
||||
width: 100%;
|
||||
height: 250px;
|
||||
}
|
||||
|
||||
.select2-results__option {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
body .select2-container--default .select2-selection--single {
|
||||
border-color: #ddd;
|
||||
}
|
||||
|
||||
.select2-results__option[role="list"] {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#generate_premium_elements #_generate_content_width {
|
||||
width: 65px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
#_generate_content_width + span {
|
||||
border: 1px solid #ddd;
|
||||
height: 26px;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
line-height: 26px;
|
||||
padding: 0 10px;
|
||||
margin-left: -6px;
|
||||
}
|
||||
|
||||
.hide-hook-row,
|
||||
.sidebar-notice {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.sidebar-notice {
|
||||
margin-top: 10px;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.element-settings.block .generate-elements-settings[data-type="hook"] tr:last-child td {
|
||||
border-bottom: 0;
|
||||
}
|
||||
@ -0,0 +1,424 @@
|
||||
jQuery( function( $ ) {
|
||||
if ( $( '.element-settings' ).hasClass( 'header' ) || $( '.element-settings' ).hasClass( 'hook' ) ) {
|
||||
$( function() {
|
||||
if ( elements.settings ) {
|
||||
wp.codeEditor.initialize( 'generate-element-content', elements.settings );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
$( '#_generate_block_type' ).on( 'change', function() {
|
||||
var _this = $( this ).val();
|
||||
|
||||
if ( 'hook' === _this ) {
|
||||
$( '.hook-row' ).removeClass( 'hide-hook-row' );
|
||||
} else {
|
||||
$( '.hook-row' ).addClass( 'hide-hook-row' );
|
||||
}
|
||||
|
||||
$( 'body' ).removeClass( 'right-sidebar-block-type' );
|
||||
$( 'body' ).removeClass( 'left-sidebar-block-type' );
|
||||
$( 'body' ).removeClass( 'header-block-type' );
|
||||
$( 'body' ).removeClass( 'footer-block-type' );
|
||||
|
||||
$( 'body' ).addClass( _this + '-block-type' );
|
||||
|
||||
if ( 'left-sidebar' === _this || 'right-sidebar' === _this ) {
|
||||
$( '.sidebar-notice' ).show();
|
||||
} else {
|
||||
$( '.sidebar-notice' ).hide();
|
||||
}
|
||||
} );
|
||||
|
||||
$( '#_generate_hook' ).on( 'change', function() {
|
||||
var _this = $( this );
|
||||
|
||||
$( '.disable-header-hook' ).hide();
|
||||
$( '.disable-footer-hook' ).hide();
|
||||
$( '.custom-hook-name' ).hide();
|
||||
|
||||
if ( 'generate_header' === _this.val() ) {
|
||||
$( '.disable-header-hook' ).show();
|
||||
}
|
||||
|
||||
if ( 'generate_footer' === _this.val() ) {
|
||||
$( '.disable-footer-hook' ).show();
|
||||
}
|
||||
|
||||
if ( 'custom' === _this.val() ) {
|
||||
$( '.custom-hook-name' ).show();
|
||||
}
|
||||
} );
|
||||
|
||||
$( '#_generate_hook' ).select2( {
|
||||
width: '100%',
|
||||
} );
|
||||
|
||||
$( '.element-metabox-tabs li' ).on( 'click', function() {
|
||||
var _this = $( this ),
|
||||
tab = _this.data( 'tab' );
|
||||
|
||||
_this.siblings().removeClass( 'is-selected' );
|
||||
_this.addClass( 'is-selected' );
|
||||
$( '.generate-elements-settings' ).hide();
|
||||
$( '.generate-elements-settings[data-tab="' + tab + '"]' ).show();
|
||||
|
||||
if ( $( '.element-settings' ).hasClass( 'block' ) && 'hook-settings' === tab ) {
|
||||
$( '.generate-elements-settings[data-tab="display-rules"]' ).show();
|
||||
}
|
||||
|
||||
if ( $( '.element-settings' ).hasClass( 'header' ) ) {
|
||||
if ( 'hero' !== tab ) {
|
||||
$( '#generate-element-content' ).next( '.CodeMirror' ).removeClass( 'gpp-elements-show-codemirror' );
|
||||
$( '#generate_page_hero_template_tags' ).css( 'display', '' );
|
||||
} else {
|
||||
$( '#generate-element-content' ).next( '.CodeMirror' ).addClass( 'gpp-elements-show-codemirror' );
|
||||
$( '#generate_page_hero_template_tags' ).css( 'display', 'block' );
|
||||
}
|
||||
}
|
||||
} );
|
||||
|
||||
var select2Init = function() {
|
||||
var selects = $( '.generate-element-row-content .condition:not(.hidden) select:not(.select2-init)' );
|
||||
|
||||
selects.each( function() {
|
||||
var select = $( this ),
|
||||
config = {
|
||||
width: 'style',
|
||||
};
|
||||
|
||||
select.select2( config );
|
||||
select.addClass( 'select2-init' );
|
||||
} );
|
||||
};
|
||||
|
||||
select2Init();
|
||||
|
||||
$( '.add-condition' ).on( 'click', function() {
|
||||
var _this = $( this );
|
||||
|
||||
var row = _this.closest( '.generate-element-row-content' ).find( '.condition.hidden.screen-reader-text' ).clone( true );
|
||||
row.removeClass( 'hidden screen-reader-text' );
|
||||
row.insertBefore( _this.closest( '.generate-element-row-content' ).find( '.condition:last' ) );
|
||||
|
||||
select2Init();
|
||||
|
||||
return false;
|
||||
} );
|
||||
|
||||
$( '.remove-condition' ).on( 'click', function() {
|
||||
$( this ).parents( '.condition' ).remove();
|
||||
|
||||
select2Init();
|
||||
|
||||
return false;
|
||||
} );
|
||||
|
||||
var getLocationObjects = function( _this, onload = false, data = '' ) {
|
||||
var select = _this,
|
||||
parent = select.parent(),
|
||||
location = select.val(),
|
||||
objectSelect = parent.find( '.condition-object-select' ),
|
||||
locationType = '',
|
||||
actionType = 'terms';
|
||||
|
||||
if ( '' === location ) {
|
||||
parent.removeClass( 'generate-elements-rule-objects-visible' );
|
||||
select.closest( '.generate-element-row-content' ).find( '.generate-element-row-loading' ).remove();
|
||||
} else {
|
||||
if ( location.indexOf( ':taxonomy:' ) > 0 ) {
|
||||
locationType = 'taxonomy';
|
||||
} else {
|
||||
locationType = location.substr( 0, location.indexOf( ':' ) );
|
||||
}
|
||||
|
||||
var locationID = location.substr( location.lastIndexOf( ':' ) + 1 );
|
||||
|
||||
if ( 'taxonomy' === locationType || 'post' === locationType ) {
|
||||
if ( ! ( '.generate-element-row-loading' ).length ) {
|
||||
select.closest( '.generate-element-row-content' ).prepend( '<div class="generate-element-row-loading"></div>' );
|
||||
}
|
||||
|
||||
var fillObjects = function( response ) {
|
||||
var objects = response[ locationID ].objects;
|
||||
|
||||
var blank = {
|
||||
id: '',
|
||||
name: 'All ' + response[ locationID ].label,
|
||||
};
|
||||
|
||||
if ( location.indexOf( ':taxonomy:' ) > 0 ) {
|
||||
blank.name = elements.choose;
|
||||
}
|
||||
|
||||
objectSelect.empty();
|
||||
|
||||
objectSelect.append( $( '<option>', {
|
||||
value: blank.id,
|
||||
label: blank.name,
|
||||
text: blank.name,
|
||||
} ) );
|
||||
|
||||
$.each( objects, function( key, value ) {
|
||||
objectSelect.append( $( '<option>', {
|
||||
value: value.id,
|
||||
label: elements.showID && value.id ? value.name + ': ' + value.id : value.name,
|
||||
text: elements.showID && value.id ? value.name + ': ' + value.id : value.name,
|
||||
} ) );
|
||||
} );
|
||||
|
||||
parent.addClass( 'generate-elements-rule-objects-visible' );
|
||||
|
||||
if ( onload ) {
|
||||
objectSelect.val( objectSelect.attr( 'data-saved-value' ) );
|
||||
}
|
||||
|
||||
select.closest( '.generate-element-row-content' ).find( '.generate-element-row-loading' ).remove();
|
||||
};
|
||||
|
||||
if ( data && onload ) {
|
||||
// Use pre-fetched data if we just loaded the page.
|
||||
fillObjects( data );
|
||||
} else {
|
||||
if ( 'post' === locationType ) {
|
||||
if ( 'taxonomy' === locationType ) {
|
||||
actionType = 'terms';
|
||||
} else {
|
||||
actionType = 'posts';
|
||||
}
|
||||
}
|
||||
|
||||
$.post( ajaxurl, {
|
||||
action: 'generate_elements_get_location_' + actionType,
|
||||
id: locationID,
|
||||
nonce: elements.nonce,
|
||||
}, function( response ) {
|
||||
response = JSON.parse( response );
|
||||
fillObjects( response );
|
||||
} );
|
||||
}
|
||||
} else {
|
||||
parent.removeClass( 'generate-elements-rule-objects-visible' );
|
||||
select.closest( '.generate-element-row-content' ).find( '.generate-element-row-loading' ).remove();
|
||||
objectSelect.empty().append( '<option value="0"></option>' );
|
||||
objectSelect.val( '0' );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$( '.condition select.condition-select' ).on( 'change', function() {
|
||||
getLocationObjects( $( this ) );
|
||||
|
||||
$( '.elements-no-location-error' ).hide();
|
||||
} );
|
||||
|
||||
var postObjects = [];
|
||||
var termObjects = [];
|
||||
|
||||
$( '.generate-elements-rule-objects-visible' ).each( function() {
|
||||
var _this = $( this ),
|
||||
select = _this.find( 'select.condition-select' ),
|
||||
location = select.val(),
|
||||
locationID = location.substr( location.lastIndexOf( ':' ) + 1 ),
|
||||
locationType = '';
|
||||
|
||||
if ( location.indexOf( ':taxonomy:' ) > 0 ) {
|
||||
locationType = 'taxonomy';
|
||||
} else {
|
||||
locationType = location.substr( 0, location.indexOf( ':' ) );
|
||||
}
|
||||
|
||||
if ( 'post' === locationType ) {
|
||||
if ( ! postObjects.includes( locationID ) ) {
|
||||
postObjects.push( locationID );
|
||||
}
|
||||
} else if ( 'taxonomy' === locationType && ! termObjects.includes( locationID ) ) {
|
||||
termObjects.push( locationID );
|
||||
}
|
||||
} );
|
||||
|
||||
if ( postObjects.length > 0 || termObjects.length > 0 ) {
|
||||
$.post( ajaxurl, {
|
||||
action: 'generate_elements_get_location_objects',
|
||||
posts: postObjects,
|
||||
terms: termObjects,
|
||||
nonce: elements.nonce,
|
||||
}, function( response ) {
|
||||
response = JSON.parse( response );
|
||||
|
||||
$( '.generate-elements-rule-objects-visible' ).each( function() {
|
||||
var _this = $( this ),
|
||||
select = _this.find( 'select.condition-select' );
|
||||
|
||||
$( '<div class="generate-element-row-loading"></div>' ).insertBefore( _this );
|
||||
|
||||
getLocationObjects( select, true, response );
|
||||
} );
|
||||
} );
|
||||
}
|
||||
|
||||
$( '.set-featured-image a, .change-featured-image a:not(.remove-image)' ).on( 'click', function( event ) {
|
||||
event.preventDefault();
|
||||
|
||||
// Stop propagation to prevent thickbox from activating.
|
||||
event.stopPropagation();
|
||||
|
||||
// Open the featured image modal
|
||||
wp.media.featuredImage.frame().open();
|
||||
} );
|
||||
|
||||
wp.media.featuredImage.frame().on( 'select', function() {
|
||||
$( '.set-featured-image' ).hide();
|
||||
$( '.change-featured-image' ).show();
|
||||
|
||||
setTimeout( function() {
|
||||
$( '.image-preview' ).empty();
|
||||
$( '#postimagediv img' ).appendTo( '.image-preview' );
|
||||
}, 500 );
|
||||
} );
|
||||
|
||||
$( '#postimagediv' ).on( 'click', '#remove-post-thumbnail', function() {
|
||||
$( '.set-featured-image' ).show();
|
||||
$( '.change-featured-image' ).hide();
|
||||
$( '.image-preview' ).empty();
|
||||
return false;
|
||||
} );
|
||||
|
||||
$( '.remove-image' ).on( 'click', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
$( '#remove-post-thumbnail' ).trigger( 'click' );
|
||||
} );
|
||||
|
||||
$( '.generate-upload-file' ).on( 'click', function() {
|
||||
if ( frame ) {
|
||||
frame.open();
|
||||
return;
|
||||
}
|
||||
|
||||
var _this = $( this ),
|
||||
container = _this.closest( '.media-container' );
|
||||
|
||||
var frame = wp.media( {
|
||||
title: _this.data( 'title' ),
|
||||
multiple: false,
|
||||
library: { type: _this.data( 'type' ) },
|
||||
button: { text: _this.data( 'insert' ) },
|
||||
} );
|
||||
|
||||
frame.on( 'select', function() {
|
||||
var attachment = frame.state().get( 'selection' ).first().toJSON();
|
||||
|
||||
container.find( '.media-field' ).val( attachment.id );
|
||||
container.find( '.remove-field' ).show();
|
||||
|
||||
if ( _this.data( 'preview' ) ) {
|
||||
container.find( '.gp-media-preview' ).empty().append( '<img src="' + attachment.url + '" width="50" />' ).show();
|
||||
}
|
||||
} );
|
||||
|
||||
frame.open();
|
||||
} );
|
||||
|
||||
$( '.remove-field' ).on( 'click', function() {
|
||||
var _this = $( this ),
|
||||
container = _this.closest( '.media-container' );
|
||||
|
||||
_this.hide();
|
||||
container.find( '.media-field' ).val( '' );
|
||||
container.find( '.gp-media-preview' ).empty();
|
||||
} );
|
||||
|
||||
$( '#_generate_hero_background_image' ).on( 'change', function() {
|
||||
var _this = $( this );
|
||||
|
||||
if ( '' !== _this.val() ) {
|
||||
$( '.requires-background-image' ).show();
|
||||
} else {
|
||||
$( '.requires-background-image' ).hide();
|
||||
}
|
||||
|
||||
if ( 'featured-image' === _this.val() ) {
|
||||
$( '.image-text' ).text( elements.fallback_image );
|
||||
}
|
||||
|
||||
if ( 'custom-image' === _this.val() ) {
|
||||
$( '.image-text' ).text( elements.custom_image );
|
||||
}
|
||||
} );
|
||||
|
||||
// Responsive controls in our settings.
|
||||
$( '.responsive-controls a' ).on( 'click', function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
var _this = $( this ),
|
||||
control = _this.attr( 'data-control' ),
|
||||
controlArea = _this.closest( '.generate-element-row-content' );
|
||||
|
||||
controlArea.find( '.padding-container' ).hide();
|
||||
controlArea.find( '.padding-container.' + control ).show();
|
||||
_this.siblings().removeClass( 'is-selected' );
|
||||
_this.addClass( 'is-selected' );
|
||||
} );
|
||||
|
||||
$( '#_generate_site_header_merge' ).on( 'change', function() {
|
||||
var _this = $( this );
|
||||
|
||||
if ( '' !== _this.val() ) {
|
||||
$( '.requires-header-merge' ).show();
|
||||
|
||||
if ( $( '#_generate_navigation_colors' ).is( ':checked' ) ) {
|
||||
$( '.requires-navigation-colors' ).show();
|
||||
}
|
||||
|
||||
if ( $( '#_generate_hero_full_screen' ).is( ':checked' ) ) {
|
||||
$( '.requires-full-screen' ).show();
|
||||
}
|
||||
} else {
|
||||
$( '.requires-header-merge' ).hide();
|
||||
$( '.requires-navigation-colors' ).hide();
|
||||
$( '.requires-full-screen' ).hide();
|
||||
}
|
||||
} );
|
||||
|
||||
$( '#_generate_navigation_colors' ).on( 'change', function() {
|
||||
var _this = $( this );
|
||||
|
||||
if ( _this.is( ':checked' ) ) {
|
||||
$( '.requires-navigation-colors' ).show();
|
||||
} else {
|
||||
$( '.requires-navigation-colors' ).hide();
|
||||
}
|
||||
} );
|
||||
|
||||
$( '#_generate_hero_full_screen' ).on( 'change', function() {
|
||||
var _this = $( this );
|
||||
|
||||
if ( _this.is( ':checked' ) ) {
|
||||
$( '.requires-full-screen' ).show();
|
||||
} else {
|
||||
$( '.requires-full-screen' ).hide();
|
||||
}
|
||||
} );
|
||||
|
||||
$( '#_generate_hero_background_parallax' ).on( 'change', function() {
|
||||
var _this = $( this );
|
||||
|
||||
if ( _this.is( ':checked' ) ) {
|
||||
$( '#_generate_hero_background_position' ).val( '' ).change();
|
||||
$( '#_generate_hero_background_position option[value="left center"]' ).attr( 'disabled', true );
|
||||
$( '#_generate_hero_background_position option[value="left bottom"]' ).attr( 'disabled', true );
|
||||
$( '#_generate_hero_background_position option[value="right center"]' ).attr( 'disabled', true );
|
||||
$( '#_generate_hero_background_position option[value="right bottom"]' ).attr( 'disabled', true );
|
||||
$( '#_generate_hero_background_position option[value="center center"]' ).attr( 'disabled', true );
|
||||
$( '#_generate_hero_background_position option[value="center bottom"]' ).attr( 'disabled', true );
|
||||
} else {
|
||||
$( '#_generate_hero_background_position option[value="left center"]' ).attr( 'disabled', false );
|
||||
$( '#_generate_hero_background_position option[value="left bottom"]' ).attr( 'disabled', false );
|
||||
$( '#_generate_hero_background_position option[value="right center"]' ).attr( 'disabled', false );
|
||||
$( '#_generate_hero_background_position option[value="right bottom"]' ).attr( 'disabled', false );
|
||||
$( '#_generate_hero_background_position option[value="center center"]' ).attr( 'disabled', false );
|
||||
$( '#_generate_hero_background_position option[value="center bottom"]' ).attr( 'disabled', false );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 4.1 KiB |
@ -0,0 +1,17 @@
|
||||
function generate_parallax_element( selector, context ) {
|
||||
context = context || document;
|
||||
var elements = context.querySelectorAll( selector );
|
||||
return Array.prototype.slice.call( elements );
|
||||
}
|
||||
|
||||
window.addEventListener( "scroll", function() {
|
||||
var scrolledHeight= window.pageYOffset;
|
||||
generate_parallax_element( ".page-hero" ).forEach( function( el, index, array ) {
|
||||
var limit = el.offsetTop + el.offsetHeight;
|
||||
if( scrolledHeight > el.offsetTop && scrolledHeight <= limit ) {
|
||||
el.style.backgroundPositionY = ( scrolledHeight - el.offsetTop ) / hero.parallax + "px";
|
||||
} else {
|
||||
el.style.backgroundPositionY = "0";
|
||||
}
|
||||
});
|
||||
});
|
||||
1
wp-content/upgrade-temp-backup/plugins/gp-premium/elements/assets/js/parallax.min.js
vendored
Normal file
1
wp-content/upgrade-temp-backup/plugins/gp-premium/elements/assets/js/parallax.min.js
vendored
Normal file
@ -0,0 +1 @@
|
||||
function generate_parallax_element(e,o){var t=(o=o||document).querySelectorAll(e);return Array.prototype.slice.call(t)}window.addEventListener("scroll",function(){var r=window.pageYOffset;generate_parallax_element(".page-hero").forEach(function(e,o,t){var a=e.offsetTop+e.offsetHeight;r>e.offsetTop&&r<=a?e.style.backgroundPositionY=(r-e.offsetTop)/hero.parallax+"px":e.style.backgroundPositionY="0"})});
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,469 @@
|
||||
<?php
|
||||
/**
|
||||
* This file displays our block elements on the site.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
/**
|
||||
* Build our Block Elements.
|
||||
*/
|
||||
class GeneratePress_Block_Element {
|
||||
|
||||
/**
|
||||
* The element ID.
|
||||
*
|
||||
* @since 1.11.0
|
||||
* @var int ID of the element.
|
||||
*/
|
||||
protected $post_id = '';
|
||||
|
||||
/**
|
||||
* The element type.
|
||||
*
|
||||
* @since 1.11.0
|
||||
* @var string Type of element.
|
||||
*/
|
||||
protected $type = '';
|
||||
|
||||
/**
|
||||
* Has post ancestors.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @var boolean If this post has a parent.
|
||||
*/
|
||||
protected $has_parent = false;
|
||||
|
||||
/**
|
||||
* Kicks it all off.
|
||||
*
|
||||
* @since 1.11.0
|
||||
*
|
||||
* @param int $post_id The element post ID.
|
||||
*/
|
||||
public function __construct( $post_id ) {
|
||||
$this->post_id = $post_id;
|
||||
$this->type = get_post_meta( $post_id, '_generate_block_type', true );
|
||||
$has_content_template_condition = get_post_meta( $post_id, '_generate_post_loop_item_display', true );
|
||||
|
||||
// Take over the $post_id temporarily if this is a child block.
|
||||
// This allows us to inherit the parent block Display Rules.
|
||||
if ( 'content-template' === $this->type && $has_content_template_condition ) {
|
||||
$parent_block = wp_get_post_parent_id( $post_id );
|
||||
|
||||
if ( ! empty( $parent_block ) ) {
|
||||
$this->has_parent = true;
|
||||
$post_id = $parent_block;
|
||||
}
|
||||
}
|
||||
|
||||
$display_conditions = get_post_meta( $post_id, '_generate_element_display_conditions', true ) ? get_post_meta( $post_id, '_generate_element_display_conditions', true ) : array();
|
||||
$exclude_conditions = get_post_meta( $post_id, '_generate_element_exclude_conditions', true ) ? get_post_meta( $post_id, '_generate_element_exclude_conditions', true ) : array();
|
||||
$user_conditions = get_post_meta( $post_id, '_generate_element_user_conditions', true ) ? get_post_meta( $post_id, '_generate_element_user_conditions', true ) : array();
|
||||
|
||||
$display = apply_filters(
|
||||
'generate_block_element_display',
|
||||
GeneratePress_Conditions::show_data(
|
||||
$display_conditions,
|
||||
$exclude_conditions,
|
||||
$user_conditions
|
||||
),
|
||||
$post_id
|
||||
);
|
||||
|
||||
/**
|
||||
* Simplify filter name.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
$display = apply_filters(
|
||||
'generate_element_display',
|
||||
$display,
|
||||
$post_id
|
||||
);
|
||||
|
||||
// Restore our actual post ID if it's been changed.
|
||||
if ( 'content-template' === $this->type && $has_content_template_condition ) {
|
||||
$post_id = $this->post_id;
|
||||
}
|
||||
|
||||
if ( $display ) {
|
||||
global $generate_elements;
|
||||
|
||||
$generate_elements[ $post_id ] = array(
|
||||
'is_block_element' => true,
|
||||
'type' => $this->type,
|
||||
'id' => $post_id,
|
||||
);
|
||||
|
||||
$hook = get_post_meta( $post_id, '_generate_hook', true );
|
||||
$custom_hook = get_post_meta( $post_id, '_generate_custom_hook', true );
|
||||
$priority = get_post_meta( $post_id, '_generate_hook_priority', true );
|
||||
|
||||
if ( '' === $priority ) {
|
||||
$priority = 10;
|
||||
}
|
||||
|
||||
switch ( $this->type ) {
|
||||
case 'site-header':
|
||||
$hook = 'generate_header';
|
||||
break;
|
||||
|
||||
case 'site-footer':
|
||||
$hook = 'generate_footer';
|
||||
break;
|
||||
|
||||
case 'right-sidebar':
|
||||
$hook = 'generate_before_right_sidebar_content';
|
||||
break;
|
||||
|
||||
case 'left-sidebar':
|
||||
$hook = 'generate_before_left_sidebar_content';
|
||||
break;
|
||||
|
||||
case 'content-template':
|
||||
$hook = 'generate_before_do_template_part';
|
||||
break;
|
||||
|
||||
case 'loop-template':
|
||||
$hook = 'generate_before_main_content';
|
||||
break;
|
||||
|
||||
case 'search-modal':
|
||||
$hook = 'generate_inside_search_modal';
|
||||
break;
|
||||
}
|
||||
|
||||
if ( 'custom' === $hook && $custom_hook ) {
|
||||
$hook = $custom_hook;
|
||||
}
|
||||
|
||||
if ( 'post-meta-template' === $this->type ) {
|
||||
$post_meta_location = get_post_meta( $post_id, '_generate_post_meta_location', true );
|
||||
|
||||
if ( '' === $post_meta_location || 'after-post-title' === $post_meta_location ) {
|
||||
$hook = 'generate_after_entry_title';
|
||||
|
||||
if ( is_page() ) {
|
||||
$hook = 'generate_after_page_title';
|
||||
}
|
||||
} elseif ( 'before-post-title' === $post_meta_location ) {
|
||||
$hook = 'generate_before_entry_title';
|
||||
|
||||
if ( is_page() ) {
|
||||
$hook = 'generate_before_page_title';
|
||||
}
|
||||
} elseif ( 'after-content' === $post_meta_location ) {
|
||||
$hook = 'generate_after_content';
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $hook ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( 'generate_header' === $hook ) {
|
||||
remove_action( 'generate_header', 'generate_construct_header' );
|
||||
}
|
||||
|
||||
if ( 'generate_footer' === $hook ) {
|
||||
remove_action( 'generate_footer', 'generate_construct_footer' );
|
||||
}
|
||||
|
||||
if ( 'content-template' === $this->type && ! $this->has_parent ) {
|
||||
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' ) );
|
||||
}
|
||||
|
||||
if ( 'search-modal' === $this->type ) {
|
||||
remove_action( 'generate_inside_search_modal', 'generate_do_search_fields' );
|
||||
}
|
||||
|
||||
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' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable our post loop items if needed.
|
||||
*
|
||||
* @param boolean $do Whether to display the default post loop item or not.
|
||||
*/
|
||||
public function do_template_part( $do ) {
|
||||
if ( GeneratePress_Elements_Helper::should_render_content_template( $this->post_id ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $do;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell GenerateBlocks about our block element content so it can build CSS.
|
||||
*
|
||||
* @since 1.11.0
|
||||
* @param string $content The existing content.
|
||||
*/
|
||||
public function do_block_content( $content ) {
|
||||
if ( has_blocks( $this->post_id ) ) {
|
||||
$block_element = get_post( $this->post_id );
|
||||
|
||||
if ( ! $block_element || 'gp_elements' !== $block_element->post_type ) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
if ( 'publish' !== $block_element->post_status || ! empty( $block_element->post_password ) ) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
$content .= $block_element->post_content;
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove existing sidebar widgets.
|
||||
*
|
||||
* @since 1.11.0
|
||||
* @param array $widgets The existing widgets.
|
||||
*/
|
||||
public function remove_sidebar_widgets( $widgets ) {
|
||||
if ( 'right-sidebar' === $this->type ) {
|
||||
unset( $widgets['sidebar-1'] );
|
||||
}
|
||||
|
||||
if ( 'left-sidebar' === $this->type ) {
|
||||
unset( $widgets['sidebar-2'] );
|
||||
}
|
||||
|
||||
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.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public function remove_elements() {
|
||||
if ( 'right-sidebar' === $this->type || 'left-sidebar' === $this->type ) {
|
||||
add_filter( 'sidebars_widgets', array( $this, 'remove_sidebar_widgets' ) );
|
||||
add_filter( 'generate_show_default_sidebar_widgets', '__return_false' );
|
||||
}
|
||||
|
||||
if ( 'page-hero' === $this->type ) {
|
||||
$disable_title = get_post_meta( $this->post_id, '_generate_disable_title', true );
|
||||
$disable_featured_image = get_post_meta( $this->post_id, '_generate_disable_featured_image', true );
|
||||
$disable_primary_post_meta = get_post_meta( $this->post_id, '_generate_disable_primary_post_meta', true );
|
||||
|
||||
if ( $disable_title ) {
|
||||
if ( is_singular() ) {
|
||||
add_filter( 'generate_show_title', '__return_false' );
|
||||
}
|
||||
|
||||
remove_action( 'generate_archive_title', 'generate_archive_title' );
|
||||
remove_filter( 'get_the_archive_title', 'generate_filter_the_archive_title' );
|
||||
|
||||
// WooCommerce removal.
|
||||
if ( class_exists( 'WooCommerce' ) ) {
|
||||
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
|
||||
add_filter( 'woocommerce_show_page_title', '__return_false' );
|
||||
remove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description' );
|
||||
remove_action( 'woocommerce_archive_description', 'woocommerce_product_archive_description' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( $disable_primary_post_meta ) {
|
||||
remove_action( 'generate_after_entry_title', 'generate_post_meta' );
|
||||
}
|
||||
|
||||
if ( $disable_featured_image && is_singular() ) {
|
||||
remove_action( 'generate_after_entry_header', 'generate_blog_single_featured_image' );
|
||||
remove_action( 'generate_before_content', 'generate_blog_single_featured_image' );
|
||||
remove_action( 'generate_after_header', 'generate_blog_single_featured_image' );
|
||||
remove_action( 'generate_before_content', 'generate_featured_page_header_inside_single' );
|
||||
remove_action( 'generate_after_header', 'generate_featured_page_header' );
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'post-meta-template' === $this->type ) {
|
||||
$post_meta_location = get_post_meta( $this->post_id, '_generate_post_meta_location', true );
|
||||
$disable_primary_post_meta = get_post_meta( $this->post_id, '_generate_disable_primary_post_meta', true );
|
||||
$disable_secondary_post_meta = get_post_meta( $this->post_id, '_generate_disable_secondary_post_meta', true );
|
||||
|
||||
if ( '' === $post_meta_location || 'after-post-title' === $post_meta_location || 'custom' === $post_meta_location ) {
|
||||
if ( $disable_primary_post_meta ) {
|
||||
remove_action( 'generate_after_entry_title', 'generate_post_meta' );
|
||||
}
|
||||
} elseif ( 'before-post-title' === $post_meta_location || 'custom' === $post_meta_location ) {
|
||||
if ( $disable_primary_post_meta ) {
|
||||
remove_action( 'generate_after_entry_title', 'generate_post_meta' );
|
||||
}
|
||||
} elseif ( 'after-content' === $post_meta_location || 'custom' === $post_meta_location ) {
|
||||
if ( $disable_secondary_post_meta ) {
|
||||
remove_action( 'generate_after_entry_content', 'generate_footer_meta' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'post-navigation-template' === $this->type ) {
|
||||
$disable_post_navigation = get_post_meta( $this->post_id, '_generate_disable_post_navigation', true );
|
||||
|
||||
if ( $disable_post_navigation ) {
|
||||
add_filter( 'generate_footer_entry_meta_items', array( $this, 'disable_post_navigation' ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'archive-navigation-template' === $this->type ) {
|
||||
$disable_archive_navigation = get_post_meta( $this->post_id, '_generate_disable_archive_navigation', true );
|
||||
|
||||
if ( $disable_archive_navigation ) {
|
||||
remove_action( 'generate_after_loop', 'generate_do_post_navigation' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable post navigation.
|
||||
*
|
||||
* @param array $items The post meta items.
|
||||
*/
|
||||
public function disable_post_navigation( $items ) {
|
||||
return array_diff( $items, array( 'post-navigation' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the HTML structure for Page Headers.
|
||||
*
|
||||
* @since 1.11.0
|
||||
*/
|
||||
public function build_hook() {
|
||||
$post_id = $this->post_id;
|
||||
|
||||
if ( 'content-template' === $this->type ) {
|
||||
// Check for child templates if this isn't already one.
|
||||
if ( ! $this->has_parent ) {
|
||||
$children = get_posts(
|
||||
array(
|
||||
'post_type' => 'gp_elements',
|
||||
'post_parent' => $post_id,
|
||||
'order' => 'ASC',
|
||||
'orderby' => 'menu_order',
|
||||
'no_found_rows' => true,
|
||||
'post_status' => 'publish',
|
||||
'numberposts' => 20,
|
||||
'fields' => 'ids',
|
||||
)
|
||||
);
|
||||
|
||||
if ( ! empty( $children ) ) {
|
||||
// Loop through any child templates and overwrite $post_id if applicable.
|
||||
foreach ( (array) $children as $child_id ) {
|
||||
if ( GeneratePress_Elements_Helper::should_render_content_template( $child_id ) ) {
|
||||
$post_id = $child_id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// No children, check if parent should render.
|
||||
if ( ! GeneratePress_Elements_Helper::should_render_content_template( $post_id ) ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// No children, check if template should render.
|
||||
if ( ! GeneratePress_Elements_Helper::should_render_content_template( $post_id ) ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Don't display child elements - they will replace the parent element if applicable.
|
||||
if ( $this->has_parent ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$tag_name_value = get_post_meta( $post_id, '_generate_post_loop_item_tagname', true );
|
||||
$use_theme_container = get_post_meta( $post_id, '_generate_use_theme_post_container', true );
|
||||
|
||||
if ( $tag_name_value ) {
|
||||
$tag_name = $tag_name_value;
|
||||
} else {
|
||||
$tag_name = 'article';
|
||||
}
|
||||
|
||||
printf(
|
||||
'<%s id="%s" class="%s">',
|
||||
esc_attr( $tag_name ),
|
||||
'post-' . get_the_ID(),
|
||||
implode( ' ', get_post_class( 'dynamic-content-template' ) ) // phpcs:ignore -- No escaping needed.
|
||||
);
|
||||
|
||||
if ( $use_theme_container ) {
|
||||
echo '<div class="inside-article">';
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'archive-navigation-template' === $this->type || 'post-navigation-template' === $this->type ) {
|
||||
$use_theme_pagination_container = get_post_meta( $post_id, '_generate_use_archive_navigation_container', true );
|
||||
|
||||
if ( $use_theme_pagination_container ) {
|
||||
echo '<div class="paging-navigation">';
|
||||
}
|
||||
}
|
||||
|
||||
echo GeneratePress_Elements_Helper::build_content( $post_id ); // phpcs:ignore -- No escaping needed.
|
||||
|
||||
if ( 'content-template' === $this->type ) {
|
||||
if ( $use_theme_container ) {
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
echo '</' . esc_attr( $tag_name ) . '>';
|
||||
}
|
||||
|
||||
if ( 'archive-navigation-template' === $this->type || 'post-navigation-template' === $this->type ) {
|
||||
$use_theme_pagination_container = get_post_meta( $post_id, '_generate_use_archive_navigation_container', true );
|
||||
|
||||
if ( $use_theme_pagination_container ) {
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,447 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the Display Rule conditions for Elements.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
/**
|
||||
* The conditions class.
|
||||
*/
|
||||
class GeneratePress_Conditions {
|
||||
/**
|
||||
* Instance.
|
||||
*
|
||||
* @var instance
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* Initiator
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Output our available location conditions.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_conditions() {
|
||||
$types = array(
|
||||
'general' => array(
|
||||
'label' => esc_attr__( 'General', 'gp-premium' ),
|
||||
'locations' => array(
|
||||
'general:site' => esc_attr__( 'Entire Site', 'gp-premium' ),
|
||||
'general:front_page' => esc_attr__( 'Front Page', 'gp-premium' ),
|
||||
'general:blog' => esc_attr__( 'Blog', 'gp-premium' ),
|
||||
'general:singular' => esc_attr__( 'All Singular', 'gp-premium' ),
|
||||
'general:archive' => esc_attr__( 'All Archives', 'gp-premium' ),
|
||||
'general:author' => esc_attr__( 'Author Archives', 'gp-premium' ),
|
||||
'general:date' => esc_attr__( 'Date Archives', 'gp-premium' ),
|
||||
'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' ),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// Add the post types.
|
||||
$post_types = get_post_types(
|
||||
array(
|
||||
'public' => true,
|
||||
),
|
||||
'objects'
|
||||
);
|
||||
|
||||
foreach ( $post_types as $post_type_slug => $post_type ) {
|
||||
|
||||
if ( in_array( $post_type_slug, array( 'fl-theme-layout' ) ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$post_type_object = get_post_type_object( $post_type_slug );
|
||||
$counts = wp_count_posts( $post_type_slug );
|
||||
$count = $counts->publish + $counts->future + $counts->draft + $counts->pending + $counts->private;
|
||||
|
||||
// Add the post type.
|
||||
$types[ $post_type_slug ] = array(
|
||||
'label' => esc_html( $post_type->labels->name ),
|
||||
'locations' => array(
|
||||
'post:' . $post_type_slug => esc_html( $post_type->labels->singular_name ),
|
||||
),
|
||||
);
|
||||
|
||||
// Add the post type archive.
|
||||
// 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 */
|
||||
'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' );
|
||||
|
||||
foreach ( $taxonomies as $taxonomy_slug => $taxonomy ) {
|
||||
|
||||
$public = $taxonomy->public && $taxonomy->show_ui;
|
||||
|
||||
if ( 'post_format' === $taxonomy_slug ) {
|
||||
continue;
|
||||
} elseif ( ! apply_filters( 'generate_elements_show_taxonomy', $public, $taxonomy ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$label = str_replace(
|
||||
array(
|
||||
$post_type->labels->name,
|
||||
$post_type->labels->singular_name,
|
||||
),
|
||||
'',
|
||||
$taxonomy->labels->singular_name
|
||||
);
|
||||
|
||||
if ( isset( $types[ $post_type_slug . '_archive' ]['locations'] ) ) {
|
||||
/* translators: '%1$s is post type label. %2$s is taxonomy label. */
|
||||
$types[ $post_type_slug . '_archive' ]['locations'][ 'taxonomy:' . $taxonomy_slug ] = sprintf( esc_html_x( '%1$s %2$s Archive', '%1$s is post type label. %2$s is taxonomy label.', 'gp-premium' ), $post_type->labels->singular_name, $label );
|
||||
}
|
||||
|
||||
if ( isset( $types[ $post_type_slug ]['locations'] ) ) {
|
||||
$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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Output our available user conditions.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_user_conditions() {
|
||||
$rules = array(
|
||||
'general' => array(
|
||||
'label' => esc_attr__( 'General', 'gp-premium' ),
|
||||
'rules' => array(
|
||||
'general:all' => esc_attr__( 'All Users', 'gp-premium' ),
|
||||
'general:logged_in' => esc_attr__( 'Logged In', 'gp-premium' ),
|
||||
'general:logged_out' => esc_attr__( 'Logged Out', 'gp-premium' ),
|
||||
),
|
||||
),
|
||||
'role' => array(
|
||||
'label' => esc_attr__( 'Roles', 'gp-premium' ),
|
||||
'rules' => array(),
|
||||
),
|
||||
);
|
||||
|
||||
$roles = get_editable_roles();
|
||||
|
||||
foreach ( $roles as $slug => $data ) {
|
||||
$rules['role']['rules'][ $slug ] = $data['name'];
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get our current location.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_current_location() {
|
||||
global $wp_query;
|
||||
global $post;
|
||||
|
||||
$location = null;
|
||||
$object = null;
|
||||
$queried_object = get_queried_object();
|
||||
|
||||
// Get the location string.
|
||||
if ( is_front_page() ) {
|
||||
$location = 'general:front_page';
|
||||
} elseif ( is_home() ) {
|
||||
$location = 'general:blog';
|
||||
} elseif ( is_author() ) {
|
||||
$location = 'general:author';
|
||||
} elseif ( is_date() ) {
|
||||
$location = 'general:date';
|
||||
} elseif ( is_search() ) {
|
||||
$location = 'general:search';
|
||||
|
||||
global $wp_query;
|
||||
|
||||
if ( 0 === $wp_query->found_posts ) {
|
||||
$location = 'general:no_results';
|
||||
}
|
||||
} elseif ( is_404() ) {
|
||||
$location = 'general:404';
|
||||
} elseif ( is_category() ) {
|
||||
|
||||
$location = 'taxonomy:category';
|
||||
|
||||
if ( is_object( $queried_object ) ) {
|
||||
$object = $queried_object->term_id;
|
||||
}
|
||||
} elseif ( is_tag() ) {
|
||||
|
||||
$location = 'taxonomy:post_tag';
|
||||
|
||||
if ( is_object( $queried_object ) ) {
|
||||
$object = $queried_object->term_id;
|
||||
}
|
||||
} elseif ( is_tax() ) {
|
||||
|
||||
$location = 'taxonomy:' . get_query_var( 'taxonomy' );
|
||||
|
||||
if ( is_object( $queried_object ) ) {
|
||||
$location = 'taxonomy:' . $queried_object->taxonomy;
|
||||
$object = $queried_object->term_id;
|
||||
}
|
||||
} elseif ( is_post_type_archive() ) {
|
||||
$post_type = $wp_query->get( 'post_type' );
|
||||
|
||||
if ( is_array( $post_type ) ) {
|
||||
$location = 'archive:' . $post_type[0];
|
||||
} else {
|
||||
$location = 'archive:' . $post_type;
|
||||
}
|
||||
} elseif ( is_singular() ) {
|
||||
|
||||
if ( is_object( $post ) ) {
|
||||
$location = 'post:' . $post->post_type;
|
||||
}
|
||||
|
||||
if ( is_object( $queried_object ) ) {
|
||||
$object = $queried_object->ID;
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_admin() && function_exists( 'get_current_screen' ) ) {
|
||||
$current_screen = get_current_screen();
|
||||
|
||||
if ( isset( $current_screen->is_block_editor ) && $current_screen->is_block_editor ) {
|
||||
$post_id = false;
|
||||
|
||||
if ( isset( $_GET['post'] ) ) { // phpcs:ignore -- Just checking if it's set.
|
||||
$post_id = absint( $_GET['post'] ); // phpcs:ignore -- No data processing going on.
|
||||
}
|
||||
|
||||
if ( $post_id ) {
|
||||
// Get the location string.
|
||||
$front_page_id = get_option( 'page_on_front' );
|
||||
$blog_id = get_option( 'page_for_posts' );
|
||||
|
||||
if ( (int) $post_id === (int) $front_page_id ) {
|
||||
$location = 'general:front_page';
|
||||
} elseif ( (int) $post_id === (int) $blog_id ) {
|
||||
$location = 'general:blog';
|
||||
} else {
|
||||
if ( isset( $current_screen->post_type ) ) {
|
||||
$location = 'post:' . $current_screen->post_type;
|
||||
}
|
||||
|
||||
$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.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
'rule' => $location,
|
||||
'object' => $object,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get info on the current user.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_current_user() {
|
||||
$status = array();
|
||||
if ( is_user_logged_in() ) {
|
||||
$status[] = 'general:logged_in';
|
||||
} else {
|
||||
$status[] = 'general:logged_out';
|
||||
}
|
||||
|
||||
$user = wp_get_current_user();
|
||||
|
||||
foreach ( (array) $user->roles as $role ) {
|
||||
$status[] = $role;
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Figure out if we should display the element or not.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @param array $conditionals The conditions.
|
||||
* @param array $exclude The exclusions.
|
||||
* @param array $roles The roles.
|
||||
* @return bool
|
||||
*/
|
||||
public static function show_data( $conditionals, $exclude, $roles ) {
|
||||
$current_location = self::get_current_location();
|
||||
$show = false;
|
||||
|
||||
// Show depending on location conditionals.
|
||||
if ( ! $show ) {
|
||||
foreach ( (array) $conditionals as $conditional ) {
|
||||
if ( in_array( 'general:site', $conditional ) ) {
|
||||
$show = true;
|
||||
} elseif ( is_singular() && in_array( 'general:singular', $conditional ) ) {
|
||||
$show = true;
|
||||
} elseif ( is_archive() && in_array( 'general:archive', $conditional ) ) {
|
||||
$show = true;
|
||||
} elseif ( ! empty( $current_location['rule'] ) && in_array( $current_location['rule'], $conditional ) ) {
|
||||
if ( ! isset( $conditional['object'] ) || empty( $conditional['object'] ) ) {
|
||||
$show = true;
|
||||
} else {
|
||||
if ( in_array( $current_location['object'], $conditional ) ) {
|
||||
$show = true;
|
||||
}
|
||||
}
|
||||
} elseif ( is_singular() && strstr( $conditional['rule'], ':taxonomy:' ) ) {
|
||||
$tax = substr( $conditional['rule'], strrpos( $conditional['rule'], ':' ) + 1 );
|
||||
|
||||
if ( $tax && isset( $conditional['object'] ) && has_term( $conditional['object'], $tax ) ) {
|
||||
$show = true;
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Exclude based on exclusion conditionals.
|
||||
if ( $show ) {
|
||||
foreach ( (array) $exclude as $conditional ) {
|
||||
if ( is_singular() && in_array( 'general:singular', $conditional ) ) {
|
||||
$show = false;
|
||||
} elseif ( is_archive() && in_array( 'general:archive', $conditional ) ) {
|
||||
$show = false;
|
||||
} elseif ( ! empty( $current_location['rule'] ) && in_array( $current_location['rule'], $conditional ) ) {
|
||||
if ( ! isset( $conditional['object'] ) || empty( $conditional['object'] ) ) {
|
||||
$show = false;
|
||||
} else {
|
||||
if ( in_array( $current_location['object'], $conditional ) ) {
|
||||
$show = false;
|
||||
}
|
||||
}
|
||||
} elseif ( is_singular() && strstr( $conditional['rule'], ':taxonomy:' ) ) {
|
||||
$tax = substr( $conditional['rule'], strrpos( $conditional['rule'], ':' ) + 1 );
|
||||
|
||||
if ( $tax && isset( $conditional['object'] ) && has_term( $conditional['object'], $tax ) ) {
|
||||
$show = false;
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Exclude user roles.
|
||||
if ( $show && ! empty( $roles ) ) {
|
||||
$user_info = self::get_current_user();
|
||||
|
||||
$check = array_intersect( $roles, $user_info );
|
||||
if ( ! count( $check ) > 0 && ! in_array( 'general:all', $roles ) ) {
|
||||
$show = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $show;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the label for a saved location.
|
||||
*
|
||||
* @since 1.7
|
||||
* @param string $saved_location The location.
|
||||
* @return string|bool
|
||||
*/
|
||||
public static function get_saved_label( $saved_location ) {
|
||||
$locations = self::get_conditions();
|
||||
|
||||
$rule = $saved_location['rule'];
|
||||
$object_id = $saved_location['object'];
|
||||
$object_type = '';
|
||||
$label = false;
|
||||
|
||||
foreach ( $locations as $data ) {
|
||||
if ( isset( $data['locations'][ $rule ] ) && ! $label ) {
|
||||
$label = $data['locations'][ $rule ];
|
||||
|
||||
$object_types = explode( ':', $rule );
|
||||
|
||||
if ( in_array( 'taxonomy', $object_types ) && $object_id ) {
|
||||
$term = get_term( $object_id );
|
||||
|
||||
if ( ! is_object( $term ) || is_wp_error( $term ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$label .= ': ' . $term->name;
|
||||
} elseif ( ( in_array( 'post', $object_types ) || in_array( 'page', $object_types ) ) && $object_id ) {
|
||||
$post = get_post( $object_id );
|
||||
|
||||
if ( ! is_object( $post ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$label .= ': ' . $post->post_title;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $label;
|
||||
}
|
||||
}
|
||||
|
||||
GeneratePress_Conditions::get_instance();
|
||||
@ -0,0 +1,527 @@
|
||||
<?php
|
||||
/**
|
||||
* This file contains helper functions for Elements.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper functions.
|
||||
*/
|
||||
class GeneratePress_Elements_Helper {
|
||||
/**
|
||||
* Instance.
|
||||
*
|
||||
* @access private
|
||||
* @var object Instance
|
||||
* @since 1.7
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* Initiator.
|
||||
*
|
||||
* @since 1.7
|
||||
* @return object initialized object of class.
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if specific theme/GPP options exist and are set.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @param string $option Option to check.
|
||||
* @return bool
|
||||
*/
|
||||
public static function does_option_exist( $option ) {
|
||||
if ( function_exists( 'generate_get_defaults' ) ) {
|
||||
$theme_settings = wp_parse_args(
|
||||
get_option( 'generate_settings', array() ),
|
||||
generate_get_defaults()
|
||||
);
|
||||
|
||||
if ( 'site-title' === $option ) {
|
||||
return $theme_settings['hide_title'] ? false : true;
|
||||
}
|
||||
|
||||
if ( 'site-tagline' === $option ) {
|
||||
return $theme_settings['hide_tagline'] ? false : true;
|
||||
}
|
||||
|
||||
if ( 'retina-logo' === $option ) {
|
||||
return $theme_settings['retina_logo'];
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'site-logo' === $option ) {
|
||||
return get_theme_mod( 'custom_logo' );
|
||||
}
|
||||
|
||||
if ( function_exists( 'generate_menu_plus_get_defaults' ) ) {
|
||||
$menu_settings = wp_parse_args(
|
||||
get_option( 'generate_menu_plus_settings', array() ),
|
||||
generate_menu_plus_get_defaults()
|
||||
);
|
||||
|
||||
if ( 'navigation-as-header' === $option ) {
|
||||
return $menu_settings['navigation_as_header'];
|
||||
}
|
||||
|
||||
if ( 'mobile-logo' === $option ) {
|
||||
return $menu_settings['mobile_header_logo'];
|
||||
}
|
||||
|
||||
if ( 'navigation-logo' === $option ) {
|
||||
return $menu_settings['sticky_menu_logo'];
|
||||
}
|
||||
|
||||
if ( 'sticky-navigation' === $option ) {
|
||||
return 'false' !== $menu_settings['sticky_menu'] ? true : false;
|
||||
}
|
||||
|
||||
if ( 'sticky-navigation-logo' === $option ) {
|
||||
return $menu_settings['sticky_navigation_logo'];
|
||||
}
|
||||
|
||||
if ( 'mobile-header-branding' === $option ) {
|
||||
return $menu_settings['mobile_header_branding'];
|
||||
}
|
||||
|
||||
if ( 'sticky-mobile-header' === $option ) {
|
||||
return 'disable' !== $menu_settings['mobile_header_sticky'] ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether we should execute PHP or not.
|
||||
*/
|
||||
public static function should_execute_php() {
|
||||
$php = true;
|
||||
|
||||
if ( defined( 'DISALLOW_FILE_EDIT' ) && true === DISALLOW_FILE_EDIT ) {
|
||||
$php = false;
|
||||
}
|
||||
|
||||
return apply_filters( 'generate_hooks_execute_php', $php );
|
||||
}
|
||||
|
||||
/**
|
||||
* Build our HTML generated by the blocks.
|
||||
*
|
||||
* @since 1.11.0
|
||||
*
|
||||
* @param int $id The ID to check.
|
||||
* @return string
|
||||
*/
|
||||
public static function build_content( $id ) {
|
||||
if ( ! function_exists( 'do_blocks' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$block_element = get_post( $id );
|
||||
|
||||
if ( ! $block_element || 'gp_elements' !== $block_element->post_type ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ( 'publish' !== $block_element->post_status || ! empty( $block_element->post_password ) ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$block_type = get_post_meta( $id, '_generate_block_type', true );
|
||||
|
||||
if ( 'site-footer' === $block_type ) {
|
||||
$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 ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get our Element type label.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @param string $type The type value.
|
||||
*/
|
||||
public static function get_element_type_label( $type ) {
|
||||
switch ( $type ) {
|
||||
case 'block':
|
||||
$label = __( 'Block', 'gp-premium' );
|
||||
break;
|
||||
|
||||
case 'header':
|
||||
$label = __( 'Header', 'gp-premium' );
|
||||
break;
|
||||
|
||||
case 'hook':
|
||||
$label = __( 'Hook', 'gp-premium' );
|
||||
break;
|
||||
|
||||
case 'layout':
|
||||
$label = __( 'Layout', 'gp-premium' );
|
||||
break;
|
||||
|
||||
case 'site-header':
|
||||
$label = __( 'Site Header', 'gp-premium' );
|
||||
break;
|
||||
|
||||
case 'page-hero':
|
||||
$label = __( 'Page Hero', 'gp-premium' );
|
||||
break;
|
||||
|
||||
case 'content-template':
|
||||
$label = __( 'Content Template', 'gp-premium' );
|
||||
break;
|
||||
|
||||
case 'loop-template':
|
||||
$label = __( 'Loop Template', 'gp-premium' );
|
||||
break;
|
||||
|
||||
case 'post-meta-template':
|
||||
$label = __( 'Post Meta Template', 'gp-premium' );
|
||||
break;
|
||||
|
||||
case 'post-navigation-template':
|
||||
$label = __( 'Post Navigation', 'gp-premium' );
|
||||
break;
|
||||
|
||||
case 'archive-navigation-template':
|
||||
$label = __( 'Archive Navigation', 'gp-premium' );
|
||||
break;
|
||||
|
||||
case 'right-sidebar':
|
||||
$label = __( 'Right Sidebar', 'gp-premium' );
|
||||
break;
|
||||
|
||||
case 'left-sidebar':
|
||||
$label = __( 'Left Sidebar', 'gp-premium' );
|
||||
break;
|
||||
|
||||
case 'site-footer':
|
||||
$label = __( 'Site Footer', 'gp-premium' );
|
||||
break;
|
||||
|
||||
default:
|
||||
$label = esc_html( str_replace( '-', ' ', ucfirst( $type ) ) );
|
||||
break;
|
||||
}
|
||||
|
||||
return $label;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for content template conditions.
|
||||
*
|
||||
* @since 2.0.0
|
||||
* @param int $post_id The post to check.
|
||||
*/
|
||||
public static function should_render_content_template( $post_id ) {
|
||||
$loop_item_display = get_post_meta( $post_id, '_generate_post_loop_item_display', true );
|
||||
$display = true;
|
||||
|
||||
if ( 'has-term' === $loop_item_display ) {
|
||||
$tax = get_post_meta( $post_id, '_generate_post_loop_item_display_tax', true );
|
||||
|
||||
if ( $tax ) {
|
||||
$term = get_post_meta( $post_id, '_generate_post_loop_item_display_term', true );
|
||||
|
||||
// Add support for multiple comma separated terms.
|
||||
if ( ! empty( $term ) ) {
|
||||
$term = str_replace( ' ', '', $term );
|
||||
$term = explode( ',', $term );
|
||||
}
|
||||
|
||||
if ( has_term( $term, $tax ) ) {
|
||||
$display = true;
|
||||
} else {
|
||||
$display = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'has-post-meta' === $loop_item_display ) {
|
||||
$post_meta_name = get_post_meta( $post_id, '_generate_post_loop_item_display_post_meta', true );
|
||||
|
||||
if ( $post_meta_name ) {
|
||||
$post_meta = get_post_meta( get_the_ID(), $post_meta_name, true );
|
||||
|
||||
if ( $post_meta ) {
|
||||
$display = true;
|
||||
} else {
|
||||
$display = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'is-first-post' === $loop_item_display ) {
|
||||
global $wp_query;
|
||||
|
||||
if ( 0 === $wp_query->current_post && ! is_paged() ) {
|
||||
$display = true;
|
||||
} else {
|
||||
$display = false;
|
||||
}
|
||||
}
|
||||
|
||||
return apply_filters( 'generate_should_render_content_template', $display, $post_id );
|
||||
}
|
||||
|
||||
/**
|
||||
* Build our entire list of hooks to display.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @return array Our list of hooks.
|
||||
*/
|
||||
public static function get_available_hooks() {
|
||||
$hooks = array(
|
||||
'scripts' => array(
|
||||
'group' => esc_attr__( 'Scripts/Styles', 'gp-premium' ),
|
||||
'hooks' => array(
|
||||
'wp_head',
|
||||
'wp_body_open',
|
||||
'wp_footer',
|
||||
),
|
||||
),
|
||||
'header' => array(
|
||||
'group' => esc_attr__( 'Header', 'gp-premium' ),
|
||||
'hooks' => array(
|
||||
'generate_before_header',
|
||||
'generate_after_header',
|
||||
'generate_before_header_content',
|
||||
'generate_after_header_content',
|
||||
'generate_before_logo',
|
||||
'generate_after_logo',
|
||||
'generate_header',
|
||||
),
|
||||
),
|
||||
'navigation' => array(
|
||||
'group' => esc_attr__( 'Navigation', 'gp-premium' ),
|
||||
'hooks' => array(
|
||||
'generate_inside_navigation',
|
||||
'generate_after_primary_menu',
|
||||
'generate_inside_secondary_navigation',
|
||||
'generate_inside_mobile_menu',
|
||||
'generate_inside_mobile_menu_bar',
|
||||
'generate_inside_mobile_header',
|
||||
'generate_inside_slideout_navigation',
|
||||
'generate_after_slideout_navigation',
|
||||
),
|
||||
),
|
||||
'content' => array(
|
||||
'group' => esc_attr__( 'Content', 'gp-premium' ),
|
||||
'hooks' => array(
|
||||
'generate_inside_site_container',
|
||||
'generate_inside_container',
|
||||
'generate_before_main_content',
|
||||
'generate_after_main_content',
|
||||
'generate_before_content',
|
||||
'generate_after_content',
|
||||
'generate_after_entry_content',
|
||||
'generate_after_primary_content_area',
|
||||
'generate_before_entry_title',
|
||||
'generate_after_entry_title',
|
||||
'generate_after_entry_header',
|
||||
'generate_before_archive_title',
|
||||
'generate_after_archive_title',
|
||||
'generate_after_archive_description',
|
||||
),
|
||||
),
|
||||
'comments' => array(
|
||||
'group' => esc_attr__( 'Comments', 'gp-premium' ),
|
||||
'hooks' => array(
|
||||
'generate_before_comments_container',
|
||||
'generate_before_comments',
|
||||
'generate_inside_comments',
|
||||
'generate_below_comments_title',
|
||||
),
|
||||
),
|
||||
'sidebars' => array(
|
||||
'group' => esc_attr__( 'Sidebars', 'gp-premium' ),
|
||||
'hooks' => array(
|
||||
'generate_before_right_sidebar_content',
|
||||
'generate_after_right_sidebar_content',
|
||||
'generate_before_left_sidebar_content',
|
||||
'generate_after_left_sidebar_content',
|
||||
),
|
||||
),
|
||||
'footer' => array(
|
||||
'group' => esc_attr__( 'Footer', 'gp-premium' ),
|
||||
'hooks' => array(
|
||||
'generate_before_footer',
|
||||
'generate_after_footer',
|
||||
'generate_after_footer_widgets',
|
||||
'generate_before_footer_content',
|
||||
'generate_after_footer_content',
|
||||
'generate_footer',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
if ( class_exists( 'WooCommerce' ) ) {
|
||||
$hooks['navigation']['hooks'][] = 'generate_mobile_cart_items';
|
||||
|
||||
$hooks['woocommerce-global'] = array(
|
||||
'group' => esc_attr__( 'WooCommerce - Global', 'gp-premium' ),
|
||||
'hooks' => array(
|
||||
'woocommerce_before_main_content',
|
||||
'woocommerce_after_main_content',
|
||||
'woocommerce_sidebar',
|
||||
'woocommerce_breadcrumb',
|
||||
),
|
||||
);
|
||||
|
||||
$hooks['woocommerce-shop'] = array(
|
||||
'group' => esc_attr__( 'WooCommerce - Shop', 'gp-premium' ),
|
||||
'hooks' => array(
|
||||
'woocommerce_archive_description',
|
||||
'woocommerce_before_shop_loop',
|
||||
'woocommerce_after_shop_loop',
|
||||
'woocommerce_before_shop_loop_item_title',
|
||||
'woocommerce_after_shop_loop_item_title',
|
||||
),
|
||||
);
|
||||
|
||||
$hooks['woocommerce-product'] = array(
|
||||
'group' => esc_attr__( 'WooCommerce - Product', 'gp-premium' ),
|
||||
'hooks' => array(
|
||||
'woocommerce_before_single_product',
|
||||
'woocommerce_before_single_product_summary',
|
||||
'woocommerce_after_single_product_summary',
|
||||
'woocommerce_single_product_summary',
|
||||
'woocommerce_share',
|
||||
'woocommerce_simple_add_to_cart',
|
||||
'woocommerce_before_add_to_cart_form',
|
||||
'woocommerce_after_add_to_cart_form',
|
||||
'woocommerce_before_add_to_cart_button',
|
||||
'woocommerce_after_add_to_cart_button',
|
||||
'woocommerce_before_add_to_cart_quantity',
|
||||
'woocommerce_after_add_to_cart_quantity',
|
||||
'woocommerce_product_meta_start',
|
||||
'woocommerce_product_meta_end',
|
||||
'woocommerce_after_single_product',
|
||||
),
|
||||
);
|
||||
|
||||
$hooks['woocommerce-cart'] = array(
|
||||
'group' => esc_attr__( 'WooCommerce - Cart', 'gp-premium' ),
|
||||
'hooks' => array(
|
||||
'woocommerce_before_calculate_totals',
|
||||
'woocommerce_after_calculate_totals',
|
||||
'woocommerce_before_cart',
|
||||
'woocommerce_after_cart_table',
|
||||
'woocommerce_before_cart_table',
|
||||
'woocommerce_before_cart_contents',
|
||||
'woocommerce_cart_contents',
|
||||
'woocommerce_after_cart_contents',
|
||||
'woocommerce_cart_coupon',
|
||||
'woocommerce_cart_actions',
|
||||
'woocommerce_before_cart_totals',
|
||||
'woocommerce_cart_totals_before_order_total',
|
||||
'woocommerce_cart_totals_after_order_total',
|
||||
'woocommerce_proceed_to_checkout',
|
||||
'woocommerce_after_cart_totals',
|
||||
'woocommerce_after_cart',
|
||||
),
|
||||
);
|
||||
|
||||
$hooks['woocommerce-checkout'] = array(
|
||||
'group' => esc_attr__( 'WooCommerce - Checkout', 'gp-premium' ),
|
||||
'hooks' => array(
|
||||
'woocommerce_before_checkout_form',
|
||||
'woocommerce_checkout_before_customer_details',
|
||||
'woocommerce_checkout_after_customer_details',
|
||||
'woocommerce_checkout_billing',
|
||||
'woocommerce_before_checkout_billing_form',
|
||||
'woocommerce_after_checkout_billing_form',
|
||||
'woocommerce_before_order_notes',
|
||||
'woocommerce_after_order_notes',
|
||||
'woocommerce_checkout_shipping',
|
||||
'woocommerce_checkout_before_order_review',
|
||||
'woocommerce_checkout_order_review',
|
||||
'woocommerce_review_order_before_cart_contents',
|
||||
'woocommerce_review_order_after_cart_contents',
|
||||
'woocommerce_review_order_before_order_total',
|
||||
'woocommerce_review_order_after_order_total',
|
||||
'woocommerce_review_order_before_payment',
|
||||
'woocommerce_review_order_before_submit',
|
||||
'woocommerce_review_order_after_submit',
|
||||
'woocommerce_review_order_after_payment',
|
||||
'woocommerce_checkout_after_order_review',
|
||||
'woocommerce_after_checkout_form',
|
||||
),
|
||||
);
|
||||
|
||||
$hooks['woocommerce-account'] = array(
|
||||
'group' => esc_attr__( 'WooCommerce - Account', 'gp-premium' ),
|
||||
'hooks' => array(
|
||||
'woocommerce_before_account_navigation',
|
||||
'woocommerce_account_navigation',
|
||||
'woocommerce_after_account_navigation',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
if ( function_exists( 'generate_is_using_flexbox' ) && generate_is_using_flexbox() ) {
|
||||
$hooks['navigation']['hooks'][] = 'generate_menu_bar_items';
|
||||
}
|
||||
|
||||
if ( defined( 'GENERATE_VERSION' ) && version_compare( GENERATE_VERSION, '3.0.0-alpha.1', '>' ) ) {
|
||||
$hooks['navigation']['hooks'][] = 'generate_before_navigation';
|
||||
$hooks['navigation']['hooks'][] = 'generate_after_navigation';
|
||||
$hooks['navigation']['hooks'][] = 'generate_after_mobile_menu_button';
|
||||
$hooks['navigation']['hooks'][] = 'generate_inside_mobile_menu_control_wrapper';
|
||||
|
||||
$hooks['content']['hooks'][] = 'generate_after_loop';
|
||||
$hooks['content']['hooks'][] = 'generate_before_do_template_part';
|
||||
$hooks['content']['hooks'][] = 'generate_after_do_template_part';
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,223 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the Hook Element.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute our hook elements.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
class GeneratePress_Hook {
|
||||
|
||||
/**
|
||||
* Set our content variable.
|
||||
*
|
||||
* @since 1.7
|
||||
* @var string The content.
|
||||
*/
|
||||
protected $content = '';
|
||||
|
||||
/**
|
||||
* Set our hook/action variable.
|
||||
*
|
||||
* @since 1.7
|
||||
* @var string The hook.
|
||||
*/
|
||||
protected $hook = '';
|
||||
|
||||
/**
|
||||
* Set our custom hook variable.
|
||||
*
|
||||
* @since 1.7
|
||||
* @var string The custom hook.
|
||||
*/
|
||||
protected $custom_hook = '';
|
||||
|
||||
/**
|
||||
* Set our disable site header variable.
|
||||
*
|
||||
* @since 1.7
|
||||
* @var boolean Whether we're disabling the header.
|
||||
*/
|
||||
protected $disable_site_header = false;
|
||||
|
||||
/**
|
||||
* Set our disable footer variable.
|
||||
*
|
||||
* @since 1.7
|
||||
* @var boolean Whether we're disabling the footer.
|
||||
*/
|
||||
protected $disable_site_footer = false;
|
||||
|
||||
/**
|
||||
* Set our priority variable.
|
||||
*
|
||||
* @since 1.7
|
||||
* @var int The hook priority.
|
||||
*/
|
||||
protected $priority = 10;
|
||||
|
||||
/**
|
||||
* Set our execute PHP variable.
|
||||
*
|
||||
* @since 1.7
|
||||
* @var boolean Whether we're executing PHP.
|
||||
*/
|
||||
protected $php = false;
|
||||
|
||||
/**
|
||||
* Set our execute shortcodes variable.
|
||||
*
|
||||
* @since 1.7
|
||||
* @var boolean Whether we're executing shortcodes.
|
||||
*/
|
||||
protected $shortcodes = false;
|
||||
|
||||
/**
|
||||
* Set our location variable.
|
||||
*
|
||||
* @since 1.7
|
||||
* @var array The conditions.
|
||||
*/
|
||||
protected $conditional = array();
|
||||
|
||||
/**
|
||||
* Set our exclusions variable.
|
||||
*
|
||||
* @since 1.7
|
||||
* @var array The exclusions.
|
||||
*/
|
||||
protected $exclude = array();
|
||||
|
||||
/**
|
||||
* Set our user condition variable.
|
||||
*
|
||||
* @since 1.7
|
||||
* @var array The user roles.
|
||||
*/
|
||||
protected $users = array();
|
||||
|
||||
/**
|
||||
* Set up our class and give variables their values.
|
||||
*
|
||||
* @param int $post_id The post ID of the element we're executing.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public function __construct( $post_id ) {
|
||||
|
||||
$this->hook = get_post_meta( $post_id, '_generate_hook', true );
|
||||
|
||||
if ( empty( $this->hook ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->content = get_post_meta( $post_id, '_generate_element_content', true );
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_custom_hook', true ) ) {
|
||||
$this->custom_hook = get_post_meta( $post_id, '_generate_custom_hook', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_hook_disable_site_header', true ) ) {
|
||||
$this->disable_site_header = get_post_meta( $post_id, '_generate_hook_disable_site_header', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_hook_disable_site_footer', true ) ) {
|
||||
$this->disable_site_footer = get_post_meta( $post_id, '_generate_hook_disable_site_footer', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_hook_priority', true ) || '0' === get_post_meta( $post_id, '_generate_hook_priority', true ) ) {
|
||||
$this->priority = get_post_meta( $post_id, '_generate_hook_priority', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_hook_execute_php', true ) ) {
|
||||
$this->php = get_post_meta( $post_id, '_generate_hook_execute_php', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_hook_execute_shortcodes', true ) ) {
|
||||
$this->shortcodes = get_post_meta( $post_id, '_generate_hook_execute_shortcodes', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_element_display_conditions', true ) ) {
|
||||
$this->conditional = get_post_meta( $post_id, '_generate_element_display_conditions', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_element_exclude_conditions', true ) ) {
|
||||
$this->exclude = get_post_meta( $post_id, '_generate_element_exclude_conditions', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_element_user_conditions', true ) ) {
|
||||
$this->users = get_post_meta( $post_id, '_generate_element_user_conditions', true );
|
||||
}
|
||||
|
||||
if ( 'custom' === $this->hook && $this->custom_hook ) {
|
||||
$this->hook = $this->custom_hook;
|
||||
}
|
||||
|
||||
$display = apply_filters( 'generate_hook_element_display', GeneratePress_Conditions::show_data( $this->conditional, $this->exclude, $this->users ), $post_id );
|
||||
|
||||
/**
|
||||
* Simplify filter name.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
$display = apply_filters(
|
||||
'generate_element_display',
|
||||
$display,
|
||||
$post_id
|
||||
);
|
||||
|
||||
if ( $display ) {
|
||||
global $generate_elements;
|
||||
|
||||
$generate_elements[ $post_id ] = array(
|
||||
'is_block_element' => false,
|
||||
'type' => 'hook',
|
||||
'id' => $post_id,
|
||||
);
|
||||
|
||||
if ( 'generate_header' === $this->hook && $this->disable_site_header ) {
|
||||
remove_action( 'generate_header', 'generate_construct_header' );
|
||||
}
|
||||
|
||||
if ( 'generate_footer' === $this->hook && $this->disable_site_footer ) {
|
||||
remove_action( 'generate_footer', 'generate_construct_footer' );
|
||||
add_filter( 'generate_footer_widgets', '__return_null' );
|
||||
}
|
||||
|
||||
add_action( esc_attr( $this->hook ), array( $this, 'execute_hook' ), absint( $this->priority ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Output our hook content.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public function execute_hook() {
|
||||
|
||||
$content = $this->content;
|
||||
|
||||
if ( $this->shortcodes ) {
|
||||
$content = do_shortcode( $content );
|
||||
}
|
||||
|
||||
if ( $this->php && GeneratePress_Elements_Helper::should_execute_php() ) {
|
||||
ob_start();
|
||||
eval( '?>' . $content . '<?php ' ); // phpcs:ignore -- Using eval() to execute PHP.
|
||||
echo ob_get_clean(); // phpcs:ignore -- Escaping not necessary.
|
||||
} else {
|
||||
echo $content; // phpcs:ignore -- Escaping not necessary.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,550 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles our Layout Element functionality.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
/**
|
||||
* The Layout Element.
|
||||
*/
|
||||
class GeneratePress_Site_Layout {
|
||||
/**
|
||||
* Set our location variable.
|
||||
*
|
||||
* @since 1.7
|
||||
* @var array
|
||||
*/
|
||||
protected $conditional = array();
|
||||
|
||||
/**
|
||||
* Set our exclusion variable.
|
||||
*
|
||||
* @since 1.7
|
||||
* @var array
|
||||
*/
|
||||
protected $exclude = array();
|
||||
|
||||
/**
|
||||
* Set our user condition variable.
|
||||
*
|
||||
* @since 1.7
|
||||
* @var array
|
||||
*/
|
||||
protected $users = array();
|
||||
|
||||
/**
|
||||
* Set up our other options.
|
||||
*
|
||||
* @since 1.7
|
||||
* @deprecated 1.7.3
|
||||
* @var array
|
||||
*/
|
||||
protected static $options = array();
|
||||
|
||||
/**
|
||||
* Sidebar layout.
|
||||
*
|
||||
* @since 1.7.3
|
||||
* @var string
|
||||
*/
|
||||
protected $sidebar_layout = null;
|
||||
|
||||
/**
|
||||
* Footer widgets layout.
|
||||
*
|
||||
* @since 1.7.3
|
||||
* @var int
|
||||
*/
|
||||
protected $footer_widgets = null;
|
||||
|
||||
/**
|
||||
* Whether to disable site header.
|
||||
*
|
||||
* @since 1.7.3
|
||||
* @var boolean
|
||||
*/
|
||||
protected $disable_site_header = null;
|
||||
|
||||
/**
|
||||
* Whether to disable mobile header.
|
||||
*
|
||||
* @since 1.11.0
|
||||
* @var boolean
|
||||
*/
|
||||
protected $disable_mobile_header = null;
|
||||
|
||||
/**
|
||||
* Whether to disable top bar.
|
||||
*
|
||||
* @since 1.7.3
|
||||
* @var boolean
|
||||
*/
|
||||
protected $disable_top_bar = null;
|
||||
|
||||
/**
|
||||
* Whether to disable primary nav.
|
||||
*
|
||||
* @since 1.7.3
|
||||
* @var boolean
|
||||
*/
|
||||
protected $disable_primary_navigation = null;
|
||||
|
||||
/**
|
||||
* Whether to disable secondary nav.
|
||||
*
|
||||
* @since 1.7.3
|
||||
* @var boolean
|
||||
*/
|
||||
protected $disable_secondary_navigation = null;
|
||||
|
||||
/**
|
||||
* Whether to disable featured image.
|
||||
*
|
||||
* @since 1.7.3
|
||||
* @var boolean
|
||||
*/
|
||||
protected $disable_featured_image = null;
|
||||
|
||||
/**
|
||||
* Whether to disable content title.
|
||||
*
|
||||
* @since 1.7.3
|
||||
* @var boolean
|
||||
*/
|
||||
protected $disable_content_title = null;
|
||||
|
||||
/**
|
||||
* Whether to disable footer.
|
||||
*
|
||||
* @since 1.7.3
|
||||
* @var boolean
|
||||
*/
|
||||
protected $disable_footer = null;
|
||||
|
||||
/**
|
||||
* Container type (full width etc..).
|
||||
*
|
||||
* @since 1.7.3
|
||||
* @var string
|
||||
*/
|
||||
protected $content_area = null;
|
||||
|
||||
/**
|
||||
* Content width.
|
||||
*
|
||||
* @since 1.7.3
|
||||
* @var int
|
||||
*/
|
||||
protected $content_width = null;
|
||||
|
||||
/**
|
||||
* Set our post ID.
|
||||
*
|
||||
* @since 1.7
|
||||
* @var int
|
||||
*/
|
||||
protected static $post_id = '';
|
||||
|
||||
/**
|
||||
* Count how many instances are set.
|
||||
*
|
||||
* @since 1.7
|
||||
* @deprecated 1.7.3
|
||||
* @var int
|
||||
*/
|
||||
public static $instances = 0;
|
||||
|
||||
/**
|
||||
* Set our class and give our variables values.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @param int $post_id The post ID of our element.
|
||||
*/
|
||||
public function __construct( $post_id ) {
|
||||
|
||||
self::$post_id = $post_id;
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_element_display_conditions', true ) ) {
|
||||
$this->conditional = get_post_meta( $post_id, '_generate_element_display_conditions', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_element_exclude_conditions', true ) ) {
|
||||
$this->exclude = get_post_meta( $post_id, '_generate_element_exclude_conditions', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_element_user_conditions', true ) ) {
|
||||
$this->users = get_post_meta( $post_id, '_generate_element_user_conditions', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_sidebar_layout', true ) ) {
|
||||
$this->sidebar_layout = get_post_meta( $post_id, '_generate_sidebar_layout', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_footer_widgets', true ) ) {
|
||||
$this->footer_widgets = get_post_meta( $post_id, '_generate_footer_widgets', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_disable_site_header', true ) ) {
|
||||
$this->disable_site_header = get_post_meta( $post_id, '_generate_disable_site_header', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_disable_mobile_header', true ) ) {
|
||||
$this->disable_mobile_header = get_post_meta( $post_id, '_generate_disable_mobile_header', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_disable_top_bar', true ) ) {
|
||||
$this->disable_top_bar = get_post_meta( $post_id, '_generate_disable_top_bar', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_disable_primary_navigation', true ) ) {
|
||||
$this->disable_primary_navigation = get_post_meta( $post_id, '_generate_disable_primary_navigation', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_disable_secondary_navigation', true ) ) {
|
||||
$this->disable_secondary_navigation = get_post_meta( $post_id, '_generate_disable_secondary_navigation', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_disable_featured_image', true ) ) {
|
||||
$this->disable_featured_image = get_post_meta( $post_id, '_generate_disable_featured_image', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_disable_content_title', true ) ) {
|
||||
$this->disable_content_title = get_post_meta( $post_id, '_generate_disable_content_title', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_disable_footer', true ) ) {
|
||||
$this->disable_footer = get_post_meta( $post_id, '_generate_disable_footer', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_content_area', true ) ) {
|
||||
$this->content_area = get_post_meta( $post_id, '_generate_content_area', true );
|
||||
}
|
||||
|
||||
if ( get_post_meta( $post_id, '_generate_content_width', true ) ) {
|
||||
$this->content_width = get_post_meta( $post_id, '_generate_content_width', true );
|
||||
}
|
||||
|
||||
$display = apply_filters( 'generate_layout_element_display', GeneratePress_Conditions::show_data( $this->conditional, $this->exclude, $this->users ), $post_id );
|
||||
|
||||
/**
|
||||
* Simplify filter name.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
$display = apply_filters(
|
||||
'generate_element_display',
|
||||
$display,
|
||||
$post_id
|
||||
);
|
||||
|
||||
if ( $display ) {
|
||||
global $generate_elements;
|
||||
|
||||
$generate_elements[ $post_id ] = array(
|
||||
'is_block_element' => false,
|
||||
'type' => 'layout',
|
||||
'id' => $post_id,
|
||||
);
|
||||
|
||||
add_action( 'wp', array( $this, 'after_setup' ), 100 );
|
||||
add_action( 'wp_enqueue_scripts', array( $this, 'build_css' ), 50 );
|
||||
|
||||
if ( is_admin() ) {
|
||||
add_action( 'current_screen', array( $this, 'after_setup' ), 100 );
|
||||
add_action( 'enqueue_block_editor_assets', array( $this, 'build_css' ), 50 );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Return our available options.
|
||||
*
|
||||
* @since 1.7
|
||||
* @deprecated 1.7.3
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function get_options() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initiate our set layout changes.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public function after_setup() {
|
||||
if ( $this->sidebar_layout && ! self::post_meta_exists( '_generate-sidebar-layout-meta' ) ) {
|
||||
add_filter( 'generate_sidebar_layout', array( $this, 'filter_options' ) );
|
||||
}
|
||||
|
||||
if ( $this->footer_widgets && ! self::post_meta_exists( '_generate-footer-widget-meta' ) ) {
|
||||
add_filter( 'generate_footer_widgets', array( $this, 'filter_options' ) );
|
||||
}
|
||||
|
||||
if ( $this->disable_site_header ) {
|
||||
remove_action( 'generate_header', 'generate_construct_header' );
|
||||
}
|
||||
|
||||
if ( $this->disable_mobile_header ) {
|
||||
remove_action( 'generate_after_header', 'generate_menu_plus_mobile_header', 5 );
|
||||
}
|
||||
|
||||
if ( $this->disable_top_bar ) {
|
||||
remove_action( 'generate_before_header', 'generate_top_bar', 5 );
|
||||
remove_action( 'generate_inside_secondary_navigation', 'generate_secondary_nav_top_bar_widget', 5 );
|
||||
}
|
||||
|
||||
if ( $this->disable_primary_navigation ) {
|
||||
add_filter( 'generate_navigation_location', '__return_false', 20 );
|
||||
add_filter( 'generate_disable_mobile_header_menu', '__return_true' );
|
||||
}
|
||||
|
||||
if ( $this->disable_secondary_navigation ) {
|
||||
add_filter( 'has_nav_menu', array( $this, 'disable_secondary_navigation' ), 10, 2 );
|
||||
}
|
||||
|
||||
if ( $this->disable_featured_image ) {
|
||||
remove_action( 'generate_after_entry_header', 'generate_blog_single_featured_image' );
|
||||
remove_action( 'generate_before_content', 'generate_blog_single_featured_image' );
|
||||
remove_action( 'generate_after_header', 'generate_blog_single_featured_image' );
|
||||
remove_action( 'generate_before_content', 'generate_featured_page_header_inside_single' );
|
||||
remove_action( 'generate_after_header', 'generate_featured_page_header' );
|
||||
add_filter( 'body_class', array( $this, 'remove_featured_image_class' ), 20 );
|
||||
}
|
||||
|
||||
if ( $this->disable_content_title ) {
|
||||
add_filter( 'generate_show_title', '__return_false' );
|
||||
}
|
||||
|
||||
if ( $this->disable_footer ) {
|
||||
remove_action( 'generate_footer', 'generate_construct_footer' );
|
||||
add_filter( 'generate_footer_widgets', '__return_null' );
|
||||
}
|
||||
|
||||
if ( $this->content_area ) {
|
||||
add_filter( 'body_class', array( $this, 'body_classes' ) );
|
||||
}
|
||||
|
||||
if ( is_admin() ) {
|
||||
if ( $this->sidebar_layout && ! self::admin_post_meta_exists( '_generate-sidebar-layout-meta' ) ) {
|
||||
add_filter( 'generate_block_editor_sidebar_layout', array( $this, 'filter_options' ) );
|
||||
}
|
||||
|
||||
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' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build dynamic CSS
|
||||
*/
|
||||
public function build_css() {
|
||||
if ( $this->content_width ) {
|
||||
wp_add_inline_style( 'generate-style', '#content {max-width: ' . absint( $this->content_width ) . 'px;margin-left: auto;margin-right: auto;}' );
|
||||
}
|
||||
|
||||
if ( is_admin() ) {
|
||||
$admin_css = '';
|
||||
|
||||
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 ( $admin_css ) {
|
||||
wp_add_inline_style( 'wp-edit-blocks', $admin_css );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if our individual post metabox has a value.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @param string $meta The meta key we're checking for.
|
||||
* @return bool
|
||||
*/
|
||||
public static function post_meta_exists( $meta ) {
|
||||
if ( ! is_singular() ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$value = get_post_meta( get_the_ID(), $meta, true );
|
||||
|
||||
if ( '_generate-footer-widget-meta' === $meta && '0' === $value ) {
|
||||
$value = true;
|
||||
}
|
||||
|
||||
if ( $value ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check to see if our individual post metabox has a value in the admin area.
|
||||
*
|
||||
* @since 1.11.0
|
||||
*
|
||||
* @param string $meta The meta key we're checking for.
|
||||
* @return bool
|
||||
*/
|
||||
public static function admin_post_meta_exists( $meta ) {
|
||||
if ( is_admin() ) {
|
||||
$current_screen = get_current_screen();
|
||||
|
||||
if ( isset( $current_screen->is_block_editor ) && $current_screen->is_block_editor ) {
|
||||
$post_id = false;
|
||||
|
||||
if ( isset( $_GET['post'] ) ) { // phpcs:ignore -- No data processing happening here.
|
||||
$post_id = absint( $_GET['post'] ); // phpcs:ignore -- No data processing happening here.
|
||||
}
|
||||
|
||||
if ( $post_id ) {
|
||||
$value = get_post_meta( $post_id, $meta, true );
|
||||
|
||||
if ( '_generate-footer-widget-meta' === $meta && '0' === $value ) {
|
||||
$value = true;
|
||||
}
|
||||
|
||||
if ( $value ) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter our filterable options.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public function filter_options() {
|
||||
$filter = current_filter();
|
||||
|
||||
if ( 'generate_sidebar_layout' === $filter || 'generate_block_editor_sidebar_layout' === $filter ) {
|
||||
return $this->sidebar_layout;
|
||||
}
|
||||
|
||||
if ( 'generate_footer_widgets' === $filter ) {
|
||||
if ( 'no-widgets' === $this->footer_widgets ) {
|
||||
return 0;
|
||||
} else {
|
||||
return $this->footer_widgets;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @param bool $has_nav_menu The existing value.
|
||||
* @param string $location The location we're checking.
|
||||
* @return bool
|
||||
*/
|
||||
public static function disable_secondary_navigation( $has_nav_menu, $location ) {
|
||||
if ( 'secondary' === $location ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $has_nav_menu;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets any necessary body classes.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @param array $classes Our existing body classes.
|
||||
* @return array Our new set of classes.
|
||||
*/
|
||||
public function body_classes( $classes ) {
|
||||
if ( 'full-width' === $this->content_area ) {
|
||||
$classes[] = 'full-width-content';
|
||||
}
|
||||
|
||||
if ( 'contained' === $this->content_area ) {
|
||||
$classes[] = 'contained-content';
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the featured image class if it's disabled.
|
||||
*
|
||||
* @since 2.1.0
|
||||
* @param array $classes The body classes.
|
||||
*/
|
||||
public function remove_featured_image_class( $classes ) {
|
||||
if ( is_singular() ) {
|
||||
$classes = generate_premium_remove_featured_image_class( $classes, $this->disable_featured_image );
|
||||
}
|
||||
|
||||
return $classes;
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,508 @@
|
||||
<?php
|
||||
/**
|
||||
* This file sets up our Elements post type.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
/**
|
||||
* Start our Elements post type class.
|
||||
*/
|
||||
class GeneratePress_Elements_Post_Type {
|
||||
/**
|
||||
* Instance.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @var instance
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* Initiator
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build it.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'init', array( $this, 'post_type' ) );
|
||||
|
||||
if ( is_admin() ) {
|
||||
add_action( 'admin_menu', array( $this, 'menu_item' ), 100 );
|
||||
add_action( 'admin_head', array( $this, 'fix_current_item' ) );
|
||||
add_filter( 'manage_gp_elements_posts_columns', array( $this, 'register_columns' ) );
|
||||
add_action( 'manage_gp_elements_posts_custom_column', array( $this, 'add_columns' ), 10, 2 );
|
||||
add_action( 'restrict_manage_posts', array( $this, 'build_element_type_filter' ) );
|
||||
add_filter( 'pre_get_posts', array( $this, 'filter_element_types' ) );
|
||||
add_filter( 'register_post_type_args', array( $this, 'set_standard_element' ), 10, 2 );
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
|
||||
add_action( 'admin_footer', array( $this, 'element_modal' ) );
|
||||
|
||||
self::setup_metabox();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the metabox.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public function setup_metabox() {
|
||||
require plugin_dir_path( __FILE__ ) . 'class-metabox.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up our custom post type.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public function post_type() {
|
||||
$labels = array(
|
||||
'name' => _x( 'Elements', 'Post Type General Name', 'gp-premium' ),
|
||||
'singular_name' => _x( 'Element', 'Post Type Singular Name', 'gp-premium' ),
|
||||
'menu_name' => __( 'Elements', 'gp-premium' ),
|
||||
'all_items' => __( 'All Elements', 'gp-premium' ),
|
||||
'add_new' => __( 'Add New Element', 'gp-premium' ),
|
||||
'add_new_item' => __( 'Add New Element', 'gp-premium' ),
|
||||
'new_item' => __( 'New Element', 'gp-premium' ),
|
||||
'edit_item' => __( 'Edit Element', 'gp-premium' ),
|
||||
'update_item' => __( 'Update Element', 'gp-premium' ),
|
||||
'search_items' => __( 'Search Element', 'gp-premium' ),
|
||||
'featured_image' => __( 'Background Image', 'gp-premium' ),
|
||||
'set_featured_image' => __( 'Set background image', 'gp-premium' ),
|
||||
'remove_featured_image' => __( 'Remove background image', 'gp-premium' ),
|
||||
'item_published' => __( 'Element published.', 'gp-premium' ),
|
||||
'item_updated' => __( 'Element updated.', 'gp-premium' ),
|
||||
'item_scheduled' => __( 'Element scheduled.', 'gp-premium' ),
|
||||
'item_reverted_to_draft' => __( 'Element reverted to draft.', 'gp-premium' ),
|
||||
);
|
||||
|
||||
$args = array(
|
||||
'labels' => $labels,
|
||||
'supports' => array( 'title', 'editor', 'thumbnail', 'custom-fields', 'page-attributes', 'revisions' ),
|
||||
'hierarchical' => true,
|
||||
'public' => false,
|
||||
'show_ui' => true,
|
||||
'show_in_menu' => false,
|
||||
'can_export' => true,
|
||||
'has_archive' => false,
|
||||
'exclude_from_search' => true,
|
||||
'show_in_rest' => true,
|
||||
);
|
||||
|
||||
register_post_type( 'gp_elements', $args );
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable editor and show_in_rest support for non-Block Elements.
|
||||
*
|
||||
* @since 1.11.0
|
||||
* @param array $args The existing args.
|
||||
* @param string $post_type The current post type.
|
||||
*/
|
||||
public function set_standard_element( $args, $post_type ) {
|
||||
if ( 'gp_elements' === $post_type ) {
|
||||
$post_id = false;
|
||||
$type = false;
|
||||
|
||||
if ( isset( $_GET['post'] ) ) { // phpcs:ignore -- No processing happening.
|
||||
$post_id = absint( $_GET['post'] ); // phpcs:ignore -- No processing happening.
|
||||
}
|
||||
|
||||
if ( $post_id ) {
|
||||
$type = get_post_meta( $post_id, '_generate_element_type', true );
|
||||
} elseif ( isset( $_GET['element_type'] ) ) { // phpcs:ignore -- No processing happening.
|
||||
$type = esc_html( $_GET['element_type'] ); // phpcs:ignore -- No processing happening.
|
||||
}
|
||||
|
||||
if ( ! $type ) {
|
||||
return $args;
|
||||
}
|
||||
|
||||
if ( 'block' !== $type ) {
|
||||
$args['supports'] = array( 'title', 'thumbnail' );
|
||||
$args['show_in_rest'] = false;
|
||||
$args['hierarchical'] = false;
|
||||
}
|
||||
|
||||
if ( 'block' === $type ) {
|
||||
$args['supports'] = array( 'title', 'editor', 'custom-fields', 'page-attributes', 'revisions' );
|
||||
}
|
||||
|
||||
if ( 'layout' === $type ) {
|
||||
$args['labels']['add_new_item'] = __( 'Add New Layout', 'gp-premium' );
|
||||
$args['labels']['edit_item'] = __( 'Edit Layout', 'gp-premium' );
|
||||
}
|
||||
|
||||
if ( 'hook' === $type ) {
|
||||
$args['labels']['add_new_item'] = __( 'Add New Hook', 'gp-premium' );
|
||||
$args['labels']['edit_item'] = __( 'Edit Hook', 'gp-premium' );
|
||||
}
|
||||
|
||||
if ( 'header' === $type ) {
|
||||
$args['labels']['add_new_item'] = __( 'Add New Header', 'gp-premium' );
|
||||
$args['labels']['edit_item'] = __( 'Edit Header', 'gp-premium' );
|
||||
}
|
||||
}
|
||||
|
||||
return $args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register custom post type columns.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @param array $columns Existing CPT columns.
|
||||
* @return array All our CPT columns.
|
||||
*/
|
||||
public function register_columns( $columns ) {
|
||||
$columns['element_type'] = esc_html__( 'Type', 'gp-premium' );
|
||||
$columns['location'] = esc_html__( 'Location', 'gp-premium' );
|
||||
$columns['exclusions'] = esc_html__( 'Exclusions', 'gp-premium' );
|
||||
$columns['users'] = esc_html__( 'Users', 'gp-premium' );
|
||||
|
||||
$new_columns = array();
|
||||
|
||||
// Need to do some funky stuff to display these columns before the date.
|
||||
foreach ( $columns as $key => $value ) {
|
||||
if ( 'date' === $key ) {
|
||||
$new_columns['element_type'] = esc_html__( 'Type', 'gp-premium' );
|
||||
$new_columns['location'] = esc_html__( 'Location', 'gp-premium' );
|
||||
$new_columns['exclusions'] = esc_html__( 'Exclusions', 'gp-premium' );
|
||||
$new_columns['users'] = esc_html__( 'Users', 'gp-premium' );
|
||||
}
|
||||
|
||||
$new_columns[ $key ] = $value;
|
||||
}
|
||||
|
||||
return $new_columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a filter select input to the admin list.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public function build_element_type_filter() {
|
||||
$screen = function_exists( 'get_current_screen' ) ? get_current_screen() : false;
|
||||
|
||||
if ( ! $screen ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! isset( $screen->post_type ) || 'gp_elements' !== $screen->post_type ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$values = array(
|
||||
'block' => esc_html__( 'Blocks', 'gp-premium' ),
|
||||
'header' => esc_html__( 'Headers', 'gp-premium' ),
|
||||
'hook' => esc_html__( 'Hooks', 'gp-premium' ),
|
||||
'layout' => esc_html__( 'Layouts', 'gp-premium' ),
|
||||
);
|
||||
|
||||
$current_element_type = isset( $_GET['gp_element_type_filter'] ) ? esc_html( $_GET['gp_element_type_filter'] ) : ''; // phpcs:ignore -- No processing happening.
|
||||
$current_block_type = isset( $_GET['gp_elements_block_type_filter'] ) ? esc_html( $_GET['gp_elements_block_type_filter'] ) : ''; // phpcs:ignore -- No processing happening.
|
||||
?>
|
||||
<select name="gp_element_type_filter">
|
||||
<option value=""><?php esc_html_e( 'All types', 'gp-premium' ); ?></option>
|
||||
<?php
|
||||
foreach ( $values as $value => $label ) {
|
||||
printf(
|
||||
'<option value="%1$s" %2$s>%3$s</option>',
|
||||
esc_html( $value ),
|
||||
$value === $current_element_type ? 'selected="selected"' : '',
|
||||
esc_html( $label )
|
||||
);
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<?php
|
||||
if ( 'block' === $current_element_type ) {
|
||||
$block_types = array(
|
||||
'hook',
|
||||
'site-header',
|
||||
'page-hero',
|
||||
'content-template',
|
||||
'loop-template',
|
||||
'post-meta-template',
|
||||
'post-navigation-template',
|
||||
'archive-navigation-template',
|
||||
'right-sidebar',
|
||||
'left-sidebar',
|
||||
'site-footer',
|
||||
);
|
||||
?>
|
||||
<select name="gp_elements_block_type_filter">
|
||||
<option value=""><?php esc_html_e( 'All block types', 'gp-premium' ); ?></option>
|
||||
<?php
|
||||
foreach ( $block_types as $value ) {
|
||||
printf(
|
||||
'<option value="%1$s" %2$s>%3$s</option>',
|
||||
esc_html( $value ),
|
||||
$value === $current_block_type ? 'selected="selected"' : '',
|
||||
esc_html( GeneratePress_Elements_Helper::get_element_type_label( $value ) )
|
||||
);
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the shown elements in the admin list if our filter is set.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @param object $query Existing query.
|
||||
*/
|
||||
public function filter_element_types( $query ) {
|
||||
// phpcs:ignore -- No processing happening.
|
||||
if ( ! isset( $_GET['post_type'] ) || 'gp_elements' != $_GET['post_type'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
global $pagenow;
|
||||
|
||||
$type = isset( $_GET['gp_element_type_filter'] ) ? $_GET['gp_element_type_filter'] : ''; // phpcs:ignore -- No processing happening.
|
||||
$meta_query = array();
|
||||
|
||||
if ( 'edit.php' === $pagenow && $query->is_main_query() && '' !== $type ) {
|
||||
$meta_query[] = array(
|
||||
'key' => '_generate_element_type',
|
||||
'value' => esc_attr( $type ),
|
||||
'compare' => '=',
|
||||
);
|
||||
|
||||
$block_type = isset( $_GET['gp_elements_block_type_filter'] ) ? $_GET['gp_elements_block_type_filter'] : ''; // phpcs:ignore -- No processing happening.
|
||||
|
||||
if ( 'block' === $type && '' !== $block_type ) {
|
||||
$meta_query['relation'] = 'AND';
|
||||
|
||||
$meta_query[] = array(
|
||||
'key' => '_generate_block_type',
|
||||
'value' => esc_attr( $block_type ),
|
||||
'compare' => '=',
|
||||
);
|
||||
}
|
||||
|
||||
$query->set( 'meta_query', $meta_query );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add content to our custom post type columns.
|
||||
*
|
||||
* @since 1.7
|
||||
*
|
||||
* @param string $column The name of the column.
|
||||
* @param int $post_id The ID of the post row.
|
||||
*/
|
||||
public function add_columns( $column, $post_id ) {
|
||||
switch ( $column ) {
|
||||
case 'element_type':
|
||||
$type = get_post_meta( $post_id, '_generate_element_type', true );
|
||||
$hook_location = get_post_meta( $post_id, '_generate_hook', true );
|
||||
|
||||
if ( 'block' === $type ) {
|
||||
echo esc_html__( 'Block', 'gp-premium' );
|
||||
|
||||
$block_type = get_post_meta( $post_id, '_generate_block_type', true );
|
||||
|
||||
if ( $block_type ) {
|
||||
echo ' - ' . esc_html( GeneratePress_Elements_Helper::get_element_type_label( $block_type ) );
|
||||
|
||||
if ( 'hook' === $block_type && $hook_location ) {
|
||||
echo '<br />';
|
||||
|
||||
if ( 'custom' === $hook_location ) {
|
||||
$custom_hook = get_post_meta( $post_id, '_generate_custom_hook', true );
|
||||
echo '<span class="hook-location">' . esc_html( $custom_hook ) . '</span>';
|
||||
} else {
|
||||
echo '<span class="hook-location">' . esc_html( $hook_location ) . '</span>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'header' === $type ) {
|
||||
echo esc_html__( 'Header', 'gp-premium' );
|
||||
}
|
||||
|
||||
if ( 'hook' === $type ) {
|
||||
echo esc_html__( 'Hook', 'gp-premium' );
|
||||
|
||||
if ( $hook_location ) {
|
||||
echo '<br />';
|
||||
|
||||
if ( 'custom' === $hook_location ) {
|
||||
$custom_hook = get_post_meta( $post_id, '_generate_custom_hook', true );
|
||||
echo '<span class="hook-location">' . esc_html( $custom_hook ) . '</span>';
|
||||
} else {
|
||||
echo '<span class="hook-location">' . esc_html( $hook_location ) . '</span>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( 'layout' === $type ) {
|
||||
echo esc_html__( 'Layout', 'gp-premium' );
|
||||
}
|
||||
break;
|
||||
|
||||
case 'location':
|
||||
$location = get_post_meta( $post_id, '_generate_element_display_conditions', true );
|
||||
$parent_block = wp_get_post_parent_id( $post_id );
|
||||
|
||||
if ( $location ) {
|
||||
foreach ( (array) $location as $data ) {
|
||||
echo esc_html( GeneratePress_Conditions::get_saved_label( $data ) );
|
||||
echo '<br />';
|
||||
}
|
||||
} elseif ( ! empty( $parent_block ) ) {
|
||||
echo esc_html__( 'Inherit from parent', 'gp-premium' );
|
||||
} else {
|
||||
echo esc_html__( 'Not set', 'gp-premium' );
|
||||
}
|
||||
break;
|
||||
|
||||
case 'exclusions':
|
||||
$location = get_post_meta( $post_id, '_generate_element_exclude_conditions', true );
|
||||
|
||||
if ( $location ) {
|
||||
foreach ( (array) $location as $data ) {
|
||||
echo esc_html( GeneratePress_Conditions::get_saved_label( $data ) );
|
||||
echo '<br />';
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'users':
|
||||
$users = get_post_meta( $post_id, '_generate_element_user_conditions', true );
|
||||
|
||||
if ( $users ) {
|
||||
foreach ( (array) $users as $data ) {
|
||||
if ( strpos( $data, ':' ) !== false ) {
|
||||
$data = substr( $data, strpos( $data, ':' ) + 1 );
|
||||
}
|
||||
|
||||
$return = ucwords( str_replace( '_', ' ', $data ) );
|
||||
|
||||
echo esc_html( $return ) . '<br />';
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create our admin menu item.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public function menu_item() {
|
||||
add_submenu_page(
|
||||
'themes.php',
|
||||
esc_html__( 'Elements', 'gp-premium' ),
|
||||
esc_html__( 'Elements', 'gp-premium' ),
|
||||
apply_filters( 'generate_elements_admin_menu_capability', 'manage_options' ),
|
||||
'edit.php?post_type=gp_elements'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure our admin menu item is highlighted.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
public function fix_current_item() {
|
||||
global $parent_file, $submenu_file, $post_type;
|
||||
|
||||
if ( 'gp_elements' === $post_type ) {
|
||||
$parent_file = 'themes.php'; // phpcs:ignore
|
||||
$submenu_file = 'edit.php?post_type=gp_elements'; // phpcs:ignore
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add scripts to the edit/post area of Elements.
|
||||
*
|
||||
* @since 1.11.0
|
||||
* @param string $hook The current hook for the page.
|
||||
*/
|
||||
public function admin_scripts( $hook ) {
|
||||
if ( ! function_exists( 'get_current_screen' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$current_screen = get_current_screen();
|
||||
|
||||
if ( 'edit.php' === $hook || 'post.php' === $hook ) {
|
||||
if ( 'gp_elements' === $current_screen->post_type ) {
|
||||
wp_enqueue_script( 'generate-elements', plugin_dir_url( __FILE__ ) . 'assets/admin/elements.js', array( 'jquery' ), GP_PREMIUM_VERSION, true );
|
||||
wp_enqueue_style( 'generate-elements', plugin_dir_url( __FILE__ ) . 'assets/admin/elements.css', array(), GP_PREMIUM_VERSION );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Add New Element modal.
|
||||
*
|
||||
* @since 1.11.0
|
||||
*/
|
||||
public function element_modal() {
|
||||
if ( ! function_exists( 'get_current_screen' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$current_screen = get_current_screen();
|
||||
|
||||
if ( 'edit-gp_elements' === $current_screen->id || 'gp_elements' === $current_screen->id ) {
|
||||
?>
|
||||
<form method="get" class="choose-element-type-parent" action="<?php echo esc_url( admin_url( 'post-new.php' ) ); ?>" style="display: none;">
|
||||
<input type="hidden" name="post_type" value="gp_elements" />
|
||||
|
||||
<div class="choose-element-type">
|
||||
<h2><?php _e( 'Choose Element Type', 'gp-premium' ); ?></h2>
|
||||
<div class="select-type-container">
|
||||
<select class="select-type" name="element_type">
|
||||
<option value=""><?php esc_attr_e( 'Choose...', 'gp-premium' ); ?></option>
|
||||
<option value="block"><?php esc_attr_e( 'Block', 'gp-premium' ); ?></option>
|
||||
<option value="hook"><?php esc_attr_e( 'Hook', 'gp-premium' ); ?></option>
|
||||
<option value="layout"><?php esc_attr_e( 'Layout', 'gp-premium' ); ?></option>
|
||||
<option value="header"><?php esc_attr_e( 'Header', 'gp-premium' ); ?></option>
|
||||
</select>
|
||||
|
||||
<button class="button button-primary"><?php _e( 'Create', 'gp-premium' ); ?></button>
|
||||
</div>
|
||||
|
||||
<button class="close-choose-element-type" aria-label="<?php esc_attr_e( 'Close', 'gp-premium' ); ?>">
|
||||
<svg aria-hidden="true" data-prefix="fas" data-icon="times" class="svg-inline--fa fa-times fa-w-11" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 352 512">
|
||||
<path fill="currentColor" d="M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GeneratePress_Elements_Post_Type::get_instance();
|
||||
@ -0,0 +1,290 @@
|
||||
<?php
|
||||
/**
|
||||
* This file sets up our Elements module.
|
||||
*
|
||||
* @since 1.7.0
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
$elements_dir = plugin_dir_path( __FILE__ );
|
||||
|
||||
require $elements_dir . 'class-conditions.php';
|
||||
require $elements_dir . 'class-elements-helper.php';
|
||||
require $elements_dir . 'class-hooks.php';
|
||||
require $elements_dir . 'class-hero.php';
|
||||
require $elements_dir . 'class-layout.php';
|
||||
require $elements_dir . 'class-block.php';
|
||||
require $elements_dir . 'class-block-elements.php';
|
||||
require $elements_dir . 'class-post-type.php';
|
||||
|
||||
add_action( 'wp', 'generate_premium_do_elements' );
|
||||
add_action( 'current_screen', 'generate_premium_do_elements' );
|
||||
/**
|
||||
* Execute our Elements.
|
||||
*
|
||||
* @since 1.7
|
||||
*/
|
||||
function generate_premium_do_elements() {
|
||||
$args = array(
|
||||
'post_type' => 'gp_elements',
|
||||
'no_found_rows' => true,
|
||||
'post_status' => 'publish',
|
||||
'numberposts' => 500, // phpcs:ignore
|
||||
'fields' => 'ids',
|
||||
'suppress_filters' => false,
|
||||
);
|
||||
|
||||
$custom_args = apply_filters(
|
||||
'generate_elements_custom_args',
|
||||
array(
|
||||
'order' => 'ASC',
|
||||
)
|
||||
);
|
||||
|
||||
$args = array_merge( $args, $custom_args );
|
||||
|
||||
// Prevent Polylang from altering the query.
|
||||
if ( function_exists( 'pll_get_post_language' ) ) {
|
||||
$args['lang'] = '';
|
||||
}
|
||||
|
||||
$posts = get_posts( $args );
|
||||
|
||||
foreach ( $posts as $post_id ) {
|
||||
$post_id = apply_filters( 'generate_element_post_id', $post_id );
|
||||
$type = get_post_meta( $post_id, '_generate_element_type', true );
|
||||
|
||||
if ( 'hook' === $type ) {
|
||||
new GeneratePress_Hook( $post_id );
|
||||
}
|
||||
|
||||
if ( 'header' === $type && ! GeneratePress_Hero::$instances ) {
|
||||
new GeneratePress_Hero( $post_id );
|
||||
}
|
||||
|
||||
if ( 'layout' === $type ) {
|
||||
new GeneratePress_Site_Layout( $post_id );
|
||||
}
|
||||
|
||||
if ( 'block' === $type ) {
|
||||
new GeneratePress_Block_Element( $post_id );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
add_filter( 'generate_dashboard_tabs', 'generate_elements_dashboard_tab' );
|
||||
/**
|
||||
* Add the Sites tab to our Dashboard tabs.
|
||||
*
|
||||
* @since 1.6
|
||||
*
|
||||
* @param array $tabs Existing tabs.
|
||||
* @return array New tabs.
|
||||
*/
|
||||
function generate_elements_dashboard_tab( $tabs ) {
|
||||
$screen = get_current_screen();
|
||||
|
||||
$tabs['Elements'] = array(
|
||||
'name' => __( 'Elements', 'gp-premium' ),
|
||||
'url' => admin_url( 'edit.php?post_type=gp_elements' ),
|
||||
'class' => 'edit-gp_elements' === $screen->id ? 'active' : '',
|
||||
'id' => 'gp-elements-tab',
|
||||
);
|
||||
|
||||
return $tabs;
|
||||
}
|
||||
|
||||
add_filter( 'generate_dashboard_screens', 'generate_elements_dashboard_screen' );
|
||||
/**
|
||||
* Add the Sites tab to our Dashboard screens.
|
||||
*
|
||||
* @since 2.1.0
|
||||
*
|
||||
* @param array $screens Existing screens.
|
||||
* @return array New screens.
|
||||
*/
|
||||
function generate_elements_dashboard_screen( $screens ) {
|
||||
$screens[] = 'edit-gp_elements';
|
||||
|
||||
return $screens;
|
||||
}
|
||||
|
||||
add_filter( 'generate_element_post_id', 'generate_elements_ignore_languages' );
|
||||
/**
|
||||
* Disable Polylang elements if their language doesn't match.
|
||||
* We disable their automatic quering so Elements with no language display by default.
|
||||
*
|
||||
* @since 1.8
|
||||
*
|
||||
* @param int $post_id The current post ID.
|
||||
* @return bool|int
|
||||
*/
|
||||
function generate_elements_ignore_languages( $post_id ) {
|
||||
if ( function_exists( 'pll_get_post_language' ) && function_exists( 'pll_current_language' ) ) {
|
||||
$language = pll_get_post_language( $post_id, 'locale' );
|
||||
$disable = get_post_meta( $post_id, '_generate_element_ignore_languages', true );
|
||||
|
||||
if ( $disable ) {
|
||||
return $post_id;
|
||||
}
|
||||
|
||||
if ( $language && $language !== pll_current_language( 'locale' ) ) { // phpcs:ignore -- Using Yoda check I am.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return $post_id;
|
||||
}
|
||||
|
||||
add_action( 'save_post_wp_block', 'generate_elements_wp_block_update', 10, 2 );
|
||||
/**
|
||||
* Regenerate the GenerateBlocks CSS file when a re-usable block is saved.
|
||||
*
|
||||
* @since 1.11.0
|
||||
* @param int $post_id The post ID.
|
||||
* @param object $post The post object.
|
||||
*/
|
||||
function generate_elements_wp_block_update( $post_id, $post ) {
|
||||
$is_autosave = wp_is_post_autosave( $post_id );
|
||||
$is_revision = wp_is_post_revision( $post_id );
|
||||
|
||||
if ( $is_autosave || $is_revision || ! current_user_can( 'edit_post', $post_id ) ) {
|
||||
return $post_id;
|
||||
}
|
||||
|
||||
if ( isset( $post->post_content ) ) {
|
||||
if ( strpos( $post->post_content, 'wp:generateblocks' ) !== false ) {
|
||||
global $wpdb;
|
||||
|
||||
$option = get_option( 'generateblocks_dynamic_css_posts', array() );
|
||||
|
||||
$posts = $wpdb->get_col( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_generateblocks_reusable_blocks'" );
|
||||
|
||||
foreach ( (array) $posts as $id ) {
|
||||
$display_conditions = get_post_meta( $id, '_generate_element_display_conditions', true );
|
||||
|
||||
if ( $display_conditions ) {
|
||||
foreach ( (array) $display_conditions as $condition ) {
|
||||
if ( 'general:site' === $condition['rule'] ) {
|
||||
$option = array();
|
||||
break;
|
||||
}
|
||||
|
||||
if ( $condition['object'] && isset( $option[ $condition['object'] ] ) ) {
|
||||
unset( $option[ $condition['object'] ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
update_option( 'generateblocks_dynamic_css_posts', $option );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
add_filter( 'generate_do_block_element_content', 'generate_add_block_element_content_filters' );
|
||||
/**
|
||||
* Apply content filters to our block elements.
|
||||
*
|
||||
* @since 1.11.0
|
||||
* @param string $content The block element content.
|
||||
*/
|
||||
function generate_add_block_element_content_filters( $content ) {
|
||||
$content = shortcode_unautop( $content );
|
||||
$content = do_shortcode( $content );
|
||||
|
||||
if ( function_exists( 'wp_filter_content_tags' ) ) {
|
||||
$content = wp_filter_content_tags( $content );
|
||||
} elseif ( function_exists( 'wp_make_content_images_responsive' ) ) {
|
||||
$content = wp_make_content_images_responsive( $content );
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
add_action( 'admin_bar_menu', 'generate_add_elements_admin_bar', 100 );
|
||||
/**
|
||||
* Add the Elementd admin bar item.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
function generate_add_elements_admin_bar() {
|
||||
$current_user_can = 'manage_options';
|
||||
|
||||
if ( apply_filters( 'generate_elements_metabox_ajax_allow_editors', false ) ) {
|
||||
$current_user_can = 'edit_posts';
|
||||
}
|
||||
|
||||
if ( ! current_user_can( $current_user_can ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
global $wp_admin_bar;
|
||||
global $generate_elements;
|
||||
|
||||
$title = __( 'Elements', 'gp-premium' );
|
||||
$count = ! empty( $generate_elements ) ? count( $generate_elements ) : 0;
|
||||
|
||||
// Prevent "Entire Site" Elements from being counted on non-edit pages in the admin.
|
||||
if ( is_admin() && function_exists( 'get_current_screen' ) ) {
|
||||
$screen = get_current_screen();
|
||||
|
||||
if ( ! isset( $screen->is_block_editor ) || ! $screen->is_block_editor ) {
|
||||
$count = 0;
|
||||
}
|
||||
|
||||
if ( 'edit' !== $screen->parent_base ) {
|
||||
$count = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $count > 0 ) {
|
||||
$title = sprintf(
|
||||
/* translators: Active Element count. */
|
||||
__( 'Elements (%s)', 'gp-premium' ),
|
||||
$count
|
||||
);
|
||||
}
|
||||
|
||||
$wp_admin_bar->add_menu(
|
||||
array(
|
||||
'id' => 'gp_elements-menu',
|
||||
'title' => $title,
|
||||
'href' => esc_url( admin_url( 'edit.php?post_type=gp_elements' ) ),
|
||||
)
|
||||
);
|
||||
|
||||
if ( ! empty( $generate_elements ) ) {
|
||||
// Prevent "Entire Site" Elements from being counted on non-edit pages in the admin.
|
||||
if ( is_admin() && function_exists( 'get_current_screen' ) ) {
|
||||
$screen = get_current_screen();
|
||||
|
||||
if ( ! isset( $screen->is_block_editor ) || ! $screen->is_block_editor ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( 'edit' !== $screen->parent_base ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ( (array) $generate_elements as $key => $data ) {
|
||||
$label = GeneratePress_Elements_Helper::get_element_type_label( $data['type'] );
|
||||
|
||||
$wp_admin_bar->add_menu(
|
||||
array(
|
||||
'id' => 'element-' . absint( $data['id'] ),
|
||||
'parent' => 'gp_elements-menu',
|
||||
'title' => get_the_title( $data['id'] ) . ' (' . $label . ')',
|
||||
'href' => get_edit_post_link( $data['id'] ),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,134 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the Font Library CPT.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
/**
|
||||
* Font library CPT class.
|
||||
*/
|
||||
class GeneratePress_Pro_Font_Library_CPT extends GeneratePress_Pro_Singleton {
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function init() {
|
||||
add_action( 'init', array( $this, 'register_cpt' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up our custom post type.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*/
|
||||
public function register_cpt() {
|
||||
$labels = array(
|
||||
'name' => _x( 'Fonts', 'Post Type General Name', 'gp-premium' ),
|
||||
'singular_name' => _x( 'Font', 'Post Type Singular Name', 'gp-premium' ),
|
||||
'menu_name' => __( 'Fonts', 'gp-premium' ),
|
||||
'all_items' => __( 'All Fonts', 'gp-premium' ),
|
||||
'add_new' => __( 'Add New Font', 'gp-premium' ),
|
||||
'add_new_item' => __( 'Add New Font', 'gp-premium' ),
|
||||
'new_item' => __( 'New Font', 'gp-premium' ),
|
||||
'edit_item' => __( 'Edit Font', 'gp-premium' ),
|
||||
'update_item' => __( 'Update Font', 'gp-premium' ),
|
||||
'search_items' => __( 'Search Font', 'gp-premium' ),
|
||||
'item_published' => __( 'Font published.', 'gp-premium' ),
|
||||
'item_updated' => __( 'Font updated.', 'gp-premium' ),
|
||||
'item_scheduled' => __( 'Font scheduled.', 'gp-premium' ),
|
||||
'item_reverted_to_draft' => __( 'Font reverted to draft.', 'gp-premium' ),
|
||||
);
|
||||
|
||||
$args = array(
|
||||
'labels' => $labels,
|
||||
'supports' => array( 'title', 'custom-fields' ),
|
||||
'hierarchical' => false,
|
||||
'public' => false,
|
||||
'show_ui' => false,
|
||||
'show_in_menu' => true,
|
||||
'has_archive' => false,
|
||||
'exclude_from_search' => true,
|
||||
'show_in_rest' => true,
|
||||
);
|
||||
|
||||
register_post_type( GeneratePress_Pro_Font_Library::FONT_LIBRARY_CPT, $args );
|
||||
|
||||
// Font variants.
|
||||
register_post_meta(
|
||||
GeneratePress_Pro_Font_Library::FONT_LIBRARY_CPT,
|
||||
'gp_font_variants',
|
||||
array(
|
||||
'type' => 'array',
|
||||
'show_in_rest' => false,
|
||||
)
|
||||
);
|
||||
|
||||
// Font family alias.
|
||||
register_post_meta(
|
||||
GeneratePress_Pro_Font_Library::FONT_LIBRARY_CPT,
|
||||
'gp_font_family_alias',
|
||||
array(
|
||||
'type' => 'string',
|
||||
'show_in_rest' => false,
|
||||
)
|
||||
);
|
||||
|
||||
// Font display value.
|
||||
register_post_meta(
|
||||
GeneratePress_Pro_Font_Library::FONT_LIBRARY_CPT,
|
||||
'gp_font_display',
|
||||
array(
|
||||
'type' => 'string',
|
||||
'show_in_rest' => false,
|
||||
)
|
||||
);
|
||||
|
||||
// Font source.
|
||||
register_post_meta(
|
||||
GeneratePress_Pro_Font_Library::FONT_LIBRARY_CPT,
|
||||
'gp_font_source',
|
||||
array(
|
||||
'type' => 'string',
|
||||
'show_in_rest' => false,
|
||||
)
|
||||
);
|
||||
|
||||
// Font family fallback.
|
||||
register_post_meta(
|
||||
GeneratePress_Pro_Font_Library::FONT_LIBRARY_CPT,
|
||||
'gp_font_fallback',
|
||||
array(
|
||||
'type' => 'string',
|
||||
'show_in_rest' => false,
|
||||
)
|
||||
);
|
||||
|
||||
// Font family preview.
|
||||
register_post_meta(
|
||||
GeneratePress_Pro_Font_Library::FONT_LIBRARY_CPT,
|
||||
'gp_font_preview',
|
||||
array(
|
||||
'type' => 'string',
|
||||
'show_in_rest' => false,
|
||||
)
|
||||
);
|
||||
|
||||
// Font family variable.
|
||||
register_post_meta(
|
||||
GeneratePress_Pro_Font_Library::FONT_LIBRARY_CPT,
|
||||
'gp_font_variable',
|
||||
array(
|
||||
'type' => 'string',
|
||||
'show_in_rest' => false,
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
GeneratePress_Pro_Font_Library_CPT::get_instance()->init();
|
||||
@ -0,0 +1,252 @@
|
||||
<?php
|
||||
/**
|
||||
* Font Optimizations
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
/**
|
||||
* Font library class.
|
||||
*/
|
||||
class GeneratePress_Pro_Font_Library_Optimize extends GeneratePress_Pro_Singleton {
|
||||
/**
|
||||
* User Agent to be used to make requests to the Google Fonts API.
|
||||
*/
|
||||
const USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:124.0) Gecko/20100101 Firefox/124.0';
|
||||
|
||||
/**
|
||||
* Get the optimized font variants for download.
|
||||
*
|
||||
* @param array $font Array of data for the font to optimize.
|
||||
* @param array $variants The variants to optimize.
|
||||
*
|
||||
* @return array The fonts object.
|
||||
*/
|
||||
public static function get_variants( $font, $variants ) {
|
||||
$font_family = $font['name'] ?? '';
|
||||
$slug = $font['slug'] ?? '';
|
||||
|
||||
$variants = wp_list_sort(
|
||||
wp_list_sort( $variants, 'fontWeight', 'ASC' ),
|
||||
'fontStyle',
|
||||
'DESC'
|
||||
);
|
||||
|
||||
$fonts_object = self::convert_to_fonts_object(
|
||||
self::fetch_stylesheet(
|
||||
$font_family,
|
||||
$variants
|
||||
)
|
||||
);
|
||||
|
||||
return $fonts_object[ $slug ]['variants'] ?? $fonts_object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the URL for the google fonts stylesheet to fetch.
|
||||
*
|
||||
* @param string $font_family The font-family name with no fallback.
|
||||
* @param array $variants The list of variants to include.
|
||||
* @return string
|
||||
*/
|
||||
private static function get_google_css_url( $font_family, $variants ) {
|
||||
$encoded_name = str_replace( ' ', '+', $font_family );
|
||||
$weights = wp_list_pluck( $variants, 'fontWeight' );
|
||||
$styles = wp_list_pluck( $variants, 'fontStyle' );
|
||||
$has_italics = in_array( 'italic', $styles, true );
|
||||
// Build the URL.
|
||||
$url = 'https://fonts.googleapis.com/css2?family=' . $encoded_name;
|
||||
|
||||
// If there's only one variant and it's regular, return the URL immediately.
|
||||
$only_regular = count( $variants ) === 1 && 'normal' === $styles[0];
|
||||
if ( $only_regular ) {
|
||||
return $url;
|
||||
}
|
||||
|
||||
if ( $has_italics ) {
|
||||
$url .= ':ital,wght@';
|
||||
} else {
|
||||
$url .= ':wght@' . implode( ';', $weights );
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
// If some variants are italic, build the weight string.
|
||||
foreach ( $variants as $variant ) {
|
||||
|
||||
$is_italic = 'italic' === $variant['fontStyle'];
|
||||
$first_value = $is_italic ? 1 : 0;
|
||||
$url .= "{$first_value},{$variant['fontWeight']};";
|
||||
}
|
||||
|
||||
return rtrim( $url, ';' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch Stylesheet.
|
||||
*
|
||||
* @param string $font_family The font-family name.
|
||||
* @param array $variants The variants to optimize.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function fetch_stylesheet( $font_family, $variants ) {
|
||||
$url = self::get_google_css_url( $font_family, $variants );
|
||||
|
||||
// Get the remote stylesheet.
|
||||
$response = wp_remote_get(
|
||||
$url,
|
||||
array(
|
||||
'user-agent' => self::USER_AGENT,
|
||||
)
|
||||
);
|
||||
|
||||
$code = wp_remote_retrieve_response_code( $response );
|
||||
|
||||
if ( 200 !== $code ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return wp_remote_retrieve_body( $response );
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the stylesheet and build it into a font object which OMGF can understand.
|
||||
*
|
||||
* @param string $stylesheet A valid CSS stylesheet.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private static function convert_to_fonts_object( $stylesheet ) {
|
||||
preg_match_all( '/font-family:\s\'(.*?)\';/', $stylesheet, $font_families );
|
||||
|
||||
if ( empty( $font_families[1] ) ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$font_families = array_unique( $font_families[1] );
|
||||
$object = array();
|
||||
|
||||
foreach ( $font_families as $font_family ) {
|
||||
$slug = sanitize_title( $font_family );
|
||||
$object[ $slug ] = array(
|
||||
'slug' => $slug,
|
||||
'fontFamily' => $font_family,
|
||||
'variants' => self::parse_variants( $stylesheet, $font_family ),
|
||||
'subsets' => self::parse_subsets( $stylesheet, $font_family ),
|
||||
);
|
||||
}
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a stylesheet from Google Fonts' API into a valid Font Object.
|
||||
*
|
||||
* @param string $stylesheet The stylesheet to parse.
|
||||
* @param string $font_family The font family used in the parse.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private static function parse_variants( $stylesheet, $font_family ) {
|
||||
/**
|
||||
* This also captures the commented Subset name.
|
||||
*/
|
||||
preg_match_all( '/\/\*\s.*?}/s', $stylesheet, $font_faces );
|
||||
|
||||
if ( empty( $font_faces[0] ) ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$font_object = array();
|
||||
|
||||
foreach ( $font_faces[0] as $font_face ) {
|
||||
// Check for exact match of font-family.
|
||||
if ( ! preg_match( '/font-family:[\s\'"]*?' . $font_family . '[\'"]?;/', $font_face ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
preg_match( '/font-style:\s(normal|italic);/', $font_face, $font_style );
|
||||
preg_match( '/font-weight:\s([0-9]+);/', $font_face, $font_weight );
|
||||
preg_match( '/src:\surl\((.*?woff2)\)/', $font_face, $font_src );
|
||||
preg_match( '/\/\*\s([a-z\-0-9\[\]]+?)\s\*\//', $font_face, $subset );
|
||||
preg_match( '/unicode-range:\s(.*?);/', $font_face, $range );
|
||||
|
||||
$subset = ! empty( $subset[1] ) ? trim( $subset[1], '[]' ) : '';
|
||||
|
||||
/**
|
||||
* Remove variants that have subset the user doesn't need.
|
||||
*/
|
||||
$allowed_subsets = apply_filters(
|
||||
'generatepress_google_font_subsets',
|
||||
GeneratePress_Pro_Font_Library::get_settings( 'preferred_subset' )
|
||||
);
|
||||
|
||||
if ( empty( $allowed_subsets ) ) {
|
||||
$allowed_subsets = array( 'latin' );
|
||||
}
|
||||
|
||||
if ( ! empty( $subset ) && ! in_array( $subset, $allowed_subsets, true ) && ! is_numeric( $subset ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* If $subset is empty, assume it's a logographic (Chinese, Japanese, etc.) character set.
|
||||
*
|
||||
* @TODO: Apply subset setting here.
|
||||
*/
|
||||
if ( is_numeric( $subset ) ) {
|
||||
$subset = 'logogram-' . $subset;
|
||||
}
|
||||
|
||||
$key = $subset . '-' . $font_weight[1] . ( 'normal' === $font_style[1] ? '' : '-' . $font_style[1] );
|
||||
|
||||
// Setup font object data.
|
||||
$font_object[ $key ] = array(
|
||||
'fontFamily' => $font_family,
|
||||
'fontStyle' => $font_style[1],
|
||||
'fontWeight' => $font_weight[1],
|
||||
'src' => $font_src[1],
|
||||
);
|
||||
|
||||
if ( ! empty( $subset ) ) {
|
||||
$font_object[ $key ]['subset'] = $subset;
|
||||
}
|
||||
|
||||
if ( ! empty( $range ) && isset( $range[1] ) ) {
|
||||
$font_object[ $key ]['range'] = $range[1];
|
||||
}
|
||||
}
|
||||
|
||||
return $font_object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse stylesheets for subsets, which in Google Fonts stylesheets are always
|
||||
* included, commented above each @font-face statements, e.g. /* latin-ext
|
||||
*
|
||||
* @param string $stylesheet The stylesheet to parse.
|
||||
* @param string $font_family The font family used in the parse.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private static function parse_subsets( $stylesheet, $font_family ) {
|
||||
|
||||
preg_match_all( '/\/\*\s([a-z\-]+?)\s\*\//', $stylesheet, $subsets );
|
||||
|
||||
if ( empty( $subsets[1] ) ) {
|
||||
return array();
|
||||
}
|
||||
|
||||
$subsets = array_unique( $subsets[1] );
|
||||
|
||||
return $subsets;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,579 @@
|
||||
<?php
|
||||
/**
|
||||
* Rest API functions.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
/**
|
||||
* Font library REST API endpoints class.
|
||||
*/
|
||||
class GeneratePress_Pro_Font_Library_Rest extends WP_REST_Controller {
|
||||
/**
|
||||
* Instance.
|
||||
*
|
||||
* @access private
|
||||
* @var object Instance
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* Namespace.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $namespace = 'generatepress-font-library/v';
|
||||
|
||||
/**
|
||||
* Version.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $version = '1';
|
||||
|
||||
/**
|
||||
* Initiator.
|
||||
*
|
||||
* @return object initialized object of class.
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* GenerateBlocks_Rest constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'rest_api_init', array( $this, 'register_routes' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Register rest routes.
|
||||
*/
|
||||
public function register_routes() {
|
||||
$namespace = $this->namespace . $this->version;
|
||||
|
||||
// Get fonts from CPT.
|
||||
register_rest_route(
|
||||
$namespace,
|
||||
'/get-fonts/',
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'callback' => array( $this, 'get_fonts' ),
|
||||
'permission_callback' => array( $this, 'edit_posts_permission' ),
|
||||
)
|
||||
);
|
||||
|
||||
// Download a Google font.
|
||||
register_rest_route(
|
||||
$namespace,
|
||||
'/download-google-font/',
|
||||
array(
|
||||
'methods' => WP_REST_Server::EDITABLE,
|
||||
'callback' => array( $this, 'download_google_font' ),
|
||||
'permission_callback' => array( $this, 'edit_posts_permission' ),
|
||||
)
|
||||
);
|
||||
|
||||
// Upload a font.
|
||||
register_rest_route(
|
||||
$namespace,
|
||||
'/upload-fonts/',
|
||||
array(
|
||||
'methods' => WP_REST_Server::EDITABLE,
|
||||
'callback' => array( $this, 'upload_fonts' ),
|
||||
'permission_callback' => array( $this, 'edit_posts_permission' ),
|
||||
)
|
||||
);
|
||||
|
||||
// Delete a font family.
|
||||
register_rest_route(
|
||||
$namespace,
|
||||
'/delete-font/',
|
||||
array(
|
||||
'methods' => WP_REST_Server::EDITABLE,
|
||||
'callback' => array( $this, 'delete_font' ),
|
||||
'permission_callback' => array( $this, 'edit_posts_permission' ),
|
||||
)
|
||||
);
|
||||
|
||||
// Get font library settings.
|
||||
register_rest_route(
|
||||
$namespace,
|
||||
'/get-settings/',
|
||||
array(
|
||||
'methods' => WP_REST_Server::READABLE,
|
||||
'callback' => array( $this, 'get_settings' ),
|
||||
'permission_callback' => array( $this, 'edit_posts_permission' ),
|
||||
)
|
||||
);
|
||||
|
||||
// Set font library settings.
|
||||
register_rest_route(
|
||||
$namespace,
|
||||
'/set-settings/',
|
||||
array(
|
||||
'methods' => WP_REST_Server::EDITABLE,
|
||||
'callback' => array( $this, 'set_settings' ),
|
||||
'permission_callback' => array( $this, 'edit_posts_permission' ),
|
||||
)
|
||||
);
|
||||
|
||||
register_rest_route(
|
||||
$namespace,
|
||||
'/optimize-google-fonts/',
|
||||
array(
|
||||
'methods' => WP_REST_Server::EDITABLE,
|
||||
'callback' => array( $this, 'optimize_google_fonts' ),
|
||||
'permission_callback' => array( $this, 'edit_posts_permission' ),
|
||||
)
|
||||
);
|
||||
|
||||
register_rest_route(
|
||||
$namespace,
|
||||
'/update-font-post/',
|
||||
array(
|
||||
'methods' => WP_REST_Server::EDITABLE,
|
||||
'callback' => array( $this, 'update_font_post' ),
|
||||
'permission_callback' => array( $this, 'edit_posts_permission' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get font posts.
|
||||
*
|
||||
* @param WP_REST_Request $request The request object.
|
||||
*
|
||||
* @return array The response.
|
||||
*/
|
||||
public function get_fonts( WP_REST_Request $request ) {
|
||||
$name = $request->get_param( 'name' );
|
||||
$response = GeneratePress_Pro_Font_Library::get_fonts( $name );
|
||||
|
||||
return $this->success( $response );
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate font CSS.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function build_css_file() {
|
||||
|
||||
$result = GeneratePress_Pro_Font_Library::build_css_file();
|
||||
|
||||
if ( is_wp_error( $result ) ) {
|
||||
return $this->error( 'font_css_generation_failed', __( 'Failed to generate font CSS.', 'gp-premium' ) );
|
||||
}
|
||||
|
||||
return $this->success( $result );
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a specific font from the library and the associated CPT post.
|
||||
*
|
||||
* @param WP_REST_Request $request request object.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function delete_font( WP_REST_Request $request ) {
|
||||
$font_id = $request->get_param( 'fontId' );
|
||||
$slug = get_post_field( 'post_name', $font_id );
|
||||
$upload_dir = wp_get_upload_dir();
|
||||
$font_base_path = trailingslashit( $upload_dir['basedir'] ) . 'generatepress/fonts/' . $slug . '/';
|
||||
|
||||
// Delete the font post.
|
||||
$success = wp_delete_post( $font_id, true );
|
||||
|
||||
if ( ! $success ) {
|
||||
return $this->error(
|
||||
'font_post_delete_failed',
|
||||
__( 'Failed to delete font post.', 'gp-premium' )
|
||||
);
|
||||
}
|
||||
|
||||
// Delete the font sub folder if it exists.
|
||||
if ( file_exists( $font_base_path ) ) {
|
||||
GeneratePress_Pro_Font_Library::delete_directory( $font_base_path );
|
||||
}
|
||||
|
||||
// Regenerate the font CSS.
|
||||
$this->build_css_file();
|
||||
|
||||
// Return success.
|
||||
return $this->success( __( 'Font successfully deleted!', 'gp-premium' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Download a specific Google font and update the CPT.
|
||||
*
|
||||
* @param WP_REST_Request $request request object.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function optimize_google_fonts( WP_REST_Request $request ) {
|
||||
$font = $request->get_param( 'font' ) ?? array();
|
||||
$variants = $request->get_param( 'variants' ) ?? array();
|
||||
|
||||
if ( ! $font || ! $variants ) {
|
||||
return $this->failed( 'No font or variants provided' );
|
||||
}
|
||||
|
||||
$optimized_variants = GeneratePress_Pro_Font_Library_Optimize::get_variants( $font, $variants );
|
||||
|
||||
if ( $optimized_variants ) {
|
||||
foreach ( $optimized_variants as $key => $optimized_variant ) {
|
||||
foreach ( $variants as &$variant ) {
|
||||
$style_match = $variant['fontStyle'] === $optimized_variant['fontStyle'];
|
||||
$weight_match = $variant['fontWeight'] === $optimized_variant['fontWeight'];
|
||||
|
||||
if ( $style_match && $weight_match ) {
|
||||
$variant['src'] = $optimized_variant['src'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->success( $variants );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a font post exists by slug and create it if it doesn't exist.
|
||||
*
|
||||
* @param array $variant The font variant to check.
|
||||
* @param array $slug The font slug.
|
||||
* @return mixed
|
||||
*/
|
||||
public static function get_font_post( $variant, $slug ) {
|
||||
global $wpdb;
|
||||
|
||||
$font_post = $wpdb->get_row(
|
||||
$wpdb->prepare(
|
||||
"SELECT ID FROM $wpdb->posts WHERE post_name = %s AND post_type = %s",
|
||||
$slug,
|
||||
GeneratePress_Pro_Font_Library::FONT_LIBRARY_CPT
|
||||
)
|
||||
);
|
||||
|
||||
if ( $font_post ) {
|
||||
return $font_post->ID;
|
||||
}
|
||||
|
||||
$font_post = wp_insert_post(
|
||||
array(
|
||||
'post_title' => $variant['fontFamily'],
|
||||
'post_name' => $slug,
|
||||
'post_type' => GeneratePress_Pro_Font_Library::FONT_LIBRARY_CPT,
|
||||
'post_status' => 'publish',
|
||||
'wp_error' => true,
|
||||
'meta_input' => array(
|
||||
'gp_font_family_alias' => '',
|
||||
'gp_font_variants' => array(),
|
||||
'gp_font_display' => 'auto',
|
||||
'gp_font_fallback' => '',
|
||||
'gp_font_variable' => GeneratePress_Pro_Font_Library::CSS_VAR_PREFIX . $slug,
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
return $font_post;
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload a specific custom font and update the CPT.
|
||||
*
|
||||
* @param WP_REST_Request $request request object.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function upload_fonts( WP_REST_Request $request ) {
|
||||
$font = $request->get_param( 'font' ) ?? array();
|
||||
$variants = $request->get_param( 'variants' );
|
||||
$source = $request->get_param( 'source' );
|
||||
$slug = $request->get_param( 'slug' ) ?? $font['slug'] ?? '';
|
||||
$results = array(
|
||||
'ID' => null,
|
||||
'variants' => array(),
|
||||
);
|
||||
|
||||
// Tweaks variants based on the source if needed.
|
||||
if ( 'custom' === $source ) {
|
||||
// Decode the FormData sent via POST.
|
||||
$variants = json_decode( $variants, true );
|
||||
}
|
||||
|
||||
foreach ( $variants as $variant ) {
|
||||
// Move the uploaded font asset from the temp folder to the fonts directory.
|
||||
if ( ! function_exists( 'wp_handle_upload' ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/file.php';
|
||||
}
|
||||
|
||||
$file = $variant['src'];
|
||||
|
||||
// If custom assume the font is being uploaded.
|
||||
if ( 'custom' === $source ) {
|
||||
$file_params = $request->get_file_params();
|
||||
$file = $file_params[ $variant['src'] ] ?? $variant['src'];
|
||||
}
|
||||
|
||||
$font_file = GeneratePress_Pro_Font_Library::handle_font_file_upload( $variant, $slug, $file );
|
||||
|
||||
if ( is_wp_error( $font_file ) ) {
|
||||
$results['error'][] = array(
|
||||
'font' => $variant,
|
||||
'message' => $font_file->get_error_message(),
|
||||
);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get the font post for this variant.
|
||||
$font_post = self::get_font_post( $variant, $slug );
|
||||
|
||||
if ( is_wp_error( $font_post ) ) {
|
||||
return $this->error( 500, __( 'Failed to create font post.', 'gp-premium' ) );
|
||||
}
|
||||
|
||||
if ( 'google' === $source ) {
|
||||
$font_family = explode( ', ', $font['fontFamily'] ?? '' );
|
||||
// Remove the main font-family.
|
||||
array_shift( $font_family );
|
||||
|
||||
// Set the fallback if we can infer one.
|
||||
if ( $font_family ) {
|
||||
$fallback = implode( ', ', $font_family );
|
||||
update_post_meta( $font_post, 'gp_font_fallback', $fallback );
|
||||
}
|
||||
}
|
||||
|
||||
$existing_variants = get_post_meta( $font_post, 'gp_font_variants', true );
|
||||
|
||||
if ( ! is_array( $variants ) ) {
|
||||
$existing_variants = array();
|
||||
}
|
||||
|
||||
$checked_variants = GeneratePress_Pro_Font_Library::check_variants(
|
||||
$existing_variants,
|
||||
array(
|
||||
'src' => $font_file['url'],
|
||||
'fontFamily' => $variant['fontFamily'],
|
||||
'fontStyle' => $variant['fontStyle'],
|
||||
'fontWeight' => $variant['fontWeight'],
|
||||
'name' => GeneratePress_Pro_Font_Library::get_variant_name( $variant ),
|
||||
'isVariable' => $variant['isVariable'] ?? false,
|
||||
'source' => 'custom',
|
||||
'disabled' => false,
|
||||
'preview' => '',
|
||||
)
|
||||
);
|
||||
|
||||
// Update the font post meta with merged variants.
|
||||
update_post_meta( $font_post, 'gp_font_variants', $checked_variants );
|
||||
|
||||
// Generate the font CSS.
|
||||
$generate_css = $this->build_css_file();
|
||||
|
||||
if ( false === $generate_css->data['success'] ) {
|
||||
return $this->error( 500, __( 'CSS Generation failed', 'gp-premium' ) );
|
||||
}
|
||||
|
||||
$results['ID'] = $font_post;
|
||||
$results['variants'] = $checked_variants;
|
||||
}
|
||||
|
||||
return $this->success( $results );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get font library settings.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function get_settings() {
|
||||
return $this->success( get_option( 'gp_font_library_settings', array() ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Update font library settings.
|
||||
*
|
||||
* @param WP_REST_Request $request request object.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function set_settings( WP_REST_Request $request ) {
|
||||
$settings = $request->get_param( 'settings' );
|
||||
$sanitized_settings = array();
|
||||
|
||||
foreach ( $settings as $setting => $value ) {
|
||||
if ( 'google_gdpr' === $setting ) {
|
||||
$sanitized_settings[ $setting ] = (bool) $value;
|
||||
} elseif ( 'preferred_subset' === $setting ) {
|
||||
// Stored as an array to support multiple preferred subsets in the future.
|
||||
$sanitized_settings[ $setting ] = array( sanitize_text_field( $value ) );
|
||||
} else {
|
||||
$sanitized_settings[ $setting ] = sanitize_text_field( $value );
|
||||
}
|
||||
}
|
||||
|
||||
$updated = update_option(
|
||||
GeneratePress_Pro_Font_Library::SETTINGS_OPTION,
|
||||
$sanitized_settings,
|
||||
false
|
||||
);
|
||||
|
||||
if ( $updated ) {
|
||||
// Return success.
|
||||
return $this->success(
|
||||
array(
|
||||
'message' => __( 'Font settings successfully updated!', 'gp-premium' ),
|
||||
'response' => $updated,
|
||||
'settings' => $sanitized_settings,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return $this->failed(
|
||||
array(
|
||||
'message' => __( 'Failed to update font settings.', 'gp-premium' ),
|
||||
'settings' => $sanitized_settings,
|
||||
)
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a font post.
|
||||
*
|
||||
* @param WP_REST_Request $request request object.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function update_font_post( WP_REST_Request $request ) {
|
||||
$font_id = $request->get_param( 'id' );
|
||||
$status = $request->get_param( 'status' );
|
||||
$font_family_alias = $request->get_param( 'alias' );
|
||||
$new_variants = $request->get_param( 'newVariants' );
|
||||
$delete_variants = $request->get_param( 'deleteVariants' );
|
||||
$font_display = $request->get_param( 'fontDisplay' );
|
||||
$fallback = $request->get_param( 'fallback' );
|
||||
$css_variable = $request->get_param( 'cssVariable' );
|
||||
$slug = get_post_field( 'post_name', $font_id );
|
||||
|
||||
// Update the font post.
|
||||
wp_update_post(
|
||||
array(
|
||||
'ID' => $font_id,
|
||||
'post_status' => $status,
|
||||
'meta_input' => array(
|
||||
'gp_font_family_alias' => $font_family_alias,
|
||||
'gp_font_variants' => $new_variants,
|
||||
'gp_font_display' => $font_display,
|
||||
'gp_font_fallback' => $fallback,
|
||||
'gp_font_variable' => $css_variable,
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
$upload_dir = wp_get_upload_dir();
|
||||
$base_path = trailingslashit( $upload_dir['basedir'] ) . 'generatepress/fonts/' . $slug . '/';
|
||||
foreach ( $delete_variants as $variant ) {
|
||||
if ( isset( $variant['deleteStatus'] ) && $variant['deleteStatus'] ) {
|
||||
$file_path = $base_path . basename( $variant['src'] );
|
||||
if ( file_exists( $file_path ) ) {
|
||||
unlink( $file_path );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Regenerate the font CSS.
|
||||
$this->build_css_file();
|
||||
|
||||
// Return success.
|
||||
return $this->success( __( 'Font post successfully updated!', 'gp-premium' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get edit options permissions.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function update_settings_permission() {
|
||||
return current_user_can( 'manage_options' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get edit posts permissions.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function edit_posts_permission() {
|
||||
return current_user_can( 'edit_posts' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Success rest.
|
||||
*
|
||||
* @param mixed $response response data.
|
||||
* @param mixed $data data.
|
||||
* @return mixed
|
||||
*/
|
||||
public function success( $response, $data = null ) {
|
||||
return new WP_REST_Response(
|
||||
array(
|
||||
'success' => true,
|
||||
'response' => $response,
|
||||
'data' => $data,
|
||||
),
|
||||
200
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Failed rest.
|
||||
*
|
||||
* @param mixed $response response data.
|
||||
* @return mixed
|
||||
*/
|
||||
public function failed( $response ) {
|
||||
return new WP_REST_Response(
|
||||
array(
|
||||
'success' => false,
|
||||
'response' => $response,
|
||||
),
|
||||
200
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Error rest.
|
||||
*
|
||||
* @param mixed $code error code.
|
||||
* @param mixed $response response data.
|
||||
* @return mixed
|
||||
*/
|
||||
public function error( $code, $response ) {
|
||||
return new WP_REST_Response(
|
||||
array(
|
||||
'error' => true,
|
||||
'success' => false,
|
||||
'error_code' => $code,
|
||||
'response' => $response,
|
||||
),
|
||||
500
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
GeneratePress_Pro_Font_Library_Rest::get_instance();
|
||||
@ -0,0 +1,840 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the Font Library.
|
||||
*
|
||||
* @since 2.5.0
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
/**
|
||||
* Font library class.
|
||||
*/
|
||||
class GeneratePress_Pro_Font_Library extends GeneratePress_Pro_Singleton {
|
||||
const FONT_LIBRARY_CPT = 'gp_font';
|
||||
const FONTS_MAX_QUERY = 100;
|
||||
const CSS_VAR_PREFIX = '--gp-font--';
|
||||
const SETTINGS_OPTION = 'gp_font_library_settings';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function init() {
|
||||
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_font_css' ), 1 );
|
||||
|
||||
if ( ! is_admin() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
add_filter( 'block_editor_settings_all', array( $this, 'add_fonts_to_editor' ) );
|
||||
add_filter( 'generate_dashboard_tabs', array( $this, 'add_dashboard_tab' ) );
|
||||
add_action( 'admin_menu', array( $this, 'add_menu' ), 100 );
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
|
||||
add_filter( 'generate_dashboard_screens', array( $this, 'add_dashboard_screen' ) );
|
||||
add_action( 'admin_head', array( $this, 'add_head_tags' ), 0 );
|
||||
add_action( 'import_post_meta', array( $this, 'update_post_meta' ), 100, 3 );
|
||||
add_action( 'wp_import_existing_post', array( $this, 'maybe_font_exists' ), 10, 2 );
|
||||
add_action( 'save_post_' . self::FONT_LIBRARY_CPT, array( $this, 'build_css_file' ), 100, 3 );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the Font Library tab to our Dashboard tabs.
|
||||
*
|
||||
* @param array $tabs Existing tabs.
|
||||
* @return array New tabs.
|
||||
*/
|
||||
public function add_dashboard_tab( $tabs ) {
|
||||
$screen = get_current_screen();
|
||||
|
||||
$tabs['Fonts'] = array(
|
||||
'name' => __( 'Font Library', 'gp-premium' ),
|
||||
'url' => self::get_font_library_uri(),
|
||||
'class' => 'appearance_page_generatepress-font-library' === $screen->id ? 'active' : '',
|
||||
'id' => 'gp-font-library-tab',
|
||||
);
|
||||
|
||||
return $tabs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add our menu item.
|
||||
*/
|
||||
public function add_menu() {
|
||||
add_submenu_page(
|
||||
'themes.php',
|
||||
__( 'Font Library', 'gp-premium' ),
|
||||
__( 'Font Library', 'gp-premium' ),
|
||||
'manage_options',
|
||||
'generatepress-font-library',
|
||||
array( $this, 'library_page' )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add our page.
|
||||
*/
|
||||
public function library_page() {
|
||||
echo '<div id="gp-font-library" class="gp-font-library gp-premium"></div>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Add tags to the head element for the font library page.
|
||||
*/
|
||||
public function add_head_tags() {
|
||||
$screen = get_current_screen();
|
||||
$user_id = get_current_user_id();
|
||||
$google_gdpr = (bool) self::get_settings( 'google_gdpr' );
|
||||
|
||||
// Stop if we're not on the right page or the user hasn't opted in to google fonts.
|
||||
if ( 'appearance_page_generatepress-font-library' !== $screen->id || ! $google_gdpr ) {
|
||||
return;
|
||||
}
|
||||
|
||||
echo '
|
||||
<link href="https://fonts.gstatic.com" rel="preconnect" crossorigin="anonymous" id="gp-preconnect-gstatic">
|
||||
<link href="https://fonts.googleapis.com" rel="preconnect" id="gp-preconnect-google-api">
|
||||
<link href="https://s.w.org" rel="preconnect" id="gp-preconnect-wp-cdn">
|
||||
';
|
||||
}
|
||||
|
||||
/**
|
||||
* Add our scripts.
|
||||
*/
|
||||
public function enqueue_scripts() {
|
||||
$screen = get_current_screen();
|
||||
|
||||
if ( 'appearance_page_generatepress-font-library' === $screen->id ) {
|
||||
$assets = generate_premium_get_enqueue_assets( 'font-library' );
|
||||
$upload_dir = wp_get_upload_dir();
|
||||
|
||||
wp_enqueue_script(
|
||||
'generatepress-pro-font-library',
|
||||
GP_PREMIUM_DIR_URL . 'dist/font-library.js',
|
||||
$assets['dependencies'],
|
||||
$assets['version'],
|
||||
true
|
||||
);
|
||||
|
||||
if ( function_exists( 'wp_set_script_translations' ) ) {
|
||||
wp_set_script_translations( 'generatepress-pro-font-library', 'gp-premium', GP_PREMIUM_DIR_PATH . 'langs' );
|
||||
}
|
||||
|
||||
wp_localize_script(
|
||||
'generatepress-pro-font-library',
|
||||
'gppFontLibrary',
|
||||
array(
|
||||
'uploadsUrl' => $upload_dir['baseurl'],
|
||||
)
|
||||
);
|
||||
|
||||
wp_enqueue_style(
|
||||
'generatepress-pro-font-library',
|
||||
GP_PREMIUM_DIR_URL . 'dist/font-library.css',
|
||||
array( 'wp-components' ),
|
||||
GP_PREMIUM_VERSION
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell GeneratePress this is an admin page.
|
||||
*
|
||||
* @param array $screens Existing screens.
|
||||
*/
|
||||
public function add_dashboard_screen( $screens ) {
|
||||
$screens[] = 'appearance_page_generatepress-font-library';
|
||||
|
||||
return $screens;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get font posts.
|
||||
*
|
||||
* @param string $name font name.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function get_fonts( $name = null ) {
|
||||
$args = array(
|
||||
'post_type' => self::FONT_LIBRARY_CPT,
|
||||
'post_status' => 'any',
|
||||
'numberposts' => GeneratePress_Pro_Font_Library::FONTS_MAX_QUERY, // phpcs:ignore
|
||||
'fields' => 'ids',
|
||||
'no_found_rows' => true,
|
||||
'update_post_meta_cache' => false,
|
||||
'update_post_term_cache' => false,
|
||||
'order' => 'ASC',
|
||||
);
|
||||
|
||||
if ( $name ) {
|
||||
$args['name'] = $name;
|
||||
}
|
||||
|
||||
$all_fonts = get_posts( $args );
|
||||
$response = array();
|
||||
|
||||
if ( is_array( $all_fonts ) ) {
|
||||
foreach ( $all_fonts as $font_post ) {
|
||||
$font_name = get_the_title( $font_post );
|
||||
$alias = get_post_meta( $font_post, 'gp_font_family_alias', true );
|
||||
$slug = get_post_field( 'post_name', $font_post );
|
||||
$status = get_post_status( $font_post );
|
||||
$fallback = get_post_meta( $font_post, 'gp_font_fallback', true );
|
||||
$preview = get_post_meta( $font_post, 'gp_font_preview', true );
|
||||
$font_family = empty( $alias ) ? $font_name : $alias;
|
||||
|
||||
$font_family = "\"$font_family\"";
|
||||
|
||||
if ( $fallback ) {
|
||||
$font_family .= ", $fallback";
|
||||
}
|
||||
|
||||
// Setup the font data.
|
||||
$response[] = array(
|
||||
'id' => $font_post,
|
||||
'name' => $font_name,
|
||||
'fontFamily' => $font_family,
|
||||
'disabled' => 'publish' !== $status,
|
||||
'slug' => get_post_field( 'post_name', $font_post ),
|
||||
'alias' => get_post_meta( $font_post, 'gp_font_family_alias', true ),
|
||||
'variants' => get_post_meta( $font_post, 'gp_font_variants', true ),
|
||||
'source' => get_post_meta( $font_post, 'gp_font_source', true ),
|
||||
'fallback' => $fallback,
|
||||
'fontDisplay' => get_post_meta( $font_post, 'gp_font_display', true ),
|
||||
'preview' => empty( $preview ) ? '' : $preview,
|
||||
'cssVariable' => get_post_meta( $font_post, 'gp_font_variable', true ),
|
||||
);
|
||||
}
|
||||
|
||||
return $response;
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the font library URI.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_font_library_uri() {
|
||||
return admin_url( 'themes.php?page=generatepress-font-library' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Font format mappings.
|
||||
*
|
||||
* @param array $font Array of font data.
|
||||
* @return string
|
||||
*/
|
||||
public static function get_font_face_rule( $font ) {
|
||||
$css = '';
|
||||
if ( ! empty( $font['variants'] ) ) {
|
||||
$font_family = $font['alias'] ? $font['alias'] : $font['name'];
|
||||
|
||||
foreach ( $font['variants'] as $variant ) {
|
||||
$is_disabled = $variant['disabled'] ?? false;
|
||||
|
||||
if ( $is_disabled ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$format = self::get_font_format( $variant['src'] );
|
||||
$css .= "@font-face {
|
||||
font-display: {$font['fontDisplay']};
|
||||
font-family: \"$font_family\";
|
||||
font-style: {$variant['fontStyle']};
|
||||
font-weight: {$variant['fontWeight']};
|
||||
src: url('{$variant['src']}')$format;
|
||||
}\n";
|
||||
}
|
||||
}
|
||||
|
||||
return $css;
|
||||
}
|
||||
|
||||
/**
|
||||
* Font format mappings.
|
||||
*
|
||||
* @param string $font_url File extension.
|
||||
* @return string|null
|
||||
*/
|
||||
private static function get_font_format( $font_url ) {
|
||||
$extension = pathinfo( $font_url, PATHINFO_EXTENSION );
|
||||
|
||||
$format_map = array(
|
||||
'woff' => 'woff',
|
||||
'woff2' => 'woff2',
|
||||
'ttf' => 'truetype',
|
||||
'otf' => 'opentype',
|
||||
);
|
||||
|
||||
$format_string = isset( $format_map[ $extension ] ) ? $format_map[ $extension ] : null;
|
||||
return $format_string ? " format('$format_string')" : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a font variant string to determine weight and style.
|
||||
* Returns an array with 'weight', 'style'.
|
||||
*
|
||||
* @param string $variant Font variant string.
|
||||
* @return array
|
||||
*/
|
||||
private static function parse_font_variant( $variant ) {
|
||||
$weight = '400';
|
||||
$style = 'normal';
|
||||
|
||||
if ( 'regular' === $variant ) {
|
||||
return array(
|
||||
'weight' => $weight,
|
||||
'style' => $style,
|
||||
);
|
||||
}
|
||||
|
||||
if ( 'italic' === $variant || strpos( $variant, 'italic' ) !== false ) {
|
||||
$style = 'italic';
|
||||
if ( strpos( $variant, 'italic' ) !== false ) {
|
||||
$variant = str_replace( 'italic', '', $variant );
|
||||
}
|
||||
}
|
||||
|
||||
return array(
|
||||
'weight' => empty( $variant ) ? $weight : $variant,
|
||||
'style' => $style,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the existing font variant exists.
|
||||
*
|
||||
* Overwrite it if it exists, and delete associated font file if different.
|
||||
* Otherwise, add new variant if not found in the list.
|
||||
*
|
||||
* @param array $variants Font variants.
|
||||
* @param int $new_variant New variant to be added.
|
||||
* @param string $base_path Base path.
|
||||
*
|
||||
* @return array The resolved list of variants.
|
||||
*/
|
||||
public static function check_variants( $variants, $new_variant ) {
|
||||
$checked_variants = $variants;
|
||||
if ( empty( $variants ) ) {
|
||||
return array( $new_variant );
|
||||
}
|
||||
|
||||
$found = false;
|
||||
foreach ( $variants as $key => $variant ) {
|
||||
if ( $variant['name'] === $new_variant['name'] ) {
|
||||
$checked_variants[ $key ] = $new_variant;
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $found ) {
|
||||
$checked_variants[] = $new_variant;
|
||||
}
|
||||
|
||||
return $checked_variants;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format uploaded font variant.
|
||||
*
|
||||
* @param array $variant Font variant.
|
||||
* @return string The formatted variant name.
|
||||
*/
|
||||
public static function get_variant_name( $variant ) {
|
||||
// Force variant to array-like structure.
|
||||
$is_italic = 'italic' === $variant['fontStyle'];
|
||||
|
||||
$labels = array(
|
||||
'100' => 'Thin 100',
|
||||
'200' => 'ExtraLight 200',
|
||||
'250' => 'ExtraLight 250',
|
||||
'300' => 'Light 300',
|
||||
'400' => 'Regular 400',
|
||||
'regular' => 'Regular 400',
|
||||
'500' => 'Medium 500',
|
||||
'600' => 'SemiBold 600',
|
||||
'700' => 'Bold 700',
|
||||
'800' => 'ExtraBold 800',
|
||||
'900' => 'Black 900',
|
||||
);
|
||||
|
||||
$resolved_label = $labels[ $variant['fontWeight'] ];
|
||||
|
||||
if ( $resolved_label ) {
|
||||
return $resolved_label . ( $is_italic ? ' Italic' : '' );
|
||||
}
|
||||
|
||||
return str_replace( ' ', '-', $variant['fontWeight'] ) . ' ' . __( '(Variable)', 'gp-premium' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Format a font file name to remove spaces, commas.
|
||||
*
|
||||
* @param string $name Font name.
|
||||
* @return string
|
||||
*/
|
||||
public static function format_font_filename( $name ) {
|
||||
// Replace spaces and commas in file name with hyphen.
|
||||
$name = preg_replace( '/[ ,]/', '-', $name );
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the expected mime-type values for font files, depending on PHP version.
|
||||
*
|
||||
* This is needed because font mime types vary by PHP version, so checking the PHP version
|
||||
* is necessary until a list of valid mime-types for each file extension can be provided to
|
||||
* the 'upload_mimes' filter.
|
||||
*
|
||||
* @return array A collection of mime types keyed by file extension.
|
||||
*/
|
||||
public static function get_allowed_font_mime_types() {
|
||||
$php_7_ttf_mime_type = PHP_VERSION_ID >= 70300 ? 'application/font-sfnt' : 'application/x-font-ttf';
|
||||
|
||||
return array(
|
||||
'otf' => 'application/vnd.ms-opentype',
|
||||
'ttf' => PHP_VERSION_ID >= 70400 ? 'font/sfnt' : $php_7_ttf_mime_type,
|
||||
'woff' => PHP_VERSION_ID >= 80112 ? 'font/woff' : 'application/font-woff',
|
||||
'woff2' => PHP_VERSION_ID >= 80112 ? 'font/woff2' : 'application/font-woff2',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the font CSS file.
|
||||
*
|
||||
* @param string $type Type of path to return. Can return the `path` or `url` to the file.
|
||||
* @return string
|
||||
*/
|
||||
public static function get_font_css_file( $type ) {
|
||||
$upload_dir = wp_get_upload_dir();
|
||||
$file_path = 'generatepress/fonts/fonts.css';
|
||||
$base = '';
|
||||
|
||||
if ( 'url' === $type ) {
|
||||
$base = $upload_dir['baseurl'];
|
||||
} elseif ( 'path' === $type ) {
|
||||
$base = $upload_dir['basedir'];
|
||||
}
|
||||
|
||||
return $base ? trailingslashit( $base ) . $file_path : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the font CSS file URL.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function get_font_css_file_url() {
|
||||
$css_file_url = self::get_font_css_file( 'url' );
|
||||
$css_file_dir = self::get_font_css_file( 'path' );
|
||||
|
||||
return file_exists( $css_file_dir )
|
||||
? $css_file_url
|
||||
: '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Add our font CSS.
|
||||
*/
|
||||
public function enqueue_font_css() {
|
||||
$font_file_url = self::get_font_css_file_url();
|
||||
|
||||
// Enqueue the custom fonts CSS if the file exists.
|
||||
if ( $font_file_url ) {
|
||||
$version = filemtime( self::get_font_css_file( 'path' ) ) ?? GP_PREMIUM_VERSION;
|
||||
|
||||
wp_enqueue_style( 'generatepress-fonts', $font_file_url, array(), $version );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a font to the uploads directory either from $_FILES or a remote URL.
|
||||
*
|
||||
* @param array $variant Font variant object.
|
||||
* @param string $slug Font slug.
|
||||
* @param array|null $file Single file item from $_FILES or null.
|
||||
* @return array|WP_Error Array containing uploaded file attributes on success, or WP_Error object on failure.
|
||||
*/
|
||||
public static function handle_font_file_upload( $variant, $slug, $file ) {
|
||||
if ( ! $slug ) {
|
||||
$slug = $variant['slug'] ?? '';
|
||||
}
|
||||
$upload_dir = wp_get_upload_dir();
|
||||
$base_path = trailingslashit( $upload_dir['basedir'] ) . 'generatepress/fonts/' . $slug . '/';
|
||||
|
||||
// Ensure the directory exists.
|
||||
if ( ! file_exists( $base_path ) ) {
|
||||
wp_mkdir_p( $base_path );
|
||||
}
|
||||
|
||||
/**
|
||||
* If $file is an array, assume it's a param from $_FILES.
|
||||
*/
|
||||
if ( is_array( $file ) ) {
|
||||
$file_name = basename( $file['name'] );
|
||||
$file_path = $base_path . $file_name;
|
||||
|
||||
// Check if the font file exists and delete it if so.
|
||||
if ( file_exists( $file_path ) ) {
|
||||
unlink( $file_path );
|
||||
}
|
||||
|
||||
$set_upload_dir = function ( $font_dir ) use ( $base_path, $slug ) {
|
||||
$font_dir['path'] = $base_path;
|
||||
$font_dir['url'] = untrailingslashit(
|
||||
content_url( 'uploads/generatepress/fonts/' . $slug )
|
||||
);
|
||||
$font_dir['subdir'] = '';
|
||||
return $font_dir;
|
||||
};
|
||||
|
||||
add_filter( 'upload_mimes', array( __CLASS__, 'get_allowed_font_mime_types' ) );
|
||||
add_filter( 'upload_dir', $set_upload_dir );
|
||||
|
||||
$overrides = array(
|
||||
'upload_error_handler' => array( __CLASS__, 'handle_font_file_upload_error' ),
|
||||
// Not testing a form submission.
|
||||
'test_form' => false,
|
||||
// Only allow uploading font files for this request.
|
||||
'mimes' => self::get_allowed_font_mime_types(),
|
||||
);
|
||||
|
||||
$uploaded_file = wp_handle_upload( $file, $overrides );
|
||||
|
||||
remove_filter( 'upload_dir', $set_upload_dir );
|
||||
remove_filter( 'upload_mimes', array( __CLASS__, 'get_allowed_font_mime_types' ) );
|
||||
|
||||
return $uploaded_file;
|
||||
}
|
||||
|
||||
$file_name = basename( $variant['src'] );
|
||||
$file_path = $base_path . $file_name;
|
||||
|
||||
$response = wp_remote_get( $variant['src'] );
|
||||
|
||||
if ( is_wp_error( $response ) ) {
|
||||
$error_message = $response->get_error_message();
|
||||
return new WP_Error( 500, "Failed to download {$variant['fontFamily']} from {$variant['src']}: $error_message" );
|
||||
}
|
||||
|
||||
// Save the file.
|
||||
$filesystem = generate_premium_get_wp_filesystem();
|
||||
|
||||
if ( ! $filesystem ) {
|
||||
return new WP_Error( 500, 'Error setting up the file system object.' );
|
||||
}
|
||||
|
||||
$file_contents = wp_remote_retrieve_body( $response );
|
||||
|
||||
if ( ! $file_contents ) {
|
||||
return new WP_Error( 500, "Failed to download $variant from {$variant['src']}: Empty body" );
|
||||
}
|
||||
|
||||
// Assuming $filesystem is already set up correctly.
|
||||
$chmod_file = defined( 'FS_CHMOD_FILE' ) ? FS_CHMOD_FILE : 0644;
|
||||
|
||||
if ( is_writable( $file_path ) || is_writable( dirname( $file_path ) ) ) {
|
||||
if ( $filesystem->put_contents( $file_path, $file_contents, $chmod_file ) ) {
|
||||
return array(
|
||||
'file' => $file_path,
|
||||
'url' => trailingslashit( $upload_dir['baseurl'] ) . 'generatepress/fonts/' . $slug . '/' . $file_name,
|
||||
);
|
||||
} else {
|
||||
return new WP_Error( 500, "Failed to download $variant from {$variant['src']}." );
|
||||
}
|
||||
}
|
||||
|
||||
return new WP_Error( 500, 'Unable to write to file path.' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles file upload error.
|
||||
*
|
||||
* @param array $file File upload data.
|
||||
* @param string $message Error message from wp_handle_upload().
|
||||
* @return WP_Error WP_Error object.
|
||||
*/
|
||||
public static function handle_font_file_upload_error( $file, $message ) {
|
||||
$status = 500;
|
||||
$code = 'rest_font_upload_unknown_error';
|
||||
|
||||
// Note: The absence of a text domain is intentional here as it's checking against a WP core string.
|
||||
if ( __( 'Sorry, you are not allowed to upload this file type.' ) === $message ) {
|
||||
$status = 400;
|
||||
$code = 'rest_font_upload_invalid_file_type';
|
||||
}
|
||||
|
||||
return new WP_Error( $code, $message, array( 'status' => $status ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs on wp_after_insert_post to download remote font files.
|
||||
*
|
||||
* @param int $post_id Post ID.
|
||||
* @param string $key The meta key that was imported.
|
||||
* @param mixed $value The meta value that was imported.
|
||||
* @return void
|
||||
*/
|
||||
public function update_post_meta( $post_id, $key, $value ) {
|
||||
$upload_dir = wp_get_upload_dir();
|
||||
// Bail if we're not working with a font library post variant meta value.
|
||||
if ( get_post_type( $post_id ) !== self::FONT_LIBRARY_CPT || 'gp_font_variants' !== $key ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check the src of each variant and if the URL is remote, download the file.
|
||||
$variants = $value;
|
||||
|
||||
// Stop here if variants aren't found.
|
||||
if ( ! $variants ) {
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ( $variants as &$variant ) {
|
||||
$site_hostname = wp_parse_url( site_url(), PHP_URL_HOST );
|
||||
|
||||
// Bail if the variant src is already on this site.
|
||||
if ( strpos( $variant['src'], $site_hostname ) !== false ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$font_slug = get_post_field( 'post_name', $post_id );
|
||||
$font_dir = trailingslashit( $upload_dir['basedir'] ) . 'generatepress/fonts/' . $font_slug . '/';
|
||||
$font_base_url = trailingslashit( $upload_dir['baseurl'] ) . 'generatepress/fonts/' . $font_slug . '/';
|
||||
$response = wp_remote_get( $variant['src'] );
|
||||
$response_code = (int) wp_remote_retrieve_response_code( $response );
|
||||
|
||||
if ( is_wp_error( $response ) || 200 !== $response_code ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$file_name = basename( $variant['src'] );
|
||||
$file_path = $font_dir . $file_name;
|
||||
|
||||
// If the directory exists, remove it and it's contents.
|
||||
if ( ! file_exists( $font_dir ) ) {
|
||||
wp_mkdir_p( $font_dir );
|
||||
}
|
||||
|
||||
// Setup filesystem.
|
||||
$filesystem = generate_premium_get_wp_filesystem();
|
||||
|
||||
// Bail here if the filesystem can't initialize.
|
||||
if ( ! $filesystem ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$file_contents = wp_remote_retrieve_body( $response );
|
||||
|
||||
// Bail if file contents are empty or not found.
|
||||
if ( ! $file_contents ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$chmod_file = defined( 'FS_CHMOD_FILE' ) ? FS_CHMOD_FILE : 0644;
|
||||
|
||||
if ( is_writable( $file_path ) || is_writable( dirname( $file_path ) ) ) {
|
||||
// Bail if the file can't be written.
|
||||
if ( ! $filesystem->put_contents( $file_path, $file_contents, $chmod_file ) ) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$variant['src'] = $font_base_url . $file_name;
|
||||
}
|
||||
|
||||
// Update the meta value with the new src for each variant.
|
||||
update_post_meta( $post_id, 'gp_font_variants', $variants );
|
||||
}
|
||||
|
||||
/**
|
||||
* Recursive function to delete a directory and its contents.
|
||||
*
|
||||
* @param string $dir directory path.
|
||||
* @return bool
|
||||
*/
|
||||
public static function delete_directory( $dir ) {
|
||||
if ( ! file_exists( $dir ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( ! is_dir( $dir ) ) {
|
||||
return unlink( $dir );
|
||||
}
|
||||
|
||||
foreach ( scandir( $dir ) as $item ) {
|
||||
if ( '.' === $item || '..' === $item ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( ! self::delete_directory( $dir . DIRECTORY_SEPARATOR . $item ) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return rmdir( $dir );
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the post exists by checking the title.
|
||||
*
|
||||
* @param bool $post_exists Unused. The default post_exists function value.
|
||||
* @param array $font The font post array.
|
||||
* @return int Post ID on success, 0 on failure.
|
||||
*/
|
||||
public function maybe_font_exists( $post_exists, $font ) {
|
||||
/**
|
||||
* The value of $font here is a post array from the XML import, not our standard
|
||||
* font array. We need to check if the font exists by title.
|
||||
*/
|
||||
return post_exists( $font['post_title'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the CSS variables and values for each font-family.
|
||||
*
|
||||
* @return string The color palette variable CSS declaration.
|
||||
*/
|
||||
public static function get_css_variables() {
|
||||
$fonts = self::get_fonts();
|
||||
|
||||
if ( ! $fonts ) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$variables = ":root {\n";
|
||||
|
||||
foreach ( $fonts as $font ) {
|
||||
if ( isset( $font['disabled'] ) && $font['disabled'] ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$variables .= sprintf(
|
||||
"%s: %s;\n",
|
||||
$font['cssVariable'],
|
||||
$font['fontFamily']
|
||||
);
|
||||
}
|
||||
|
||||
$variables .= "}\n";
|
||||
|
||||
return $variables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add CSS variable definitions to the block editor.
|
||||
*
|
||||
* @param string $css The generated CSS for the stylesheet.
|
||||
* @return void
|
||||
**/
|
||||
public function add_variable_definitions_to_editor( $css ) {
|
||||
wp_add_inline_style( 'generateblocks-pro', self::get_css_variables() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the font CSS file.
|
||||
*
|
||||
* @return string|WP_Error The file path on success, WP_Error on failure.
|
||||
*/
|
||||
public static function build_css_file() {
|
||||
$generated_css = self::generate_font_css();
|
||||
$upload_dir = wp_get_upload_dir();
|
||||
|
||||
// Save the generated font CSS to a file.
|
||||
$base_path_dir = trailingslashit( $upload_dir['basedir'] ) . 'generatepress/fonts/';
|
||||
$file_path = $base_path_dir . 'fonts.css';
|
||||
$filesystem = generate_premium_get_wp_filesystem();
|
||||
|
||||
if ( ! $filesystem ) {
|
||||
return new WP_Error( 500, __( 'Error setting up the file system object.', 'gp-premium' ) );
|
||||
}
|
||||
|
||||
// Assuming $filesystem is already set up correctly.
|
||||
$chmod_file = defined( 'FS_CHMOD_FILE' ) ? FS_CHMOD_FILE : 0644;
|
||||
|
||||
if ( empty( $generated_css ) ) {
|
||||
if ( file_exists( $file_path ) ) {
|
||||
$filesystem->delete( $file_path );
|
||||
}
|
||||
} else {
|
||||
if ( is_writable( $file_path ) || is_writable( dirname( $file_path ) ) ) {
|
||||
if ( ! $filesystem->put_contents( $file_path, $generated_css, $chmod_file ) ) {
|
||||
return new WP_Error( 500, __( 'Failed to write Google font CSS to file.', 'gp-premium' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $file_path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate font CSS.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function generate_font_css() {
|
||||
$fonts = self::get_fonts();
|
||||
$variables = self::get_css_variables();
|
||||
$css = $variables . "\n";
|
||||
|
||||
if ( $fonts ) {
|
||||
foreach ( $fonts as $font ) {
|
||||
// Add the generated CSS.
|
||||
$css .= self::get_font_face_rule( $font );
|
||||
}
|
||||
}
|
||||
|
||||
return apply_filters( 'generatepress_font_css', $css, $fonts );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the font CSS to the block editor.
|
||||
*
|
||||
* @param array $settings The block editor settings.
|
||||
* @return array
|
||||
*/
|
||||
public function add_fonts_to_editor( $settings ) {
|
||||
$font_file_url = self::get_font_css_file_url();
|
||||
|
||||
if ( ! $font_file_url ) {
|
||||
return $settings;
|
||||
}
|
||||
|
||||
$fonts_import = sprintf(
|
||||
'@import url("%s");',
|
||||
$font_file_url
|
||||
);
|
||||
|
||||
$settings['styles'][] = array( 'css' => $fonts_import );
|
||||
|
||||
return $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get font library settings. At the moment this is just the Google GDPR setting.
|
||||
*
|
||||
* @param string $setting The setting to retrieve.
|
||||
* @return mixed
|
||||
*/
|
||||
public static function get_settings( $setting = null ) {
|
||||
|
||||
$settings = get_option( self::SETTINGS_OPTION, array() );
|
||||
|
||||
if ( $setting ) {
|
||||
return $settings[ $setting ] ?? null;
|
||||
}
|
||||
|
||||
return $settings;
|
||||
}
|
||||
}
|
||||
|
||||
GeneratePress_Pro_Font_Library::get_instance()->init();
|
||||
@ -0,0 +1,449 @@
|
||||
<?php
|
||||
/**
|
||||
* This file builds an external CSS file for our options.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
/**
|
||||
* Build and enqueue a dynamic stylsheet if needed.
|
||||
*/
|
||||
class GeneratePress_External_CSS_File {
|
||||
/**
|
||||
* Instance.
|
||||
*
|
||||
* @access private
|
||||
* @var object Instance
|
||||
* @since 1.11.0
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* Initiator.
|
||||
*
|
||||
* @since 1.11.0
|
||||
* @return object initialized object of class.
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_dynamic_css' ), 20 );
|
||||
add_action( 'wp', array( $this, 'init' ), 9 );
|
||||
add_action( 'customize_save_after', array( $this, 'delete_saved_time' ) );
|
||||
add_action( 'customize_register', array( $this, 'add_customizer_field' ) );
|
||||
add_filter( 'generate_option_defaults', array( $this, 'add_option_default' ) );
|
||||
add_filter( 'generatepress_dynamic_css_print_method', array( $this, 'set_print_method' ) );
|
||||
|
||||
if ( ! empty( $_POST ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Just checking, false positive.
|
||||
add_action( 'wp_ajax_generatepress_regenerate_css_file', array( $this, 'regenerate_css_file' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set our CSS Print Method default.
|
||||
*
|
||||
* @param array $defaults Our existing defaults.
|
||||
*/
|
||||
public function add_option_default( $defaults ) {
|
||||
$defaults['css_print_method'] = 'inline';
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add our option to the Customizer.
|
||||
*
|
||||
* @param object $wp_customize The Customizer object.
|
||||
*/
|
||||
public function add_customizer_field( $wp_customize ) {
|
||||
if ( ! function_exists( 'generate_get_defaults' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$defaults = generate_get_defaults();
|
||||
|
||||
require_once GP_LIBRARY_DIRECTORY . 'customizer-helpers.php';
|
||||
|
||||
if ( method_exists( $wp_customize, 'register_control_type' ) ) {
|
||||
$wp_customize->register_control_type( 'GeneratePress_Action_Button_Control' );
|
||||
}
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[css_print_method]',
|
||||
array(
|
||||
'default' => $defaults['css_print_method'],
|
||||
'type' => 'option',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_choices',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
'generate_settings[css_print_method]',
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => __( 'Dynamic CSS Print Method', 'gp-premium' ),
|
||||
'description' => __( 'Generating your dynamic CSS in an external file offers significant performance advantages.', 'gp-premium' ),
|
||||
'section' => 'generate_general_section',
|
||||
'choices' => array(
|
||||
'inline' => __( 'Inline Embedding', 'gp-premium' ),
|
||||
'file' => __( 'External File', 'gp-premium' ),
|
||||
),
|
||||
'settings' => 'generate_settings[css_print_method]',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Action_Button_Control(
|
||||
$wp_customize,
|
||||
'generate_regenerate_external_css_file',
|
||||
array(
|
||||
'section' => 'generate_general_section',
|
||||
'data_type' => 'regenerate_external_css',
|
||||
'nonce' => esc_html( wp_create_nonce( 'generatepress_regenerate_css_file' ) ),
|
||||
'label' => __( 'Regenerate CSS File', 'gp-premium' ),
|
||||
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
|
||||
'active_callback' => 'generate_is_using_external_css_file_callback',
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set our CSS Print Method.
|
||||
*
|
||||
* @param string $method The existing method.
|
||||
*/
|
||||
public function set_print_method( $method ) {
|
||||
if ( ! function_exists( 'generate_get_option' ) ) {
|
||||
return $method;
|
||||
}
|
||||
|
||||
return generate_get_option( 'css_print_method' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if we're using file mode or inline mode.
|
||||
*/
|
||||
public function mode() {
|
||||
$mode = generate_get_css_print_method();
|
||||
|
||||
if ( 'file' === $mode && $this->needs_update() ) {
|
||||
$data = get_option( 'generatepress_dynamic_css_data', array() );
|
||||
|
||||
if ( ! isset( $data['updated_time'] ) ) {
|
||||
// No time set, so set the current time minus 5 seconds so the file is still generated.
|
||||
$data['updated_time'] = time() - 5;
|
||||
update_option( 'generatepress_dynamic_css_data', $data );
|
||||
}
|
||||
|
||||
// Only allow processing 1 file every 5 seconds.
|
||||
$current_time = (int) time();
|
||||
$last_time = (int) $data['updated_time'];
|
||||
|
||||
if ( 5 <= ( $current_time - $last_time ) ) {
|
||||
|
||||
// Attempt to write to the file.
|
||||
$mode = ( $this->can_write() && $this->make_css() ) ? 'file' : 'inline';
|
||||
|
||||
// Does again if the file exists.
|
||||
if ( 'file' === $mode ) {
|
||||
$mode = ( file_exists( $this->file( 'path' ) ) ) ? 'file' : 'inline';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set things up.
|
||||
*/
|
||||
public function init() {
|
||||
if ( 'file' === $this->mode() ) {
|
||||
add_filter( 'generate_using_dynamic_css_external_file', '__return_true' );
|
||||
add_filter( 'generate_dynamic_css_skip_cache', '__return_true', 20 );
|
||||
|
||||
// Remove inline CSS in GP < 3.0.0.
|
||||
if ( ! function_exists( 'generate_get_dynamic_css' ) && function_exists( 'generate_enqueue_dynamic_css' ) ) {
|
||||
remove_action( 'wp_enqueue_scripts', 'generate_enqueue_dynamic_css', 50 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue the dynamic CSS.
|
||||
*/
|
||||
public function enqueue_dynamic_css() {
|
||||
if ( 'file' === $this->mode() ) {
|
||||
wp_enqueue_style( 'generatepress-dynamic', esc_url( $this->file( 'uri' ) ), array( 'generate-style' ), null ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
|
||||
|
||||
// Move the child theme after our dynamic stylesheet.
|
||||
if ( is_child_theme() && wp_style_is( 'generate-child', 'enqueued' ) ) {
|
||||
wp_dequeue_style( 'generate-child' );
|
||||
wp_enqueue_style( 'generate-child' );
|
||||
}
|
||||
|
||||
// Re-add no-cache CSS in GP < 3.0.0.
|
||||
if ( ! function_exists( 'generate_get_dynamic_css' ) && function_exists( 'generate_no_cache_dynamic_css' ) ) {
|
||||
$nocache_css = generate_no_cache_dynamic_css();
|
||||
|
||||
if ( function_exists( 'generate_do_icon_css' ) ) {
|
||||
$nocache_css .= generate_do_icon_css();
|
||||
}
|
||||
|
||||
wp_add_inline_style( 'generate-style', wp_strip_all_tags( $nocache_css ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Make our CSS.
|
||||
*/
|
||||
public function make_css() {
|
||||
$content = '';
|
||||
|
||||
if ( function_exists( 'generate_get_dynamic_css' ) ) {
|
||||
$content = generate_get_dynamic_css();
|
||||
} elseif ( function_exists( 'generate_base_css' ) && function_exists( 'generate_font_css' ) && function_exists( 'generate_advanced_css' ) && function_exists( 'generate_spacing_css' ) ) {
|
||||
$content = generate_base_css() . generate_font_css() . generate_advanced_css() . generate_spacing_css();
|
||||
}
|
||||
|
||||
$content = apply_filters( 'generate_external_dynamic_css_output', $content );
|
||||
|
||||
if ( ! $content ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$filesystem = generate_premium_get_wp_filesystem();
|
||||
|
||||
if ( ! $filesystem ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Take care of domain mapping.
|
||||
if ( defined( 'DOMAIN_MAPPING' ) && DOMAIN_MAPPING ) {
|
||||
if ( function_exists( 'domain_mapping_siteurl' ) && function_exists( 'get_original_url' ) ) {
|
||||
$mapped_domain = domain_mapping_siteurl( false );
|
||||
$original_domain = get_original_url( 'siteurl' );
|
||||
|
||||
$content = str_replace( $original_domain, $mapped_domain, $content );
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_writable( $this->file( 'path' ) ) || ( ! file_exists( $this->file( 'path' ) ) && is_writable( dirname( $this->file( 'path' ) ) ) ) ) {
|
||||
$chmod_file = 0644;
|
||||
|
||||
if ( defined( 'FS_CHMOD_FILE' ) ) {
|
||||
$chmod_file = FS_CHMOD_FILE;
|
||||
}
|
||||
|
||||
if ( ! $filesystem->put_contents( $this->file( 'path' ), wp_strip_all_tags( $content ), $chmod_file ) ) {
|
||||
|
||||
// Fail!
|
||||
return false;
|
||||
|
||||
} else {
|
||||
|
||||
$this->update_saved_time();
|
||||
|
||||
// Success!
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the CSS file is writable.
|
||||
*/
|
||||
public function can_write() {
|
||||
global $blog_id;
|
||||
|
||||
// Get the upload directory for this site.
|
||||
$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;
|
||||
|
||||
$file_name = '/style' . $css_blog_id . '.min.css';
|
||||
$folder_path = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . 'generatepress';
|
||||
|
||||
// Does the folder exist?
|
||||
if ( file_exists( $folder_path ) ) {
|
||||
// Folder exists, but is the folder writable?
|
||||
if ( ! is_writable( $folder_path ) ) {
|
||||
// Folder is not writable.
|
||||
// Does the file exist?
|
||||
if ( ! file_exists( $folder_path . $file_name ) ) {
|
||||
// File does not exist, therefore it can't be created
|
||||
// since the parent folder is not writable.
|
||||
return false;
|
||||
} else {
|
||||
// File exists, but is it writable?
|
||||
if ( ! is_writable( $folder_path . $file_name ) ) {
|
||||
// Nope, it's not writable.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// The folder is writable.
|
||||
// Does the file exist?
|
||||
if ( file_exists( $folder_path . $file_name ) ) {
|
||||
// File exists.
|
||||
// Is it writable?
|
||||
if ( ! is_writable( $folder_path . $file_name ) ) {
|
||||
// Nope, it's not writable.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Can we create the folder?
|
||||
// returns true if yes and false if not.
|
||||
return wp_mkdir_p( $folder_path );
|
||||
}
|
||||
|
||||
// all is well!
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the css path or url to the stylesheet
|
||||
*
|
||||
* @param string $target path/url.
|
||||
*/
|
||||
public function file( $target = 'path' ) {
|
||||
global $blog_id;
|
||||
|
||||
// Get the upload directory for this site.
|
||||
$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;
|
||||
|
||||
$file_name = 'style' . $css_blog_id . '.min.css';
|
||||
$folder_path = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . 'generatepress';
|
||||
|
||||
// The complete path to the file.
|
||||
$file_path = $folder_path . DIRECTORY_SEPARATOR . $file_name;
|
||||
|
||||
// Get the URL directory of the stylesheet.
|
||||
$css_uri_folder = $upload_dir['baseurl'];
|
||||
|
||||
$css_uri = trailingslashit( $css_uri_folder ) . 'generatepress/' . $file_name;
|
||||
|
||||
// Take care of domain mapping.
|
||||
if ( defined( 'DOMAIN_MAPPING' ) && DOMAIN_MAPPING ) {
|
||||
if ( function_exists( 'domain_mapping_siteurl' ) && function_exists( 'get_original_url' ) ) {
|
||||
$mapped_domain = domain_mapping_siteurl( false );
|
||||
$original_domain = get_original_url( 'siteurl' );
|
||||
$css_uri = str_replace( $original_domain, $mapped_domain, $css_uri );
|
||||
}
|
||||
}
|
||||
|
||||
$css_uri = set_url_scheme( $css_uri );
|
||||
|
||||
if ( 'path' === $target ) {
|
||||
return $file_path;
|
||||
} elseif ( 'url' === $target || 'uri' === $target ) {
|
||||
$timestamp = ( file_exists( $file_path ) ) ? '?ver=' . filemtime( $file_path ) : '';
|
||||
return $css_uri . $timestamp;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the our updated file time.
|
||||
*/
|
||||
public function update_saved_time() {
|
||||
$data = get_option( 'generatepress_dynamic_css_data', array() );
|
||||
$data['updated_time'] = time();
|
||||
|
||||
update_option( 'generatepress_dynamic_css_data', $data );
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the saved time.
|
||||
*/
|
||||
public function delete_saved_time() {
|
||||
$data = get_option( 'generatepress_dynamic_css_data', array() );
|
||||
|
||||
if ( isset( $data['updated_time'] ) ) {
|
||||
unset( $data['updated_time'] );
|
||||
}
|
||||
|
||||
update_option( 'generatepress_dynamic_css_data', $data );
|
||||
}
|
||||
|
||||
/**
|
||||
* Update our plugin/theme versions.
|
||||
*/
|
||||
public function update_versions() {
|
||||
$data = get_option( 'generatepress_dynamic_css_data', array() );
|
||||
|
||||
$data['theme_version'] = GENERATE_VERSION;
|
||||
$data['plugin_version'] = GP_PREMIUM_VERSION;
|
||||
|
||||
update_option( 'generatepress_dynamic_css_data', $data );
|
||||
}
|
||||
|
||||
/**
|
||||
* Do we need to update the CSS file?
|
||||
*/
|
||||
public function needs_update() {
|
||||
$data = get_option( 'generatepress_dynamic_css_data', array() );
|
||||
$update = false;
|
||||
|
||||
// If there's no updated time, needs update.
|
||||
// The time is set in mode().
|
||||
if ( ! isset( $data['updated_time'] ) ) {
|
||||
$update = true;
|
||||
}
|
||||
|
||||
// If we haven't set our versions, do so now.
|
||||
if ( ! isset( $data['theme_version'] ) && ! isset( $data['plugin_version'] ) ) {
|
||||
$update = true;
|
||||
$this->update_versions();
|
||||
|
||||
// Bail early so we don't check undefined versions below.
|
||||
return $update;
|
||||
}
|
||||
|
||||
// Version numbers have changed, needs update.
|
||||
if ( (string) GENERATE_VERSION !== (string) $data['theme_version'] || (string) GP_PREMIUM_VERSION !== (string) $data['plugin_version'] ) {
|
||||
$update = true;
|
||||
$this->update_versions();
|
||||
}
|
||||
|
||||
return $update;
|
||||
}
|
||||
|
||||
/**
|
||||
* Regenerate the CSS file.
|
||||
*/
|
||||
public function regenerate_css_file() {
|
||||
check_ajax_referer( 'generatepress_regenerate_css_file', '_nonce' );
|
||||
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
wp_send_json_error( __( 'Security check failed.', 'gp-premium' ) );
|
||||
}
|
||||
|
||||
$this->delete_saved_time();
|
||||
|
||||
wp_send_json_success();
|
||||
}
|
||||
}
|
||||
|
||||
GeneratePress_External_CSS_File::get_instance();
|
||||
@ -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' )
|
||||
);
|
||||
}
|
||||
@ -0,0 +1,87 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles SVG icons.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'generate_enqueue_premium_icons' );
|
||||
/**
|
||||
* Register our GP Premium icons.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
function generate_enqueue_premium_icons() {
|
||||
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
||||
|
||||
wp_register_style( 'gp-premium-icons', plugin_dir_url( __FILE__ ) . "icons/icons{$suffix}.css", array(), GP_PREMIUM_VERSION );
|
||||
}
|
||||
|
||||
add_filter( 'generate_svg_icon', 'generate_premium_add_svg_icons', 10, 2 );
|
||||
/**
|
||||
* Add our premium SVG icons.
|
||||
*
|
||||
* @since 1.9
|
||||
* @param string $output The SVG HTML output.
|
||||
* @param string $icon The icon name.
|
||||
*/
|
||||
function generate_premium_add_svg_icons( $output, $icon ) {
|
||||
$svg = '';
|
||||
|
||||
if ( 'shopping-bag' === $icon ) {
|
||||
$svg = '<svg viewBox="0 0 518 512" aria-hidden="true" version="1.1" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em">
|
||||
<g id="Union" transform="matrix(1,0,0,1,2.01969,2)">
|
||||
<path d="M172,108.5C172,61.832 209.832,24 256.5,24C303.168,24 341,61.832 341,108.5L341,116C341,122.627 346.373,128 353,128C359.628,128 365,122.627 365,116L365,108.5C365,48.577 316.423,0 256.5,0C196.577,0 148,48.577 148,108.5L148,116C148,122.627 153.373,128 160,128C166.628,128 172,122.627 172,116L172,108.5Z" style="fill-rule:nonzero;"/>
|
||||
<path d="M4.162,145.236C7.195,141.901 11.493,140 16,140L496,140C500.507,140 504.806,141.901 507.838,145.236C510.87,148.571 512.355,153.03 511.928,157.517L482.687,464.551C480.34,489.186 459.65,508 434.903,508L77.097,508C52.35,508 31.66,489.186 29.314,464.551L0.072,157.517C-0.355,153.03 1.13,148.571 4.162,145.236Z" style="fill-rule:nonzero;"/>
|
||||
</g>
|
||||
</svg>';
|
||||
}
|
||||
|
||||
if ( 'shopping-cart' === $icon ) {
|
||||
$svg = '<svg viewBox="0 0 576 512" aria-hidden="true" version="1.1" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em">
|
||||
<path fill="none" d="M0 0h576v512H0z"/>
|
||||
<path d="M181.54 409.6c-29.249 0-52.914 23.04-52.914 51.2 0 28.16 23.665 51.2 52.915 51.2 29.249 0 53.18-23.04 53.18-51.2 0-28.16-23.931-51.2-53.18-51.2zM22 0v51.2h53.18l95.725 194.304-35.897 62.464C115.598 342.272 141.124 384 181.54 384h319.08v-51.2h-319.08l29.249-51.2h198.096c19.943 0 37.492-10.496 46.533-26.368L550.61 89.088c9.838-16.896-2.925-37.888-23.133-37.888H133.944L108.95 0H22zm425.442 409.6c-29.25 0-52.915 23.04-52.915 51.2 0 28.16 23.665 51.2 52.915 51.2 29.249 0 53.18-23.04 53.18-51.2 0-28.16-23.931-51.2-53.18-51.2z"/>
|
||||
</svg>';
|
||||
}
|
||||
|
||||
if ( 'shopping-basket' === $icon ) {
|
||||
$svg = '<svg viewBox="0 0 626 512" aria-hidden="true" version="1.1" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em">
|
||||
<path d="M4.83 187.075a19.505 19.505 0 0 1 14.675-6.656h585.144a19.505 19.505 0 0 1 19.334 22.083L589.486 461.22c-3.875 29.07-28.672 50.781-58 50.781H92.668c-29.328 0-54.126-21.71-58.002-50.78L.171 202.501a19.511 19.511 0 0 1 4.659-15.427zm165.748 69.748c-.892-8.03-8.125-13.815-16.155-12.924-8.03.892-13.815 8.125-12.924 16.155l19.505 175.543c.892 8.03 8.125 13.816 16.154 12.924 8.03-.892 13.816-8.125 12.925-16.154l-19.505-175.544zm312.077 3.23c.892-8.029-4.895-15.262-12.925-16.154-8.03-.891-15.262 4.894-16.154 12.924L434.07 432.367c-.893 8.03 4.894 15.262 12.924 16.154 8.03.892 15.263-4.894 16.155-12.924l19.505-175.543zm-153.512-1.614c0-8.079-6.55-14.629-14.628-14.629-8.079 0-14.629 6.55-14.629 14.629v175.543c0 8.078 6.55 14.628 14.629 14.628s14.628-6.55 14.628-14.628V258.439z"/>
|
||||
<path d="M283.41 4.285c5.715 5.712 5.715 14.975 0 20.687L146.878 161.506c-5.712 5.714-14.975 5.714-20.687 0-5.714-5.713-5.714-14.975 0-20.687L262.724 4.285c5.712-5.714 14.974-5.714 20.687 0zm57.333 0c5.712-5.714 14.975-5.714 20.687 0l136.534 136.534c5.713 5.712 5.713 14.974 0 20.687-5.713 5.714-14.975 5.714-20.688 0L340.743 24.972c-5.714-5.712-5.714-14.975 0-20.687z" />
|
||||
</svg>';
|
||||
}
|
||||
|
||||
if ( 'spinner' === $icon ) {
|
||||
$svg = '<svg viewBox="0 0 512 512" aria-hidden="true" version="1.1" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em">
|
||||
<path d="M288 32c0 17.673-14.327 32-32 32-17.673 0-32-14.327-32-32 0-17.673 14.327-32 32-32 17.673 0 32 14.327 32 32zM288 480c0 17.673-14.327 32-32 32-17.673 0-32-14.327-32-32 0-17.673 14.327-32 32-32 17.673 0 32 14.327 32 32zM448 256c0 17.673 14.327 32 32 32 17.673 0 32-14.327 32-32 0-17.673-14.327-32-32-32-17.673 0-32 14.327-32 32zM32 288c-17.673 0-32-14.327-32-32 0-17.673 14.327-32 32-32 17.673 0 32 14.327 32 32 0 17.673-14.327 32-32 32zM391.764 391.764c-12.496 12.497-12.496 32.759 0 45.255 12.497 12.497 32.758 12.497 45.255 0 12.497-12.496 12.497-32.758 0-45.255-12.497-12.496-32.758-12.496-45.255 0zM74.981 120.235c-12.497-12.496-12.497-32.758 0-45.254 12.496-12.497 32.758-12.497 45.254 0 12.497 12.496 12.497 32.758 0 45.254-12.496 12.497-32.758 12.497-45.254 0zM120.235 391.765c-12.496-12.497-32.758-12.497-45.254 0-12.497 12.496-12.497 32.758 0 45.254 12.496 12.497 32.758 12.497 45.254 0 12.497-12.496 12.497-32.758 0-45.254z"/>
|
||||
</svg>';
|
||||
}
|
||||
|
||||
if ( 'pro-menu-bars' === $icon ) {
|
||||
$svg = '<svg viewBox="0 0 512 512" aria-hidden="true" role="img" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1em" height="1em">
|
||||
<path d="M0 96c0-13.255 10.745-24 24-24h464c13.255 0 24 10.745 24 24s-10.745 24-24 24H24c-13.255 0-24-10.745-24-24zm0 160c0-13.255 10.745-24 24-24h464c13.255 0 24 10.745 24 24s-10.745 24-24 24H24c-13.255 0-24-10.745-24-24zm0 160c0-13.255 10.745-24 24-24h464c13.255 0 24 10.745 24 24s-10.745 24-24 24H24c-13.255 0-24-10.745-24-24z" />
|
||||
</svg>';
|
||||
}
|
||||
|
||||
if ( 'pro-close' === $icon ) {
|
||||
$svg = '<svg viewBox="0 0 512 512" aria-hidden="true" role="img" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1em" height="1em">
|
||||
<path d="M71.029 71.029c9.373-9.372 24.569-9.372 33.942 0L256 222.059l151.029-151.03c9.373-9.372 24.569-9.372 33.942 0 9.372 9.373 9.372 24.569 0 33.942L289.941 256l151.03 151.029c9.372 9.373 9.372 24.569 0 33.942-9.373 9.372-24.569 9.372-33.942 0L256 289.941l-151.029 151.03c-9.373 9.372-24.569 9.372-33.942 0-9.372-9.373-9.372-24.569 0-33.942L222.059 256 71.029 104.971c-9.372-9.373-9.372-24.569 0-33.942z" />
|
||||
</svg>';
|
||||
}
|
||||
|
||||
if ( $svg ) {
|
||||
$output = sprintf(
|
||||
'<span class="gp-icon %1$s">
|
||||
%2$s
|
||||
</span>',
|
||||
$icon,
|
||||
$svg
|
||||
);
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
Binary file not shown.
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<metadata>Generated by IcoMoon</metadata>
|
||||
<defs>
|
||||
<font id="icomoon" horiz-adv-x="1024">
|
||||
<font-face units-per-em="1024" ascent="960" descent="-64" />
|
||||
<missing-glyph horiz-adv-x="1024" />
|
||||
<glyph unicode=" " horiz-adv-x="512" d="" />
|
||||
<glyph unicode="" glyph-name="spinner" d="M576 896c0-35.346-28.654-64-64-64s-64 28.654-64 64c0 35.346 28.654 64 64 64s64-28.654 64-64zM576 0c0-35.346-28.654-64-64-64s-64 28.654-64 64c0 35.346 28.654 64 64 64s64-28.654 64-64zM896 448c0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64s-64-28.654-64-64zM64 384c-35.346 0-64 28.654-64 64s28.654 64 64 64c35.346 0 64-28.654 64-64s-28.654-64-64-64zM783.528 176.472c-24.992-24.994-24.992-65.518 0-90.51 24.994-24.994 65.516-24.994 90.51 0 24.994 24.992 24.994 65.516 0 90.51-24.994 24.992-65.516 24.992-90.51 0zM149.962 719.53c-24.994 24.992-24.994 65.516 0 90.508 24.992 24.994 65.516 24.994 90.508 0 24.994-24.992 24.994-65.516 0-90.508-24.992-24.994-65.516-24.994-90.508 0zM240.47 176.47c-24.992 24.994-65.516 24.994-90.508 0-24.994-24.992-24.994-65.516 0-90.508 24.992-24.994 65.516-24.994 90.508 0 24.994 24.992 24.994 65.516 0 90.508z" />
|
||||
<glyph unicode="" glyph-name="angle-right" horiz-adv-x="384" d="M333.8 431l-235.6-232c-9.4-9.4-24.6-9.4-34 0l-14.2 14.2c-9.4 9.4-9.4 24.6 0 34l204.6 200.8-204.4 200.8c-9.4 9.4-9.4 24.6 0 34l14.2 14.2c9.4 9.4 24.6 9.4 34 0l235.6-232c9.2-9.4 9.2-24.6-0.2-34z" />
|
||||
<glyph unicode="" glyph-name="circle" d="M512 865.477c-230.565 0-417.477-186.911-417.477-417.477s186.911-417.477 417.477-417.477c230.565 0 417.477 186.911 417.477 417.477s-186.911 417.477-417.477 417.477zM0 448c0 282.77 229.23 512 512 512s512-229.23 512-512c0-282.77-229.23-512-512-512s-512 229.23-512 512z" />
|
||||
<glyph unicode="" glyph-name="angle-down" horiz-adv-x="660" d="M611.825 565.831c0-4.532-2.266-9.63-5.665-13.029l-263.987-263.987c-3.399-3.399-8.497-5.665-13.029-5.665s-9.63 2.266-13.029 5.665l-263.987 263.987c-3.399 3.399-5.665 8.497-5.665 13.029s2.266 9.63 5.665 13.029l28.325 28.325c3.399 3.399 7.931 5.665 13.029 5.665 4.532 0 9.63-2.266 13.029-5.665l222.633-222.633 222.633 222.633c3.399 3.399 8.497 5.665 13.029 5.665s9.63-2.266 13.029-5.665l28.325-28.325c3.399-3.399 5.665-8.497 5.665-13.029z" />
|
||||
<glyph unicode="" glyph-name="dot-circle" d="M512 865.477c-230.565 0-417.477-186.911-417.477-417.477s186.911-417.477 417.477-417.477c230.565 0 417.477 186.911 417.477 417.477s-186.911 417.477-417.477 417.477zM0 448c0 282.77 229.23 512 512 512s512-229.23 512-512c0-282.77-229.23-512-512-512s-512 229.23-512 512zM519.877 518.892c-43.502 0-78.769-35.267-78.769-78.769s35.267-78.769 78.769-78.769c43.502 0 78.769 35.267 78.769 78.769s-35.267 78.769-78.769 78.769zM346.584 440.123c0 95.707 77.586 173.292 173.292 173.292s173.292-77.586 173.292-173.292c0-95.707-77.586-173.292-173.292-173.292s-173.292 77.586-173.292 173.292z" />
|
||||
<glyph unicode="" glyph-name="times" d="M142.058 817.942c18.746 18.744 49.138 18.744 67.884 0l302.058-302.060 302.058 302.060c18.746 18.744 49.138 18.744 67.884 0 18.744-18.746 18.744-49.138 0-67.884l-302.060-302.058 302.060-302.058c18.744-18.746 18.744-49.138 0-67.884-18.746-18.744-49.138-18.744-67.884 0l-302.058 302.060-302.058-302.060c-18.746-18.744-49.138-18.744-67.884 0-18.744 18.746-18.744 49.138 0 67.884l302.060 302.058-302.060 302.058c-18.744 18.746-18.744 49.138 0 67.884z" />
|
||||
<glyph unicode="" glyph-name="shopping-cart" horiz-adv-x="1152" d="M363.081 140.8c-58.498 0-105.829-46.080-105.829-102.4s47.33-102.4 105.829-102.4c58.498 0 106.36 46.080 106.36 102.4s-47.862 102.4-106.36 102.4zM44 960v-102.4h106.36l191.449-388.608-71.793-124.928c-38.822-68.608 12.231-152.064 93.065-152.064h638.162v102.4h-638.162l58.498 102.4h396.192c39.885 0 74.984 20.992 93.065 52.736l190.385 332.288c19.677 33.792-5.85 75.776-46.267 75.776h-787.067l-49.989 102.4h-173.899zM894.883 140.8c-58.498 0-105.829-46.080-105.829-102.4s47.33-102.4 105.829-102.4c58.498 0 106.36 46.080 106.36 102.4s-47.862 102.4-106.36 102.4z" />
|
||||
<glyph unicode="" glyph-name="bars" d="M0 768c0 26.51 21.49 48 48 48h928c26.51 0 48-21.49 48-48s-21.49-48-48-48h-928c-26.51 0-48 21.49-48 48zM0 448c0 26.51 21.49 48 48 48h928c26.51 0 48-21.49 48-48s-21.49-48-48-48h-928c-26.51 0-48 21.49-48 48zM0 128c0 26.51 21.49 48 48 48h928c26.51 0 48-21.49 48-48s-21.49-48-48-48h-928c-26.51 0-48 21.49-48 48z" />
|
||||
<glyph unicode="" glyph-name="shopping-bag" horiz-adv-x="1036" d="M348.039 739c0 93.336 75.664 169 169 169s169-75.664 169-169v-15c0-13.254 10.746-24 24-24 13.256 0 24 10.746 24 24v15c0 119.846-97.154 217-217 217s-217-97.154-217-217v-15c0-13.254 10.746-24 24-24 13.256 0 24 10.746 24 24v15zM12.363 665.528c6.066 6.67 14.662 10.472 23.676 10.472h960c9.014 0 17.612-3.802 23.676-10.472s9.034-15.588 8.18-24.562l-58.482-614.068c-4.694-49.27-46.074-86.898-95.568-86.898h-715.612c-49.494 0-90.874 37.628-95.566 86.898l-58.484 614.068c-0.854 8.974 2.116 17.892 8.18 24.562z" />
|
||||
<glyph unicode="" glyph-name="shopping-basket" horiz-adv-x="1252" d="M9.66 585.849c7.407 8.46 18.105 13.312 29.35 13.312h1170.288c11.245 0 21.943-4.852 29.35-13.312 7.407-8.463 10.803-19.707 9.318-30.854l-68.993-517.436c-7.751-58.141-57.344-101.561-116.002-101.561h-877.633c-58.656 0-108.252 43.42-116.002 101.561l-68.993 517.436c-1.485 11.147 1.911 22.392 9.318 30.854zM341.156 446.353c-1.785 16.060-16.25 27.631-32.31 25.849-16.060-1.785-27.631-16.25-25.849-32.31l39.010-351.086c1.785-16.060 16.25-27.631 32.31-25.849 16.060 1.785 27.631 16.25 25.849 32.31l-39.010 351.086zM965.31 439.892c1.785 16.060-9.789 30.525-25.849 32.31-16.060 1.782-30.525-9.789-32.31-25.849l-39.010-351.086c-1.785-16.060 9.789-30.525 25.849-32.31 16.060-1.782 30.525 9.789 32.31 25.849l39.010 351.086zM658.287 443.123c0 16.157-13.1 29.257-29.257 29.257s-29.257-13.1-29.257-29.257v-351.086c0-16.157 13.1-29.257 29.257-29.257s29.257 13.1 29.257 29.257v351.086zM566.822 951.43c11.427-11.425 11.427-29.95 0-41.375l-273.067-273.067c-11.425-11.427-29.95-11.427-41.375 0-11.427 11.425-11.427 29.95 0 41.375l273.067 273.067c11.425 11.427 29.95 11.427 41.375 0zM681.486 951.43c11.425 11.427 29.95 11.427 41.375 0l273.067-273.067c11.427-11.425 11.427-29.95 0-41.375-11.425-11.427-29.95-11.427-41.375 0l-273.067 273.067c-11.427 11.425-11.427 29.95 0 41.375z" />
|
||||
</font></defs></svg>
|
||||
|
After Width: | Height: | Size: 6.3 KiB |
Binary file not shown.
Binary file not shown.
@ -0,0 +1,10 @@
|
||||
@font-face {
|
||||
font-family: 'GP Premium';
|
||||
src: url('gp-premium.eot');
|
||||
src: url('gp-premium.eot#iefix') format('embedded-opentype'),
|
||||
url('gp-premium.woff') format('woff'),
|
||||
url('gp-premium.ttf') format('truetype'),
|
||||
url('gp-premium.svg#gp-premium') format('svg');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
1
wp-content/upgrade-temp-backup/plugins/gp-premium/general/icons/icons.min.css
vendored
Normal file
1
wp-content/upgrade-temp-backup/plugins/gp-premium/general/icons/icons.min.css
vendored
Normal file
@ -0,0 +1 @@
|
||||
@font-face{font-family:'GP Premium';src:url(gp-premium.eot);src:url(gp-premium.eot#iefix) format('embedded-opentype'),url(gp-premium.woff) format('woff'),url(gp-premium.ttf) format('truetype'),url(gp-premium.svg#gp-premium) format('svg');font-weight:400;font-style:normal}
|
||||
@ -0,0 +1,743 @@
|
||||
/*!
|
||||
* smooth-scroll v14.2.1: Animate scrolling to anchor links
|
||||
* (c) 2018 Chris Ferdinandi
|
||||
* MIT License
|
||||
* http://github.com/cferdinandi/smooth-scroll
|
||||
*/
|
||||
|
||||
/**
|
||||
* closest() polyfill
|
||||
* @link https://developer.mozilla.org/en-US/docs/Web/API/Element/closest#Polyfill
|
||||
*/
|
||||
if (window.Element && !Element.prototype.closest) {
|
||||
Element.prototype.closest = function(s) {
|
||||
var matches = (this.document || this.ownerDocument).querySelectorAll(s),
|
||||
i,
|
||||
el = this;
|
||||
do {
|
||||
i = matches.length;
|
||||
while (--i >= 0 && matches.item(i) !== el) {}
|
||||
} while ((i < 0) && (el = el.parentElement));
|
||||
return el;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* CustomEvent() polyfill
|
||||
* https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent#Polyfill
|
||||
*/
|
||||
(function () {
|
||||
|
||||
if (typeof window.CustomEvent === "function") return false;
|
||||
|
||||
function CustomEvent(event, params) {
|
||||
params = params || { bubbles: false, cancelable: false, detail: undefined };
|
||||
var evt = document.createEvent('CustomEvent');
|
||||
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
|
||||
return evt;
|
||||
}
|
||||
|
||||
CustomEvent.prototype = window.Event.prototype;
|
||||
|
||||
window.CustomEvent = CustomEvent;
|
||||
})();
|
||||
/**
|
||||
* requestAnimationFrame() polyfill
|
||||
* By Erik Möller. Fixes from Paul Irish and Tino Zijdel.
|
||||
* @link http://paulirish.com/2011/requestanimationframe-for-smart-animating/
|
||||
* @link http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
|
||||
* @license MIT
|
||||
*/
|
||||
(function() {
|
||||
var lastTime = 0;
|
||||
var vendors = ['ms', 'moz', 'webkit', 'o'];
|
||||
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
|
||||
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
|
||||
window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] ||
|
||||
window[vendors[x]+'CancelRequestAnimationFrame'];
|
||||
}
|
||||
|
||||
if (!window.requestAnimationFrame) {
|
||||
window.requestAnimationFrame = function(callback, element) {
|
||||
var currTime = new Date().getTime();
|
||||
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
|
||||
var id = window.setTimeout((function() { callback(currTime + timeToCall); }),
|
||||
timeToCall);
|
||||
lastTime = currTime + timeToCall;
|
||||
return id;
|
||||
};
|
||||
}
|
||||
|
||||
if (!window.cancelAnimationFrame) {
|
||||
window.cancelAnimationFrame = function(id) {
|
||||
clearTimeout(id);
|
||||
};
|
||||
}
|
||||
}());
|
||||
|
||||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define([], (function () {
|
||||
return factory(root);
|
||||
}));
|
||||
} else if (typeof exports === 'object') {
|
||||
module.exports = factory(root);
|
||||
} else {
|
||||
root.SmoothScroll = factory(root);
|
||||
}
|
||||
})(typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : this, (function (window) {
|
||||
|
||||
'use strict';
|
||||
|
||||
//
|
||||
// Default settings
|
||||
//
|
||||
|
||||
var defaults = {
|
||||
// Selectors
|
||||
ignore: '[data-scroll-ignore]',
|
||||
header: null,
|
||||
topOnEmptyHash: true,
|
||||
|
||||
// Speed & Easing
|
||||
speed: 500,
|
||||
clip: true,
|
||||
offset: 0,
|
||||
easing: 'easeInOutCubic',
|
||||
customEasing: null,
|
||||
|
||||
// History
|
||||
updateURL: true,
|
||||
popstate: true,
|
||||
|
||||
// Custom Events
|
||||
emitEvents: true
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Utility Methods
|
||||
//
|
||||
|
||||
/**
|
||||
* Check if browser supports required methods
|
||||
* @return {Boolean} Returns true if all required methods are supported
|
||||
*/
|
||||
var supports = function () {
|
||||
return (
|
||||
'querySelector' in document &&
|
||||
'addEventListener' in window &&
|
||||
'requestAnimationFrame' in window &&
|
||||
'closest' in window.Element.prototype
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Merge two or more objects. Returns a new object.
|
||||
* @param {Object} objects The objects to merge together
|
||||
* @returns {Object} Merged values of defaults and options
|
||||
*/
|
||||
var extend = function () {
|
||||
|
||||
// Variables
|
||||
var extended = {};
|
||||
|
||||
// Merge the object into the extended object
|
||||
var merge = function (obj) {
|
||||
for (var prop in obj) {
|
||||
if (obj.hasOwnProperty(prop)) {
|
||||
extended[prop] = obj[prop];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Loop through each object and conduct a merge
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
merge(arguments[i]);
|
||||
}
|
||||
|
||||
return extended;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Check to see if user prefers reduced motion
|
||||
* @param {Object} settings Script settings
|
||||
*/
|
||||
var reduceMotion = function (settings) {
|
||||
if ('matchMedia' in window && window.matchMedia('(prefers-reduced-motion)').matches) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the height of an element.
|
||||
* @param {Node} elem The element to get the height of
|
||||
* @return {Number} The element's height in pixels
|
||||
*/
|
||||
var getHeight = function (elem) {
|
||||
return parseInt(window.getComputedStyle(elem).height, 10);
|
||||
};
|
||||
|
||||
/**
|
||||
* Decode a URI, with error check
|
||||
* @param {String} hash The URI to decode
|
||||
* @return {String} A decoded URI (or the original string if an error is thrown)
|
||||
*/
|
||||
var decode = function (hash) {
|
||||
var decoded;
|
||||
try {
|
||||
decoded = decodeURIComponent(hash);
|
||||
} catch(e) {
|
||||
decoded = hash;
|
||||
}
|
||||
return decoded;
|
||||
};
|
||||
|
||||
/**
|
||||
* Escape special characters for use with querySelector
|
||||
* @author Mathias Bynens
|
||||
* @link https://github.com/mathiasbynens/CSS.escape
|
||||
* @param {String} id The anchor ID to escape
|
||||
*/
|
||||
var escapeCharacters = function (id) {
|
||||
|
||||
// Remove leading hash
|
||||
if (id.charAt(0) === '#') {
|
||||
id = id.substr(1);
|
||||
}
|
||||
|
||||
var string = String(id);
|
||||
var length = string.length;
|
||||
var index = -1;
|
||||
var codeUnit;
|
||||
var result = '';
|
||||
var firstCodeUnit = string.charCodeAt(0);
|
||||
while (++index < length) {
|
||||
codeUnit = string.charCodeAt(index);
|
||||
// Note: there’s no need to special-case astral symbols, surrogate
|
||||
// pairs, or lone surrogates.
|
||||
|
||||
// If the character is NULL (U+0000), then throw an
|
||||
// `InvalidCharacterError` exception and terminate these steps.
|
||||
if (codeUnit === 0x0000) {
|
||||
throw new InvalidCharacterError(
|
||||
'Invalid character: the input contains U+0000.'
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
// If the character is in the range [\1-\1F] (U+0001 to U+001F) or is
|
||||
// U+007F, […]
|
||||
(codeUnit >= 0x0001 && codeUnit <= 0x001F) || codeUnit == 0x007F ||
|
||||
// If the character is the first character and is in the range [0-9]
|
||||
// (U+0030 to U+0039), […]
|
||||
(index === 0 && codeUnit >= 0x0030 && codeUnit <= 0x0039) ||
|
||||
// If the character is the second character and is in the range [0-9]
|
||||
// (U+0030 to U+0039) and the first character is a `-` (U+002D), […]
|
||||
(
|
||||
index === 1 &&
|
||||
codeUnit >= 0x0030 && codeUnit <= 0x0039 &&
|
||||
firstCodeUnit === 0x002D
|
||||
)
|
||||
) {
|
||||
// http://dev.w3.org/csswg/cssom/#escape-a-character-as-code-point
|
||||
result += '\\' + codeUnit.toString(16) + ' ';
|
||||
continue;
|
||||
}
|
||||
|
||||
// If the character is not handled by one of the above rules and is
|
||||
// greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or
|
||||
// is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to
|
||||
// U+005A), or [a-z] (U+0061 to U+007A), […]
|
||||
if (
|
||||
codeUnit >= 0x0080 ||
|
||||
codeUnit === 0x002D ||
|
||||
codeUnit === 0x005F ||
|
||||
codeUnit >= 0x0030 && codeUnit <= 0x0039 ||
|
||||
codeUnit >= 0x0041 && codeUnit <= 0x005A ||
|
||||
codeUnit >= 0x0061 && codeUnit <= 0x007A
|
||||
) {
|
||||
// the character itself
|
||||
result += string.charAt(index);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Otherwise, the escaped character.
|
||||
// http://dev.w3.org/csswg/cssom/#escape-a-character
|
||||
result += '\\' + string.charAt(index);
|
||||
|
||||
}
|
||||
|
||||
// Return sanitized hash
|
||||
var hash;
|
||||
try {
|
||||
hash = decodeURIComponent('#' + result);
|
||||
} catch(e) {
|
||||
hash = '#' + result;
|
||||
}
|
||||
return hash;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Calculate the easing pattern
|
||||
* @link https://gist.github.com/gre/1650294
|
||||
* @param {String} type Easing pattern
|
||||
* @param {Number} time Time animation should take to complete
|
||||
* @returns {Number}
|
||||
*/
|
||||
var easingPattern = function (settings, time) {
|
||||
var pattern;
|
||||
|
||||
// Default Easing Patterns
|
||||
if (settings.easing === 'easeInQuad') pattern = time * time; // accelerating from zero velocity
|
||||
if (settings.easing === 'easeOutQuad') pattern = time * (2 - time); // decelerating to zero velocity
|
||||
if (settings.easing === 'easeInOutQuad') pattern = time < 0.5 ? 2 * time * time : -1 + (4 - 2 * time) * time; // acceleration until halfway, then deceleration
|
||||
if (settings.easing === 'easeInCubic') pattern = time * time * time; // accelerating from zero velocity
|
||||
if (settings.easing === 'easeOutCubic') pattern = (--time) * time * time + 1; // decelerating to zero velocity
|
||||
if (settings.easing === 'easeInOutCubic') pattern = time < 0.5 ? 4 * time * time * time : (time - 1) * (2 * time - 2) * (2 * time - 2) + 1; // acceleration until halfway, then deceleration
|
||||
if (settings.easing === 'easeInQuart') pattern = time * time * time * time; // accelerating from zero velocity
|
||||
if (settings.easing === 'easeOutQuart') pattern = 1 - (--time) * time * time * time; // decelerating to zero velocity
|
||||
if (settings.easing === 'easeInOutQuart') pattern = time < 0.5 ? 8 * time * time * time * time : 1 - 8 * (--time) * time * time * time; // acceleration until halfway, then deceleration
|
||||
if (settings.easing === 'easeInQuint') pattern = time * time * time * time * time; // accelerating from zero velocity
|
||||
if (settings.easing === 'easeOutQuint') pattern = 1 + (--time) * time * time * time * time; // decelerating to zero velocity
|
||||
if (settings.easing === 'easeInOutQuint') pattern = time < 0.5 ? 16 * time * time * time * time * time : 1 + 16 * (--time) * time * time * time * time; // acceleration until halfway, then deceleration
|
||||
|
||||
// Custom Easing Patterns
|
||||
if (!!settings.customEasing) pattern = settings.customEasing(time);
|
||||
|
||||
return pattern || time; // no easing, no acceleration
|
||||
};
|
||||
|
||||
/**
|
||||
* Determine the document's height
|
||||
* @returns {Number}
|
||||
*/
|
||||
var getDocumentHeight = function () {
|
||||
return Math.max(
|
||||
document.body.scrollHeight, document.documentElement.scrollHeight,
|
||||
document.body.offsetHeight, document.documentElement.offsetHeight,
|
||||
document.body.clientHeight, document.documentElement.clientHeight
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Calculate how far to scroll
|
||||
* Clip support added by robjtede - https://github.com/cferdinandi/smooth-scroll/issues/405
|
||||
* @param {Element} anchor The anchor element to scroll to
|
||||
* @param {Number} headerHeight Height of a fixed header, if any
|
||||
* @param {Number} offset Number of pixels by which to offset scroll
|
||||
* @param {Boolean} clip If true, adjust scroll distance to prevent abrupt stops near the bottom of the page
|
||||
* @returns {Number}
|
||||
*/
|
||||
var getEndLocation = function (anchor, headerHeight, offset, clip) {
|
||||
var location = 0;
|
||||
if (anchor.offsetParent) {
|
||||
do {
|
||||
location += anchor.offsetTop;
|
||||
anchor = anchor.offsetParent;
|
||||
} while (anchor);
|
||||
}
|
||||
location = Math.max(location - headerHeight - offset, 0);
|
||||
if (clip) {
|
||||
location = Math.min(location, getDocumentHeight() - window.innerHeight);
|
||||
}
|
||||
return location;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the height of the fixed header
|
||||
* @param {Node} header The header
|
||||
* @return {Number} The height of the header
|
||||
*/
|
||||
var getHeaderHeight = function (header) {
|
||||
return !header ? 0 : (getHeight(header) + header.offsetTop);
|
||||
};
|
||||
|
||||
/**
|
||||
* Update the URL
|
||||
* @param {Node} anchor The anchor that was scrolled to
|
||||
* @param {Boolean} isNum If true, anchor is a number
|
||||
* @param {Object} options Settings for Smooth Scroll
|
||||
*/
|
||||
var updateURL = function (anchor, isNum, options) {
|
||||
|
||||
// Bail if the anchor is a number
|
||||
if (isNum) return;
|
||||
|
||||
// Verify that pushState is supported and the updateURL option is enabled
|
||||
if (!history.pushState || !options.updateURL) return;
|
||||
|
||||
// Update URL
|
||||
history.pushState(
|
||||
{
|
||||
smoothScroll: JSON.stringify(options),
|
||||
anchor: anchor.id
|
||||
},
|
||||
document.title,
|
||||
anchor === document.documentElement ? '#top' : '#' + anchor.id
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Bring the anchored element into focus
|
||||
* @param {Node} anchor The anchor element
|
||||
* @param {Number} endLocation The end location to scroll to
|
||||
* @param {Boolean} isNum If true, scroll is to a position rather than an element
|
||||
*/
|
||||
var adjustFocus = function (anchor, endLocation, isNum) {
|
||||
|
||||
// Is scrolling to top of page, blur
|
||||
if (anchor === 0) {
|
||||
document.body.focus();
|
||||
}
|
||||
|
||||
// Don't run if scrolling to a number on the page
|
||||
if (isNum) return;
|
||||
|
||||
// Otherwise, bring anchor element into focus
|
||||
anchor.focus();
|
||||
if (document.activeElement !== anchor) {
|
||||
anchor.setAttribute('tabindex', '-1');
|
||||
anchor.focus();
|
||||
anchor.style.outline = 'none';
|
||||
}
|
||||
window.scrollTo(0 , endLocation);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Emit a custom event
|
||||
* @param {String} type The event type
|
||||
* @param {Object} options The settings object
|
||||
* @param {Node} anchor The anchor element
|
||||
* @param {Node} toggle The toggle element
|
||||
*/
|
||||
var emitEvent = function (type, options, anchor, toggle) {
|
||||
if (!options.emitEvents || typeof window.CustomEvent !== 'function') return;
|
||||
var event = new CustomEvent(type, {
|
||||
bubbles: true,
|
||||
detail: {
|
||||
anchor: anchor,
|
||||
toggle: toggle
|
||||
}
|
||||
});
|
||||
document.dispatchEvent(event);
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// SmoothScroll Constructor
|
||||
//
|
||||
|
||||
var SmoothScroll = function (selector, options) {
|
||||
|
||||
//
|
||||
// Variables
|
||||
//
|
||||
|
||||
var smoothScroll = {}; // Object for public APIs
|
||||
var settings, anchor, toggle, fixedHeader, headerHeight, eventTimeout, animationInterval;
|
||||
|
||||
|
||||
//
|
||||
// Methods
|
||||
//
|
||||
|
||||
/**
|
||||
* Cancel a scroll-in-progress
|
||||
*/
|
||||
smoothScroll.cancelScroll = function (noEvent) {
|
||||
cancelAnimationFrame(animationInterval);
|
||||
animationInterval = null;
|
||||
if (noEvent) return;
|
||||
emitEvent('scrollCancel', settings);
|
||||
};
|
||||
|
||||
/**
|
||||
* Start/stop the scrolling animation
|
||||
* @param {Node|Number} anchor The element or position to scroll to
|
||||
* @param {Element} toggle The element that toggled the scroll event
|
||||
* @param {Object} options
|
||||
*/
|
||||
smoothScroll.animateScroll = function (anchor, toggle, options) {
|
||||
|
||||
// Local settings
|
||||
var animateSettings = extend(settings || defaults, options || {}); // Merge user options with defaults
|
||||
|
||||
// Selectors and variables
|
||||
var isNum = Object.prototype.toString.call(anchor) === '[object Number]' ? true : false;
|
||||
var anchorElem = isNum || !anchor.tagName ? null : anchor;
|
||||
if (!isNum && !anchorElem) return;
|
||||
var startLocation = window.pageYOffset; // Current location on the page
|
||||
if (animateSettings.header && !fixedHeader) {
|
||||
// Get the fixed header if not already set
|
||||
fixedHeader = document.querySelector(animateSettings.header);
|
||||
}
|
||||
if (!headerHeight) {
|
||||
// Get the height of a fixed header if one exists and not already set
|
||||
headerHeight = getHeaderHeight(fixedHeader);
|
||||
}
|
||||
var endLocation = isNum ? anchor : getEndLocation(anchorElem, headerHeight, parseInt((typeof animateSettings.offset === 'function' ? animateSettings.offset(anchor, toggle) : animateSettings.offset), 10), animateSettings.clip); // Location to scroll to
|
||||
var distance = endLocation - startLocation; // distance to travel
|
||||
var documentHeight = getDocumentHeight();
|
||||
var timeLapsed = 0;
|
||||
var start, percentage, position;
|
||||
|
||||
/**
|
||||
* Stop the scroll animation when it reaches its target (or the bottom/top of page)
|
||||
* @param {Number} position Current position on the page
|
||||
* @param {Number} endLocation Scroll to location
|
||||
* @param {Number} animationInterval How much to scroll on this loop
|
||||
*/
|
||||
var stopAnimateScroll = function (position, endLocation) {
|
||||
|
||||
// Get the current location
|
||||
var currentLocation = window.pageYOffset;
|
||||
|
||||
// Check if the end location has been reached yet (or we've hit the end of the document)
|
||||
if (position == endLocation || currentLocation == endLocation || ((startLocation < endLocation && window.innerHeight + currentLocation) >= documentHeight)) {
|
||||
|
||||
// Clear the animation timer
|
||||
smoothScroll.cancelScroll(true);
|
||||
|
||||
// Bring the anchored element into focus
|
||||
adjustFocus(anchor, endLocation, isNum);
|
||||
|
||||
// Emit a custom event
|
||||
emitEvent('scrollStop', animateSettings, anchor, toggle);
|
||||
|
||||
// Reset start
|
||||
start = null;
|
||||
animationInterval = null;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Loop scrolling animation
|
||||
*/
|
||||
var loopAnimateScroll = function (timestamp) {
|
||||
if (!start) { start = timestamp; }
|
||||
timeLapsed += timestamp - start;
|
||||
percentage = (timeLapsed / parseInt(animateSettings.speed, 10));
|
||||
percentage = (percentage > 1) ? 1 : percentage;
|
||||
position = startLocation + (distance * easingPattern(animateSettings, percentage));
|
||||
window.scrollTo(0, Math.floor(position));
|
||||
if (!stopAnimateScroll(position, endLocation)) {
|
||||
animationInterval = window.requestAnimationFrame(loopAnimateScroll);
|
||||
start = timestamp;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Reset position to fix weird iOS bug
|
||||
* @link https://github.com/cferdinandi/smooth-scroll/issues/45
|
||||
*/
|
||||
if (window.pageYOffset === 0) {
|
||||
window.scrollTo(0, 0);
|
||||
}
|
||||
|
||||
// Update the URL
|
||||
updateURL(anchor, isNum, animateSettings);
|
||||
|
||||
// Emit a custom event
|
||||
emitEvent('scrollStart', animateSettings, anchor, toggle);
|
||||
|
||||
// Start scrolling animation
|
||||
smoothScroll.cancelScroll(true);
|
||||
window.requestAnimationFrame(loopAnimateScroll);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* If smooth scroll element clicked, animate scroll
|
||||
*/
|
||||
var clickHandler = function (event) {
|
||||
|
||||
// Don't run if the user prefers reduced motion
|
||||
if (reduceMotion(settings)) return;
|
||||
|
||||
// Don't run if right-click or command/control + click
|
||||
if (event.button !== 0 || event.metaKey || event.ctrlKey) return;
|
||||
|
||||
// Check if event.target has closest() method
|
||||
// By @totegi - https://github.com/cferdinandi/smooth-scroll/pull/401/
|
||||
if(!('closest' in event.target))return;
|
||||
|
||||
// Check if a smooth scroll link was clicked
|
||||
toggle = event.target.closest(selector);
|
||||
if (!toggle || toggle.tagName.toLowerCase() !== 'a' || event.target.closest(settings.ignore)) return;
|
||||
|
||||
// Only run if link is an anchor and points to the current page
|
||||
if (toggle.hostname !== window.location.hostname || toggle.pathname !== window.location.pathname || !/#/.test(toggle.href)) return;
|
||||
|
||||
// Get an escaped version of the hash
|
||||
var hash = escapeCharacters(decode(toggle.hash));
|
||||
|
||||
// Get the anchored element
|
||||
var anchor = settings.topOnEmptyHash && hash === '#' ? document.documentElement : document.querySelector(hash);
|
||||
anchor = !anchor && hash === '#top' ? document.documentElement : anchor;
|
||||
|
||||
// If anchored element exists, scroll to it
|
||||
if (!anchor) return;
|
||||
event.preventDefault();
|
||||
smoothScroll.animateScroll(anchor, toggle);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Animate scroll on popstate events
|
||||
*/
|
||||
var popstateHandler = function (event) {
|
||||
// Stop if history.state doesn't exist (ex. if clicking on a broken anchor link).
|
||||
// fixes `Cannot read property 'smoothScroll' of null` error getting thrown.
|
||||
if (history.state === null) return;
|
||||
|
||||
// Only run if state is a popstate record for this instantiation
|
||||
if (!history.state.smoothScroll || history.state.smoothScroll !== JSON.stringify(settings)) return;
|
||||
|
||||
// Only run if state includes an anchor
|
||||
if (!history.state.anchor) return;
|
||||
|
||||
// Get the anchor
|
||||
var anchor = document.querySelector(escapeCharacters(decode(history.state.anchor)));
|
||||
if (!anchor) return;
|
||||
|
||||
// Animate scroll to anchor link
|
||||
smoothScroll.animateScroll(anchor, null, {updateURL: false});
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* On window scroll and resize, only run events at a rate of 15fps for better performance
|
||||
*/
|
||||
var resizeThrottler = function (event) {
|
||||
if (!eventTimeout) {
|
||||
eventTimeout = setTimeout((function() {
|
||||
eventTimeout = null; // Reset timeout
|
||||
headerHeight = getHeaderHeight(fixedHeader); // Get the height of a fixed header if one exists
|
||||
}), 66);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Destroy the current initialization.
|
||||
*/
|
||||
smoothScroll.destroy = function () {
|
||||
|
||||
// If plugin isn't already initialized, stop
|
||||
if (!settings) return;
|
||||
|
||||
// Remove event listeners
|
||||
document.removeEventListener('click', clickHandler, false);
|
||||
window.removeEventListener('resize', resizeThrottler, false);
|
||||
window.removeEventListener('popstate', popstateHandler, false);
|
||||
|
||||
// Cancel any scrolls-in-progress
|
||||
smoothScroll.cancelScroll();
|
||||
|
||||
// Reset variables
|
||||
settings = null;
|
||||
anchor = null;
|
||||
toggle = null;
|
||||
fixedHeader = null;
|
||||
headerHeight = null;
|
||||
eventTimeout = null;
|
||||
animationInterval = null;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize Smooth Scroll
|
||||
* @param {Object} options User settings
|
||||
*/
|
||||
smoothScroll.init = function (options) {
|
||||
|
||||
// feature test
|
||||
if (!supports()) throw 'Smooth Scroll: This browser does not support the required JavaScript methods and browser APIs.';
|
||||
|
||||
// Destroy any existing initializations
|
||||
smoothScroll.destroy();
|
||||
|
||||
// Selectors and variables
|
||||
settings = extend(defaults, options || {}); // Merge user options with defaults
|
||||
fixedHeader = settings.header ? document.querySelector(settings.header) : null; // Get the fixed header
|
||||
headerHeight = getHeaderHeight(fixedHeader);
|
||||
|
||||
// When a toggle is clicked, run the click handler
|
||||
document.addEventListener('click', clickHandler, false);
|
||||
|
||||
// If window is resized and there's a fixed header, recalculate its size
|
||||
if (fixedHeader) {
|
||||
window.addEventListener('resize', resizeThrottler, false);
|
||||
}
|
||||
|
||||
// If updateURL and popState are enabled, listen for pop events
|
||||
if (settings.updateURL && settings.popstate) {
|
||||
window.addEventListener('popstate', popstateHandler, false);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Initialize plugin
|
||||
//
|
||||
|
||||
smoothScroll.init(options);
|
||||
|
||||
|
||||
//
|
||||
// Public APIs
|
||||
//
|
||||
|
||||
return smoothScroll;
|
||||
|
||||
};
|
||||
|
||||
return SmoothScroll;
|
||||
|
||||
}));
|
||||
|
||||
/* GP */
|
||||
var gpscroll = new SmoothScroll( gpSmoothScroll.elements.join(), {
|
||||
speed: gpSmoothScroll.duration,
|
||||
offset: function( anchor, toggle ) {
|
||||
var body = document.body,
|
||||
nav = document.querySelector( '#site-navigation' ),
|
||||
stickyNav = document.querySelector( '#sticky-navigation' ),
|
||||
mobileHeader = document.querySelector( '#mobile-header' ),
|
||||
menuToggle = document.querySelector( '.menu-toggle' ),
|
||||
offset = 0;
|
||||
|
||||
if ( mobileHeader && ( mobileHeader.offsetWidth || mobileHeader.offsetHeight || mobileHeader.getClientRects().length ) ) {
|
||||
if ( body.classList.contains( 'mobile-header-sticky' ) ) {
|
||||
offset = offset + mobileHeader.clientHeight;
|
||||
}
|
||||
} else if ( menuToggle && ( menuToggle.offsetWidth || menuToggle.offsetHeight || menuToggle.getClientRects().length ) ) {
|
||||
if ( body.classList.contains( 'both-sticky-menu' ) || body.classList.contains( 'mobile-sticky-menu' ) ) {
|
||||
if ( stickyNav ) {
|
||||
offset = offset + stickyNav.clientHeight;
|
||||
} else if ( nav ) {
|
||||
offset = offset + nav.clientHeight;
|
||||
}
|
||||
}
|
||||
} else if ( body.classList.contains( 'both-sticky-menu' ) || body.classList.contains( 'desktop-sticky-menu' ) ) {
|
||||
if ( stickyNav ) {
|
||||
offset = offset + stickyNav.clientHeight;
|
||||
} else if ( nav ) {
|
||||
offset = offset + nav.clientHeight;
|
||||
}
|
||||
}
|
||||
|
||||
return gpSmoothScroll.offset
|
||||
? gpSmoothScroll.offset
|
||||
: offset;
|
||||
}
|
||||
} );
|
||||
1
wp-content/upgrade-temp-backup/plugins/gp-premium/general/js/smooth-scroll.min.js
vendored
Normal file
1
wp-content/upgrade-temp-backup/plugins/gp-premium/general/js/smooth-scroll.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -0,0 +1,103 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the smooth scroll functionality.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'generate_smooth_scroll_scripts' );
|
||||
/**
|
||||
* Add the smooth scroll script if enabled.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
function generate_smooth_scroll_scripts() {
|
||||
if ( ! function_exists( 'generate_get_defaults' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$settings = wp_parse_args(
|
||||
get_option( 'generate_settings', array() ),
|
||||
generate_get_defaults()
|
||||
);
|
||||
|
||||
if ( ! $settings['smooth_scroll'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
||||
|
||||
wp_enqueue_script( 'generate-smooth-scroll', plugin_dir_url( __FILE__ ) . "js/smooth-scroll{$suffix}.js", array(), GP_PREMIUM_VERSION, true );
|
||||
|
||||
wp_localize_script(
|
||||
'generate-smooth-scroll',
|
||||
'gpSmoothScroll',
|
||||
array(
|
||||
'elements' => apply_filters(
|
||||
'generate_smooth_scroll_elements',
|
||||
array(
|
||||
'.smooth-scroll',
|
||||
'li.smooth-scroll a',
|
||||
)
|
||||
),
|
||||
'duration' => apply_filters( 'generate_smooth_scroll_duration', 800 ),
|
||||
'offset' => apply_filters( 'generate_smooth_scroll_offset', '' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
add_filter( 'generate_option_defaults', 'generate_smooth_scroll_default' );
|
||||
/**
|
||||
* Add the smooth scroll option to our defaults.
|
||||
*
|
||||
* @since 1.6
|
||||
*
|
||||
* @param array $defaults Existing defaults.
|
||||
* @return array New defaults.
|
||||
*/
|
||||
function generate_smooth_scroll_default( $defaults ) {
|
||||
$defaults['smooth_scroll'] = false;
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
add_action( 'customize_register', 'generate_smooth_scroll_customizer', 99 );
|
||||
/**
|
||||
* Add our smooth scroll option to the Customizer.
|
||||
*
|
||||
* @since 1.6
|
||||
*
|
||||
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
|
||||
*/
|
||||
function generate_smooth_scroll_customizer( $wp_customize ) {
|
||||
if ( ! function_exists( 'generate_get_defaults' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$defaults = generate_get_defaults();
|
||||
|
||||
require_once GP_LIBRARY_DIRECTORY . 'customizer-helpers.php';
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[smooth_scroll]',
|
||||
array(
|
||||
'default' => $defaults['smooth_scroll'],
|
||||
'type' => 'option',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_checkbox',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
'generate_settings[smooth_scroll]',
|
||||
array(
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Smooth scroll', 'gp-premium' ),
|
||||
'description' => __( 'Initiate smooth scroll on anchor links using the <code>smooth-scroll</code> class.', 'gp-premium' ),
|
||||
'section' => 'generate_general_section',
|
||||
)
|
||||
);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user