updated plugin `GP Premium` version 1.11.2

This commit is contained in:
KawaiiPunk 2020-08-13 14:53:39 +00:00 committed by Gitium
parent 3f0f8d3ac9
commit 885bbdd113
151 changed files with 11329 additions and 6954 deletions

View File

@ -1,18 +1,64 @@
<?php
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) exit;
/**
* 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 {
protected $_selector = '';
protected $_selector_output = '';
protected $_css = '';
protected $_output = '';
/**
* 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 !== '' ) {
// Render the css in the output string everytime the selector changes.
if ( '' !== $this->_selector ) {
$this->add_selector_rules_to_output();
}
@ -21,20 +67,39 @@ if ( ! class_exists( 'GeneratePress_Backgrounds_CSS' ) ) {
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 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('" : "";
$url_end = ( '' !== $url ) ? "')" : "";
// 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;
@ -42,18 +107,26 @@ if ( ! class_exists( 'GeneratePress_Backgrounds_CSS' ) ) {
$this->_output .= $selector_output;
// Reset the css
// 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
// Add current selector's rules to output.
$this->add_selector_rules_to_output();
// Output minified css
// Output minified css.
return $this->_output;
}

View File

@ -1,8 +1,14 @@
<?php
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) exit;
/**
* The functions for our Backgrounds module.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
// Add necessary files
require_once plugin_dir_path( __FILE__ ) . 'secondary-nav-backgrounds.php';
require_once plugin_dir_path( __FILE__ ) . 'css.php';
@ -77,29 +83,30 @@ if ( ! function_exists( 'generate_backgrounds_customize' ) ) {
* Build our Customizer options
*
* @since 0.1
*
* @param object $wp_customize The Customizer object.
*/
function generate_backgrounds_customize( $wp_customize ) {
// Get our defaults
$defaults = generate_get_background_defaults();
// Get our controls
require_once GP_LIBRARY_DIRECTORY . 'customizer-helpers.php';
// Register our custom control
if ( method_exists( $wp_customize,'register_control_type' ) ) {
if ( method_exists( $wp_customize, 'register_control_type' ) ) {
$wp_customize->register_control_type( 'GeneratePress_Background_Images_Customize_Control' );
$wp_customize->register_control_type( 'GeneratePress_Section_Shortcut_Control' );
}
// Add our panel
if ( class_exists( 'WP_Customize_Panel' ) ) {
if ( ! $wp_customize->get_panel( 'generate_backgrounds_panel' ) ) {
$wp_customize->add_panel( 'generate_backgrounds_panel', array(
'capability' => 'edit_theme_options',
'theme_supports' => '',
'title' => __( 'Background Images', 'gp-premium' ),
'priority' => 55
) );
$wp_customize->add_panel(
'generate_backgrounds_panel',
array(
'capability' => 'edit_theme_options',
'theme_supports' => '',
'title' => __( 'Background Images', 'gp-premium' ),
'priority' => 55,
)
);
}
}
@ -143,7 +150,8 @@ if ( ! function_exists( 'generate_backgrounds_customize' ) ) {
* Body background
*/
$wp_customize->add_setting(
'generate_background_settings[body_image]', array(
'generate_background_settings[body_image]',
array(
'default' => $defaults['body_image'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -191,7 +199,8 @@ if ( ! function_exists( 'generate_backgrounds_customize' ) ) {
);
$wp_customize->add_setting(
'generate_background_settings[body_position]', array(
'generate_background_settings[body_position]',
array(
'default' => $defaults['body_position'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -230,7 +239,8 @@ if ( ! function_exists( 'generate_backgrounds_customize' ) ) {
);
$wp_customize->add_setting(
'generate_background_settings[top_bar_image]', array(
'generate_background_settings[top_bar_image]',
array(
'default' => $defaults['top_bar_image'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -278,7 +288,8 @@ if ( ! function_exists( 'generate_backgrounds_customize' ) ) {
);
$wp_customize->add_setting(
'generate_background_settings[top_bar_position]', array(
'generate_background_settings[top_bar_position]',
array(
'default' => $defaults['top_bar_position'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -334,7 +345,8 @@ if ( ! function_exists( 'generate_backgrounds_customize' ) ) {
);
$wp_customize->add_setting(
'generate_background_settings[header_image]', array(
'generate_background_settings[header_image]',
array(
'default' => $defaults['header_image'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -382,7 +394,8 @@ if ( ! function_exists( 'generate_backgrounds_customize' ) ) {
);
$wp_customize->add_setting(
'generate_background_settings[header_position]', array(
'generate_background_settings[header_position]',
array(
'default' => $defaults['header_position'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -438,7 +451,8 @@ if ( ! function_exists( 'generate_backgrounds_customize' ) ) {
* Navigation background
*/
$wp_customize->add_setting(
'generate_background_settings[nav_image]', array(
'generate_background_settings[nav_image]',
array(
'default' => $defaults['nav_image'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -488,7 +502,8 @@ if ( ! function_exists( 'generate_backgrounds_customize' ) ) {
* Navigation item background
*/
$wp_customize->add_setting(
'generate_background_settings[nav_item_image]', array(
'generate_background_settings[nav_item_image]',
array(
'default' => $defaults['nav_item_image'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -538,7 +553,8 @@ if ( ! function_exists( 'generate_backgrounds_customize' ) ) {
* Navigation item hover background
*/
$wp_customize->add_setting(
'generate_background_settings[nav_item_hover_image]', array(
'generate_background_settings[nav_item_hover_image]',
array(
'default' => $defaults['nav_item_hover_image'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -588,7 +604,8 @@ if ( ! function_exists( 'generate_backgrounds_customize' ) ) {
* Navigation item current background
*/
$wp_customize->add_setting(
'generate_background_settings[nav_item_current_image]', array(
'generate_background_settings[nav_item_current_image]',
array(
'default' => $defaults['nav_item_current_image'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -648,7 +665,8 @@ if ( ! function_exists( 'generate_backgrounds_customize' ) ) {
* Sub-Navigation item background
*/
$wp_customize->add_setting(
'generate_background_settings[sub_nav_item_image]', array(
'generate_background_settings[sub_nav_item_image]',
array(
'default' => $defaults['sub_nav_item_image'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -698,7 +716,8 @@ if ( ! function_exists( 'generate_backgrounds_customize' ) ) {
* Sub-Navigation item hover background
*/
$wp_customize->add_setting(
'generate_background_settings[sub_nav_item_hover_image]', array(
'generate_background_settings[sub_nav_item_hover_image]',
array(
'default' => $defaults['sub_nav_item_hover_image'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -748,7 +767,8 @@ if ( ! function_exists( 'generate_backgrounds_customize' ) ) {
* Sub-Navigation item current background
*/
$wp_customize->add_setting(
'generate_background_settings[sub_nav_item_current_image]', array(
'generate_background_settings[sub_nav_item_current_image]',
array(
'default' => $defaults['sub_nav_item_current_image'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -790,7 +810,7 @@ if ( ! function_exists( 'generate_backgrounds_customize' ) ) {
'no-repeat' => __( 'No Repeat', 'gp-premium' ),
),
'settings' => 'generate_background_settings[sub_nav_item_current_repeat]',
'priority' => 2400
'priority' => 2400,
)
);
@ -825,7 +845,8 @@ if ( ! function_exists( 'generate_backgrounds_customize' ) ) {
* Content background
*/
$wp_customize->add_setting(
'generate_background_settings[content_image]', array(
'generate_background_settings[content_image]',
array(
'default' => $defaults['content_image'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -873,7 +894,8 @@ if ( ! function_exists( 'generate_backgrounds_customize' ) ) {
);
$wp_customize->add_setting(
'generate_background_settings[content_position]', array(
'generate_background_settings[content_position]',
array(
'default' => $defaults['content_position'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -897,7 +919,6 @@ if ( ! function_exists( 'generate_backgrounds_customize' ) ) {
)
);
// Sidebars
$wp_customize->add_section(
'generate_backgrounds_sidebars',
array(
@ -927,7 +948,8 @@ if ( ! function_exists( 'generate_backgrounds_customize' ) ) {
);
$wp_customize->add_setting(
'generate_background_settings[sidebar_widget_image]', array(
'generate_background_settings[sidebar_widget_image]',
array(
'default' => $defaults['sidebar_widget_image'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -975,7 +997,8 @@ if ( ! function_exists( 'generate_backgrounds_customize' ) ) {
);
$wp_customize->add_setting(
'generate_background_settings[sidebar_widget_position]', array(
'generate_background_settings[sidebar_widget_position]',
array(
'default' => $defaults['sidebar_widget_position'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -999,7 +1022,6 @@ if ( ! function_exists( 'generate_backgrounds_customize' ) ) {
)
);
// Footer widgets
$wp_customize->add_section(
'generate_backgrounds_footer',
array(
@ -1078,7 +1100,8 @@ if ( ! function_exists( 'generate_backgrounds_customize' ) ) {
);
$wp_customize->add_setting(
'generate_background_settings[footer_widget_position]', array(
'generate_background_settings[footer_widget_position]',
array(
'default' => $defaults['footer_widget_position'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -1102,7 +1125,6 @@ if ( ! function_exists( 'generate_backgrounds_customize' ) ) {
)
);
// Footer
$wp_customize->add_setting(
'generate_background_settings[footer_image]',
array(
@ -1153,7 +1175,8 @@ if ( ! function_exists( 'generate_backgrounds_customize' ) ) {
);
$wp_customize->add_setting(
'generate_background_settings[footer_position]', array(
'generate_background_settings[footer_position]',
array(
'default' => $defaults['footer_position'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -1191,113 +1214,97 @@ if ( ! function_exists( 'generate_backgrounds_css' ) ) {
generate_get_background_defaults()
);
// Fix size values
// Spaces and % are stripped by sanitize_key
$generate_settings[ 'body_size' ] = ( '100' == $generate_settings[ 'body_size' ] ) ? '100% auto' : esc_attr( $generate_settings[ 'body_size' ] );
$generate_settings[ 'top_bar_size' ] = ( '100' == $generate_settings[ 'top_bar_size' ] ) ? '100% auto' : esc_attr( $generate_settings[ 'top_bar_size' ] );
$generate_settings[ 'header_size' ] = ( '100' == $generate_settings[ 'header_size' ] ) ? '100% auto' : esc_attr( $generate_settings[ 'header_size' ] );
$generate_settings[ 'content_size' ] = ( '100' == $generate_settings[ 'content_size' ] ) ? '100% auto' : esc_attr( $generate_settings[ 'content_size' ] );
$generate_settings[ 'sidebar_widget_size' ] = ( '100' == $generate_settings[ 'sidebar_widget_size' ] ) ? '100% auto' : esc_attr( $generate_settings[ 'sidebar_widget_size' ] );
$generate_settings[ 'footer_widget_size' ] = ( '100' == $generate_settings[ 'footer_widget_size' ] ) ? '100% auto' : esc_attr( $generate_settings[ 'footer_widget_size' ] );
$generate_settings[ 'footer_size' ] = ( '100' == $generate_settings[ 'footer_size' ] ) ? '100% auto' : esc_attr( $generate_settings[ 'footer_size' ] );
// Fix size values.
// Spaces and % are stripped by sanitize_key.
$generate_settings['body_size'] = ( '100' == $generate_settings['body_size'] ) ? '100% auto' : esc_attr( $generate_settings['body_size'] ); // phpcs:ignore -- Non-strict comparison ok.
$generate_settings['top_bar_size'] = ( '100' == $generate_settings['top_bar_size'] ) ? '100% auto' : esc_attr( $generate_settings['top_bar_size'] ); // phpcs:ignore -- Non-strict comparison ok.
$generate_settings['header_size'] = ( '100' == $generate_settings['header_size'] ) ? '100% auto' : esc_attr( $generate_settings['header_size'] ); // phpcs:ignore -- Non-strict comparison ok.
$generate_settings['content_size'] = ( '100' == $generate_settings['content_size'] ) ? '100% auto' : esc_attr( $generate_settings['content_size'] ); // phpcs:ignore -- Non-strict comparison ok.
$generate_settings['sidebar_widget_size'] = ( '100' == $generate_settings['sidebar_widget_size'] ) ? '100% auto' : esc_attr( $generate_settings['sidebar_widget_size'] ); // phpcs:ignore -- Non-strict comparison ok.
$generate_settings['footer_widget_size'] = ( '100' == $generate_settings['footer_widget_size'] ) ? '100% auto' : esc_attr( $generate_settings['footer_widget_size'] ); // phpcs:ignore -- Non-strict comparison ok.
$generate_settings['footer_size'] = ( '100' == $generate_settings['footer_size'] ) ? '100% auto' : esc_attr( $generate_settings['footer_size'] ); // phpcs:ignore -- Non-strict comparison ok.
// Initiate our CSS class
$css = new GeneratePress_Backgrounds_CSS;
$css = new GeneratePress_Backgrounds_CSS();
// Body
$css->set_selector( 'body' );
$css->add_property( 'background-image', esc_url( $generate_settings[ 'body_image' ] ), 'url' );
$css->add_property( 'background-repeat', esc_attr( $generate_settings[ 'body_repeat' ] ) );
$css->add_property( 'background-size', esc_attr( $generate_settings[ 'body_size' ] ) );
$css->add_property( 'background-attachment', esc_attr( $generate_settings[ 'body_attachment' ] ) );
$css->add_property( 'background-position', esc_attr( $generate_settings[ 'body_position' ] ) );
$css->add_property( 'background-image', esc_url( $generate_settings['body_image'] ), 'url' );
$css->add_property( 'background-repeat', esc_attr( $generate_settings['body_repeat'] ) );
$css->add_property( 'background-size', esc_attr( $generate_settings['body_size'] ) );
$css->add_property( 'background-attachment', esc_attr( $generate_settings['body_attachment'] ) );
$css->add_property( 'background-position', esc_attr( $generate_settings['body_position'] ) );
// Top bar
if ( is_active_sidebar( 'top-bar' ) ) {
$css->set_selector( '.top-bar' );
$css->add_property( 'background-image', esc_url( $generate_settings[ 'top_bar_image' ] ), 'url' );
$css->add_property( 'background-repeat', esc_attr( $generate_settings[ 'top_bar_repeat' ] ) );
$css->add_property( 'background-size', esc_attr( $generate_settings[ 'top_bar_size' ] ) );
$css->add_property( 'background-attachment', esc_attr( $generate_settings[ 'top_bar_attachment' ] ) );
$css->add_property( 'background-position', esc_attr( $generate_settings[ 'top_bar_position' ] ) );
$css->add_property( 'background-image', esc_url( $generate_settings['top_bar_image'] ), 'url' );
$css->add_property( 'background-repeat', esc_attr( $generate_settings['top_bar_repeat'] ) );
$css->add_property( 'background-size', esc_attr( $generate_settings['top_bar_size'] ) );
$css->add_property( 'background-attachment', esc_attr( $generate_settings['top_bar_attachment'] ) );
$css->add_property( 'background-position', esc_attr( $generate_settings['top_bar_position'] ) );
}
// Header
$css->set_selector( '.site-header' );
$css->add_property( 'background-image', esc_url( $generate_settings[ 'header_image' ] ), 'url' );
$css->add_property( 'background-repeat', esc_attr( $generate_settings[ 'header_repeat' ] ) );
$css->add_property( 'background-size', esc_attr( $generate_settings[ 'header_size' ] ) );
$css->add_property( 'background-attachment', esc_attr( $generate_settings[ 'header_attachment' ] ) );
$css->add_property( 'background-position', esc_attr( $generate_settings[ 'header_position' ] ) );
$css->add_property( 'background-image', esc_url( $generate_settings['header_image'] ), 'url' );
$css->add_property( 'background-repeat', esc_attr( $generate_settings['header_repeat'] ) );
$css->add_property( 'background-size', esc_attr( $generate_settings['header_size'] ) );
$css->add_property( 'background-attachment', esc_attr( $generate_settings['header_attachment'] ) );
$css->add_property( 'background-position', esc_attr( $generate_settings['header_position'] ) );
// Navigation background
$css->set_selector( '.main-navigation,.menu-toggle' );
$css->add_property( 'background-image', esc_url( $generate_settings[ 'nav_image' ] ), 'url' );
$css->add_property( 'background-repeat', esc_attr( $generate_settings[ 'nav_repeat' ] ) );
$css->add_property( 'background-image', esc_url( $generate_settings['nav_image'] ), 'url' );
$css->add_property( 'background-repeat', esc_attr( $generate_settings['nav_repeat'] ) );
// Navigation item background
$css->set_selector( '.main-navigation .main-nav > ul > li > a' );
$css->add_property( 'background-image', esc_url( $generate_settings[ 'nav_item_image' ] ), 'url' );
$css->add_property( 'background-repeat', esc_attr( $generate_settings[ 'nav_item_repeat' ] ) );
$css->add_property( 'background-image', esc_url( $generate_settings['nav_item_image'] ), 'url' );
$css->add_property( 'background-repeat', esc_attr( $generate_settings['nav_item_repeat'] ) );
// Navigation background/text on hover
$css->set_selector( '.main-navigation .main-nav > ul > li > a:hover,.main-navigation .main-nav > ul > li.sfHover > a' );
$css->add_property( 'background-image', esc_url( $generate_settings[ 'nav_item_hover_image' ] ), 'url' );
$css->add_property( 'background-repeat', esc_attr( $generate_settings[ 'nav_item_hover_repeat' ] ) );
$css->add_property( 'background-image', esc_url( $generate_settings['nav_item_hover_image'] ), 'url' );
$css->add_property( 'background-repeat', esc_attr( $generate_settings['nav_item_hover_repeat'] ) );
// Navigation background/text current
$css->set_selector( '.main-navigation .main-nav > ul > li[class*="current-menu-"] > a,.main-navigation .main-nav > ul > li[class*="current-menu-"] > a:hover,.main-navigation .main-nav > ul > li[class*="current-menu-"].sfHover > a' );
$css->add_property( 'background-image', esc_url( $generate_settings[ 'nav_item_current_image' ] ), 'url' );
$css->add_property( 'background-repeat', esc_attr( $generate_settings[ 'nav_item_current_repeat' ] ) );
$css->add_property( 'background-image', esc_url( $generate_settings['nav_item_current_image'] ), 'url' );
$css->add_property( 'background-repeat', esc_attr( $generate_settings['nav_item_current_repeat'] ) );
// Sub-Navigation text
$css->set_selector( '.main-navigation ul ul li a' );
$css->add_property( 'background-image', esc_url( $generate_settings[ 'sub_nav_item_image' ] ), 'url' );
$css->add_property( 'background-repeat', esc_attr( $generate_settings[ 'sub_nav_item_repeat' ] ) );
$css->add_property( 'background-image', esc_url( $generate_settings['sub_nav_item_image'] ), 'url' );
$css->add_property( 'background-repeat', esc_attr( $generate_settings['sub_nav_item_repeat'] ) );
// Sub-Navigation background/text on hover
$css->set_selector( '.main-navigation ul ul li > a:hover,.main-navigation ul ul li.sfHover > a' );
$css->add_property( 'background-image', esc_url( $generate_settings[ 'sub_nav_item_hover_image' ] ), 'url' );
$css->add_property( 'background-repeat', esc_attr( $generate_settings[ 'sub_nav_item_hover_repeat' ] ) );
$css->add_property( 'background-image', esc_url( $generate_settings['sub_nav_item_hover_image'] ), 'url' );
$css->add_property( 'background-repeat', esc_attr( $generate_settings['sub_nav_item_hover_repeat'] ) );
// Sub-Navigation background / text current
$css->set_selector( '.main-navigation ul ul li[class*="current-menu-"] > a,.main-navigation ul ul li[class*="current-menu-"] > a:hover,.main-navigation ul ul li[class*="current-menu-"].sfHover > a' );
$css->add_property( 'background-image', esc_url( $generate_settings[ 'sub_nav_item_current_image' ] ), 'url' );
$css->add_property( 'background-repeat', esc_attr( $generate_settings[ 'sub_nav_item_current_repeat' ] ) );
$css->add_property( 'background-image', esc_url( $generate_settings['sub_nav_item_current_image'] ), 'url' );
$css->add_property( 'background-repeat', esc_attr( $generate_settings['sub_nav_item_current_repeat'] ) );
// Content
$css->set_selector( '.separate-containers .inside-article,.separate-containers .comments-area,.separate-containers .page-header,.one-container .container,.separate-containers .paging-navigation,.separate-containers .inside-page-header' );
$css->add_property( 'background-image', esc_url( $generate_settings[ 'content_image' ] ), 'url' );
$css->add_property( 'background-repeat', esc_attr( $generate_settings[ 'content_repeat' ] ) );
$css->add_property( 'background-size', esc_attr( $generate_settings[ 'content_size' ] ) );
$css->add_property( 'background-attachment', esc_attr( $generate_settings[ 'content_attachment' ] ) );
$css->add_property( 'background-position', esc_attr( $generate_settings[ 'content_position' ] ) );
$css->add_property( 'background-image', esc_url( $generate_settings['content_image'] ), 'url' );
$css->add_property( 'background-repeat', esc_attr( $generate_settings['content_repeat'] ) );
$css->add_property( 'background-size', esc_attr( $generate_settings['content_size'] ) );
$css->add_property( 'background-attachment', esc_attr( $generate_settings['content_attachment'] ) );
$css->add_property( 'background-position', esc_attr( $generate_settings['content_position'] ) );
// Sidebar widget
$css->set_selector( '.sidebar .widget' );
$css->add_property( 'background-image', esc_url( $generate_settings[ 'sidebar_widget_image' ] ), 'url' );
$css->add_property( 'background-repeat', esc_attr( $generate_settings[ 'sidebar_widget_repeat' ] ) );
$css->add_property( 'background-size', esc_attr( $generate_settings[ 'sidebar_widget_size' ] ) );
$css->add_property( 'background-attachment', esc_attr( $generate_settings[ 'sidebar_widget_attachment' ] ) );
$css->add_property( 'background-position', esc_attr( $generate_settings[ 'sidebar_widget_position' ] ) );
$css->add_property( 'background-image', esc_url( $generate_settings['sidebar_widget_image'] ), 'url' );
$css->add_property( 'background-repeat', esc_attr( $generate_settings['sidebar_widget_repeat'] ) );
$css->add_property( 'background-size', esc_attr( $generate_settings['sidebar_widget_size'] ) );
$css->add_property( 'background-attachment', esc_attr( $generate_settings['sidebar_widget_attachment'] ) );
$css->add_property( 'background-position', esc_attr( $generate_settings['sidebar_widget_position'] ) );
// Footer widget
$css->set_selector( '.footer-widgets' );
$css->add_property( 'background-image', esc_url( $generate_settings[ 'footer_widget_image' ] ), 'url' );
$css->add_property( 'background-repeat', esc_attr( $generate_settings[ 'footer_widget_repeat' ] ) );
$css->add_property( 'background-size', esc_attr( $generate_settings[ 'footer_widget_size' ] ) );
$css->add_property( 'background-attachment', esc_attr( $generate_settings[ 'footer_widget_attachment' ] ) );
$css->add_property( 'background-position', esc_attr( $generate_settings[ 'footer_widget_position' ] ) );
$css->add_property( 'background-image', esc_url( $generate_settings['footer_widget_image'] ), 'url' );
$css->add_property( 'background-repeat', esc_attr( $generate_settings['footer_widget_repeat'] ) );
$css->add_property( 'background-size', esc_attr( $generate_settings['footer_widget_size'] ) );
$css->add_property( 'background-attachment', esc_attr( $generate_settings['footer_widget_attachment'] ) );
$css->add_property( 'background-position', esc_attr( $generate_settings['footer_widget_position'] ) );
// Footer
$css->set_selector( '.site-info' );
$css->add_property( 'background-image', esc_url( $generate_settings[ 'footer_image' ] ), 'url' );
$css->add_property( 'background-repeat', esc_attr( $generate_settings[ 'footer_repeat' ] ) );
$css->add_property( 'background-size', esc_attr( $generate_settings[ 'footer_size' ] ) );
$css->add_property( 'background-attachment', esc_attr( $generate_settings[ 'footer_attachment' ] ) );
$css->add_property( 'background-position', esc_attr( $generate_settings[ 'footer_position' ] ) );
$css->add_property( 'background-image', esc_url( $generate_settings['footer_image'] ), 'url' );
$css->add_property( 'background-repeat', esc_attr( $generate_settings['footer_repeat'] ) );
$css->add_property( 'background-size', esc_attr( $generate_settings['footer_size'] ) );
$css->add_property( 'background-attachment', esc_attr( $generate_settings['footer_attachment'] ) );
$css->add_property( 'background-position', esc_attr( $generate_settings['footer_position'] ) );
// Return our dynamic CSS
return apply_filters( 'generate_backgrounds_css_output', $css->css_output() );
}
}
@ -1310,6 +1317,26 @@ if ( ! function_exists( 'generate_background_scripts' ) ) {
* @since 0.1
*/
function generate_background_scripts() {
wp_add_inline_style( 'generate-style', generate_backgrounds_css() );
if ( 'inline' === generate_get_css_print_method() ) {
wp_add_inline_style( 'generate-style', generate_backgrounds_css() );
}
}
}
add_filter( 'generate_external_dynamic_css_output', 'generate_backgrounds_add_external_css' );
/**
* Add to external stylesheet.
*
* @since 1.11.0
*
* @param string $css Existing CSS.
*/
function generate_backgrounds_add_external_css( $css ) {
if ( 'inline' === generate_get_css_print_method() ) {
return $css;
}
$css .= generate_backgrounds_css();
return $css;
}

View File

@ -1,6 +1,13 @@
<?php
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) exit;
/**
* 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 );
@ -14,29 +21,26 @@ if ( ! function_exists( 'generate_backgrounds_secondary_nav_customizer' ) ) {
* 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 ) {
// Bail if we don't have our defaults
if ( ! function_exists( 'generate_secondary_nav_get_defaults' ) ) {
return;
}
// Make sure Secondary Nav is activated
if ( ! $wp_customize->get_section( 'secondary_nav_section' ) ) {
return;
}
// Get our defaults
$defaults = generate_secondary_nav_get_defaults();
if ( method_exists( $wp_customize, 'register_control_type' ) ) {
$wp_customize->register_control_type( 'GeneratePress_Section_Shortcut_Control' );
}
// Get our controls
require_once GP_LIBRARY_DIRECTORY . 'customizer-helpers.php';
// Add our section
$wp_customize->add_section(
'secondary_bg_images_section',
array(
@ -66,9 +70,9 @@ if ( ! function_exists( 'generate_backgrounds_secondary_nav_customizer' ) ) {
)
);
// Background
$wp_customize->add_setting(
'generate_secondary_nav_settings[nav_image]', array(
'generate_secondary_nav_settings[nav_image]',
array(
'default' => $defaults['nav_image'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -89,7 +93,6 @@ if ( ! function_exists( 'generate_backgrounds_secondary_nav_customizer' ) ) {
)
);
// Repeat
$wp_customize->add_setting(
'generate_secondary_nav_settings[nav_repeat]',
array(
@ -111,13 +114,13 @@ if ( ! function_exists( 'generate_backgrounds_secondary_nav_customizer' ) ) {
'no-repeat' => __( 'No Repeat', 'gp-premium' ),
),
'settings' => 'generate_secondary_nav_settings[nav_repeat]',
'priority' => 800
'priority' => 800,
)
);
// Item background
$wp_customize->add_setting(
'generate_secondary_nav_settings[nav_item_image]', array(
'generate_secondary_nav_settings[nav_item_image]',
array(
'default' => $defaults['nav_item_image'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -138,7 +141,6 @@ if ( ! function_exists( 'generate_backgrounds_secondary_nav_customizer' ) ) {
)
);
// Item repeat
$wp_customize->add_setting(
'generate_secondary_nav_settings[nav_item_repeat]',
array(
@ -160,13 +162,13 @@ if ( ! function_exists( 'generate_backgrounds_secondary_nav_customizer' ) ) {
'no-repeat' => __( 'No Repeat', 'gp-premium' ),
),
'settings' => 'generate_secondary_nav_settings[nav_item_repeat]',
'priority' => 1000
'priority' => 1000,
)
);
// Item hover
$wp_customize->add_setting(
'generate_secondary_nav_settings[nav_item_hover_image]', array(
'generate_secondary_nav_settings[nav_item_hover_image]',
array(
'default' => $defaults['nav_item_hover_image'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -187,7 +189,6 @@ if ( ! function_exists( 'generate_backgrounds_secondary_nav_customizer' ) ) {
)
);
// Item hover repeat
$wp_customize->add_setting(
'generate_secondary_nav_settings[nav_item_hover_repeat]',
array(
@ -213,9 +214,9 @@ if ( ! function_exists( 'generate_backgrounds_secondary_nav_customizer' ) ) {
)
);
// Current background
$wp_customize->add_setting(
'generate_secondary_nav_settings[nav_item_current_image]', array(
'generate_secondary_nav_settings[nav_item_current_image]',
array(
'default' => $defaults['nav_item_current_image'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -236,7 +237,6 @@ if ( ! function_exists( 'generate_backgrounds_secondary_nav_customizer' ) ) {
)
);
// Current repeat
$wp_customize->add_setting(
'generate_secondary_nav_settings[nav_item_current_repeat]',
array(
@ -262,7 +262,6 @@ if ( ! function_exists( 'generate_backgrounds_secondary_nav_customizer' ) ) {
)
);
// Sub-navigation section
$wp_customize->add_section(
'secondary_subnav_bg_images_section',
array(
@ -274,9 +273,9 @@ if ( ! function_exists( 'generate_backgrounds_secondary_nav_customizer' ) ) {
)
);
// Item background
$wp_customize->add_setting(
'generate_secondary_nav_settings[sub_nav_item_image]', array(
'generate_secondary_nav_settings[sub_nav_item_image]',
array(
'default' => $defaults['sub_nav_item_image'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -297,7 +296,6 @@ if ( ! function_exists( 'generate_backgrounds_secondary_nav_customizer' ) ) {
)
);
// Item repeat
$wp_customize->add_setting(
'generate_secondary_nav_settings[sub_nav_item_repeat]',
array(
@ -319,13 +317,13 @@ if ( ! function_exists( 'generate_backgrounds_secondary_nav_customizer' ) ) {
'no-repeat' => __( 'No Repeat', 'gp-premium' ),
),
'settings' => 'generate_secondary_nav_settings[sub_nav_item_repeat]',
'priority' => 1800
'priority' => 1800,
)
);
// Item hover
$wp_customize->add_setting(
'generate_secondary_nav_settings[sub_nav_item_hover_image]', array(
'generate_secondary_nav_settings[sub_nav_item_hover_image]',
array(
'default' => $defaults['sub_nav_item_hover_image'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -346,7 +344,6 @@ if ( ! function_exists( 'generate_backgrounds_secondary_nav_customizer' ) ) {
)
);
// Item hover repeat
$wp_customize->add_setting(
'generate_secondary_nav_settings[sub_nav_item_hover_repeat]',
array(
@ -372,9 +369,9 @@ if ( ! function_exists( 'generate_backgrounds_secondary_nav_customizer' ) ) {
)
);
// Current background
$wp_customize->add_setting(
'generate_secondary_nav_settings[sub_nav_item_current_image]', array(
'generate_secondary_nav_settings[sub_nav_item_current_image]',
array(
'default' => $defaults['sub_nav_item_current_image'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -395,7 +392,6 @@ if ( ! function_exists( 'generate_backgrounds_secondary_nav_customizer' ) ) {
)
);
// Current background repeat
$wp_customize->add_setting(
'generate_secondary_nav_settings[sub_nav_item_current_repeat]',
array(

View File

@ -1,19 +1,19 @@
<?php
/*
Addon Name: Generate Backgrounds
Author: Thomas Usborne
Author URI: http://edge22.com
*/
/**
* Backgrounds module.
*
* @since 1.1.0
*
* @package GP Premium
*/
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
exit; // No direct access, please.
}
// Define the version
// 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 );
}
// Include functions identical between standalone addon and GP Premium
require plugin_dir_path( __FILE__ ) . 'functions/functions.php';

View File

@ -1,5 +1,13 @@
<?php
defined( 'WPINC' ) or die;
/**
* This file handles column-related functionality.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
if ( ! function_exists( 'generate_blog_get_columns' ) ) {
/**
@ -13,33 +21,36 @@ if ( ! function_exists( 'generate_blog_get_columns' ) ) {
generate_blog_get_defaults()
);
// If columns are enabled, set to true
$columns = ( true == $generate_blog_settings['column_layout'] ) ? true : false;
// 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;
$columns = ( 'post' === get_post_type() || is_search() || is_home() ) ? $columns : false;
// If masonry is enabled via filter, enable columns
// 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
// 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
// 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
// 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 the result.
return apply_filters( 'generate_blog_columns', $columns );
}
}
@ -56,6 +67,7 @@ if ( ! function_exists( 'generate_blog_get_masonry' ) ) {
);
// 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 {
@ -88,7 +100,7 @@ if ( ! function_exists( 'generate_blog_add_columns_container' ) ) {
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 ' . esc_attr( 'grid-' . esc_attr( $columns ) ) . ' tablet-grid-50 mobile-grid-100"></div>' : ''
'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.
);
}
}
@ -126,7 +138,7 @@ if ( ! function_exists( 'generate_blog_columns_css' ) ) {
);
}
$separator = ( function_exists('generate_spacing_get_defaults') ) ? absint( $spacing_settings['separator'] ) : 20;
$separator = ( function_exists( 'generate_spacing_get_defaults' ) ) ? absint( $spacing_settings['separator'] ) : 20;
$return = '';
if ( generate_blog_get_columns() ) {

View File

@ -0,0 +1,143 @@
.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-flow: row wrap;
align-items: stretch;
}
.generate-columns-container:not(.masonry-container) .generate-columns {
display: flex;
}
.generate-columns .inside-article {
width: 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;
}
.no-sidebar .generate-columns-container .inside-article > * {
max-width: none;
}
.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 {
width: 20%;
}
.generate-columns.grid-25 {
width: 25%;
}
.generate-columns.grid-33 {
width: 33.3333%;
}
.generate-columns.grid-50 {
width: 50%;
}
.generate-columns.grid-60 {
width: 60%;
}
.generate-columns.grid-66 {
width: 66.66667%;
}
@media (min-width: 768px) and (max-width: 1024px) {
.generate-columns.tablet-grid-50 {
width: 50%;
}
}
@media (max-width: 767px) {
.generate-columns-activated .generate-columns-container {
margin-left: 0;
margin-right: 0;
}
.generate-columns-container > * {
padding-left: 0;
}
.generate-columns-container .page-header {
margin-left: 0;
}
.generate-columns.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;
}
}

View 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-flow:row wrap;align-items:stretch}.generate-columns-container:not(.masonry-container) .generate-columns{display:flex}.generate-columns .inside-article{width: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}.no-sidebar .generate-columns-container .inside-article>*{max-width:none}.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{width:20%}.generate-columns.grid-25{width:25%}.generate-columns.grid-33{width:33.3333%}.generate-columns.grid-50{width:50%}.generate-columns.grid-60{width:60%}.generate-columns.grid-66{width:66.66667%}@media (min-width:768px) and (max-width:1024px){.generate-columns.tablet-grid-50{width:50%}}@media (max-width:767px){.generate-columns-activated .generate-columns-container{margin-left:0;margin-right:0}.generate-columns-container>*{padding-left:0}.generate-columns-container .page-header{margin-left:0}.generate-columns.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}}

View File

@ -0,0 +1,110 @@
.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;
}
.post-image-aligned-left .inside-article,
.post-image-aligned-right .inside-article {
zoom: 1;
/* For IE 6/7 (trigger hasLayout) */
}
.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;
}
}

View 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}.post-image-aligned-left .inside-article,.post-image-aligned-right .inside-article{zoom:1}.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}}

File diff suppressed because one or more lines are too long

View File

@ -1,27 +1,27 @@
.post-image-above-header .inside-article .post-image,
.post-image-above-header .inside-article .featured-image {
margin-top:0;
margin-bottom:2em;
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;
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;
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;
margin-top: 0;
margin-left: 2em;
float: right;
text-align: right;
}
@ -30,7 +30,7 @@
.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;
margin-top: 2em;
}
.post-image-aligned-left > .featured-image,
@ -63,31 +63,52 @@
.post-image-aligned-left .inside-article,
.post-image-aligned-right .inside-article {
zoom: 1; /* For IE 6/7 (trigger hasLayout) */
zoom: 1;
/* For IE 6/7 (trigger hasLayout) */
}
.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.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.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.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.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,
.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;
}
@ -99,33 +120,22 @@
.masonry-container.are-images-unloaded,
.load-more.are-images-unloaded,
.masonry-enabled #nav-below {
opacity: 0;
opacity: 0;
}
/* columns */
.generate-columns-container:not(.masonry-container) {
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-flow: row wrap;
-ms-flex-flow: row wrap;
flex-flow: row wrap;
-webkit-align-items: stretch;
-ms-flex-align: stretch;
align-items: stretch;
flex-flow: row wrap;
align-items: stretch;
}
.generate-columns-container:not(.masonry-container) .generate-columns {
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
}
.generate-columns .inside-article {
width: 100%;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
@ -139,10 +149,7 @@
.generate-columns-container .paging-navigation,
.generate-columns-container .page-header {
-webkit-box-flex: 1;
-webkit-flex: 1 1 100%;
-ms-flex: 1 1 100%;
flex: 1 1 100%;
flex: 1 1 100%;
clear: both;
}
@ -157,16 +164,12 @@
.load-more:not(.has-svg-icon) .button.loading:before {
content: "\e900";
display: inline-block;
font-family: "GP Premium";
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-animation: spin 2s infinite linear;
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;
}
@ -176,23 +179,53 @@
}
.load-more .gp-icon svg {
-webkit-animation: spin 2s infinite linear;
animation: spin 2s infinite linear;
margin-right: 7px;
}
@keyframes spin {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
.generate-columns {
box-sizing: border-box;
}
.generate-columns.grid-20 {
width: 20%;
}
.generate-columns.grid-25 {
width: 25%;
}
.generate-columns.grid-33 {
width: 33.3333%;
}
.generate-columns.grid-50 {
width: 50%;
}
.generate-columns.grid-60 {
width: 60%;
}
.generate-columns.grid-66 {
width: 66.66667%;
}
@media (min-width: 768px) and (max-width: 1024px) {
.generate-columns.tablet-grid-50 {
width: 50%;
}
}
@media (max-width: 767px) {
.generate-columns-activated .generate-columns-container {
margin-left: 0;
@ -204,21 +237,18 @@
.generate-columns-container .page-header {
margin-left: 0;
}
.generate-columns.mobile-grid-100 {
width: 100%;
}
.generate-columns-container > .paging-navigation {
margin-left: 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;
}
@media (max-width: 768px) {
.load-more {
display: block;
text-align:center;
text-align: center;
margin-bottom: 0;
}
}

File diff suppressed because one or more lines are too long

View File

@ -14,6 +14,8 @@ if ( ! function_exists( 'generate_blog_scripts' ) ) {
* 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()
@ -47,15 +49,80 @@ if ( ! function_exists( 'generate_blog_scripts' ) ) {
}
if ( ( 'true' == generate_blog_get_masonry() && generate_blog_get_columns() ) || ( $settings[ 'infinite_scroll' ] && ! is_singular() && ! is_404() ) ) {
wp_enqueue_script( 'generate-blog', plugin_dir_url( __FILE__ ) . 'js/scripts.min.js', $deps, GENERATE_BLOG_VERSION, true );
wp_localize_script( 'generate-blog', 'blog', array(
'more' => $settings['masonry_load_more'],
'loading' => $settings['masonry_loading'],
'icon' => function_exists( 'generate_get_svg_icon' ) ? generate_get_svg_icon( 'spinner' ) : '',
) );
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' => 'none',
'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' => '.nav-links .next',
'append' => '#main article',
'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,
)
),
)
);
}
wp_enqueue_style( 'generate-blog', plugin_dir_url( __FILE__ ) . 'css/style-min.css', array(), GENERATE_BLOG_VERSION );
$needs_columns_css = false;
$needs_featured_image_css = false;
if ( ( ! is_singular() && $settings['column_layout'] ) || $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 );
}
}
}
@ -220,31 +287,37 @@ if ( ! function_exists( 'generate_blog_css' ) ) {
generate_blog_get_defaults()
);
// 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 ( ! defined( 'GENERATE_VERSION' ) ) {
return;
}
if ( ! $settings['single_date'] && ! $settings['single_author'] && $disable_headline && is_singular() ) {
$return .= '.single .entry-header{display:none;}.single .entry-content {margin-top:0;}';
}
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['date'] && ! $settings['author'] && ! is_singular() ) {
$return .= '.entry-header .entry-meta {display:none;}';
}
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'] && is_singular() ) {
$return .= '.entry-header .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['single_post_navigation'] && is_singular() ) {
$return .= '.post-navigation {display:none;}';
}
if ( ! $settings['date'] && ! $settings['author'] && ! is_singular() ) {
$return .= '.entry-header .entry-meta {display:none;}';
}
if ( ! $settings['single_categories'] && ! $settings['single_post_navigation'] && ! $settings['single_tags'] && is_singular() ) {
$return .= '.single footer.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;
@ -349,16 +422,24 @@ if ( ! function_exists( 'generate_blog_excerpt_more' ) ) {
generate_blog_get_defaults()
);
// If empty, return
if ( '' == $generate_settings['read_more'] ) {
return '';
}
return apply_filters( 'generate_excerpt_more_output', sprintf( ' ... <a title="%1$s" class="read-more" href="%2$s">%3$s</a>',
the_title_attribute( 'echo=0' ),
esc_url( get_permalink( get_the_ID() ) ),
wp_kses_post( $generate_settings['read_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' )
)
)
);
}
}
@ -373,17 +454,24 @@ if ( ! function_exists( 'generate_blog_content_more' ) ) {
generate_blog_get_defaults()
);
// If empty, return
if ( '' == $generate_settings['read_more'] ) {
return '';
}
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">%3$s%4$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'] ),
'<span class="screen-reader-text">' . get_the_title() . '</span>'
) );
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' )
)
)
);
}
}
@ -485,15 +573,18 @@ if ( ! function_exists( 'generate_disable_post_comments_link' ) ) {
}
}
add_filter( 'next_post_link', 'generate_disable_post_navigation' );
add_filter( 'previous_post_link', 'generate_disable_post_navigation' );
add_filter( 'generate_show_post_navigation', 'generate_disable_post_navigation' );
/**
* Remove the single post navigation
*
* @since 1.5
*/
function generate_disable_post_navigation( $navigation ) {
return generate_disable_post_thing( $navigation, 'single_post_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' );

View File

@ -1,5 +1,13 @@
<?php
defined( 'WPINC' ) or die;
/**
* 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.
@ -95,13 +103,13 @@ if ( ! function_exists( 'generate_get_blog_image_attributes' ) ) {
$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
'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' ] ) {
// If there's no height or width, empty the array.
if ( 9999 == $atts['width'] && 9999 == $atts['height'] ) { // phpcs:ignore
$atts = array();
}
@ -122,13 +130,13 @@ if ( ! function_exists( 'generate_blog_setup' ) ) {
generate_blog_get_defaults()
);
// Move our featured images to above the title
if ( 'post-image-above-header' == $settings['post_image_position'] ) {
// 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') ) {
// 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' );
}
@ -137,12 +145,13 @@ if ( ! function_exists( 'generate_blog_setup' ) ) {
$page_header_content = false;
if ( function_exists( 'generate_page_header_get_options' ) ) {
$options = generate_page_header_get_options();
if ( '' !== $options[ 'content' ] ) {
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 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' );
@ -150,23 +159,23 @@ if ( ! function_exists( 'generate_blog_setup' ) ) {
}
}
// Remove the core theme featured image
// I would like to filter instead one day
// 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'] ) {
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'] ) {
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'] ) {
if ( 'above-content' === $settings[ $location . '_post_image_position' ] ) {
add_action( 'generate_after_header', 'generate_blog_single_featured_image' );
}
}
@ -178,6 +187,7 @@ 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 ) {
@ -219,15 +229,27 @@ function generate_blog_single_featured_image() {
$location = generate_blog_get_singular_template();
if ( ( function_exists( 'is_woocommerce' ) && is_woocommerce() ) || ! $settings[$location . '_post_image'] || ! $image_id ) {
if ( ( function_exists( 'is_woocommerce' ) && is_woocommerce() ) || ! $settings[ $location . '_post_image' ] || ! $image_id ) {
return false;
}
$image_html = apply_filters( 'post_thumbnail_html',
wp_get_attachment_image( $image_id, apply_filters( 'generate_page_header_default_size', 'full' ), '',
array(
'itemprop' => 'image',
)
$attrs = array(
'itemprop' => 'image',
);
if ( function_exists( 'generate_get_schema_type' ) ) {
if ( 'microdata' !== generate_get_schema_type() ) {
$attrs = array();
}
}
$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,
@ -240,18 +262,23 @@ function generate_blog_single_featured_image() {
$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,
'above-content' === $settings[ $location . '_post_image_position' ] ? 'grid-container grid-parent' : null,
);
$image_html = apply_filters( 'generate_single_featured_image_html', $image_html );
echo apply_filters( 'generate_single_featured_image_output', sprintf(
'<div class="featured-image %2$s">
%1$s
</div>',
$image_html,
implode( ' ', $classes )
), $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' );
@ -274,13 +301,13 @@ function generate_blog_page_header_image_atts( $atts ) {
$options = generate_page_header_get_options();
if ( 'enable' == $options[ 'image_resize' ] ) {
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
'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,
);
}
@ -304,7 +331,7 @@ function generate_blog_page_header_link( $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>';
return '<a href="' . esc_url( $options['image_link'] ) . '"' . apply_filters( 'generate_page_header_link_target', '' ) . '>' . $image_html . '</a>';
} else {
return $image_html;
}

View File

@ -3,15 +3,7 @@ jQuery( document ).ready( function( $ ) {
var msnry = false;
if ( $masonry_container.length ) {
var $grid = $masonry_container.masonry({
columnWidth: '.grid-sizer',
itemSelector: 'none',
stamp: '.page-header',
percentPosition: true,
stagger: 30,
visibleStyle: { transform: 'translateY(0)', opacity: 1 },
hiddenStyle: { transform: 'translateY(5px)', opacity: 0 },
} );
var $grid = $masonry_container.masonry( generateBlog.masonryInit );
msnry = $grid.data( 'masonry' );
@ -37,22 +29,19 @@ jQuery( document ).ready( function( $ ) {
var $button = $( '.load-more a' );
var svgIcon = '';
if ( blog.icon ) {
svgIcon = blog.icon;
if ( generateBlog.icon ) {
svgIcon = generateBlog.icon;
}
$container.infiniteScroll( {
path: '.nav-links .next',
append: '#main article',
history: false,
outlayer: msnry,
loadOnScroll: $button.length ? false : true,
button: $button.length ? '.load-more a' : null,
scrollThreshold: $button.length ? false : 600,
} );
var infiniteScrollInit = generateBlog.infiniteScrollInit;
infiniteScrollInit.outlayer = msnry;
$container.infiniteScroll( infiniteScrollInit );
$button.on( 'click', function( e ) {
$( this ).html( svgIcon + blog.loading ).addClass( 'loading' );
document.activeElement.blur();
$( this ).html( svgIcon + generateBlog.loading ).addClass( 'loading' );
} );
$container.on( 'append.infiniteScroll', function( event, response, path, items ) {
@ -60,8 +49,11 @@ jQuery( document ).ready( function( $ ) {
$container.append( $button.parent() );
}
// Fix srcset images not loading in Safari.
// img.outerHTML = img.outerHTML isn't minified properly, so we need the extra var.
$( items ).find( 'img' ).each( function( index, img ) {
img.outerHTML = img.outerHTML;
var imgOuterHTML = img.outerHTML;
img.outerHTML = imgOuterHTML;
} );
if ( $grid ) {
@ -70,7 +62,7 @@ jQuery( document ).ready( function( $ ) {
} );
}
$button.html( svgIcon + blog.more ).removeClass( 'loading' );
$button.html( svgIcon + generateBlog.more ).removeClass( 'loading' );
} );
$container.on( 'last.infiniteScroll', function() {

View File

@ -1 +1 @@
jQuery(document).ready(function(t){var n=t(".masonry-container"),o=!1;if(n.length){var i=n.masonry({columnWidth:".grid-sizer",itemSelector:"none",stamp:".page-header",percentPosition:!0,stagger:30,visibleStyle:{transform:"translateY(0)",opacity:1},hiddenStyle:{transform:"translateY(5px)",opacity:0}});o=i.data("masonry"),i.imagesLoaded(function(){i.masonry("layout"),i.removeClass("are-images-unloaded"),t(".load-more").removeClass("are-images-unloaded"),t("#nav-below").css("opacity","1"),i.masonry("option",{itemSelector:".masonry-post"});var n=i.find(".masonry-post");i.masonry("appended",n)}),t("#nav-below").insertAfter(".masonry-container"),t(window).on("orientationchange",function(n){i.masonry("layout")})}if(t(".infinite-scroll").length&&t(".nav-links .next").length){var l=t("#main article").first().parent(),r=t(".load-more a"),s="";blog.icon&&(s=blog.icon),l.infiniteScroll({path:".nav-links .next",append:"#main article",history:!1,outlayer:o,loadOnScroll:!r.length,button:r.length?".load-more a":null,scrollThreshold:!r.length&&600}),r.on("click",function(n){t(this).html(s+blog.loading).addClass("loading")}),l.on("append.infiniteScroll",function(n,o,e,a){t(".generate-columns-container").length||l.append(r.parent()),t(a).find("img").each(function(n,o){o.outerHTML=o.outerHTML}),i&&i.imagesLoaded(function(){i.masonry("layout")}),r.html(s+blog.more).removeClass("loading")}),l.on("last.infiniteScroll",function(){t(".load-more").hide()})}});
jQuery(document).ready(function(t){var i,r,l,s,n,e=t(".masonry-container"),o=!1;e.length&&(o=(i=e.masonry(generateBlog.masonryInit)).data("masonry"),i.imagesLoaded(function(){i.masonry("layout"),i.removeClass("are-images-unloaded"),t(".load-more").removeClass("are-images-unloaded"),t("#nav-below").css("opacity","1"),i.masonry("option",{itemSelector:".masonry-post"});var n=i.find(".masonry-post");i.masonry("appended",n)}),t("#nav-below").insertAfter(".masonry-container"),t(window).on("orientationchange",function(n){i.masonry("layout")})),t(".infinite-scroll").length&&t(".nav-links .next").length&&(r=t("#main article").first().parent(),l=t(".load-more a"),s="",generateBlog.icon&&(s=generateBlog.icon),(n=generateBlog.infiniteScrollInit).outlayer=o,r.infiniteScroll(n),l.on("click",function(n){document.activeElement.blur(),t(this).html(s+generateBlog.loading).addClass("loading")}),r.on("append.infiniteScroll",function(n,e,o,a){t(".generate-columns-container").length||r.append(l.parent()),t(a).find("img").each(function(n,e){var o=e.outerHTML;e.outerHTML=o}),i&&i.imagesLoaded(function(){i.masonry("layout")}),l.html(s+generateBlog.more).removeClass("loading")}),r.on("last.infiniteScroll",function(){t(".load-more").hide()}))});

View File

@ -1,17 +1,20 @@
<?php
/*
Add-on Name: Generate Blog
Author: Thomas Usborne
Author URI: http://edge22.com
*/
/**
* Blog module.
*
* @since 1.1.0
*
* @package GP Premium
*/
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
// Define the version
// 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
// Include functions identical between standalone addon and GP Premium.
require plugin_dir_path( __FILE__ ) . 'functions/generate-blog.php';

View File

@ -1,543 +0,0 @@
== changelog ==
= 1.10.0 =
* Blog: Remove existing on-the-fly featured image resizer (Image Processing Queue)
* Blog: Choose from existing image sizes for featured images
* Blog: Use CSS to further resize featured images if necessary
* Blog: Fix edge case persistent transient bug with old image resizer
* Elements: Fix broken closing element in metabox
* General: Change scroll variable to gpscroll in smooth scroll script to avoid conflicts
* General: Update responsive widths in Customizer
* General: Fix responsive Customizer views when using RTL
* Menu Plus: Don't output sticky nav branding if sticky nav is disabled
* Menu Plus: Fix focus when off canvas overlay is opened (a11y)
* Menu Plus: Fix sticky navigation jump when navigation branding is in use
* Sections: Fix visible block editor when Sections are enabled
* WooCommerce: Use minmax in grid template definitions to fix overflow issue
* WooCommerce: Prevent add to cart panel interfering with back to top button on mobile
* WooCommerce: WooCommerce: Fix secondary image position if HTML isn't ordered correctly
* General: Add/update all translations over 50% complete. Big thanks to all contributors!
* Translation: Added Arabic - thank you anass!
* Translation: Added Bengali - thank you gtmroy!
* Translation: Added Spanish (Spain) - thank you davidperez (closemarketing.es)!
* Translation: Added Spanish (Argentina) - thank you bratorr!
* Translation: Added Finnish - thank you Stedi!
* Translation: Add Dutch - thank you Robin!
* Translation: Added Ukrainian - thank you EUROMEDIA!
* Translation: Vietnamese added - thank you themevi!
= 1.9.1 =
* Blog: Fix "null" in infinite scroll load more button text
* WooCommerce: Fix hidden added to cart panel on mobile when sticky nav active
* WooCommerce: Fix missing SVG icon in mobile added to cart panel
= 1.9.0 =
* Blog: Support SVG icon feature
* Colors: Add navigation search color options
* Disable Elements: Disable mobile menu in Mobile Header if nav is disabled
* Elements: Add wp_body_open hook
* Elements: Allow 0 mobile padding in Elements
* Elements: Add generate_elements_admin_menu_capability filter
* Elements: Add generate_page_hero_css_output filter
* Elements: Prevent error in Header Element if taxonomy doesn't exist
* Elements: Fix double logo when Header Element has logo + using nav as header
* Elements: Fix mobile header logo not replacing if merge is disabled
* Elements: Fix missing arrow in Choose Element Type select in WP 5.3
* Elements: Add generate_inside_site_container hook option
* Elements: Add generate_after_entry_content hook option
* Menu Plus: Add off canvas desktop toggle label option
* Menu Plus: Add generate_off_canvas_toggle_output filter
* Menu Plus: Support SVG icon feature
* Menu Plus: Fix sticky navigation overlapping BB controls
* Menu Plus: Add align-items: center to nav as header, mobile header and sticky nav with branding
* Sections: Fix text/visual switch bug in Firefox
* Sites: Add option to revert site import
* Sites: Increase site library limit to 100
* Spacing: Add live preview to group container padding
* Typography: Add tablet site title/navigation font size options
* Typography: Add archive post title weight, transform, font size and line height
* Typography: Add single content title weight, transform, font size and line height
* Typography: Only call all google fonts once in the Customizer
* Typography: Get Google fonts from readable JSON list
* Typography: Make sure font settings aren't lost if list is changed
* Typography: Only call generate_get_all_google_fonts if needed
* WooCommerce: Add columns gap options (desktop, tablet, mobile)
* WooCommerce: Add tablet column options
* WooCommerce: Add related/upsell tablet column options
* WooCommerce: Support SVG icon feature
* WooCommerce: Prevent empty added to cart panel on single products
* WooCommerce: Fix woocommerce-ordering arrow in old FF versions
* WooCommerce: Make item/items string translatable
* General: Better customizer device widths
* General: Use generate_premium_get_media_query throughout modules
* General: Improve Customizer control styling
= 1.8.3 =
* Menu Plus: Use flexbox for center aligned nav with nav branding
* Menu Plus: Center overlay off canvas exit button on mobile
* Menu Plus: Add alt tag to sticky nav logo
* Menu Plus: Set generate_not_mobile_menu_media_query filter based on mobile menu breakpoint
* Sections: Remember when text tab is active
* Sections: Disable visual editor if turned off in profile
* Typography: Add generate_google_font_display filter
* WooCommerce: Fix single product sidebar layout metabox option
* WooCommerce: Reduce carousel thumbnail max-width to 100px to match new thumbnail sizes
= 1.8.2 =
* Elements: Use Page Hero site title color for mobile header site title
* Menu Plus: Give mobile header site title more left spacing
* Menu Plus: Fix nav search icon in sticky navigation when using nav branding in Firefox
* Site Library: Show Site Library tab even if no sites exist
* Site Library: Show an error message in Site Library if no sites exist
* Typography: Remove reference to generate_get_navigation_location() function
* WooCommerce: Remove quantity field arrows when using quantity buttons in Firefox
* WooCommerce: Remove extra border when loading quantity buttons
* WooCommerce: Use get_price_html() is sticky add to cart panel
= 1.8.1 =
* Menu Plus: Revert sticky nav duplicate ID fix due to Cyrillic script bug
= 1.8 =
* Blog: Apply columns filter to masonry grid sizer
* Colors: Merge Footer Widgets and Footer controls in Color panel
* Colors: Remove edit_theme_options capability to Customizer controls (set by default)
* Disable Elements: Make sure mobile header is disabled when primary navigation is disabled
* Elements: Add content width option in Layout Element
* Elements: Fix mobile header logo when mobile menu toggled
* Elements: Add generate_page_hero_location filter
* Elements: Add generate_elements_show_object_ids filter to show IDs in Display Rule values
* Elements: Prevent merged header wrap from conflicting with Elementor controls
* Elements: Change Container tab name to Content
* Elements: Add woocommerce_share option to Hooks
* Elements: Improve WPML compatibility
* Elements: Improve Polylang compatibility
* Elements: Prevent PHP notices when adding taxonomy locations to non-existent archives
* Elements: Add generate_mobile_cart_items hook to hook list
* Elements: Add generate_element_post_id filter
* Elements: Escape HTML elements inside Element textarea
* Elements: Add Beaver Builder templates to the Display Rules
* Menu Plus: Add mobile header breakpoint option
* Menu Plus: Add off canvas overlay option
* Menu Plus: Add navigation as header option
* Menu Plus: Remove navigation logo option if navigation as header set
* Menu Plus: Add sticky navigation logo option
* Menu Plus: Allow site title in mobile header instead of logo
* Menu Plus: Add option to move exit button inside the off canvas panel
* Menu Plus: Change Slideout Navigation name to Off Canvas Panel
* Menu Plus: Only re-focus after slideout close on escape key
* Menu Plus: Give close slideout event a name so it can be removed
* Menu Plus: Remove invalid transition-delay
* Menu Plus: Improve slideout overlay transition
* Menu Plus: Add mobile open/close icons to GPP font
* Menu Plus: Allow dynamic widget classes in off canvas panel (fixes WC range slider widget issue)
* Menu Plus: Basic compatibility with future SVG icons
* Menu Plus: Prevent duplicate IDs when sticky navigation is cloned
* Secondary Nav: Add dropdown direction option
* Secondary Nav: Basic compatibility with future SVG icons
* Sections: Fix section editor issues in WP 5.0
* Sections: Show Better Font Awesome icon in editor
* Sites: Re-design UI
* Sites: Add option to activate as a module like all the other modules
* Sites: Don't show backup options button if no options exist
* Sites: Make JS action classes more specific to the site library
* Sites: Set mime types of content.xml and widgets.wie
* Spacing: Add header padding option for mobile
* Spacing: Add widget padding option for mobile
* Spacing: Add footer widgets padding option for mobile
* Spacing: Add content separator option
* Spacing: Apply mobile menu item width to mobile bar only
* WooCommerce: Add option for mini cart in the menu
* WooCommerce: Add option to open off overlay panel on add to cart
* WooCommerce: Add option to open sticky add to cart panel on single products
* WooCommerce: Add option to add +/- buttons to the quantity fields
* WooCommerce: Add option to show number of items in cart menu item
* WooCommerce: Add option to choose single product image area width
* WooCommerce: Add color options for price slider widget
* WooCommerce: Use CSS grid for the product archives
* WooCommerce: Horizontally align add to cart buttons
* WooCommerce: Re-design the cart widget
* WooCommerce: Tighten up product info spacing
* WooCommerce: Improve product tab design to look more like tabs
* WooCommerce: Simplify single product image display
* WooCommerce: Use flexbox for quantity/add to cart alignment
* WooCommerce: Improve rating star styles
* WooCommerce: Use product alignment setting for related/upsell products
* WooCommerce: Remove bottom margin from product image
* WooCommerce: Organize colors in the Customizer
* WooCommerce: Remove title attribute from menu cart item
* WooCommerce: Improve coupon field design
* WooCommerce: Improve result count/ordering styling
* WooCommerce: Add gap around WC single product images
* WooCommerce: Remove arrow from checkout button
* WooCommerce: Hide view cart link on add to cart click
* WooCommerce: Organize CSS
* Introduce in-Customizer shortcuts
* Add generate_disable_customizer_shortcuts filter
= 1.7.8 =
* Sites: Prevent future compatibility issues with Elementor by removing automatic URL replacement
= 1.7.7 =
* Sites: Fix failed content import in specific PHP versions
= 1.7.6 =
* Elements: Hide Add New button when opening saved Element with no type
* Sections: Show page title in Gutenberg when Sections are active
* Sections: Fix relative image URLs inside the Section editor
* Sites: Fix failed content/widget import in WP 5.0.1/4.9.9
* Sites: Fix no access to WooCommerce setup wizard
= 1.7.5 =
* Colors: Improve block editor button color preview
* Menu Plus: Mobile menu items hidden behind content with higher z-index when sticky
* Menu Plus: Prevent mobile menu from covering mobile toggle when sticky
* Menu Plus: Don't close mobile menu if # is the whole URL
= 1.7.4 =
* Colors: Fix navigation live color preview issues
* Colors: Move navigation parent item title down in Customizer
* Elements: Allow slashes in hook names
* General: Fix smooth scroll anchor location on mobile (requires GP 2.2)
* Menu Plus: Use https for navigation microdata
* Menu Plus: Remove header-image class from navigation and mobile header logos
* Menu Plus: Add navigation search height support to mobile header and sticky nav
* Typography: Include block editor button in live preview
= 1.7.3 =
* Blog: Allow masonry to be turned off using a boolean filter
* Blog: Fix load more button appearing when not needed
* Blog: Remove infinite scroll load more button from WooCommerce archives
* Blog: Prevent content width option from applying to columns
* Elements: Fix empty object fields when Post Archive is set
* Elements: Allow slashes in custom hook field
* Elements: Allow multiple layout elements per condition
* Elements: Allow 0 value in mobile padding options
* Elements: Prevent PHP notice if $post isn't an object
* Gutenberg: Add initial support for live preview spacing of Gutenberg blocks
* Menu Plus: Add menu-item-align-right class to slideout toggle
* Menu Plus: Fix JS error in slideout navigation when no menu is set
* Sites: Fix image shadow on hover
* Sites: Add message when no plugins are needed
* Sites: Update custom link URL in menu items
* Sites: Prevent PHP warning in PHP 7.3
* Sites: Add generate_sites_ignore_plugins filter
* Sites: Fix WooCommerce setup wizard conflict with Site Library
* Sites: Fix PHP notices during WooCommerce setup wizard
* Typography: Add support for H1-H3 bottom margin options
* WooCommerce: Add menu-item-align-right class to cart menu item
* WooCommerce: Fix multi column product spacing on mobile
= 1.7.2 =
* Elements: Fix admin body class spaces
* General: Fix JS error in anchors when smooth scroll class not added
* General: Fix sticky navigation offset when using smooth scroll
* WooCommerce: Apply Elementor Pro WC columns fix to Elementor Pro widget only
* WooCommerce: Fix BlockUI issue
= 1.7.1 =
* Elements: Fix PHP error in PHP 5.3
* Elements: Fix Choose Element not showing due to some third party plugins
= 1.7 =
* Blog: Prevent masonry container jump on load
* Blog: Change "Full" label to "Full Content"
* New: Elements module
* Elements: Header element (replaces the Page Header module)
* Elements: Hook element (replaces the Hooks module)
* Elements: Layout element
* Hooks: Replaced by Elements module
* Hooks: Move link to legacy hooks inside Elements area
* Import/Export: Re-write code
* Import/Export: Import activated modules
* Menu Plus: Fix slideout close button alignment/color issues
* Menu Plus: Fix slideout issue with relative main navigation CSS
* Menu Plus: Fix ul display inside slideout navigation widget
* Menu Plus: Change Slideout Navigation theme location label to Slideout Menu
* Menu Plus: Close slideout navigation when a link within it is clicked
* Menu Plus: Show slideout navigation theme location option after Primary
* Menu Plus: Improve a11y of slideout navigation
* Menu Plus: Add .site-wrapper class compatibility to sticky nav
* Menu Plus: Prepare offside.js for future button dropdown menu toggle
* Menu Plus: Add .slideout-exit class to close slideout
* Page Header: Replaced by Elements module
* Page Header: Move link to legacy Page Headers inside Elements area
* Page Header: Fix hentry Google Search Console errors
* Page Header: Fix clearing element issue
* Page Header: WPML fix in global locations
* Page Header: Prevent PHP notices within Elementor Library area
* Page Header: Fix retina logo issue (in new Elements module only)
* Page Header: Show original logo in sticky navigation (in new Elements module only)
* Page Header: Add mobile header logo option (in new Elements module only)
* Secondary Nav: Show theme location option after Primary
* Sections: Allow Sections when Gutenberg is activated
* Sections: Hide Gutenberg editor when Sections enabled
* Sections: Fix text domain issues
* Sections: Use regular checkbox for use sections
* Spacing: Add future support for sub-menu width option
* Sites: Fix .complete class conflicts
* Sites: Add GENERATE_DISABLE_SITE_LIBRARY constant
* Sites: Remove verified provider debug notice
* Sites: Add class check to prevent future Elementor error
* WooCommerce: Add shopping bag and shopping basket icon options to cart menu item
* WooCommerce: Update shopping cart icon
* WooCommerce: Fix WC error with non-product post types
* WooCommerce: Fix too many WC star issue
* WooCommerce: Add CSS for cart menu item in secondary nav
* WooCommerce: Add WC menu item location filter to mobile cart
* WooCommerce: Fix issue with disabling sale badge when set to overlay
* WooCommerce: Add option to disable/enable sale badge on single product pages
* WooCommerce: Fix my account icon on mobile
* WooCommerce: Fix columns issue with Elementor Pro
* General: Fix smooth scroll issues on mobile
* General: Improve overall smooth scroll functionality
* General: Add generate_smooth_scroll_elements filter
* General: Move GPP icons from Font Awesome to custom icons
* A11y: Add context to all "Contained" strings
= 1.6.2 =
* Sites: Prevent PHP notice when Sites can't be reached
= 1.6.1 =
* Blog: Fix infinite scroll masonry issues in Firefox
* General: Improve smooth scroll script
* Import/Export: Show modules to export if defined in wp-config.php
* Sites: Prevent PHP warnings if no Sites are found
* Sites: Add generate_disable_site_library filter to disable Site Library
* Sites: Improve page builder filter display
* Sites: Prevent duplicate site display after details button in preview clicked
* WooCommerce: Add missing icons if Font Awesome is turned off
= 1.6 =
* New: Sites module
* Translations: Merge all translations into gp-premium text domain
* General: Add smooth scroll option
* General: Move batch processing files into library
* General: Add GPP icon set
* General: WPCS and PHPCS improvements
* Blog: Fix PHP 7.2 warning
* Blog: Fix Safari infinite scroll issues with srcset
* Blog: Refresh masonry on infinite scroll append
* Blog: Remove infinite scroll on 404 and no results pages
* Blog: Fix Yoast SEO breaking columns with certain settings
* Blog: Re-layout masonry on load
* Colors: Add slideout navigation color options
* Colors: Merge navigation + sub-navigation options into one section
* Import/Export: One click export and import
* Menu Plus: Re-build slideout navigation to use vanilla JS
* Menu Plus: Add slideout navigation widget area
* Menu Plus: Add close icon to slideout navigation
* Menu Plus: Set sticky nav ID on refresh if stuck
* Menu Plus: Allow WPML to modify Page Header select metabox
* Menu Plus: Re-build mobile header using flexbox
* Menu Plus: Use CSS for slideout navigation icon
* Menu Plus: Fix sticky navigation slide down in Safari
* Menu Plus: Add workaround for iOS sticky nav search issue
* Page Header: Improve Page Header metabox UI on smaller screens
* Page Header: Use author display name in template tag
* Page Header: Add generate_page_header_id filter
* Page Header: Fix vertical center issues in IE11
* Page Header: Remove flexibility.js for IE8 support
* Page Header: Fix GiveWP compatibility
* Secondary Navigation: Re-build CSS
* Sections: Disable Gutenberg if Sections are activated
* Sections: Add generate_sections_gutenberg_compatible filter
* Spacing: Fix one container widget padding preview in Customizer
* Typography: Add Slideout Navigation typography options
* WooCommerce: Clear up-sells when directly after entry content
* WooCommerce: Fix placeholder text cut off in Firefox
* WooCommerce: Use GPP icon set for cart menu item
* WooCommerce: Load .js in the footer
* Update Background Process library
* Clean up code license key activation code
* Remove verify.php
* Prevent PHP notice when saving empty license
* Add beta testing checkbox to license key area
= 1.5.6 =
* Backgrounds: Make position control description translatable
* Blog: Fix disabled page featured images if post featured images are disabled
* Blog: Let WP handle featured image alt attributes
* Colors: Fix text domain
* Colors: Improve inconsistent live preview behavior
* Menu Plus: Prep desktop only slideout icon for GP 2.0
* Page Header: Allow unfiltered HTML in content if user is allowed
* Page Header: Only load CSS file if content is added
* Typography: Fix h5 font size not appearing in GP 2.0
= 1.5.5 =
* Blog: Fix broken images while using Infinite Scroll in Safari
* Typography: Fix first variant not appearing when you select a font
* Typography: Fix select issues when plugins load old versions of the select2 library
= 1.5.4 =
* Sections: Fix Visual/Text tab in WP 4.9
* Sections: Fix Content/Settings tab in WP 4.9
= 1.5.3 =
* Blog: Fix masonry filter not working on custom post type archives
* Blog: Fix resized featured images when page header resizer is enabled
* Blog: Fix broken Customizer toggles in Safari
* Page Header: Fix PHP notice when saving posts
* Fix/add various gettext values
= 1.5.2 =
* Backgrounds: Fix issue with saving background image options
= 1.5.1 =
* Blog: Make infinite scroll container selector more specific
* Page Header: Fix background video when container is contained
* Page Header: Remove featured image on attachment pages
= 1.5 =
* Backgrounds: Rebuild Customizer control
* Blog: Move Blog panel into the Layout panel
* Blog: Migrate options from select dropdowns to checkboxes where applicable
* Blog: Merge masonry + column options into one area
* Blog: Add new post meta visibility options for single posts
* Blog: Replace old image resizer (aq_resize) with Image Processing Queue (reload your site once or twice to build new images)
* Blog: Add single post featured image options
* Blog: Add page featured image options
* Blog: Remove masonry meta box
* Blog: Add option to remove padding around centered featured images
* Blog: Add option to turn read more link into button
* Blog: Add option to turn on infinite scroll regardless of layout
* Blog: Use infinite scroll with or without a load more button
* Blog: Make read more links better for accessibility
* Blog: Migrate single post page header position option to single featured image location option
* Blog: Remove ellipses if excerpt is set to 0
* Blog: Change style.css handle to include generate prefix
* Blog: Remove unnecessary IE8 support
* Blog: Add alt attribute to featured images
* Blog: Fix pagination spacing when One Container is set
* Blog: Fix column/masonry spacing at 768px
* Colors: Add select input live preview settings
* Colors: Fix button labels
* Copyright: Move Copyright section into Layout panel
* Menu Plus: Fix mobile menu logo bug when navigation is set to float right
* Menu Plus: Fix no transition sticky navigation bug while on mobile
* Page Header: Replace old image resizer (aq_resize) with Image Processing Queue (reload your site once or twice to build new images)
* Page Header: Don't use global page header locations if not published
* Page Header: Sanitize page header content when saved to database
* Page Header: Make sure Elementor sections are accessible when page header is merged
* Page Header: Prepare transparent color picker for WP 4.9 changes
* Page Header: Fix background video in Safari 11
* Page Header: Add global locations for taxonomies
* Page Header: Add {{custom_field.description}} template tag to taxonomies (categories etc..)
* Page Header: Add ID to page header element
* Page Header: Fix individual taxonomy page header control not appearing on Toolset created taxonomies
* Page Header: Ensure jQuery Vide (video background) script only loads when needed
* Page Header: Fix custom images not displaying
* Page Header: Fix image link option not working
* Typography: Lay groundwork for H6 options
* Typography: Space out heading typography options
* Typography: Add System Stack option
* Typography: Fix Google Font variant control in WP 4.9
* Sections: Show Envira button
* Sections: Show Gridable button
* Sections: Prepare transparent color picker for WP 4.9 changes
* WooCommerce: Add filter to cart menu item location
* WooCommerce: Better activation compatibility with multi-site
* WooCommerce: Use wc_get_cart_url() for menu item
* German translations updated (Thanks, Daniel!)
= 1.4.3 =
* Page Header: Pass args to post_thumbnail_html filter
* Page Header: Allow custom field template tags on pages
* Page Header: Re-add generate_page_header_video_loop filter
* Page Header: Add generate_page_header_video_muted filter
* Page Header: Remove taxonomy title if page header has title
* WooCommerce: Improve disabled WC button styling
= 1.4.2 =
* Page Header: Improve inner container
* Page Header: Allow contained page header even when position:absolute is set
* Page Header: Apply page header text color to headings in page header
* WooCommerce: Fix mobile columns issue
= 1.4.1 =
* Page Header: Fix error in Customizer when using PHP version < 5.5
= 1.4 =
* Colors: Add back to top button color options
* Colors: Add h4-h5 color options
* Colors: Move button color options into own Buttons section
* Hooks: Show PHP execution message to admins only
* Menu Plus: Improve disabling of native mobile menu when slide-out is set
* Menu Plus: Fix sticky mobile menu when navigation is in sidebar
* Menu Plus: Fix invisible navigation when slide sticky is shown/hidden quickly
* Page Header: Complete code re-write
* Page Header: Turn Page Headers into a custom post type (CPT)
* Page Header: Can be applied per page, or globally (pages, posts, categories, CPTs etc..)
* Page Header: Template tags can be used in Page Header content (page title, author, date)
* Page Header: Turn bg color options in RGBA picker
* Page Header: New use bg color as image overlay option
* Page Header: Re-write parallax feature
* Page Header: Migrate Blog Page Header in Customizer into a CPT post on update
* Page Header: Add "Inner Container" width option.
* Page Header: Add menu background color (instead of forcing transparent)
* Page Header: Show content options all the time
* Page Header: Force full width page header if merge is set
* Page Header: Use set default color palettes in color pickers
* Page Header: New left/right padding option
* Sections: Make background color rgba color picker
* Sections: Add background color overlay options
* Sections: Use set default color palettes in color pickers
* Sections: Fix dropdown z-index bug introduced in WP 4.8.1
* Typography: Add H1-H3 line-height options
* Typography: Add H4-H5 typography options
* Typography: Add footer/copyright area typography options
* Typography: Add button typography options
* Typography: Rename Content Customizer section to Headings
* Typography: Add widget title separating space option
* Typography: Make fonts in Customizer search-able
* Typography: Allow Google Font variants to be added/removed
* WooCommerce: Fix columns issue on some pages
* WooCommerce: Fix mobile columns when using shortcode
* WooCommerce: Fix extra spacing in empty cart menu item
* WooCommerce: Show Cart text if no icon
* WooCommerce: Make cart menu item filterable
* WooCommerce: Fix sales badge height in IE11
= 1.3.1 =
* Hooks: Add notice to disable PHP execution if DISALLOW_FILE_EDIT is defined
* Menu Plus: Fix RTL spacing in slide-out menu
* Menu Plus: Fix bug where sticky nav was interfering with mobile header
* Menu Plus: Merge all sticky nav transitions into one script
* Menu Plus: Re-write fade and slide sticky navigation transitions
* Menu Plus: Add new option to hide sticky navigation while scrolling down
* WooCommerce: Add padding to terms on checkout
* WooCommerce: Make shop page options work when shop is set to category display
* WooCommerce: Style mark element
* WooCommerce: Remove border/padding from checkout fields
* WooCommerce: Remove color from my account arrows
* WooCommerce: Adjust ship to address padding
* WooCommerce: Fix ul elements when WC image is floating
* WooCommerce: Fix pagination clearing issue
* WooCommerce: Add pt_BR translation
* WooCommerce: Fix spacing issue with menu item cart icon and certain fonts
* Fix double forward slashes in some script calls inside Customizer
* Add WPML config file
= 1.3 =
* Backgrounds: Fix big with 100% auto sizing option
* Colors: Add WooCommerce add-on colors
* Import/Export: Add WooCommerce add-on
* Menu Plus: Improve Navigation Logo sizing
* Menu Plus: Re-write no transition sticky navigation
* Secondary Nav: Add padding to sides of top bar when merged
* Secondary Nav: Only load resources if the Secondary theme location is set
* Sections: Fix mix up of left/right content padding
* Spacing: New mobile menu item width/height options
* Spacing: New sticky menu item height option
* Spacing: New slide-out menu item height option
* Typography: New mobile menu item font size option
* WooCommerce: Introducing new WooCommerce add-on
* Move all Customizer controls and helper functions into globally accessible library
* Rebuilt range slider control to include responsive icons which display responsive controls
* Rebuilt typography control reducing number of controls from 50 to 10 (performance)
* Updated the automatic updater function
* Add filter to enable beta updates: generate_premium_beta_tester
== Changelog archives ==
* See more at https://generatepress.com/category/development/

View File

@ -1,12 +1,18 @@
<?php
/**
* This file handles most of our Colors functionality.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please
exit; // No direct access, please.
}
// Add necessary files
require_once trailingslashit( dirname(__FILE__) ) . 'secondary-nav-colors.php';
require_once trailingslashit( dirname(__FILE__) ) . 'woocommerce-colors.php';
require_once trailingslashit( dirname(__FILE__) ) . 'slideout-nav-colors.php';
// Add necessary files.
require_once trailingslashit( dirname( __FILE__ ) ) . 'secondary-nav-colors.php';
require_once trailingslashit( dirname( __FILE__ ) ) . 'woocommerce-colors.php';
require_once trailingslashit( dirname( __FILE__ ) ) . 'slideout-nav-colors.php';
if ( ! function_exists( 'generate_colors_customize_register' ) ) {
add_action( 'customize_register', 'generate_colors_customize_register' );
@ -14,38 +20,42 @@ if ( ! function_exists( 'generate_colors_customize_register' ) ) {
* Add our Customizer options.
*
* @since 0.1
* @param object $wp_customize The Customizer object.
*/
function generate_colors_customize_register( $wp_customize ) {
// Bail if we don't have our color defaults
// Bail if we don't have our color defaults.
if ( ! function_exists( 'generate_get_color_defaults' ) ) {
return;
}
// Add our controls
// Add our controls.
require_once GP_LIBRARY_DIRECTORY . 'customizer-helpers.php';
// Get our defaults
// Get our defaults.
$defaults = generate_get_color_defaults();
// Add control types so controls can be built using JS
// 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
// Get our palettes.
$palettes = generate_get_default_color_palettes();
// Add our Colors panel
// Add our Colors panel.
if ( class_exists( 'WP_Customize_Panel' ) ) {
$wp_customize->add_panel( 'generate_colors_panel', array(
'priority' => 30,
'theme_supports' => '',
'title' => __( 'Colors', 'gp-premium' ),
'description' => '',
) );
$wp_customize->add_panel(
'generate_colors_panel',
array(
'priority' => 30,
'theme_supports' => '',
'title' => __( 'Colors', 'gp-premium' ),
'description' => '',
)
);
}
$wp_customize->add_control(
@ -64,8 +74,8 @@ if ( ! function_exists( 'generate_colors_customize_register' ) ) {
)
);
// Add Top Bar Colors section
if ( isset( $defaults[ 'top_bar_background_color' ] ) && function_exists( 'generate_is_top_bar_active' ) ) {
// Add Top Bar Colors section.
if ( isset( $defaults['top_bar_background_color'] ) && function_exists( 'generate_is_top_bar_active' ) ) {
$wp_customize->add_section(
'generate_top_bar_colors',
array(
@ -101,7 +111,7 @@ if ( ! function_exists( 'generate_colors_customize_register' ) ) {
)
);
// Add color settings
// Add color settings.
$top_bar_colors = array();
$top_bar_colors[] = array(
'slug' => 'top_bar_text_color',
@ -122,13 +132,14 @@ if ( ! function_exists( 'generate_colors_customize_register' ) ) {
'priority' => 4,
);
foreach( $top_bar_colors as $color ) {
foreach ( $top_bar_colors as $color ) {
$wp_customize->add_setting(
'generate_settings[' . $color['slug'] . ']', array(
'generate_settings[' . $color['slug'] . ']',
array(
'default' => $color['default'],
'type' => 'option',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage'
'transport' => 'postMessage',
)
);
@ -142,14 +153,14 @@ if ( ! function_exists( 'generate_colors_customize_register' ) ) {
'settings' => 'generate_settings[' . $color['slug'] . ']',
'priority' => $color['priority'],
'palette' => $palettes,
'active_callback' => 'generate_is_top_bar_active'
'active_callback' => 'generate_is_top_bar_active',
)
)
);
}
}
// Add Header Colors section
// Add Header Colors section.
$wp_customize->add_section(
'header_color_section',
array(
@ -202,7 +213,7 @@ if ( ! function_exists( 'generate_colors_customize_register' ) ) {
)
);
// Add color settings
// Add color settings.
$header_colors = array();
$header_colors[] = array(
'slug' => 'header_text_color',
@ -235,13 +246,14 @@ if ( ! function_exists( 'generate_colors_customize_register' ) ) {
'priority' => 6,
);
foreach( $header_colors as $color ) {
foreach ( $header_colors as $color ) {
$wp_customize->add_setting(
'generate_settings[' . $color['slug'] . ']', array(
'generate_settings[' . $color['slug'] . ']',
array(
'default' => $color['default'],
'type' => 'option',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage'
'transport' => 'postMessage',
)
);
@ -260,7 +272,7 @@ if ( ! function_exists( 'generate_colors_customize_register' ) ) {
);
}
// Add Navigation section
// Add Navigation section.
$wp_customize->add_section(
'navigation_color_section',
array(
@ -293,11 +305,11 @@ if ( ! function_exists( 'generate_colors_customize_register' ) ) {
$wp_customize,
'generate_primary_navigation_parent_items',
array(
'section' => 'navigation_color_section',
'type' => 'generatepress-customizer-title',
'title' => __( 'Parent Items', 'gp-premium' ),
'section' => 'navigation_color_section',
'type' => 'generatepress-customizer-title',
'title' => __( 'Parent Items', 'gp-premium' ),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
'priority' => 1,
'priority' => 1,
)
)
);
@ -374,34 +386,35 @@ if ( ! function_exists( 'generate_colors_customize_register' ) ) {
)
);
// Add color settings
// Add color settings.
$navigation_colors = array();
$navigation_colors[] = array(
'slug'=>'navigation_text_color',
'slug' => 'navigation_text_color',
'default' => $defaults['navigation_text_color'],
'label' => __( 'Text', 'gp-premium' ),
'priority' => 2,
);
$navigation_colors[] = array(
'slug'=>'navigation_text_hover_color',
'slug' => 'navigation_text_hover_color',
'default' => $defaults['navigation_text_hover_color'],
'label' => __( 'Text Hover', 'gp-premium' ),
'priority' => 4,
);
$navigation_colors[] = array(
'slug'=>'navigation_text_current_color',
'slug' => 'navigation_text_current_color',
'default' => $defaults['navigation_text_current_color'],
'label' => __( 'Text Current', 'gp-premium' ),
'priority' => 6,
);
foreach( $navigation_colors as $color ) {
foreach ( $navigation_colors as $color ) {
$wp_customize->add_setting(
'generate_settings[' . $color['slug'] . ']', array(
'generate_settings[' . $color['slug'] . ']',
array(
'default' => $color['default'],
'type' => 'option',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage'
'transport' => 'postMessage',
)
);
@ -413,7 +426,7 @@ if ( ! function_exists( 'generate_colors_customize_register' ) ) {
'label' => $color['label'],
'section' => 'navigation_color_section',
'settings' => 'generate_settings[' . $color['slug'] . ']',
'priority' => $color['priority']
'priority' => $color['priority'],
)
)
);
@ -424,9 +437,9 @@ if ( ! function_exists( 'generate_colors_customize_register' ) ) {
$wp_customize,
'generate_primary_navigation_sub_menu_items',
array(
'section' => 'navigation_color_section',
'type' => 'generatepress-customizer-title',
'title' => __( 'Sub-Menu Items', 'gp-premium' ),
'section' => 'navigation_color_section',
'type' => 'generatepress-customizer-title',
'title' => __( 'Sub-Menu Items', 'gp-premium' ),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
'priority' => 7,
)
@ -505,29 +518,31 @@ if ( ! function_exists( 'generate_colors_customize_register' ) ) {
)
);
// Add color settings
// Add color settings.
$subnavigation_colors = array();
$subnavigation_colors[] = array(
'slug'=>'subnavigation_text_color',
'slug' => 'subnavigation_text_color',
'default' => $defaults['subnavigation_text_color'],
'label' => __( 'Text', 'gp-premium' ),
'priority' => 9,
);
$subnavigation_colors[] = array(
'slug'=>'subnavigation_text_hover_color',
'slug' => 'subnavigation_text_hover_color',
'default' => $defaults['subnavigation_text_hover_color'],
'label' => __( 'Text Hover', 'gp-premium' ),
'priority' => 11,
);
$subnavigation_colors[] = array(
'slug'=>'subnavigation_text_current_color',
'slug' => 'subnavigation_text_current_color',
'default' => $defaults['subnavigation_text_current_color'],
'label' => __( 'Text Current', 'gp-premium' ),
'priority' => 13,
);
foreach( $subnavigation_colors as $color ) {
foreach ( $subnavigation_colors as $color ) {
$wp_customize->add_setting(
'generate_settings[' . $color['slug'] . ']', array(
'generate_settings[' . $color['slug'] . ']',
array(
'default' => $color['default'],
'type' => 'option',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
@ -555,9 +570,9 @@ if ( ! function_exists( 'generate_colors_customize_register' ) ) {
$wp_customize,
'generate_primary_navigation_search',
array(
'section' => 'navigation_color_section',
'type' => 'generatepress-customizer-title',
'title' => __( 'Navigation Search', 'gp-premium' ),
'section' => 'navigation_color_section',
'type' => 'generatepress-customizer-title',
'title' => __( 'Navigation Search', 'gp-premium' ),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
'priority' => 15,
)
@ -589,11 +604,12 @@ if ( ! function_exists( 'generate_colors_customize_register' ) ) {
);
$wp_customize->add_setting(
'generate_settings[navigation_search_text_color]', array(
'generate_settings[navigation_search_text_color]',
array(
'default' => $defaults['navigation_search_text_color'],
'type' => 'option',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage'
'transport' => 'postMessage',
)
);
@ -660,7 +676,8 @@ if ( ! function_exists( 'generate_colors_customize_register' ) ) {
);
$wp_customize->add_setting(
'generate_settings[form_button_text_color]', array(
'generate_settings[form_button_text_color]',
array(
'default' => $defaults['form_button_text_color'],
'type' => 'option',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
@ -704,7 +721,8 @@ if ( ! function_exists( 'generate_colors_customize_register' ) ) {
);
$wp_customize->add_setting(
'generate_settings[form_button_text_color_hover]', array(
'generate_settings[form_button_text_color_hover]',
array(
'default' => $defaults['form_button_text_color_hover'],
'type' => 'option',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
@ -724,7 +742,7 @@ if ( ! function_exists( 'generate_colors_customize_register' ) ) {
)
);
// Add Content Colors section
// Add Content Colors section.
$wp_customize->add_section(
'content_color_section',
array(
@ -776,7 +794,7 @@ if ( ! function_exists( 'generate_colors_customize_register' ) ) {
)
);
// Add color settings
// Add color settings.
$content_colors = array();
$content_colors[] = array(
'slug' => 'content_text_color',
@ -869,9 +887,10 @@ if ( ! function_exists( 'generate_colors_customize_register' ) ) {
);
}
foreach( $content_colors as $color ) {
foreach ( $content_colors as $color ) {
$wp_customize->add_setting(
'generate_settings[' . $color['slug'] . ']', array(
'generate_settings[' . $color['slug'] . ']',
array(
'default' => $color['default'],
'type' => 'option',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
@ -893,7 +912,7 @@ if ( ! function_exists( 'generate_colors_customize_register' ) ) {
);
}
// Add Sidebar Widget colors
// Add Sidebar Widget colors.
$wp_customize->add_section(
'sidebar_widget_color_section',
array(
@ -945,7 +964,7 @@ if ( ! function_exists( 'generate_colors_customize_register' ) ) {
)
);
// Add color settings
// Add color settings.
$sidebar_widget_colors = array();
$sidebar_widget_colors[] = array(
'slug' => 'sidebar_widget_text_color',
@ -972,9 +991,10 @@ if ( ! function_exists( 'generate_colors_customize_register' ) ) {
'priority' => 5,
);
foreach( $sidebar_widget_colors as $color ) {
foreach ( $sidebar_widget_colors as $color ) {
$wp_customize->add_setting(
'generate_settings[' . $color['slug'] . ']', array(
'generate_settings[' . $color['slug'] . ']',
array(
'default' => $color['default'],
'type' => 'option',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
@ -996,7 +1016,7 @@ if ( ! function_exists( 'generate_colors_customize_register' ) ) {
);
}
// Add Form colors
// Add Form colors.
$wp_customize->add_section(
'form_color_section',
array(
@ -1102,7 +1122,7 @@ if ( ! function_exists( 'generate_colors_customize_register' ) ) {
)
);
// Add color settings
// Add color settings.
$form_colors = array();
$form_colors[] = array(
'slug' => 'form_text_color',
@ -1117,9 +1137,10 @@ if ( ! function_exists( 'generate_colors_customize_register' ) ) {
'priority' => 4,
);
foreach( $form_colors as $color ) {
foreach ( $form_colors as $color ) {
$wp_customize->add_setting(
'generate_settings[' . $color['slug'] . ']', array(
'generate_settings[' . $color['slug'] . ']',
array(
'default' => $color['default'],
'type' => 'option',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
@ -1141,7 +1162,7 @@ if ( ! function_exists( 'generate_colors_customize_register' ) ) {
);
}
// Add Footer colors
// Add Footer colors.
$wp_customize->add_section(
'footer_color_section',
array(
@ -1205,7 +1226,7 @@ if ( ! function_exists( 'generate_colors_customize_register' ) ) {
)
);
// Add color settings
// Add color settings.
$footer_widget_colors = array();
$footer_widget_colors[] = array(
'slug' => 'footer_widget_text_color',
@ -1228,9 +1249,10 @@ if ( ! function_exists( 'generate_colors_customize_register' ) ) {
'label' => __( 'Widget Title', 'gp-premium' ),
);
foreach( $footer_widget_colors as $color ) {
foreach ( $footer_widget_colors as $color ) {
$wp_customize->add_setting(
'generate_settings[' . $color['slug'] . ']', array(
'generate_settings[' . $color['slug'] . ']',
array(
'default' => $color['default'],
'type' => 'option',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
@ -1287,7 +1309,7 @@ if ( ! function_exists( 'generate_colors_customize_register' ) ) {
)
);
// Add color settings
// Add color settings.
$footer_colors = array();
$footer_colors[] = array(
'slug' => 'footer_text_color',
@ -1305,9 +1327,10 @@ if ( ! function_exists( 'generate_colors_customize_register' ) ) {
'label' => __( 'Link Hover', 'gp-premium' ),
);
foreach( $footer_colors as $color ) {
foreach ( $footer_colors as $color ) {
$wp_customize->add_setting(
'generate_settings[' . $color['slug'] . ']', array(
'generate_settings[' . $color['slug'] . ']',
array(
'default' => $color['default'],
'type' => 'option',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
@ -1343,7 +1366,8 @@ if ( ! function_exists( 'generate_colors_customize_register' ) ) {
);
$wp_customize->add_setting(
'generate_settings[back_to_top_background_color]', array(
'generate_settings[back_to_top_background_color]',
array(
'default' => $defaults['back_to_top_background_color'],
'type' => 'option',
'sanitize_callback' => 'generate_premium_sanitize_rgba',
@ -1365,7 +1389,8 @@ if ( ! function_exists( 'generate_colors_customize_register' ) ) {
);
$wp_customize->add_setting(
'generate_settings[back_to_top_text_color]', array(
'generate_settings[back_to_top_text_color]',
array(
'default' => $defaults['back_to_top_text_color'],
'type' => 'option',
'sanitize_callback' => 'generate_premium_sanitize_rgba',
@ -1386,7 +1411,8 @@ if ( ! function_exists( 'generate_colors_customize_register' ) ) {
);
$wp_customize->add_setting(
'generate_settings[back_to_top_background_color_hover]', array(
'generate_settings[back_to_top_background_color_hover]',
array(
'default' => $defaults['back_to_top_background_color_hover'],
'type' => 'option',
'sanitize_callback' => 'generate_premium_sanitize_rgba',
@ -1408,7 +1434,8 @@ if ( ! function_exists( 'generate_colors_customize_register' ) ) {
);
$wp_customize->add_setting(
'generate_settings[back_to_top_text_color_hover]', array(
'generate_settings[back_to_top_text_color_hover]',
array(
'default' => $defaults['back_to_top_text_color_hover'],
'type' => 'option',
'sanitize_callback' => 'generate_premium_sanitize_rgba',
@ -1436,16 +1463,17 @@ if ( ! function_exists( 'generate_get_color_setting' ) ) {
* Wrapper function to get our settings
*
* @since 1.3.42
* @param string $setting The setting to check.
*/
function generate_get_color_setting( $setting ) {
// Bail if we don't have our color defaults
// Bail if we don't have our color defaults.
if ( ! function_exists( 'generate_get_color_defaults' ) ) {
return;
}
if ( function_exists( 'generate_get_defaults' ) ) {
$defaults = array_merge( generate_get_defaults(), generate_get_color_defaults() );
$defaults = array_merge( generate_get_defaults(), generate_get_color_defaults() );
} else {
$defaults = generate_get_color_defaults();
}
@ -1462,10 +1490,12 @@ if ( ! function_exists( 'generate_get_color_setting' ) ) {
if ( ! function_exists( 'generate_colors_rgba_to_hex' ) ) {
/**
* Convert RGBA to hex if necessary
*
* @since 1.3.42
* @param string $rgba The string to convert to hex.
*/
function generate_colors_rgba_to_hex( $rgba ) {
// If it's not rgba, return it
// If it's not rgba, return it.
if ( false === strpos( $rgba, 'rgba' ) ) {
return $rgba;
}
@ -1489,7 +1519,7 @@ if ( ! function_exists( 'generate_get_default_color_palettes' ) ) {
'#F1C40F',
'#1e72bd',
'#1ABC9C',
'#3498DB'
'#3498DB',
);
return apply_filters( 'generate_default_color_palettes', $palettes );
@ -1505,16 +1535,16 @@ if ( ! function_exists( 'generate_enqueue_color_palettes' ) ) {
* @since 1.3.42
*/
function generate_enqueue_color_palettes() {
// Old versions of WP don't get nice things
// Old versions of WP don't get nice things.
if ( ! function_exists( 'wp_add_inline_script' ) ) {
return;
}
// Grab our palette array and turn it into JS
$palettes = json_encode( generate_get_default_color_palettes() );
// Grab our palette array and turn it into JS.
$palettes = wp_json_encode( generate_get_default_color_palettes() );
// Add our custom palettes
// json_encode takes care of escaping
// Add our custom palettes.
// json_encode takes care of escaping.
wp_add_inline_script( 'wp-color-picker', 'jQuery.wp.wpColorPicker.prototype.options.palettes = ' . $palettes . ';' );
}
}
@ -1528,27 +1558,27 @@ if ( ! function_exists( 'generate_colors_customizer_live_preview' ) ) {
*/
function generate_colors_customizer_live_preview() {
wp_enqueue_script(
'generate-colors-customizer',
trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/customizer.js',
array( 'jquery','customize-preview' ),
GENERATE_COLORS_VERSION,
true
'generate-colors-customizer',
trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/customizer.js',
array( 'jquery', 'customize-preview' ),
GENERATE_COLORS_VERSION,
true
);
wp_register_script(
'generate-wc-colors-customizer',
trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/wc-customizer.js',
array( 'jquery','customize-preview', 'generate-colors-customizer' ),
GENERATE_COLORS_VERSION,
true
'generate-wc-colors-customizer',
trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/wc-customizer.js',
array( 'jquery', 'customize-preview', 'generate-colors-customizer' ),
GENERATE_COLORS_VERSION,
true
);
wp_register_script(
'generate-menu-plus-colors-customizer',
trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/menu-plus-customizer.js',
array( 'jquery','customize-preview', 'generate-colors-customizer' ),
GENERATE_COLORS_VERSION,
true
'generate-menu-plus-colors-customizer',
trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/menu-plus-customizer.js',
array( 'jquery', 'customize-preview', 'generate-colors-customizer' ),
GENERATE_COLORS_VERSION,
true
);
}
}

View File

@ -129,7 +129,8 @@ generate_colors_live_update( 'navigation_text_color',
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 .mobile-bar-items a:focus,\
.main-navigation .menu-bar-items',
'color', '', 'link_color'
);
@ -143,7 +144,8 @@ generate_colors_live_update( 'navigation_text_hover_color',
.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 .main-nav ul li.sfHover > a,\
.main-navigation .menu-bar-item:hover a',
'color', '', 'link_color_hover'
);
@ -156,7 +158,8 @@ generate_colors_live_update( 'navigation_background_hover_color',
.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 .main-nav ul li.sfHover > a,\
.main-navigation .menu-bar-item:hover a',
'background-color', 'transparent'
);
@ -245,7 +248,9 @@ generate_colors_live_update( 'navigation_text_color',
button.secondary-menu-toggle:hover,\
button.secondary-menu-toggle:focus, \
.secondary-navigation .top-bar, \
.secondary-navigation .top-bar a',
.secondary-navigation .top-bar a,\
.secondary-menu-bar-items,\
.secondary-menu-bar-items .menu-bar-item > a',
'color', '', 'link_color', 'generate_secondary_nav_settings'
);
@ -290,7 +295,8 @@ generate_colors_live_update( 'navigation_search_text_color', '.navigation-search
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-navigation .main-nav ul li.sfHover > a,\
.secondary-menu-bar-items .menu-bar-item:hover > a',
'color', '', 'link_color_hover', 'generate_secondary_nav_settings'
);
@ -301,7 +307,8 @@ generate_colors_live_update( 'navigation_text_hover_color',
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-navigation .main-nav ul li.sfHover > a, \
.secondary-menu-bar-items .menu-bar-item:hover > a',
'background-color', 'transparent', '', 'generate_secondary_nav_settings'
);

View File

@ -1,6 +1,12 @@
<?php
/**
* This file handles the Customizer options for the Secondary Nav module.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please
exit; // No direct access, please.
}
if ( ! function_exists( 'generate_colors_secondary_nav_customizer' ) ) {
@ -15,36 +21,38 @@ if ( ! function_exists( 'generate_colors_secondary_nav_customizer' ) ) {
* 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
// 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
// Bail if we don't have our color defaults.
if ( ! function_exists( 'generate_secondary_nav_get_defaults' ) ) {
return;
}
// Add our controls
// Add our controls.
require_once GP_LIBRARY_DIRECTORY . 'customizer-helpers.php';
// Get our defaults
// Get our defaults.
$defaults = generate_secondary_nav_get_defaults();
// Add control types so controls can be built using JS
// 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
// Get our palettes.
$palettes = generate_get_default_color_palettes();
// Add Secondary Navigation section
// Add Secondary Navigation section.
$wp_customize->add_section(
'secondary_navigation_color_section',
array(
@ -78,17 +86,18 @@ if ( ! function_exists( 'generate_colors_secondary_nav_customizer' ) ) {
$wp_customize,
'generate_secondary_navigation_items',
array(
'section' => 'secondary_navigation_color_section',
'type' => 'generatepress-customizer-title',
'title' => __( 'Parent Items', 'gp-premium' ),
'section' => 'secondary_navigation_color_section',
'type' => 'generatepress-customizer-title',
'title' => __( 'Parent Items', 'gp-premium' ),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
)
)
);
// Background
// Background.
$wp_customize->add_setting(
'generate_secondary_nav_settings[navigation_background_color]', array(
'generate_secondary_nav_settings[navigation_background_color]',
array(
'default' => $defaults['navigation_background_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -110,9 +119,10 @@ if ( ! function_exists( 'generate_colors_secondary_nav_customizer' ) ) {
)
);
// Text
// Text.
$wp_customize->add_setting(
'generate_secondary_nav_settings[navigation_text_color]', array(
'generate_secondary_nav_settings[navigation_text_color]',
array(
'default' => $defaults['navigation_text_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -133,9 +143,10 @@ if ( ! function_exists( 'generate_colors_secondary_nav_customizer' ) ) {
)
);
// Background hover
// Background hover.
$wp_customize->add_setting(
'generate_secondary_nav_settings[navigation_background_hover_color]', array(
'generate_secondary_nav_settings[navigation_background_hover_color]',
array(
'default' => $defaults['navigation_background_hover_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -157,9 +168,10 @@ if ( ! function_exists( 'generate_colors_secondary_nav_customizer' ) ) {
)
);
// Text hover
// Text hover.
$wp_customize->add_setting(
'generate_secondary_nav_settings[navigation_text_hover_color]', array(
'generate_secondary_nav_settings[navigation_text_hover_color]',
array(
'default' => $defaults['navigation_text_hover_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -180,9 +192,10 @@ if ( ! function_exists( 'generate_colors_secondary_nav_customizer' ) ) {
)
);
// Background current
// Background current.
$wp_customize->add_setting(
'generate_secondary_nav_settings[navigation_background_current_color]', array(
'generate_secondary_nav_settings[navigation_background_current_color]',
array(
'default' => $defaults['navigation_background_current_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -204,9 +217,10 @@ if ( ! function_exists( 'generate_colors_secondary_nav_customizer' ) ) {
)
);
// Text current
// Text current.
$wp_customize->add_setting(
'generate_secondary_nav_settings[navigation_text_current_color]', array(
'generate_secondary_nav_settings[navigation_text_current_color]',
array(
'default' => $defaults['navigation_text_current_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -232,17 +246,18 @@ if ( ! function_exists( 'generate_colors_secondary_nav_customizer' ) ) {
$wp_customize,
'generate_secondary_navigation_sub_menu_items',
array(
'section' => 'secondary_navigation_color_section',
'type' => 'generatepress-customizer-title',
'title' => __( 'Sub-Menu Items', 'gp-premium' ),
'section' => 'secondary_navigation_color_section',
'type' => 'generatepress-customizer-title',
'title' => __( 'Sub-Menu Items', 'gp-premium' ),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
)
)
);
// Background
// Background.
$wp_customize->add_setting(
'generate_secondary_nav_settings[subnavigation_background_color]', array(
'generate_secondary_nav_settings[subnavigation_background_color]',
array(
'default' => $defaults['subnavigation_background_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -264,9 +279,10 @@ if ( ! function_exists( 'generate_colors_secondary_nav_customizer' ) ) {
)
);
// Text
// Text.
$wp_customize->add_setting(
'generate_secondary_nav_settings[subnavigation_text_color]', array(
'generate_secondary_nav_settings[subnavigation_text_color]',
array(
'default' => $defaults['subnavigation_text_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -287,9 +303,10 @@ if ( ! function_exists( 'generate_colors_secondary_nav_customizer' ) ) {
)
);
// Background hover
// Background hover.
$wp_customize->add_setting(
'generate_secondary_nav_settings[subnavigation_background_hover_color]', array(
'generate_secondary_nav_settings[subnavigation_background_hover_color]',
array(
'default' => $defaults['subnavigation_background_hover_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -311,9 +328,10 @@ if ( ! function_exists( 'generate_colors_secondary_nav_customizer' ) ) {
)
);
// Text hover
// Text hover.
$wp_customize->add_setting(
'generate_secondary_nav_settings[subnavigation_text_hover_color]', array(
'generate_secondary_nav_settings[subnavigation_text_hover_color]',
array(
'default' => $defaults['subnavigation_text_hover_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -334,9 +352,10 @@ if ( ! function_exists( 'generate_colors_secondary_nav_customizer' ) ) {
)
);
// Background current
// Background current.
$wp_customize->add_setting(
'generate_secondary_nav_settings[subnavigation_background_current_color]', array(
'generate_secondary_nav_settings[subnavigation_background_current_color]',
array(
'default' => $defaults['subnavigation_background_current_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -358,9 +377,10 @@ if ( ! function_exists( 'generate_colors_secondary_nav_customizer' ) ) {
)
);
// Text current
// Text current.
$wp_customize->add_setting(
'generate_secondary_nav_settings[subnavigation_text_current_color]', array(
'generate_secondary_nav_settings[subnavigation_text_current_color]',
array(
'default' => $defaults['subnavigation_text_current_color'],
'type' => 'option',
'capability' => 'edit_theme_options',

View File

@ -1,9 +1,18 @@
<?php
/**
* This file handles the Customizer options for the Off-Canvas Panel.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please
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' );
}
@ -13,34 +22,35 @@ add_action( 'customize_register', 'generate_slideout_navigation_color_controls',
* 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
// 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
// Bail if we don't have our color defaults.
if ( ! function_exists( 'generate_get_color_defaults' ) ) {
return;
}
// Add our controls
// Add our controls.
require_once GP_LIBRARY_DIRECTORY . 'customizer-helpers.php';
// Get our defaults
// Get our defaults.
$defaults = generate_get_color_defaults();
// Add control types so controls can be built using JS
// 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
// Get our palettes.
$palettes = generate_get_default_color_palettes();
// Add Secondary Navigation section
// Add Secondary Navigation section.
$wp_customize->add_section(
'slideout_color_section',
array(
@ -73,17 +83,18 @@ function generate_slideout_navigation_color_controls( $wp_customize ) {
$wp_customize,
'generate_slideout_navigation_items',
array(
'section' => 'slideout_color_section',
'type' => 'generatepress-customizer-title',
'title' => __( 'Parent Menu Items', 'gp-premium' ),
'section' => 'slideout_color_section',
'type' => 'generatepress-customizer-title',
'title' => __( 'Parent Menu Items', 'gp-premium' ),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
)
)
);
// Background
// Background.
$wp_customize->add_setting(
'generate_settings[slideout_background_color]', array(
'generate_settings[slideout_background_color]',
array(
'default' => $defaults['slideout_background_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -105,9 +116,10 @@ function generate_slideout_navigation_color_controls( $wp_customize ) {
)
);
// Text
// Text.
$wp_customize->add_setting(
'generate_settings[slideout_text_color]', array(
'generate_settings[slideout_text_color]',
array(
'default' => $defaults['slideout_text_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -128,9 +140,10 @@ function generate_slideout_navigation_color_controls( $wp_customize ) {
)
);
// Background hover
// Background hover.
$wp_customize->add_setting(
'generate_settings[slideout_background_hover_color]', array(
'generate_settings[slideout_background_hover_color]',
array(
'default' => $defaults['slideout_background_hover_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -152,9 +165,10 @@ function generate_slideout_navigation_color_controls( $wp_customize ) {
)
);
// Text hover
// Text hover.
$wp_customize->add_setting(
'generate_settings[slideout_text_hover_color]', array(
'generate_settings[slideout_text_hover_color]',
array(
'default' => $defaults['slideout_text_hover_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -175,9 +189,10 @@ function generate_slideout_navigation_color_controls( $wp_customize ) {
)
);
// Background current
// Background current.
$wp_customize->add_setting(
'generate_settings[slideout_background_current_color]', array(
'generate_settings[slideout_background_current_color]',
array(
'default' => $defaults['slideout_background_current_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -199,9 +214,10 @@ function generate_slideout_navigation_color_controls( $wp_customize ) {
)
);
// Text current
// Text current.
$wp_customize->add_setting(
'generate_settings[slideout_text_current_color]', array(
'generate_settings[slideout_text_current_color]',
array(
'default' => $defaults['slideout_text_current_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -227,17 +243,18 @@ function generate_slideout_navigation_color_controls( $wp_customize ) {
$wp_customize,
'generate_slideout_navigation_sub_menu_items',
array(
'section' => 'slideout_color_section',
'type' => 'generatepress-customizer-title',
'title' => __( 'Sub-Menu Items', 'gp-premium' ),
'section' => 'slideout_color_section',
'type' => 'generatepress-customizer-title',
'title' => __( 'Sub-Menu Items', 'gp-premium' ),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
)
)
);
// Background
// Background.
$wp_customize->add_setting(
'generate_settings[slideout_submenu_background_color]', array(
'generate_settings[slideout_submenu_background_color]',
array(
'default' => $defaults['slideout_submenu_background_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -259,9 +276,10 @@ function generate_slideout_navigation_color_controls( $wp_customize ) {
)
);
// Text
// Text.
$wp_customize->add_setting(
'generate_settings[slideout_submenu_text_color]', array(
'generate_settings[slideout_submenu_text_color]',
array(
'default' => $defaults['slideout_submenu_text_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -282,9 +300,10 @@ function generate_slideout_navigation_color_controls( $wp_customize ) {
)
);
// Background hover
// Background hover.
$wp_customize->add_setting(
'generate_settings[slideout_submenu_background_hover_color]', array(
'generate_settings[slideout_submenu_background_hover_color]',
array(
'default' => $defaults['slideout_submenu_background_hover_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -306,9 +325,10 @@ function generate_slideout_navigation_color_controls( $wp_customize ) {
)
);
// Text hover
// Text hover.
$wp_customize->add_setting(
'generate_settings[slideout_submenu_text_hover_color]', array(
'generate_settings[slideout_submenu_text_hover_color]',
array(
'default' => $defaults['slideout_submenu_text_hover_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -329,9 +349,10 @@ function generate_slideout_navigation_color_controls( $wp_customize ) {
)
);
// Background current
// Background current.
$wp_customize->add_setting(
'generate_settings[slideout_submenu_background_current_color]', array(
'generate_settings[slideout_submenu_background_current_color]',
array(
'default' => $defaults['slideout_submenu_background_current_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -353,9 +374,10 @@ function generate_slideout_navigation_color_controls( $wp_customize ) {
)
);
// Text current
// Text current.
$wp_customize->add_setting(
'generate_settings[slideout_submenu_text_current_color]', array(
'generate_settings[slideout_submenu_text_current_color]',
array(
'default' => $defaults['slideout_submenu_text_current_color'],
'type' => 'option',
'capability' => 'edit_theme_options',

View File

@ -1,16 +1,23 @@
<?php
// No direct access, please
/**
* This file handles the Customizer options for the WooCommerce module.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
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
// Bail if WooCommerce isn't activated.
if ( ! $wp_customize->get_section( 'generate_woocommerce_colors' ) ) {
return;
}
@ -19,13 +26,13 @@ if ( ! function_exists( 'generate_colors_wc_customizer' ) ) {
return;
}
// Add our controls
// Add our controls.
require_once GP_LIBRARY_DIRECTORY . 'customizer-helpers.php';
// Get our defaults
// Get our defaults.
$defaults = generate_get_color_defaults();
// Add control types so controls can be built using JS
// 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' );
@ -33,7 +40,7 @@ if ( ! function_exists( 'generate_colors_wc_customizer' ) ) {
$wp_customize->register_control_type( 'GeneratePress_Section_Shortcut_Control' );
}
// Get our palettes
// Get our palettes.
$palettes = generate_get_default_color_palettes();
$wp_customize->add_control(
@ -61,7 +68,7 @@ if ( ! function_exists( 'generate_colors_wc_customizer' ) ) {
'section' => 'generate_woocommerce_colors',
'type' => 'generatepress-customizer-title',
'title' => __( 'Buttons', 'gp-premium' ),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname'
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
)
)
);
@ -71,10 +78,10 @@ if ( ! function_exists( 'generate_colors_wc_customizer' ) ) {
$wp_customize,
'generate_woocommerce_primary_button_message',
array(
'section' => 'generate_woocommerce_colors',
'label' => __( 'Primary Button Colors','generate-woocommerce' ),
'description' => __( 'Primary button colors can be set <a href="#">here</a>.','generate-woocommerce' ),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname'
'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',
)
)
);
@ -128,7 +135,8 @@ if ( ! function_exists( 'generate_colors_wc_customizer' ) ) {
);
$wp_customize->add_setting(
'generate_settings[wc_alt_button_text]', array(
'generate_settings[wc_alt_button_text]',
array(
'default' => $defaults['wc_alt_button_text'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -149,9 +157,9 @@ if ( ! function_exists( 'generate_colors_wc_customizer' ) ) {
)
);
$wp_customize->add_setting(
'generate_settings[wc_alt_button_text_hover]', array(
'generate_settings[wc_alt_button_text_hover]',
array(
'default' => $defaults['wc_alt_button_text_hover'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -180,13 +188,14 @@ if ( ! function_exists( 'generate_colors_wc_customizer' ) ) {
'section' => 'generate_woocommerce_colors',
'type' => 'generatepress-customizer-title',
'title' => __( 'Products', 'gp-premium' ),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname'
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
)
)
);
$wp_customize->add_setting(
'generate_settings[wc_product_title_color]', array(
'generate_settings[wc_product_title_color]',
array(
'default' => $defaults['wc_product_title_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -208,7 +217,8 @@ if ( ! function_exists( 'generate_colors_wc_customizer' ) ) {
);
$wp_customize->add_setting(
'generate_settings[wc_product_title_color_hover]', array(
'generate_settings[wc_product_title_color_hover]',
array(
'default' => $defaults['wc_product_title_color_hover'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -278,7 +288,8 @@ if ( ! function_exists( 'generate_colors_wc_customizer' ) ) {
);
$wp_customize->add_setting(
'generate_settings[wc_sale_sticker_text]', array(
'generate_settings[wc_sale_sticker_text]',
array(
'default' => $defaults['wc_sale_sticker_text'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -300,7 +311,8 @@ if ( ! function_exists( 'generate_colors_wc_customizer' ) ) {
);
$wp_customize->add_setting(
'generate_settings[wc_price_color]', array(
'generate_settings[wc_price_color]',
array(
'default' => $defaults['wc_price_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -329,7 +341,7 @@ if ( ! function_exists( 'generate_colors_wc_customizer' ) ) {
'section' => 'generate_woocommerce_colors',
'type' => 'generatepress-customizer-title',
'title' => __( 'Sticky Panel Cart', 'gp-premium' ),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname'
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
)
)
);
@ -359,7 +371,8 @@ if ( ! function_exists( 'generate_colors_wc_customizer' ) ) {
);
$wp_customize->add_setting(
'generate_settings[wc_panel_cart_text_color]', array(
'generate_settings[wc_panel_cart_text_color]',
array(
'default' => $defaults['wc_panel_cart_text_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -381,7 +394,8 @@ if ( ! function_exists( 'generate_colors_wc_customizer' ) ) {
);
$wp_customize->add_setting(
'generate_settings[wc_panel_cart_button_background]', array(
'generate_settings[wc_panel_cart_button_background]',
array(
'default' => $defaults['wc_panel_cart_button_background'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -403,7 +417,8 @@ if ( ! function_exists( 'generate_colors_wc_customizer' ) ) {
);
$wp_customize->add_setting(
'generate_settings[wc_panel_cart_button_background_hover]', array(
'generate_settings[wc_panel_cart_button_background_hover]',
array(
'default' => $defaults['wc_panel_cart_button_background_hover'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -425,7 +440,8 @@ if ( ! function_exists( 'generate_colors_wc_customizer' ) ) {
);
$wp_customize->add_setting(
'generate_settings[wc_panel_cart_button_text]', array(
'generate_settings[wc_panel_cart_button_text]',
array(
'default' => $defaults['wc_panel_cart_button_text'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -447,7 +463,8 @@ if ( ! function_exists( 'generate_colors_wc_customizer' ) ) {
);
$wp_customize->add_setting(
'generate_settings[wc_panel_cart_button_text_hover]', array(
'generate_settings[wc_panel_cart_button_text_hover]',
array(
'default' => $defaults['wc_panel_cart_button_text_hover'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -476,7 +493,7 @@ if ( ! function_exists( 'generate_colors_wc_customizer' ) ) {
'section' => 'generate_woocommerce_colors',
'type' => 'generatepress-customizer-title',
'title' => __( 'Menu Mini Cart', 'gp-premium' ),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname'
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
)
)
);
@ -506,7 +523,8 @@ if ( ! function_exists( 'generate_colors_wc_customizer' ) ) {
);
$wp_customize->add_setting(
'generate_settings[wc_mini_cart_text_color]', array(
'generate_settings[wc_mini_cart_text_color]',
array(
'default' => $defaults['wc_mini_cart_text_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -528,7 +546,8 @@ if ( ! function_exists( 'generate_colors_wc_customizer' ) ) {
);
$wp_customize->add_setting(
'generate_settings[wc_mini_cart_button_background]', array(
'generate_settings[wc_mini_cart_button_background]',
array(
'default' => $defaults['wc_mini_cart_button_background'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -550,7 +569,8 @@ if ( ! function_exists( 'generate_colors_wc_customizer' ) ) {
);
$wp_customize->add_setting(
'generate_settings[wc_mini_cart_button_background_hover]', array(
'generate_settings[wc_mini_cart_button_background_hover]',
array(
'default' => $defaults['wc_mini_cart_button_background_hover'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -572,7 +592,8 @@ if ( ! function_exists( 'generate_colors_wc_customizer' ) ) {
);
$wp_customize->add_setting(
'generate_settings[wc_mini_cart_button_text]', array(
'generate_settings[wc_mini_cart_button_text]',
array(
'default' => $defaults['wc_mini_cart_button_text'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -594,7 +615,8 @@ if ( ! function_exists( 'generate_colors_wc_customizer' ) ) {
);
$wp_customize->add_setting(
'generate_settings[wc_mini_cart_button_text_hover]', array(
'generate_settings[wc_mini_cart_button_text_hover]',
array(
'default' => $defaults['wc_mini_cart_button_text_hover'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -623,13 +645,14 @@ if ( ! function_exists( 'generate_colors_wc_customizer' ) ) {
'section' => 'generate_woocommerce_colors',
'type' => 'generatepress-customizer-title',
'title' => __( 'Price Slider Widget', 'gp-premium' ),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname'
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
)
)
);
$wp_customize->add_setting(
'generate_settings[wc_price_slider_background_color]', array(
'generate_settings[wc_price_slider_background_color]',
array(
'default' => $defaults['wc_price_slider_background_color'],
'type' => 'option',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
@ -650,7 +673,8 @@ if ( ! function_exists( 'generate_colors_wc_customizer' ) ) {
);
$wp_customize->add_setting(
'generate_settings[wc_price_slider_bar_color]', array(
'generate_settings[wc_price_slider_bar_color]',
array(
'default' => $defaults['wc_price_slider_bar_color'],
'type' => 'option',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
@ -678,13 +702,14 @@ if ( ! function_exists( 'generate_colors_wc_customizer' ) ) {
'section' => 'generate_woocommerce_colors',
'type' => 'generatepress-customizer-title',
'title' => __( 'Product Tabs', 'gp-premium' ),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname'
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
)
)
);
$wp_customize->add_setting(
'generate_settings[wc_product_tab]', array(
'generate_settings[wc_product_tab]',
array(
'default' => $defaults['wc_product_tab'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -706,7 +731,8 @@ if ( ! function_exists( 'generate_colors_wc_customizer' ) ) {
);
$wp_customize->add_setting(
'generate_settings[wc_product_tab_highlight]', array(
'generate_settings[wc_product_tab_highlight]',
array(
'default' => $defaults['wc_product_tab_highlight'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -735,7 +761,7 @@ if ( ! function_exists( 'generate_colors_wc_customizer' ) ) {
'section' => 'generate_woocommerce_colors',
'type' => 'generatepress-customizer-title',
'title' => __( 'Messages', 'gp-premium' ),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname'
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
)
)
);
@ -765,7 +791,8 @@ if ( ! function_exists( 'generate_colors_wc_customizer' ) ) {
);
$wp_customize->add_setting(
'generate_settings[wc_success_message_text]', array(
'generate_settings[wc_success_message_text]',
array(
'default' => $defaults['wc_success_message_text'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -811,7 +838,8 @@ if ( ! function_exists( 'generate_colors_wc_customizer' ) ) {
);
$wp_customize->add_setting(
'generate_settings[wc_info_message_text]', array(
'generate_settings[wc_info_message_text]',
array(
'default' => $defaults['wc_info_message_text'],
'type' => 'option',
'capability' => 'edit_theme_options',
@ -857,7 +885,8 @@ if ( ! function_exists( 'generate_colors_wc_customizer' ) ) {
);
$wp_customize->add_setting(
'generate_settings[wc_error_message_text]', array(
'generate_settings[wc_error_message_text]',
array(
'default' => $defaults['wc_error_message_text'],
'type' => 'option',
'capability' => 'edit_theme_options',

View File

@ -1,19 +1,20 @@
<?php
/*
Addon Name: Generate Colors
Author: Thomas Usborne
Author URI: http://edge22.com
*/
/**
* The Colors module.
*
* @since 1.1.0
*
* @package GP Premium
*/
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
exit; // No direct access, please.
}
// Define the version
// 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
// Include functions identical between standalone addon and GP Premium.
require plugin_dir_path( __FILE__ ) . 'functions/functions.php';

View File

@ -1,24 +1,30 @@
<?php
// No direct access, please
/**
* This file handles the Copyright functionality.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
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
* 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
// Get our custom control.
require_once GP_LIBRARY_DIRECTORY . 'customizer-helpers.php';
// Register our custom control
if ( method_exists( $wp_customize,'register_control_type' ) ) {
// Register our custom control.
if ( method_exists( $wp_customize, 'register_control_type' ) ) {
$wp_customize->register_control_type( 'GeneratePress_Copyright_Customize_Control' );
}
// Copyright
$wp_customize->add_setting(
'generate_copyright',
array(
@ -31,23 +37,27 @@ if ( ! function_exists( 'generate_copyright_customize_register' ) ) {
$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,
) )
$wp_customize,
'generate_copyright',
array(
'label' => __( 'Copyright', 'gp-premium' ),
'section' => 'generate_layout_footer',
'settings' => 'generate_copyright',
'priority' => 500,
)
)
);
// Initiate selective refresh
// 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',
) );
$wp_customize->selective_refresh->add_partial(
'generate_copyright',
array(
'selector' => '.copyright-bar',
'settings' => array( 'generate_copyright' ),
'render_callback' => 'generate_copyright_selective_refresh',
)
);
}
}
}
@ -59,12 +69,12 @@ if ( ! function_exists( 'generate_copyright_selective_refresh' ) ) {
function generate_copyright_selective_refresh() {
$options = array(
'%current_year%',
'%copy%'
'%copy%',
);
$replace = array(
date('Y'),
'&copy;'
date( 'Y' ), // phpcs:ignore -- prefer date().
'&copy;',
);
$new_copyright = get_theme_mod( 'generate_copyright' );
@ -77,20 +87,21 @@ if ( ! function_exists( 'generate_copyright_selective_refresh' ) ) {
if ( ! function_exists( 'generate_copyright_remove_default' ) ) {
add_action( 'wp', 'generate_copyright_remove_default' );
/**
* Remove the default copyright
* 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
// 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' );
remove_action( 'generate_copyright_line', 'generate_add_login_attribution' );
}
}
}
@ -98,25 +109,26 @@ if ( ! function_exists( 'generate_copyright_remove_default' ) ) {
if ( ! function_exists( 'generate_copyright_add_custom' ) ) {
add_action( 'generate_credits', 'generate_copyright_add_custom' );
/**
* Add the custom copyright
* 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
// 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%'
'%copy%',
);
$replace = array(
date('Y'),
'&copy;'
date( 'Y' ), // phpcs:ignore -- prefer date().
'&copy;',
);
$new_copyright = get_theme_mod( 'generate_copyright' );
@ -134,21 +146,22 @@ if ( ! function_exists( '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
// 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%'
'%copy%',
);
$replace = array(
date('Y'),
'&copy;'
date( 'Y' ), // phpcs:ignore -- prefer date().
'&copy;',
);
$new_copyright = get_theme_mod( 'generate_copyright' );
@ -170,11 +183,11 @@ if ( ! function_exists( 'generate_copyright_customizer_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
'generate-copyright-customizer',
plugin_dir_url( __FILE__ ) . 'js/customizer.js',
array( 'jquery', 'customize-preview' ),
GENERATE_COPYRIGHT_VERSION,
true
);
}
}
@ -202,7 +215,7 @@ if ( ! function_exists( 'generate_update_copyright' ) ) {
// 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
// Got our custom logo? Time to delete the old value.
if ( get_theme_mod( 'generate_copyright' ) ) {
delete_option( 'gen_custom_copyright' );
}

View File

@ -1,19 +1,20 @@
<?php
/*
Addon Name: Generate Copyright
Author: Thomas Usborne
Author URI: http://edge22.com
*/
/**
* The Copyright module.
*
* @since 1.0.0
*
* @package GP Premium
*/
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
exit; // No direct access, please.
}
// Define the version
// Define the version.
if ( ! defined( 'GENERATE_COPYRIGHT_VERSION' ) ) {
define( 'GENERATE_COPYRIGHT_VERSION', GP_PREMIUM_VERSION );
}
// Include functions identical between standalone addon and GP Premium
// Include functions identical between standalone addon and GP Premium.
require plugin_dir_path( __FILE__ ) . 'functions/functions.php';

View File

@ -1,25 +1,31 @@
<?php
// No direct access, please
/**
* This file handles the Disable Elements functionality.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
exit; // No direct access, please.
}
define( 'GENERATE_DE_LAYOUT_META_BOX', true );
if ( ! function_exists( 'generate_disable_elements' ) ) {
/**
* Remove the default 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
// Don't run the function unless we're on a page it applies to.
if ( ! is_singular() ) {
return;
}
global $post;
// Prevent PHP notices
// 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 );
@ -47,7 +53,13 @@ if ( ! function_exists( 'generate_disable_elements' ) ) {
$return .= '.generate-page-header, .page-header-image, .page-header-image-single {display:none}';
}
if ( ( ! empty( $disable_headline ) && false !== $disable_headline ) && ! is_single() ) {
$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}';
}
@ -59,7 +71,7 @@ if ( ! function_exists( 'generate_disable_elements' ) ) {
}
}
if ( ! function_exists('generate_de_scripts') ) {
if ( ! function_exists( 'generate_de_scripts' ) ) {
add_action( 'wp_enqueue_scripts', 'generate_de_scripts', 50 );
/**
* Enqueue scripts and styles
@ -69,7 +81,7 @@ if ( ! function_exists('generate_de_scripts') ) {
}
}
if ( ! function_exists('generate_add_de_meta_box') ) {
if ( ! function_exists( 'generate_add_de_meta_box' ) ) {
add_action( 'add_meta_boxes', 'generate_add_de_meta_box', 50 );
/**
* Generate the layout metabox.
@ -77,10 +89,10 @@ if ( ! function_exists('generate_add_de_meta_box') ) {
* @since 0.1
*/
function generate_add_de_meta_box() {
// Set user role - make filterable
// Set user role - make filterable.
$allowed = apply_filters( 'generate_metabox_capability', 'edit_theme_options' );
// If not an administrator, don't show the metabox
// If not an administrator, don't show the metabox.
if ( ! current_user_can( $allowed ) ) {
return;
}
@ -91,7 +103,7 @@ if ( ! function_exists('generate_add_de_meta_box') ) {
$args = array( 'public' => true );
$post_types = get_post_types( $args );
foreach ($post_types as $type) {
foreach ( $post_types as $type ) {
if ( 'attachment' !== $type ) {
add_meta_box(
'generate_de_meta_box',
@ -106,13 +118,15 @@ if ( ! function_exists('generate_add_de_meta_box') ) {
}
}
if ( ! function_exists('generate_show_de_meta_box') ) {
if ( ! function_exists( 'generate_show_de_meta_box' ) ) {
/**
* Outputs the content of the metabox
* 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 );
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] : '';
@ -120,59 +134,61 @@ if ( ! function_exists('generate_show_de_meta_box') ) {
$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>
<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' );?>">
<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' );?>
<?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' );?>">
<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' );?>
<?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' );?>">
<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' );?>
<?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' );?>">
<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' );?>
<?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 / Page Header', 'gp-premium' );?>">
<label for="meta-generate-disable-post-image" style="display:block;margin-bottom:3px;" title="<?php _e( 'Featured Image / Page Header', '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 / Page Header', 'gp-premium' );?>
<?php _e( 'Featured Image / Page Header', 'gp-premium' ); ?>
</label>
<label for="meta-generate-disable-headline" style="display:block;margin-bottom:3px;" title="<?php _e( 'Content Title', 'gp-premium' );?>">
<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' );?>
<?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' );?>">
<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' );?>
<?php _e( 'Footer', 'gp-premium' ); ?>
</label>
</div>
</p>
<?php
<?php
}
}
if ( ! function_exists('generate_save_de_meta') ) {
if ( ! function_exists( 'generate_save_de_meta' ) ) {
add_action( 'save_post', 'generate_save_de_meta' );
/**
* Save our options
* Save our options.
*
* @param int $post_id The post ID.
*/
function generate_save_de_meta( $post_id ) {
@ -180,17 +196,17 @@ if ( ! function_exists('generate_save_de_meta') ) {
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;
// 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;
}
// 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
// Check that the logged in user has permission to edit this post.
if ( ! current_user_can( 'edit_post', $post_id ) ) {
return $post_id;
}
@ -202,7 +218,7 @@ if ( ! function_exists('generate_save_de_meta') ) {
'_generate-disable-secondary-nav',
'_generate-disable-headline',
'_generate-disable-footer',
'_generate-disable-post-image'
'_generate-disable-post-image',
);
foreach ( $options as $key ) {
@ -219,52 +235,62 @@ if ( ! function_exists('generate_save_de_meta') ) {
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
// Don't run the function unless we're on a page it applies to.
if ( ! is_singular() ) {
return;
}
// Get the current post
// Get the current post.
global $post;
// Grab our values
// 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
// 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_before_header', 'generate_top_bar', 5 );
remove_action( 'generate_inside_secondary_navigation', 'generate_secondary_nav_top_bar_widget', 5 );
}
// Remove the header
// Remove the header.
if ( ! empty( $disable_header ) && false !== $disable_header && function_exists( 'generate_construct_header' ) ) {
remove_action( 'generate_header','generate_construct_header' );
remove_action( 'generate_header', 'generate_construct_header' );
}
// Remove the navigation
// 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_navigation_location', '__return_false', 20 );
}
// Remove the title
// Remove the title.
if ( ! empty( $disable_headline ) && false !== $disable_headline && function_exists( 'generate_show_title' ) ) {
add_filter( 'generate_show_title','__return_false' );
add_filter( 'generate_show_title', '__return_false' );
}
// Remove the footer
// 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 );
remove_action( 'generate_footer', 'generate_construct_footer_widgets', 5 );
}
if ( function_exists( 'generate_construct_footer' ) ) {
remove_action( 'generate_footer','generate_construct_footer' );
remove_action( 'generate_footer', 'generate_construct_footer' );
}
}
}
@ -275,9 +301,11 @@ add_action( 'generate_layout_disable_elements_section', 'generate_premium_disabl
* 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] : '';
@ -287,42 +315,60 @@ function generate_premium_disable_elements_options( $stored_meta ) {
?>
<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' );?>">
<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' );?>
<?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' );?>">
<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' );?>
<?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' );?>">
<?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' );?>
<?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' );?>">
<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' );?>
<?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 / Page Header', 'gp-premium' );?>">
<label for="meta-generate-disable-post-image" style="display:block;margin-bottom:3px;" title="<?php _e( 'Featured Image / Page Header', '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 / Page Header', 'gp-premium' );?>
<?php _e( 'Featured Image / Page Header', 'gp-premium' ); ?>
</label>
<label for="meta-generate-disable-headline" style="display:block;margin-bottom:3px;" title="<?php _e( 'Content Title', 'gp-premium' );?>">
<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' );?>
<?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' );?>">
<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' );?>
<?php _e( 'Footer', 'gp-premium' ); ?>
</label>
</div>
<?php
@ -333,16 +379,18 @@ add_action( 'generate_layout_meta_box_save', 'generate_premium_save_disable_elem
* 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'
'_generate-disable-post-image',
);
foreach ( $options as $key ) {

View File

@ -1,19 +1,20 @@
<?php
/*
Addon Name: Generate Disable Elements
Author: Thomas Usborne
Author URI: http://edge22.com
*/
/**
* The Disable Elements module.
*
* @since 1.0.0
*
* @package GP Premium
*/
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
exit; // No direct access, please.
}
// Define the version
// Define the version.
if ( ! defined( 'GENERATE_DE_VERSION' ) ) {
define( 'GENERATE_DE_VERSION', GP_PREMIUM_VERSION );
}
// Include functions identical between standalone addon and GP Premium
// Include functions identical between standalone addon and GP Premium.
require plugin_dir_path( __FILE__ ) . 'functions/functions.php';

View File

@ -11,10 +11,6 @@ button[data-balloon] {
-khtml-opacity: 0;
opacity: 0;
pointer-events: none;
-webkit-transition: all 0.18s ease-out 0.18s;
-moz-transition: all 0.18s ease-out 0.18s;
-ms-transition: all 0.18s ease-out 0.18s;
-o-transition: all 0.18s ease-out 0.18s;
transition: all 0.18s ease-out 0.18s;
font-weight: normal !important;
font-style: normal !important;
@ -39,10 +35,6 @@ button[data-balloon] {
-khtml-opacity: 0;
opacity: 0;
pointer-events: none;
-webkit-transition: all 0.18s ease-out 0.18s;
-moz-transition: all 0.18s ease-out 0.18s;
-ms-transition: all 0.18s ease-out 0.18s;
-o-transition: all 0.18s ease-out 0.18s;
transition: all 0.18s ease-out 0.18s;
content: '';
position: absolute;
@ -59,120 +51,59 @@ button[data-balloon] {
[data-balloon][data-balloon-break]:after {
white-space: pre; }
[data-balloon][data-balloon-blunt]:before, [data-balloon][data-balloon-blunt]:after {
-webkit-transition: none;
-moz-transition: none;
-ms-transition: none;
-o-transition: none;
transition: none; }
[data-balloon][data-balloon-pos="up"]:after {
bottom: 100%;
left: 50%;
margin-bottom: 11px;
-webkit-transform: translate(-50%, 10px);
-moz-transform: translate(-50%, 10px);
-ms-transform: translate(-50%, 10px);
transform: translate(-50%, 10px);
-webkit-transform-origin: top;
-moz-transform-origin: top;
-ms-transform-origin: top;
transform-origin: top; }
[data-balloon][data-balloon-pos="up"]:before {
bottom: 100%;
left: 50%;
margin-bottom: 5px;
-webkit-transform: translate(-50%, 10px);
-moz-transform: translate(-50%, 10px);
-ms-transform: translate(-50%, 10px);
transform: translate(-50%, 10px);
-webkit-transform-origin: top;
-moz-transform-origin: top;
-ms-transform-origin: top;
transform-origin: top; }
[data-balloon][data-balloon-pos="up"]:hover:after, [data-balloon][data-balloon-pos="up"][data-balloon-visible]:after {
-webkit-transform: translate(-50%, 0);
-moz-transform: translate(-50%, 0);
-ms-transform: translate(-50%, 0);
transform: translate(-50%, 0); }
[data-balloon][data-balloon-pos="up"]:hover:before, [data-balloon][data-balloon-pos="up"][data-balloon-visible]:before {
-webkit-transform: translate(-50%, 0);
-moz-transform: translate(-50%, 0);
-ms-transform: translate(-50%, 0);
transform: translate(-50%, 0); }
[data-balloon][data-balloon-pos="up-left"]:after {
bottom: 100%;
left: 0;
margin-bottom: 11px;
-webkit-transform: translate(0, 10px);
-moz-transform: translate(0, 10px);
-ms-transform: translate(0, 10px);
transform: translate(0, 10px);
-webkit-transform-origin: top;
-moz-transform-origin: top;
-ms-transform-origin: top;
transform-origin: top; }
[data-balloon][data-balloon-pos="up-left"]:before {
bottom: 100%;
left: 5px;
margin-bottom: 5px;
-webkit-transform: translate(0, 10px);
-moz-transform: translate(0, 10px);
-ms-transform: translate(0, 10px);
transform: translate(0, 10px);
-webkit-transform-origin: top;
-moz-transform-origin: top;
-ms-transform-origin: top;
transform-origin: top; }
[data-balloon][data-balloon-pos="up-left"]:hover:after, [data-balloon][data-balloon-pos="up-left"][data-balloon-visible]:after {
-webkit-transform: translate(0, 0);
-moz-transform: translate(0, 0);
-ms-transform: translate(0, 0);
transform: translate(0, 0); }
[data-balloon][data-balloon-pos="up-left"]:hover:before, [data-balloon][data-balloon-pos="up-left"][data-balloon-visible]:before {
-webkit-transform: translate(0, 0);
-moz-transform: translate(0, 0);
-ms-transform: translate(0, 0);
transform: translate(0, 0); }
[data-balloon][data-balloon-pos="up-right"]:after {
bottom: 100%;
right: 0;
margin-bottom: 11px;
-webkit-transform: translate(0, 10px);
-moz-transform: translate(0, 10px);
-ms-transform: translate(0, 10px);
transform: translate(0, 10px);
-webkit-transform-origin: top;
-moz-transform-origin: top;
-ms-transform-origin: top;
transform-origin: top; }
[data-balloon][data-balloon-pos="up-right"]:before {
bottom: 100%;
right: 5px;
margin-bottom: 5px;
-webkit-transform: translate(0, 10px);
-moz-transform: translate(0, 10px);
-ms-transform: translate(0, 10px);
transform: translate(0, 10px);
-webkit-transform-origin: top;
-moz-transform-origin: top;
-ms-transform-origin: top;
transform-origin: top; }
[data-balloon][data-balloon-pos="up-right"]:hover:after, [data-balloon][data-balloon-pos="up-right"][data-balloon-visible]:after {
-webkit-transform: translate(0, 0);
-moz-transform: translate(0, 0);
-ms-transform: translate(0, 0);
transform: translate(0, 0); }
[data-balloon][data-balloon-pos="up-right"]:hover:before, [data-balloon][data-balloon-pos="up-right"][data-balloon-visible]:before {
-webkit-transform: translate(0, 0);
-moz-transform: translate(0, 0);
-ms-transform: translate(0, 0);
transform: translate(0, 0); }
[data-balloon][data-balloon-pos='down']:after {
left: 50%;
margin-top: 11px;
top: 100%;
-webkit-transform: translate(-50%, -10px);
-moz-transform: translate(-50%, -10px);
-ms-transform: translate(-50%, -10px);
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");
@ -182,27 +113,15 @@ button[data-balloon] {
left: 50%;
margin-top: 5px;
top: 100%;
-webkit-transform: translate(-50%, -10px);
-moz-transform: translate(-50%, -10px);
-ms-transform: translate(-50%, -10px);
transform: translate(-50%, -10px); }
[data-balloon][data-balloon-pos='down']:hover:after, [data-balloon][data-balloon-pos='down'][data-balloon-visible]:after {
-webkit-transform: translate(-50%, 0);
-moz-transform: translate(-50%, 0);
-ms-transform: translate(-50%, 0);
transform: translate(-50%, 0); }
[data-balloon][data-balloon-pos='down']:hover:before, [data-balloon][data-balloon-pos='down'][data-balloon-visible]:before {
-webkit-transform: translate(-50%, 0);
-moz-transform: translate(-50%, 0);
-ms-transform: translate(-50%, 0);
transform: translate(-50%, 0); }
[data-balloon][data-balloon-pos='down-left']:after {
left: 0;
margin-top: 11px;
top: 100%;
-webkit-transform: translate(0, -10px);
-moz-transform: translate(0, -10px);
-ms-transform: translate(0, -10px);
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");
@ -212,27 +131,15 @@ button[data-balloon] {
left: 5px;
margin-top: 5px;
top: 100%;
-webkit-transform: translate(0, -10px);
-moz-transform: translate(0, -10px);
-ms-transform: translate(0, -10px);
transform: translate(0, -10px); }
[data-balloon][data-balloon-pos='down-left']:hover:after, [data-balloon][data-balloon-pos='down-left'][data-balloon-visible]:after {
-webkit-transform: translate(0, 0);
-moz-transform: translate(0, 0);
-ms-transform: translate(0, 0);
transform: translate(0, 0); }
[data-balloon][data-balloon-pos='down-left']:hover:before, [data-balloon][data-balloon-pos='down-left'][data-balloon-visible]:before {
-webkit-transform: translate(0, 0);
-moz-transform: translate(0, 0);
-ms-transform: translate(0, 0);
transform: translate(0, 0); }
[data-balloon][data-balloon-pos='down-right']:after {
right: 0;
margin-top: 11px;
top: 100%;
-webkit-transform: translate(0, -10px);
-moz-transform: translate(0, -10px);
-ms-transform: translate(0, -10px);
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");
@ -242,27 +149,15 @@ button[data-balloon] {
right: 5px;
margin-top: 5px;
top: 100%;
-webkit-transform: translate(0, -10px);
-moz-transform: translate(0, -10px);
-ms-transform: translate(0, -10px);
transform: translate(0, -10px); }
[data-balloon][data-balloon-pos='down-right']:hover:after, [data-balloon][data-balloon-pos='down-right'][data-balloon-visible]:after {
-webkit-transform: translate(0, 0);
-moz-transform: translate(0, 0);
-ms-transform: translate(0, 0);
transform: translate(0, 0); }
[data-balloon][data-balloon-pos='down-right']:hover:before, [data-balloon][data-balloon-pos='down-right'][data-balloon-visible]:before {
-webkit-transform: translate(0, 0);
-moz-transform: translate(0, 0);
-ms-transform: translate(0, 0);
transform: translate(0, 0); }
[data-balloon][data-balloon-pos='left']:after {
margin-right: 11px;
right: 100%;
top: 50%;
-webkit-transform: translate(10px, -50%);
-moz-transform: translate(10px, -50%);
-ms-transform: translate(10px, -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");
@ -272,27 +167,15 @@ button[data-balloon] {
margin-right: 5px;
right: 100%;
top: 50%;
-webkit-transform: translate(10px, -50%);
-moz-transform: translate(10px, -50%);
-ms-transform: translate(10px, -50%);
transform: translate(10px, -50%); }
[data-balloon][data-balloon-pos='left']:hover:after, [data-balloon][data-balloon-pos='left'][data-balloon-visible]:after {
-webkit-transform: translate(0, -50%);
-moz-transform: translate(0, -50%);
-ms-transform: translate(0, -50%);
transform: translate(0, -50%); }
[data-balloon][data-balloon-pos='left']:hover:before, [data-balloon][data-balloon-pos='left'][data-balloon-visible]:before {
-webkit-transform: translate(0, -50%);
-moz-transform: translate(0, -50%);
-ms-transform: translate(0, -50%);
transform: translate(0, -50%); }
[data-balloon][data-balloon-pos='right']:after {
left: 100%;
margin-left: 11px;
top: 50%;
-webkit-transform: translate(-10px, -50%);
-moz-transform: translate(-10px, -50%);
-ms-transform: translate(-10px, -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");
@ -302,19 +185,10 @@ button[data-balloon] {
left: 100%;
margin-left: 5px;
top: 50%;
-webkit-transform: translate(-10px, -50%);
-moz-transform: translate(-10px, -50%);
-ms-transform: translate(-10px, -50%);
transform: translate(-10px, -50%); }
[data-balloon][data-balloon-pos='right']:hover:after, [data-balloon][data-balloon-pos='right'][data-balloon-visible]:after {
-webkit-transform: translate(0, -50%);
-moz-transform: translate(0, -50%);
-ms-transform: translate(0, -50%);
transform: translate(0, -50%); }
[data-balloon][data-balloon-pos='right']:hover:before, [data-balloon][data-balloon-pos='right'][data-balloon-visible]:before {
-webkit-transform: translate(0, -50%);
-moz-transform: translate(0, -50%);
-ms-transform: translate(0, -50%);
transform: translate(0, -50%); }
[data-balloon][data-balloon-length='small']:after {
white-space: normal;

View File

@ -0,0 +1,82 @@
.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;
}

View File

@ -0,0 +1,13 @@
jQuery( document ).ready( function( $ ) {
$( '.post-type-gp_elements .page-title-action' ).on( 'click', function( e ) {
e.preventDefault();
$( '.choose-element-type-parent' ).show();
} );
$( '.close-choose-element-type' ).on( 'click', function( e ) {
e.preventDefault();
$( '.choose-element-type-parent' ).hide();
} );
} );

View File

@ -1,16 +1,3 @@
.no-element-type #titlediv,
.no-element-type h1.wp-heading-inline,
.no-element-type h1.wp-heading-inline + .page-title-action,
.no-element-type #submitdiv,
.no-element-type .postbox:not(#generate_premium_elements),
.no-element-type .notice,
.no-element-type .error,
.element-settings.no-element-type {
opacity: 0;
height: 0;
overflow: hidden;
}
#generate_premium_elements {
background-color: transparent;
border: 0;
@ -60,7 +47,8 @@ td.generate-element-row-content {
}
#generate_premium_elements .handlediv,
#generate_premium_elements .hndle {
#generate_premium_elements .hndle,
#generate_premium_elements .postbox-header {
display: none;
}
@ -90,16 +78,12 @@ td.generate-element-row-content {
}
#generate_premium_elements .condition {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
margin-bottom: 10px;
}
#generate_premium_elements .condition .select2 {
-webkit-box-flex: 1;
-ms-flex-positive: 1;
flex-grow: 1;
flex-grow: 1;
}
button.remove-condition {
@ -151,7 +135,6 @@ ul.element-metabox-tabs {
margin: 0 0 20px;
background: white;
box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3;
display: -ms-flexbox;
display: flex;
width: 100%;
overflow: hidden;
@ -159,7 +142,6 @@ ul.element-metabox-tabs {
ul.element-metabox-tabs li {
width: auto;
-ms-flex: none;
flex: none;
border-bottom: 2px solid transparent;
border-top: none;
@ -194,27 +176,6 @@ ul.element-metabox-tabs li.is-selected a {
margin-bottom: 20px;
}
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;
}
.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;
@ -222,23 +183,24 @@ select.select-type:hover {
.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 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.layout #generate-element-content {
.element-settings.layout #generate-element-content,
.element-settings.block #generate-element-content {
display: none;
}
.padding-container {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
}
@ -252,6 +214,10 @@ select.select-type:hover {
vertical-align: middle;
}
.padding-element-options {
display: flex;
}
.padding-element span.unit {
border: 1px solid #ddd;
display: inline-block;
@ -270,7 +236,6 @@ select.select-type:hover {
.padding-element select {
width: auto !important;
position: relative;
top: -2.5px;
left: -5px;
min-height: 30px;
}
@ -278,7 +243,7 @@ select.select-type:hover {
.padding-element span {
display: block;
font-size: 90%;
opacity: 0.8;
opacity: 0.8;
}
.generate-element-row-content .responsive-controls.single-responsive-value {
@ -311,12 +276,8 @@ select.select-type:hover {
.media-container,
.change-featured-image,
.set-featured-image {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
align-items: center;
}
.media-container > input,
@ -355,35 +316,6 @@ select.select-type:hover {
height: 300px;
}
.choose-element-type-parent:before {
content: "";
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
}
.choose-element-type {
position: fixed;
width: 500px;
background: #fff;
left: calc(50% - 250px);
padding: 50px;
box-sizing: border-box;
box-shadow: 0 0 20px rgba(0,0,0,0.05);
border: 1px solid #ddd;
z-index: 11;
}
#poststuff .choose-element-type h2 {
font-size: 30px;
text-align: center;
margin-bottom: 30px;
padding: 0;
line-height: 1;
}
.layout-radio-item {
margin-bottom: 3px;
}
@ -441,6 +373,16 @@ body .select2-container--default .select2-selection--single {
margin-left: -6px;
}
.generate-element-row-content .color-alpha {
height: 100% !important;
.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;
}

View File

@ -7,40 +7,27 @@ jQuery(document).ready(function( $ ) {
} );
}
if ( $( '.choose-element-type-parent' ).is( ':visible' ) ) {
$( '.select-type' ).focus();
}
$( '#_generate_block_type' ).on( 'change', function() {
var _this = $( this ).val();
$( 'select[name="_generate_element_type"]' ).on( 'change', function() {
var _this = $( this ),
element = _this.val();
if ( '' == element ) {
return;
if ( 'hook' === _this ) {
$( '.hook-row' ).removeClass( 'hide-hook-row' );
} else {
$( '.hook-row' ).addClass( 'hide-hook-row' );
}
$( '.element-settings' ).addClass( element ).removeClass( 'no-element-type' ).css( 'opacity', '' );
$( 'body' ).removeClass( 'no-element-type' );
$( 'body' ).removeClass( 'right-sidebar-block-type' );
$( 'body' ).removeClass( 'left-sidebar-block-type' );
$( 'body' ).removeClass( 'header-block-type' );
$( 'body' ).removeClass( 'footer-block-type' );
var active_tab = $( '.element-metabox-tabs' ).find( 'li:visible:first' );
active_tab.addClass( 'is-selected' );
$( '.generate-elements-settings[data-tab="' + active_tab.attr( 'data-tab' ) + '"]' ).show();
$( 'body' ).addClass( _this + '-block-type' );
if ( 'layout' === element ) {
$( '#generate-element-content' ).hide();
if ( 'left-sidebar' === _this || 'right-sidebar' === _this ) {
$( '.sidebar-notice' ).show();
} else {
$( '.sidebar-notice' ).hide();
}
if ( 'header' === element ) {
$( 'body' ).addClass( 'header-element-type' );
}
if ( elements.settings && 'layout' !== element ) {
$( function() {
wp.codeEditor.initialize( "generate-element-content", elements.settings );
} );
}
_this.closest( '.choose-element-type-parent' ).hide();
} );
$( '#_generate_hook' ).on( 'change', function() {
@ -76,6 +63,10 @@ jQuery(document).ready(function( $ ) {
$( '.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' ).hide();
@ -208,6 +199,8 @@ jQuery(document).ready(function( $ ) {
$( '.condition select.condition-select' ).on( 'change', function() {
get_location_objects( $( this ) );
$( '.elements-no-location-error' ).hide();
} );
$( '.generate-elements-rule-objects-visible' ).each( function() {

View File

@ -0,0 +1,498 @@
/**!
* wp-color-picker-alpha
*
* Overwrite Automattic Iris for enabled Alpha Channel in wpColorPicker
* Only run in input and is defined data alpha in true
*
* Version: 2.1.4
* https://github.com/kallookoo/wp-color-picker-alpha
* Licensed under the GPLv2 license or later.
*/
( function( $ ) {
// Prevent double-init.
if ( $.wp.wpColorPicker.prototype._hasAlpha ) {
return;
}
// Variable for some backgrounds ( grid )
var image = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAAHnlligAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAHJJREFUeNpi+P///4EDBxiAGMgCCCAGFB5AADGCRBgYDh48CCRZIJS9vT2QBAggFBkmBiSAogxFBiCAoHogAKIKAlBUYTELAiAmEtABEECk20G6BOmuIl0CIMBQ/IEMkO0myiSSraaaBhZcbkUOs0HuBwDplz5uFJ3Z4gAAAABJRU5ErkJggg==',
// html stuff for wpColorPicker copy of the original color-picker.js
_after = '<div class="wp-picker-holder" />',
_wrap = '<div class="wp-picker-container" />',
_button = '<input type="button" class="button button-small" />',
// Prevent CSS issues in < WordPress 4.9
_deprecated = ( wpColorPickerL10n.current !== undefined );
// Declare some global variables when is deprecated or not
if ( _deprecated ) {
var _before = '<a tabindex="0" class="wp-color-result" />';
} else {
var _before = '<button type="button" class="button wp-color-result" aria-expanded="false"><span class="wp-color-result-text"></span></button>',
_wrappingLabel = '<label></label>',
_wrappingLabelText = '<span class="screen-reader-text"></span>';
}
/**
* Overwrite Color
* for enable support rbga
*/
Color.fn.toString = function() {
if ( this._alpha < 1 )
return this.toCSS( 'rgba', this._alpha ).replace( /\s+/g, '' );
var hex = parseInt( this._color, 10 ).toString( 16 );
if ( this.error )
return '';
if ( hex.length < 6 )
hex = ( '00000' + hex ).substr( -6 );
return '#' + hex;
};
/**
* Overwrite wpColorPicker
*/
$.widget( 'wp.wpColorPicker', $.wp.wpColorPicker, {
_hasAlpha: true,
/**
* @summary Creates the color picker.
*
* Creates the color picker, sets default values, css classes and wraps it all in HTML.
*
* @since 3.5.0
*
* @access private
*
* @returns {void}
*/
_create: function() {
// Return early if Iris support is missing.
if ( ! $.support.iris ) {
return;
}
var self = this,
el = self.element;
// Override default options with options bound to the element.
$.extend( self.options, el.data() );
// Create a color picker which only allows adjustments to the hue.
if ( self.options.type === 'hue' ) {
return self._createHueOnly();
}
// Bind the close event.
self.close = $.proxy( self.close, self );
self.initialValue = el.val();
// Add a CSS class to the input field.
el.addClass( 'wp-color-picker' );
if ( _deprecated ) {
el.hide().wrap( _wrap );
self.wrap = el.parent();
self.toggler = $( _before )
.insertBefore( el )
.css( { backgroundColor : self.initialValue } )
.attr( 'title', wpColorPickerL10n.pick )
.attr( 'data-current', wpColorPickerL10n.current );
self.pickerContainer = $( _after ).insertAfter( el );
self.button = $( _button ).addClass('hidden');
} else {
/*
* Check if there's already a wrapping label, e.g. in the Customizer.
* If there's no label, add a default one to match the Customizer template.
*/
if ( ! el.parent( 'label' ).length ) {
// Wrap the input field in the default label.
el.wrap( _wrappingLabel );
// Insert the default label text.
self.wrappingLabelText = $( _wrappingLabelText )
.insertBefore( el )
.text( wpColorPickerL10n.defaultLabel );
}
/*
* At this point, either it's the standalone version or the Customizer
* one, we have a wrapping label to use as hook in the DOM, let's store it.
*/
self.wrappingLabel = el.parent();
// Wrap the label in the main wrapper.
self.wrappingLabel.wrap( _wrap );
// Store a reference to the main wrapper.
self.wrap = self.wrappingLabel.parent();
// Set up the toggle button and insert it before the wrapping label.
self.toggler = $( _before )
.insertBefore( self.wrappingLabel )
.css( { backgroundColor: self.initialValue } );
// Set the toggle button span element text.
self.toggler.find( '.wp-color-result-text' ).text( wpColorPickerL10n.pick );
// Set up the Iris container and insert it after the wrapping label.
self.pickerContainer = $( _after ).insertAfter( self.wrappingLabel );
// Store a reference to the Clear/Default button.
self.button = $( _button );
}
// Set up the Clear/Default button.
if ( self.options.defaultColor ) {
self.button.addClass( 'wp-picker-default' ).val( wpColorPickerL10n.defaultString );
if ( ! _deprecated ) {
self.button.attr( 'aria-label', wpColorPickerL10n.defaultAriaLabel );
}
} else {
self.button.addClass( 'wp-picker-clear' ).val( wpColorPickerL10n.clear );
if ( ! _deprecated ) {
self.button.attr( 'aria-label', wpColorPickerL10n.clearAriaLabel );
}
}
if ( _deprecated ) {
el.wrap( '<span class="wp-picker-input-wrap" />' ).after( self.button );
} else {
// Wrap the wrapping label in its wrapper and append the Clear/Default button.
self.wrappingLabel
.wrap( '<span class="wp-picker-input-wrap hidden" />' )
.after( self.button );
/*
* The input wrapper now contains the label+input+Clear/Default button.
* Store a reference to the input wrapper: we'll use this to toggle
* the controls visibility.
*/
self.inputWrapper = el.closest( '.wp-picker-input-wrap' );
}
el.iris( {
target: self.pickerContainer,
hide: self.options.hide,
width: self.options.width,
mode: self.options.mode,
palettes: self.options.palettes,
/**
* @summary Handles the onChange event if one has been defined in the options.
*
* Handles the onChange event if one has been defined in the options and additionally
* sets the background color for the toggler element.
*
* @since 3.5.0
*
* @param {Event} event The event that's being called.
* @param {HTMLElement} ui The HTMLElement containing the color picker.
*
* @returns {void}
*/
change: function( event, ui ) {
if ( self.options.alpha ) {
self.toggler.css( { 'background-image' : 'url(' + image + ')' } );
if ( _deprecated ) {
self.toggler.html( '<span class="color-alpha" />' );
} else {
self.toggler.css( {
'position' : 'relative'
} );
if ( self.toggler.find('span.color-alpha').length == 0 ) {
self.toggler.append('<span class="color-alpha" />');
}
}
self.toggler.find( 'span.color-alpha' ).css( {
'width' : '30px',
'height' : '100%',
'position' : 'absolute',
'top' : 0,
'left' : 0,
'border-top-left-radius' : '2px',
'border-bottom-left-radius' : '2px',
'background' : ui.color.toString()
} );
} else {
self.toggler.css( { backgroundColor : ui.color.toString() } );
}
if ( $.isFunction( self.options.change ) ) {
self.options.change.call( this, event, ui );
}
}
} );
el.val( self.initialValue );
self._addListeners();
// Force the color picker to always be closed on initial load.
if ( ! self.options.hide ) {
self.toggler.click();
}
},
/**
* @summary Binds event listeners to the color picker.
*
* @since 3.5.0
*
* @access private
*
* @returns {void}
*/
_addListeners: function() {
var self = this;
/**
* @summary Prevent any clicks inside this widget from leaking to the top and closing it.
*
* @since 3.5.0
*
* @param {Event} event The event that's being called.
*
* @returs {void}
*/
self.wrap.on( 'click.wpcolorpicker', function( event ) {
event.stopPropagation();
});
/**
* @summary Open or close the color picker depending on the class.
*
* @since 3.5
*/
self.toggler.click( function(){
if ( self.toggler.hasClass( 'wp-picker-open' ) ) {
self.close();
} else {
self.open();
}
});
/**
* @summary Checks if value is empty when changing the color in the color picker.
*
* Checks if value is empty when changing the color in the color picker.
* If so, the background color is cleared.
*
* @since 3.5.0
*
* @param {Event} event The event that's being called.
*
* @returns {void}
*/
self.element.on( 'change', function( event ) {
// Empty or Error = clear
if ( $( this ).val() === '' || self.element.hasClass( 'iris-error' ) ) {
if ( self.options.alpha ) {
if ( _deprecated ) {
self.toggler.removeAttr( 'style' );
}
self.toggler.find( 'span.color-alpha' ).css( 'backgroundColor', '' );
} else {
self.toggler.css( 'backgroundColor', '' );
}
// fire clear callback if we have one
if ( $.isFunction( self.options.clear ) )
self.options.clear.call( this, event );
}
} );
/**
* @summary Enables the user to clear or revert the color in the color picker.
*
* Enables the user to either clear the color in the color picker or revert back to the default color.
*
* @since 3.5.0
*
* @param {Event} event The event that's being called.
*
* @returns {void}
*/
self.button.on( 'click', function( event ) {
if ( $( this ).hasClass( 'wp-picker-clear' ) ) {
self.element.val( '' );
if ( self.options.alpha ) {
if ( _deprecated ) {
self.toggler.removeAttr( 'style' );
}
self.toggler.find( 'span.color-alpha' ).css( 'backgroundColor', '' );
} else {
self.toggler.css( 'backgroundColor', '' );
}
if ( $.isFunction( self.options.clear ) )
self.options.clear.call( this, event );
self.element.trigger( 'change' );
} else if ( $( this ).hasClass( 'wp-picker-default' ) ) {
self.element.val( self.options.defaultColor ).change();
}
});
},
});
/**
* Overwrite iris
*/
$.widget( 'a8c.iris', $.a8c.iris, {
_create: function() {
this._super();
// Global option for check is mode rbga is enabled
this.options.alpha = this.element.data( 'alpha' ) || false;
// Is not input disabled
if ( ! this.element.is( ':input' ) )
this.options.alpha = false;
if ( typeof this.options.alpha !== 'undefined' && this.options.alpha ) {
var self = this,
el = self.element,
_html = '<div class="iris-strip iris-slider iris-alpha-slider"><div class="iris-slider-offset iris-slider-offset-alpha"></div></div>',
aContainer = $( _html ).appendTo( self.picker.find( '.iris-picker-inner' ) ),
aSlider = aContainer.find( '.iris-slider-offset-alpha' ),
controls = {
aContainer : aContainer,
aSlider : aSlider
};
if ( typeof el.data( 'custom-width' ) !== 'undefined' ) {
self.options.customWidth = parseInt( el.data( 'custom-width' ) ) || 0;
} else {
self.options.customWidth = 100;
}
// Set default width for input reset
self.options.defaultWidth = el.width();
// Update width for input
if ( self._color._alpha < 1 || self._color.toString().indexOf('rgb') != -1 )
el.width( parseInt( self.options.defaultWidth + self.options.customWidth ) );
// Push new controls
$.each( controls, function( k, v ) {
self.controls[k] = v;
} );
// Change size strip and add margin for sliders
self.controls.square.css( { 'margin-right': '0' } );
var emptyWidth = ( self.picker.width() - self.controls.square.width() - 20 ),
stripsMargin = ( emptyWidth / 6 ),
stripsWidth = ( ( emptyWidth / 2 ) - stripsMargin );
$.each( [ 'aContainer', 'strip' ], function( k, v ) {
self.controls[v].width( stripsWidth ).css( { 'margin-left' : stripsMargin + 'px' } );
} );
// Add new slider
self._initControls();
// For updated widget
self._change();
}
},
_initControls: function() {
this._super();
if ( this.options.alpha ) {
var self = this,
controls = self.controls;
controls.aSlider.slider({
orientation : 'vertical',
min : 0,
max : 100,
step : 1,
value : parseInt( self._color._alpha * 100 ),
slide : function( event, ui ) {
// Update alpha value
self._color._alpha = parseFloat( ui.value / 100 );
self._change.apply( self, arguments );
}
});
}
},
_change: function() {
this._super();
var self = this,
el = self.element;
if ( this.options.alpha ) {
var controls = self.controls,
alpha = parseInt( self._color._alpha * 100 ),
color = self._color.toRgb(),
gradient = [
'rgb(' + color.r + ',' + color.g + ',' + color.b + ') 0%',
'rgba(' + color.r + ',' + color.g + ',' + color.b + ', 0) 100%'
],
defaultWidth = self.options.defaultWidth,
customWidth = self.options.customWidth,
target = self.picker.closest( '.wp-picker-container' ).find( '.wp-color-result' );
// Generate background slider alpha, only for CSS3 old browser fuck!! :)
controls.aContainer.css( { 'background' : 'linear-gradient(to bottom, ' + gradient.join( ', ' ) + '), url(' + image + ')' } );
if ( target.hasClass( 'wp-picker-open' ) ) {
// Update alpha value
controls.aSlider.slider( 'value', alpha );
/**
* Disabled change opacity in default slider Saturation ( only is alpha enabled )
* and change input width for view all value
*/
if ( self._color._alpha < 1 ) {
controls.strip.attr( 'style', controls.strip.attr( 'style' ).replace( /rgba\(([0-9]+,)(\s+)?([0-9]+,)(\s+)?([0-9]+)(,(\s+)?[0-9\.]+)\)/g, 'rgb($1$3$5)' ) );
el.width( parseInt( defaultWidth + customWidth ) );
} else {
el.width( defaultWidth );
}
}
}
var reset = el.data( 'reset-alpha' ) || false;
if ( reset ) {
self.picker.find( '.iris-palette-container' ).on( 'click.palette', '.iris-palette', function() {
self._color._alpha = 1;
self.active = 'external';
self._change();
} );
}
el.trigger( 'change' );
},
_addInputListeners: function( input ) {
var self = this,
debounceTimeout = 100,
callback = function( event ) {
var color = new Color( input.val() ),
val = input.val();
input.removeClass( 'iris-error' );
// we gave a bad color
if ( color.error ) {
// don't error on an empty input
if ( val !== '' )
input.addClass( 'iris-error' );
} else {
if ( color.toString() !== self._color.toString() ) {
// let's not do this on keyup for hex shortcodes
if ( ! ( event.type === 'keyup' && val.match( /^[0-9a-fA-F]{3}$/ ) ) )
self._setOption( 'color', color.toString() );
}
}
};
input.on( 'change', callback ).on( 'keyup', self._debounce( callback, debounceTimeout ) );
// If we initialized hidden, show on first focus. The rest is up to you.
if ( self.options.hide ) {
input.on( 'focus', function() {
self.show();
} );
}
}
} );
}( jQuery ) );
// Auto Call plugin is class is color-picker
jQuery( document ).ready( function( $ ) {
$( '.color-picker' ).wpColorPicker();
} );

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,163 @@
<?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 = '';
/**
* 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 );
$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
);
if ( $display ) {
$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 'custom':
$hook = $custom_hook;
break;
}
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' );
}
add_action( esc_attr( $hook ), array( $this, 'build_hook' ), absint( $priority ) );
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' );
}
add_filter( 'generateblocks_do_content', array( $this, 'do_block_content' ) );
}
}
/**
* 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;
}
/**
* Builds the HTML structure for Page Headers.
*
* @since 1.11.0
*/
public function build_hook() {
echo GeneratePress_Elements_Helper::build_content( $this->post_id); // phpcs:ignore -- No escaping needed.
}
}

View File

@ -1,9 +1,17 @@
<?php
// No direct access, please
/**
* This file handles the Display Rule conditions for Elements.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
exit; // No direct access, please.
}
/**
* The conditions class.
*/
class GeneratePress_Conditions {
/**
* Instance.
@ -17,7 +25,7 @@ class GeneratePress_Conditions {
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self;
self::$instance = new self();
}
return self::$instance;
@ -33,25 +41,28 @@ class GeneratePress_Conditions {
public static function get_conditions() {
$types = array(
'general' => array(
'label' => esc_attr__( 'General', 'gp-premium' ),
'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:404' => esc_attr__( '404 Template', 'gp-premium' ),
)
)
'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:404' => esc_attr__( '404 Template', 'gp-premium' ),
),
),
);
// Add the post types.
$post_types = get_post_types( array(
'public' => true,
), 'objects' );
$post_types = get_post_types(
array(
'public' => true,
),
'objects'
);
foreach ( $post_types as $post_type_slug => $post_type ) {
@ -67,15 +78,17 @@ class GeneratePress_Conditions {
$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 )
)
'post:' . $post_type_slug => esc_html( $post_type->labels->singular_name ),
),
);
// Add the post type archive.
if ( 'post' == $post_type_slug || ! empty( $post_type_object->has_archive ) ) {
if ( 'post' === $post_type_slug || ! empty( $post_type_object->has_archive ) ) {
$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 ),
),
);
@ -88,23 +101,28 @@ class GeneratePress_Conditions {
$public = $taxonomy->public && $taxonomy->show_ui;
if ( 'post_format' == $taxonomy_slug ) {
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 );
$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'] ) ) {
$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 );
/* 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 );
$types[ $post_type_slug ]['locations'][ $post_type_slug . ':taxonomy:' . $taxonomy_slug ] = esc_html( $post_type->labels->singular_name . ' ' . $label );
}
}
}
@ -122,17 +140,17 @@ class GeneratePress_Conditions {
public static function get_user_conditions() {
$rules = array(
'general' => array(
'label' => esc_attr__( 'General', 'gp-premium' ),
'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' ),
)
'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();
@ -207,6 +225,37 @@ class GeneratePress_Conditions {
}
}
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;
}
}
}
}
return array(
'rule' => $location,
'object' => $object,
@ -230,7 +279,7 @@ class GeneratePress_Conditions {
$user = wp_get_current_user();
foreach ( ( array ) $user->roles as $role ) {
foreach ( (array) $user->roles as $role ) {
$status[] = $role;
}
@ -242,6 +291,9 @@ class GeneratePress_Conditions {
*
* @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 ) {
@ -250,7 +302,7 @@ class GeneratePress_Conditions {
// Show depending on location conditionals.
if ( ! $show ) {
foreach( ( array ) $conditionals as $conditional ) {
foreach ( (array) $conditionals as $conditional ) {
if ( in_array( 'general:site', $conditional ) ) {
$show = true;
} elseif ( is_singular() && in_array( 'general:singular', $conditional ) ) {
@ -280,7 +332,7 @@ class GeneratePress_Conditions {
// Exclude based on exclusion conditionals.
if ( $show ) {
foreach( ( array ) $exclude as $conditional ) {
foreach ( (array) $exclude as $conditional ) {
if ( is_singular() && in_array( 'general:singular', $conditional ) ) {
$show = false;
} elseif ( is_archive() && in_array( 'general:archive', $conditional ) ) {
@ -294,7 +346,7 @@ class GeneratePress_Conditions {
}
}
} elseif ( is_singular() && strstr( $conditional['rule'], ':taxonomy:' ) ) {
$tax = substr( $conditional['rule'], strrpos( $conditional['rule'], ':') + 1 );
$tax = substr( $conditional['rule'], strrpos( $conditional['rule'], ':' ) + 1 );
if ( $tax && isset( $conditional['object'] ) && has_term( $conditional['object'], $tax ) ) {
$show = false;
@ -323,11 +375,11 @@ class GeneratePress_Conditions {
* Returns the label for a saved location.
*
* @since 1.7
* @param string $saved_location
* @param string $saved_location The location.
* @return string|bool
*/
static public function get_saved_label( $saved_location ) {
$locations = self::get_conditions();
public static function get_saved_label( $saved_location ) {
$locations = self::get_conditions();
$rule = $saved_location['rule'];
$object_id = $saved_location['object'];

View File

@ -1,8 +1,17 @@
<?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.
@ -21,7 +30,7 @@ class GeneratePress_Elements_Helper {
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self;
self::$instance = new self();
}
return self::$instance;
@ -32,6 +41,7 @@ class GeneratePress_Elements_Helper {
*
* @since 1.7
*
* @param string $option Option to check.
* @return bool
*/
public static function does_option_exist( $option ) {
@ -96,6 +106,9 @@ class GeneratePress_Elements_Helper {
return false;
}
/**
* Check whether we should execute PHP or not.
*/
public static function should_execute_php() {
$php = true;
@ -105,4 +118,30 @@ class GeneratePress_Elements_Helper {
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 '';
}
return apply_filters( 'generate_do_block_element_content', do_blocks( $block_element->post_content ) );
}
}

View File

@ -1,10 +1,23 @@
<?php
/**
* This file handles the Header Element type.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
/**
* The Header Element type.
*/
class GeneratePress_Hero {
/**
* Our conditionals for this header.
*
* @since 1.7
* @var array Conditions.
*/
protected $conditional = array();
@ -12,6 +25,7 @@ class GeneratePress_Hero {
* Our exclusions for this header.
*
* @since 1.7
* @var array Exclusions.
*/
protected $exclude = array();
@ -19,6 +33,7 @@ class GeneratePress_Hero {
* Our user conditionals for this header.
*
* @since 1.7
* @var array Users.
*/
protected $users = array();
@ -26,6 +41,7 @@ class GeneratePress_Hero {
* Our array of available options.
*
* @since 1.7
* @var array Options.
*/
protected static $options = array();
@ -33,6 +49,7 @@ class GeneratePress_Hero {
* The element ID.
*
* @since 1.7
* @var int Post ID.
*/
protected static $post_id = '';
@ -40,6 +57,7 @@ class GeneratePress_Hero {
* How many times this class has been called per page.
*
* @since 1.7
* @var int Instances.
*/
public static $instances = 0;
@ -47,6 +65,7 @@ class GeneratePress_Hero {
* Get our current instance.
*
* @since 1.7
* @var instance This hero.
*/
protected static $hero = '';
@ -54,10 +73,9 @@ class GeneratePress_Hero {
* Kicks it all off.
*
* @since 1.7
*
* @param int The element post ID.
* @param int $post_id The element post ID.
*/
function __construct( $post_id ) {
public function __construct( $post_id ) {
self::$post_id = $post_id;
@ -81,9 +99,9 @@ class GeneratePress_Hero {
if ( $display ) {
$location = apply_filters( 'generate_page_hero_location', 'generate_after_header', $post_id );
add_action( $location, array( $this, 'build_hero' ), 9 );
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue' ), 100 );
add_action( 'wp', array( $this, 'after_setup' ), 100 );
add_action( $location, array( $this, 'build_hero' ), 9 );
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue' ), 100 );
add_action( 'wp', array( $this, 'after_setup' ), 100 );
self::$instances++;
}
@ -102,9 +120,13 @@ class GeneratePress_Hero {
if ( $options['parallax'] ) {
wp_enqueue_script( 'generate-hero-parallax', plugin_dir_url( __FILE__ ) . 'assets/js/parallax.min.js', array(), GP_PREMIUM_VERSION, true );
wp_localize_script( 'generate-hero-parallax', 'hero', array(
'parallax' => apply_filters( 'generate_hero_parallax_speed', 2 ),
) );
wp_localize_script(
'generate-hero-parallax',
'hero',
array(
'parallax' => apply_filters( 'generate_hero_parallax_speed', 2 ),
)
);
}
}
@ -120,30 +142,41 @@ class GeneratePress_Hero {
return;
}
$options['container_classes'] = implode( ' ', array(
'page-hero',
'contained' === $options['container'] ? 'grid-container grid-parent' : '',
$options['classes'],
) );
$options['container_classes'] = implode(
' ',
array(
'page-hero',
'contained' === $options['container'] ? 'grid-container grid-parent' : '',
$options['classes'],
)
);
$options['inner_container_classes'] = implode( ' ', array(
'inside-page-hero',
'full-width' !== $options['inner_container'] ? 'grid-container grid-parent' : '',
) );
$options['inner_container_classes'] = implode(
' ',
array(
'inside-page-hero',
'full-width' !== $options['inner_container'] ? 'grid-container grid-parent' : '',
)
);
$options['content'] = self::template_tags( $options['content'] );
$options['content'] = do_shortcode( $options['content'] );
echo apply_filters( 'generate_page_hero_output', sprintf(
'<div class="%1$s">
<div class="%2$s">
%3$s
</div>
</div>',
trim( $options['container_classes'] ),
trim( $options['inner_container_classes'] ),
$options['content']
), $options );
// phpcs:ignore -- No escaping needed.
echo apply_filters(
'generate_page_hero_output',
sprintf(
'<div class="%1$s">
<div class="%2$s">
%3$s
</div>
</div>',
trim( $options['container_classes'] ),
trim( $options['inner_container_classes'] ),
$options['content']
),
$options
);
}
/**
@ -156,9 +189,9 @@ class GeneratePress_Hero {
public static function build_css() {
$options = self::get_options();
// Initiate our CSS class
// Initiate our CSS class.
require_once GP_LIBRARY_DIRECTORY . 'class-make-css.php';
$css = new GeneratePress_Pro_CSS;
$css = new GeneratePress_Pro_CSS();
$image_url = false;
if ( $options['background_image'] && function_exists( 'get_the_post_thumbnail_url' ) ) {
@ -180,16 +213,16 @@ class GeneratePress_Hero {
$image_url = apply_filters( 'generate_page_hero_background_image_url', $image_url, $options );
// Figure out desktop units.
$options['padding_top_unit'] = $options['padding_top_unit'] ? $options['padding_top_unit'] : 'px';
$options['padding_right_unit'] = $options['padding_right_unit'] ? $options['padding_right_unit'] : 'px';
$options['padding_top_unit'] = $options['padding_top_unit'] ? $options['padding_top_unit'] : 'px';
$options['padding_right_unit'] = $options['padding_right_unit'] ? $options['padding_right_unit'] : 'px';
$options['padding_bottom_unit'] = $options['padding_bottom_unit'] ? $options['padding_bottom_unit'] : 'px';
$options['padding_left_unit'] = $options['padding_left_unit'] ? $options['padding_left_unit'] : 'px';
$options['padding_left_unit'] = $options['padding_left_unit'] ? $options['padding_left_unit'] : 'px';
// Figure out mobile units.
$options['padding_top_unit_mobile'] = $options['padding_top_unit_mobile'] ? $options['padding_top_unit_mobile'] : 'px';
$options['padding_right_unit_mobile'] = $options['padding_right_unit_mobile'] ? $options['padding_right_unit_mobile'] : 'px';
$options['padding_bottom_unit_mobile'] = $options['padding_bottom_unit_mobile'] ? $options['padding_bottom_unit_mobile'] : 'px';
$options['padding_left_unit_mobile'] = $options['padding_left_unit_mobile'] ? $options['padding_left_unit_mobile'] : 'px';
$options['padding_top_unit_mobile'] = $options['padding_top_unit_mobile'] ? $options['padding_top_unit_mobile'] : 'px';
$options['padding_right_unit_mobile'] = $options['padding_right_unit_mobile'] ? $options['padding_right_unit_mobile'] : 'px';
$options['padding_bottom_unit_mobile'] = $options['padding_bottom_unit_mobile'] ? $options['padding_bottom_unit_mobile'] : 'px';
$options['padding_left_unit_mobile'] = $options['padding_left_unit_mobile'] ? $options['padding_left_unit_mobile'] : 'px';
$css->set_selector( '.page-hero' );
@ -349,24 +382,24 @@ class GeneratePress_Hero {
$css->add_property( 'background', $navigation_background );
$css->set_selector( '.header-wrap #site-navigation:not(.toggled) .main-nav > ul > li > a, .header-wrap #mobile-header:not(.toggled):not(.navigation-stick) .main-nav > ul > li > a, .header-wrap .main-navigation:not(.toggled):not(.navigation-stick) .menu-toggle, .header-wrap .main-navigation:not(.toggled):not(.navigation-stick) .menu-toggle:hover, .main-navigation:not(.toggled):not(.navigation-stick) .mobile-bar-items a, .main-navigation:not(.toggled):not(.navigation-stick) .mobile-bar-items a:hover, .main-navigation:not(.toggled):not(.navigation-stick) .mobile-bar-items a:focus' );
$css->add_property( 'color', esc_attr( $options['navigation_text_color' ] ) );
$css->add_property( 'color', esc_attr( $options['navigation_text_color'] ) );
$css->set_selector( '.header-wrap #site-navigation:not(.toggled) .main-nav > ul > li:hover > a, .header-wrap #site-navigation:not(.toggled) .main-nav > ul > li:focus > a, .header-wrap #site-navigation:not(.toggled) .main-nav > ul > li.sfHover > a, .header-wrap #mobile-header:not(.toggled) .main-nav > ul > li:hover > a' );
$css->add_property( 'background', $navigation_background_hover );
if ( '' !== $options[ 'navigation_text_color_hover' ] ) {
$css->add_property( 'color', esc_attr( $options[ 'navigation_text_color_hover' ] ) );
if ( '' !== $options['navigation_text_color_hover'] ) {
$css->add_property( 'color', esc_attr( $options['navigation_text_color_hover'] ) );
} else {
$css->add_property( 'color', esc_attr( $options[ 'navigation_text_color' ] ) );
$css->add_property( 'color', esc_attr( $options['navigation_text_color'] ) );
}
$css->set_selector( '.header-wrap #site-navigation:not(.toggled) .main-nav > ul > li[class*="current-menu-"] > a, .header-wrap #mobile-header:not(.toggled) .main-nav > ul > li[class*="current-menu-"] > a, .header-wrap #site-navigation:not(.toggled) .main-nav > ul > li[class*="current-menu-"]:hover > a, .header-wrap #mobile-header:not(.toggled) .main-nav > ul > li[class*="current-menu-"]:hover > a' );
$css->add_property( 'background', $navigation_background_current );
if ( '' !== $options[ 'navigation_text_color_current' ] ) {
$css->add_property( 'color', esc_attr( $options[ 'navigation_text_color_current' ] ) );
if ( '' !== $options['navigation_text_color_current'] ) {
$css->add_property( 'color', esc_attr( $options['navigation_text_color_current'] ) );
} else {
$css->add_property( 'color', esc_attr( $options[ 'navigation_text_color' ] ) );
$css->add_property( 'color', esc_attr( $options['navigation_text_color'] ) );
}
}
@ -467,59 +500,62 @@ class GeneratePress_Hero {
public static function get_options() {
$post_id = self::$post_id;
return apply_filters( 'generate_hero_options', array(
'element_id' => $post_id,
'content' => get_post_meta( $post_id, '_generate_element_content', true ),
'classes' => get_post_meta( $post_id, '_generate_hero_custom_classes', true ),
'container' => get_post_meta( $post_id, '_generate_hero_container', true ),
'inner_container' => get_post_meta( $post_id, '_generate_hero_inner_container', true ),
'horizontal_alignment' => get_post_meta( $post_id, '_generate_hero_horizontal_alignment', true ),
'full_screen' => get_post_meta( $post_id, '_generate_hero_full_screen', true ),
'vertical_alignment' => get_post_meta( $post_id, '_generate_hero_vertical_alignment', true ),
'padding_top' => get_post_meta( $post_id, '_generate_hero_padding_top', true ),
'padding_top_unit' => get_post_meta( $post_id, '_generate_hero_padding_top_unit', true ),
'padding_right' => get_post_meta( $post_id, '_generate_hero_padding_right', true ),
'padding_right_unit' => get_post_meta( $post_id, '_generate_hero_padding_right_unit', true ),
'padding_bottom' => get_post_meta( $post_id, '_generate_hero_padding_bottom', true ),
'padding_bottom_unit' => get_post_meta( $post_id, '_generate_hero_padding_bottom_unit', true ),
'padding_left' => get_post_meta( $post_id, '_generate_hero_padding_left', true ),
'padding_left_unit' => get_post_meta( $post_id, '_generate_hero_padding_left_unit', true ),
'padding_top_mobile' => get_post_meta( $post_id, '_generate_hero_padding_top_mobile', true ),
'padding_top_unit_mobile' => get_post_meta( $post_id, '_generate_hero_padding_top_unit_mobile', true ),
'padding_right_mobile' => get_post_meta( $post_id, '_generate_hero_padding_right_mobile', true ),
'padding_right_unit_mobile' => get_post_meta( $post_id, '_generate_hero_padding_right_unit_mobile', true ),
'padding_bottom_mobile' => get_post_meta( $post_id, '_generate_hero_padding_bottom_mobile', true ),
'padding_bottom_unit_mobile' => get_post_meta( $post_id, '_generate_hero_padding_bottom_unit_mobile', true ),
'padding_left_mobile' => get_post_meta( $post_id, '_generate_hero_padding_left_mobile', true ),
'padding_left_unit_mobile' => get_post_meta( $post_id, '_generate_hero_padding_left_unit_mobile', true ),
'background_image' => get_post_meta( $post_id, '_generate_hero_background_image', true ),
'disable_featured_image' => get_post_meta( $post_id, '_generate_hero_disable_featured_image', true ),
'background_overlay' => get_post_meta( $post_id, '_generate_hero_background_overlay', true ),
'background_position' => get_post_meta( $post_id, '_generate_hero_background_position', true ),
'parallax' => get_post_meta( $post_id, '_generate_hero_background_parallax', true ),
'background_color' => get_post_meta( $post_id, '_generate_hero_background_color', true ),
'text_color' => get_post_meta( $post_id, '_generate_hero_text_color', true ),
'link_color' => get_post_meta( $post_id, '_generate_hero_link_color', true ),
'link_color_hover' => get_post_meta( $post_id, '_generate_hero_background_link_color_hover', true ),
'site_header_merge' => get_post_meta( $post_id, '_generate_site_header_merge', true ),
'site_header_height' => get_post_meta( $post_id, '_generate_site_header_height', true ),
'site_header_height_mobile' => get_post_meta( $post_id, '_generate_site_header_height_mobile', true ),
'site_logo' => get_post_meta( $post_id, '_generate_site_logo', true ),
'retina_logo' => get_post_meta( $post_id, '_generate_retina_logo', true ),
'navigation_logo' => get_post_meta( $post_id, '_generate_navigation_logo', true ),
'mobile_logo' => get_post_meta( $post_id, '_generate_mobile_logo', true ),
'navigation_location' => get_post_meta( $post_id, '_generate_navigation_location', true ),
'header_background_color' => get_post_meta( $post_id, '_generate_site_header_background_color', true ),
'header_title_color' => get_post_meta( $post_id, '_generate_site_header_title_color', true ),
'header_tagline_color' => get_post_meta( $post_id, '_generate_site_header_tagline_color', true ),
'navigation_colors' => get_post_meta( $post_id, '_generate_navigation_colors', true ),
'navigation_background_color' => get_post_meta( $post_id, '_generate_navigation_background_color', true ),
'navigation_text_color' => get_post_meta( $post_id, '_generate_navigation_text_color', true ),
'navigation_background_color_hover' => get_post_meta( $post_id, '_generate_navigation_background_color_hover', true ),
'navigation_text_color_hover' => get_post_meta( $post_id, '_generate_navigation_text_color_hover', true ),
'navigation_background_color_current' => get_post_meta( $post_id, '_generate_navigation_background_color_current', true ),
'navigation_text_color_current' => get_post_meta( $post_id, '_generate_navigation_text_color_current', true ),
) );
return apply_filters(
'generate_hero_options',
array(
'element_id' => $post_id,
'content' => get_post_meta( $post_id, '_generate_element_content', true ),
'classes' => get_post_meta( $post_id, '_generate_hero_custom_classes', true ),
'container' => get_post_meta( $post_id, '_generate_hero_container', true ),
'inner_container' => get_post_meta( $post_id, '_generate_hero_inner_container', true ),
'horizontal_alignment' => get_post_meta( $post_id, '_generate_hero_horizontal_alignment', true ),
'full_screen' => get_post_meta( $post_id, '_generate_hero_full_screen', true ),
'vertical_alignment' => get_post_meta( $post_id, '_generate_hero_vertical_alignment', true ),
'padding_top' => get_post_meta( $post_id, '_generate_hero_padding_top', true ),
'padding_top_unit' => get_post_meta( $post_id, '_generate_hero_padding_top_unit', true ),
'padding_right' => get_post_meta( $post_id, '_generate_hero_padding_right', true ),
'padding_right_unit' => get_post_meta( $post_id, '_generate_hero_padding_right_unit', true ),
'padding_bottom' => get_post_meta( $post_id, '_generate_hero_padding_bottom', true ),
'padding_bottom_unit' => get_post_meta( $post_id, '_generate_hero_padding_bottom_unit', true ),
'padding_left' => get_post_meta( $post_id, '_generate_hero_padding_left', true ),
'padding_left_unit' => get_post_meta( $post_id, '_generate_hero_padding_left_unit', true ),
'padding_top_mobile' => get_post_meta( $post_id, '_generate_hero_padding_top_mobile', true ),
'padding_top_unit_mobile' => get_post_meta( $post_id, '_generate_hero_padding_top_unit_mobile', true ),
'padding_right_mobile' => get_post_meta( $post_id, '_generate_hero_padding_right_mobile', true ),
'padding_right_unit_mobile' => get_post_meta( $post_id, '_generate_hero_padding_right_unit_mobile', true ),
'padding_bottom_mobile' => get_post_meta( $post_id, '_generate_hero_padding_bottom_mobile', true ),
'padding_bottom_unit_mobile' => get_post_meta( $post_id, '_generate_hero_padding_bottom_unit_mobile', true ),
'padding_left_mobile' => get_post_meta( $post_id, '_generate_hero_padding_left_mobile', true ),
'padding_left_unit_mobile' => get_post_meta( $post_id, '_generate_hero_padding_left_unit_mobile', true ),
'background_image' => get_post_meta( $post_id, '_generate_hero_background_image', true ),
'disable_featured_image' => get_post_meta( $post_id, '_generate_hero_disable_featured_image', true ),
'background_overlay' => get_post_meta( $post_id, '_generate_hero_background_overlay', true ),
'background_position' => get_post_meta( $post_id, '_generate_hero_background_position', true ),
'parallax' => get_post_meta( $post_id, '_generate_hero_background_parallax', true ),
'background_color' => get_post_meta( $post_id, '_generate_hero_background_color', true ),
'text_color' => get_post_meta( $post_id, '_generate_hero_text_color', true ),
'link_color' => get_post_meta( $post_id, '_generate_hero_link_color', true ),
'link_color_hover' => get_post_meta( $post_id, '_generate_hero_background_link_color_hover', true ),
'site_header_merge' => get_post_meta( $post_id, '_generate_site_header_merge', true ),
'site_header_height' => get_post_meta( $post_id, '_generate_site_header_height', true ),
'site_header_height_mobile' => get_post_meta( $post_id, '_generate_site_header_height_mobile', true ),
'site_logo' => get_post_meta( $post_id, '_generate_site_logo', true ),
'retina_logo' => get_post_meta( $post_id, '_generate_retina_logo', true ),
'navigation_logo' => get_post_meta( $post_id, '_generate_navigation_logo', true ),
'mobile_logo' => get_post_meta( $post_id, '_generate_mobile_logo', true ),
'navigation_location' => get_post_meta( $post_id, '_generate_navigation_location', true ),
'header_background_color' => get_post_meta( $post_id, '_generate_site_header_background_color', true ),
'header_title_color' => get_post_meta( $post_id, '_generate_site_header_title_color', true ),
'header_tagline_color' => get_post_meta( $post_id, '_generate_site_header_tagline_color', true ),
'navigation_colors' => get_post_meta( $post_id, '_generate_navigation_colors', true ),
'navigation_background_color' => get_post_meta( $post_id, '_generate_navigation_background_color', true ),
'navigation_text_color' => get_post_meta( $post_id, '_generate_navigation_text_color', true ),
'navigation_background_color_hover' => get_post_meta( $post_id, '_generate_navigation_background_color_hover', true ),
'navigation_text_color_hover' => get_post_meta( $post_id, '_generate_navigation_text_color_hover', true ),
'navigation_background_color_current' => get_post_meta( $post_id, '_generate_navigation_background_color_current', true ),
'navigation_text_color_current' => get_post_meta( $post_id, '_generate_navigation_text_color_current', true ),
)
);
}
/**
@ -627,12 +663,15 @@ class GeneratePress_Hero {
return;
}
$attr = apply_filters( 'generate_page_hero_logo_attributes', array(
'class' => 'header-image',
'alt' => esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
'src' => $logo_url,
'title' => esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
) );
$attr = apply_filters(
'generate_page_hero_logo_attributes',
array(
'class' => 'header-image',
'alt' => esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
'src' => $logo_url,
'title' => esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
)
);
if ( '' !== $retina_logo_url ) {
$attr['srcset'] = $logo_url . ' 1x, ' . $retina_logo_url . ' 2x';
@ -653,16 +692,22 @@ class GeneratePress_Hero {
$html_attr .= " $name=" . '"' . $value . '"';
}
echo apply_filters( 'generate_page_hero_logo_output', sprintf( // WPCS: XSS ok, sanitization ok.
'<div class="site-logo page-hero-logo">
<a href="%1$s" title="%2$s" rel="home">
<img %3$s />
</a>
</div>',
esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ),
esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
// phpcs:ignore -- Escaping not needed.
echo apply_filters(
'generate_page_hero_logo_output',
sprintf(
'<div class="site-logo page-hero-logo">
<a href="%1$s" title="%2$s" rel="home">
<img %3$s />
</a>
</div>',
esc_url( apply_filters( 'generate_logo_href', home_url( '/' ) ) ),
esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
$html_attr
),
$logo_url,
$html_attr
), $logo_url, $html_attr );
);
}
/**
@ -680,7 +725,7 @@ class GeneratePress_Hero {
<img class="header-image" src="%3$s" alt="%4$s" />
</a>
</div>',
esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ),
esc_url( apply_filters( 'generate_logo_href', home_url( '/' ) ) ),
esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
esc_url( wp_get_attachment_url( $options['navigation_logo'] ) ),
esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) )
@ -706,7 +751,7 @@ class GeneratePress_Hero {
<img class="header-image" src="%3$s" alt="%4$s" />
</a>
</div>',
esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ),
esc_url( apply_filters( 'generate_logo_href', home_url( '/' ) ) ),
esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
esc_url( wp_get_attachment_url( $options['mobile_logo'] ) ),
esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) )
@ -753,7 +798,7 @@ class GeneratePress_Hero {
*
* @since 1.7
*
* @param $classes Existing classes.
* @param array $classes Existing classes.
* @return array New classes.
*/
public static function site_header_classes( $classes ) {
@ -771,27 +816,27 @@ class GeneratePress_Hero {
public static function remove_template_elements() {
$options = self::get_options();
if ( strpos( $options[ 'content' ], '{{post_title}}' ) !== false ) {
if ( strpos( $options['content'], '{{post_title}}' ) !== false ) {
add_filter( 'generate_show_title', '__return_false' );
remove_action( 'generate_archive_title', 'generate_archive_title' );
add_filter( 'post_class', array( self::$hero, 'remove_hentry' ) );
}
if ( strpos( $options[ 'content' ], '{{post_date}}' ) !== false ) {
if ( strpos( $options['content'], '{{post_date}}' ) !== false ) {
add_filter( 'generate_post_date', '__return_false' );
add_filter( 'post_class', array( self::$hero, 'remove_hentry' ) );
}
if ( strpos( $options[ 'content' ], '{{post_author}}' ) !== false ) {
if ( strpos( $options['content'], '{{post_author}}' ) !== false ) {
add_filter( 'generate_post_author', '__return_false' );
add_filter( 'post_class', array( self::$hero, 'remove_hentry' ) );
}
if ( strpos( $options[ 'content' ], '{{post_terms.category}}' ) !== false ) {
if ( strpos( $options['content'], '{{post_terms.category}}' ) !== false ) {
add_filter( 'generate_show_categories', '__return_false' );
}
if ( strpos( $options[ 'content' ], '{{post_terms.post_tag}}' ) !== false ) {
if ( strpos( $options['content'], '{{post_terms.post_tag}}' ) !== false ) {
add_filter( 'generate_show_tags', '__return_false' );
}
}
@ -801,7 +846,7 @@ class GeneratePress_Hero {
*
* @since 1.7
*
* @param $content The content to check.
* @param string $content The content to check.
* @return mixed The content with the template tags replaced.
*/
public static function template_tags( $content ) {
@ -831,7 +876,8 @@ class GeneratePress_Hero {
$time_string = '<time class="updated" datetime="%3$s" itemprop="dateModified">%4$s</time>' . $time_string;
}
$time_string = sprintf( $time_string,
$time_string = sprintf(
$time_string,
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() ),
esc_attr( get_the_modified_date( 'c' ) ),
@ -841,12 +887,14 @@ class GeneratePress_Hero {
$search[] = '{{post_date}}';
$replace[] = apply_filters( 'generate_page_hero_post_date', $time_string );
// Author
// Author.
global $post;
$author_id = $post->post_author;
$author = sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author"><a class="url fn n" href="%1$s" title="%2$s" rel="author" itemprop="url"><span class="author-name" itemprop="name">%3$s</span></a></span>',
$author = sprintf(
'<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author"><a class="url fn n" href="%1$s" title="%2$s" rel="author" itemprop="url"><span class="author-name" itemprop="name">%3$s</span></a></span>',
esc_url( get_author_posts_url( $author_id ) ),
/* translators: author name */
esc_attr( sprintf( __( 'View all posts by %s', 'gp-premium' ), get_the_author_meta( 'display_name', $author_id ) ) ),
esc_html( get_the_author_meta( 'display_name', $author_id ) )
);
@ -854,7 +902,7 @@ class GeneratePress_Hero {
$search[] = '{{post_author}}';
$replace[] = apply_filters( 'generate_page_hero_post_author', $author );
// Post terms
// Post terms.
if ( strpos( $content, '{{post_terms' ) !== false ) {
$data = preg_match_all( '/{{post_terms.([^}]*)}}/', $content, $matches );
foreach ( $matches[1] as $match ) {
@ -867,7 +915,7 @@ class GeneratePress_Hero {
}
}
// Custom field
// Custom field.
if ( strpos( $content, '{{custom_field' ) !== false ) {
$data = preg_match_all( '/{{custom_field.([^}]*)}}/', $content, $matches );
foreach ( $matches[1] as $match ) {
@ -885,7 +933,7 @@ class GeneratePress_Hero {
}
}
// Taxonomy description
// Taxonomy description.
if ( is_tax() || is_category() || is_tag() ) {
if ( strpos( $content, '{{custom_field' ) !== false ) {
$search[] = '{{custom_field.description}}';
@ -902,7 +950,7 @@ class GeneratePress_Hero {
*
* @since 1.7
*
* @param array $classes
* @param array $classes Existing classes.
* @return array
*/
public function remove_hentry( $classes ) {

View File

@ -1,4 +1,10 @@
<?php
/**
* This file handles the Hook Element.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
@ -14,6 +20,7 @@ class GeneratePress_Hook {
* Set our content variable.
*
* @since 1.7
* @var string The content.
*/
protected $content = '';
@ -21,6 +28,7 @@ class GeneratePress_Hook {
* Set our hook/action variable.
*
* @since 1.7
* @var string The hook.
*/
protected $hook = '';
@ -28,6 +36,7 @@ class GeneratePress_Hook {
* Set our custom hook variable.
*
* @since 1.7
* @var string The custom hook.
*/
protected $custom_hook = '';
@ -35,6 +44,7 @@ class GeneratePress_Hook {
* Set our disable site header variable.
*
* @since 1.7
* @var boolean Whether we're disabling the header.
*/
protected $disable_site_header = false;
@ -42,6 +52,7 @@ class GeneratePress_Hook {
* Set our disable footer variable.
*
* @since 1.7
* @var boolean Whether we're disabling the footer.
*/
protected $disable_site_footer = false;
@ -49,6 +60,7 @@ class GeneratePress_Hook {
* Set our priority variable.
*
* @since 1.7
* @var int The hook priority.
*/
protected $priority = 10;
@ -56,6 +68,7 @@ class GeneratePress_Hook {
* Set our execute PHP variable.
*
* @since 1.7
* @var boolean Whether we're executing PHP.
*/
protected $php = false;
@ -63,6 +76,7 @@ class GeneratePress_Hook {
* Set our execute shortcodes variable.
*
* @since 1.7
* @var boolean Whether we're executing shortcodes.
*/
protected $shortcodes = false;
@ -70,6 +84,7 @@ class GeneratePress_Hook {
* Set our location variable.
*
* @since 1.7
* @var array The conditions.
*/
protected $conditional = array();
@ -77,6 +92,7 @@ class GeneratePress_Hook {
* Set our exclusions variable.
*
* @since 1.7
* @var array The exclusions.
*/
protected $exclude = array();
@ -84,6 +100,7 @@ class GeneratePress_Hook {
* Set our user condition variable.
*
* @since 1.7
* @var array The user roles.
*/
protected $users = array();
@ -94,7 +111,7 @@ class GeneratePress_Hook {
*
* @since 1.7
*/
function __construct( $post_id ) {
public function __construct( $post_id ) {
$this->hook = get_post_meta( $post_id, '_generate_hook', true );
@ -176,12 +193,10 @@ class GeneratePress_Hook {
if ( $this->php && GeneratePress_Elements_Helper::should_execute_php() ) {
ob_start();
// @codingStandardsIgnoreStart
eval( '?>' . $content . '<?php ' );
// @codingStandardsIgnoreEnd
echo ob_get_clean();
eval( '?>' . $content . '<?php ' ); // phpcs:ignore -- Using eval() to execute PHP.
echo ob_get_clean(); // phpcs:ignore -- Escaping not necessary.
} else {
echo $content;
echo $content; // phpcs:ignore -- Escaping not necessary.
}
}

View File

@ -1,10 +1,23 @@
<?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();
@ -12,6 +25,7 @@ class GeneratePress_Site_Layout {
* Set our exclusion variable.
*
* @since 1.7
* @var array
*/
protected $exclude = array();
@ -19,6 +33,7 @@ class GeneratePress_Site_Layout {
* Set our user condition variable.
*
* @since 1.7
* @var array
*/
protected $users = array();
@ -27,30 +42,111 @@ class GeneratePress_Site_Layout {
*
* @since 1.7
* @deprecated 1.7.3
* @var array
*/
protected static $options = array();
/**
* Set up options.
* Sidebar layout.
*
* @since 1.7.3
* @var string
*/
protected $sidebar_layout = null;
protected $footer_widgets = null;
protected $disable_site_header = null;
protected $disable_top_bar = null;
protected $disable_primary_navigation = null;
protected $disable_secondary_navigation = null;
protected $disable_featured_image = null;
protected $disable_content_title = null;
protected $disable_footer = null;
protected $content_area = null;
protected $content_width = 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 = '';
@ -59,6 +155,7 @@ class GeneratePress_Site_Layout {
*
* @since 1.7
* @deprecated 1.7.3
* @var int
*/
public static $instances = 0;
@ -67,9 +164,9 @@ class GeneratePress_Site_Layout {
*
* @since 1.7
*
* @param int $post_ID The post ID of our element.
* @param int $post_id The post ID of our element.
*/
function __construct( $post_id ) {
public function __construct( $post_id ) {
self::$post_id = $post_id;
@ -89,39 +186,43 @@ class GeneratePress_Site_Layout {
$this->sidebar_layout = get_post_meta( $post_id, '_generate_sidebar_layout', true );
}
if ( get_post_meta( $post_id, '_generate_footer_widgets', 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 ) ) {
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_top_bar', 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 ) ) {
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 ) ) {
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 ) ) {
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 ) ) {
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 ) ) {
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 ) ) {
if ( get_post_meta( $post_id, '_generate_content_area', true ) ) {
$this->content_area = get_post_meta( $post_id, '_generate_content_area', true );
}
@ -132,8 +233,13 @@ class GeneratePress_Site_Layout {
$display = apply_filters( 'generate_layout_element_display', GeneratePress_Conditions::show_data( $this->conditional, $this->exclude, $this->users ), $post_id );
if ( $display ) {
add_action( 'wp', array( $this, 'after_setup' ), 100 );
add_action( 'wp_enqueue_scripts', array( $this, 'build_css' ), 50 );
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 );
}
}
}
@ -168,13 +274,17 @@ class GeneratePress_Site_Layout {
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 );
remove_action( 'generate_after_header', 'generate_menu_plus_mobile_header', 5 );
}
if ( $this->disable_secondary_navigation ) {
@ -201,12 +311,49 @@ class GeneratePress_Site_Layout {
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' );
}
}
}
/**
* 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 ( 'full-width' === $this->content_area ) {
$admin_css .= 'body .wp-block{max-width: 100%}';
}
if ( $this->content_area ) {
$admin_css .= '#generate-layout-page-builder-container {opacity: 0.5;pointer-events: none;}';
}
if ( $this->disable_content_title ) {
$admin_css .= '.content-title-visibility{display: none !important;}label[for="meta-generate-disable-headline"] {opacity: 0.5;pointer-events: none;}';
}
if ( $this->content_width ) {
$admin_css .= 'body .wp-block{max-width: ' . absint( $this->content_width ) . 'px;}';
}
if ( $admin_css ) {
wp_add_inline_style( 'generate-block-editor-styles', $admin_css );
}
}
}
/**
@ -235,6 +382,42 @@ class GeneratePress_Site_Layout {
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.
*
@ -243,7 +426,7 @@ class GeneratePress_Site_Layout {
public function filter_options() {
$filter = current_filter();
if ( 'generate_sidebar_layout' === $filter ) {
if ( 'generate_sidebar_layout' === $filter || 'generate_block_editor_sidebar_layout' === $filter ) {
return $this->sidebar_layout;
}
@ -261,8 +444,8 @@ class GeneratePress_Site_Layout {
*
* @since 1.7
*
* @param bool $has_nav_menu
* @param string $location
* @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 ) {

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,17 @@
<?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.
@ -20,7 +29,7 @@ class GeneratePress_Elements_Post_Type {
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self;
self::$instance = new self();
}
return self::$instance;
@ -35,12 +44,15 @@ class GeneratePress_Elements_Post_Type {
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_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();
}
@ -66,19 +78,20 @@ class GeneratePress_Elements_Post_Type {
'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' ),
'featured_image' => __( 'Background Image', 'gp-premium' ),
'set_featured_image' => __( 'Set background image', 'gp-premium' ),
'remove_featured_image' => __( 'Remove background image', 'gp-premium' ),
);
$args = array(
'labels' => $labels,
'supports' => array( 'title', 'thumbnail' ),
'supports' => array( 'title', 'editor', 'thumbnail' ),
'hierarchical' => false,
'public' => false,
'show_ui' => true,
@ -86,11 +99,66 @@ class GeneratePress_Elements_Post_Type {
'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;
}
if ( 'block' === $type ) {
$args['supports'] = array( 'title', 'editor' );
}
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.
*
@ -133,6 +201,7 @@ class GeneratePress_Elements_Post_Type {
}
$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' ),
@ -142,15 +211,16 @@ class GeneratePress_Elements_Post_Type {
<select name="gp_element_type_filter">
<option value=""><?php esc_html_e( 'All types', 'gp-premium' ); ?></option>
<?php
$current = isset( $_GET['gp_element_type_filter'] )? esc_html( $_GET['gp_element_type_filter'] ) : '';
foreach ( $values as $value => $label ) {
printf(
'<option value="%1$s" %2$s>%3$s</option>',
esc_html( $value ),
$value === $current ? 'selected="selected"' : '',
$label
);
}
$current = isset( $_GET['gp_element_type_filter'] )? esc_html( $_GET['gp_element_type_filter'] ) : ''; // phpcs:ignore -- No processing happening.
foreach ( $values as $value => $label ) {
printf(
'<option value="%1$s" %2$s>%3$s</option>',
esc_html( $value ),
$value === $current ? 'selected="selected"' : '',
esc_html( $label )
);
}
?>
</select>
<?php
@ -164,13 +234,14 @@ class GeneratePress_Elements_Post_Type {
* @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'] : '';
$type = isset( $_GET['gp_element_type_filter'] ) ? $_GET['gp_element_type_filter'] : ''; // phpcs:ignore -- No processing happening.
if ( 'edit.php' === $pagenow && $query->is_main_query() && '' !== $type ) {
$query->set( 'meta_key', '_generate_element_type' );
@ -184,12 +255,28 @@ class GeneratePress_Elements_Post_Type {
* @since 1.7
*
* @param string $column The name of the column.
* @param int $post_id The ID of the post row.
* @param int $post_id The ID of the post row.
*/
public function add_columns( $column, $post_id ) {
switch ( $column ) {
case 'element_type' :
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( str_replace( '-', ' ', ucfirst( $block_type ) ) );
if ( 'hook' === $block_type && $hook_location ) {
echo '<br />';
echo '<span class="hook-location">' . esc_html( $hook_location ) . '</span>';
}
}
}
if ( 'header' === $type ) {
echo esc_html__( 'Header', 'gp-premium' );
@ -197,50 +284,57 @@ class GeneratePress_Elements_Post_Type {
if ( 'hook' === $type ) {
echo esc_html__( 'Hook', 'gp-premium' );
if ( $hook_location ) {
echo '<br />';
echo '<span class="hook-location">' . esc_html( $hook_location ) . '</span>';
}
}
if ( 'layout' === $type ) {
echo esc_html__( 'Layout', 'gp-premium' );
}
break;
break;
case 'location' :
case 'location':
$location = get_post_meta( $post_id, '_generate_element_display_conditions', true );
if ( $location ) {
foreach ( ( array ) $location as $data ) {
echo GeneratePress_Conditions::get_saved_label( $data );
foreach ( (array) $location as $data ) {
echo esc_html( GeneratePress_Conditions::get_saved_label( $data ) );
echo '<br />';
}
} else {
echo esc_html__( 'Not set', 'gp-premium' );
}
break;
break;
case 'exclusions' :
case 'exclusions':
$location = get_post_meta( $post_id, '_generate_element_exclude_conditions', true );
if ( $location ) {
foreach ( ( array ) $location as $data ) {
echo GeneratePress_Conditions::get_saved_label( $data );
foreach ( (array) $location as $data ) {
echo esc_html( GeneratePress_Conditions::get_saved_label( $data ) );
echo '<br />';
}
}
break;
break;
case 'users' :
case 'users':
$users = get_post_meta( $post_id, '_generate_element_user_conditions', true );
if ( $users ) {
foreach ( ( array ) $users as $data ) {
if ( strpos( $data, ':' ) !== FALSE ) {
foreach ( (array) $users as $data ) {
if ( strpos( $data, ':' ) !== false ) {
$data = substr( $data, strpos( $data, ':' ) + 1 );
}
$return = ucwords( str_replace( '_', ' ', $data ) );
echo $return . '<br />';
echo esc_html( $return ) . '<br />';
}
}
break;
break;
}
}
@ -268,8 +362,71 @@ class GeneratePress_Elements_Post_Type {
global $parent_file, $submenu_file, $post_type;
if ( 'gp_elements' === $post_type ) {
$parent_file = 'themes.php';
$submenu_file = 'edit.php?post_type=gp_elements';
$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="header"><?php esc_attr_e( 'Header', '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>
</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
}
}
}

View File

@ -1,16 +1,28 @@
<?php
/**
* This file sets up our Elements module.
*
* @since 1.7.0
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
require plugin_dir_path( __FILE__ ) . 'class-elements-helper.php';
require plugin_dir_path( __FILE__ ) . 'class-hooks.php';
require plugin_dir_path( __FILE__ ) . 'class-hero.php';
require plugin_dir_path( __FILE__ ) . 'class-layout.php';
require plugin_dir_path( __FILE__ ) . 'class-conditions.php';
require plugin_dir_path( __FILE__ ) . 'class-post-type.php';
$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-post-type.php';
add_action( 'wp', 'generate_premium_do_elements' );
add_action( 'current_screen', 'generate_premium_do_elements' );
/**
* Execute our Elements.
*
@ -18,20 +30,15 @@ add_action( 'wp', 'generate_premium_do_elements' );
*/
function generate_premium_do_elements() {
$args = array(
'post_type' => 'gp_elements',
'no_found_rows' => true,
'post_status' => 'publish',
'numberposts' => 500,
'fields' => 'ids',
'suppress_filters' => false,
'post_type' => 'gp_elements',
'no_found_rows' => true,
'post_status' => 'publish',
'numberposts' => 500, // phpcs:ignore
'fields' => 'ids',
'order' => 'ASC',
'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'] = '';
@ -54,6 +61,10 @@ function generate_premium_do_elements() {
if ( 'layout' === $type ) {
new GeneratePress_Site_Layout( $post_id );
}
if ( 'block' === $type ) {
new GeneratePress_Block_Element( $post_id );
}
}
}
@ -83,7 +94,7 @@ add_filter( 'generate_element_post_id', 'generate_elements_ignore_languages' );
*
* @since 1.8
*
* @param int $post_id
* @param int $post_id The current post ID.
* @return bool|int
*/
function generate_elements_ignore_languages( $post_id ) {
@ -95,10 +106,77 @@ function generate_elements_ignore_languages( $post_id ) {
return $post_id;
}
if ( $language && $language !== pll_current_language( 'locale' ) ) {
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;
}

View File

@ -0,0 +1,451 @@
<?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(), null ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
// 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;
}
global $wp_filesystem;
// Initialize the WordPress filesystem.
if ( empty( $wp_filesystem ) ) {
require_once ABSPATH . '/wp-admin/includes/file.php';
WP_Filesystem();
}
// 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 );
$mapped_domain = str_replace( 'https://', '//', $domain_mapping );
$mapped_domain = str_replace( 'http://', '//', $mapped_domain );
$original_domain = get_original_url( 'siteurl' );
$original_domain = str_replace( 'https://', '//', $original_domain );
$original_domain = str_replace( 'http://', '//', $original_domain );
$content = str_replace( $original_domain, $mapped_domain, $content );
}
}
// Strip protocols.
$content = str_replace( 'https://', '//', $content );
$content = str_replace( 'http://', '//', $content );
if ( is_writable( $this->file( 'path' ) ) || ( ! file_exists( $this->file( 'path' ) ) && is_writable( dirname( $this->file( 'path' ) ) ) ) ) {
if ( ! $wp_filesystem->put_contents( $this->file( 'path' ), wp_strip_all_tags( $content ), FS_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_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_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 );
}
}
// Strip protocols.
$css_uri = str_replace( 'https://', '//', $css_uri );
$css_uri = str_replace( 'http://', '//', $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();

View File

@ -1,7 +1,12 @@
<?php
// No direct access, please
/**
* This file handles SVG icons.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
exit; // No direct access, please.
}
add_action( 'wp_enqueue_scripts', 'generate_enqueue_premium_icons' );
@ -21,6 +26,8 @@ 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 = '';

View File

@ -1,7 +1,12 @@
<?php
// No direct access, please
/**
* This file handles the smooth scroll functionality.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
exit; // No direct access, please.
}
add_action( 'wp_enqueue_scripts', 'generate_smooth_scroll_scripts' );
@ -32,11 +37,14 @@ function generate_smooth_scroll_scripts() {
'generate-smooth-scroll',
'smooth',
array(
'elements' => apply_filters( 'generate_smooth_scroll_elements', array(
'.smooth-scroll',
'li.smooth-scroll a',
) ),
'duration' => apply_filters( 'generate_smooth_scroll_duration', 800 )
'elements' => apply_filters(
'generate_smooth_scroll_elements',
array(
'.smooth-scroll',
'li.smooth-scroll a',
)
),
'duration' => apply_filters( 'generate_smooth_scroll_duration', 800 ),
)
);
}
@ -78,7 +86,7 @@ function generate_smooth_scroll_customizer( $wp_customize ) {
array(
'default' => $defaults['smooth_scroll'],
'type' => 'option',
'sanitize_callback' => 'generate_premium_sanitize_checkbox'
'sanitize_callback' => 'generate_premium_sanitize_checkbox',
)
);

View File

@ -1,41 +1,42 @@
<?php
/*
Plugin Name: GP Premium
Plugin URI: https://generatepress.com
Description: The entire collection of GeneratePress premium modules.
Version: 1.10.0
Author: Tom Usborne
Author URI: https://generatepress.com
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: gp-premium
*/
/**
* Plugin Name: GP Premium
* Plugin URI: https://generatepress.com
* Description: The entire collection of GeneratePress premium modules.
* Version: 1.11.2
* Author: Tom Usborne
* Author URI: https://generatepress.com
* License: GNU General Public License v2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: gp-premium
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
// Set our version
define( 'GP_PREMIUM_VERSION', '1.10.0' );
// Set our library directory
define( 'GP_PREMIUM_VERSION', '1.11.2' );
define( 'GP_PREMIUM_DIR_PATH', plugin_dir_path( __FILE__ ) );
define( 'GP_LIBRARY_DIRECTORY', plugin_dir_path( __FILE__ ) . 'library/' );
define( 'GP_LIBRARY_DIRECTORY_URL', plugin_dir_url( __FILE__ ) . 'library/' );
if ( ! function_exists( 'generatepress_is_module_active' ) ) {
/**
* Check to see if an add-ons is active
* module: Check the database entry
* definition: Check to see if defined in wp-config.php
* Checks if a module is active.
*
* @param string $module The option name to check.
* @param string $constant The constant to check for.
**/
function generatepress_is_module_active( $module, $definition ) {
// If we don't have the module or definition, bail.
if ( ! $module && ! $definition ) {
function generatepress_is_module_active( $module, $constant ) {
// If we don't have the module or constant, bail.
if ( ! $module && ! $constant ) {
return false;
}
// If our module is active, return true.
if ( 'activated' == get_option( $module ) || defined( $definition ) ) {
if ( 'activated' === get_option( $module ) || defined( $constant ) ) {
return true;
}
@ -54,98 +55,83 @@ if ( ! function_exists( 'generate_package_setup' ) ) {
}
}
// Backgrounds
if ( generatepress_is_module_active( 'generate_package_backgrounds', 'GENERATE_BACKGROUNDS' ) ) {
require_once plugin_dir_path( __FILE__ ) . 'backgrounds/generate-backgrounds.php';
require_once GP_PREMIUM_DIR_PATH . 'backgrounds/generate-backgrounds.php';
}
// Blog
if ( generatepress_is_module_active( 'generate_package_blog', 'GENERATE_BLOG' ) ) {
require_once plugin_dir_path( __FILE__ ) . 'blog/generate-blog.php';
require_once GP_PREMIUM_DIR_PATH . 'blog/generate-blog.php';
}
// Colors
if ( generatepress_is_module_active( 'generate_package_colors', 'GENERATE_COLORS' ) ) {
require_once plugin_dir_path( __FILE__ ) . 'colors/generate-colors.php';
require_once GP_PREMIUM_DIR_PATH . 'colors/generate-colors.php';
}
// Copyright
if ( generatepress_is_module_active( 'generate_package_copyright', 'GENERATE_COPYRIGHT' ) ) {
require_once plugin_dir_path( __FILE__ ) . 'copyright/generate-copyright.php';
require_once GP_PREMIUM_DIR_PATH . 'copyright/generate-copyright.php';
}
// Disable Elements
if ( generatepress_is_module_active( 'generate_package_disable_elements', 'GENERATE_DISABLE_ELEMENTS' ) ) {
require_once plugin_dir_path( __FILE__ ) . 'disable-elements/generate-disable-elements.php';
require_once GP_PREMIUM_DIR_PATH . 'disable-elements/generate-disable-elements.php';
}
// Elements
if ( generatepress_is_module_active( 'generate_package_elements', 'GENERATE_ELEMENTS' ) ) {
require_once plugin_dir_path( __FILE__ ) . 'elements/elements.php';
require_once GP_PREMIUM_DIR_PATH . 'elements/elements.php';
}
// Hooks
if ( generatepress_is_module_active( 'generate_package_hooks', 'GENERATE_HOOKS' ) ) {
require_once plugin_dir_path( __FILE__ ) . 'hooks/generate-hooks.php';
require_once GP_PREMIUM_DIR_PATH . 'hooks/generate-hooks.php';
}
// Page Header
if ( generatepress_is_module_active( 'generate_package_page_header', 'GENERATE_PAGE_HEADER' ) ) {
require_once plugin_dir_path( __FILE__ ) . 'page-header/generate-page-header.php';
require_once GP_PREMIUM_DIR_PATH . 'page-header/generate-page-header.php';
}
// Secondary Navigation
if ( generatepress_is_module_active( 'generate_package_secondary_nav', 'GENERATE_SECONDARY_NAV' ) ) {
require_once plugin_dir_path( __FILE__ ) . 'secondary-nav/generate-secondary-nav.php';
require_once GP_PREMIUM_DIR_PATH . 'secondary-nav/generate-secondary-nav.php';
}
// Spacing
if ( generatepress_is_module_active( 'generate_package_spacing', 'GENERATE_SPACING' ) ) {
require_once plugin_dir_path( __FILE__ ) . 'spacing/generate-spacing.php';
require_once GP_PREMIUM_DIR_PATH . 'spacing/generate-spacing.php';
}
// Typography
if ( generatepress_is_module_active( 'generate_package_typography', 'GENERATE_TYPOGRAPHY' ) ) {
require_once plugin_dir_path( __FILE__ ) . 'typography/generate-fonts.php';
require_once GP_PREMIUM_DIR_PATH . 'typography/generate-fonts.php';
}
// Sections
if ( generatepress_is_module_active( 'generate_package_sections', 'GENERATE_SECTIONS' ) ) {
require_once plugin_dir_path( __FILE__ ) . 'sections/generate-sections.php';
require_once GP_PREMIUM_DIR_PATH . 'sections/generate-sections.php';
}
// Menu Plus
if ( generatepress_is_module_active( 'generate_package_menu_plus', 'GENERATE_MENU_PLUS' ) ) {
require_once plugin_dir_path( __FILE__ ) . 'menu-plus/generate-menu-plus.php';
require_once GP_PREMIUM_DIR_PATH . 'menu-plus/generate-menu-plus.php';
}
// WooCommerce
if ( generatepress_is_module_active( 'generate_package_woocommerce', 'GENERATE_WOOCOMMERCE' ) ) {
include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
include_once ABSPATH . 'wp-admin/includes/plugin.php';
if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
require_once plugin_dir_path( __FILE__ ) . 'woocommerce/woocommerce.php';
require_once GP_PREMIUM_DIR_PATH . 'woocommerce/woocommerce.php';
}
}
// General
require_once plugin_dir_path( __FILE__ ) . 'inc/functions.php';
require_once plugin_dir_path( __FILE__ ) . 'general/smooth-scroll.php';
require_once plugin_dir_path( __FILE__ ) . 'general/icons.php';
// General functionality.
require_once GP_PREMIUM_DIR_PATH . 'inc/functions.php';
require_once GP_PREMIUM_DIR_PATH . 'general/class-external-file-css.php';
require_once GP_PREMIUM_DIR_PATH . 'general/smooth-scroll.php';
require_once GP_PREMIUM_DIR_PATH . 'general/icons.php';
require_once GP_PREMIUM_DIR_PATH . 'inc/deprecated.php';
// Deprecated functions.
require_once plugin_dir_path( __FILE__ ) . 'inc/deprecated.php';
// Load admin-only files.
if ( is_admin() ) {
require_once plugin_dir_path( __FILE__ ) . 'inc/reset.php';
require_once plugin_dir_path( __FILE__ ) . 'import-export/generate-ie.php';
require_once GP_PREMIUM_DIR_PATH . 'inc/reset.php';
require_once GP_PREMIUM_DIR_PATH . 'import-export/generate-ie.php';
if ( generatepress_is_module_active( 'generate_package_site_library', 'GENERATE_SITE_LIBRARY' ) && version_compare( PHP_VERSION, '5.4', '>=' ) && ! defined( 'GENERATE_DISABLE_SITE_LIBRARY' ) ) {
require_once plugin_dir_path( __FILE__ ) . 'sites/sites.php';
require_once GP_PREMIUM_DIR_PATH . 'sites/sites.php';
}
require_once plugin_dir_path( __FILE__ ) . 'inc/activation.php';
require_once plugin_dir_path( __FILE__ ) . 'inc/dashboard.php';
require_once GP_PREMIUM_DIR_PATH . 'inc/activation.php';
require_once GP_PREMIUM_DIR_PATH . 'inc/dashboard.php';
}
if ( ! function_exists( 'generate_premium_updater' ) ) {
@ -154,22 +140,22 @@ if ( ! function_exists( 'generate_premium_updater' ) ) {
* Set up the updater
**/
function generate_premium_updater() {
// Load EDD SL Plugin Updater
if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) {
include( dirname( __FILE__ ) . '/library/EDD_SL_Plugin_Updater.php' );
include GP_PREMIUM_DIR_PATH . 'library/EDD_SL_Plugin_Updater.php';
}
// retrieve our license key from the DB
$license_key = get_option( 'gen_premium_license_key' );
// setup the updater
$edd_updater = new EDD_SL_Plugin_Updater( 'https://generatepress.com', __FILE__, array(
'version' => GP_PREMIUM_VERSION,
'license' => trim( $license_key ),
$edd_updater = new EDD_SL_Plugin_Updater(
'https://generatepress.com',
__FILE__,
array(
'version' => GP_PREMIUM_VERSION,
'license' => trim( $license_key ),
'item_name' => 'GP Premium',
'author' => 'Tom Usborne',
'author' => 'Tom Usborne',
'url' => home_url(),
'beta' => apply_filters( 'generate_premium_beta_tester', false ),
'beta' => apply_filters( 'generate_premium_beta_tester', false ),
)
);
}
@ -196,15 +182,12 @@ if ( ! function_exists( 'generate_premium_theme_information' ) ) {
* @since 1.2.95
**/
function generate_premium_theme_information() {
// Get our theme data
$theme = wp_get_theme();
// If we're using GeneratePress
if ( 'GeneratePress' == $theme->name || 'generatepress' == $theme->template ) {
if ( 'GeneratePress' === $theme->name || 'generatepress' === $theme->template ) {
// Get our information on updates
// Taken from https://developer.wordpress.org/reference/functions/wp_prepare_themes_for_js/
// Get our information on updates.
// @see https://developer.wordpress.org/reference/functions/wp_prepare_themes_for_js/.
$updates = array();
if ( current_user_can( 'update_themes' ) ) {
$updates_transient = get_site_transient( 'update_themes' );
@ -213,13 +196,11 @@ if ( ! function_exists( 'generate_premium_theme_information' ) ) {
}
}
// Check what admin page we're on
$screen = get_current_screen();
// If a GeneratePress update exists, and we're not on the themes page.
// No need to tell people an update exists on the themes page, WP does that for us.
if ( isset( $updates[ 'generatepress' ] ) && 'themes' !== $screen->base ) {
if ( isset( $updates['generatepress'] ) && 'themes' !== $screen->base ) {
printf(
'<div class="notice is-dismissible notice-info">
<p>%1$s <a href="%2$s">%3$s</a></p>
@ -228,11 +209,8 @@ if ( ! function_exists( 'generate_premium_theme_information' ) ) {
esc_url( admin_url( 'themes.php' ) ),
esc_html__( 'Update now.', 'gp-premium' )
);
}
} else {
// GeneratePress isn't the active theme, let them know GP Premium won't work.
printf(
'<div class="notice is-dismissible notice-warning">
@ -241,7 +219,6 @@ if ( ! function_exists( 'generate_premium_theme_information' ) ) {
esc_html__( 'GP Premium requires GeneratePress to be your active theme.', 'gp-premium' ),
esc_html__( 'Install now.', 'gp-premium' )
);
}
}
@ -252,9 +229,11 @@ add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'generate_add_
* Show a "Configure" link in the plugin action links.
*
* @since 1.3
* @param array $links The existing plugin row links.
*/
function generate_add_configure_action_link( $links ) {
$configuration_link = '<a href="' . admin_url( 'themes.php?page=generate-options' ) . '">' . __( 'Configure', 'gp-premium' ) . '</a>';
return array_merge( $links, array( $configuration_link ) );
}
@ -278,7 +257,7 @@ function generatepress_deactivate_standalone_addons() {
'generate-secondary-nav/generate-secondary-nav.php',
'generate-sections/generate-sections.php',
'generate-spacing/generate-spacing.php',
'generate-typography/generate-fonts.php'
'generate-typography/generate-fonts.php',
);
deactivate_plugins( $addons );

View File

@ -4,8 +4,6 @@
background: #FFF;
display: block;
width: 100%;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
margin-bottom: 0;
}
@ -19,12 +17,7 @@
display: block;
max-width: 100%;
border: 1px solid #e5e5e5;
-moz-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}

View File

@ -1,13 +1,21 @@
<?php
// No direct access, please
/**
* This file handles the legacy hook system.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
exit; // No direct access, please.
}
// Add any necessary files
// Add any necessary files.
require plugin_dir_path( __FILE__ ) . 'hooks.php';
if ( ! function_exists( 'generate_hooks_get_hooks' ) ) {
/**
* Get our list of hooks.
*/
function generate_hooks_get_hooks() {
$hooks = array(
'generate_wp_head_php',
@ -45,7 +53,7 @@ if ( ! function_exists( 'generate_hooks_get_hooks' ) ) {
'generate_after_footer_content_php',
'generate_after_footer_content',
'generate_wp_footer_php',
'generate_wp_footer'
'generate_wp_footer',
);
return $hooks;
@ -407,7 +415,7 @@ if ( ! class_exists( 'Generate_Hooks_Settings' ) ) {
}
$html .= '</select>';
$html .= '<p style="padding:0;margin:13px 0 0 0;" class="submit">';
$html .= '<input name="Submit" type="submit" class="button-primary" value="' . esc_attr( __( 'Save Hooks' , 'generate-hooks' ) ) . '" />';
$html .= '<input name="Submit" type="submit" class="button-primary" value="' . esc_attr( __( 'Save Hooks', 'gp-premium' ) ) . '" />';
$html .= '</p>';
$html .= '</div>';
$html .= '</div>';

View File

@ -1,19 +1,21 @@
<?php
/*
Addon Name: Generate Hooks
Author: Thomas Usborne
Author URI: http://edge22.com
*/
/**
* The legacy hooks module.
*
* @since 1.0.0
* @deprecated 1.7.0
*
* @package GP Premium
*/
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
exit; // No direct access, please.
}
// Define the version
// Define the version.
if ( ! defined( 'GENERATE_HOOKS_VERSION' ) ) {
define( 'GENERATE_HOOKS_VERSION', GP_PREMIUM_VERSION );
}
// Include functions identical between standalone addon and GP Premium
// Include functions identical between standalone addon and GP Premium.
require plugin_dir_path( __FILE__ ) . 'functions/functions.php';

View File

@ -1,8 +1,17 @@
<?php
/**
* This file handles the import/export functionality.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
/**
* Import/export class.
*/
class GeneratePress_Import_Export {
/**
* Instance.
@ -21,7 +30,7 @@ class GeneratePress_Import_Export {
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self;
self::$instance = new self();
}
return self::$instance;
@ -33,9 +42,9 @@ class GeneratePress_Import_Export {
* @since 1.7
*/
public function __construct() {
add_action( 'generate_admin_right_panel', array( $this, 'build_html' ), 15 );
add_action( 'admin_init', array( $this, 'export' ) );
add_action( 'admin_init', array( $this, 'import' ) );
add_action( 'generate_admin_right_panel', array( $this, 'build_html' ), 15 );
add_action( 'admin_init', array( $this, 'export' ) );
add_action( 'admin_init', array( $this, 'import' ) );
}
/**
@ -46,9 +55,10 @@ class GeneratePress_Import_Export {
public static function build_html() {
?>
<div class="postbox generate-metabox" id="generate-ie">
<h3 class="hndle"><?php _e( 'Export Settings', 'gp-premium' );?></h3>
<h3 class="hndle"><?php esc_html_e( 'Import/Export', 'gp-premium' ); ?></h3>
<div class="inside">
<form method="post">
<h3 style="font-size: 15px;"><?php esc_html_e( 'Export', 'gp-premium' ); ?></h3>
<span class="show-advanced"><?php _e( 'Advanced', 'gp-premium' ); ?></span>
<div class="export-choices advanced-choices">
<label>
@ -127,12 +137,8 @@ class GeneratePress_Import_Export {
<?php submit_button( __( 'Export', 'gp-premium' ), 'button-primary', 'submit', false, array( 'id' => '' ) ); ?>
</p>
</form>
</div>
</div>
<div class="postbox generate-metabox" id="generate-ie">
<h3 class="hndle"><?php _e( 'Import Settings', 'gp-premium' );?></h3>
<div class="inside">
<h3 style="font-size: 15px;margin-top: 30px;"><?php esc_html_e( 'Import', 'gp-premium' ); ?></h3>
<form method="post" enctype="multipart/form-data">
<p>
<input type="file" name="import_file"/>
@ -143,7 +149,6 @@ class GeneratePress_Import_Export {
<?php submit_button( __( 'Import', 'gp-premium' ), 'button-primary', 'submit', false, array( 'id' => '' ) ); ?>
</p>
</form>
</div>
</div>
<?php
@ -155,7 +160,7 @@ class GeneratePress_Import_Export {
* @since 1.7
*/
public static function export() {
if ( empty( $_POST['generate_action'] ) || 'export_settings' != $_POST['generate_action'] ) {
if ( empty( $_POST['generate_action'] ) || 'export_settings' !== $_POST['generate_action'] ) {
return;
}
@ -174,30 +179,30 @@ class GeneratePress_Import_Export {
$data = array(
'modules' => array(),
'mods' => array(),
'options' => array()
'options' => array(),
);
foreach ( $modules as $name => $value ) {
if ( 'activated' === get_option( $value ) ) {
$data['modules'][$name] = $value;
$data['modules'][ $name ] = $value;
}
}
foreach ( $theme_mods as $theme_mod ) {
if ( 'generate_copyright' == $theme_mod ) {
if ( 'generate_copyright' === $theme_mod ) {
if ( in_array( 'copyright', $_POST['module_group'] ) ) {
$data['mods'][$theme_mod] = get_theme_mod( $theme_mod );
$data['mods'][ $theme_mod ] = get_theme_mod( $theme_mod );
}
} else {
if ( in_array( 'generate_settings', $_POST['module_group'] ) ) {
$data['mods'][$theme_mod] = get_theme_mod( $theme_mod );
$data['mods'][ $theme_mod ] = get_theme_mod( $theme_mod );
}
}
}
foreach ( $settings as $setting ) {
if ( in_array( $setting, $_POST['module_group'] ) ) {
$data['options'][$setting] = get_option( $setting );
$data['options'][ $setting ] = get_option( $setting );
}
}
@ -205,10 +210,10 @@ class GeneratePress_Import_Export {
nocache_headers();
header( 'Content-Type: application/json; charset=utf-8' );
header( 'Content-Disposition: attachment; filename=generate-settings-export-' . date( 'm-d-Y' ) . '.json' );
header( "Expires: 0" );
header( 'Content-Disposition: attachment; filename=generate-settings-export-' . date( 'm-d-Y' ) . '.json' ); // phpcs:ignore -- Prefer date().
header( 'Expires: 0' );
echo json_encode( $data );
echo wp_json_encode( $data );
exit;
}
@ -218,7 +223,7 @@ class GeneratePress_Import_Export {
* @since 1.7
*/
public static function import() {
if ( empty( $_POST['generate_action'] ) || 'import_settings' != $_POST['generate_action'] ) {
if ( empty( $_POST['generate_action'] ) || 'import_settings' !== $_POST['generate_action'] ) {
return;
}
@ -233,7 +238,7 @@ class GeneratePress_Import_Export {
$filename = $_FILES['import_file']['name'];
$extension = end( explode( '.', $_FILES['import_file']['name'] ) );
if ( $extension != 'json' ) {
if ( 'json' !== $extension ) {
wp_die( __( 'Please upload a valid .json file', 'gp-premium' ) );
}
@ -244,30 +249,38 @@ class GeneratePress_Import_Export {
}
// Retrieve the settings from the file and convert the json object to an array.
$settings = json_decode( file_get_contents( $import_file ), true );
$settings = json_decode( file_get_contents( $import_file ), true ); // phpcs:ignore -- file_get_contents() is fine here.
foreach ( ( array ) $settings['modules'] as $key => $val ) {
foreach ( (array) $settings['modules'] as $key => $val ) {
if ( in_array( $val, self::get_modules() ) ) {
update_option( $val, 'activated' );
}
}
foreach ( ( array ) $settings['mods'] as $key => $val ) {
foreach ( (array) $settings['mods'] as $key => $val ) {
if ( in_array( $key, self::get_theme_mods() ) ) {
set_theme_mod( $key, $val );
}
}
foreach ( ( array ) $settings['options'] as $key => $val ) {
foreach ( (array) $settings['options'] as $key => $val ) {
if ( in_array( $key, self::get_settings() ) ) {
update_option( $key, $val );
}
}
// Delete existing dynamic CSS cache
// Delete existing dynamic CSS cache.
delete_option( 'generate_dynamic_css_output' );
delete_option( 'generate_dynamic_css_cached_version' );
$dynamic_css_data = get_option( 'generatepress_dynamic_css_data', array() );
if ( isset( $dynamic_css_data['updated_time'] ) ) {
unset( $dynamic_css_data['updated_time'] );
}
update_option( 'generatepress_dynamic_css_data', $dynamic_css_data );
wp_safe_redirect( admin_url( 'admin.php?page=generate-options&status=imported' ) );
exit;
}

View File

@ -1,19 +1,20 @@
<?php
/*
Addon Name: Generate Import Export
Author: Thomas Usborne
Author URI: http://edge22.com
*/
/**
* Import/Export module.
*
* @since 1.1.0
*
* @package GP Premium
*/
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
exit; // No direct access, please.
}
// Define the version
// Define the version.
if ( ! defined( 'GENERATE_IE_VERSION' ) ) {
define( 'GENERATE_IE_VERSION', GP_PREMIUM_VERSION );
}
// Include functions identical between standalone addon and GP Premium
// Include functions identical between standalone addon and GP Premium.
require plugin_dir_path( __FILE__ ) . 'functions/functions.php';

View File

@ -153,7 +153,7 @@ if ( ! function_exists( 'generate_super_package_addons' ) ) {
</div>
<div class="addon-action addon-addon-action" style="text-align:right;">
<?php wp_nonce_field( $v . '_deactivate_nonce', $v . '_deactivate_nonce' ); ?>
<input type="submit" name="<?php echo $v;?>_deactivate_package" value="<?php _e( 'Deactivate' );?>"/>
<input type="submit" name="<?php echo $v;?>_deactivate_package" value="<?php _e( 'Deactivate', 'gp-premium' );?>"/>
</div>
</div>
<?php } else {
@ -173,7 +173,7 @@ if ( ! function_exists( 'generate_super_package_addons' ) ) {
<?php _e( 'WooCommerce not activated.','gp-premium' ); ?>
<?php } else { ?>
<?php wp_nonce_field( $v . '_activate_nonce', $v . '_activate_nonce' ); ?>
<input type="submit" name="<?php echo $v;?>_activate_package" value="<?php _e( 'Activate' );?>"/>
<input type="submit" name="<?php echo $v;?>_activate_package" value="<?php _e( 'Activate', 'gp-premium' );?>"/>
<?php } ?>
</div>

View File

@ -56,8 +56,6 @@ input#generate-select-all,
.premium-addons .add-on.gp-clear {
padding: 15px !important;
margin: 0 !important;
-moz-box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.1) inset;
-webkit-box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.1) inset;
box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.1) inset;
}
@ -89,8 +87,6 @@ input#generate-select-all,
padding: 0;
font-size: inherit;
cursor: pointer;
-moz-box-shadow: 0 0 0 transparent;
-webkit-box-shadow: 0 0 0 transparent;
box-shadow: 0 0 0 transparent;
}
@ -101,8 +97,6 @@ input#generate-select-all,
color: #0f92e5;
padding: 0;
font-size: inherit;
-moz-box-shadow: 0 0 0 transparent;
-webkit-box-shadow: 0 0 0 transparent;
box-shadow: 0 0 0 transparent;
}

View File

@ -365,6 +365,25 @@ if ( ! function_exists( 'generate_slideout_navigation_classes' ) ) {
}
}
if ( ! function_exists( 'generate_menu_plus_init' ) ) {
function generate_menu_plus_init() {
load_plugin_textdomain( 'menu-plus', false, 'gp-premium/langs/menu-plus/' );
}
}
if ( ! function_exists( 'generate_slideout_menu_fallback' ) ) {
/**
* Menu fallback.
*
* @param array $args
* @return string
* @since 1.1.4
*/
function generate_slideout_menu_fallback( $args ) {
}
}
/**
* Page header module.
*/
@ -436,6 +455,12 @@ if ( ! function_exists( 'generate_page_header_single' ) ) {
}
}
if ( ! function_exists( 'generate_page_header_init' ) ) {
function generate_page_header_init() {
load_plugin_textdomain( 'page-header', false, 'gp-premium/langs/page-header/' );
}
}
/**
* Secondary Navigation module.
*/
@ -661,3 +686,19 @@ function generate_menu_plus_make_css() {
function generate_menu_plus_enqueue_dynamic_css() {
// No longer needed.
}
if ( ! function_exists( 'generate_hidden_secondary_navigation' ) && function_exists( 'is_customize_preview' ) ) {
/**
* Adds a hidden navigation if no navigation is set
* This allows us to use postMessage to position the navigation when it doesn't exist
*/
function generate_hidden_secondary_navigation() {
if ( is_customize_preview() && function_exists( 'generate_secondary_navigation_position' ) ) {
?>
<div style="display:none;">
<?php generate_secondary_navigation_position(); ?>
</div>
<?php
}
}
}

View File

@ -1,8 +1,20 @@
<?php
/**
* This file handles general functions in the plugin.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
/**
* Get the requested media query.
*
* @since 1.9.0
* @param string $name Name of the media query.
*/
function generate_premium_get_media_query( $name ) {
if ( function_exists( 'generate_get_media_query' ) ) {
return generate_get_media_query( $name );
@ -14,12 +26,34 @@ function generate_premium_get_media_query( $name ) {
$mobile = apply_filters( 'generate_mobile_media_query', '(max-width:768px)' );
$mobile_menu = apply_filters( 'generate_mobile_menu_media_query', $mobile );
$queries = apply_filters( 'generate_media_queries', array(
'desktop' => $desktop,
'tablet' => $tablet,
'mobile' => $mobile,
'mobile-menu' => $mobile_menu,
) );
$queries = apply_filters(
'generate_media_queries',
array(
'desktop' => $desktop,
'tablet' => $tablet,
'mobile' => $mobile,
'mobile-menu' => $mobile_menu,
)
);
return $queries[ $name ];
}
}
/**
* Get our CSS print method.
*
* @since 1.11.0
*/
function generate_get_css_print_method() {
$mode = apply_filters( 'generatepress_dynamic_css_print_method', 'inline' );
if ( ( function_exists( 'is_customize_preview' ) && is_customize_preview() ) || is_preview() ) {
return 'inline';
}
if ( ! defined( 'GENERATE_VERSION' ) ) {
return 'inline';
}
return $mode;
}

View File

@ -1,15 +1,25 @@
<?php
defined( 'WPINC' ) or die;
/**
* This file handles resetting of options.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
add_action( 'generate_admin_right_panel', 'generate_premium_reset_metabox', 25 );
/**
* Add the reset options to the Dashboard.
*/
function generate_premium_reset_metabox() {
?>
<div class="postbox generate-metabox" id="generate-reset">
<h3 class="hndle"><?php _e( 'Reset Settings', 'gp-premium' );?></h3>
<h3 class="hndle"><?php esc_html_e( 'Reset Settings', 'gp-premium' ); ?></h3>
<div class="inside">
<form method="post">
<span class="show-advanced"><?php _e( 'Advanced', 'gp-premium' ); ?></span>
<span class="show-advanced"><?php esc_html_e( 'Advanced', 'gp-premium' ); ?></span>
<div class="reset-choices advanced-choices">
<label><input type="checkbox" name="module_group[]" value="generate_settings" checked /><?php _ex( 'Core', 'Module name', 'gp-premium' ); ?></label>
@ -47,7 +57,7 @@ function generate_premium_reset_metabox() {
<?php if ( generatepress_is_module_active( 'generate_package_copyright', 'GENERATE_COPYRIGHT' ) ) { ?>
<label><input type="checkbox" name="module_group[]" value="copyright" checked /><?php _ex( 'Copyright', 'Module name', 'gp-premium' ); ?></label>
<?php }?>
<?php } ?>
</div>
<p><input type="hidden" name="generate_reset_action" value="reset_settings" /></p>
<p style="margin-bottom:0">
@ -61,7 +71,7 @@ function generate_premium_reset_metabox() {
false,
array(
'onclick' => esc_js( $warning ),
'id' => '' ,
'id' => '',
)
);
?>
@ -73,9 +83,11 @@ function generate_premium_reset_metabox() {
}
add_action( 'admin_init', 'generate_premium_process_reset' );
/**
* Process the reset functions.
*/
function generate_premium_process_reset() {
if ( empty( $_POST['generate_reset_action'] ) || 'reset_settings' != $_POST['generate_reset_action'] ) {
if ( empty( $_POST['generate_reset_action'] ) || 'reset_settings' !== $_POST['generate_reset_action'] ) {
return;
}
@ -133,11 +145,11 @@ function generate_premium_process_reset() {
$data = array(
'mods' => array(),
'options' => array()
'options' => array(),
);
foreach ( $theme_mods as $theme_mod ) {
if ( 'generate_copyright' == $theme_mod ) {
if ( 'generate_copyright' === $theme_mod ) {
if ( in_array( 'copyright', $_POST['module_group'] ) ) {
remove_theme_mod( $theme_mod );
}
@ -154,13 +166,23 @@ function generate_premium_process_reset() {
}
}
// Delete our dynamic CSS option.
delete_option( 'generate_dynamic_css_output' );
delete_option( 'generate_dynamic_css_cached_version' );
// Reset our dynamic CSS file updated time so it regenerates.
$dynamic_css_data = get_option( 'generatepress_dynamic_css_data', array() );
if ( isset( $dynamic_css_data['updated_time'] ) ) {
unset( $dynamic_css_data['updated_time'] );
}
update_option( 'generatepress_dynamic_css_data', $dynamic_css_data );
// Delete any GeneratePress Site CSS in Additional CSS.
$additional_css = wp_get_custom_css_post();
if ( ! empty ( $additional_css ) ) {
if ( ! empty( $additional_css ) ) {
$additional_css->post_content = preg_replace( '#(/\\* GeneratePress Site CSS \\*/).*?(/\\* End GeneratePress Site CSS \\*/)#s', '', $additional_css->post_content );
wp_update_custom_css_post( $additional_css->post_content );
}
@ -170,7 +192,9 @@ function generate_premium_process_reset() {
}
add_action( 'admin_head', 'generate_reset_options_css', 100 );
/**
* Add CSS to the dashboard.
*/
function generate_reset_options_css() {
$screen = get_current_screen();
@ -223,7 +247,9 @@ function generate_reset_options_css() {
}
add_action( 'admin_footer', 'generate_reset_options_scripts', 100 );
/**
* Add scripts to the Dashboard.
*/
function generate_reset_options_scripts() {
$screen = get_current_screen();

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@ if ( ! defined( 'ABSPATH' ) ) exit;
* Allows plugins to use their own update API.
*
* @author Easy Digital Downloads
* @version 1.6.18
* @version 1.7.1
*/
class EDD_SL_Plugin_Updater {
@ -117,6 +117,7 @@ class EDD_SL_Plugin_Updater {
if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
$no_update = false;
if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
$_transient_data->response[ $this->name ] = $version_info;
@ -124,11 +125,25 @@ class EDD_SL_Plugin_Updater {
// Make sure the plugin property is set to the plugin's name/location. See issue 1463 on Software Licensing's GitHub repo.
$_transient_data->response[ $this->name ]->plugin = $this->name;
} else {
$no_update = new stdClass();
$no_update->id = '';
$no_update->slug = $this->slug;
$no_update->plugin = $this->name;
$no_update->new_version = $version_info->new_version;
$no_update->url = $version_info->homepage;
$no_update->package = $version_info->package;
$no_update->icons = $version_info->icons;
$no_update->banners = $version_info->banners;
$no_update->banners_rtl = array();
}
$_transient_data->last_checked = time();
$_transient_data->checked[ $this->name ] = $this->version;
if ( $no_update ) {
$_transient_data->no_update[ $this->name ] = $no_update;
}
}
return $_transient_data;
@ -185,6 +200,10 @@ class EDD_SL_Plugin_Updater {
$version_info->icons = $this->convert_object_to_array( $version_info->icons );
}
if ( isset( $version_info->contributors ) && ! is_array( $version_info->contributors ) ) {
$version_info->contributors = $this->convert_object_to_array( $version_info->contributors );
}
$this->set_version_info_cache( $version_info );
}
@ -192,14 +211,29 @@ class EDD_SL_Plugin_Updater {
return;
}
$no_update = false;
if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
$update_cache->response[ $this->name ] = $version_info;
} else {
$no_update = new stdClass();
$no_update->id = '';
$no_update->slug = $this->slug;
$no_update->plugin = $this->name;
$no_update->new_version = $version_info->new_version;
$no_update->url = $version_info->homepage;
$no_update->package = $version_info->package;
$no_update->icons = $version_info->icons;
$no_update->banners = $version_info->banners;
$no_update->banners_rtl = array();
}
$update_cache->last_checked = time();
$update_cache->last_checked = time();
$update_cache->checked[ $this->name ] = $this->version;
if ( $no_update ) {
$update_cache->no_update[ $this->name ] = $no_update;
}
set_site_transient( 'update_plugins', $update_cache );
@ -283,10 +317,8 @@ class EDD_SL_Plugin_Updater {
)
);
$cache_key = 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
// Get the transient where we store the api request for this plugin for 24 hours
$edd_api_request_transient = $this->get_cached_version_info( $cache_key );
$edd_api_request_transient = $this->get_cached_version_info();
//If we have no transient-saved value, run the API, set a fresh transient with the API value, and return that value too right now.
if ( empty( $edd_api_request_transient ) ) {
@ -294,7 +326,7 @@ class EDD_SL_Plugin_Updater {
$api_response = $this->api_request( 'plugin_information', $to_send );
// Expires in 3 hours
$this->set_version_info_cache( $api_response, $cache_key );
$this->set_version_info_cache( $api_response );
if ( false !== $api_response ) {
$_data = $api_response;
@ -319,6 +351,11 @@ class EDD_SL_Plugin_Updater {
$_data->icons = $this->convert_object_to_array( $_data->icons );
}
// Convert contributors into an associative array, since we're getting an object, but Core expects an array.
if ( isset( $_data->contributors ) && ! is_array( $_data->contributors ) ) {
$_data->contributors = $this->convert_object_to_array( $_data->contributors );
}
if( ! isset( $_data->plugin ) ) {
$_data->plugin = $this->name;
}
@ -341,7 +378,7 @@ class EDD_SL_Plugin_Updater {
private function convert_object_to_array( $data ) {
$new_data = array();
foreach ( $data as $key => $value ) {
$new_data[ $key ] = $value;
$new_data[ $key ] = is_object( $value ) ? $this->convert_object_to_array( $value ) : $value;
}
return $new_data;
@ -454,6 +491,9 @@ class EDD_SL_Plugin_Updater {
return $request;
}
/**
* If available, show the changelog for sites in a multisite install.
*/
public function show_changelog() {
global $edd_plugin_data;
@ -475,9 +515,7 @@ class EDD_SL_Plugin_Updater {
}
$data = $edd_plugin_data[ $_REQUEST['slug'] ];
$beta = ! empty( $data['beta'] ) ? true : false;
$cache_key = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_' . $beta . '_version_info' );
$version_info = $this->get_cached_version_info( $cache_key );
$version_info = $this->get_cached_version_info();
if( false === $version_info ) {
@ -498,7 +536,6 @@ class EDD_SL_Plugin_Updater {
$version_info = json_decode( wp_remote_retrieve_body( $request ) );
}
if ( ! empty( $version_info ) && isset( $version_info->sections ) ) {
$version_info->sections = maybe_unserialize( $version_info->sections );
} else {
@ -511,17 +548,28 @@ class EDD_SL_Plugin_Updater {
}
}
$this->set_version_info_cache( $version_info, $cache_key );
$this->set_version_info_cache( $version_info );
// Delete the unneeded option
delete_option( md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_' . $this->beta . '_version_info' ) );
}
if( ! empty( $version_info ) && isset( $version_info->sections['changelog'] ) ) {
echo '<div style="background:#fff;padding:10px;">' . $version_info->sections['changelog'] . '</div>';
if ( isset( $version_info->sections ) ) {
$sections = $this->convert_object_to_array( $version_info->sections );
if ( ! empty( $sections['changelog'] ) ) {
echo '<div style="background:#fff;padding:10px;">' . wp_kses_post( $sections['changelog'] ) . '</div>';
}
}
exit;
}
/**
* Gets the plugin's cached version information from the database.
*
* @param string $cache_key
* @return boolean|string
*/
public function get_cached_version_info( $cache_key = '' ) {
if( empty( $cache_key ) ) {
@ -544,6 +592,12 @@ class EDD_SL_Plugin_Updater {
}
/**
* Adds the plugin version information to the database.
*
* @param string $value
* @param string $cache_key
*/
public function set_version_info_cache( $value = '', $cache_key = '' ) {
if( empty( $cache_key ) ) {
@ -557,6 +611,8 @@ class EDD_SL_Plugin_Updater {
update_option( $cache_key, $data, 'no' );
// Delete the duplicate option
delete_option( 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) ) );
}
/**

View File

@ -582,3 +582,20 @@ function generate_premium_wc_menu_item_active() {
return true;
}
/**
* Checks to see if we're using external CSS file.
*
* @since 1.11.0
*/
function generate_is_using_external_css_file_callback() {
if ( ! function_exists( 'generate_get_option' ) ) {
return false;
}
if ( 'file' === generate_get_option( 'css_print_method' ) ) {
return true;
}
return false;
}

View File

@ -15,9 +15,11 @@ if ( ! class_exists( 'GeneratePress_Action_Button_Control' ) ) {
public $type = 'gp_action_button';
public $data_type = '';
public $description = '';
public $nonce = '';
public function enqueue() {
wp_enqueue_script( 'gp-button-actions', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/button-actions.js', array( 'customize-controls' ), GP_PREMIUM_VERSION, true );
wp_enqueue_script( 'gp-button-actions', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/button-actions.js', array( 'customize-controls' ), GP_PREMIUM_VERSION, true );
wp_enqueue_style( 'gp-button-actions', trailingslashit( plugin_dir_url( __FILE__ ) ) . 'css/button-actions.css', array(), GP_PREMIUM_VERSION );
}
public function to_json() {
@ -25,14 +27,17 @@ if ( ! class_exists( 'GeneratePress_Action_Button_Control' ) ) {
$this->json['data_type'] = $this->data_type;
$this->json['description'] = $this->description;
$this->json['nonce'] = $this->nonce;
}
public function content_template() {
?>
<button class="button" data-type="{{{ data.data_type }}}">{{{ data.label }}}</button>
<span class="description customize-control-description">
<p>{{{ data.description }}}</p>
</span>
<button class="button" data-type="{{{ data.data_type }}}" data-nonce="{{{ data.nonce }}}">{{{ data.label }}}</button>
<# if ( data.description ) { #>
<span class="description customize-control-description">
<p>{{{ data.description }}}</p>
</span>
<# } #>
<?php
}
}

View File

@ -34,8 +34,8 @@ class GeneratePress_Spacing_Control extends WP_Customize_Control {
}
$this->json[ 'element' ] = $this->element;
$this->json[ 'title' ] = __( 'Link values','generate-spacing' );
$this->json[ 'unlink_title' ] = __( 'Un-link values','generate-spacing' );
$this->json[ 'title' ] = __( 'Link values', 'gp-premium' );
$this->json[ 'unlink_title' ] = __( 'Un-link values', 'gp-premium' );
$this->json['label_top'] = esc_html__( 'Top', 'gp-premium' );
$this->json['label_right'] = esc_html__( 'Right', 'gp-premium' );

View File

@ -13,7 +13,6 @@
}
.alpha-color-picker-wrap a.iris-square-value:focus {
-webkit-box-shadow: none;
box-shadow: none;
}

View File

@ -0,0 +1,20 @@
button[data-type="regenerate_external_css"]:before {
font: normal 20px/.5 dashicons;
speak: none;
display: inline-block;
padding: 0;
top: 9px;
left: -4px;
position: relative;
vertical-align: top;
content: "\f463";
}
button[data-type="regenerate_external_css"].loading:before {
animation: rotation 1s infinite linear;
}
button[data-type="regenerate_external_css"].success:before {
content: "\f147";
color: #46b450;
}

View File

@ -4,8 +4,6 @@
height: 6px;
background-color: rgba(0,0,0,.10);
cursor: pointer;
-webkit-transition: background .5s;
-moz-transition: background .5s;
transition: background .5s;
}
@ -28,21 +26,14 @@
display: inline-block;
position: absolute;
top: 50%;
-webkit-transform: translateY(-50%) translateX(-4px);
transform: translateY(-50%) translateX(-4px);
border-radius: 50%;
cursor: pointer;
}
.customize-control-generatepress-pro-range-slider .wrapper {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: justify;
-ms-flex-pack: justify;
justify-content: space-between;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
@ -51,8 +42,6 @@
padding: 0;
font-weight: 400;
width: 50px;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
}
@ -126,8 +115,6 @@
}
.gp-range-title-area {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
}

View File

@ -1,6 +1,4 @@
.gp-spacing-control-section-title-area {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
}
@ -17,8 +15,6 @@
}
.spacing-values-area {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
}

View File

@ -3,11 +3,7 @@
}
.generatepress-weight-transform-wrapper {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: justify;
-ms-flex-pack: justify;
justify-content: space-between;
}

View File

@ -26,4 +26,19 @@ jQuery( document ).ready( function( $ ) {
}( wp.customize ) );
} );
$( '[data-type="regenerate_external_css"]' ).on( 'click', function( e ) {
var $thisButton = $( this ); // eslint-disable-line no-var
e.preventDefault();
$thisButton.removeClass( 'success' ).addClass( 'loading' );
$.post( ajaxurl, {
action: 'generatepress_regenerate_css_file',
_nonce: $thisButton.data( 'nonce' ),
} ).done( function() {
$thisButton.removeClass( 'loading' ).addClass( 'success' );
} );
} );
} );

View File

@ -19,36 +19,48 @@
headerTextColorSetting = api.instance( 'generate_settings[header_text_color]' ),
headerTextColor = gpControls.headerTextColor;
if ( ! siteTitleFontSizeSetting._dirty && 25 !== siteTitleFontSizeSetting.get() ) {
if ( siteTitleFontSizeSetting && ! siteTitleFontSizeSetting._dirty && 25 !== siteTitleFontSizeSetting.get() ) {
siteTitleFontSize = siteTitleFontSizeSetting.get();
}
if ( ! mobileSiteTitleFontSizeSetting._dirty && 20 !== mobileSiteTitleFontSizeSetting.get() ) {
if ( mobileSiteTitleFontSizeSetting && ! mobileSiteTitleFontSizeSetting._dirty && 20 !== mobileSiteTitleFontSizeSetting.get() ) {
mobileSiteTitleFontSize = mobileSiteTitleFontSizeSetting.get();
}
if ( ! navTextColorSetting._dirty ) {
if ( navTextColorSetting && ! navTextColorSetting._dirty ) {
navTextColor = navTextColorSetting.get();
}
if ( ! headerTextColorSetting._dirty ) {
if ( headerTextColorSetting && ! headerTextColorSetting._dirty ) {
headerTextColor = headerTextColorSetting.get();
}
if ( newval ) {
navAlignmentSetting.set( 'right' );
siteTitleFontSizeSetting.set( 25 );
api.instance( 'generate_settings[site_title_color]' ).set( navTextColor );
if ( 'enable' !== mobileHeader ) {
if ( siteTitleFontSizeSetting ) {
siteTitleFontSizeSetting.set( 25 );
}
if ( api.instance( 'generate_settings[site_title_color]' ) ) {
api.instance( 'generate_settings[site_title_color]' ).set( navTextColor );
}
if ( mobileSiteTitleFontSizeSetting && 'enable' !== mobileHeader ) {
mobileSiteTitleFontSizeSetting.set( 20 );
}
} else {
navAlignmentSetting.set( navAlignment );
siteTitleFontSizeSetting.set( siteTitleFontSize );
api.instance( 'generate_settings[site_title_color]' ).set( headerTextColor );
if ( 'enable' !== mobileHeader ) {
if ( siteTitleFontSizeSetting ) {
siteTitleFontSizeSetting.set( siteTitleFontSize );
}
if ( api.instance( 'generate_settings[site_title_color]' ) ) {
api.instance( 'generate_settings[site_title_color]' ).set( headerTextColor );
}
if ( mobileSiteTitleFontSizeSetting && 'enable' !== mobileHeader ) {
mobileSiteTitleFontSizeSetting.set( mobileSiteTitleFontSize );
}
}
@ -138,7 +150,7 @@
*/
api( 'generate_menu_plus_settings[mobile_header_branding]', function( value ) {
value.bind( function( newval ) {
if ( 'title' === newval ) {
if ( api.instance( 'generate_settings[mobile_site_title_font_size]' ) && 'title' === newval ) {
api.instance( 'generate_settings[mobile_site_title_font_size]' ).set( 20 );
}
} );
@ -154,14 +166,16 @@
var mobileSiteTitleFontSizeSetting = api.instance( 'generate_settings[mobile_site_title_font_size]' ),
mobileSiteTitleFontSize = gpControls.mobileSiteTitleFontSize;
if ( ! mobileSiteTitleFontSizeSetting._dirty && 20 !== mobileSiteTitleFontSizeSetting.get() ) {
if ( mobileSiteTitleFontSizeSetting && ! mobileSiteTitleFontSizeSetting._dirty && 20 !== mobileSiteTitleFontSizeSetting.get() ) {
mobileSiteTitleFontSize = mobileSiteTitleFontSizeSetting.get();
}
if ( 'enable' === newval ) {
api.instance( 'generate_settings[mobile_site_title_font_size]' ).set( 20 );
} else {
api.instance( 'generate_settings[mobile_site_title_font_size]' ).set( mobileSiteTitleFontSize );
if ( api.instance( 'generate_settings[mobile_site_title_font_size]' ) ) {
if ( 'enable' === newval ) {
api.instance( 'generate_settings[mobile_site_title_font_size]' ).set( 20 );
} else {
api.instance( 'generate_settings[mobile_site_title_font_size]' ).set( mobileSiteTitleFontSize );
}
}
} );
} );

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -2,9 +2,7 @@
float: left;
display: block;
margin-left: -10px;
-webkit-transition: height .3s ease;
-o-transition: height .3s ease;
transition: height .3s ease;
transition: height .3s ease;
opacity: 1;
}
@ -13,12 +11,8 @@
vertical-align:middle;
padding: 10px;
display: block;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
-webkit-transition: height .3s ease;
-o-transition: height .3s ease;
transition: height .3s ease;
transition: height .3s ease;
}
.nav-float-left .main-navigation .navigation-logo {

View File

@ -1 +1 @@
.main-navigation .navigation-logo,.main-navigation .navigation-logo img{display:block;-webkit-transition:height .3s ease;-o-transition:height .3s ease;transition:height .3s ease}.main-navigation .navigation-logo{float:left;margin-left:-10px;opacity:1}.main-navigation .navigation-logo img{position:relative;vertical-align:middle;padding:10px;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}.nav-float-left .main-navigation .navigation-logo{float:right;margin-left:0;margin-right:-10px}.regular-menu-logo .navigation-stick .navigation-logo,.sticky-menu-logo .main-navigation .navigation-logo{display:none!important}.sticky-menu-logo .navigation-stick:not(#sticky-placeholder) .navigation-logo{display:block!important}.main-navigation .inside-navigation:not(.grid-container) .navigation-logo,.main-navigation.grid-container .navigation-logo{margin-left:0}.gen-sidebar-nav .main-navigation .navigation-logo{float:none;padding:0;margin:30px 0!important;text-align:center}.gen-sidebar-nav .main-navigation .navigation-logo img{height:auto;max-width:100%;vertical-align:bottom;padding:0;margin:0 auto}body[class*=nav-float-].menu-logo-enabled:not(.sticky-menu-logo) .main-navigation .main-nav,body[class*=nav-float-].menu-logo-enabled:not(.sticky-menu-logo) .main-navigation .navigation-logo{display:inline-block;vertical-align:middle}body[class*=nav-float-].menu-logo-enabled:not(.sticky-menu-logo) .main-navigation:not(.navigation-stick) .navigation-logo{margin:0}.using-floats .main-navigation:not(.slideout-navigation) .inside-navigation:after,.using-floats .main-navigation:not(.slideout-navigation) .inside-navigation:before{content:".";display:block;overflow:hidden;visibility:hidden;font-size:0;line-height:0;width:0;height:0}
.main-navigation .navigation-logo{float:left;display:block;margin-left:-10px;transition:height .3s ease;opacity:1}.main-navigation .navigation-logo img{position:relative;vertical-align:middle;padding:10px;display:block;box-sizing:border-box;transition:height .3s ease}.nav-float-left .main-navigation .navigation-logo{float:right}.nav-float-left .main-navigation .navigation-logo{margin-left:0;margin-right:-10px}.regular-menu-logo .navigation-stick .navigation-logo,.sticky-menu-logo .main-navigation .navigation-logo{display:none!important}.sticky-menu-logo .navigation-stick:not(#sticky-placeholder) .navigation-logo{display:block!important}.main-navigation .inside-navigation:not(.grid-container) .navigation-logo,.main-navigation.grid-container .navigation-logo{margin-left:0}.gen-sidebar-nav .main-navigation .navigation-logo{float:none;padding:0;margin:30px 0!important;text-align:center}.gen-sidebar-nav .main-navigation .navigation-logo img{height:auto;max-width:100%;vertical-align:bottom;padding:0;margin:0 auto}body[class*=nav-float-].menu-logo-enabled:not(.sticky-menu-logo) .main-navigation .main-nav,body[class*=nav-float-].menu-logo-enabled:not(.sticky-menu-logo) .main-navigation .navigation-logo{display:inline-block;vertical-align:middle}body[class*=nav-float-].menu-logo-enabled:not(.sticky-menu-logo) .main-navigation:not(.navigation-stick) .navigation-logo{margin:0}.using-floats .main-navigation:not(.slideout-navigation) .inside-navigation:after,.using-floats .main-navigation:not(.slideout-navigation) .inside-navigation:before{content:".";display:block;overflow:hidden;visibility:hidden;font-size:0;line-height:0;width:0;height:0}

View File

@ -0,0 +1,115 @@
.navigation-branding,
.site-logo.mobile-header-logo {
display: flex;
align-items: center;
order: 0;
margin-right: 10px;
margin-left: 10px;
}
.rtl .navigation-branding,
.rtl .site-logo.mobile-header-logo {
margin-right: 10px;
margin-left: auto;
}
.navigation-branding img,
.site-logo.mobile-header-logo img {
position: relative;
vertical-align: middle;
padding: 10px 0;
display: block;
box-sizing: border-box;
transition: height .3s ease;
}
.navigation-branding img {
margin-right: 10px;
}
.navigation-branding .main-title {
transition: line-height .3s ease;
margin-right: 10px;
}
.rtl .navigation-branding .main-title {
margin-right: 0;
margin-left: 10px;
}
.mobile-header-navigation .navigation-branding .main-title {
margin-left: 10px;
}
.rtl .mobile-header-navigation .navigation-branding .main-title {
margin-left: 0;
margin-right: 10px;
}
.navigation-branding .main-title a {
font-family: inherit;
font-size: inherit;
font-weight: inherit;
text-transform: unset;
}
.main-navigation:not(.grid-container):not(.mobile-header-navigation) .inside-navigation.grid-container .navigation-branding {
margin-left: 0;
}
.rtl .main-navigation:not(.grid-container).nav-align-left:not(.mobile-header-navigation) .inside-navigation.grid-container .navigation-branding {
margin-left: auto;
margin-right: 0;
}
.rtl .main-navigation.nav-align-right:not(.mobile-header-navigation) .navigation-branding {
order: 10;
}
.main-navigation.mobile-header-navigation {
display: none;
float: none;
margin-bottom: 0;
}
.mobile-header-navigation.is_stuck {
box-shadow: 0 2px 2px -2px rgba(0, 0, 0, .2);
}
.main-navigation .menu-toggle {
flex-grow: 1;
width: auto;
}
.main-navigation.has-branding .menu-toggle,
.main-navigation.has-sticky-branding.navigation-stick .menu-toggle {
flex-grow: 0;
padding-right: 20px;
order: 2;
}
.main-navigation:not(.slideout-navigation) .mobile-bar-items + .menu-toggle {
text-align: left;
}
.main-navigation.has-sticky-branding:not(.has-branding):not(.navigation-stick) .navigation-branding {
display: none;
}
.nav-align-right .navigation-branding {
margin-right: auto;
}
.nav-align-center .navigation-branding {
margin-right: 10px;
}
.main-navigation.has-branding:not([class*="nav-align-"]):not(.mobile-header-navigation) .inside-navigation,
.main-navigation.has-sticky-branding.navigation-stick:not([class*="nav-align-"]):not(.mobile-header-navigation) .inside-navigation {
justify-content: flex-start;
}
.main-navigation.has-branding:not([class*="nav-align-"]):not(.mobile-header-navigation) .menu-bar-items,
.main-navigation.has-sticky-branding.navigation-stick:not([class*="nav-align-"]):not(.mobile-header-navigation) .menu-bar-items {
margin-left: auto;
}

View File

@ -0,0 +1 @@
.navigation-branding,.site-logo.mobile-header-logo{display:flex;align-items:center;order:0;margin-right:10px;margin-left:10px}.rtl .navigation-branding,.rtl .site-logo.mobile-header-logo{margin-right:10px;margin-left:auto}.navigation-branding img,.site-logo.mobile-header-logo img{position:relative;vertical-align:middle;padding:10px 0;display:block;box-sizing:border-box;transition:height .3s ease}.navigation-branding img{margin-right:10px}.navigation-branding .main-title{transition:line-height .3s ease;margin-right:10px}.rtl .navigation-branding .main-title{margin-right:0;margin-left:10px}.mobile-header-navigation .navigation-branding .main-title{margin-left:10px}.rtl .mobile-header-navigation .navigation-branding .main-title{margin-left:0;margin-right:10px}.navigation-branding .main-title a{font-family:inherit;font-size:inherit;font-weight:inherit;text-transform:unset}.main-navigation:not(.grid-container):not(.mobile-header-navigation) .inside-navigation.grid-container .navigation-branding{margin-left:0}.rtl .main-navigation:not(.grid-container).nav-align-left:not(.mobile-header-navigation) .inside-navigation.grid-container .navigation-branding{margin-left:auto;margin-right:0}.rtl .main-navigation.nav-align-right:not(.mobile-header-navigation) .navigation-branding{order:10}.main-navigation.mobile-header-navigation{display:none;float:none;margin-bottom:0}.mobile-header-navigation.is_stuck{box-shadow:0 2px 2px -2px rgba(0,0,0,.2)}.main-navigation .menu-toggle{flex-grow:1;width:auto}.main-navigation.has-branding .menu-toggle,.main-navigation.has-sticky-branding.navigation-stick .menu-toggle{flex-grow:0;padding-right:20px;order:2}.main-navigation:not(.slideout-navigation) .mobile-bar-items+.menu-toggle{text-align:left}.main-navigation.has-sticky-branding:not(.has-branding):not(.navigation-stick) .navigation-branding{display:none}.nav-align-right .navigation-branding{margin-right:auto}.nav-align-center .navigation-branding{margin-right:10px}.main-navigation.has-branding:not([class*=nav-align-]):not(.mobile-header-navigation) .inside-navigation,.main-navigation.has-sticky-branding.navigation-stick:not([class*=nav-align-]):not(.mobile-header-navigation) .inside-navigation{justify-content:flex-start}.main-navigation.has-branding:not([class*=nav-align-]):not(.mobile-header-navigation) .menu-bar-items,.main-navigation.has-sticky-branding.navigation-stick:not([class*=nav-align-]):not(.mobile-header-navigation) .menu-bar-items{margin-left:auto}

View File

@ -1,29 +1,25 @@
.navigation-branding,
.site-logo.mobile-header-logo {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-webkit-box-ordinal-group: 2;
-ms-flex-order: 1;
order: 1;
margin-right: auto;
margin-left: 10px;
}
.rtl .navigation-branding,
.rtl .site-logo.mobile-header-logo {
margin-right: 10px;
margin-left: auto;
}
.navigation-branding img,
.site-logo.mobile-header-logo img {
position: relative;
vertical-align: middle;
padding: 10px 0;
display: block;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
-webkit-transition: height .3s ease;
-o-transition: height .3s ease;
transition: height .3s ease;
}
@ -32,16 +28,24 @@
}
.navigation-branding .main-title {
-webkit-transition: line-height .3s ease;
-o-transition: line-height .3s ease;
transition: line-height .3s ease;
margin-right: 10px;
}
.rtl .navigation-branding .main-title {
margin-right: 0;
margin-left: 10px;
}
.mobile-header-navigation .navigation-branding .main-title {
margin-left: 10px;
}
.rtl .mobile-header-navigation .navigation-branding .main-title {
margin-left: 0;
margin-right: 10px;
}
.navigation-branding .main-title a {
font-family: inherit;
font-size: inherit;
@ -53,6 +57,11 @@
margin-left: 0;
}
.rtl .main-navigation:not(.grid-container):not(.mobile-header-navigation) .inside-navigation.grid-container .navigation-branding {
margin-left: auto;
margin-right: 0;
}
.main-navigation.mobile-header-navigation {
display: none;
float: none;
@ -66,48 +75,31 @@
.main-navigation.has-branding .inside-navigation,
.main-navigation.has-sticky-branding.navigation-stick .inside-navigation,
#mobile-header .inside-navigation {
-ms-flex-wrap: wrap;
flex-wrap: wrap;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
.main-navigation .menu-toggle {
-webkit-box-flex: 1;
-ms-flex-positive: 1;
flex-grow: 1;
width: auto;
}
.main-navigation.has-branding .menu-toggle,
.main-navigation.has-sticky-branding.navigation-stick .menu-toggle {
-webkit-box-flex: 0;
-ms-flex-positive: 0;
flex-grow: 0;
-webkit-box-ordinal-group: 4;
-ms-flex-order: 3;
order: 3;
padding-right: 20px;
}
.main-navigation .mobile-bar-items {
-webkit-box-ordinal-group: 3;
-ms-flex-order: 2;
order: 2;
position: relative;
}
.main-navigation:not(.slideout-navigation):not(.has-branding):not(.has-sticky-branding) .menu-toggle,
.main-navigation.navigation-stick:not(.has-sticky-branding):not(.has-branding) .menu-toggle {
-webkit-box-ordinal-group: 2;
-ms-flex-order: 1;
order: 1;
-webkit-box-flex: 1;
-ms-flex-positive: 1;
flex-grow: 1;
}
@ -116,8 +108,6 @@
}
.main-navigation:not(.slideout-navigation) .main-nav {
-webkit-box-ordinal-group: 5;
-ms-flex-order: 4;
order: 4;
}
@ -136,14 +126,10 @@
.nav-aligned-center .main-navigation.has-branding .inside-navigation,
.nav-aligned-center .main-navigation.has-sticky-branding.navigation-stick .inside-navigation {
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
}
.nav-aligned-left .main-navigation.has-branding:not(.slideout-navigation) .inside-navigation .main-nav,
.nav-aligned-left .main-navigation.has-sticky-branding.navigation-stick .inside-navigation .main-nav {
-webkit-box-flex: 1;
-ms-flex-positive: 1;
flex-grow: 1;
}

View File

@ -1 +1 @@
.navigation-branding,.site-logo.mobile-header-logo{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-ordinal-group:2;-ms-flex-order:1;order:1;margin-right:auto;margin-left:10px}.navigation-branding img,.site-logo.mobile-header-logo img{position:relative;vertical-align:middle;padding:10px 0;display:block;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box;-webkit-transition:height .3s ease;-o-transition:height .3s ease;transition:height .3s ease}.navigation-branding img{margin-right:10px}.navigation-branding .main-title{-webkit-transition:line-height .3s ease;-o-transition:line-height .3s ease;transition:line-height .3s ease;margin-right:10px}.mobile-header-navigation .navigation-branding .main-title{margin-left:10px}.navigation-branding .main-title a{font-family:inherit;font-size:inherit;font-weight:inherit;text-transform:unset}.main-navigation:not(.grid-container):not(.mobile-header-navigation) .inside-navigation.grid-container .navigation-branding{margin-left:0}.main-navigation.mobile-header-navigation{display:none;float:none;margin-bottom:0}.mobile-header-navigation.is_stuck{box-shadow:0 2px 2px -2px rgba(0,0,0,.2)}#mobile-header .inside-navigation,.main-navigation.has-branding .inside-navigation,.main-navigation.has-sticky-branding.navigation-stick .inside-navigation{-ms-flex-wrap:wrap;flex-wrap:wrap;display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.main-navigation .menu-toggle{-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1;width:auto}.main-navigation.has-branding .menu-toggle,.main-navigation.has-sticky-branding.navigation-stick .menu-toggle{-webkit-box-flex:0;-ms-flex-positive:0;flex-grow:0;-webkit-box-ordinal-group:4;-ms-flex-order:3;order:3;padding-right:20px}.main-navigation .mobile-bar-items{-webkit-box-ordinal-group:3;-ms-flex-order:2;order:2;position:relative}.main-navigation.navigation-stick:not(.has-sticky-branding):not(.has-branding) .menu-toggle,.main-navigation:not(.slideout-navigation):not(.has-branding):not(.has-sticky-branding) .menu-toggle{-webkit-box-ordinal-group:2;-ms-flex-order:1;order:1;-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1}.main-navigation:not(.slideout-navigation) .mobile-bar-items+.menu-toggle{text-align:left}.main-navigation:not(.slideout-navigation) .main-nav{-webkit-box-ordinal-group:5;-ms-flex-order:4;order:4}.mobile-bar-items{position:relative}.main-navigation.has-sticky-branding:not(.has-branding):not(.navigation-stick) .navigation-branding{display:none}.nav-aligned-center .navigation-branding,.nav-aligned-left .navigation-branding{margin-right:10px}.nav-aligned-center .main-navigation.has-branding .inside-navigation,.nav-aligned-center .main-navigation.has-sticky-branding.navigation-stick .inside-navigation{-webkit-box-pack:center;-ms-flex-pack:center;justify-content:center}.nav-aligned-left .main-navigation.has-branding:not(.slideout-navigation) .inside-navigation .main-nav,.nav-aligned-left .main-navigation.has-sticky-branding.navigation-stick .inside-navigation .main-nav{-webkit-box-flex:1;-ms-flex-positive:1;flex-grow:1}
.navigation-branding,.site-logo.mobile-header-logo{display:flex;align-items:center;order:1;margin-right:auto;margin-left:10px}.rtl .navigation-branding,.rtl .site-logo.mobile-header-logo{margin-right:10px;margin-left:auto}.navigation-branding img,.site-logo.mobile-header-logo img{position:relative;vertical-align:middle;padding:10px 0;display:block;box-sizing:border-box;transition:height .3s ease}.navigation-branding img{margin-right:10px}.navigation-branding .main-title{transition:line-height .3s ease;margin-right:10px}.rtl .navigation-branding .main-title{margin-right:0;margin-left:10px}.mobile-header-navigation .navigation-branding .main-title{margin-left:10px}.rtl .mobile-header-navigation .navigation-branding .main-title{margin-left:0;margin-right:10px}.navigation-branding .main-title a{font-family:inherit;font-size:inherit;font-weight:inherit;text-transform:unset}.main-navigation:not(.grid-container):not(.mobile-header-navigation) .inside-navigation.grid-container .navigation-branding{margin-left:0}.rtl .main-navigation:not(.grid-container):not(.mobile-header-navigation) .inside-navigation.grid-container .navigation-branding{margin-left:auto;margin-right:0}.main-navigation.mobile-header-navigation{display:none;float:none;margin-bottom:0}.mobile-header-navigation.is_stuck{box-shadow:0 2px 2px -2px rgba(0,0,0,.2)}#mobile-header .inside-navigation,.main-navigation.has-branding .inside-navigation,.main-navigation.has-sticky-branding.navigation-stick .inside-navigation{flex-wrap:wrap;display:flex;align-items:center}.main-navigation .menu-toggle{flex-grow:1;width:auto}.main-navigation.has-branding .menu-toggle,.main-navigation.has-sticky-branding.navigation-stick .menu-toggle{flex-grow:0;order:3;padding-right:20px}.main-navigation .mobile-bar-items{order:2;position:relative}.main-navigation.navigation-stick:not(.has-sticky-branding):not(.has-branding) .menu-toggle,.main-navigation:not(.slideout-navigation):not(.has-branding):not(.has-sticky-branding) .menu-toggle{order:1;flex-grow:1}.main-navigation:not(.slideout-navigation) .mobile-bar-items+.menu-toggle{text-align:left}.main-navigation:not(.slideout-navigation) .main-nav{order:4}.mobile-bar-items{position:relative}.main-navigation.has-sticky-branding:not(.has-branding):not(.navigation-stick) .navigation-branding{display:none}.nav-aligned-center .navigation-branding,.nav-aligned-left .navigation-branding{margin-right:10px}.nav-aligned-center .main-navigation.has-branding .inside-navigation,.nav-aligned-center .main-navigation.has-sticky-branding.navigation-stick .inside-navigation{justify-content:center}.nav-aligned-left .main-navigation.has-branding:not(.slideout-navigation) .inside-navigation .main-nav,.nav-aligned-left .main-navigation.has-sticky-branding.navigation-stick .inside-navigation .main-nav{flex-grow:1}

View File

@ -37,10 +37,6 @@
*/
.offside--left.is-open,
.offside-js--is-left .offside-sliding-element {
-webkit-transform: translate3d(265px, 0, 0);
-moz-transform: translate3d(265px, 0, 0);
-ms-transform: translate3d(265px, 0, 0);
-o-transform: translate3d(265px, 0, 0);
transform: translate3d(265px, 0, 0);
}
@ -51,19 +47,12 @@
*/
.offside--right.is-open,
.offside-js--is-right .offside-sliding-element {
-webkit-transform: translate3d(-265px, 0, 0);
-moz-transform: translate3d(-265px, 0, 0);
-ms-transform: translate3d(-265px, 0, 0);
-o-transform: translate3d(-265px, 0, 0);
transform: translate3d(-265px, 0, 0);
}
/* Elements Transitions */
.offside-js--interact .offside,
.offside-js--interact .offside-sliding-element {
-webkit-transition: -webkit-transform .2s cubic-bezier(.16, .68, .43, .99);
-moz-transition: -moz-transform .2s cubic-bezier(.16, .68, .43, .99);
-o-transition: -o-transform .2s cubic-bezier(.16, .68, .43, .99);
transition: transform .2s cubic-bezier(.16, .68, .43, .99);
/* improves performance issues on mobile*/
@ -81,7 +70,6 @@
/* Modernizr false negative csstransforms3d fix, reset CSS 3d Transitions */
.no-csstransforms3d .offside {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
@ -124,10 +112,6 @@
visibility: hidden;
opacity: 0;
cursor: pointer;
-webkit-transition: visibility .2s ease, opacity .2s ease;
-moz-transition: visibility .2s ease, opacity .2s ease;
-o-transition: visibility .2s ease, opacity .2s ease;
transition: visibility .2s ease, opacity .2s ease;
}
@ -292,12 +276,7 @@ button.slideout-exit:hover {
}
.slideout-navigation.do-overlay .inside-navigation {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
padding: 10% 10% 0;
max-width: 700px;
@ -351,14 +330,10 @@ button.slideout-exit:hover {
}
.slideout-navigation .sfHover > a > .dropdown-menu-toggle > .gp-icon svg {
-webkit-transform: rotate(180deg);
-ms-transform: rotate(180deg);
transform: rotate(180deg);
}
.slideout-navigation .sub-menu .dropdown-menu-toggle .gp-icon svg {
-webkit-transform: rotate(0deg);
-ms-transform: rotate(0deg);
transform: rotate(0deg);
}

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
.sticky-enabled .gen-sidebar-nav.is_stuck .main-navigation{margin-bottom:0}.sticky-enabled .gen-sidebar-nav.is_stuck{z-index:500}.sticky-enabled .main-navigation.is_stuck{box-shadow:0 2px 2px -2px rgba(0,0,0,.2)}.sticky-enabled .fixfixed .is_stuck{position:relative!important}.navigation-stick:not(.gen-sidebar-nav){left:0;right:0;width:100%!important}.both-sticky-menu .main-navigation:not(#mobile-header).toggled .main-nav,.mobile-sticky-menu .main-navigation:not(#mobile-header).toggled .main-nav{clear:both}.both-sticky-menu .main-navigation:not(#mobile-header).toggled .main-nav>ul,.mobile-header-sticky #mobile-header.toggled .main-nav>ul,.mobile-sticky-menu .main-navigation:not(#mobile-header).toggled .main-nav>ul{position:absolute;left:0;right:0;z-index:999}#sticky-placeholder .navigation-branding,#sticky-placeholder.mobile-header-navigation .mobile-header-logo{display:none}.nav-float-right .is_stuck.main-navigation:not(.toggled) .menu>li{float:none;display:inline-block}.nav-float-right .is_stuck.main-navigation:not(.toggled) .menu>li.search-item,.nav-float-right .is_stuck.main-navigation:not(.toggled) .menu>li.slideout-toggle,.nav-float-right .is_stuck.main-navigation:not(.toggled) .menu>li.wc-menu-item{display:block;float:right}.nav-float-right .is_stuck.main-navigation:not(.toggled) ul{letter-spacing:-.31em;font-size:1em}.nav-float-right .is_stuck.main-navigation:not(.toggled) ul li{letter-spacing:normal}.nav-float-right .is_stuck.main-navigation:not(.toggled){text-align:right}.nav-float-right .is_stuck.main-navigation.has-branding:not(.toggled) ul,.nav-float-right .is_stuck.main-navigation.has-sticky-branding:not(.toggled) ul{letter-spacing:unset}.nav-float-right .is_stuck.main-navigation.has-branding:not(.toggled) .menu>li,.nav-float-right .is_stuck.main-navigation.has-sticky-branding:not(.toggled) .menu>li{display:block;float:left}
.sticky-enabled .gen-sidebar-nav.is_stuck .main-navigation{margin-bottom:0}.sticky-enabled .gen-sidebar-nav.is_stuck{z-index:500}.sticky-enabled .main-navigation.is_stuck{box-shadow:0 2px 2px -2px rgba(0,0,0,.2)}.sticky-enabled .fixfixed .is_stuck{position:relative!important}.navigation-stick:not(.gen-sidebar-nav){left:0;right:0;width:100%!important}.both-sticky-menu .main-navigation:not(#mobile-header).toggled .main-nav,.mobile-sticky-menu .main-navigation:not(#mobile-header).toggled .main-nav{clear:both}.both-sticky-menu .main-navigation:not(#mobile-header).toggled .main-nav>ul,.mobile-header-sticky #mobile-header.toggled .main-nav>ul,.mobile-sticky-menu .main-navigation:not(#mobile-header).toggled .main-nav>ul{position:absolute;left:0;right:0;z-index:999}#sticky-placeholder .navigation-branding,#sticky-placeholder.mobile-header-navigation .mobile-header-logo{display:none}.nav-float-right .is_stuck.main-navigation:not(.toggled) .menu>li{float:none;display:inline-block}.nav-float-right .is_stuck.main-navigation:not(.toggled) .menu>li.search-item,.nav-float-right .is_stuck.main-navigation:not(.toggled) .menu>li.slideout-toggle,.nav-float-right .is_stuck.main-navigation:not(.toggled) .menu>li.wc-menu-item{display:block;float:right}.nav-float-right .is_stuck.main-navigation:not(.toggled) ul{letter-spacing:-.31em;font-size:1em}.nav-float-right .is_stuck.main-navigation:not(.toggled) ul li{letter-spacing:normal}.nav-float-right .is_stuck.main-navigation:not(.toggled){text-align:right}.nav-float-right .is_stuck.main-navigation.has-branding:not(.toggled) ul,.nav-float-right .is_stuck.main-navigation.has-sticky-branding:not(.toggled) ul{letter-spacing:unset}.nav-float-right .is_stuck.main-navigation.has-branding:not(.toggled) .menu>li,.nav-float-right .is_stuck.main-navigation.has-sticky-branding:not(.toggled) .menu>li{display:block;float:left}

File diff suppressed because one or more lines are too long

View File

@ -27,6 +27,7 @@
'display': 'none'
}).attr({
id: 'sticky-placeholder',
'aria-hidden': true,
itemtype: null,
itemscope: null,
}),
@ -72,7 +73,7 @@
unStick = function() {
void 0;
$placeholder.hide().removeClass( options.fixedClass ).removeClass( 'sticky-navigation-transition' );
$placeholder.remove();
$element.removeClass(options.fixedClass)
.css({
@ -98,7 +99,8 @@
'visibility': ''
})
.removeClass( 'sticky-navigation-transition' )
.removeClass( 'navigation-transition' );
.removeClass( 'navigation-transition' )
.removeClass( 'sticky-nav-scrolling-up' );
if ( 'sticky-navigation' === $element.attr( 'id' ) ) {
$element.attr( 'id', 'site-navigation' );
@ -113,7 +115,9 @@
holdIt = function( forceBottom ) {
void 0;
$placeholder.show().addClass( options.fixedClass );
$( $placeholder ).insertAfter( $element ).show().addClass( options.fixedClass );
var offsetParent = $placeholder.offsetParent();
if ( forceBottom ) {
@ -155,7 +159,11 @@
});
}
$placeholder.show().addClass( options.fixedClass );
$( $placeholder ).insertAfter( $element ).show().addClass( options.fixedClass );
if ( $( '.gen-sidebar-nav' ).length ) {
$placeholder.css( 'height', $element.outerHeight() );
}
if ( 'left' == $element.css( 'float' ) || 'right' == $element.css( 'float' ) ) {
$placeholder.css( 'float', $element.css( 'float' ) );
@ -224,7 +232,7 @@
},
syncWidth = function() {
if( $placeholder.width() !== $element.outerWidth() ) {
if ( $placeholder && $placeholder.width() !== $element.outerWidth() ) {
$element.outerWidth( $placeholder.outerWidth() );
}
},
@ -324,9 +332,11 @@
if ( scrollDir === 'up' && topValue !== 0 ) {
var newTopValue = scrollDistance > -topValue ? 0 : topValue + scrollDistance;
$element.css( 'top', newTopValue + 'px' );
$element.addClass( 'sticky-nav-scrolling-up' );
} else if ( scrollDir === "down" && topValue > -offset ) {
var newTopValue = scrollDistance > offset + topValue ? -offset : topValue - scrollDistance;
$element.css( 'top', newTopValue + 'px' );
$element.removeClass( 'sticky-nav-scrolling-up' );
}
}
@ -357,13 +367,6 @@
var initialize = function( elem, opts ) {
$element = $( elem );
$placeholder.remove();
$element.after( $placeholder );
if ( $( '.gen-sidebar-nav' ).length ) {
$placeholder.css( 'height', $element.outerHeight() );
}
// adding a class to users div
$element.addClass( options.namespaceClass );

File diff suppressed because one or more lines are too long

View File

@ -1,28 +1,20 @@
<?php
/*
Add-on Name: Generate Menu Plus
Author: Thomas Usborne
Author URI: http://edge22.com
*/
/**
* The Menu Plus module.
*
* @since 1.0.0
*
* @package GP Premium
*/
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
exit; // No direct access, please.
}
// Define the version
// Define the version.
if ( ! defined( 'GENERATE_MENU_PLUS_VERSION' ) ) {
define( 'GENERATE_MENU_PLUS_VERSION', GP_PREMIUM_VERSION );
}
// Include functions identical between standalone add-on and GP Premium
// Include functions identical between standalone add-on and GP Premium.
require plugin_dir_path( __FILE__ ) . 'functions/generate-menu-plus.php';
// Set up language files
if ( ! function_exists( 'generate_menu_plus_init' ) ) {
add_action( 'plugins_loaded', 'generate_menu_plus_init' );
function generate_menu_plus_init() {
load_plugin_textdomain( 'menu-plus', false, 'gp-premium/langs/menu-plus/' );
}
}

View File

@ -106,10 +106,7 @@
.generate-tabs-menu li a.button:focus{
background: #eee;
border-color: #999;
-webkit-box-shadow: inset 0 2px 5px -3px rgba(0,0,0,.5);
box-shadow: inset 0 2px 5px -3px rgba(0,0,0,.5);
-webkit-transform: translateY(1px);
-ms-transform: translateY(1px);
transform: translateY(1px);
}
@ -132,9 +129,6 @@
background: #ddd;
overflow: hidden;
cursor: pointer;
-webkit-transition: all .2s ease-in-out;
-ms-transition: all .2s ease-in-out;
transition: all .2s ease-in-out;
}
#generate-tabs-container .lcs_cursor {
@ -146,9 +140,6 @@
border-radius: 100%;
background: #fff;
z-index: 10;
-webkit-transition: all .2s linear;
-ms-transition: all .2s linear;
transition: all .2s linear;
}
#generate-tabs-container .lcs_label {
@ -164,9 +155,6 @@
overflow: hidden;
text-align: center;
opacity: 0;
-webkit-transition: all .2s ease-in-out .1s;
-ms-transition: all .2s ease-in-out .1s;
transition: all .2s ease-in-out .1s;
}
#generate-tabs-container .lcs_label.lcs_label_on {
@ -278,7 +266,6 @@
.page-header-content-required {
background: #fafafa;
border-left: 4px solid #fff;
-webkit-box-shadow: 0 1px 1px 0 rgba( 0, 0, 0, 0.1 );
box-shadow: 0 1px 1px 0 rgba( 0, 0, 0, 0.1 );
margin: 5px 0 8px 0;
padding: 1px 12px;

View File

@ -21,44 +21,21 @@
}
.vertical-center-enabled {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
-webkit-flex-direction: column;
flex-direction: column;
-webkit-flex-wrap: nowrap;
-ms-flex-wrap: nowrap;
flex-wrap: nowrap;
flex-wrap: nowrap;
height: 100%;
}
.vertical-center-enabled .page-header-content-wrapper {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-ms-flex-direction: column;
-webkit-flex-direction: column;
flex-direction: column;
-webkit-flex-grow: 1;
-ms-flex-grow: 1;
flex-grow: 1;
-webkit-box-flex: 1;
width: 100%;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-justify-content: center;
justify-content: center;

View File

@ -1 +1 @@
.generate-combined-header{position:absolute;width:100%;z-index:1000}.generate-combined-page-header.grid-container .generate-combined-header{left:0;right:0;width:auto}.one-container .inside-article .page-header-below-title,.separate-containers .inside-article .page-header-below-title{margin-top:2em}.inside-article .page-header-post-image{float:none;margin-right:0}.vertical-center-enabled,.vertical-center-enabled .page-header-content-wrapper{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-ms-flex-direction:column;-webkit-flex-direction:column;flex-direction:column}.vertical-center-enabled{-webkit-box-orient:vertical;-webkit-box-direction:normal;-webkit-flex-wrap:nowrap;-ms-flex-wrap:nowrap;flex-wrap:nowrap;height:100%}.vertical-center-enabled .page-header-content-wrapper{-webkit-flex-grow:1;-ms-flex-grow:1;flex-grow:1;-webkit-box-flex:1;width:100%;-webkit-box-pack:center;-webkit-justify-content:center;-ms-justify-content:center;justify-content:center;-webkit-box-align:center;-webkit-flex-align:center}.vertical-center-enabled .main-navigation,.vertical-center-enabled .secondary-navigation,.vertical-center-enabled .site-header{flex:none;-ms-flex:none;-webkit-flex:none}.nav-above-header .vertical-center-enabled .main-navigation,.nav-below-header .vertical-center-enabled .main-navigation,.vertical-center-enabled .site-header{width:100%}.generate-merged-header .main-navigation{z-index:99}.generate-merged-header .main-navigation.mobile-header-navigation{z-index:100}.generate-merged-header .secondary-navigation{z-index:98}.generate-content-header{background-repeat:no-repeat;background-size:cover}.elementor-editor-active .generate-combined-header{pointer-events:none}.page-header-content-container:after,.page-header-content-container:before{content:"";display:table}.page-header-content-container:after{clear:both}
.generate-combined-header{position:absolute;width:100%;z-index:1000}.generate-combined-page-header.grid-container .generate-combined-header{left:0;right:0;width:auto}.one-container .inside-article .page-header-below-title,.separate-containers .inside-article .page-header-below-title{margin-top:2em}.inside-article .page-header-post-image{float:none;margin-right:0}.vertical-center-enabled{display:flex;flex-direction:column;flex-wrap:nowrap;height:100%}.vertical-center-enabled .page-header-content-wrapper{display:flex;flex-direction:column;-ms-flex-grow:1;flex-grow:1;-webkit-box-flex:1;width:100%;-ms-justify-content:center;justify-content:center;-webkit-box-align:center;-webkit-flex-align:center}.vertical-center-enabled .main-navigation,.vertical-center-enabled .secondary-navigation,.vertical-center-enabled .site-header{flex:none;-ms-flex:none;-webkit-flex:none}.nav-above-header .vertical-center-enabled .main-navigation,.nav-below-header .vertical-center-enabled .main-navigation{width:100%}.vertical-center-enabled .site-header{width:100%}.generate-merged-header .main-navigation{z-index:99}.generate-merged-header .main-navigation.mobile-header-navigation{z-index:100}.generate-merged-header .secondary-navigation{z-index:98}.generate-content-header{background-repeat:no-repeat;background-size:cover}.elementor-editor-active .generate-combined-header{pointer-events:none}.page-header-content-container:after,.page-header-content-container:before{content:"";display:table}.page-header-content-container:after{clear:both}

View File

@ -19,6 +19,11 @@ function generate_page_header_do_setup() {
}
$options = generate_page_header_get_options();
if ( ! $options ) {
return;
}
$global_locations = wp_parse_args( get_option( 'generate_page_header_global_locations', array() ), '' );
// Remove elements if they're being added as a template tag
@ -289,6 +294,11 @@ function generate_page_header_get_image( $type = 'URL', $id = '' ) {
}
$options = generate_page_header_get_options();
if ( ! $options ) {
return;
}
$image_id = $options[ 'image_id' ];
$image_url = $options[ 'image_url' ];
@ -335,6 +345,11 @@ function generate_page_header_get_image( $type = 'URL', $id = '' ) {
*/
function generate_page_header_get_image_output() {
$options = generate_page_header_get_options();
if ( ! $options ) {
return;
}
$image_url = generate_page_header_get_image( 'URL' );
$image_id = generate_page_header_get_image( 'ID' );
@ -396,6 +411,10 @@ if ( ! function_exists( 'generate_combined_page_header_start' ) ) {
function generate_combined_page_header_start() {
$options = generate_page_header_get_options();
if ( ! $options ) {
return;
}
if ( '' == $options[ 'merge' ] || '' == $options[ 'content' ] || '' == $options[ 'absolute' ] ) {
return;
}
@ -412,6 +431,10 @@ if ( ! function_exists( 'generate_combined_page_header_end' ) ) {
function generate_combined_page_header_end() {
$options = generate_page_header_get_options();
if ( ! $options ) {
return;
}
if ( '' == $options[ 'merge' ] || '' == $options[ 'content' ] || '' == $options[ 'absolute' ] ) {
return;
}
@ -429,6 +452,10 @@ if ( ! function_exists( 'generate_page_header_enqueue' ) ) {
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
$options = generate_page_header_get_options();
if ( ! $options ) {
return;
}
if ( ! empty( $options[ 'full_screen' ] ) && '' !== $options[ 'content' ] ) {
wp_enqueue_script( 'generate-page-header-full-height', plugin_dir_url( __FILE__ ) . "js/full-height{$suffix}.js", array('jquery'), GENERATE_PAGE_HEADER_VERSION, true );
}
@ -646,6 +673,10 @@ add_filter( 'generate_page_header_location','generate_page_header_force_above_co
function generate_page_header_force_above_content( $location ) {
$options = generate_page_header_get_options();
if ( ! $options ) {
return $location;
}
if ( '' !== $options[ 'merge' ] && '' !== $options[ 'content' ] ) {
$location = 'above-content';
}
@ -673,6 +704,10 @@ if ( ! function_exists( 'generate_page_header_combined' ) ) {
// Get our options
$options = generate_page_header_get_options();
if ( ! $options ) {
return;
}
// Bail if merge isn't activated
if ( '' == $options[ 'merge' ] ) {
return;
@ -943,6 +978,11 @@ if ( ! function_exists( 'generate_page_header_replace_logo' ) ) {
function generate_page_header_replace_logo( $logo ) {
if ( generate_page_header_logo_exists() ) {
$options = generate_page_header_get_options();
if ( ! $options ) {
return $logo;
}
return $options[ 'logo_url' ];
}
@ -958,6 +998,11 @@ if ( ! function_exists( 'generate_page_header_replace_navigation_logo' ) ) {
function generate_page_header_replace_navigation_logo( $logo ) {
if ( generate_page_header_navigation_logo_exists() ) {
$options = generate_page_header_get_options();
if ( ! $options ) {
return $logo;
}
return $options[ 'navigation_logo_url' ];
}

View File

@ -1,27 +1,21 @@
<?php
/*
Addon Name: Generate Page Header
Author: Thomas Usborne
Author URI: http://edge22.com
*/
/**
* The Page Header module.
*
* @since 1.1.0
* @deprecated 1.7.0
*
* @package GP Premium
*/
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
exit; // No direct access, please.
}
// Define the version
// Define the version.
if ( ! defined( 'GENERATE_PAGE_HEADER_VERSION' ) ) {
define( 'GENERATE_PAGE_HEADER_VERSION', GP_PREMIUM_VERSION );
}
if ( ! function_exists( 'generate_page_header_init' ) ) {
add_action( 'plugins_loaded', 'generate_page_header_init' );
function generate_page_header_init() {
load_plugin_textdomain( 'page-header', false, 'gp-premium/langs/page-header/' );
}
}
// Include assets unique to this addon
// Include assets unique to this addon.
require plugin_dir_path( __FILE__ ) . 'functions/functions.php';

Some files were not shown because too many files have changed in this diff Show More