modified file smtp-mailer

This commit is contained in:
2024-06-27 12:11:15 +00:00
committed by Gitium
parent 91db4aebe1
commit 19e351ef3b
1005 changed files with 230351 additions and 8670 deletions

View File

@ -0,0 +1,134 @@
<?php
/**
* This file creates a class to build our CSS.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
if ( ! class_exists( 'GeneratePress_Backgrounds_CSS' ) ) {
/**
* Generate our background CSS.
*/
class GeneratePress_Backgrounds_CSS {
/**
* The css selector that you're currently adding rules to
*
* @access protected
* @var string
*/
protected $_selector = ''; // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore
/**
* Stores the final css output with all of its rules for the current selector.
*
* @access protected
* @var string
*/
protected $_selector_output = ''; // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore
/**
* Stores all of the rules that will be added to the selector
*
* @access protected
* @var string
*/
protected $_css = ''; // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore
/**
* The string that holds all of the css to output
*
* @access protected
* @var string
*/
protected $_output = ''; // phpcs:ignore PSR2.Classes.PropertyDeclaration.Underscore
/**
* Sets a selector to the object and changes the current selector to a new one
*
* @access public
* @since 1.0
*
* @param string $selector - the css identifier of the html that you wish to target.
* @return $this
*/
public function set_selector( $selector = '' ) {
// Render the css in the output string everytime the selector changes.
if ( '' !== $this->_selector ) {
$this->add_selector_rules_to_output();
}
$this->_selector = $selector;
return $this;
}
/**
* Adds a css property with value to the css output
*
* @access public
* @since 1.0
*
* @param string $property - the css property.
* @param string $value - the value to be placed with the property.
* @param string $url Whether we need to generate URL in the string.
* @return $this
*/
public function add_property( $property, $value, $url = '' ) {
// If we don't have a value or our value is the same as our og default, bail.
if ( empty( $value ) ) {
return false;
}
// Set up our background image URL param if needed.
$url_start = ( '' !== $url ) ? "url('" : ""; // phpcs:ignore -- need double quotes.
$url_end = ( '' !== $url ) ? "')" : ""; // phpcs:ignore -- need double quotes.
$this->_css .= $property . ':' . $url_start . $value . $url_end . ';';
return $this;
}
/**
* Adds the current selector rules to the output variable
*
* @access private
* @since 1.0
*
* @return $this
*/
private function add_selector_rules_to_output() {
if ( ! empty( $this->_css ) ) {
$this->_selector_output = $this->_selector;
$selector_output = sprintf( '%1$s{%2$s}', $this->_selector_output, $this->_css );
$this->_output .= $selector_output;
// Reset the css.
$this->_css = '';
}
return $this;
}
/**
* Returns the minified css in the $_output variable
*
* @access public
* @since 1.0
*
* @return string
*/
public function css_output() {
// Add current selector's rules to output.
$this->add_selector_rules_to_output();
// Output minified css.
return $this->_output;
}
}
}

View File

@ -0,0 +1,420 @@
<?php
/**
* This file handles Secondary Nav background images.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
if ( ! function_exists( 'generate_backgrounds_secondary_nav_customizer' ) ) {
add_action( 'customize_register', 'generate_backgrounds_secondary_nav_customizer', 1000 );
/**
* Adds our Secondary Nav background image options
*
* These options are in their own function so we can hook it in late to
* make sure Secondary Nav is activated.
*
* 1000 priority is there to make sure Secondary Nav is registered (999)
* as we check to see if the layout control exists.
*
* Secondary Nav now uses 100 as a priority.
*
* @param object $wp_customize Our Customizer object.
*/
function generate_backgrounds_secondary_nav_customizer( $wp_customize ) {
if ( ! function_exists( 'generate_secondary_nav_get_defaults' ) ) {
return;
}
if ( ! $wp_customize->get_section( 'secondary_nav_section' ) ) {
return;
}
$defaults = generate_secondary_nav_get_defaults();
if ( method_exists( $wp_customize, 'register_control_type' ) ) {
$wp_customize->register_control_type( 'GeneratePress_Section_Shortcut_Control' );
}
require_once GP_LIBRARY_DIRECTORY . 'customizer-helpers.php';
$wp_customize->add_section(
'secondary_bg_images_section',
array(
'title' => __( 'Secondary Navigation', 'gp-premium' ),
'capability' => 'edit_theme_options',
'description' => '',
'panel' => 'generate_backgrounds_panel',
'priority' => 21,
)
);
$wp_customize->add_control(
new GeneratePress_Section_Shortcut_Control(
$wp_customize,
'generate_secondary_navigation_background_image_shortcuts',
array(
'section' => 'secondary_bg_images_section',
'element' => __( 'Secondary Navigation', 'gp-premium' ),
'shortcuts' => array(
'layout' => 'secondary_nav_section',
'colors' => 'secondary_navigation_color_section',
'typography' => 'secondary_font_section',
),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
'priority' => 1,
)
)
);
$wp_customize->add_setting(
'generate_secondary_nav_settings[nav_image]',
array(
'default' => $defaults['nav_image'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'esc_url_raw',
)
);
$wp_customize->add_control(
new WP_Customize_Image_Control(
$wp_customize,
'generate_secondary_backgrounds-nav-image',
array(
'section' => 'secondary_bg_images_section',
'settings' => 'generate_secondary_nav_settings[nav_image]',
'priority' => 750,
'label' => __( 'Navigation', 'gp-premium' ),
)
)
);
$wp_customize->add_setting(
'generate_secondary_nav_settings[nav_repeat]',
array(
'default' => $defaults['nav_repeat'],
'type' => 'option',
'sanitize_callback' => 'generate_premium_sanitize_choices',
)
);
$wp_customize->add_control(
'generate_secondary_nav_settings[nav_repeat]',
array(
'type' => 'select',
'section' => 'secondary_bg_images_section',
'choices' => array(
'' => __( 'Repeat', 'gp-premium' ),
'repeat-x' => __( 'Repeat x', 'gp-premium' ),
'repeat-y' => __( 'Repeat y', 'gp-premium' ),
'no-repeat' => __( 'No Repeat', 'gp-premium' ),
),
'settings' => 'generate_secondary_nav_settings[nav_repeat]',
'priority' => 800,
)
);
$wp_customize->add_setting(
'generate_secondary_nav_settings[nav_item_image]',
array(
'default' => $defaults['nav_item_image'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'esc_url_raw',
)
);
$wp_customize->add_control(
new WP_Customize_Image_Control(
$wp_customize,
'generate_secondary_backgrounds-nav-item-image',
array(
'section' => 'secondary_bg_images_section',
'settings' => 'generate_secondary_nav_settings[nav_item_image]',
'priority' => 950,
'label' => __( 'Navigation Item', 'gp-premium' ),
)
)
);
$wp_customize->add_setting(
'generate_secondary_nav_settings[nav_item_repeat]',
array(
'default' => $defaults['nav_item_repeat'],
'type' => 'option',
'sanitize_callback' => 'generate_premium_sanitize_choices',
)
);
$wp_customize->add_control(
'generate_secondary_nav_settings[nav_item_repeat]',
array(
'type' => 'select',
'section' => 'secondary_bg_images_section',
'choices' => array(
'' => __( 'Repeat', 'gp-premium' ),
'repeat-x' => __( 'Repeat x', 'gp-premium' ),
'repeat-y' => __( 'Repeat y', 'gp-premium' ),
'no-repeat' => __( 'No Repeat', 'gp-premium' ),
),
'settings' => 'generate_secondary_nav_settings[nav_item_repeat]',
'priority' => 1000,
)
);
$wp_customize->add_setting(
'generate_secondary_nav_settings[nav_item_hover_image]',
array(
'default' => $defaults['nav_item_hover_image'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'esc_url_raw',
)
);
$wp_customize->add_control(
new WP_Customize_Image_Control(
$wp_customize,
'generate_secondary_backgrounds-nav-item-hover-image',
array(
'section' => 'secondary_bg_images_section',
'settings' => 'generate_secondary_nav_settings[nav_item_hover_image]',
'priority' => 1150,
'label' => __( 'Navigation Item Hover', 'gp-premium' ),
)
)
);
$wp_customize->add_setting(
'generate_secondary_nav_settings[nav_item_hover_repeat]',
array(
'default' => $defaults['nav_item_hover_repeat'],
'type' => 'option',
'sanitize_callback' => 'generate_premium_sanitize_choices',
)
);
$wp_customize->add_control(
'generate_secondary_nav_settings[nav_item_hover_repeat]',
array(
'type' => 'select',
'section' => 'secondary_bg_images_section',
'choices' => array(
'' => __( 'Repeat', 'gp-premium' ),
'repeat-x' => __( 'Repeat x', 'gp-premium' ),
'repeat-y' => __( 'Repeat y', 'gp-premium' ),
'no-repeat' => __( 'No Repeat', 'gp-premium' ),
),
'settings' => 'generate_secondary_nav_settings[nav_item_hover_repeat]',
'priority' => 1200,
)
);
$wp_customize->add_setting(
'generate_secondary_nav_settings[nav_item_current_image]',
array(
'default' => $defaults['nav_item_current_image'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'esc_url_raw',
)
);
$wp_customize->add_control(
new WP_Customize_Image_Control(
$wp_customize,
'generate_secondary_backgrounds-nav-item-current-image',
array(
'section' => 'secondary_bg_images_section',
'settings' => 'generate_secondary_nav_settings[nav_item_current_image]',
'priority' => 1350,
'label' => __( 'Navigation Item Current', 'gp-premium' ),
)
)
);
$wp_customize->add_setting(
'generate_secondary_nav_settings[nav_item_current_repeat]',
array(
'default' => $defaults['nav_item_current_repeat'],
'type' => 'option',
'sanitize_callback' => 'generate_premium_sanitize_choices',
)
);
$wp_customize->add_control(
'generate_secondary_nav_settings[nav_item_current_repeat]',
array(
'type' => 'select',
'section' => 'secondary_bg_images_section',
'choices' => array(
'' => __( 'Repeat', 'gp-premium' ),
'repeat-x' => __( 'Repeat x', 'gp-premium' ),
'repeat-y' => __( 'Repeat y', 'gp-premium' ),
'no-repeat' => __( 'No Repeat', 'gp-premium' ),
),
'settings' => 'generate_secondary_nav_settings[nav_item_current_repeat]',
'priority' => 1400,
)
);
$wp_customize->add_section(
'secondary_subnav_bg_images_section',
array(
'title' => __( 'Secondary Sub-Navigation', 'gp-premium' ),
'capability' => 'edit_theme_options',
'description' => '',
'panel' => 'generate_backgrounds_panel',
'priority' => 22,
)
);
$wp_customize->add_setting(
'generate_secondary_nav_settings[sub_nav_item_image]',
array(
'default' => $defaults['sub_nav_item_image'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'esc_url_raw',
)
);
$wp_customize->add_control(
new WP_Customize_Image_Control(
$wp_customize,
'generate_secondary_backgrounds-sub-nav-item-image',
array(
'section' => 'secondary_subnav_bg_images_section',
'settings' => 'generate_secondary_nav_settings[sub_nav_item_image]',
'priority' => 1700,
'label' => __( 'Sub-Navigation Item', 'gp-premium' ),
)
)
);
$wp_customize->add_setting(
'generate_secondary_nav_settings[sub_nav_item_repeat]',
array(
'default' => $defaults['sub_nav_item_repeat'],
'type' => 'option',
'sanitize_callback' => 'generate_premium_sanitize_choices',
)
);
$wp_customize->add_control(
'generate_secondary_nav_settings[sub_nav_item_repeat]',
array(
'type' => 'select',
'section' => 'secondary_subnav_bg_images_section',
'choices' => array(
'' => __( 'Repeat', 'gp-premium' ),
'repeat-x' => __( 'Repeat x', 'gp-premium' ),
'repeat-y' => __( 'Repeat y', 'gp-premium' ),
'no-repeat' => __( 'No Repeat', 'gp-premium' ),
),
'settings' => 'generate_secondary_nav_settings[sub_nav_item_repeat]',
'priority' => 1800,
)
);
$wp_customize->add_setting(
'generate_secondary_nav_settings[sub_nav_item_hover_image]',
array(
'default' => $defaults['sub_nav_item_hover_image'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'esc_url_raw',
)
);
$wp_customize->add_control(
new WP_Customize_Image_Control(
$wp_customize,
'generate_secondary_backgrounds-sub-nav-item-hover-image',
array(
'section' => 'secondary_subnav_bg_images_section',
'settings' => 'generate_secondary_nav_settings[sub_nav_item_hover_image]',
'priority' => 2000,
'label' => __( 'Sub-Navigation Item Hover', 'gp-premium' ),
)
)
);
$wp_customize->add_setting(
'generate_secondary_nav_settings[sub_nav_item_hover_repeat]',
array(
'default' => $defaults['sub_nav_item_hover_repeat'],
'type' => 'option',
'sanitize_callback' => 'generate_premium_sanitize_choices',
)
);
$wp_customize->add_control(
'generate_secondary_nav_settings[sub_nav_item_hover_repeat]',
array(
'type' => 'select',
'section' => 'secondary_subnav_bg_images_section',
'choices' => array(
'' => __( 'Repeat', 'gp-premium' ),
'repeat-x' => __( 'Repeat x', 'gp-premium' ),
'repeat-y' => __( 'Repeat y', 'gp-premium' ),
'no-repeat' => __( 'No Repeat', 'gp-premium' ),
),
'settings' => 'generate_secondary_nav_settings[sub_nav_item_hover_repeat]',
'priority' => 2100,
)
);
$wp_customize->add_setting(
'generate_secondary_nav_settings[sub_nav_item_current_image]',
array(
'default' => $defaults['sub_nav_item_current_image'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'esc_url_raw',
)
);
$wp_customize->add_control(
new WP_Customize_Image_Control(
$wp_customize,
'generate_secondary_backgrounds-sub-nav-item-current-image',
array(
'section' => 'secondary_subnav_bg_images_section',
'settings' => 'generate_secondary_nav_settings[sub_nav_item_current_image]',
'priority' => 2300,
'label' => __( 'Sub-Navigation Item Current', 'gp-premium' ),
)
)
);
$wp_customize->add_setting(
'generate_secondary_nav_settings[sub_nav_item_current_repeat]',
array(
'default' => $defaults['sub_nav_item_current_repeat'],
'type' => 'option',
'sanitize_callback' => 'generate_premium_sanitize_choices',
)
);
$wp_customize->add_control(
'generate_secondary_nav_settings[sub_nav_item_current_repeat]',
array(
'type' => 'select',
'section' => 'secondary_subnav_bg_images_section',
'choices' => array(
'' => __( 'Repeat', 'gp-premium' ),
'repeat-x' => __( 'Repeat x', 'gp-premium' ),
'repeat-y' => __( 'Repeat y', 'gp-premium' ),
'no-repeat' => __( 'No Repeat', 'gp-premium' ),
),
'settings' => 'generate_secondary_nav_settings[sub_nav_item_current_repeat]',
'priority' => 2400,
)
);
}
}

View File

@ -0,0 +1,19 @@
<?php
/**
* Backgrounds module.
*
* @since 1.1.0
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
// Define the version. This used to be a standalone plugin, so we need to keep this constant.
if ( ! defined( 'GENERATE_BACKGROUNDS_VERSION' ) ) {
define( 'GENERATE_BACKGROUNDS_VERSION', GP_PREMIUM_VERSION );
}
require plugin_dir_path( __FILE__ ) . 'functions/functions.php';

View File

@ -0,0 +1,169 @@
<?php
/**
* This file handles column-related functionality.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
if ( ! function_exists( 'generate_blog_get_columns' ) ) {
/**
* Initiate columns.
*
* @since 0.1
*/
function generate_blog_get_columns() {
$generate_blog_settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
// If columns are enabled, set to true.
$columns = ( $generate_blog_settings['column_layout'] ) ? true : false;
// If we're not dealing with posts, set it to false.
// Check for is_home() to prevent bug in Yoast that throws off the post type check.
$columns = ( 'post' === get_post_type() || is_search() || is_home() ) ? $columns : false;
// If masonry is enabled via filter, enable columns.
// phpcs:ignore -- Non-strict comparison allowed.
$columns = ( 'true' == apply_filters( 'generate_blog_masonry', 'false' ) ) ? true : $columns;
// If we're on a singular post or page, disable.
$columns = ( is_singular() ) ? false : $columns;
// Turn off columns if we're on a WooCommerce search page.
if ( function_exists( 'is_woocommerce' ) ) {
$columns = ( is_woocommerce() && is_search() ) ? false : $columns;
}
// Bail if there's no search results.
if ( is_search() ) {
global $wp_query;
// phpcs:ignore -- non-strict comparison allowed.
if ( 0 == $wp_query->post_count ) {
$columns = false;
}
}
// Return the result.
return apply_filters( 'generate_blog_columns', $columns );
}
}
if ( ! function_exists( 'generate_blog_get_masonry' ) ) {
/**
* Check if masonry is enabled.
* This function is a mess with strings as bools etc.. Will re-write in a big upate to get lots of testing.
*/
function generate_blog_get_masonry() {
$generate_blog_settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
// If masonry is enabled via option or filter, enable it.
// phpcs:ignore -- non-strict comparison allowed.
if ( $generate_blog_settings['masonry'] || 'true' == apply_filters( 'generate_blog_masonry', 'false' ) ) {
$masonry = 'true';
} else {
$masonry = 'false';
}
// Allow masonry to be turned off using a boolean.
if ( false === apply_filters( 'generate_blog_masonry', 'false' ) ) {
$masonry = 'false';
}
return $masonry;
}
}
if ( ! function_exists( 'generate_blog_add_columns_container' ) ) {
add_action( 'generate_before_main_content', 'generate_blog_add_columns_container' );
/**
* Add columns container
*
* @since 1.0
*/
function generate_blog_add_columns_container() {
if ( ! generate_blog_get_columns() ) {
return;
}
$columns = generate_blog_get_column_count();
printf(
'<div class="generate-columns-container %1$s">%2$s',
'false' !== generate_blog_get_masonry() ? 'masonry-container are-images-unloaded' : '',
'false' !== generate_blog_get_masonry() ? '<div class="grid-sizer grid-' . esc_attr( $columns ) . ' tablet-grid-50 mobile-grid-100"></div>' : '' // phpcs:ignore -- no escaping needed.
);
}
}
if ( ! function_exists( 'generate_blog_add_ending_columns_container' ) ) {
add_action( 'generate_after_main_content', 'generate_blog_add_ending_columns_container' );
/**
* Add closing columns container
*
* @since 1.0
*/
function generate_blog_add_ending_columns_container() {
if ( ! generate_blog_get_columns() ) {
return;
}
echo '</div><!-- .generate-columns-contaier -->';
}
}
if ( ! function_exists( 'generate_blog_columns_css' ) ) {
/**
* Add inline CSS
*/
function generate_blog_columns_css() {
$generate_blog_settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
if ( function_exists( 'generate_spacing_get_defaults' ) ) {
$spacing_settings = wp_parse_args(
get_option( 'generate_spacing_settings', array() ),
generate_spacing_get_defaults()
);
}
$separator = ( function_exists( 'generate_spacing_get_defaults' ) ) ? absint( $spacing_settings['separator'] ) : 20;
$return = '';
if ( generate_blog_get_columns() ) {
$return .= '.generate-columns {margin-bottom: ' . $separator . 'px;padding-left: ' . $separator . 'px;}';
$return .= '.generate-columns-container {margin-left: -' . $separator . 'px;}';
$return .= '.page-header {margin-bottom: ' . $separator . 'px;margin-left: ' . $separator . 'px}';
$return .= '.generate-columns-container > .paging-navigation {margin-left: ' . $separator . 'px;}';
}
return $return;
}
}
if ( ! function_exists( 'generate_blog_get_column_count' ) ) {
/**
* Get our column grid class
*/
function generate_blog_get_column_count() {
$generate_blog_settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
$count = $generate_blog_settings['columns'];
return apply_filters( 'generate_blog_get_column_count', $count );
}
}

View File

@ -0,0 +1,149 @@
.masonry-enabled .page-header {
position: relative !important;
}
.separate-containers .site-main > .generate-columns-container {
margin-bottom: 0;
}
.masonry-container.are-images-unloaded,
.load-more.are-images-unloaded,
.masonry-enabled #nav-below {
opacity: 0;
}
/* columns */
.generate-columns-container:not(.masonry-container) {
display: flex;
flex-wrap: wrap;
align-items: stretch;
}
.generate-columns .inside-article {
height: 100%;
box-sizing: border-box;
}
.generate-columns-activated.post-image-aligned-left .generate-columns-container article:not(.featured-column) .post-image,
.generate-columns-activated.post-image-aligned-right .generate-columns-container article:not(.featured-column) .post-image {
float: none;
text-align: center;
margin-left: 0;
margin-right: 0;
}
.generate-columns-container .paging-navigation,
.generate-columns-container .page-header {
flex: 1 1 100%;
clear: both;
}
.generate-columns-container .paging-navigation {
margin-bottom: 0;
}
.load-more:not(.has-svg-icon) .button.loading:before {
content: "\e900";
display: inline-block;
font-family: "GP Premium";
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
animation: spin 2s infinite linear;
margin-right: 7px;
}
.load-more .button:not(.loading) .gp-icon {
display: none;
}
.load-more .gp-icon svg {
animation: spin 2s infinite linear;
margin-right: 7px;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.generate-columns {
box-sizing: border-box;
}
.generate-columns.grid-20,
.grid-sizer.grid-20 {
width: 20%;
}
.generate-columns.grid-25,
.grid-sizer.grid-25 {
width: 25%;
}
.generate-columns.grid-33,
.grid-sizer.grid-33 {
width: 33.3333%;
}
.generate-columns.grid-50,
.grid-sizer.grid-50 {
width: 50%;
}
.generate-columns.grid-60,
.grid-sizer.grid-60 {
width: 60%;
}
.generate-columns.grid-66,
.grid-sizer.grid-66 {
width: 66.66667%;
}
.generate-columns.grid-100,
.grid-sizer.grid-100 {
width: 100%;
}
@media (min-width: 768px) and (max-width: 1024px) {
.generate-columns.tablet-grid-50,
.grid-sizer.tablet-grid-50 {
width: 50%;
}
}
@media (max-width: 767px) {
.generate-columns-activated .generate-columns-container {
margin-left: 0;
margin-right: 0;
}
.generate-columns-container > *,
.generate-columns-container .generate-columns {
padding-left: 0;
}
.generate-columns-container .page-header {
margin-left: 0;
}
.generate-columns.mobile-grid-100,
.grid-sizer.mobile-grid-100 {
width: 100%;
}
.generate-columns-container > .paging-navigation {
margin-left: 0;
}
}
@media (max-width: 768px) {
.load-more {
display: block;
text-align: center;
margin-bottom: 0;
}
}

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-wrap:wrap;align-items:stretch}.generate-columns .inside-article{height:100%;box-sizing:border-box}.generate-columns-activated.post-image-aligned-left .generate-columns-container article:not(.featured-column) .post-image,.generate-columns-activated.post-image-aligned-right .generate-columns-container article:not(.featured-column) .post-image{float:none;text-align:center;margin-left:0;margin-right:0}.generate-columns-container .page-header,.generate-columns-container .paging-navigation{flex:1 1 100%;clear:both}.generate-columns-container .paging-navigation{margin-bottom:0}.load-more:not(.has-svg-icon) .button.loading:before{content:"\e900";display:inline-block;font-family:"GP Premium";font-style:normal;font-weight:400;font-variant:normal;text-transform:none;line-height:1;animation:spin 2s infinite linear;margin-right:7px}.load-more .button:not(.loading) .gp-icon{display:none}.load-more .gp-icon svg{animation:spin 2s infinite linear;margin-right:7px}@keyframes spin{0%{transform:rotate(0)}100%{transform:rotate(360deg)}}.generate-columns{box-sizing:border-box}.generate-columns.grid-20,.grid-sizer.grid-20{width:20%}.generate-columns.grid-25,.grid-sizer.grid-25{width:25%}.generate-columns.grid-33,.grid-sizer.grid-33{width:33.3333%}.generate-columns.grid-50,.grid-sizer.grid-50{width:50%}.generate-columns.grid-60,.grid-sizer.grid-60{width:60%}.generate-columns.grid-66,.grid-sizer.grid-66{width:66.66667%}.generate-columns.grid-100,.grid-sizer.grid-100{width:100%}@media (min-width:768px) and (max-width:1024px){.generate-columns.tablet-grid-50,.grid-sizer.tablet-grid-50{width:50%}}@media (max-width:767px){.generate-columns-activated .generate-columns-container{margin-left:0;margin-right:0}.generate-columns-container .generate-columns,.generate-columns-container>*{padding-left:0}.generate-columns-container .page-header{margin-left:0}.generate-columns.mobile-grid-100,.grid-sizer.mobile-grid-100{width:100%}.generate-columns-container>.paging-navigation{margin-left:0}}@media (max-width:768px){.load-more{display:block;text-align:center;margin-bottom:0}}

View File

@ -0,0 +1,104 @@
.post-image-above-header .inside-article .post-image,
.post-image-above-header .inside-article .featured-image {
margin-top: 0;
margin-bottom: 2em;
}
.post-image-aligned-left .inside-article .post-image,
.post-image-aligned-left .inside-article .featured-image {
margin-top: 0;
margin-right: 2em;
float: left;
text-align: left;
}
.post-image-aligned-center .post-image,
.post-image-aligned-center .featured-image {
text-align: center;
}
.post-image-aligned-right .inside-article .post-image,
.post-image-aligned-right .inside-article .featured-image {
margin-top: 0;
margin-left: 2em;
float: right;
text-align: right;
}
.post-image-below-header.post-image-aligned-right .inside-article .post-image,
.post-image-below-header.post-image-aligned-right .inside-article .featured-image,
.post-image-below-header.post-image-aligned-center .inside-article .featured-image,
.post-image-below-header.post-image-aligned-left .inside-article .post-image,
.post-image-below-header.post-image-aligned-left .inside-article .featured-image {
margin-top: 2em;
}
.post-image-aligned-left > .featured-image,
.post-image-aligned-right > .featured-image {
float: none;
margin-left: auto;
margin-right: auto;
}
.post-image-aligned-left .featured-image {
text-align: left;
}
.post-image-aligned-right .featured-image {
text-align: right;
}
.post-image-aligned-left .inside-article:before,
.post-image-aligned-left .inside-article:after,
.post-image-aligned-right .inside-article:before,
.post-image-aligned-right .inside-article:after {
content: "";
display: table;
}
.post-image-aligned-left .inside-article:after,
.post-image-aligned-right .inside-article:after {
clear: both;
}
.one-container.post-image-above-header .page-header + .no-featured-image-padding .inside-article .post-image,
.one-container.post-image-above-header .no-featured-image-padding.generate-columns .inside-article .post-image {
margin-top: 0;
}
.one-container.right-sidebar.post-image-aligned-center .no-featured-image-padding .post-image,
.one-container.right-sidebar.post-image-aligned-center .no-featured-image-padding .featured-image,
.one-container.both-right.post-image-aligned-center .no-featured-image-padding .post-image,
.one-container.both-right.post-image-aligned-center .no-featured-image-padding .featured-image {
margin-right: 0;
}
.one-container.left-sidebar.post-image-aligned-center .no-featured-image-padding .post-image,
.one-container.left-sidebar.post-image-aligned-center .no-featured-image-padding .featured-image,
.one-container.both-left.post-image-aligned-center .no-featured-image-padding .post-image,
.one-container.both-left.post-image-aligned-center .no-featured-image-padding .featured-image {
margin-left: 0;
}
.one-container.both-sidebars.post-image-aligned-center .no-featured-image-padding .post-image,
.one-container.both-sidebars.post-image-aligned-center .no-featured-image-padding .featured-image {
margin-left: 0;
margin-right: 0;
}
.one-container.post-image-aligned-center .no-featured-image-padding.generate-columns .post-image,
.one-container.post-image-aligned-center .no-featured-image-padding.generate-columns .featured-image {
margin-left: 0;
margin-right: 0;
}
@media (max-width: 768px) {
body:not(.post-image-aligned-center) .inside-article .post-image,
body:not(.post-image-aligned-center) .featured-image,
body:not(.post-image-aligned-center) .inside-article .featured-image {
margin-right: 0;
margin-left: 0;
float: none;
text-align: center;
}
}

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}.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}}

View File

@ -0,0 +1,254 @@
.post-image-above-header .inside-article .post-image,
.post-image-above-header .inside-article .featured-image {
margin-top: 0;
margin-bottom: 2em;
}
.post-image-aligned-left .inside-article .post-image,
.post-image-aligned-left .inside-article .featured-image {
margin-top: 0;
margin-right: 2em;
float: left;
text-align: left;
}
.post-image-aligned-center .post-image,
.post-image-aligned-center .featured-image {
text-align: center;
}
.post-image-aligned-right .inside-article .post-image,
.post-image-aligned-right .inside-article .featured-image {
margin-top: 0;
margin-left: 2em;
float: right;
text-align: right;
}
.post-image-below-header.post-image-aligned-right .inside-article .post-image,
.post-image-below-header.post-image-aligned-right .inside-article .featured-image,
.post-image-below-header.post-image-aligned-center .inside-article .featured-image,
.post-image-below-header.post-image-aligned-left .inside-article .post-image,
.post-image-below-header.post-image-aligned-left .inside-article .featured-image {
margin-top: 2em;
}
.post-image-aligned-left > .featured-image,
.post-image-aligned-right > .featured-image {
float: none;
margin-left: auto;
margin-right: auto;
}
.post-image-aligned-left .featured-image {
text-align: left;
}
.post-image-aligned-right .featured-image {
text-align: right;
}
.post-image-aligned-left .inside-article:before,
.post-image-aligned-left .inside-article:after,
.post-image-aligned-right .inside-article:before,
.post-image-aligned-right .inside-article:after {
content: "";
display: table;
}
.post-image-aligned-left .inside-article:after,
.post-image-aligned-right .inside-article:after {
clear: both;
}
.one-container.post-image-above-header .page-header + .no-featured-image-padding .inside-article .post-image,
.one-container.post-image-above-header .no-featured-image-padding.generate-columns .inside-article .post-image {
margin-top: 0;
}
.one-container.right-sidebar.post-image-aligned-center .no-featured-image-padding .post-image,
.one-container.right-sidebar.post-image-aligned-center .no-featured-image-padding .featured-image,
.one-container.both-right.post-image-aligned-center .no-featured-image-padding .post-image,
.one-container.both-right.post-image-aligned-center .no-featured-image-padding .featured-image {
margin-right: 0;
}
.one-container.left-sidebar.post-image-aligned-center .no-featured-image-padding .post-image,
.one-container.left-sidebar.post-image-aligned-center .no-featured-image-padding .featured-image,
.one-container.both-left.post-image-aligned-center .no-featured-image-padding .post-image,
.one-container.both-left.post-image-aligned-center .no-featured-image-padding .featured-image {
margin-left: 0;
}
.one-container.both-sidebars.post-image-aligned-center .no-featured-image-padding .post-image,
.one-container.both-sidebars.post-image-aligned-center .no-featured-image-padding .featured-image {
margin-left: 0;
margin-right: 0;
}
.one-container.post-image-aligned-center .no-featured-image-padding.generate-columns .post-image,
.one-container.post-image-aligned-center .no-featured-image-padding.generate-columns .featured-image {
margin-left: 0;
margin-right: 0;
}
@media (max-width: 768px) {
body:not(.post-image-aligned-center) .inside-article .post-image,
body:not(.post-image-aligned-center) .featured-image,
body:not(.post-image-aligned-center) .inside-article .featured-image {
margin-right: 0;
margin-left: 0;
float: none;
text-align: center;
}
}
.masonry-enabled .page-header {
position: relative !important;
}
.separate-containers .site-main > .generate-columns-container {
margin-bottom: 0;
}
.masonry-container.are-images-unloaded,
.load-more.are-images-unloaded,
.masonry-enabled #nav-below {
opacity: 0;
}
/* columns */
.generate-columns-container:not(.masonry-container) {
display: flex;
flex-wrap: wrap;
align-items: stretch;
}
.generate-columns .inside-article {
height: 100%;
box-sizing: border-box;
}
.generate-columns-activated.post-image-aligned-left .generate-columns-container article:not(.featured-column) .post-image,
.generate-columns-activated.post-image-aligned-right .generate-columns-container article:not(.featured-column) .post-image {
float: none;
text-align: center;
margin-left: 0;
margin-right: 0;
}
.generate-columns-container .paging-navigation,
.generate-columns-container .page-header {
flex: 1 1 100%;
clear: both;
}
.generate-columns-container .paging-navigation {
margin-bottom: 0;
}
.load-more:not(.has-svg-icon) .button.loading:before {
content: "\e900";
display: inline-block;
font-family: "GP Premium";
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
animation: spin 2s infinite linear;
margin-right: 7px;
}
.load-more .button:not(.loading) .gp-icon {
display: none;
}
.load-more .gp-icon svg {
animation: spin 2s infinite linear;
margin-right: 7px;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.generate-columns {
box-sizing: border-box;
}
.generate-columns.grid-20,
.grid-sizer.grid-20 {
width: 20%;
}
.generate-columns.grid-25,
.grid-sizer.grid-25 {
width: 25%;
}
.generate-columns.grid-33,
.grid-sizer.grid-33 {
width: 33.3333%;
}
.generate-columns.grid-50,
.grid-sizer.grid-50 {
width: 50%;
}
.generate-columns.grid-60,
.grid-sizer.grid-60 {
width: 60%;
}
.generate-columns.grid-66,
.grid-sizer.grid-66 {
width: 66.66667%;
}
.generate-columns.grid-100,
.grid-sizer.grid-100 {
width: 100%;
}
@media (min-width: 768px) and (max-width: 1024px) {
.generate-columns.tablet-grid-50,
.grid-sizer.tablet-grid-50 {
width: 50%;
}
}
@media (max-width: 767px) {
.generate-columns-activated .generate-columns-container {
margin-left: 0;
margin-right: 0;
}
.generate-columns-container > *,
.generate-columns-container .generate-columns {
padding-left: 0;
}
.generate-columns-container .page-header {
margin-left: 0;
}
.generate-columns.mobile-grid-100,
.grid-sizer.mobile-grid-100 {
width: 100%;
}
.generate-columns-container > .paging-navigation {
margin-left: 0;
}
}
@media (max-width: 768px) {
.load-more {
display: block;
text-align: center;
margin-bottom: 0;
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,58 @@
<?php
defined( 'WPINC' ) or die;
if ( ! function_exists( 'generate_blog_get_defaults' ) ) {
/**
* Set our defaults
*
* @since 0.1
*/
function generate_blog_get_defaults() {
$generate_blog_defaults = array(
'excerpt_length' => '55',
'read_more' => __( 'Read more', 'gp-premium' ),
'read_more_button' => false,
'masonry' => false,
'masonry_load_more' => __( '+ More', 'gp-premium' ),
'masonry_loading' => __( 'Loading...', 'gp-premium' ),
'infinite_scroll' => false,
'infinite_scroll_button' => false,
'post_image' => true,
'post_image_position' => '',
'post_image_alignment' => 'post-image-aligned-center',
'post_image_size' => 'full',
'post_image_width' => '',
'post_image_height' => '',
'post_image_padding' => true,
'single_post_image' => true,
'single_post_image_position' => 'inside-content',
'single_post_image_alignment' => 'center',
'single_post_image_size' => 'full',
'single_post_image_width' => '',
'single_post_image_height' => '',
'single_post_image_padding' => true,
'page_post_image' => true,
'page_post_image_position' => 'above-content',
'page_post_image_alignment' => 'center',
'page_post_image_size' => 'full',
'page_post_image_width' => '',
'page_post_image_height' => '',
'page_post_image_padding' => true,
'date' => true,
'author' => true,
'categories' => true,
'tags' => true,
'comments' => true,
'single_date' => true,
'single_author' => true,
'single_categories' => true,
'single_tags' => true,
'single_post_navigation' => true,
'column_layout' => false,
'columns' => '50',
'featured_column' => false,
);
return apply_filters( 'generate_blog_option_defaults', $generate_blog_defaults );
}
}

View File

@ -0,0 +1,754 @@
<?php
defined( 'WPINC' ) or die;
// Pull in our defaults and functions
require plugin_dir_path( __FILE__ ) . 'defaults.php';
require plugin_dir_path( __FILE__ ) . 'images.php';
require plugin_dir_path( __FILE__ ) . 'columns.php';
require plugin_dir_path( __FILE__ ) . 'customizer.php';
require plugin_dir_path( __FILE__ ) . 'migrate.php';
if ( ! function_exists( 'generate_blog_scripts' ) ) {
add_action( 'wp_enqueue_scripts', 'generate_blog_scripts', 50 );
/**
* Enqueue scripts and styles
*/
function generate_blog_scripts() {
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
$settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
wp_add_inline_style( 'generate-style', generate_blog_css() );
wp_add_inline_style( 'generate-style', generate_blog_columns_css() );
$deps = array();
if ( 'true' == generate_blog_get_masonry() && generate_blog_get_columns() ) {
$deps[] = 'masonry';
$deps[] = 'imagesloaded';
}
if ( $settings[ 'infinite_scroll' ] && ! is_singular() && ! is_404() && ! is_post_type_archive( 'product' ) ) {
$deps[] = 'infinite-scroll';
wp_enqueue_script( 'infinite-scroll', plugin_dir_url( __FILE__ ) . 'js/infinite-scroll.pkgd.min.js', array(), '3.0.6', true );
$font_icons = true;
if ( function_exists( 'generate_get_option' ) ) {
if ( 'font' !== generate_get_option( 'icons' ) ) {
$font_icons = false;
}
}
if ( $settings['infinite_scroll_button'] && $font_icons ) {
wp_enqueue_style( 'gp-premium-icons' );
}
}
if ( ( 'true' == generate_blog_get_masonry() && generate_blog_get_columns() ) || ( $settings[ 'infinite_scroll' ] && ! is_singular() && ! is_404() && ! is_post_type_archive( 'product' ) ) ) {
wp_enqueue_script( 'generate-blog', plugin_dir_url( __FILE__ ) . "js/scripts{$suffix}.js", $deps, GENERATE_BLOG_VERSION, true );
wp_localize_script(
'generate-blog',
'generateBlog',
array(
'more' => $settings['masonry_load_more'],
'loading' => $settings['masonry_loading'],
'icon' => function_exists( 'generate_get_svg_icon' ) ? generate_get_svg_icon( 'spinner' ) : '',
'masonryInit' => apply_filters(
'generate_blog_masonry_init',
array(
'columnWidth' => '.grid-sizer',
'itemSelector' => '.masonry-post',
'stamp' => '.page-header',
'percentPosition' => true,
'stagger' => 30,
'visibleStyle' => array(
'transform' => 'translateY(0)',
'opacity' => 1,
),
'hiddenStyle' => array(
'transform' => 'translateY(5px)',
'opacity' => 0,
),
)
),
'infiniteScrollInit' => apply_filters(
'generate_blog_infinite_scroll_init',
array(
'path' => '.infinite-scroll-path a',
'append' => '#main .infinite-scroll-item',
'history' => false,
'loadOnScroll' => $settings['infinite_scroll_button'] ? false : true,
'button' => $settings['infinite_scroll_button'] ? '.load-more a' : null,
'scrollThreshold' => $settings['infinite_scroll_button'] ? false : 600,
)
),
)
);
}
$needs_columns_css = false;
$needs_featured_image_css = false;
if ( generate_blog_get_columns() || $settings['infinite_scroll'] ) {
$needs_columns_css = true;
}
if ( ! is_singular() ) {
if ( $settings['post_image'] ) {
$needs_featured_image_css = true;
}
}
if ( is_page() && has_post_thumbnail() ) {
if ( $settings['page_post_image'] ) {
$needs_featured_image_css = true;
}
}
if ( is_single() && has_post_thumbnail() ) {
if ( $settings['single_post_image'] ) {
$needs_featured_image_css = true;
}
}
if ( $needs_columns_css && $needs_featured_image_css ) {
wp_enqueue_style( 'generate-blog', plugin_dir_url( __FILE__ ) . "css/style{$suffix}.css", array(), GENERATE_BLOG_VERSION );
} elseif ( $needs_columns_css ) {
wp_enqueue_style( 'generate-blog-columns', plugin_dir_url( __FILE__ ) . "css/columns{$suffix}.css", array(), GENERATE_BLOG_VERSION );
} elseif ( $needs_featured_image_css ) {
wp_enqueue_style( 'generate-blog-images', plugin_dir_url( __FILE__ ) . "css/featured-images{$suffix}.css", array(), GENERATE_BLOG_VERSION );
}
}
}
if ( ! function_exists( 'generate_blog_post_classes' ) ) {
add_filter( 'post_class', 'generate_blog_post_classes' );
/**
* Adds custom classes to the content container
*
* @since 0.1
*/
function generate_blog_post_classes( $classes ) {
// Don't add these classes to the GB Query Loop block items.
if ( in_array( 'gb-query-loop-item', $classes ) ) {
return $classes;
}
global $wp_query;
$paged = get_query_var( 'paged' );
$paged = $paged ? $paged : 1;
// Get our options
$settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
if ( $settings['infinite_scroll'] ) {
$classes[] = 'infinite-scroll-item';
}
// Set our masonry class
if ( 'true' == generate_blog_get_masonry() && generate_blog_get_columns() ) {
$classes[] = 'masonry-post';
}
// Set our column classes
if ( generate_blog_get_columns() && ! is_singular() ) {
$classes[] = 'generate-columns';
$classes[] = 'tablet-grid-50';
$classes[] = 'mobile-grid-100';
$classes[] = 'grid-parent';
// Set our featured column class
if ( $wp_query->current_post == 0 && $paged == 1 && $settings['featured_column'] ) {
if ( 50 == generate_blog_get_column_count() ) {
$classes[] = 'grid-100';
}
if ( 33 == generate_blog_get_column_count() ) {
$classes[] = 'grid-66';
}
if ( 25 == generate_blog_get_column_count() ) {
$classes[] = 'grid-50';
}
if ( 20 == generate_blog_get_column_count() ) {
$classes[] = 'grid-60';
}
$classes[] = 'featured-column';
} else {
$classes[] = 'grid-' . generate_blog_get_column_count();
}
}
if ( ! $settings['post_image_padding'] && ! is_singular() ) {
$classes[] = 'no-featured-image-padding';
}
$location = generate_blog_get_singular_template();
if ( ! $settings[$location . '_post_image_padding'] && is_singular() ) {
$classes[] = 'no-featured-image-padding';
}
$atts = generate_get_blog_image_attributes();
if ( ! is_singular() && has_post_thumbnail() && ! empty( $atts ) ) {
$values = array(
$atts['width'],
$atts['height'],
$atts['crop'],
);
$image_src = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID(), 'full' ), $values );
if ( $image_src && ( ! $image_src[3] || ! apply_filters( 'generate_use_featured_image_size_match', true ) ) ) {
$classes[] = 'resize-featured-image';
}
}
return $classes;
}
}
if ( ! function_exists( 'generate_blog_body_classes' ) ) {
add_filter( 'body_class', 'generate_blog_body_classes' );
/**
* Adds custom classes to the body
*
* @since 0.1
*/
function generate_blog_body_classes( $classes ) {
// Get theme options
$settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
if ( is_singular() ) {
$location = generate_blog_get_singular_template();
if ( 'below-title' == $settings[$location . '_post_image_position'] ) {
$classes[] = 'post-image-below-header';
}
if ( 'inside-content' == $settings[$location . '_post_image_position'] ) {
$classes[] = 'post-image-above-header';
}
$classes[] = ( ! empty( $settings[$location . '_post_image_alignment'] ) ) ? 'post-image-aligned-' . $settings[$location . '_post_image_alignment'] : 'post-image-aligned-center';
} else {
$classes[] = ( '' == $settings['post_image_position'] ) ? 'post-image-below-header' : 'post-image-above-header';
$classes[] = ( ! empty( $settings['post_image_alignment'] ) ) ? $settings['post_image_alignment'] : 'post-image-aligned-center';
}
if ( 'true' == generate_blog_get_masonry() && generate_blog_get_columns() ) {
$classes[] = 'masonry-enabled';
}
if ( generate_blog_get_columns() && ! is_singular() ) {
$classes[] = 'generate-columns-activated';
}
if ( $settings[ 'infinite_scroll' ] && ! is_singular() ) {
$classes[] = 'infinite-scroll';
}
return $classes;
}
}
if ( ! function_exists( 'generate_excerpt_length' ) ) {
add_filter( 'excerpt_length', 'generate_excerpt_length', 15 );
/**
* Set our excerpt length
*
* @since 0.1
*/
function generate_excerpt_length( $length ) {
$generate_settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
return absint( apply_filters( 'generate_excerpt_length', $generate_settings['excerpt_length'] ) );
}
}
if ( ! function_exists( 'generate_blog_css' ) ) {
/**
* Build our inline CSS
*
* @since 0.1
*/
function generate_blog_css() {
global $post;
$return = '';
$settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
if ( ! defined( 'GENERATE_VERSION' ) ) {
return;
}
if ( version_compare( GENERATE_VERSION, '3.0.0-alpha.1', '<' ) ) {
// Get disable headline meta.
$disable_headline = ( isset( $post ) ) ? get_post_meta( $post->ID, '_generate-disable-headline', true ) : '';
if ( ! $settings['categories'] && ! $settings['comments'] && ! $settings['tags'] && ! is_singular() ) {
$return .= '.blog footer.entry-meta, .archive footer.entry-meta {display:none;}';
}
if ( ! $settings['single_date'] && ! $settings['single_author'] && $disable_headline && is_singular() ) {
$return .= '.single .entry-header{display:none;}.single .entry-content {margin-top:0;}';
}
if ( ! $settings['date'] && ! $settings['author'] && ! is_singular() ) {
$return .= '.entry-header .entry-meta {display:none;}';
}
if ( ! $settings['single_date'] && ! $settings['single_author'] && is_singular() ) {
$return .= '.entry-header .entry-meta {display:none;}';
}
if ( ! $settings['single_post_navigation'] && is_singular() ) {
$return .= '.post-navigation {display:none;}';
}
if ( ! $settings['single_categories'] && ! $settings['single_post_navigation'] && ! $settings['single_tags'] && is_singular() ) {
$return .= '.single footer.entry-meta {display:none;}';
}
}
$separator = 20;
$content_padding_top = 40;
$content_padding_right = 40;
$content_padding_left = 40;
$mobile_content_padding_top = 30;
$mobile_content_padding_right = 30;
$mobile_content_padding_left = 30;
if ( function_exists( 'generate_spacing_get_defaults' ) ) {
$spacing_settings = wp_parse_args(
get_option( 'generate_spacing_settings', array() ),
generate_spacing_get_defaults()
);
$separator = absint( $spacing_settings['separator'] );
$content_padding_top = absint( $spacing_settings['content_top'] );
$content_padding_right = absint( $spacing_settings['content_right'] );
$content_padding_left = absint( $spacing_settings['content_left'] );
$mobile_content_padding_top = absint( $spacing_settings['mobile_content_top'] );
$mobile_content_padding_right = absint( $spacing_settings['mobile_content_right'] );
$mobile_content_padding_left = absint( $spacing_settings['mobile_content_left'] );
}
if ( 'true' == generate_blog_get_masonry() && generate_blog_get_columns() ) {
$return .= '.page-header {margin-bottom: ' . $separator . 'px;margin-left: ' . $separator . 'px}';
}
if ( $settings[ 'infinite_scroll' ] && ! is_singular() ) {
$return .= '#nav-below {display:none;}';
}
if ( ! $settings['post_image_padding'] && 'post-image-aligned-center' == $settings['post_image_alignment'] && ! is_singular() ) {
$return .= '.no-featured-image-padding .post-image {margin-left:-' . $content_padding_left . 'px;margin-right:-' . $content_padding_right . 'px;}';
$return .= '.post-image-above-header .no-featured-image-padding .inside-article .post-image {margin-top:-' . $content_padding_top . 'px;}';
}
$location = generate_blog_get_singular_template();
if ( ! $settings[$location . '_post_image_padding'] && 'center' == $settings[$location . '_post_image_alignment'] && is_singular() ) {
$return .= '.no-featured-image-padding .featured-image {margin-left:-' . $content_padding_left . 'px;margin-right:-' . $content_padding_right . 'px;}';
$return .= '.post-image-above-header .no-featured-image-padding .inside-article .featured-image {margin-top:-' . $content_padding_top . 'px;}';
}
if ( ! $settings['page_post_image_padding'] || ! $settings['single_post_image_padding'] || ! $settings['post_image_padding'] ) {
$return .= '@media ' . generate_premium_get_media_query( 'mobile' ) . '{';
if ( ! $settings['post_image_padding'] && 'post-image-aligned-center' == $settings['post_image_alignment'] && ! is_singular() ) {
$return .= '.no-featured-image-padding .post-image {margin-left:-' . $mobile_content_padding_left . 'px;margin-right:-' . $mobile_content_padding_right . 'px;}';
$return .= '.post-image-above-header .no-featured-image-padding .inside-article .post-image {margin-top:-' . $mobile_content_padding_top . 'px;}';
}
if ( ! $settings[$location . '_post_image_padding'] && 'center' == $settings[$location . '_post_image_alignment'] && is_singular() ) {
$return .= '.no-featured-image-padding .featured-image {margin-left:-' . $mobile_content_padding_left . 'px;margin-right:-' . $mobile_content_padding_right . 'px;}';
$return .= '.post-image-above-header .no-featured-image-padding .inside-article .featured-image {margin-top:-' . $mobile_content_padding_top . 'px;}';
}
$return .= '}';
}
$atts = generate_get_blog_image_attributes();
if ( ! empty( $atts ) ) {
$image_width = $atts['width'] && 9999 !== $atts['width'] ? 'width: ' . $atts['width'] . 'px;' : '';
$image_height = $atts['height'] && 9999 !== $atts['height'] ? 'height: ' . $atts['height'] . 'px;' : '';
$image_crop = $atts['crop'] ? '-o-object-fit: cover;object-fit: cover;' : '';
if ( ! $image_width && $image_height ) {
$image_crop = '-o-object-fit: cover;object-fit: cover;';
}
if ( ! is_singular() ) {
$return .= '.resize-featured-image .post-image img {' . $image_width . $image_height . $image_crop . '}';
}
if ( is_single() || is_page() ) {
$values = array(
$atts['width'],
$atts['height'],
$atts['crop'],
);
$image_src = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID(), 'full' ), $values );
if ( $image_src && ( ! $image_src[3] || ! apply_filters( 'generate_use_featured_image_size_match', true ) ) ) {
$return .= '.featured-image img {' . $image_width . $image_height . $image_crop . '}';
}
}
}
return $return;
}
}
add_filter( 'generate_excerpt_more_text', 'generate_blog_set_read_more_text' );
/**
* Set the read more text with our Customizer setting.
*
* @param string $text The read more text.
*/
function generate_blog_set_read_more_text( $text ) {
$settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
if ( $settings['read_more'] ) {
return wp_kses_post( $settings['read_more'] );
}
return $text;
}
if ( ! function_exists( 'generate_blog_excerpt_more' ) ) {
add_filter( 'excerpt_more', 'generate_blog_excerpt_more', 15 );
/**
* Prints the read more HTML
*/
function generate_blog_excerpt_more( $more ) {
$generate_settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
if ( '' == $generate_settings['read_more'] ) {
return '';
}
// We don't need to overwrite the entire element just to change its text.
// If we can filter the text, stop here.
if ( function_exists( 'generate_get_read_more_text' ) ) {
return $more;
}
return apply_filters(
'generate_excerpt_more_output',
sprintf(
' ... <a title="%1$s" class="read-more" href="%2$s" aria-label="%4$s">%3$s</a>',
the_title_attribute( 'echo=0' ),
esc_url( get_permalink( get_the_ID() ) ),
wp_kses_post( $generate_settings['read_more'] ),
sprintf(
/* translators: Aria-label describing the read more button */
_x( 'More on %s', 'more on post title', 'gp-premium' ),
the_title_attribute( 'echo=0' )
)
)
);
}
}
if ( ! function_exists( 'generate_blog_content_more' ) ) {
add_filter( 'the_content_more_link', 'generate_blog_content_more', 15 );
/**
* Prints the read more HTML
*/
function generate_blog_content_more( $more ) {
$generate_settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
if ( '' == $generate_settings['read_more'] ) {
return '';
}
// We don't need to overwrite the entire element just to change its text.
// If we can filter the text, stop here.
if ( function_exists( 'generate_get_read_more_text' ) ) {
return $more;
}
return apply_filters(
'generate_content_more_link_output',
sprintf(
'<p class="read-more-container"><a title="%1$s" class="read-more content-read-more" href="%2$s" aria-label="%4$s">%3$s</a></p>',
the_title_attribute( 'echo=0' ),
esc_url( get_permalink( get_the_ID() ) . apply_filters( 'generate_more_jump', '#more-' . get_the_ID() ) ),
wp_kses_post( $generate_settings['read_more'] ),
sprintf(
/* translators: Aria-label describing the read more button */
_x( 'More on %s', 'more on post title', 'gp-premium' ),
the_title_attribute( 'echo=0' )
)
)
);
}
}
/**
* Checks the setting and returns false if $thing is disabled
*
* @since 1.4
*
* @param String $data The original data, passed through if not disabled
* @param String $thing The name of the thing to check
* @return String|False The original data, or false (if disabled)
*/
function generate_disable_post_thing( $data, $thing ) {
$generate_blog_settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
if ( ! $generate_blog_settings[$thing] ) {
return false;
}
return $data;
}
if ( ! function_exists( 'generate_disable_post_date' ) ) {
add_filter( 'generate_post_date', 'generate_disable_post_date' );
/**
* Remove the post date if set
*
* @since 0.1
*/
function generate_disable_post_date( $date ) {
if ( is_singular() ) {
return generate_disable_post_thing( $date, 'single_date' );
} else {
return generate_disable_post_thing( $date, 'date' );
}
}
}
if ( ! function_exists( 'generate_disable_post_author' ) ) {
add_filter( 'generate_post_author', 'generate_disable_post_author' );
/**
* Set the author if set
*
* @since 0.1
*/
function generate_disable_post_author( $author ) {
if ( is_singular() ) {
return generate_disable_post_thing( $author, 'single_author' );
} else {
return generate_disable_post_thing( $author, 'author' );
}
}
}
if ( ! function_exists( 'generate_disable_post_categories' ) ) {
add_filter( 'generate_show_categories', 'generate_disable_post_categories' );
/**
* Remove the categories if set
*
* @since 0.1
*/
function generate_disable_post_categories( $categories ) {
if ( is_singular() ) {
return generate_disable_post_thing( $categories, 'single_categories' );
} else {
return generate_disable_post_thing( $categories, 'categories' );
}
}
}
if ( ! function_exists( 'generate_disable_post_tags' ) ) {
add_filter( 'generate_show_tags', 'generate_disable_post_tags' );
/**
* Remove the tags if set
*
* @since 0.1
*/
function generate_disable_post_tags( $tags ) {
if ( is_singular() ) {
return generate_disable_post_thing( $tags, 'single_tags' );
} else {
return generate_disable_post_thing( $tags, 'tags' );
}
}
}
if ( ! function_exists( 'generate_disable_post_comments_link' ) ) {
add_filter( 'generate_show_comments', 'generate_disable_post_comments_link' );
/**
* Remove the link to comments if set
*
* @since 0.1
*/
function generate_disable_post_comments_link( $comments_link ) {
return generate_disable_post_thing( $comments_link, 'comments' );
}
}
add_filter( 'generate_show_post_navigation', 'generate_disable_post_navigation' );
/**
* Remove the single post navigation
*
* @since 1.5
*/
function generate_disable_post_navigation( $navigation ) {
if ( is_singular() ) {
return generate_disable_post_thing( $navigation, 'single_post_navigation' );
} else {
return $navigation;
}
}
add_filter( 'generate_excerpt_more_output', 'generate_blog_read_more_button' );
add_filter( 'generate_content_more_link_output', 'generate_blog_read_more_button' );
/**
* Add the button class to our read more link if set.
*
* @since 1.5
*
* @param string $output Our existing read more link.
*/
function generate_blog_read_more_button( $output ) {
$settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
if ( ! $settings['read_more_button'] ) {
return $output;
}
$aria_label = function_exists( 'generate_get_read_more_aria_label' )
? generate_get_read_more_aria_label()
: sprintf(
/* translators: Aria-label describing the read more button */
_x( 'More on %s', 'more on post title', 'gp-premium' ),
the_title_attribute( 'echo=0' )
);
return sprintf(
'%5$s<p class="read-more-container"><a title="%1$s" class="read-more button" href="%2$s" aria-label="%4$s">%3$s</a></p>',
the_title_attribute( 'echo=0' ),
esc_url( get_permalink( get_the_ID() ) . apply_filters( 'generate_more_jump', '#more-' . get_the_ID() ) ),
wp_kses_post( $settings['read_more'] ),
$aria_label,
'generate_excerpt_more_output' === current_filter() ? ' ... ' : ''
);
}
if ( ! function_exists( 'generate_blog_load_more' ) ) {
add_action( 'generate_after_main_content', 'generate_blog_load_more', 20 );
/**
* Build our load more button
*/
function generate_blog_load_more() {
// Get theme options
$settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
if ( ( ! $settings[ 'infinite_scroll_button' ] || ! $settings[ 'infinite_scroll' ] ) || is_singular() || is_404() ) {
return;
}
global $wp_query;
if ( $wp_query->max_num_pages < 2 ) {
return;
}
if ( is_post_type_archive( 'product' ) ) {
return;
}
if ( is_tax( 'product_cat' ) ) {
return;
}
$icon = '';
if ( function_exists( 'generate_get_svg_icon' ) ) {
$icon = generate_get_svg_icon( 'spinner' );
}
printf(
'<div class="masonry-load-more load-more %1$s %2$s">
<a class="button" href="#">%3$s%4$s</a>
</div>',
$icon ? 'has-svg-icon' : '',
( 'true' == generate_blog_get_masonry() && generate_blog_get_columns() ) ? 'are-images-unloaded' : '',
$icon,
wp_kses_post( $settings['masonry_load_more'] )
);
}
}
/**
* Checks to see whether we're getting page or single post options.
*
* @since 1.5
*
* @return string Name of our singular template
*/
function generate_blog_get_singular_template() {
$template = 'single';
if ( is_page() ) {
$template = 'page';
}
return $template;
}
add_action( 'generate_after_footer', 'generate_blog_do_infinite_scroll_path', 500 );
/**
* Add a next page of posts link for infinite scroll.
*
* @since 2.0.0
*/
function generate_blog_do_infinite_scroll_path() {
if ( function_exists( 'is_woocommerce' ) && is_woocommerce() ) {
return;
}
$settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
if ( $settings['infinite_scroll'] && ! is_singular() && ! is_404() ) {
printf(
'<div class="infinite-scroll-path" aria-hidden="true" style="display: none;">%s</div>',
get_next_posts_link()
);
}
}

View File

@ -0,0 +1,369 @@
<?php
/**
* Functions specific to featured images.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
/**
* Collects all available image sizes which we use in the Customizer.
*
* @since 1.10.0
*
* @return array
*/
function generate_blog_get_image_sizes() {
$sizes = get_intermediate_image_sizes();
$new_sizes = array(
'full' => 'full',
);
foreach ( $sizes as $key => $name ) {
$new_sizes[ $name ] = $name;
}
return $new_sizes;
}
add_filter( 'generate_page_header_default_size', 'generate_blog_set_featured_image_size' );
/**
* Set our featured image sizes.
*
* @since 1.10.0
*
* @param string $size The existing size.
* @return string The new size.
*/
function generate_blog_set_featured_image_size( $size ) {
$settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
if ( ! is_singular() ) {
$size = $settings['post_image_size'];
}
if ( is_single() ) {
$size = $settings['single_post_image_size'];
}
if ( is_page() ) {
$size = $settings['page_post_image_size'];
}
$atts = generate_get_blog_image_attributes();
if ( ! empty( $atts ) ) {
$values = array(
$atts['width'],
$atts['height'],
$atts['crop'],
);
$image_src = wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID(), 'full' ), $values );
if ( $image_src && $image_src[3] && apply_filters( 'generate_use_featured_image_size_match', true ) ) {
return $values;
} else {
return $size;
}
}
return $size;
}
if ( ! function_exists( 'generate_get_blog_image_attributes' ) ) {
/**
* Build our image attributes
*
* @since 0.1
*/
function generate_get_blog_image_attributes() {
$settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
if ( is_singular() ) {
if ( is_singular( 'page' ) ) {
$single = 'page_';
} else {
$single = 'single_';
}
} else {
$single = '';
}
$ignore_crop = array( '', '0', '9999' );
$atts = array(
'width' => ( in_array( $settings[ "{$single}post_image_width" ], $ignore_crop ) ) ? 9999 : absint( $settings[ "{$single}post_image_width" ] ),
'height' => ( in_array( $settings[ "{$single}post_image_height" ], $ignore_crop ) ) ? 9999 : absint( $settings[ "{$single}post_image_height" ] ),
'crop' => ( in_array( $settings[ "{$single}post_image_width" ], $ignore_crop ) || in_array( $settings[ "{$single}post_image_height" ], $ignore_crop ) ) ? false : true,
);
// If there's no height or width, empty the array.
if ( 9999 == $atts['width'] && 9999 == $atts['height'] ) { // phpcs:ignore
$atts = array();
}
return apply_filters( 'generate_blog_image_attributes', $atts );
}
}
if ( ! function_exists( 'generate_blog_setup' ) ) {
add_action( 'wp', 'generate_blog_setup', 50 );
/**
* Setup our blog functions and actions
*
* @since 0.1
*/
function generate_blog_setup() {
$settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
// Move our featured images to above the title.
if ( 'post-image-above-header' === $settings['post_image_position'] ) {
remove_action( 'generate_after_entry_header', 'generate_post_image' );
add_action( 'generate_before_content', 'generate_post_image' );
// If we're using the Page Header add-on, move those as well.
if ( function_exists( 'generate_page_header_post_image' ) ) {
remove_action( 'generate_after_entry_header', 'generate_page_header_post_image' );
add_action( 'generate_before_content', 'generate_page_header_post_image' );
}
}
$page_header_content = false;
if ( function_exists( 'generate_page_header_get_options' ) ) {
$options = generate_page_header_get_options();
if ( $options && '' !== $options['content'] ) {
$page_header_content = true;
}
// If our Page Header has no content, remove it.
// This will allow the Blog add-on to add an image for us.
if ( ! $page_header_content && is_singular() ) {
remove_action( 'generate_before_content', 'generate_page_header' );
remove_action( 'generate_after_entry_header', 'generate_page_header' );
remove_action( 'generate_after_header', 'generate_page_header' );
}
}
// Remove the core theme featured image.
// I would like to filter instead one day.
remove_action( 'generate_after_header', 'generate_featured_page_header' );
remove_action( 'generate_before_content', 'generate_featured_page_header_inside_single' );
$location = generate_blog_get_singular_template();
if ( $settings[ $location . '_post_image' ] && is_singular() && ! $page_header_content ) {
if ( 'below-title' === $settings[ $location . '_post_image_position' ] ) {
add_action( 'generate_after_entry_header', 'generate_blog_single_featured_image' );
}
if ( 'inside-content' === $settings[ $location . '_post_image_position' ] ) {
add_action( 'generate_before_content', 'generate_blog_single_featured_image' );
}
if ( 'above-content' === $settings[ $location . '_post_image_position' ] ) {
add_action( 'generate_after_header', 'generate_blog_single_featured_image' );
}
}
}
}
add_filter( 'generate_featured_image_output', 'generate_blog_featured_image' );
/**
* Remove featured image if set or using WooCommerce.
*
* @since 1.5
* @param string $output The existing output.
* @return string The image HTML
*/
function generate_blog_featured_image( $output ) {
$settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
if ( ( function_exists( 'is_woocommerce' ) && is_woocommerce() ) || ! $settings['post_image'] ) {
return false;
}
return $output;
}
/**
* Build our featured images for single posts and pages.
*
* This function is way more complicated than it could be so it can
* ensure compatibility with the Page Header add-on.
*
* @since 1.5
*
* @return string The image HTML
*/
function generate_blog_single_featured_image() {
$settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
$image_id = get_post_thumbnail_id( get_the_ID(), 'full' );
if ( function_exists( 'generate_page_header_get_image' ) && generate_page_header_get_image( 'ID' ) ) {
if ( intval( $image_id ) !== generate_page_header_get_image( 'ID' ) ) {
$image_id = generate_page_header_get_image( 'ID' );
}
}
$location = generate_blog_get_singular_template();
if ( ( function_exists( 'is_woocommerce' ) && is_woocommerce() ) || ! $settings[ $location . '_post_image' ] || ! $image_id ) {
return false;
}
$attrs = array(
'itemprop' => 'image',
);
if ( function_exists( 'generate_get_schema_type' ) ) {
if ( 'microdata' !== generate_get_schema_type() ) {
$attrs = array();
}
}
$attrs['loading'] = false;
$attrs = apply_filters( 'generate_single_featured_image_attrs', $attrs );
$image_html = apply_filters(
'post_thumbnail_html', // phpcs:ignore -- Core filter.
wp_get_attachment_image(
$image_id,
apply_filters( 'generate_page_header_default_size', 'full' ),
'',
$attrs
),
get_the_ID(),
$image_id,
apply_filters( 'generate_page_header_default_size', 'full' ),
''
);
$location = generate_blog_get_singular_template();
$classes = array(
is_page() ? 'page-header-image' : null,
is_singular() && ! is_page() ? 'page-header-image-single' : null,
'above-content' === $settings[ $location . '_post_image_position' ] ? 'grid-container grid-parent' : null,
);
$image_html = apply_filters( 'generate_single_featured_image_html', $image_html );
// phpcs:ignore -- No need to escape here.
echo apply_filters(
'generate_single_featured_image_output',
sprintf(
'<div class="featured-image %2$s">
%1$s
</div>',
$image_html,
implode( ' ', $classes )
),
$image_html
);
}
add_filter( 'generate_blog_image_attributes', 'generate_blog_page_header_image_atts' );
/**
* Filter our image attributes in case we're using differents atts in our Page Header
*
* @since 1.5
*
* @param array $atts Our existing image attributes.
* @return array Image attributes
*/
function generate_blog_page_header_image_atts( $atts ) {
if ( ! function_exists( 'generate_page_header_get_options' ) ) {
return $atts;
}
if ( ! is_singular() ) {
return $atts;
}
$options = generate_page_header_get_options();
if ( $options && 'enable' === $options['image_resize'] ) {
$ignore_crop = array( '', '0', '9999' );
$atts = array(
'width' => ( in_array( $options['image_width'], $ignore_crop ) ) ? 9999 : absint( $options['image_width'] ),
'height' => ( in_array( $options['image_height'], $ignore_crop ) ) ? 9999 : absint( $options['image_height'] ),
'crop' => ( in_array( $options['image_width'], $ignore_crop ) || in_array( $options['image_height'], $ignore_crop ) ) ? false : true,
);
}
return $atts;
}
add_filter( 'generate_single_featured_image_html', 'generate_blog_page_header_link' );
/**
* Add our Page Header link to our featured image if set.
*
* @since 1.5
*
* @param string $image_html Our existing image HTML.
* @return string Our new image HTML.
*/
function generate_blog_page_header_link( $image_html ) {
if ( ! function_exists( 'generate_page_header_get_options' ) ) {
return $image_html;
}
$options = generate_page_header_get_options();
if ( ! empty( $options['image_link'] ) ) {
return '<a href="' . esc_url( $options['image_link'] ) . '"' . apply_filters( 'generate_page_header_link_target', '' ) . '>' . $image_html . '</a>';
} else {
return $image_html;
}
}
add_filter( 'body_class', 'generate_blog_remove_featured_image_class', 20 );
/**
* Remove the featured image classes if they're disabled.
*
* @since 2.1.0
* @param array $classes The body classes.
*/
function generate_blog_remove_featured_image_class( $classes ) {
if ( is_singular() ) {
$settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
if ( is_single() ) {
$disable_single_featured_image = ! $settings['single_post_image'];
$classes = generate_premium_remove_featured_image_class( $classes, $disable_single_featured_image );
}
if ( is_page() && ! $settings['page_post_image'] ) {
$disable_page_featured_image = ! $settings['page_post_image'];
$classes = generate_premium_remove_featured_image_class( $classes, $disable_page_featured_image );
}
}
return $classes;
}

View File

@ -0,0 +1,98 @@
jQuery( function( $ ) {
// Featured image controls
var featuredImageArchiveControls = [
'generate_blog_settings-post_image',
'generate_blog_settings-post_image_padding',
'generate_blog_settings-post_image_position',
'generate_blog_settings-post_image_alignment',
'generate_blog_settings-post_image_size',
'generate_blog_settings-post_image_width',
'generate_blog_settings-post_image_height',
'generate_regenerate_images_notice',
];
$.each( featuredImageArchiveControls, function( index, value ) {
$( '#customize-control-' + value ).attr( 'data-control-section', 'featured-image-archives' );
} );
var featuredImageSingleControls = [
'generate_blog_settings-single_post_image',
'generate_blog_settings-single_post_image_padding',
'generate_blog_settings-single_post_image_position',
'generate_blog_settings-single_post_image_alignment',
'generate_blog_settings-single_post_image_size',
'generate_blog_settings-single_post_image_width',
'generate_blog_settings-single_post_image_height',
'generate_regenerate_single_post_images_notice',
];
$.each( featuredImageSingleControls, function( index, value ) {
$( '#customize-control-' + value ).attr( 'data-control-section', 'featured-image-single' ).css( {
visibility: 'hidden',
height: '0',
width: '0',
margin: '0',
overflow: 'hidden',
} );
} );
var featuredImagePageControls = [
'generate_blog_settings-page_post_image',
'generate_blog_settings-page_post_image_padding',
'generate_blog_settings-page_post_image_position',
'generate_blog_settings-page_post_image_alignment',
'generate_blog_settings-page_post_image_size',
'generate_blog_settings-page_post_image_width',
'generate_blog_settings-page_post_image_height',
'generate_regenerate_page_images_notice',
];
$.each( featuredImagePageControls, function( index, value ) {
$( '#customize-control-' + value ).attr( 'data-control-section', 'featured-image-page' ).css( {
visibility: 'hidden',
height: '0',
width: '0',
margin: '0',
overflow: 'hidden',
} );
} );
// Post meta controls
var postMetaArchiveControls = [
'generate_settings-post_content',
'generate_blog_settings-excerpt_length',
'generate_blog_settings-read_more',
'generate_blog_settings-read_more_button',
'generate_blog_settings-date',
'generate_blog_settings-author',
'generate_blog_settings-categories',
'generate_blog_settings-tags',
'generate_blog_settings-comments',
'generate_blog_settings-infinite_scroll',
'generate_blog_settings-infinite_scroll_button',
'blog_masonry_load_more_control',
'blog_masonry_loading_control',
];
$.each( postMetaArchiveControls, function( index, value ) {
$( '#customize-control-' + value ).attr( 'data-control-section', 'post-meta-archives' );
} );
var postMetaSingleControls = [
'generate_blog_settings-single_date',
'generate_blog_settings-single_author',
'generate_blog_settings-single_categories',
'generate_blog_settings-single_tags',
'generate_blog_settings-single_post_navigation',
];
$.each( postMetaSingleControls, function( index, value ) {
$( '#customize-control-' + value ).attr( 'data-control-section', 'post-meta-single' ).css( {
visibility: 'hidden',
height: '0',
width: '0',
margin: '0',
overflow: 'hidden',
} );
} );
} );

View File

@ -0,0 +1,76 @@
/**
* Theme Customizer enhancements for a better user experience.
*
* Contains handlers to make Theme Customizer preview reload changes asynchronously.
*/
( function( $ ) {
// Container width
wp.customize( 'generate_settings[container_width]', function( value ) {
value.bind( function() {
if ( $( '.masonry-container' )[ 0 ] ) {
jQuery( '.masonry-container' ).imagesLoaded( function() {
$container = jQuery( '.masonry-container' );
if ( jQuery( $container ).length ) {
$container.masonry( {
columnWidth: '.grid-sizer',
itemSelector: '.masonry-post',
stamp: '.page-header',
} );
}
} );
}
} );
} );
$( 'body' ).on( 'generate_spacing_updated', function() {
if ( $( '.masonry-container' )[ 0 ] ) {
jQuery( '.masonry-container' ).imagesLoaded( function() {
$container = jQuery( '.masonry-container' );
if ( jQuery( $container ).length ) {
$container.masonry( {
columnWidth: '.grid-sizer',
itemSelector: '.masonry-post',
stamp: '.page-header',
} );
}
} );
}
} );
/**
* The first infinite scroll load in the Customizer misses article classes if they've been
* added or removed in the previous refresh.
*
* This is totally hacky, but I'm just happy I finally got it working!
*/
var $container = $( '.infinite-scroll-item' ).first().parent();
$container.on( 'load.infiniteScroll', function( event, response ) {
var $posts = $( response ).find( 'article' );
if ( wp.customize.value( 'generate_blog_settings[column_layout]' )() ) {
$posts.addClass( 'generate-columns' );
$posts.addClass( 'grid-parent' );
$posts.addClass( 'grid-' + wp.customize.value( 'generate_blog_settings[columns]' )() );
$posts.addClass( 'tablet-grid-50' );
$posts.addClass( 'mobile-grid-100' );
} else {
$posts.removeClass( 'generate-columns' );
$posts.removeClass( 'grid-parent' );
$posts.removeClass( 'grid-' + wp.customize.value( 'generate_blog_settings[columns]' )() );
$posts.removeClass( 'tablet-grid-50' );
$posts.removeClass( 'mobile-grid-100' );
}
if ( wp.customize.value( 'generate_blog_settings[masonry]' )() ) {
$posts.addClass( 'masonry-post' );
} else {
$posts.removeClass( 'masonry-post' );
}
if ( ! wp.customize.value( 'generate_blog_settings[post_image_padding]' )() ) {
$posts.addClass( 'no-featured-image-padding' );
} else {
$posts.removeClass( 'no-featured-image-padding' );
}
} );
}( jQuery ) );

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,100 @@
document.addEventListener( 'DOMContentLoaded', function() {
var msnryContainer = document.querySelector( '.masonry-container' );
if ( msnryContainer ) {
// eslint-disable-next-line no-undef -- Masonry is a dependency.
var msnry = new Masonry( msnryContainer, generateBlog.masonryInit ),
navBelow = document.querySelector( '#nav-below' ),
loadMore = document.querySelector( '.load-more' );
// eslint-disable-next-line no-undef -- imagesLoaded is a dependency.
imagesLoaded( msnryContainer, function() {
msnry.layout();
msnryContainer.classList.remove( 'are-images-unloaded' );
if ( loadMore ) {
loadMore.classList.remove( 'are-images-unloaded' );
}
if ( navBelow ) {
navBelow.style.opacity = 1;
}
} );
if ( navBelow ) {
msnryContainer.parentNode.insertBefore( navBelow, msnryContainer.nextSibling );
}
window.addEventListener( 'orientationchange', function() {
msnry.layout();
} );
}
var hasInfiniteScroll = document.querySelector( '.infinite-scroll' ),
nextLink = document.querySelector( '.infinite-scroll-path a' );
if ( hasInfiniteScroll && nextLink ) {
var infiniteItems = document.querySelectorAll( '.infinite-scroll-item' ),
container = infiniteItems[ 0 ].parentNode,
button = document.querySelector( '.load-more a' ),
svgIcon = '';
if ( generateBlog.icon ) {
svgIcon = generateBlog.icon;
}
var infiniteScrollInit = generateBlog.infiniteScrollInit;
infiniteScrollInit.outlayer = msnry;
// eslint-disable-next-line no-undef -- InfiniteScroll is a dependency.
var infiniteScroll = new InfiniteScroll( container, infiniteScrollInit );
if ( button ) {
button.addEventListener( 'click', function( e ) {
document.activeElement.blur();
e.target.innerHTML = svgIcon + generateBlog.loading;
e.target.classList.add( 'loading' );
} );
}
infiniteScroll.on( 'append', function( response, path, items ) {
if ( button && ! document.querySelector( '.generate-columns-container' ) ) {
container.appendChild( button.parentNode );
}
items.forEach( function( element ) {
var images = element.querySelectorAll( 'img' );
if ( images ) {
images.forEach( function( image ) {
var imgOuterHTML = image.outerHTML;
image.outerHTML = imgOuterHTML;
} );
}
} );
if ( msnryContainer && msnry ) {
// eslint-disable-next-line no-undef -- ImagesLoaded is a dependency.
imagesLoaded( msnryContainer, function() {
msnry.layout();
} );
}
if ( button ) {
button.innerHTML = svgIcon + generateBlog.more;
button.classList.remove( 'loading' );
}
document.body.dispatchEvent( new Event( 'post-load' ) );
} );
infiniteScroll.on( 'last', function() {
var loadMoreElement = document.querySelector( '.load-more' );
if ( loadMoreElement ) {
loadMoreElement.style.display = 'none';
}
} );
}
} );

View File

@ -0,0 +1 @@
document.addEventListener("DOMContentLoaded",function(){var t,e,n,r,a,i,l=document.querySelector(".masonry-container"),o=(l&&(t=new Masonry(l,generateBlog.masonryInit),e=document.querySelector("#nav-below"),n=document.querySelector(".load-more"),imagesLoaded(l,function(){t.layout(),l.classList.remove("are-images-unloaded"),n&&n.classList.remove("are-images-unloaded"),e&&(e.style.opacity=1)}),e&&l.parentNode.insertBefore(e,l.nextSibling),window.addEventListener("orientationchange",function(){t.layout()})),document.querySelector(".infinite-scroll")),c=document.querySelector(".infinite-scroll-path a");o&&c&&(r=document.querySelectorAll(".infinite-scroll-item")[0].parentNode,a=document.querySelector(".load-more a"),i="",generateBlog.icon&&(i=generateBlog.icon),(o=generateBlog.infiniteScrollInit).outlayer=t,c=new InfiniteScroll(r,o),a&&a.addEventListener("click",function(e){document.activeElement.blur(),e.target.innerHTML=i+generateBlog.loading,e.target.classList.add("loading")}),c.on("append",function(e,n,o){a&&!document.querySelector(".generate-columns-container")&&r.appendChild(a.parentNode),o.forEach(function(e){e=e.querySelectorAll("img");e&&e.forEach(function(e){var n=e.outerHTML;e.outerHTML=n})}),l&&t&&imagesLoaded(l,function(){t.layout()}),a&&(a.innerHTML=i+generateBlog.more,a.classList.remove("loading")),document.body.dispatchEvent(new Event("post-load"))}),c.on("last",function(){var e=document.querySelector(".load-more");e&&(e.style.display="none")}))});

View File

@ -0,0 +1,122 @@
<?php
defined( 'WPINC' ) or die;
add_action( 'admin_init', 'generate_blog_update_visibility_settings' );
/**
* Migrates our old Blog settings so we can use checkboxes instead.
*
* @since 1.5
*/
function generate_blog_update_visibility_settings() {
// Get our migration settings
$settings = get_option( 'generate_migration_settings', array() );
// If we've already ran this function, bail
if ( isset( $settings[ 'blog_visibility_updated' ] ) && 'true' == $settings[ 'blog_visibility_updated' ] ) {
return;
}
// A lot of the defaults changed, so lets put the old defaults here
$defaults = array(
'masonry' => 'false',
'masonry_width' => 'width2',
'masonry_most_recent_width' => 'width4',
'post_image' => 'true',
'date' => 'true',
'author' => 'true',
'categories' => 'true',
'tags' => 'true',
'comments' => 'true',
);
// Get our spacing settings
$blog_settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
$defaults
);
$new_settings = array();
// These options use to be a select input with false + true values
// This will make the false values empty so the options can be checkboxes
$keys = array( 'date', 'author', 'categories', 'tags', 'comments', 'masonry', 'post_image' );
foreach ( $keys as $key ) {
if ( is_string( $blog_settings[ $key ] ) ) {
if ( 'false' == $blog_settings[ $key ] ) {
$new_settings[ $key ] = false;
} elseif ( 'true' == $blog_settings[ $key ] ) {
$new_settings[ $key ] = true;
}
}
}
// Set the single post meta options to whatever the blog options are
$new_settings[ 'single_date' ] = isset( $new_settings[ 'date' ] ) ? $new_settings[ 'date' ] : true;
$new_settings[ 'single_author' ] = isset( $new_settings[ 'author' ] ) ? $new_settings[ 'author' ] : true;
$new_settings[ 'single_categories' ] = isset( $new_settings[ 'categories' ] ) ? $new_settings[ 'categories' ] : true;
$new_settings[ 'single_tags' ] = isset( $new_settings[ 'tags' ] ) ? $new_settings[ 'tags' ] : true;
if ( isset( $new_settings[ 'masonry' ] ) && $new_settings[ 'masonry' ] ) {
$new_settings[ 'column_layout' ] = true;
$new_settings[ 'infinite_scroll' ] = true;
$new_settings[ 'infinite_scroll_button' ] = true;
if ( 'width2' == $blog_settings['masonry_width'] ) {
$new_settings[ 'columns' ] = '33';
}
if ( 'width4' == $blog_settings['masonry_width'] ) {
$new_settings[ 'columns' ] = '50';
}
if ( 'width6' == $blog_settings['masonry_width'] ) {
$new_settings[ 'columns' ] = '100';
}
if ( 'width2' == $blog_settings[ 'masonry_width' ] ) {
if ( 'width2' !== $blog_settings[ 'masonry_most_recent_width' ] ) {
$new_settings[ 'featured_column' ] = true;
} else {
$new_settings[ 'featured_column' ] = false;
}
}
if ( 'width4' == $blog_settings[ 'masonry_width' ] ) {
if ( 'width6' == $blog_settings[ 'masonry_most_recent_width' ] ) {
$new_settings[ 'featured_column' ] = true;
} else {
$new_settings[ 'featured_column' ] = false;
}
}
if ( 'width6' == $blog_settings[ 'masonry_width' ] ) {
$new_settings[ 'featured_column' ] = false;
}
}
if ( function_exists( 'generate_page_header_get_defaults' ) ) {
$page_header_settings = wp_parse_args(
get_option( 'generate_page_header_settings', array() ),
generate_page_header_get_defaults()
);
if ( 'hide' == $page_header_settings[ 'post_header_position' ] ) {
$new_settings[ 'single_post_image' ] = false;
} else {
$new_settings[ 'single_post_image_position' ] = $page_header_settings[ 'post_header_position' ];
}
$new_settings[ 'page_post_image_position' ] = $page_header_settings[ 'page_header_position' ];
}
unset( $blog_settings['masonry_width'] );
unset( $blog_settings['masonry_most_recent_width'] );
$update_settings = wp_parse_args( $new_settings, $blog_settings );
update_option( 'generate_blog_settings', $update_settings );
// Update our migration option so we don't need to run this again
$updated[ 'blog_visibility_updated' ] = 'true';
$migration_settings = wp_parse_args( $updated, $settings );
update_option( 'generate_migration_settings', $migration_settings );
}

View File

@ -0,0 +1,20 @@
<?php
/**
* Blog module.
*
* @since 1.1.0
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
// Define the version. This used to be a standalone plugin, so we need to keep this constant.
if ( ! defined( 'GENERATE_BLOG_VERSION' ) ) {
define( 'GENERATE_BLOG_VERSION', GP_PREMIUM_VERSION );
}
// Include functions identical between standalone addon and GP Premium.
require plugin_dir_path( __FILE__ ) . 'functions/generate-blog.php';

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,620 @@
/**
* Theme Customizer enhancements for a better user experience.
*
* Contains handlers to make Theme Customizer preview reload changes asynchronously.
*/
function generate_colors_live_update( id, selector, property, default_value, get_value, settings ) {
default_value = typeof default_value !== 'undefined' ? default_value : 'initial';
get_value = typeof get_value !== 'undefined' ? get_value : '';
settings = typeof settings !== 'undefined' ? settings : 'generate_settings';
wp.customize( settings + '[' + id + ']', function( value ) {
value.bind( function( newval ) {
// Stop the header link color from applying to the site title.
if ( 'header_link_color' === id || 'header_link_color' === id ) {
jQuery( '.site-header a' ).addClass( 'header-link' );
jQuery( '.site-header .main-title a' ).removeClass( 'header-link' );
}
if ( 'content_link_color' === id || 'content_link_color_hover' === id || 'entry_meta_link_color' === id || 'blog_post_title_color' === id ) {
var content_link = jQuery( '.inside-article a' );
var meta = jQuery( '.entry-meta a' );
var title = jQuery( '.entry-title a' );
content_link.attr( 'data-content-link-color', true );
if ( '' !== wp.customize.value('generate_settings[entry_meta_link_color]')() ) {
meta.attr( 'data-content-link-color', '' );
} else {
meta.attr( 'data-content-link-color', true );
}
if ( '' !== wp.customize.value('generate_settings[blog_post_title_color]')() ) {
title.attr( 'data-content-link-color', '' );
} else {
title.attr( 'data-content-link-color', true );
}
}
default_value = ( '' !== get_value ) ? wp.customize.value('generate_settings[' + get_value + ']')() : default_value;
newval = ( '' !== newval ) ? newval : default_value;
var unique_id = ( 'generate_secondary_nav_settings' == settings ) ? 'secondary_' : '';
if ( jQuery( 'style#' + unique_id + id ).length ) {
jQuery( 'style#' + unique_id + id ).html( selector + '{' + property + ':' + newval + ';}' );
} else {
jQuery( 'head' ).append( '<style id="' + unique_id + id + '">' + selector + '{' + property + ':' + newval + '}</style>' );
setTimeout(function() {
jQuery( 'style#' + id ).not( ':last' ).remove();
}, 1000);
}
} );
} );
}
/**
* Header background color
* Empty: transparent
*/
generate_colors_live_update( 'top_bar_background_color', '.top-bar', 'background-color', 'transparent' );
/**
* Header text color
* Empty: text_color
*/
generate_colors_live_update( 'top_bar_text_color', '.top-bar', 'color', '', 'text_color' );
/**
* Header link color
* Empty: link_color
*/
generate_colors_live_update( 'top_bar_link_color', '.top-bar a, .top-bar a:visited', 'color', '', 'link_color' );
/**
* Header link color hover
* Empty: link_color_hover
*/
generate_colors_live_update( 'top_bar_link_color_hover', '.top-bar a:hover', 'color', '', 'link_color_hover' );
/**
* Header background color
* Empty: transparent
*/
generate_colors_live_update( 'header_background_color', '.site-header', 'background-color', 'transparent' );
/**
* Header text color
* Empty: text_color
*/
generate_colors_live_update( 'header_text_color', '.site-header', 'color', '', 'text_color' );
/**
* Header link color
* Empty: link_color
*/
generate_colors_live_update( 'header_link_color', '.site-header a.header-link, .site-header a.header-link:visited', 'color', '', 'link_color' );
/**
* Header link color hover
* Empty: link_color_hover
*/
generate_colors_live_update( 'header_link_hover_color', '.site-header a.header-link:hover', 'color', '', 'link_color_hover' );
/**
* Site title color
* Empty: link_color
*/
generate_colors_live_update( 'site_title_color', '.main-title a,.main-title a:hover,.main-title a:visited,.header-wrap .navigation-stick .main-title a, .header-wrap .navigation-stick .main-title a:hover, .header-wrap .navigation-stick .main-title a:visited', 'color', '', 'link_color' );
/**
* Site tagline color
* Empty: text_color
*/
generate_colors_live_update( 'site_tagline_color', '.site-description', 'color', '', 'text_color' );
/**
* Main navigation background
* Empty: transparent
*/
generate_colors_live_update( 'navigation_background_color', '.main-navigation', 'background-color', 'transparent' );
/**
* Primary navigation text color
* Empty: link_color
*/
generate_colors_live_update( 'navigation_text_color',
'.main-navigation .main-nav ul li a,\
.menu-toggle,button.menu-toggle:hover,\
button.menu-toggle:focus,\
.main-navigation .mobile-bar-items a,\
.main-navigation .mobile-bar-items a:hover,\
.main-navigation .mobile-bar-items a:focus,\
.main-navigation .menu-bar-items',
'color', '', 'link_color'
);
/**
* Primary navigation text color hover
* Empty: link_color_hover
*/
generate_colors_live_update( 'navigation_text_hover_color',
'.navigation-search input[type="search"],\
.navigation-search input[type="search"]:active,\
.navigation-search input[type="search"]:focus,\
.main-navigation .main-nav ul li:hover > a,\
.main-navigation .main-nav ul li:focus > a,\
.main-navigation .main-nav ul li.sfHover > a,\
.main-navigation .menu-bar-item:hover a',
'color', '', 'link_color_hover'
);
/**
* Primary navigation menu item hover
* Empty: link_color_hover
*/
generate_colors_live_update( 'navigation_background_hover_color',
'.navigation-search input[type="search"],\
.navigation-search input[type="search"]:focus,\
.main-navigation .main-nav ul li:hover > a,\
.main-navigation .main-nav ul li:focus > a,\
.main-navigation .main-nav ul li.sfHover > a,\
.main-navigation .menu-bar-item:hover a',
'background-color', 'transparent'
);
/**
* Primary sub-navigation color
* Empty: transparent
*/
generate_colors_live_update( 'subnavigation_background_color', '.main-navigation ul ul', 'background-color', 'transparent' );
/**
* Primary sub-navigation text color
* Empty: link_color
*/
generate_colors_live_update( 'subnavigation_text_color', '.main-navigation .main-nav ul ul li a', 'color', 'link_color' );
/**
* Primary sub-navigation hover
*/
var subnavigation_hover = '.main-navigation .main-nav ul ul li:hover > a, \
.main-navigation .main-nav ul ul li:focus > a, \
.main-navigation .main-nav ul ul li.sfHover > a';
/**
* Primary sub-navigation text hover
* Empty: link_color_hover
*/
generate_colors_live_update( 'subnavigation_text_hover_color', subnavigation_hover, 'color', '', 'link_color_hover' );
/**
* Primary sub-navigation background hover
* Empty: transparent
*/
generate_colors_live_update( 'subnavigation_background_hover_color', subnavigation_hover, 'background-color', 'transparent' );
/**
* Navigation current selectors
*/
var navigation_current = '.main-navigation .main-nav ul li[class*="current-menu-"] > a, \
.main-navigation .main-nav ul li[class*="current-menu-"]:hover > a, \
.main-navigation .main-nav ul li[class*="current-menu-"].sfHover > a';
/**
* Primary navigation current text
* Empty: link_color
*/
generate_colors_live_update( 'navigation_text_current_color', navigation_current, 'color', '', 'link_color' );
/**
* Primary navigation current text
* Empty: transparent
*/
generate_colors_live_update( 'navigation_background_current_color', navigation_current, 'background-color', 'transparent' );
/**
* Primary sub-navigation current selectors
*/
var subnavigation_current = '.main-navigation .main-nav ul ul li[class*="current-menu-"] > a,\
.main-navigation .main-nav ul ul li[class*="current-menu-"]:hover > a, \
.main-navigation .main-nav ul ul li[class*="current-menu-"].sfHover > a';
/**
* Primary sub-navigation current text
* Empty: link_color
*/
generate_colors_live_update( 'subnavigation_text_current_color', subnavigation_current, 'color', '', 'link_color' );
/**
* Primary navigation current item background
* Empty: transparent
*/
generate_colors_live_update( 'subnavigation_background_current_color', subnavigation_current, 'background-color', 'transparent' );
/**
* Secondary navigation background
* Empty: transparent
*/
generate_colors_live_update( 'navigation_background_color', '.secondary-navigation', 'background-color', 'transparent', '', 'generate_secondary_nav_settings' );
/**
* Secondary navigation text color
* Empty: link_color
*/
generate_colors_live_update( 'navigation_text_color',
'.secondary-navigation .main-nav ul li a,\
.secondary-navigation .menu-toggle,\
button.secondary-menu-toggle:hover,\
button.secondary-menu-toggle:focus, \
.secondary-navigation .top-bar, \
.secondary-navigation .top-bar a,\
.secondary-menu-bar-items,\
.secondary-menu-bar-items .menu-bar-item > a',
'color', '', 'link_color', 'generate_secondary_nav_settings'
);
/**
* Navigation search
*/
wp.customize( 'generate_settings[navigation_search_background_color]', function( value ) {
value.bind( function( newval ) {
if ( jQuery( 'style#navigation_search_background_color' ).length ) {
jQuery( 'style#navigation_search_background_color' ).html( '.navigation-search input[type="search"],.navigation-search input[type="search"]:active, .navigation-search input[type="search"]:focus, .main-navigation .main-nav ul li.search-item.active > a, .main-navigation .menu-bar-items .search-item.active > a{background-color:' + newval + ';}' );
} else {
jQuery( 'head' ).append( '<style id="navigation_search_background_color">.navigation-search input[type="search"],.navigation-search input[type="search"]:active, .navigation-search input[type="search"]:focus, .main-navigation .main-nav ul li.search-item.active > a, .main-navigation .menu-bar-items .search-item.active > a{background-color:' + newval + ';}</style>' );
setTimeout(function() {
jQuery( 'style#navigation_search_background_color' ).not( ':last' ).remove();
}, 1000);
}
if ( jQuery( 'style#navigation_search_background_opacity' ).length ) {
if ( newval ) {
jQuery( 'style#navigation_search_background_opacity' ).html( '.navigation-search input{opacity: 1;}' );
} else {
jQuery( 'style#navigation_search_background_opacity' ).html( '.navigation-search input{opacity: 0.9;}' );
}
} else {
if ( newval ) {
jQuery( 'head' ).append( '<style id="navigation_search_background_opacity">.navigation-search input{opacity: 1;}</style>' );
}
setTimeout(function() {
jQuery( 'style#navigation_search_background_opacity' ).not( ':last' ).remove();
}, 1000);
}
} );
} );
generate_colors_live_update( 'navigation_search_text_color', '.navigation-search input[type="search"],.navigation-search input[type="search"]:active, .navigation-search input[type="search"]:focus, .main-navigation .main-nav ul li.search-item.active > a, .main-navigation .menu-bar-items .search-item.active > a', 'color', '' );
/**
* Secondary navigation text color hover
* Empty: link_color_hover
*/
generate_colors_live_update( 'navigation_text_hover_color',
'.secondary-navigation .main-nav ul li:hover > a, \
.secondary-navigation .main-nav ul li:focus > a, \
.secondary-navigation .main-nav ul li.sfHover > a,\
.secondary-menu-bar-items .menu-bar-item:hover > a',
'color', '', 'link_color_hover', 'generate_secondary_nav_settings'
);
/**
* Secondary navigation menu item hover
* Empty: link_color_hover
*/
generate_colors_live_update( 'navigation_background_hover_color',
'.secondary-navigation .main-nav ul li:hover > a, \
.secondary-navigation .main-nav ul li:focus > a, \
.secondary-navigation .main-nav ul li.sfHover > a, \
.secondary-menu-bar-items .menu-bar-item:hover > a',
'background-color', 'transparent', '', 'generate_secondary_nav_settings'
);
/**
* Secondary navigation top bar link hover
*/
wp.customize( 'generate_secondary_nav_settings[navigation_background_hover_color]', function( value ) {
value.bind( function( newval ) {
if ( jQuery( 'style#secondary_nav_top_bar_hover' ).length ) {
jQuery( 'style#secondary_nav_top_bar_hover' ).html( '.secondary-navigation .top-bar a:hover,.secondary-navigation .top-bar a:focus{color:' + newval + ';}' );
} else {
jQuery( 'head' ).append( '<style id="secondary_nav_top_bar_hover">.secondary-navigation .top-bar a:hover,.secondary-navigation .top-bar a:focus{color:' + newval + ';}</style>' );
setTimeout(function() {
jQuery( 'style#secondary_nav_top_bar_hover' ).not( ':last' ).remove();
}, 1000);
}
} );
} );
generate_colors_live_update( 'navigation_top_bar_hover_color',
'.secondary-navigation .top-bar a:hover, \
.secondary-navigation .top-bar a:focus',
'color', 'transparent', '', 'generate_secondary_nav_settings'
);
/**
* Secondary sub-navigation color
* Empty: transparent
*/
generate_colors_live_update( 'subnavigation_background_color', '.secondary-navigation ul ul', 'background-color', 'transparent', '', 'generate_secondary_nav_settings' );
/**
* Secondary sub-navigation text color
* Empty: link_color
*/
generate_colors_live_update( 'subnavigation_text_color', '.secondary-navigation .main-nav ul ul li a', 'color', '', 'link_color', 'generate_secondary_nav_settings' );
/**
* Secondary sub-navigation hover
*/
var secondary_subnavigation_hover = '.secondary-navigation .main-nav ul ul li > a:hover, \
.secondary-navigation .main-nav ul ul li:focus > a, \
.secondary-navigation .main-nav ul ul li.sfHover > a';
/**
* Secondary sub-navigation text hover
* Empty: link_color_hover
*/
generate_colors_live_update( 'subnavigation_text_hover_color', secondary_subnavigation_hover, 'color', '', 'link_color_hover', 'generate_secondary_nav_settings' );
/**
* Secondary sub-navigation background hover
* Empty: transparent
*/
generate_colors_live_update( 'subnavigation_background_hover_color', secondary_subnavigation_hover, 'background-color', 'transparent', '', 'generate_secondary_nav_settings' );
/**
* Secondary navigation current selectors
*/
var secondary_navigation_current = '.secondary-navigation .main-nav ul li[class*="current-menu-"] > a, \
.secondary-navigation .main-nav ul li[class*="current-menu-"]:hover > a, \
.secondary-navigation .main-nav ul li[class*="current-menu-"].sfHover > a';
/**
* Secondary navigation current text
* Empty: link_color
*/
generate_colors_live_update( 'navigation_text_current_color', secondary_navigation_current, 'color', '', 'link_color', 'generate_secondary_nav_settings' );
/**
* Secondary navigation current text
* Empty: transparent
*/
generate_colors_live_update( 'navigation_background_current_color', secondary_navigation_current, 'background-color', 'transparent', '', 'generate_secondary_nav_settings' );
/**
* Secondary sub-navigation current selectors
*/
var secondary_subnavigation_current = '.secondary-navigation .main-nav ul ul li[class*="current-menu-"] > a,\
.secondary-navigation .main-nav ul ul li[class*="current-menu-"]:hover > a, \
.secondary-navigation .main-nav ul ul li[class*="current-menu-"].sfHover > a';
/**
* Secondary sub-navigation current text
* Empty: link_color
*/
generate_colors_live_update( 'subnavigation_text_current_color', secondary_subnavigation_current, 'color', '', 'link_color', 'generate_secondary_nav_settings' );
/**
* Primary navigation current item background
* Empty: transparent
*/
generate_colors_live_update( 'subnavigation_background_current_color', secondary_subnavigation_current, 'background-color', 'transparent', '', 'generate_secondary_nav_settings' );
/**
* Content selectors
*/
var content = '.separate-containers .inside-article,\
.separate-containers .comments-area,\
.separate-containers .page-header,\
.one-container .container,\
.separate-containers .paging-navigation,\
.inside-page-header';
/**
* Content background
* Empty: transparent
*/
generate_colors_live_update( 'content_background_color', content, 'background-color', 'transparent' );
/**
* Content text color
* Empty: text_color
*/
generate_colors_live_update( 'content_text_color', content, 'color', '', 'text_color' );
/**
* Content links
* Empty: link_color
*/
generate_colors_live_update( 'content_link_color',
'.inside-article a:not(.button):not(.wp-block-button__link)[data-content-link-color=true], \
.inside-article a:not(.button):not(.wp-block-button__link)[data-content-link-color=true]:visited,\
.paging-navigation a,\
.paging-navigation a:visited,\
.comments-area a,\
.comments-area a:visited,\
.page-header a,\
.page-header a:visited',
'color', '', 'link_color'
);
/**
* Content links on hover
* Empty: link_color_hover
*/
generate_colors_live_update( 'content_link_hover_color',
'.inside-article a:not(.button):not(.wp-block-button__link)[data-content-link-color=true]:hover,\
.paging-navigation a:hover,\
.comments-area a:hover,\
.page-header a:hover',
'color', '', 'link_color_hover'
);
generate_colors_live_update( 'content_title_color', '.entry-header h1,.page-header h1', 'color', 'inherit', 'text_color' );
generate_colors_live_update( 'blog_post_title_color', '.entry-title a,.entry-title a:visited', 'color', '', 'link_color' );
generate_colors_live_update( 'blog_post_title_hover_color', '.entry-title a:hover', 'color', '', 'link_color_hover' );
generate_colors_live_update( 'entry_meta_text_color', '.entry-meta', 'color', '', 'text_color' );
generate_colors_live_update( 'entry_meta_link_color', '.entry-meta a, .entry-meta a:visited', 'color', '', 'link_color' );
generate_colors_live_update( 'entry_meta_link_color_hover', '.entry-meta a:hover', 'color', '', 'link_color_hover' );
generate_colors_live_update( 'h1_color', 'h1', 'color', '', 'text_color' );
generate_colors_live_update( 'h2_color', 'h2', 'color', '', 'text_color' );
generate_colors_live_update( 'h3_color', 'h3', 'color', '', 'text_color' );
generate_colors_live_update( 'h4_color', 'h4', 'color', '', 'text_color' );
generate_colors_live_update( 'h5_color', 'h5', 'color', '', 'text_color' );
generate_colors_live_update( 'sidebar_widget_background_color', '.sidebar .widget', 'background-color', 'transparent' );
generate_colors_live_update( 'sidebar_widget_text_color', '.sidebar .widget', 'color', '', 'text_color' );
generate_colors_live_update( 'sidebar_widget_link_color', '.sidebar .widget a, .sidebar .widget a:visited', 'color', '', 'link_color' );
generate_colors_live_update( 'sidebar_widget_link_hover_color', '.sidebar .widget a:hover', 'color', '', 'link_color_hover' );
generate_colors_live_update( 'sidebar_widget_title_color', '.sidebar .widget .widget-title', 'color', '', 'text_color' );
generate_colors_live_update( 'footer_widget_background_color', '.footer-widgets', 'background-color', 'transparent' );
generate_colors_live_update( 'footer_widget_text_color', '.footer-widgets', 'color', '', 'text_color' );
generate_colors_live_update( 'footer_widget_link_color', '.footer-widgets a, .footer-widgets a:visited', 'color', '', 'link_color' );
generate_colors_live_update( 'footer_widget_link_hover_color', '.footer-widgets a:hover', 'color', '', 'link_color_hover' );
generate_colors_live_update( 'footer_widget_title_color', '.footer-widgets .widget-title', 'color', '', 'text_color' );
generate_colors_live_update( 'footer_background_color', '.site-info', 'background-color', 'transparent' );
generate_colors_live_update( 'footer_text_color', '.site-info', 'color', '', 'text_color' );
generate_colors_live_update( 'footer_link_color', '.site-info a, .site-info a:visited', 'color', '', 'link_color' );
generate_colors_live_update( 'footer_link_hover_color', '.site-info a:hover', 'color', '', 'link_color_hover' );
/**
* Form selectors
*/
var forms = 'input[type="text"], \
input[type="email"], \
input[type="url"], \
input[type="password"], \
input[type="search"], \
input[type="number"], \
input[type="tel"], \
textarea, \
select';
/**
* Form background
* Empty: inherit
*/
generate_colors_live_update( 'form_background_color', forms, 'background-color', 'inherit' );
/**
* Border color
* Empty: inherit
*/
generate_colors_live_update( 'form_border_color', forms, 'border-color' );
/**
* Form text color
* Empty: text_color
*/
generate_colors_live_update( 'form_text_color', forms, 'color', '', 'text_color' );
/**
* Form background on focus selectors
* Empty: inherit
*/
var forms_focus = 'input[type="text"]:focus, \
input[type="email"]:focus, \
input[type="url"]:focus, \
input[type="password"]:focus, \
input[type="search"]:focus,\
input[type="number"]:focus,\
input[type="tel"]:focus, \
textarea:focus, \
select:focus';
/**
* Form background color on focus
* Empty: initial
*/
generate_colors_live_update( 'form_background_color_focus', forms_focus, 'background-color' );
/**
* Form text color on focus
* Empty: initial
*/
generate_colors_live_update( 'form_text_color_focus', forms_focus, 'color' );
/**
* Form border color on focus
* Empty: initial
*/
generate_colors_live_update( 'form_border_color_focus', forms_focus, 'border-color' );
/**
* Button selectors
*/
var button = 'button, \
html input[type="button"], \
input[type="reset"], \
input[type="submit"],\
a.button,\
a.button:visited,\
a.wp-block-button__link:not(.has-background)';
/**
* Button background
* Empty: initial
*/
generate_colors_live_update( 'form_button_background_color', button, 'background-color' );
/**
* Button text
* Empty: initial
*/
generate_colors_live_update( 'form_button_text_color', button, 'color' );
/**
* Button on hover/focus selectors
* Empty: initial
*/
var button_hover = 'button:hover, \
html input[type="button"]:hover, \
input[type="reset"]:hover, \
input[type="submit"]:hover,\
a.button:hover,\
button:focus, \
html input[type="button"]:focus, \
input[type="reset"]:focus, \
input[type="submit"]:focus,\
a.button:focus,\
a.wp-block-button__link:not(.has-background):active,\
a.wp-block-button__link:not(.has-background):focus,\
a.wp-block-button__link:not(.has-background):hover';
/**
* Button color on hover
* Empty: initial
*/
generate_colors_live_update( 'form_button_background_color_hover', button_hover, 'background-color' );
/**
* Button text color on hover
* Empty: initial
*/
generate_colors_live_update( 'form_button_text_color_hover', button_hover, 'color' );
/**
* Back to top background color
* Empty: transparent
*/
generate_colors_live_update( 'back_to_top_background_color', 'a.generate-back-to-top', 'background-color', 'transparent' );
/**
* Back to top text color
* Empty: text_color
*/
generate_colors_live_update( 'back_to_top_text_color', 'a.generate-back-to-top', 'color', '', 'text_color' );
/**
* Back to top background color hover
* Empty: transparent
*/
generate_colors_live_update( 'back_to_top_background_color_hover', 'a.generate-back-to-top:hover,a.generate-back-to-top:focus', 'background-color', 'transparent' );
/**
* Back to top text color hover
* Empty: text_color
*/
generate_colors_live_update( 'back_to_top_text_color_hover', 'a.generate-back-to-top:hover,a.generate-back-to-top:focus', 'color', '', 'text_color' );

View File

@ -0,0 +1,102 @@
/**
* Main navigation background
* Empty: transparent
*/
generate_colors_live_update( 'slideout_background_color', '.main-navigation.slideout-navigation', 'background-color', '' );
/**
* Primary navigation text color
* Empty: link_color
*/
generate_colors_live_update( 'slideout_text_color', '.slideout-navigation.main-navigation .main-nav ul li a, .slideout-navigation a, .slideout-navigation', 'color', '' );
/**
* Primary navigation text color hover
* Empty: link_color_hover
*/
generate_colors_live_update( 'slideout_text_hover_color',
'.slideout-navigation.main-navigation .main-nav ul li:hover > a,\
.slideout-navigation.main-navigation .main-nav ul li:focus > a,\
.slideout-navigation.main-navigation .main-nav ul li.sfHover > a',
'color', ''
);
/**
* Primary navigation menu item hover
* Empty: link_color_hover
*/
generate_colors_live_update( 'slideout_background_hover_color',
'.slideout-navigation.main-navigation .main-nav ul li:hover > a,\
.slideout-navigation.main-navigation .main-nav ul li:focus > a,\
.slideout-navigation.main-navigation .main-nav ul li.sfHover > a',
'background-color', 'transparent'
);
/**
* Primary sub-navigation color
* Empty: transparent
*/
generate_colors_live_update( 'slideout_submenu_background_color', '.slideout-navigation.main-navigation ul ul', 'background-color', '' );
/**
* Primary sub-navigation text color
* Empty: link_color
*/
generate_colors_live_update( 'slideout_submenu_text_color', '.slideout-navigation.main-navigation .main-nav ul ul li a', 'color', '' );
/**
* Primary sub-navigation hover
*/
var slideout_submenu_hover = '.slideout-navigation.main-navigation .main-nav ul ul li:hover > a,\
.slideout-navigation.main-navigation .main-nav ul ul li:focus > a,\
.slideout-navigation.main-navigation .main-nav ul ul li.sfHover > a';
/**
* Primary sub-navigation text hover
* Empty: link_color_hover
*/
generate_colors_live_update( 'slideout_submenu_text_hover_color', slideout_submenu_hover, 'color', '' );
/**
* Primary sub-navigation background hover
* Empty: transparent
*/
generate_colors_live_update( 'slideout_submenu_background_hover_color', slideout_submenu_hover, 'background-color', '' );
/**
* Navigation current selectors
*/
var slideout_current = '.slideout-navigation.main-navigation .main-nav ul li[class*="current-menu-"] > a,\
.slideout-navigation.main-navigation .main-nav ul li[class*="current-menu-"] > a:hover,\
.slideout-navigation.main-navigation .main-nav ul li[class*="current-menu-"].sfHover > a';
/**
* Primary navigation current text
* Empty: link_color
*/
generate_colors_live_update( 'slideout_text_current_color', slideout_current, 'color', '' );
/**
* Primary navigation current text
* Empty: transparent
*/
generate_colors_live_update( 'slideout_background_current_color', slideout_current, 'background-color' );
/**
* Primary sub-navigation current selectors
*/
var slideout_submenu_current = '.slideout-navigation.main-navigation .main-nav ul ul li[class*="current-menu-"] > a,\
.slideout-navigation.main-navigation .main-nav ul ul li[class*="current-menu-"] > a:hover,\
.slideout-navigation.main-navigation .main-nav ul ul li[class*="current-menu-"].sfHover > a';
/**
* Primary sub-navigation current text
* Empty: link_color
*/
generate_colors_live_update( 'slideout_submenu_text_current_color', slideout_submenu_current, 'color', '' );
/**
* Primary navigation current item background
* Empty: transparent
*/
generate_colors_live_update( 'slideout_submenu_background_current_color', slideout_submenu_current, 'background-color' );

View File

@ -0,0 +1,161 @@
/**
* WooCommerce link color
*/
generate_colors_live_update( 'wc_product_title_color', '.woocommerce ul.products li.product .woocommerce-LoopProduct-link', 'color', '', 'link_color' );
generate_colors_live_update( 'wc_product_title_color_hover', '.woocommerce ul.products li.product .woocommerce-LoopProduct-link:hover', 'color', '', 'link_color_hover' );
/**
* WooCommerce primary button
*/
var wc_button = '.woocommerce #respond input#submit, .woocommerce a.button, .woocommerce button.button, .woocommerce input.button, button, \
html input[type="button"], \
input[type="reset"], \
input[type="submit"],\
.button,\
.button:visited';
generate_colors_live_update( 'form_button_background_color', wc_button, 'background-color' );
generate_colors_live_update( 'form_button_text_color', wc_button, 'color' );
/**
* WooCommerce primary button hover
*/
var wc_button_hover = '.woocommerce #respond input#submit:hover, .woocommerce a.button:hover, .woocommerce button.button:hover, .woocommerce input.button:hover,button:hover, \
html input[type="button"]:hover, \
input[type="reset"]:hover, \
input[type="submit"]:hover,\
.button:hover,\
button:focus, \
html input[type="button"]:focus, \
input[type="reset"]:focus, \
input[type="submit"]:focus,\
.button:focus';
generate_colors_live_update( 'form_button_background_color_hover', wc_button_hover, 'background-color' );
generate_colors_live_update( 'form_button_text_color_hover', wc_button_hover, 'color' );
/**
* WooCommerce alt button
*/
var wc_alt_button = '.woocommerce #respond input#submit.alt, .woocommerce a.button.alt, .woocommerce button.button.alt, .woocommerce input.button.alt';
generate_colors_live_update( 'wc_alt_button_background', wc_alt_button, 'background-color' );
generate_colors_live_update( 'wc_alt_button_text', wc_alt_button, 'color' );
/**
* WooCommerce alt button hover
*/
var wc_alt_button_hover = '.woocommerce #respond input#submit.alt:hover, .woocommerce a.button.alt:hover, .woocommerce button.button.alt:hover, .woocommerce input.button.alt:hover';
generate_colors_live_update( 'wc_alt_button_background_hover', wc_alt_button_hover, 'background-color' );
generate_colors_live_update( 'wc_alt_button_text_hover', wc_alt_button_hover, 'color' );
/**
* WooCommerce star ratings
*/
var wc_stars = '.woocommerce .star-rating span:before, .woocommerce .star-rating:before';
generate_colors_live_update( 'wc_rating_stars', wc_stars, 'color' );
/**
* WooCommerce sale sticker
*/
var wc_sale_sticker = '.woocommerce span.onsale';
generate_colors_live_update( 'wc_sale_sticker_background', wc_sale_sticker, 'background-color' );
generate_colors_live_update( 'wc_sale_sticker_text', wc_sale_sticker, 'color' );
/**
* WooCommerce price
*/
var wc_price = '.woocommerce ul.products li.product .price, .woocommerce div.product p.price';
generate_colors_live_update( 'wc_price_color', wc_price, 'color' );
/**
* WooCommerce product tab text
*/
var wc_product_tab = '.woocommerce div.product .woocommerce-tabs ul.tabs li a';
generate_colors_live_update( 'wc_product_tab', wc_product_tab, 'color' );
/**
* WooCommerce product tab text highlight/active
*/
var wc_product_tab_active = '.woocommerce div.product .woocommerce-tabs ul.tabs li a:hover, .woocommerce div.product .woocommerce-tabs ul.tabs li.active a';
generate_colors_live_update( 'wc_product_tab_highlight', wc_product_tab_active, 'color' );
/**
* WooCommerce success message
*/
var wc_success_message = '.woocommerce-message';
generate_colors_live_update( 'wc_success_message_background', wc_success_message, 'background-color' );
generate_colors_live_update( 'wc_success_message_text', wc_success_message + ', div.woocommerce-message a.button, div.woocommerce-message a.button:focus, div.woocommerce-message a.button:hover, div.woocommerce-message a, div.woocommerce-message a:focus, div.woocommerce-message a:hover', 'color' );
/**
* WooCommerce info message
*/
var wc_info_message = '.woocommerce-info';
generate_colors_live_update( 'wc_info_message_background', wc_info_message, 'background-color' );
generate_colors_live_update( 'wc_info_message_text', wc_info_message + ', div.woocommerce-info a.button, div.woocommerce-info a.button:focus, div.woocommerce-info a.button:hover, div.woocommerce-info a, div.woocommerce-info a:focus, div.woocommerce-info a:hover', 'color' );
/**
* WooCommerce error message
*/
var wc_error_message = '.woocommerce-error';
generate_colors_live_update( 'wc_error_message_background', wc_error_message, 'background-color' );
generate_colors_live_update( 'wc_error_message_text', wc_error_message + ', div.woocommerce-error a.button, div.woocommerce-error a.button:focus, div.woocommerce-error a.button:hover, div.woocommerce-error a, div.woocommerce-error a:focus, div.woocommerce-error a:hover', 'color' );
/**
* Menu Mini Cart
*/
generate_colors_live_update( 'wc_mini_cart_background_color', '#wc-mini-cart', 'background-color' );
generate_colors_live_update( 'wc_mini_cart_text_color', '#wc-mini-cart,#wc-mini-cart a:not(.button), #wc-mini-cart a.remove', 'color' );
generate_colors_live_update( 'wc_mini_cart_button_background', '#wc-mini-cart .button.checkout', 'background-color' );
generate_colors_live_update( 'wc_mini_cart_button_text', '#wc-mini-cart .button.checkout', 'color' );
generate_colors_live_update( 'wc_mini_cart_button_background_hover', '#wc-mini-cart .button.checkout:hover, #wc-mini-cart .button.checkout:focus, #wc-mini-cart .button.checkout:active', 'background-color' );
generate_colors_live_update( 'wc_mini_cart_button_text_hover', '#wc-mini-cart .button.checkout:hover, #wc-mini-cart .button.checkout:focus, #wc-mini-cart .button.checkout:active', 'color' );
/**
* Sticky panel cart button
*/
generate_colors_live_update( 'wc_panel_cart_background_color', '.add-to-cart-panel', 'background-color' );
generate_colors_live_update( 'wc_panel_cart_text_color', '.add-to-cart-panel, .add-to-cart-panel a:not(.button)', 'color' );
generate_colors_live_update( 'wc_panel_cart_button_background', '#wc-sticky-cart-panel .button', 'background-color' );
generate_colors_live_update( 'wc_panel_cart_button_text', '#wc-sticky-cart-panel .button', 'color' );
generate_colors_live_update( 'wc_panel_cart_button_background_hover', '#wc-sticky-cart-panel .button:hover, #wc-sticky-cart-panel .button:focus, #wc-sticky-cart-panel .button:active', 'background-color' );
generate_colors_live_update( 'wc_panel_cart_button_text_hover', '#wc-sticky-cart-panel .button:hover, #wc-sticky-cart-panel .button:focus, #wc-sticky-cart-panel .button:active', 'color' );
/**
* Price slider bar
*/
generate_colors_live_update( 'wc_price_slider_background_color', '.woocommerce .widget_price_filter .price_slider_wrapper .ui-widget-content', 'background-color' );
generate_colors_live_update( 'wc_price_slider_bar_color', '.woocommerce .widget_price_filter .ui-slider .ui-slider-range, .woocommerce .widget_price_filter .ui-slider .ui-slider-handle', 'background-color' );
// Archive product description text
wp.customize( 'generate_settings[text_color]', function( value ) {
value.bind( function( newval ) {
if ( ! wp.customize.value('generate_settings[content_text_color]')() ) {
if ( jQuery( 'style#wc_desc_color' ).length ) {
jQuery( 'style#wc_desc_color' ).html( '.woocommerce-product-details__short-description{color:' + newval + ';}' );
} else {
jQuery( 'head' ).append( '<style id="wc_desc_color">.woocommerce-product-details__short-description{color:' + newval + ';}</style>' );
setTimeout(function() {
jQuery( 'style#wc_desc_color' ).not( ':last' ).remove();
}, 1000);
}
}
} );
} );
wp.customize( 'generate_settings[content_text_color]', function( value ) {
value.bind( function( newval ) {
if ( '' == newval ) {
newval = wp.customize.value('generate_settings[text_color]')();
}
if ( jQuery( 'style#wc_desc_color' ).length ) {
jQuery( 'style#wc_desc_color' ).html( '.woocommerce-product-details__short-description{color:' + newval + ';}' );
} else {
jQuery( 'head' ).append( '<style id="wc_desc_color">.woocommerce-product-details__short-description{color:' + newval + ';}</style>' );
setTimeout(function() {
jQuery( 'style#wc_desc_color' ).not( ':last' ).remove();
}, 1000);
}
} );
} );

View File

@ -0,0 +1,403 @@
<?php
/**
* This file handles the Customizer options for the Secondary Nav module.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
if ( ! function_exists( 'generate_colors_secondary_nav_customizer' ) ) {
add_action( 'customize_register', 'generate_colors_secondary_nav_customizer', 1000 );
/**
* Adds our Secondary Nav color options
*
* These options are in their own function so we can hook it in late to
* make sure Secondary Nav is activated.
*
* 1000 priority is there to make sure Secondary Nav is registered (999)
* as we check to see if the layout control exists.
*
* Secondary Nav now uses 100 as a priority.
*
* @param object $wp_customize The Customizer object.
*/
function generate_colors_secondary_nav_customizer( $wp_customize ) {
// Bail if Secondary Nav isn't activated.
if ( ! $wp_customize->get_section( 'secondary_nav_section' ) ) {
return;
}
// Bail if we don't have our color defaults.
if ( ! function_exists( 'generate_secondary_nav_get_defaults' ) ) {
return;
}
// Add our controls.
require_once GP_LIBRARY_DIRECTORY . 'customizer-helpers.php';
// Get our defaults.
$defaults = generate_secondary_nav_get_defaults();
// Add control types so controls can be built using JS.
if ( method_exists( $wp_customize, 'register_control_type' ) ) {
$wp_customize->register_control_type( 'GeneratePress_Alpha_Color_Customize_Control' );
$wp_customize->register_control_type( 'GeneratePress_Title_Customize_Control' );
$wp_customize->register_control_type( 'GeneratePress_Section_Shortcut_Control' );
}
// Get our palettes.
$palettes = generate_get_default_color_palettes();
// Add Secondary Navigation section.
$wp_customize->add_section(
'secondary_navigation_color_section',
array(
'title' => __( 'Secondary Navigation', 'gp-premium' ),
'capability' => 'edit_theme_options',
'priority' => 71,
'panel' => 'generate_colors_panel',
)
);
$wp_customize->add_control(
new GeneratePress_Section_Shortcut_Control(
$wp_customize,
'generate_secondary_navigation_color_shortcuts',
array(
'section' => 'secondary_navigation_color_section',
'element' => __( 'Secondary Navigation', 'gp-premium' ),
'shortcuts' => array(
'layout' => 'secondary_nav_section',
'typography' => 'secondary_font_section',
'backgrounds' => 'secondary_bg_images_section',
),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
'priority' => 1,
)
)
);
$wp_customize->add_control(
new GeneratePress_Title_Customize_Control(
$wp_customize,
'generate_secondary_navigation_items',
array(
'section' => 'secondary_navigation_color_section',
'type' => 'generatepress-customizer-title',
'title' => __( 'Parent Items', 'gp-premium' ),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
)
)
);
// Background.
$wp_customize->add_setting(
'generate_secondary_nav_settings[navigation_background_color]',
array(
'default' => $defaults['navigation_background_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_rgba',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new GeneratePress_Alpha_Color_Customize_Control(
$wp_customize,
'secondary_navigation_background_color',
array(
'label' => __( 'Background', 'gp-premium' ),
'section' => 'secondary_navigation_color_section',
'settings' => 'generate_secondary_nav_settings[navigation_background_color]',
'palette' => $palettes,
)
)
);
// Text.
$wp_customize->add_setting(
'generate_secondary_nav_settings[navigation_text_color]',
array(
'default' => $defaults['navigation_text_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'secondary_navigation_text_color',
array(
'label' => __( 'Text', 'gp-premium' ),
'section' => 'secondary_navigation_color_section',
'settings' => 'generate_secondary_nav_settings[navigation_text_color]',
)
)
);
// Background hover.
$wp_customize->add_setting(
'generate_secondary_nav_settings[navigation_background_hover_color]',
array(
'default' => $defaults['navigation_background_hover_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_rgba',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new GeneratePress_Alpha_Color_Customize_Control(
$wp_customize,
'secondary_navigation_background_hover_color',
array(
'label' => __( 'Background Hover', 'gp-premium' ),
'section' => 'secondary_navigation_color_section',
'settings' => 'generate_secondary_nav_settings[navigation_background_hover_color]',
'palette' => $palettes,
)
)
);
// Text hover.
$wp_customize->add_setting(
'generate_secondary_nav_settings[navigation_text_hover_color]',
array(
'default' => $defaults['navigation_text_hover_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'secondary_navigation_text_hover_color',
array(
'label' => __( 'Text Hover', 'gp-premium' ),
'section' => 'secondary_navigation_color_section',
'settings' => 'generate_secondary_nav_settings[navigation_text_hover_color]',
)
)
);
// Background current.
$wp_customize->add_setting(
'generate_secondary_nav_settings[navigation_background_current_color]',
array(
'default' => $defaults['navigation_background_current_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_rgba',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new GeneratePress_Alpha_Color_Customize_Control(
$wp_customize,
'secondary_navigation_background_current_color',
array(
'label' => __( 'Background Current', 'gp-premium' ),
'section' => 'secondary_navigation_color_section',
'settings' => 'generate_secondary_nav_settings[navigation_background_current_color]',
'palette' => $palettes,
)
)
);
// Text current.
$wp_customize->add_setting(
'generate_secondary_nav_settings[navigation_text_current_color]',
array(
'default' => $defaults['navigation_text_current_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'secondary_navigation_text_current_color',
array(
'label' => __( 'Text Current', 'gp-premium' ),
'section' => 'secondary_navigation_color_section',
'settings' => 'generate_secondary_nav_settings[navigation_text_current_color]',
)
)
);
$wp_customize->add_control(
new GeneratePress_Title_Customize_Control(
$wp_customize,
'generate_secondary_navigation_sub_menu_items',
array(
'section' => 'secondary_navigation_color_section',
'type' => 'generatepress-customizer-title',
'title' => __( 'Sub-Menu Items', 'gp-premium' ),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
)
)
);
// Background.
$wp_customize->add_setting(
'generate_secondary_nav_settings[subnavigation_background_color]',
array(
'default' => $defaults['subnavigation_background_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_rgba',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new GeneratePress_Alpha_Color_Customize_Control(
$wp_customize,
'secondary_subnavigation_background_color',
array(
'label' => __( 'Background', 'gp-premium' ),
'section' => 'secondary_navigation_color_section',
'settings' => 'generate_secondary_nav_settings[subnavigation_background_color]',
'palette' => $palettes,
)
)
);
// Text.
$wp_customize->add_setting(
'generate_secondary_nav_settings[subnavigation_text_color]',
array(
'default' => $defaults['subnavigation_text_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'secondary_subnavigation_text_color',
array(
'label' => __( 'Text', 'gp-premium' ),
'section' => 'secondary_navigation_color_section',
'settings' => 'generate_secondary_nav_settings[subnavigation_text_color]',
)
)
);
// Background hover.
$wp_customize->add_setting(
'generate_secondary_nav_settings[subnavigation_background_hover_color]',
array(
'default' => $defaults['subnavigation_background_hover_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_rgba',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new GeneratePress_Alpha_Color_Customize_Control(
$wp_customize,
'secondary_subnavigation_background_hover_color',
array(
'label' => __( 'Background Hover', 'gp-premium' ),
'section' => 'secondary_navigation_color_section',
'settings' => 'generate_secondary_nav_settings[subnavigation_background_hover_color]',
'palette' => $palettes,
)
)
);
// Text hover.
$wp_customize->add_setting(
'generate_secondary_nav_settings[subnavigation_text_hover_color]',
array(
'default' => $defaults['subnavigation_text_hover_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'secondary_subnavigation_text_hover_color',
array(
'label' => __( 'Text Hover', 'gp-premium' ),
'section' => 'secondary_navigation_color_section',
'settings' => 'generate_secondary_nav_settings[subnavigation_text_hover_color]',
)
)
);
// Background current.
$wp_customize->add_setting(
'generate_secondary_nav_settings[subnavigation_background_current_color]',
array(
'default' => $defaults['subnavigation_background_current_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_rgba',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new GeneratePress_Alpha_Color_Customize_Control(
$wp_customize,
'secondary_subnavigation_background_current_color',
array(
'label' => __( 'Background Current', 'gp-premium' ),
'section' => 'secondary_navigation_color_section',
'settings' => 'generate_secondary_nav_settings[subnavigation_background_current_color]',
'palette' => $palettes,
)
)
);
// Text current.
$wp_customize->add_setting(
'generate_secondary_nav_settings[subnavigation_text_current_color]',
array(
'default' => $defaults['subnavigation_text_current_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'secondary_subnavigation_text_current_color',
array(
'label' => __( 'Text Current', 'gp-premium' ),
'section' => 'secondary_navigation_color_section',
'settings' => 'generate_secondary_nav_settings[subnavigation_text_current_color]',
)
)
);
}
}

View File

@ -0,0 +1,400 @@
<?php
/**
* This file handles the Customizer options for the Off-Canvas Panel.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
add_action( 'customize_preview_init', 'generate_menu_plus_live_preview_scripts', 20 );
/**
* Add live preview JS to the Customizer.
*/
function generate_menu_plus_live_preview_scripts() {
wp_enqueue_script( 'generate-menu-plus-colors-customizer' );
}
add_action( 'customize_register', 'generate_slideout_navigation_color_controls', 150 );
/**
* Adds our Slideout Nav color options
*
* @since 1.6
* @param object $wp_customize The Customizer object.
*/
function generate_slideout_navigation_color_controls( $wp_customize ) {
// Bail if Secondary Nav isn't activated.
if ( ! $wp_customize->get_section( 'menu_plus_slideout_menu' ) ) {
return;
}
// Bail if we don't have our color defaults.
if ( ! function_exists( 'generate_get_color_defaults' ) ) {
return;
}
// Add our controls.
require_once GP_LIBRARY_DIRECTORY . 'customizer-helpers.php';
// Get our defaults.
$defaults = generate_get_color_defaults();
// Add control types so controls can be built using JS.
if ( method_exists( $wp_customize, 'register_control_type' ) ) {
$wp_customize->register_control_type( 'GeneratePress_Alpha_Color_Customize_Control' );
$wp_customize->register_control_type( 'GeneratePress_Section_Shortcut_Control' );
}
// Get our palettes.
$palettes = generate_get_default_color_palettes();
// Add Secondary Navigation section.
$wp_customize->add_section(
'slideout_color_section',
array(
'title' => __( 'Off Canvas Panel', 'gp-premium' ),
'capability' => 'edit_theme_options',
'priority' => 73,
'panel' => 'generate_colors_panel',
)
);
$wp_customize->add_control(
new GeneratePress_Section_Shortcut_Control(
$wp_customize,
'generate_off_canvas_color_shortcuts',
array(
'section' => 'slideout_color_section',
'element' => __( 'Off Canvas Panel', 'gp-premium' ),
'shortcuts' => array(
'layout' => 'menu_plus_slideout_menu',
'typography' => 'generate_slideout_typography',
),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
'priority' => 1,
)
)
);
$wp_customize->add_control(
new GeneratePress_Title_Customize_Control(
$wp_customize,
'generate_slideout_navigation_items',
array(
'section' => 'slideout_color_section',
'type' => 'generatepress-customizer-title',
'title' => __( 'Parent Menu Items', 'gp-premium' ),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
)
)
);
// Background.
$wp_customize->add_setting(
'generate_settings[slideout_background_color]',
array(
'default' => $defaults['slideout_background_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_rgba',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new GeneratePress_Alpha_Color_Customize_Control(
$wp_customize,
'generate_settings[slideout_background_color]',
array(
'label' => __( 'Background', 'gp-premium' ),
'section' => 'slideout_color_section',
'settings' => 'generate_settings[slideout_background_color]',
'palette' => $palettes,
)
)
);
// Text.
$wp_customize->add_setting(
'generate_settings[slideout_text_color]',
array(
'default' => $defaults['slideout_text_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'generate_settings[slideout_text_color]',
array(
'label' => __( 'Text', 'gp-premium' ),
'section' => 'slideout_color_section',
'settings' => 'generate_settings[slideout_text_color]',
)
)
);
// Background hover.
$wp_customize->add_setting(
'generate_settings[slideout_background_hover_color]',
array(
'default' => $defaults['slideout_background_hover_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_rgba',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new GeneratePress_Alpha_Color_Customize_Control(
$wp_customize,
'generate_settings[slideout_background_hover_color]',
array(
'label' => __( 'Background Hover', 'gp-premium' ),
'section' => 'slideout_color_section',
'settings' => 'generate_settings[slideout_background_hover_color]',
'palette' => $palettes,
)
)
);
// Text hover.
$wp_customize->add_setting(
'generate_settings[slideout_text_hover_color]',
array(
'default' => $defaults['slideout_text_hover_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'generate_settings[slideout_text_hover_color]',
array(
'label' => __( 'Text Hover', 'gp-premium' ),
'section' => 'slideout_color_section',
'settings' => 'generate_settings[slideout_text_hover_color]',
)
)
);
// Background current.
$wp_customize->add_setting(
'generate_settings[slideout_background_current_color]',
array(
'default' => $defaults['slideout_background_current_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_rgba',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new GeneratePress_Alpha_Color_Customize_Control(
$wp_customize,
'generate_settings[slideout_background_current_color]',
array(
'label' => __( 'Background Current', 'gp-premium' ),
'section' => 'slideout_color_section',
'settings' => 'generate_settings[slideout_background_current_color]',
'palette' => $palettes,
)
)
);
// Text current.
$wp_customize->add_setting(
'generate_settings[slideout_text_current_color]',
array(
'default' => $defaults['slideout_text_current_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'generate_settings[slideout_text_current_color]',
array(
'label' => __( 'Text Current', 'gp-premium' ),
'section' => 'slideout_color_section',
'settings' => 'generate_settings[slideout_text_current_color]',
)
)
);
$wp_customize->add_control(
new GeneratePress_Title_Customize_Control(
$wp_customize,
'generate_slideout_navigation_sub_menu_items',
array(
'section' => 'slideout_color_section',
'type' => 'generatepress-customizer-title',
'title' => __( 'Sub-Menu Items', 'gp-premium' ),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
)
)
);
// Background.
$wp_customize->add_setting(
'generate_settings[slideout_submenu_background_color]',
array(
'default' => $defaults['slideout_submenu_background_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_rgba',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new GeneratePress_Alpha_Color_Customize_Control(
$wp_customize,
'generate_settings[slideout_submenu_background_color]',
array(
'label' => __( 'Background', 'gp-premium' ),
'section' => 'slideout_color_section',
'settings' => 'generate_settings[slideout_submenu_background_color]',
'palette' => $palettes,
)
)
);
// Text.
$wp_customize->add_setting(
'generate_settings[slideout_submenu_text_color]',
array(
'default' => $defaults['slideout_submenu_text_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'generate_settings[slideout_submenu_text_color]',
array(
'label' => __( 'Text', 'gp-premium' ),
'section' => 'slideout_color_section',
'settings' => 'generate_settings[slideout_submenu_text_color]',
)
)
);
// Background hover.
$wp_customize->add_setting(
'generate_settings[slideout_submenu_background_hover_color]',
array(
'default' => $defaults['slideout_submenu_background_hover_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_rgba',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new GeneratePress_Alpha_Color_Customize_Control(
$wp_customize,
'generate_settings[slideout_submenu_background_hover_color]',
array(
'label' => __( 'Background Hover', 'gp-premium' ),
'section' => 'slideout_color_section',
'settings' => 'generate_settings[slideout_submenu_background_hover_color]',
'palette' => $palettes,
)
)
);
// Text hover.
$wp_customize->add_setting(
'generate_settings[slideout_submenu_text_hover_color]',
array(
'default' => $defaults['slideout_submenu_text_hover_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'generate_settings[slideout_submenu_text_hover_color]',
array(
'label' => __( 'Text Hover', 'gp-premium' ),
'section' => 'slideout_color_section',
'settings' => 'generate_settings[slideout_submenu_text_hover_color]',
)
)
);
// Background current.
$wp_customize->add_setting(
'generate_settings[slideout_submenu_background_current_color]',
array(
'default' => $defaults['slideout_submenu_background_current_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_rgba',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new GeneratePress_Alpha_Color_Customize_Control(
$wp_customize,
'generate_settings[slideout_submenu_background_current_color]',
array(
'label' => __( 'Background Current', 'gp-premium' ),
'section' => 'slideout_color_section',
'settings' => 'generate_settings[slideout_submenu_background_current_color]',
'palette' => $palettes,
)
)
);
// Text current.
$wp_customize->add_setting(
'generate_settings[slideout_submenu_text_current_color]',
array(
'default' => $defaults['slideout_submenu_text_current_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'generate_settings[slideout_submenu_text_current_color]',
array(
'label' => __( 'Text Current', 'gp-premium' ),
'section' => 'slideout_color_section',
'settings' => 'generate_settings[slideout_submenu_text_current_color]',
)
)
);
}

View File

@ -0,0 +1,911 @@
<?php
/**
* This file handles the Customizer options for the WooCommerce module.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
if ( ! function_exists( 'generate_colors_wc_customizer' ) ) {
add_action( 'customize_register', 'generate_colors_wc_customizer', 100 );
/**
* Adds our WooCommerce color options
*
* @param object $wp_customize The Customizer object.
*/
function generate_colors_wc_customizer( $wp_customize ) {
// Bail if WooCommerce isn't activated.
if ( ! $wp_customize->get_section( 'generate_woocommerce_colors' ) ) {
return;
}
if ( ! function_exists( 'generate_get_color_defaults' ) ) {
return;
}
// Add our controls.
require_once GP_LIBRARY_DIRECTORY . 'customizer-helpers.php';
// Get our defaults.
$defaults = generate_get_color_defaults();
// Add control types so controls can be built using JS.
if ( method_exists( $wp_customize, 'register_control_type' ) ) {
$wp_customize->register_control_type( 'GeneratePress_Alpha_Color_Customize_Control' );
$wp_customize->register_control_type( 'GeneratePress_Title_Customize_Control' );
$wp_customize->register_control_type( 'GeneratePress_Information_Customize_Control' );
$wp_customize->register_control_type( 'GeneratePress_Section_Shortcut_Control' );
}
// Get our palettes.
$palettes = generate_get_default_color_palettes();
$wp_customize->add_control(
new GeneratePress_Section_Shortcut_Control(
$wp_customize,
'generate_woocommerce_color_shortcuts',
array(
'section' => 'generate_woocommerce_colors',
'element' => __( 'WooCommerce', 'gp-premium' ),
'shortcuts' => array(
'layout' => 'generate_woocommerce_layout',
'typography' => 'generate_woocommerce_typography',
),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
'priority' => 0,
)
)
);
$wp_customize->add_control(
new GeneratePress_Title_Customize_Control(
$wp_customize,
'generate_woocommerce_button_title',
array(
'section' => 'generate_woocommerce_colors',
'type' => 'generatepress-customizer-title',
'title' => __( 'Buttons', 'gp-premium' ),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
)
)
);
$wp_customize->add_control(
new GeneratePress_Information_Customize_Control(
$wp_customize,
'generate_woocommerce_primary_button_message',
array(
'section' => 'generate_woocommerce_colors',
'label' => __( 'Primary Button Colors', 'gp-premium' ),
'description' => __( 'Primary button colors can be set <a href="#">here</a>.', 'gp-premium' ),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
)
)
);
$wp_customize->add_setting(
'generate_settings[wc_alt_button_background]',
array(
'default' => $defaults['wc_alt_button_background'],
'type' => 'option',
'capability' => 'edit_theme_options',
'transport' => 'postMessage',
'sanitize_callback' => 'generate_premium_sanitize_rgba',
)
);
$wp_customize->add_control(
new GeneratePress_Alpha_Color_Customize_Control(
$wp_customize,
'generate_settings[wc_alt_button_background]',
array(
'label' => __( 'Alt Button Background', 'gp-premium' ),
'section' => 'generate_woocommerce_colors',
'settings' => 'generate_settings[wc_alt_button_background]',
'palette' => $palettes,
)
)
);
$wp_customize->add_setting(
'generate_settings[wc_alt_button_background_hover]',
array(
'default' => $defaults['wc_alt_button_background_hover'],
'type' => 'option',
'capability' => 'edit_theme_options',
'transport' => 'postMessage',
'sanitize_callback' => 'generate_premium_sanitize_rgba',
)
);
$wp_customize->add_control(
new GeneratePress_Alpha_Color_Customize_Control(
$wp_customize,
'generate_settings[wc_alt_button_background_hover]',
array(
'label' => __( 'Alt Button Background Hover', 'gp-premium' ),
'section' => 'generate_woocommerce_colors',
'settings' => 'generate_settings[wc_alt_button_background_hover]',
'palette' => $palettes,
)
)
);
$wp_customize->add_setting(
'generate_settings[wc_alt_button_text]',
array(
'default' => $defaults['wc_alt_button_text'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'generate_settings[wc_alt_button_text]',
array(
'label' => __( 'Alt Button Text', 'gp-premium' ),
'section' => 'generate_woocommerce_colors',
'settings' => 'generate_settings[wc_alt_button_text]',
)
)
);
$wp_customize->add_setting(
'generate_settings[wc_alt_button_text_hover]',
array(
'default' => $defaults['wc_alt_button_text_hover'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'generate_settings[wc_alt_button_text_hover]',
array(
'label' => __( 'Alt Button Text Hover', 'gp-premium' ),
'section' => 'generate_woocommerce_colors',
'settings' => 'generate_settings[wc_alt_button_text_hover]',
)
)
);
$wp_customize->add_control(
new GeneratePress_Title_Customize_Control(
$wp_customize,
'generate_woocommerce_product_title',
array(
'section' => 'generate_woocommerce_colors',
'type' => 'generatepress-customizer-title',
'title' => __( 'Products', 'gp-premium' ),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
)
)
);
$wp_customize->add_setting(
'generate_settings[wc_product_title_color]',
array(
'default' => $defaults['wc_product_title_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'generate_settings[wc_product_title_color]',
array(
'label' => __( 'Product Title', 'gp-premium' ),
'section' => 'generate_woocommerce_colors',
'settings' => 'generate_settings[wc_product_title_color]',
)
)
);
$wp_customize->add_setting(
'generate_settings[wc_product_title_color_hover]',
array(
'default' => $defaults['wc_product_title_color_hover'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'generate_settings[wc_product_title_color_hover]',
array(
'label' => __( 'Product Title Hover', 'gp-premium' ),
'section' => 'generate_woocommerce_colors',
'settings' => 'generate_settings[wc_product_title_color_hover]',
)
)
);
$wp_customize->add_setting(
'generate_settings[wc_rating_stars]',
array(
'default' => $defaults['wc_rating_stars'],
'type' => 'option',
'capability' => 'edit_theme_options',
'transport' => '',
'sanitize_callback' => 'generate_premium_sanitize_rgba',
)
);
$wp_customize->add_control(
new GeneratePress_Alpha_Color_Customize_Control(
$wp_customize,
'generate_settings[wc_rating_stars]',
array(
'label' => __( 'Star Ratings', 'gp-premium' ),
'section' => 'generate_woocommerce_colors',
'settings' => 'generate_settings[wc_rating_stars]',
'palette' => $palettes,
)
)
);
$wp_customize->add_setting(
'generate_settings[wc_sale_sticker_background]',
array(
'default' => $defaults['wc_sale_sticker_background'],
'type' => 'option',
'capability' => 'edit_theme_options',
'transport' => 'postMessage',
'sanitize_callback' => 'generate_premium_sanitize_rgba',
)
);
$wp_customize->add_control(
new GeneratePress_Alpha_Color_Customize_Control(
$wp_customize,
'generate_settings[wc_sale_sticker_background]',
array(
'label' => __( 'Sale Sticker Background', 'gp-premium' ),
'section' => 'generate_woocommerce_colors',
'settings' => 'generate_settings[wc_sale_sticker_background]',
'palette' => $palettes,
)
)
);
$wp_customize->add_setting(
'generate_settings[wc_sale_sticker_text]',
array(
'default' => $defaults['wc_sale_sticker_text'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'generate_settings[wc_sale_sticker_text]',
array(
'label' => __( 'Sale Sticker Text', 'gp-premium' ),
'section' => 'generate_woocommerce_colors',
'settings' => 'generate_settings[wc_sale_sticker_text]',
)
)
);
$wp_customize->add_setting(
'generate_settings[wc_price_color]',
array(
'default' => $defaults['wc_price_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'generate_settings[wc_price_color]',
array(
'label' => __( 'Price', 'gp-premium' ),
'section' => 'generate_woocommerce_colors',
'settings' => 'generate_settings[wc_price_color]',
)
)
);
$wp_customize->add_control(
new GeneratePress_Title_Customize_Control(
$wp_customize,
'generate_woocommerce_panel_cart_title',
array(
'section' => 'generate_woocommerce_colors',
'type' => 'generatepress-customizer-title',
'title' => __( 'Sticky Panel Cart', 'gp-premium' ),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
)
)
);
$wp_customize->add_setting(
'generate_settings[wc_panel_cart_background_color]',
array(
'default' => $defaults['wc_panel_cart_background_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
'transport' => 'postMessage',
'sanitize_callback' => 'generate_premium_sanitize_rgba',
)
);
$wp_customize->add_control(
new GeneratePress_Alpha_Color_Customize_Control(
$wp_customize,
'generate_settings[wc_panel_cart_background_color]',
array(
'label' => __( 'Background Color', 'gp-premium' ),
'section' => 'generate_woocommerce_colors',
'settings' => 'generate_settings[wc_panel_cart_background_color]',
'palette' => $palettes,
)
)
);
$wp_customize->add_setting(
'generate_settings[wc_panel_cart_text_color]',
array(
'default' => $defaults['wc_panel_cart_text_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'generate_settings[wc_panel_cart_text_color]',
array(
'label' => __( 'Text Color', 'gp-premium' ),
'section' => 'generate_woocommerce_colors',
'settings' => 'generate_settings[wc_panel_cart_text_color]',
)
)
);
$wp_customize->add_setting(
'generate_settings[wc_panel_cart_button_background]',
array(
'default' => $defaults['wc_panel_cart_button_background'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'generate_settings[wc_panel_cart_button_background]',
array(
'label' => __( 'Button Background', 'gp-premium' ),
'section' => 'generate_woocommerce_colors',
'settings' => 'generate_settings[wc_panel_cart_button_background]',
)
)
);
$wp_customize->add_setting(
'generate_settings[wc_panel_cart_button_background_hover]',
array(
'default' => $defaults['wc_panel_cart_button_background_hover'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'generate_settings[wc_panel_cart_button_background_hover]',
array(
'label' => __( 'Button Background Hover', 'gp-premium' ),
'section' => 'generate_woocommerce_colors',
'settings' => 'generate_settings[wc_panel_cart_button_background_hover]',
)
)
);
$wp_customize->add_setting(
'generate_settings[wc_panel_cart_button_text]',
array(
'default' => $defaults['wc_panel_cart_button_text'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'generate_settings[wc_panel_cart_button_text]',
array(
'label' => __( 'Button Text', 'gp-premium' ),
'section' => 'generate_woocommerce_colors',
'settings' => 'generate_settings[wc_panel_cart_button_text]',
)
)
);
$wp_customize->add_setting(
'generate_settings[wc_panel_cart_button_text_hover]',
array(
'default' => $defaults['wc_panel_cart_button_text_hover'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'generate_settings[wc_panel_cart_button_text_hover]',
array(
'label' => __( 'Button Text Hover', 'gp-premium' ),
'section' => 'generate_woocommerce_colors',
'settings' => 'generate_settings[wc_panel_cart_button_text_hover]',
)
)
);
$wp_customize->add_control(
new GeneratePress_Title_Customize_Control(
$wp_customize,
'generate_woocommerce_mini_cart_title',
array(
'section' => 'generate_woocommerce_colors',
'type' => 'generatepress-customizer-title',
'title' => __( 'Menu Mini Cart', 'gp-premium' ),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
)
)
);
$wp_customize->add_setting(
'generate_settings[wc_mini_cart_background_color]',
array(
'default' => $defaults['wc_mini_cart_background_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
'transport' => 'postMessage',
'sanitize_callback' => 'generate_premium_sanitize_rgba',
)
);
$wp_customize->add_control(
new GeneratePress_Alpha_Color_Customize_Control(
$wp_customize,
'generate_settings[wc_mini_cart_background_color]',
array(
'label' => __( 'Cart Background Color', 'gp-premium' ),
'section' => 'generate_woocommerce_colors',
'settings' => 'generate_settings[wc_mini_cart_background_color]',
'palette' => $palettes,
)
)
);
$wp_customize->add_setting(
'generate_settings[wc_mini_cart_text_color]',
array(
'default' => $defaults['wc_mini_cart_text_color'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'generate_settings[wc_mini_cart_text_color]',
array(
'label' => __( 'Cart Text Color', 'gp-premium' ),
'section' => 'generate_woocommerce_colors',
'settings' => 'generate_settings[wc_mini_cart_text_color]',
)
)
);
$wp_customize->add_setting(
'generate_settings[wc_mini_cart_button_background]',
array(
'default' => $defaults['wc_mini_cart_button_background'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'generate_settings[wc_mini_cart_button_background]',
array(
'label' => __( 'Button Background', 'gp-premium' ),
'section' => 'generate_woocommerce_colors',
'settings' => 'generate_settings[wc_mini_cart_button_background]',
)
)
);
$wp_customize->add_setting(
'generate_settings[wc_mini_cart_button_background_hover]',
array(
'default' => $defaults['wc_mini_cart_button_background_hover'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'generate_settings[wc_mini_cart_button_background_hover]',
array(
'label' => __( 'Button Background Hover', 'gp-premium' ),
'section' => 'generate_woocommerce_colors',
'settings' => 'generate_settings[wc_mini_cart_button_background_hover]',
)
)
);
$wp_customize->add_setting(
'generate_settings[wc_mini_cart_button_text]',
array(
'default' => $defaults['wc_mini_cart_button_text'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'generate_settings[wc_mini_cart_button_text]',
array(
'label' => __( 'Button Text', 'gp-premium' ),
'section' => 'generate_woocommerce_colors',
'settings' => 'generate_settings[wc_mini_cart_button_text]',
)
)
);
$wp_customize->add_setting(
'generate_settings[wc_mini_cart_button_text_hover]',
array(
'default' => $defaults['wc_mini_cart_button_text_hover'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'generate_settings[wc_mini_cart_button_text_hover]',
array(
'label' => __( 'Button Text Hover', 'gp-premium' ),
'section' => 'generate_woocommerce_colors',
'settings' => 'generate_settings[wc_mini_cart_button_text_hover]',
)
)
);
$wp_customize->add_control(
new GeneratePress_Title_Customize_Control(
$wp_customize,
'generate_woocommerce_price_slider_title',
array(
'section' => 'generate_woocommerce_colors',
'type' => 'generatepress-customizer-title',
'title' => __( 'Price Slider Widget', 'gp-premium' ),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
)
)
);
$wp_customize->add_setting(
'generate_settings[wc_price_slider_background_color]',
array(
'default' => $defaults['wc_price_slider_background_color'],
'type' => 'option',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'generate_settings[wc_price_slider_background_color]',
array(
'label' => __( 'Slider Background Color', 'gp-premium' ),
'section' => 'generate_woocommerce_colors',
'settings' => 'generate_settings[wc_price_slider_background_color]',
)
)
);
$wp_customize->add_setting(
'generate_settings[wc_price_slider_bar_color]',
array(
'default' => $defaults['wc_price_slider_bar_color'],
'type' => 'option',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'generate_settings[wc_price_slider_bar_color]',
array(
'label' => __( 'Slider Bar Color', 'gp-premium' ),
'section' => 'generate_woocommerce_colors',
'settings' => 'generate_settings[wc_price_slider_bar_color]',
)
)
);
$wp_customize->add_control(
new GeneratePress_Title_Customize_Control(
$wp_customize,
'generate_woocommerce_product_tabs_title',
array(
'section' => 'generate_woocommerce_colors',
'type' => 'generatepress-customizer-title',
'title' => __( 'Product Tabs', 'gp-premium' ),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
)
)
);
$wp_customize->add_setting(
'generate_settings[wc_product_tab]',
array(
'default' => $defaults['wc_product_tab'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'generate_settings[wc_product_tab]',
array(
'label' => __( 'Product Tab Text', 'gp-premium' ),
'section' => 'generate_woocommerce_colors',
'settings' => 'generate_settings[wc_product_tab]',
)
)
);
$wp_customize->add_setting(
'generate_settings[wc_product_tab_highlight]',
array(
'default' => $defaults['wc_product_tab_highlight'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'generate_settings[wc_product_tab_highlight]',
array(
'label' => __( 'Product Tab Active', 'gp-premium' ),
'section' => 'generate_woocommerce_colors',
'settings' => 'generate_settings[wc_product_tab_highlight]',
)
)
);
$wp_customize->add_control(
new GeneratePress_Title_Customize_Control(
$wp_customize,
'generate_woocommerce_messages_title',
array(
'section' => 'generate_woocommerce_colors',
'type' => 'generatepress-customizer-title',
'title' => __( 'Messages', 'gp-premium' ),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
)
)
);
$wp_customize->add_setting(
'generate_settings[wc_success_message_background]',
array(
'default' => $defaults['wc_success_message_background'],
'type' => 'option',
'capability' => 'edit_theme_options',
'transport' => 'postMessage',
'sanitize_callback' => 'generate_premium_sanitize_rgba',
)
);
$wp_customize->add_control(
new GeneratePress_Alpha_Color_Customize_Control(
$wp_customize,
'generate_settings[wc_success_message_background]',
array(
'label' => __( 'Success Message Background', 'gp-premium' ),
'section' => 'generate_woocommerce_colors',
'settings' => 'generate_settings[wc_success_message_background]',
'palette' => $palettes,
)
)
);
$wp_customize->add_setting(
'generate_settings[wc_success_message_text]',
array(
'default' => $defaults['wc_success_message_text'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'generate_settings[wc_success_message_text]',
array(
'label' => __( 'Success Message Text', 'gp-premium' ),
'section' => 'generate_woocommerce_colors',
'settings' => 'generate_settings[wc_success_message_text]',
)
)
);
$wp_customize->add_setting(
'generate_settings[wc_info_message_background]',
array(
'default' => $defaults['wc_info_message_background'],
'type' => 'option',
'capability' => 'edit_theme_options',
'transport' => 'postMessage',
'sanitize_callback' => 'generate_premium_sanitize_rgba',
)
);
$wp_customize->add_control(
new GeneratePress_Alpha_Color_Customize_Control(
$wp_customize,
'generate_settings[wc_info_message_background]',
array(
'label' => __( 'Info Message Background', 'gp-premium' ),
'section' => 'generate_woocommerce_colors',
'settings' => 'generate_settings[wc_info_message_background]',
'palette' => $palettes,
)
)
);
$wp_customize->add_setting(
'generate_settings[wc_info_message_text]',
array(
'default' => $defaults['wc_info_message_text'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'generate_settings[wc_info_message_text]',
array(
'label' => __( 'Info Message Text', 'gp-premium' ),
'section' => 'generate_woocommerce_colors',
'settings' => 'generate_settings[wc_info_message_text]',
)
)
);
$wp_customize->add_setting(
'generate_settings[wc_error_message_background]',
array(
'default' => $defaults['wc_error_message_background'],
'type' => 'option',
'capability' => 'edit_theme_options',
'transport' => 'postMessage',
'sanitize_callback' => 'generate_premium_sanitize_rgba',
)
);
$wp_customize->add_control(
new GeneratePress_Alpha_Color_Customize_Control(
$wp_customize,
'generate_settings[wc_error_message_background]',
array(
'label' => __( 'Error Message Background', 'gp-premium' ),
'section' => 'generate_woocommerce_colors',
'settings' => 'generate_settings[wc_error_message_background]',
'palette' => $palettes,
)
)
);
$wp_customize->add_setting(
'generate_settings[wc_error_message_text]',
array(
'default' => $defaults['wc_error_message_text'],
'type' => 'option',
'capability' => 'edit_theme_options',
'sanitize_callback' => 'generate_premium_sanitize_hex_color',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new WP_Customize_Color_Control(
$wp_customize,
'generate_settings[wc_error_message_text]',
array(
'label' => __( 'Error Message Text', 'gp-premium' ),
'section' => 'generate_woocommerce_colors',
'settings' => 'generate_settings[wc_error_message_text]',
)
)
);
}
}

View File

@ -0,0 +1,20 @@
<?php
/**
* The Colors module.
*
* @since 1.1.0
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
// Define the version. This used to be a standalone plugin, so we need to keep this constant.
if ( ! defined( 'GENERATE_COLORS_VERSION' ) ) {
define( 'GENERATE_COLORS_VERSION', GP_PREMIUM_VERSION );
}
// Include functions identical between standalone addon and GP Premium.
require plugin_dir_path( __FILE__ ) . 'functions/functions.php';

View File

@ -0,0 +1,223 @@
<?php
/**
* This file handles the Copyright functionality.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
if ( ! function_exists( 'generate_copyright_customize_register' ) ) {
add_action( 'customize_register', 'generate_copyright_customize_register' );
/**
* Add our copyright options to the Customizer.
*
* @param object $wp_customize The Customizer object.
*/
function generate_copyright_customize_register( $wp_customize ) {
// Get our custom control.
require_once GP_LIBRARY_DIRECTORY . 'customizer-helpers.php';
// Register our custom control.
if ( method_exists( $wp_customize, 'register_control_type' ) ) {
$wp_customize->register_control_type( 'GeneratePress_Copyright_Customize_Control' );
}
$wp_customize->add_setting(
'generate_copyright',
array(
'default' => '',
'type' => 'theme_mod',
'sanitize_callback' => 'wp_kses_post',
'transport' => 'postMessage',
)
);
$wp_customize->add_control(
new GeneratePress_Copyright_Customize_Control(
$wp_customize,
'generate_copyright',
array(
'label' => __( 'Copyright', 'gp-premium' ),
'section' => 'generate_layout_footer',
'settings' => 'generate_copyright',
'priority' => 500,
)
)
);
// Initiate selective refresh.
if ( isset( $wp_customize->selective_refresh ) ) {
$wp_customize->selective_refresh->add_partial(
'generate_copyright',
array(
'selector' => '.copyright-bar',
'settings' => array( 'generate_copyright' ),
'render_callback' => 'generate_copyright_selective_refresh',
)
);
}
}
}
if ( ! function_exists( 'generate_copyright_selective_refresh' ) ) {
/**
* Return our copyright on selective refresh
*/
function generate_copyright_selective_refresh() {
$options = array(
'%current_year%',
'%copy%',
);
$replace = array(
date( 'Y' ), // phpcs:ignore -- prefer date().
'&copy;',
);
$new_copyright = get_theme_mod( 'generate_copyright' );
$new_copyright = str_replace( $options, $replace, get_theme_mod( 'generate_copyright' ) );
return do_shortcode( $new_copyright );
}
}
if ( ! function_exists( 'generate_copyright_remove_default' ) ) {
add_action( 'wp', 'generate_copyright_remove_default' );
/**
* Remove the default copyright.
*
* @since 0.1
* @deprecated GP 1.3.42
*/
function generate_copyright_remove_default() {
// As of 1.3.42, we no longer need to do this.
// We use a nice little filter instead.
if ( ! function_exists( 'generate_add_login_attribution' ) ) {
return;
}
if ( get_theme_mod( 'generate_copyright' ) && '' !== get_theme_mod( 'generate_copyright' ) ) {
remove_action( 'generate_credits', 'generate_add_footer_info' );
remove_action( 'generate_copyright_line', 'generate_add_login_attribution' );
}
}
}
if ( ! function_exists( 'generate_copyright_add_custom' ) ) {
add_action( 'generate_credits', 'generate_copyright_add_custom' );
/**
* Add the custom copyright.
*
* @since 0.1
* @deprecated GP 1.3.42
*/
function generate_copyright_add_custom() {
// As of 1.3.42, we no longer need to do this.
// We use a nice little filter instead.
if ( ! function_exists( 'generate_add_login_attribution' ) ) {
return;
}
$options = array(
'%current_year%',
'%copy%',
);
$replace = array(
date( 'Y' ), // phpcs:ignore -- prefer date().
'&copy;',
);
$new_copyright = get_theme_mod( 'generate_copyright' );
$new_copyright = str_replace( $options, $replace, get_theme_mod( 'generate_copyright' ) );
if ( get_theme_mod( 'generate_copyright' ) && '' !== get_theme_mod( 'generate_copyright' ) ) {
echo do_shortcode( $new_copyright );
}
}
}
if ( ! function_exists( 'generate_apply_custom_copyright' ) ) {
add_filter( 'generate_copyright', 'generate_apply_custom_copyright' );
/**
* Add the custom copyright
*
* @since 1.2.92
* @param string $copyright The copyright value.
*/
function generate_apply_custom_copyright( $copyright ) {
// This will only work if GP >= 1.3.42 and the below function doesn't exist.
if ( function_exists( 'generate_add_login_attribution' ) ) {
return;
}
$options = array(
'%current_year%',
'%copy%',
);
$replace = array(
date( 'Y' ), // phpcs:ignore -- prefer date().
'&copy;',
);
$new_copyright = get_theme_mod( 'generate_copyright' );
$new_copyright = str_replace( $options, $replace, get_theme_mod( 'generate_copyright' ) );
if ( get_theme_mod( 'generate_copyright' ) && '' !== get_theme_mod( 'generate_copyright' ) ) {
return do_shortcode( $new_copyright );
}
return $copyright;
}
}
if ( ! function_exists( 'generate_copyright_customizer_live_preview' ) ) {
add_action( 'customize_preview_init', 'generate_copyright_customizer_live_preview' );
/**
* Add our live preview
*/
function generate_copyright_customizer_live_preview() {
wp_enqueue_script(
'generate-copyright-customizer',
plugin_dir_url( __FILE__ ) . 'js/customizer.js',
array( 'jquery', 'customize-preview' ),
GENERATE_COPYRIGHT_VERSION,
true
);
}
}
if ( ! function_exists( 'generate_update_copyright' ) ) {
add_action( 'admin_init', 'generate_update_copyright' );
/**
* Our copyright use to have it's own setting
* If we have the old setting, move it into our theme_mod
*/
function generate_update_copyright() {
// If we already have a custom logo, bail.
if ( get_theme_mod( 'generate_copyright' ) ) {
return;
}
// Get the old logo value.
$old_value = get_option( 'gen_custom_copyright' );
// If there's no old value, bail.
if ( empty( $old_value ) ) {
return;
}
// Now let's update the new logo setting with our ID.
set_theme_mod( 'generate_copyright', $old_value );
// Got our custom logo? Time to delete the old value.
if ( get_theme_mod( 'generate_copyright' ) ) {
delete_option( 'gen_custom_copyright' );
}
}
}

View File

@ -0,0 +1,18 @@
/**
* Theme Customizer enhancements for a better user experience.
*
* Contains handlers to make Theme Customizer preview reload changes asynchronously.
*/
( function( $ ) {
// Update the site title in real time...
wp.customize( 'generate_copyright', function( value ) {
value.bind( function( newval ) {
if ( $( '.copyright-bar' ).length ) {
$( '.copyright-bar' ).html( newval );
} else {
$( '.inside-site-info' ).html( newval );
}
} );
} );
}( jQuery ) );

View File

@ -0,0 +1,20 @@
<?php
/**
* The Copyright module.
*
* @since 1.0.0
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
// Define the version.
if ( ! defined( 'GENERATE_COPYRIGHT_VERSION' ) ) {
define( 'GENERATE_COPYRIGHT_VERSION', GP_PREMIUM_VERSION );
}
// Include functions identical between standalone addon and GP Premium.
require plugin_dir_path( __FILE__ ) . 'functions/functions.php';

View File

@ -0,0 +1,426 @@
<?php
/**
* This file handles the Disable Elements functionality.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
define( 'GENERATE_DE_LAYOUT_META_BOX', true );
if ( ! function_exists( 'generate_disable_elements' ) ) {
/**
* Remove the default disable_elements.
*
* @since 0.1
*/
function generate_disable_elements() {
// Don't run the function unless we're on a page it applies to.
if ( ! is_singular() ) {
return '';
}
global $post;
// Prevent PHP notices.
if ( isset( $post ) ) {
$disable_header = get_post_meta( $post->ID, '_generate-disable-header', true );
$disable_nav = get_post_meta( $post->ID, '_generate-disable-nav', true );
$disable_secondary_nav = get_post_meta( $post->ID, '_generate-disable-secondary-nav', true );
$disable_post_image = get_post_meta( $post->ID, '_generate-disable-post-image', true );
$disable_headline = get_post_meta( $post->ID, '_generate-disable-headline', true );
$disable_footer = get_post_meta( $post->ID, '_generate-disable-footer', true );
}
$return = '';
if ( ! empty( $disable_header ) && false !== $disable_header ) {
$return = '.site-header {display:none}';
}
if ( ! empty( $disable_nav ) && false !== $disable_nav ) {
$return .= '#site-navigation,.navigation-clone, #mobile-header {display:none !important}';
}
if ( ! empty( $disable_secondary_nav ) && false !== $disable_secondary_nav ) {
$return .= '#secondary-navigation {display:none}';
}
if ( ! empty( $disable_post_image ) && false !== $disable_post_image ) {
$return .= '.generate-page-header, .page-header-image, .page-header-image-single {display:none}';
}
$need_css_removal = true;
if ( defined( 'GENERATE_VERSION' ) && version_compare( GENERATE_VERSION, '3.0.0-alpha.1', '>=' ) ) {
$need_css_removal = false;
}
if ( $need_css_removal && ! empty( $disable_headline ) && false !== $disable_headline && ! is_single() ) {
$return .= '.entry-header {display:none} .page-content, .entry-content, .entry-summary {margin-top:0}';
}
if ( ! empty( $disable_footer ) && false !== $disable_footer ) {
$return .= '.site-footer {display:none}';
}
return $return;
}
}
if ( ! function_exists( 'generate_de_scripts' ) ) {
add_action( 'wp_enqueue_scripts', 'generate_de_scripts', 50 );
/**
* Enqueue scripts and styles
*/
function generate_de_scripts() {
wp_add_inline_style( 'generate-style', generate_disable_elements() );
}
}
if ( ! function_exists( 'generate_add_de_meta_box' ) ) {
add_action( 'add_meta_boxes', 'generate_add_de_meta_box', 50 );
/**
* Generate the layout metabox.
*
* @since 0.1
*/
function generate_add_de_meta_box() {
// Set user role - make filterable.
$allowed = apply_filters( 'generate_metabox_capability', 'edit_theme_options' );
// If not an administrator, don't show the metabox.
if ( ! current_user_can( $allowed ) ) {
return;
}
if ( defined( 'GENERATE_LAYOUT_META_BOX' ) ) {
return;
}
$args = array( 'public' => true );
$post_types = get_post_types( $args );
foreach ( $post_types as $type ) {
if ( 'attachment' !== $type ) {
add_meta_box(
'generate_de_meta_box',
__( 'Disable Elements', 'gp-premium' ),
'generate_show_de_meta_box',
$type,
'side',
'default'
);
}
}
}
}
if ( ! function_exists( 'generate_show_de_meta_box' ) ) {
/**
* Outputs the content of the metabox.
*
* @param object $post The post object.
*/
function generate_show_de_meta_box( $post ) {
wp_nonce_field( basename( __FILE__ ), 'generate_de_nonce' );
$stored_meta = get_post_meta( $post->ID );
$stored_meta['_generate-disable-header'][0] = ( isset( $stored_meta['_generate-disable-header'][0] ) ) ? $stored_meta['_generate-disable-header'][0] : '';
$stored_meta['_generate-disable-nav'][0] = ( isset( $stored_meta['_generate-disable-nav'][0] ) ) ? $stored_meta['_generate-disable-nav'][0] : '';
$stored_meta['_generate-disable-secondary-nav'][0] = ( isset( $stored_meta['_generate-disable-secondary-nav'][0] ) ) ? $stored_meta['_generate-disable-secondary-nav'][0] : '';
$stored_meta['_generate-disable-post-image'][0] = ( isset( $stored_meta['_generate-disable-post-image'][0] ) ) ? $stored_meta['_generate-disable-post-image'][0] : '';
$stored_meta['_generate-disable-headline'][0] = ( isset( $stored_meta['_generate-disable-headline'][0] ) ) ? $stored_meta['_generate-disable-headline'][0] : '';
$stored_meta['_generate-disable-footer'][0] = ( isset( $stored_meta['_generate-disable-footer'][0] ) ) ? $stored_meta['_generate-disable-footer'][0] : '';
$stored_meta['_generate-disable-top-bar'][0] = ( isset( $stored_meta['_generate-disable-top-bar'][0] ) ) ? $stored_meta['_generate-disable-top-bar'][0] : '';
?>
<p>
<div class="generate_disable_elements">
<?php if ( function_exists( 'generate_top_bar' ) ) : ?>
<label for="meta-generate-disable-top-bar" style="display:block;margin-bottom:3px;" title="<?php _e( 'Top Bar', 'gp-premium' ); ?>">
<input type="checkbox" name="_generate-disable-top-bar" id="meta-generate-disable-top-bar" value="true" <?php checked( $stored_meta['_generate-disable-top-bar'][0], 'true' ); ?>>
<?php _e( 'Top Bar', 'gp-premium' ); ?>
</label>
<?php endif; ?>
<label for="meta-generate-disable-header" style="display:block;margin-bottom:3px;" title="<?php _e( 'Header', 'gp-premium' ); ?>">
<input type="checkbox" name="_generate-disable-header" id="meta-generate-disable-header" value="true" <?php checked( $stored_meta['_generate-disable-header'][0], 'true' ); ?>>
<?php _e( 'Header', 'gp-premium' ); ?>
</label>
<label for="meta-generate-disable-nav" style="display:block;margin-bottom:3px;" title="<?php _e( 'Primary Navigation', 'gp-premium' ); ?>">
<input type="checkbox" name="_generate-disable-nav" id="meta-generate-disable-nav" value="true" <?php checked( $stored_meta['_generate-disable-nav'][0], 'true' ); ?>>
<?php _e( 'Primary Navigation', 'gp-premium' ); ?>
</label>
<?php if ( function_exists( 'generate_secondary_nav_setup' ) ) : ?>
<label for="meta-generate-disable-secondary-nav" style="display:block;margin-bottom:3px;" title="<?php _e( 'Secondary Navigation', 'gp-premium' ); ?>">
<input type="checkbox" name="_generate-disable-secondary-nav" id="meta-generate-disable-secondary-nav" value="true" <?php checked( $stored_meta['_generate-disable-secondary-nav'][0], 'true' ); ?>>
<?php _e( 'Secondary Navigation', 'gp-premium' ); ?>
</label>
<?php endif; ?>
<label for="meta-generate-disable-post-image" style="display:block;margin-bottom:3px;" title="<?php _e( 'Featured Image', 'gp-premium' ); ?>">
<input type="checkbox" name="_generate-disable-post-image" id="meta-generate-disable-post-image" value="true" <?php checked( $stored_meta['_generate-disable-post-image'][0], 'true' ); ?>>
<?php _e( 'Featured Image', 'gp-premium' ); ?>
</label>
<label for="meta-generate-disable-headline" style="display:block;margin-bottom:3px;" title="<?php _e( 'Content Title', 'gp-premium' ); ?>">
<input type="checkbox" name="_generate-disable-headline" id="meta-generate-disable-headline" value="true" <?php checked( $stored_meta['_generate-disable-headline'][0], 'true' ); ?>>
<?php _e( 'Content Title', 'gp-premium' ); ?>
</label>
<label for="meta-generate-disable-footer" style="display:block;margin-bottom:3px;" title="<?php _e( 'Footer', 'gp-premium' ); ?>">
<input type="checkbox" name="_generate-disable-footer" id="meta-generate-disable-footer" value="true" <?php checked( $stored_meta['_generate-disable-footer'][0], 'true' ); ?>>
<?php _e( 'Footer', 'gp-premium' ); ?>
</label>
</div>
</p>
<?php
}
}
if ( ! function_exists( 'generate_save_de_meta' ) ) {
add_action( 'save_post', 'generate_save_de_meta' );
/**
* Save our options.
*
* @param int $post_id The post ID.
*/
function generate_save_de_meta( $post_id ) {
if ( defined( 'GENERATE_LAYOUT_META_BOX' ) ) {
return;
}
// Checks save status.
$is_autosave = wp_is_post_autosave( $post_id );
$is_revision = wp_is_post_revision( $post_id );
$is_valid_nonce = ( isset( $_POST['generate_de_nonce'] ) && wp_verify_nonce( $_POST['generate_de_nonce'], basename( __FILE__ ) ) ) ? true : false;
// Exits script depending on save status.
if ( $is_autosave || $is_revision || ! $is_valid_nonce ) {
return;
}
// Check that the logged in user has permission to edit this post.
if ( ! current_user_can( 'edit_post', $post_id ) ) {
return $post_id;
}
$options = array(
'_generate-disable-top-bar',
'_generate-disable-header',
'_generate-disable-nav',
'_generate-disable-secondary-nav',
'_generate-disable-headline',
'_generate-disable-footer',
'_generate-disable-post-image',
);
foreach ( $options as $key ) {
$value = isset( $_POST[ $key ] )
? sanitize_text_field( wp_unslash( $_POST[ $key ] ) )
: '';
if ( $value ) {
update_post_meta( $post_id, $key, $value );
} else {
delete_post_meta( $post_id, $key );
}
}
}
}
if ( ! function_exists( 'generate_disable_elements_setup' ) ) {
add_action( 'wp', 'generate_disable_elements_setup', 50 );
/**
* Disable the things.
*/
function generate_disable_elements_setup() {
// Don't run the function unless we're on a page it applies to.
if ( ! is_singular() ) {
return;
}
// Get the current post.
global $post;
// Grab our values.
if ( isset( $post ) ) {
$disable_top_bar = get_post_meta( $post->ID, '_generate-disable-top-bar', true );
$disable_header = get_post_meta( $post->ID, '_generate-disable-header', true );
$disable_mobile_header = get_post_meta( $post->ID, '_generate-disable-mobile-header', true );
$disable_nav = get_post_meta( $post->ID, '_generate-disable-nav', true );
$disable_headline = get_post_meta( $post->ID, '_generate-disable-headline', true );
$disable_footer = get_post_meta( $post->ID, '_generate-disable-footer', true );
}
// Remove the top bar.
if ( ! empty( $disable_top_bar ) && false !== $disable_top_bar && function_exists( 'generate_top_bar' ) ) {
remove_action( 'generate_before_header', 'generate_top_bar', 5 );
remove_action( 'generate_inside_secondary_navigation', 'generate_secondary_nav_top_bar_widget', 5 );
}
// Remove the header.
if ( ! empty( $disable_header ) && false !== $disable_header && function_exists( 'generate_construct_header' ) ) {
remove_action( 'generate_header', 'generate_construct_header' );
}
// Remove the mobile header.
if ( ! empty( $disable_mobile_header ) && false !== $disable_mobile_header && function_exists( 'generate_menu_plus_mobile_header' ) ) {
remove_action( 'generate_after_header', 'generate_menu_plus_mobile_header', 5 );
}
// Remove the navigation.
if ( ! empty( $disable_nav ) && false !== $disable_nav && function_exists( 'generate_get_navigation_location' ) ) {
add_filter( 'generate_navigation_location', '__return_false', 20 );
add_filter( 'generate_disable_mobile_header_menu', '__return_true' );
}
// Remove the title.
if ( ! empty( $disable_headline ) && false !== $disable_headline && function_exists( 'generate_show_title' ) ) {
add_filter( 'generate_show_title', '__return_false' );
}
// Remove the footer.
if ( ! empty( $disable_footer ) && false !== $disable_footer ) {
if ( function_exists( 'generate_construct_footer_widgets' ) ) {
remove_action( 'generate_footer', 'generate_construct_footer_widgets', 5 );
}
if ( function_exists( 'generate_construct_footer' ) ) {
remove_action( 'generate_footer', 'generate_construct_footer' );
}
}
}
}
add_action( 'generate_layout_disable_elements_section', 'generate_premium_disable_elements_options' );
/**
* Add the meta box options to the Layout meta box in the new GP
*
* @since 1.4
* @param array $stored_meta Existing meta data.
*/
function generate_premium_disable_elements_options( $stored_meta ) {
$stored_meta['_generate-disable-header'][0] = ( isset( $stored_meta['_generate-disable-header'][0] ) ) ? $stored_meta['_generate-disable-header'][0] : '';
$stored_meta['_generate-disable-mobile-header'][0] = ( isset( $stored_meta['_generate-disable-mobile-header'][0] ) ) ? $stored_meta['_generate-disable-mobile-header'][0] : '';
$stored_meta['_generate-disable-nav'][0] = ( isset( $stored_meta['_generate-disable-nav'][0] ) ) ? $stored_meta['_generate-disable-nav'][0] : '';
$stored_meta['_generate-disable-secondary-nav'][0] = ( isset( $stored_meta['_generate-disable-secondary-nav'][0] ) ) ? $stored_meta['_generate-disable-secondary-nav'][0] : '';
$stored_meta['_generate-disable-post-image'][0] = ( isset( $stored_meta['_generate-disable-post-image'][0] ) ) ? $stored_meta['_generate-disable-post-image'][0] : '';
$stored_meta['_generate-disable-headline'][0] = ( isset( $stored_meta['_generate-disable-headline'][0] ) ) ? $stored_meta['_generate-disable-headline'][0] : '';
$stored_meta['_generate-disable-footer'][0] = ( isset( $stored_meta['_generate-disable-footer'][0] ) ) ? $stored_meta['_generate-disable-footer'][0] : '';
$stored_meta['_generate-disable-top-bar'][0] = ( isset( $stored_meta['_generate-disable-top-bar'][0] ) ) ? $stored_meta['_generate-disable-top-bar'][0] : '';
?>
<div class="generate_disable_elements">
<?php if ( function_exists( 'generate_top_bar' ) ) : ?>
<label for="meta-generate-disable-top-bar" style="display:block;margin-bottom:3px;" title="<?php _e( 'Top Bar', 'gp-premium' ); ?>">
<input type="checkbox" name="_generate-disable-top-bar" id="meta-generate-disable-top-bar" value="true" <?php checked( $stored_meta['_generate-disable-top-bar'][0], 'true' ); ?>>
<?php _e( 'Top Bar', 'gp-premium' ); ?>
</label>
<?php endif; ?>
<label for="meta-generate-disable-header" style="display:block;margin-bottom:3px;" title="<?php _e( 'Header', 'gp-premium' ); ?>">
<input type="checkbox" name="_generate-disable-header" id="meta-generate-disable-header" value="true" <?php checked( $stored_meta['_generate-disable-header'][0], 'true' ); ?>>
<?php _e( 'Header', 'gp-premium' ); ?>
</label>
<?php
if ( function_exists( 'generate_menu_plus_get_defaults' ) ) :
$menu_plus_settings = wp_parse_args(
get_option( 'generate_menu_plus_settings', array() ),
generate_menu_plus_get_defaults()
);
if ( 'enable' === $menu_plus_settings['mobile_header'] ) :
?>
<label for="meta-generate-disable-mobile-header" style="display:block;margin-bottom:3px;" title="<?php esc_attr_e( 'Mobile Header', 'gp-premium' ); ?>">
<input type="checkbox" name="_generate-disable-mobile-header" id="meta-generate-disable-mobile-header" value="true" <?php checked( $stored_meta['_generate-disable-mobile-header'][0], 'true' ); ?>>
<?php esc_html_e( 'Mobile Header', 'gp-premium' ); ?>
</label>
<?php
endif;
endif;
?>
<label for="meta-generate-disable-nav" style="display:block;margin-bottom:3px;" title="<?php _e( 'Primary Navigation', 'gp-premium' ); ?>">
<input type="checkbox" name="_generate-disable-nav" id="meta-generate-disable-nav" value="true" <?php checked( $stored_meta['_generate-disable-nav'][0], 'true' ); ?>>
<?php _e( 'Primary Navigation', 'gp-premium' ); ?>
</label>
<?php if ( function_exists( 'generate_secondary_nav_setup' ) ) : ?>
<label for="meta-generate-disable-secondary-nav" style="display:block;margin-bottom:3px;" title="<?php _e( 'Secondary Navigation', 'gp-premium' ); ?>">
<input type="checkbox" name="_generate-disable-secondary-nav" id="meta-generate-disable-secondary-nav" value="true" <?php checked( $stored_meta['_generate-disable-secondary-nav'][0], 'true' ); ?>>
<?php _e( 'Secondary Navigation', 'gp-premium' ); ?>
</label>
<?php endif; ?>
<label for="meta-generate-disable-post-image" style="display:block;margin-bottom:3px;" title="<?php _e( 'Featured Image', 'gp-premium' ); ?>">
<input type="checkbox" name="_generate-disable-post-image" id="meta-generate-disable-post-image" value="true" <?php checked( $stored_meta['_generate-disable-post-image'][0], 'true' ); ?>>
<?php _e( 'Featured Image', 'gp-premium' ); ?>
</label>
<label for="meta-generate-disable-headline" style="display:block;margin-bottom:3px;" title="<?php _e( 'Content Title', 'gp-premium' ); ?>">
<input type="checkbox" name="_generate-disable-headline" id="meta-generate-disable-headline" value="true" <?php checked( $stored_meta['_generate-disable-headline'][0], 'true' ); ?>>
<?php _e( 'Content Title', 'gp-premium' ); ?>
</label>
<label for="meta-generate-disable-footer" style="display:block;margin-bottom:3px;" title="<?php _e( 'Footer', 'gp-premium' ); ?>">
<input type="checkbox" name="_generate-disable-footer" id="meta-generate-disable-footer" value="true" <?php checked( $stored_meta['_generate-disable-footer'][0], 'true' ); ?>>
<?php _e( 'Footer', 'gp-premium' ); ?>
</label>
</div>
<?php
}
add_action( 'generate_layout_meta_box_save', 'generate_premium_save_disable_elements_meta' );
/**
* Save the Disable Elements meta box values
*
* @since 1.4
* @param int $post_id The post ID.
*/
function generate_premium_save_disable_elements_meta( $post_id ) {
$options = array(
'_generate-disable-top-bar',
'_generate-disable-header',
'_generate-disable-mobile-header',
'_generate-disable-nav',
'_generate-disable-secondary-nav',
'_generate-disable-headline',
'_generate-disable-footer',
'_generate-disable-post-image',
);
foreach ( $options as $key ) {
$value = isset( $_POST[ $key ] ) // phpcs:ignore -- Nonce exists within `generate_layout_meta_box_save` hook.
? sanitize_text_field( wp_unslash( $_POST[ $key ] ) ) // phpcs:ignore -- Nonce exists within `generate_layout_meta_box_save` hook.
: '';
if ( $value ) {
update_post_meta( $post_id, $key, $value );
} else {
delete_post_meta( $post_id, $key );
}
}
}
add_filter( 'body_class', 'generate_disable_elements_body_classes', 20 );
/**
* Remove body classes if certain elements are disabled.
*
* @since 2.1.0
* @param array $classes Our body classes.
*/
function generate_disable_elements_body_classes( $classes ) {
if ( is_singular() ) {
$disable_featured_image = get_post_meta( get_the_ID(), '_generate-disable-post-image', true );
$classes = generate_premium_remove_featured_image_class( $classes, $disable_featured_image );
}
return $classes;
}

View File

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

View File

@ -0,0 +1 @@
<?php return array('dependencies' => array('lodash', 'react', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-data', 'wp-dom-ready', 'wp-edit-post', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-server-side-render'), 'version' => 'cf85acaca6a9b96dc3a3');

View File

@ -0,0 +1,7 @@
.inline-post-meta-area.block-editor-block-list__layout,.inline-post-meta-area>.gb-inside-container.block-editor-block-list__layout,.inline-post-meta-area>.gb-inside-container>.block-editor-inner-blocks>.block-editor-block-list__layout{align-items:center;display:flex}.inline-post-meta-area.block-editor-block-list__layout>.wp-block.block-list-appender,.inline-post-meta-area>.gb-inside-container.block-editor-block-list__layout>.wp-block.block-list-appender,.inline-post-meta-area>.gb-inside-container>.block-editor-inner-blocks>.block-editor-block-list__layout>.wp-block.block-list-appender{margin-left:20px}.inline-post-meta-area.block-editor-block-list__layout>.wp-block-image,.inline-post-meta-area>.gb-inside-container.block-editor-block-list__layout>.wp-block-image,.inline-post-meta-area>.gb-inside-container>.block-editor-inner-blocks>.block-editor-block-list__layout>.wp-block-image{line-height:0}.inline-post-meta-area.block-editor-block-list__layout>.wp-block-image figcaption,.inline-post-meta-area>.gb-inside-container.block-editor-block-list__layout>.wp-block-image figcaption,.inline-post-meta-area>.gb-inside-container>.block-editor-inner-blocks>.block-editor-block-list__layout>.wp-block-image figcaption{display:none}.inline-post-meta-area .wp-block{margin-left:0;margin-right:0}.gpp-dynamic-container-bg-dropdown .components-popover__content{width:275px}.gpp-dynamic-container-bg-dropdown .components-popover__content .components-base-control:not(:last-child){margin-bottom:20px}.gpp-dynamic-container-bg-dropdown .components-popover__content .components-base-control:last-child .components-base-control__field{margin-bottom:0}.gpp-dynamic-container-bg-dropdown .components-popover__content .components-base-control:last-child .components-base-control__help{margin-top:3px}
.gpp-dynamic-headline-text-dropdown .components-popover__content{width:275px}.gpp-dynamic-headline-text-dropdown .components-popover__content .components-base-control:not(:last-child){margin-bottom:20px}.gpp-dynamic-headline-text-dropdown .components-popover__content .components-base-control:last-child .components-base-control__field{margin-bottom:0}.gpp-dynamic-headline-text-dropdown .components-popover__content .components-base-control:last-child .components-base-control__help{margin-top:3px}.gpp-blocks-dynamic-text-replace-field{display:none}.gpp-block-dynamic-year .components-base-control__help{margin-top:2px}
.wp-block[data-type="generatepress/dynamic-content"]{margin-bottom:0;margin-top:0}
.wp-block[data-type="generatepress/dynamic-image"]{color:#fff;margin-bottom:0;margin-top:0}.wp-block[data-type="generatepress/dynamic-image"] .components-gpp-dynamic-image-placeholder__label{align-items:center;bottom:0;color:#fff;display:flex;font-size:1em;justify-content:center;left:0;position:absolute;right:0;top:0}.wp-block[data-type="generatepress/dynamic-image"] .components-gpp-dynamic-image-placeholder__label>.gpp-dynamic-featured-image__label{margin-left:10px}.wp-block[data-type="generatepress/dynamic-image"] .gpp-dynamic-image-placeholder{background:#000;vertical-align:middle}.wp-block[data-type="generatepress/dynamic-image"] .components-placeholder{width:100%}.wp-block[data-type="generatepress/dynamic-image"] .gpp-dynamic-image-preview{display:inline-block;position:relative}.wp-block[data-type="generatepress/dynamic-image"] .dynamic-author-image-rounded{border-radius:100%}
.components-generatepress-units-control-header__units{align-items:center;display:flex;justify-content:space-between;margin-bottom:5px}.components-generatepress-control__units .components-generatepress-control-buttons__units button.components-button{background:#fff;border:0;border-radius:0!important;box-shadow:none!important;color:#929da7;font-size:10px;height:auto;line-height:20px;padding:0 5px;position:relative;text-align:center;text-shadow:none}.components-generatepress-control__units .components-generatepress-control-buttons__units button.components-button.is-primary{background:#fff!important;color:#000!important;cursor:default;font-weight:700;z-index:1}
.editor-styles-wrapper .is-root-container>.wp-block{margin-left:auto;margin-right:auto;max-width:var(--gp-block-element-width)}.left-sidebar-block-type div:not(.block-editor-inner-blocks)>.block-editor-block-list__layout,.right-sidebar-block-type div:not(.block-editor-inner-blocks)>.block-editor-block-list__layout{padding:10px}.gpp-block-element-panel>.components-base-control{margin-bottom:20px}.gpp-block-element-panel .components-notice,.gpp-block-element-panel .components-notice .components-notice__content{margin:0}.gpp-element-panel-label .components-panel__body-toggle.components-button{display:flex;flex-direction:row-reverse;justify-content:flex-end}.gpp-element-panel-label .components-panel__body-toggle.components-button svg.components-panel__icon{margin:0 10px 0 0}button.gpp-block-elements-template-button{background:#fff;border:1px solid #ddd;border-radius:5px;cursor:pointer;margin:0 0 10px;padding:5px}button.gpp-block-elements-template-button:hover{border-color:var(--wp-admin-theme-color)}button.gpp-block-elements-template-button .gpp-block-template-label{color:#888;font-size:13px;padding:5px}.element-has-parent #generate_premium_elements{display:none}.gpp-block-element-template-panel{background:#fafafa}
.gp-select-search .select-search-container{--select-search-background:#fff;--select-search-border:#949494;--select-search-selected:var(--wp-admin-theme-color);--select-search-text:#2c3338;--select-search-subtle-text:#6c6f85;--select-search-inverted-text:var(--select-search-background);--select-search-highlight:#eff1f5;box-sizing:border-box;color:var(--select-search-text);font-family:var(--select-search-font);position:relative;width:100%}.gp-select-search .select-search-container *,.gp-select-search .select-search-container :after,.gp-select-search .select-search-container :before{box-sizing:inherit}.gp-select-search .select-search-input{-webkit-font-smoothing:antialiased;-webkit-appearance:none;background:var(--select-search-background) url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20width%3D%2220%22%20height%3D%2220%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3E%3Cpath%20d%3D%22M5%206l5%205%205-5%202%201-7%207-7-7%202-1z%22%20fill%3D%22%23555%22%2F%3E%3C%2Fsvg%3E") no-repeat right 5px top 55%;background-size:13px 13px;border:1px solid var(--select-search-border);border-radius:3px;color:var(--select-search-text);display:block;font-size:13px;height:30px;letter-spacing:.01rem;line-height:30px;outline:none;padding:0 26px 0 8px;position:relative;text-align:left;text-overflow:ellipsis;width:100%;z-index:1}.gp-select-search .select-search-is-multiple .select-search-input{border-radius:3px 3px 0 0;margin-bottom:-2px}.gp-select-search .select-search-input::-webkit-search-cancel-button,.gp-select-search .select-search-input::-webkit-search-decoration,.gp-select-search .select-search-input::-webkit-search-results-button,.gp-select-search .select-search-input::-webkit-search-results-decoration{-webkit-appearance:none}.gp-select-search .select-search-input[readonly]{cursor:pointer}.gp-select-search .select-search-is-disabled .select-search-input{cursor:not-allowed}.gp-select-search .select-search-container:not(.select-search-is-disabled) .select-search-input:hover,.gp-select-search .select-search-container:not(.select-search-is-disabled).select-search-has-focus .select-search-input{border-color:var(--select-search-selected)}.gp-select-search .select-search-select{background:var(--select-search-background);border:1px solid var(--select-search-border);box-shadow:0 .0625rem .125rem rgba(0,0,0,.15);max-height:360px;overflow:auto}.gp-select-search .select-search-container:not(.select-search-is-multiple) .select-search-select{border-radius:3px;display:none;left:0;position:absolute;right:0;top:35px;z-index:2}.gp-select-search .select-search-container:not(.select-search-is-multiple).select-search-has-focus .select-search-select{display:block}.gp-select-search .select-search-has-focus .select-search-select{border-color:var(--select-search-selected)}.gp-select-search .select-search-options{list-style:none}.gp-select-search .select-search-not-found,.gp-select-search .select-search-option{-webkit-font-smoothing:antialiased;background:var(--select-search-background);border:none;color:var(--select-search-text);cursor:pointer;display:block;font-family:monospace;font-size:10px;height:30px;letter-spacing:.01rem;outline:none;padding:0 16px;text-align:left;width:100%}.gp-select-search .select-search-option:disabled{background:transparent!important;cursor:not-allowed;opacity:.5}.gp-select-search .select-search-is-highlighted,.gp-select-search .select-search-option:not(.select-search-is-selected):hover{background:var(--select-search-highlight)}.gp-select-search .select-search-is-selected{color:var(--select-search-selected);font-weight:700}.gp-select-search .select-search-group-header{font-size:12px;font-weight:700;letter-spacing:.1rem;padding:10px 16px;text-transform:uppercase}

File diff suppressed because one or more lines are too long

View File

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

View File

@ -0,0 +1 @@
!function(){"use strict";function e(o){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(o)}function o(o){var r=function(o,r){if("object"!==e(o)||null===o)return o;var t=o[Symbol.toPrimitive];if(void 0!==t){var n=t.call(o,"string");if("object"!==e(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(o)}(o);return"symbol"===e(r)?r:String(r)}var r=window.wp.hooks,t=window.wp.i18n;function n(e,o){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);o&&(t=t.filter((function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable}))),r.push.apply(r,t)}return r}function a(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?n(Object(t),!0).forEach((function(r){var n,a,i;n=e,a=r,i=t[r],(a=o(a))in n?Object.defineProperty(n,a,{value:i,enumerable:!0,configurable:!0,writable:!0}):n[a]=i})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):n(Object(t)).forEach((function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(t,o))}))}return e}(0,r.addFilter)("generate_typography_element_groups","generatepress-pro/customizer/add-typography-groups",(function(e){var o={};return gpCustomizerControls.hasSecondaryNav&&(o.secondaryNavigation=(0,t.__)("Secondary Navigation","gp-premium")),gpCustomizerControls.hasMenuPlus&&(o.offCanvasPanel=(0,t.__)("Off-Canvas Panel","gp-premium")),gpCustomizerControls.hasWooCommerce&&(o.wooCommerce=(0,t.__)("WooCommerce","gp-premium")),a(a({},e),o)})),(0,r.addFilter)("generate_typography_elements","generatepress-pro/customizer/add-typography-elements",(function(e){var o={};return gpCustomizerControls.hasSecondaryNav&&(o["secondary-nav-menu-items"]={module:"secondary-nav",group:"secondaryNavigation",label:(0,t.__)("Secondary Menu Items","gp-premium"),placeholders:{fontSize:{value:"13",min:6,max:30,step:1}}},o["secondary-nav-sub-menu-items"]={module:"secondary-nav",group:"secondaryNavigation",label:(0,t.__)("Secondary Sub-Menu Items","gp-premium"),placeholders:{fontSize:{value:"12",min:6,max:30,step:1}}},o["secondary-nav-menu-toggle"]={module:"secondary-nav",group:"secondaryNavigation",label:(0,t.__)("Secondary Mobile Menu Toggle","gp-premium"),placeholders:{fontSize:{value:"13",min:6,max:30,step:1}}}),gpCustomizerControls.hasMenuPlus&&(o["off-canvas-panel-menu-items"]={module:"off-canvas-panel",group:"offCanvasPanel",label:(0,t.__)("Off-Canvas Menu Items","gp-premium"),placeholders:{fontSize:{value:"",min:6,max:30,step:1}}},o["off-canvas-panel-sub-menu-items"]={module:"off-canvas-panel",group:"offCanvasPanel",label:(0,t.__)("Off-Canvas Sub-Menu Items","gp-premium"),placeholders:{fontSize:{value:"",min:6,max:30,step:1}}}),gpCustomizerControls.hasWooCommerce&&(o["woocommerce-catalog-product-titles"]={module:"woocommerce",group:"wooCommerce",label:(0,t.__)("Catalog Product Titles","gp-premium"),placeholders:{fontSize:{value:"",min:6,max:50,step:1}}},o["woocommerce-related-product-titles"]={module:"woocommerce",group:"wooCommerce",label:(0,t.__)("Related/Upsell Product Titles","gp-premium"),placeholders:{fontSize:{value:"",min:6,max:50,step:1}}}),a(a({},e),o)}))}();

View File

@ -0,0 +1 @@
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-components', 'wp-element', 'wp-i18n'), 'version' => '0ab64c3a1832f10e060d');

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
<?php return array('dependencies' => array('react', 'wp-edit-post', 'wp-element', 'wp-html-entities', 'wp-i18n', 'wp-plugins'), 'version' => 'd1ae659d7b937f65b15d');

View File

@ -0,0 +1 @@
.gpp-active-element-type{color:#555;font-size:11px;text-transform:uppercase}

View File

@ -0,0 +1 @@
!function(){"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(t,n){for(var r=0;r<n.length;r++){var o=n[r];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,(i=o.key,c=void 0,c=function(t,n){if("object"!==e(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,"string");if("object"!==e(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(i),"symbol"===e(c)?c:String(c)),o)}var i,c}function n(e,t){return n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},n(e,t)}function r(e){return r=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},r(e)}var o=window.React,i=window.wp.i18n,c=window.wp.plugins,l=window.wp.editPost,u=window.wp.element,a=window.wp.htmlEntities;function p(t){var n=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var o,i=r(t);if(n){var c=r(this).constructor;o=Reflect.construct(i,arguments,c)}else o=i.apply(this,arguments);return function(t,n){if(n&&("object"===e(n)||"function"==typeof n))return n;if(void 0!==n)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(t)}(this,o)}}var f=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&n(e,t)}(s,e);var r,c,f=p(s);function s(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,s),f.apply(this,arguments)}return r=s,(c=[{key:"render",value:function(){var e=gpPremiumEditor.activeElements;return!e||e.length<1?null:gpPremiumEditor.postTypeIsPublic?(0,o.createElement)(l.PluginDocumentSettingPanel,{name:"generatepress-elements-info",title:(0,i.__)("Active Elements","gp-premium"),className:"gpp-element-info-panel gpp-element-panel-label"},(0,o.createElement)(u.Fragment,null,(0,o.createElement)("ul",{className:"gpp-active-elements"},Object.keys(e).map((function(t,n){return(0,o.createElement)("li",{key:"gpp-active-block-element-".concat(n)},(0,o.createElement)("a",{href:e[t].url+"&action=edit"},(0,a.decodeEntities)(e[t].name))," ",(0,o.createElement)("span",{className:"gpp-active-element-type"},"- ",e[t].type))}))),(0,o.createElement)("a",{href:gpPremiumEditor.elementsUrl,className:"components-button is-secondary"},(0,i.__)("All Elements","gp-premium")))):null}}])&&t(r.prototype,c),Object.defineProperty(r,"prototype",{writable:!1}),s}(u.Component);(0,c.registerPlugin)("generatepress-elements-info-panel",{icon:null,render:f})}();

View File

@ -0,0 +1 @@
<?php return array('dependencies' => array('react', 'wp-api-fetch', 'wp-components', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => '6e43dc7500e77c46bb9b');

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,4 @@
.generatepress-module-action{display:inline-block;font-size:12px;font-weight:400;line-height:1;margin-left:10px;text-decoration:none}.generatepress-dashboard__section-item-settings{align-items:center;display:flex}.generatepress-dashboard__section-item-settings button{font-size:11px;height:30px;justify-content:center!important}.generatepress-dashboard__section-item-settings button .components-spinner{margin-top:0}.generatepress-dashboard__section-item-settings button svg{height:20px;margin:0!important;width:20px}.generatepress-dashboard__section-item-settings button:not(:last-child){margin-right:5px}
.generatepress-license-key-area .generatepress-dashboard__section-item-message{background:#fff}.generatepress-license-key-area .generatepress-dashboard__section-item{flex-wrap:wrap;justify-content:flex-start}.generatepress-license-key-area .generatepress-dashboard__section-license-key{display:flex;flex:1}.generatepress-license-key-area .generatepress-dashboard__section-license-key .components-base-control{flex:1}.generatepress-license-key-area .generatepress-dashboard__section-license-key button{height:31px;margin-left:8px}.generatepress-license-key-area .generatepress-dashboard__section-beta-tester{align-items:center;display:flex;flex-basis:100%;margin-top:30px}.generatepress-license-key-area .generatepress-dashboard__section-license-notice{flex-basis:100%;margin:0 0 20px}.generatepress-license-key-area .components-base-control__field,.generatepress-license-key-area .components-base-control__help{margin-bottom:0}
.generatepress-dashboard__section-item-action input[type=file]{border:1px solid #ddd;padding:5px}.generatepress-dashboard__section-item-export-popover .components-popover__content{padding:20px}
.generatepress-dashboard__section-item-modules{margin-top:20px}

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

View File

@ -0,0 +1,211 @@
button[data-balloon] {
overflow: visible; }
[data-balloon] {
position: relative;
cursor: pointer; }
[data-balloon]:after {
filter: alpha(opacity=0);
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
-moz-opacity: 0;
-khtml-opacity: 0;
opacity: 0;
pointer-events: none;
transition: all 0.18s ease-out 0.18s;
font-weight: normal !important;
font-style: normal !important;
text-shadow: none !important;
font-size: 12px !important;
background: rgba(17, 17, 17, 0.9);
border-radius: 4px;
color: #fff;
content: attr(data-balloon);
padding: .5em 1em;
position: absolute;
white-space: nowrap;
z-index: 10; }
[data-balloon]:before {
background: no-repeat url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20width%3D%2236px%22%20height%3D%2212px%22%3E%3Cpath%20fill%3D%22rgba(17, 17, 17, 0.9)%22%20transform%3D%22rotate(0)%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E");
background-size: 100% auto;
width: 18px;
height: 6px;
filter: alpha(opacity=0);
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
-moz-opacity: 0;
-khtml-opacity: 0;
opacity: 0;
pointer-events: none;
transition: all 0.18s ease-out 0.18s;
content: '';
position: absolute;
z-index: 10; }
[data-balloon]:hover:before, [data-balloon]:hover:after, [data-balloon][data-balloon-visible]:before, [data-balloon][data-balloon-visible]:after {
filter: alpha(opacity=100);
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
-moz-opacity: 1;
-khtml-opacity: 1;
opacity: 1;
pointer-events: auto; }
[data-balloon].font-awesome:after {
font-family: FontAwesome; }
[data-balloon][data-balloon-break]:after {
white-space: pre; }
[data-balloon][data-balloon-blunt]:before, [data-balloon][data-balloon-blunt]:after {
transition: none; }
[data-balloon][data-balloon-pos="up"]:after {
bottom: 100%;
left: 50%;
margin-bottom: 11px;
transform: translate(-50%, 10px);
transform-origin: top; }
[data-balloon][data-balloon-pos="up"]:before {
bottom: 100%;
left: 50%;
margin-bottom: 5px;
transform: translate(-50%, 10px);
transform-origin: top; }
[data-balloon][data-balloon-pos="up"]:hover:after, [data-balloon][data-balloon-pos="up"][data-balloon-visible]:after {
transform: translate(-50%, 0); }
[data-balloon][data-balloon-pos="up"]:hover:before, [data-balloon][data-balloon-pos="up"][data-balloon-visible]:before {
transform: translate(-50%, 0); }
[data-balloon][data-balloon-pos="up-left"]:after {
bottom: 100%;
left: 0;
margin-bottom: 11px;
transform: translate(0, 10px);
transform-origin: top; }
[data-balloon][data-balloon-pos="up-left"]:before {
bottom: 100%;
left: 5px;
margin-bottom: 5px;
transform: translate(0, 10px);
transform-origin: top; }
[data-balloon][data-balloon-pos="up-left"]:hover:after, [data-balloon][data-balloon-pos="up-left"][data-balloon-visible]:after {
transform: translate(0, 0); }
[data-balloon][data-balloon-pos="up-left"]:hover:before, [data-balloon][data-balloon-pos="up-left"][data-balloon-visible]:before {
transform: translate(0, 0); }
[data-balloon][data-balloon-pos="up-right"]:after {
bottom: 100%;
right: 0;
margin-bottom: 11px;
transform: translate(0, 10px);
transform-origin: top; }
[data-balloon][data-balloon-pos="up-right"]:before {
bottom: 100%;
right: 5px;
margin-bottom: 5px;
transform: translate(0, 10px);
transform-origin: top; }
[data-balloon][data-balloon-pos="up-right"]:hover:after, [data-balloon][data-balloon-pos="up-right"][data-balloon-visible]:after {
transform: translate(0, 0); }
[data-balloon][data-balloon-pos="up-right"]:hover:before, [data-balloon][data-balloon-pos="up-right"][data-balloon-visible]:before {
transform: translate(0, 0); }
[data-balloon][data-balloon-pos='down']:after {
left: 50%;
margin-top: 11px;
top: 100%;
transform: translate(-50%, -10px); }
[data-balloon][data-balloon-pos='down']:before {
background: no-repeat url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20width%3D%2236px%22%20height%3D%2212px%22%3E%3Cpath%20fill%3D%22rgba(17, 17, 17, 0.9)%22%20transform%3D%22rotate(180 18 6)%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E");
background-size: 100% auto;
width: 18px;
height: 6px;
left: 50%;
margin-top: 5px;
top: 100%;
transform: translate(-50%, -10px); }
[data-balloon][data-balloon-pos='down']:hover:after, [data-balloon][data-balloon-pos='down'][data-balloon-visible]:after {
transform: translate(-50%, 0); }
[data-balloon][data-balloon-pos='down']:hover:before, [data-balloon][data-balloon-pos='down'][data-balloon-visible]:before {
transform: translate(-50%, 0); }
[data-balloon][data-balloon-pos='down-left']:after {
left: 0;
margin-top: 11px;
top: 100%;
transform: translate(0, -10px); }
[data-balloon][data-balloon-pos='down-left']:before {
background: no-repeat url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20width%3D%2236px%22%20height%3D%2212px%22%3E%3Cpath%20fill%3D%22rgba(17, 17, 17, 0.9)%22%20transform%3D%22rotate(180 18 6)%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E");
background-size: 100% auto;
width: 18px;
height: 6px;
left: 5px;
margin-top: 5px;
top: 100%;
transform: translate(0, -10px); }
[data-balloon][data-balloon-pos='down-left']:hover:after, [data-balloon][data-balloon-pos='down-left'][data-balloon-visible]:after {
transform: translate(0, 0); }
[data-balloon][data-balloon-pos='down-left']:hover:before, [data-balloon][data-balloon-pos='down-left'][data-balloon-visible]:before {
transform: translate(0, 0); }
[data-balloon][data-balloon-pos='down-right']:after {
right: 0;
margin-top: 11px;
top: 100%;
transform: translate(0, -10px); }
[data-balloon][data-balloon-pos='down-right']:before {
background: no-repeat url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20width%3D%2236px%22%20height%3D%2212px%22%3E%3Cpath%20fill%3D%22rgba(17, 17, 17, 0.9)%22%20transform%3D%22rotate(180 18 6)%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E");
background-size: 100% auto;
width: 18px;
height: 6px;
right: 5px;
margin-top: 5px;
top: 100%;
transform: translate(0, -10px); }
[data-balloon][data-balloon-pos='down-right']:hover:after, [data-balloon][data-balloon-pos='down-right'][data-balloon-visible]:after {
transform: translate(0, 0); }
[data-balloon][data-balloon-pos='down-right']:hover:before, [data-balloon][data-balloon-pos='down-right'][data-balloon-visible]:before {
transform: translate(0, 0); }
[data-balloon][data-balloon-pos='left']:after {
margin-right: 11px;
right: 100%;
top: 50%;
transform: translate(10px, -50%); }
[data-balloon][data-balloon-pos='left']:before {
background: no-repeat url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20width%3D%2212px%22%20height%3D%2236px%22%3E%3Cpath%20fill%3D%22rgba(17, 17, 17, 0.9)%22%20transform%3D%22rotate(-90 18 18)%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E");
background-size: 100% auto;
width: 6px;
height: 18px;
margin-right: 5px;
right: 100%;
top: 50%;
transform: translate(10px, -50%); }
[data-balloon][data-balloon-pos='left']:hover:after, [data-balloon][data-balloon-pos='left'][data-balloon-visible]:after {
transform: translate(0, -50%); }
[data-balloon][data-balloon-pos='left']:hover:before, [data-balloon][data-balloon-pos='left'][data-balloon-visible]:before {
transform: translate(0, -50%); }
[data-balloon][data-balloon-pos='right']:after {
left: 100%;
margin-left: 11px;
top: 50%;
transform: translate(-10px, -50%); }
[data-balloon][data-balloon-pos='right']:before {
background: no-repeat url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20width%3D%2212px%22%20height%3D%2236px%22%3E%3Cpath%20fill%3D%22rgba(17, 17, 17, 0.9)%22%20transform%3D%22rotate(90 6 6)%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E");
background-size: 100% auto;
width: 6px;
height: 18px;
left: 100%;
margin-left: 5px;
top: 50%;
transform: translate(-10px, -50%); }
[data-balloon][data-balloon-pos='right']:hover:after, [data-balloon][data-balloon-pos='right'][data-balloon-visible]:after {
transform: translate(0, -50%); }
[data-balloon][data-balloon-pos='right']:hover:before, [data-balloon][data-balloon-pos='right'][data-balloon-visible]:before {
transform: translate(0, -50%); }
[data-balloon][data-balloon-length='small']:after {
white-space: normal;
width: 80px; }
[data-balloon][data-balloon-length='medium']:after {
white-space: normal;
width: 150px; }
[data-balloon][data-balloon-length='large']:after {
white-space: normal;
width: 260px; }
[data-balloon][data-balloon-length='xlarge']:after {
white-space: normal;
width: 380px; }
@media screen and (max-width: 768px) {
[data-balloon][data-balloon-length='xlarge']:after {
white-space: normal;
width: 90vw; } }
[data-balloon][data-balloon-length='fit']:after {
white-space: normal;
width: 100%; }

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,29 @@
jQuery( function( $ ) {
$( '.post-type-gp_elements .page-title-action:not(.legacy-button)' ).on( 'click', function( e ) {
e.preventDefault();
$( '.choose-element-type-parent' ).show();
$( '.choose-element-type .select-type' ).focus();
} );
$( '.close-choose-element-type' ).on( 'click', function( e ) {
e.preventDefault();
$( '.choose-element-type-parent' ).hide();
$( '.page-title-action' ).focus();
} );
$( '.post-type-gp_elements' ).on( 'keyup', function( e ) {
const $element = $( '.choose-element-type-parent' );
if ( e.key === 'Escape' && $element.is( ':visible' ) ) {
$element.hide();
$( '.page-title-action' ).focus();
}
} );
// Don't allow Elements to quick edit parents.
$( '.inline-edit-gp_elements select#post_parent, .inline-edit-gp_elements .inline-edit-menu-order-input, .bulk-edit-gp_elements select#post_parent' ).each( function() {
$( this ).closest( 'label' ).remove();
} );
} );

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 B

View File

@ -0,0 +1,396 @@
#generate_premium_elements {
background-color: transparent;
border: 0;
box-shadow: 0 0 0;
}
#generate_premium_elements .inside {
padding: 0;
margin: 0;
}
#generate_premium_elements .CodeMirror {
position: relative;
padding: 0;
background: white;
box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3;
width: 100%;
overflow: hidden;
}
tr.generate-element-row td {
border-bottom: 1px solid #f0f0f0;
zoom: 1;
}
td.generate-element-row-heading {
background: #F9F9F9;
border-right: 1px solid #E1E1E1;
padding: 13px 15px;
width: 24%;
}
td.generate-element-row-heading label {
display: inline-block;
font-size: 13px;
line-height: 1.4em;
font-weight: bold;
padding: 0;
margin: 0 0 3px;
color: #333;
}
td.generate-element-row-content {
padding: 13px 15px;
position: relative;
width: 75%;
}
#generate_premium_elements .handlediv,
#generate_premium_elements .hndle,
#generate_premium_elements .postbox-header {
display: none;
}
#generate_premium_elements .inside {
padding: 0;
}
#generate_premium_elements select,
#generate_premium_elements input[type="number"],
#generate_premium_elements input[type="text"] {
width: 100%;
}
#generate_premium_elements .condition select.condition-object-select + .select2 {
display: none;
}
#generate_premium_elements .condition.generate-elements-rule-objects-visible select.condition-select + .select2 {
margin-right: 5px;
width: 100%;
}
#generate_premium_elements .condition.generate-elements-rule-objects-visible select.condition-object-select + .select2 {
display: inline-block;
margin-left: 5px;
width: 100%;
}
#generate_premium_elements .condition {
display: flex;
margin-bottom: 10px;
}
#generate_premium_elements .condition .select2 {
flex-grow: 1;
}
button.remove-condition {
background: transparent;
border: 0;
line-height: 1;
width: 30px;
font-size: 20px;
cursor: pointer;
opacity: 0.5;
position: relative;
bottom: -3px;
}
button.add-condition {
margin-top: 10px !important;
}
button.remove-condition:before {
content: "\f153";
font-family: dashicons;
}
table.generate-elements-settings {
position: relative;
padding: 0;
background: white;
box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3;
width: 100%;
overflow: hidden;
}
.generate-element-row-loading {
background-color: rgba(255,255,255,0.9);
background-image: url('spinner.gif');
background-position: center center;
background-repeat: no-repeat;
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: 1;
}
ul.element-metabox-tabs {
position: relative;
padding: 0;
margin: 0 0 20px;
background: white;
box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3;
display: flex;
width: 100%;
overflow: hidden;
}
ul.element-metabox-tabs li {
width: auto;
flex: none;
border-bottom: 2px solid transparent;
border-top: none;
text-align: center;
margin-bottom: 0;
}
ul.element-metabox-tabs li a {
display: block;
width: auto;
padding: 16px 16px 14px 16px;
color: #0087be;
font-weight: 400;
text-decoration: none;
box-shadow: 0 0 0;
}
ul.element-metabox-tabs li a:hover {
color: #00a0d2;
}
ul.element-metabox-tabs li.is-selected {
border-bottom-color: #2e4453;
}
ul.element-metabox-tabs li.is-selected a {
color: #2e4453;
}
#generate-element-content,
#generate-element-content + .CodeMirror {
margin-bottom: 20px;
}
.element-metabox-tabs li:not([data-tab="display-rules"]):not([data-tab="internal-notes"]),
.generate-elements-settings:not([data-tab="display-rules"]):not([data-tab="internal-notes"]) {
display: none;
}
.element-settings.header .element-metabox-tabs li[data-type="header"],
.element-settings.hook .element-metabox-tabs li[data-type="hook"],
.element-settings.block .element-metabox-tabs li[data-type="hook"],
.element-settings.layout .element-metabox-tabs li[data-type="layout"] {
display: block;
}
.element-settings.header:not(.has-page-hero) table[data-tab="site-header"],
.element-settings.header.has-page-hero table[data-tab="hero"],
.element-settings.hook table[data-tab="hook-settings"],
.element-settings.block table[data-tab="hook-settings"],
.element-settings.layout table[data-tab="sidebars"] {
display: table;
}
.element-settings.header:not(.has-page-hero) #generate-element-content {
display: none;
}
.element-settings.header:not(.has-page-hero) #generate-element-content + .CodeMirror:not(.gpp-elements-show-codemirror) {
height: 0;
overflow: hidden;
opacity: 0;
margin: 0;
}
.padding-container {
display: flex;
}
.single-value-padding-container {
display: block;
}
.single-value-padding-container input[type="number"] {
width: 60px !important;
display: inline-block;
vertical-align: middle;
}
.padding-element-options {
display: flex;
}
.padding-element span.unit {
border: 1px solid #ddd;
display: inline-block;
line-height: 26px;
padding: 0 10px;
margin-left: -5px;
vertical-align: middle;
border-left: 0;
}
.padding-element input {
width: 60px !important;
min-height: 30px;
}
.padding-element select {
width: auto !important;
position: relative;
left: -5px;
min-height: 30px;
}
.padding-element span {
display: block;
font-size: 90%;
opacity: 0.8;
}
.generate-element-row-content .responsive-controls.single-responsive-value {
padding: 8px 15px 7px 0;
}
.generate-element-row-content .responsive-controls.checkbox-responsive-value {
padding: 2px 15px 0 0;
}
#postimagediv {
display: none;
}
.image-preview img {
height: 30px;
width: auto;
vertical-align: middle;
border-radius: 5px;
}
.gp-media-preview img {
vertical-align: middle;
background-color: #efefef;
border-radius: 5px;
height: 30px;
width: auto;
}
.media-container,
.change-featured-image,
.set-featured-image {
display: flex;
align-items: center;
}
.media-container > input,
.media-container .gp-media-preview img,
.change-featured-image > *,
.set-featured-image > * {
margin-right: 10px !important;
}
.generate-element-row-content .responsive-controls {
float: left;
padding: 15px 15px 15px 0;
}
.generate-element-row-content .responsive-controls a {
text-decoration: none;
color: #222;
opacity: 0.5;
outline: 0;
box-shadow: 0 0 0;
}
.generate-element-row-content .responsive-controls a.is-selected {
opacity: 1;
}
.generate-element-row-content .responsive-controls a span {
font-size: 14px;
width: auto;
height: auto;
vertical-align: baseline;
}
#generate-element-content {
width: 100%;
height: 300px;
}
.layout-radio-item {
margin-bottom: 3px;
}
.layout-radio-item:first-child {
margin-bottom: 15px;
}
span.tip {
display: inline-block;
float: right;
background: #b3b3b3;
height: 15px;
width: 15px;
text-align: center;
line-height: 15px;
color: #fff;
border-radius: 50%;
font-size: 10px;
}
body:not(.header-element-type) #generate_page_hero_template_tags,
.header-element-type:not(.element-has-page-hero) #generate_page_hero_template_tags {
display: none;
}
#_generate_element_internal_notes {
width: 100%;
height: 250px;
}
.select2-results__option {
margin: 0;
}
body .select2-container--default .select2-selection--single {
border-color: #ddd;
}
.select2-results__option[role="list"] {
padding: 0;
}
#generate_premium_elements #_generate_content_width {
width: 65px;
vertical-align: middle;
}
#_generate_content_width + span {
border: 1px solid #ddd;
height: 26px;
display: inline-block;
vertical-align: middle;
line-height: 26px;
padding: 0 10px;
margin-left: -6px;
}
.hide-hook-row,
.sidebar-notice {
display: none;
}
.sidebar-notice {
margin-top: 10px;
font-style: italic;
}
.element-settings.block .generate-elements-settings[data-type="hook"] tr:last-child td {
border-bottom: 0;
}

View File

@ -0,0 +1,424 @@
jQuery( function( $ ) {
if ( $( '.element-settings' ).hasClass( 'header' ) || $( '.element-settings' ).hasClass( 'hook' ) ) {
$( function() {
if ( elements.settings ) {
wp.codeEditor.initialize( 'generate-element-content', elements.settings );
}
} );
}
$( '#_generate_block_type' ).on( 'change', function() {
var _this = $( this ).val();
if ( 'hook' === _this ) {
$( '.hook-row' ).removeClass( 'hide-hook-row' );
} else {
$( '.hook-row' ).addClass( 'hide-hook-row' );
}
$( 'body' ).removeClass( 'right-sidebar-block-type' );
$( 'body' ).removeClass( 'left-sidebar-block-type' );
$( 'body' ).removeClass( 'header-block-type' );
$( 'body' ).removeClass( 'footer-block-type' );
$( 'body' ).addClass( _this + '-block-type' );
if ( 'left-sidebar' === _this || 'right-sidebar' === _this ) {
$( '.sidebar-notice' ).show();
} else {
$( '.sidebar-notice' ).hide();
}
} );
$( '#_generate_hook' ).on( 'change', function() {
var _this = $( this );
$( '.disable-header-hook' ).hide();
$( '.disable-footer-hook' ).hide();
$( '.custom-hook-name' ).hide();
if ( 'generate_header' === _this.val() ) {
$( '.disable-header-hook' ).show();
}
if ( 'generate_footer' === _this.val() ) {
$( '.disable-footer-hook' ).show();
}
if ( 'custom' === _this.val() ) {
$( '.custom-hook-name' ).show();
}
} );
$( '#_generate_hook' ).select2( {
width: '100%',
} );
$( '.element-metabox-tabs li' ).on( 'click', function() {
var _this = $( this ),
tab = _this.data( 'tab' );
_this.siblings().removeClass( 'is-selected' );
_this.addClass( 'is-selected' );
$( '.generate-elements-settings' ).hide();
$( '.generate-elements-settings[data-tab="' + tab + '"]' ).show();
if ( $( '.element-settings' ).hasClass( 'block' ) && 'hook-settings' === tab ) {
$( '.generate-elements-settings[data-tab="display-rules"]' ).show();
}
if ( $( '.element-settings' ).hasClass( 'header' ) ) {
if ( 'hero' !== tab ) {
$( '#generate-element-content' ).next( '.CodeMirror' ).removeClass( 'gpp-elements-show-codemirror' );
$( '#generate_page_hero_template_tags' ).css( 'display', '' );
} else {
$( '#generate-element-content' ).next( '.CodeMirror' ).addClass( 'gpp-elements-show-codemirror' );
$( '#generate_page_hero_template_tags' ).css( 'display', 'block' );
}
}
} );
var select2Init = function() {
var selects = $( '.generate-element-row-content .condition:not(.hidden) select:not(.select2-init)' );
selects.each( function() {
var select = $( this ),
config = {
width: 'style',
};
select.select2( config );
select.addClass( 'select2-init' );
} );
};
select2Init();
$( '.add-condition' ).on( 'click', function() {
var _this = $( this );
var row = _this.closest( '.generate-element-row-content' ).find( '.condition.hidden.screen-reader-text' ).clone( true );
row.removeClass( 'hidden screen-reader-text' );
row.insertBefore( _this.closest( '.generate-element-row-content' ).find( '.condition:last' ) );
select2Init();
return false;
} );
$( '.remove-condition' ).on( 'click', function() {
$( this ).parents( '.condition' ).remove();
select2Init();
return false;
} );
var getLocationObjects = function( _this, onload = false, data = '' ) {
var select = _this,
parent = select.parent(),
location = select.val(),
objectSelect = parent.find( '.condition-object-select' ),
locationType = '',
actionType = 'terms';
if ( '' === location ) {
parent.removeClass( 'generate-elements-rule-objects-visible' );
select.closest( '.generate-element-row-content' ).find( '.generate-element-row-loading' ).remove();
} else {
if ( location.indexOf( ':taxonomy:' ) > 0 ) {
locationType = 'taxonomy';
} else {
locationType = location.substr( 0, location.indexOf( ':' ) );
}
var locationID = location.substr( location.lastIndexOf( ':' ) + 1 );
if ( 'taxonomy' === locationType || 'post' === locationType ) {
if ( ! ( '.generate-element-row-loading' ).length ) {
select.closest( '.generate-element-row-content' ).prepend( '<div class="generate-element-row-loading"></div>' );
}
var fillObjects = function( response ) {
var objects = response[ locationID ].objects;
var blank = {
id: '',
name: 'All ' + response[ locationID ].label,
};
if ( location.indexOf( ':taxonomy:' ) > 0 ) {
blank.name = elements.choose;
}
objectSelect.empty();
objectSelect.append( $( '<option>', {
value: blank.id,
label: blank.name,
text: blank.name,
} ) );
$.each( objects, function( key, value ) {
objectSelect.append( $( '<option>', {
value: value.id,
label: elements.showID && value.id ? value.name + ': ' + value.id : value.name,
text: elements.showID && value.id ? value.name + ': ' + value.id : value.name,
} ) );
} );
parent.addClass( 'generate-elements-rule-objects-visible' );
if ( onload ) {
objectSelect.val( objectSelect.attr( 'data-saved-value' ) );
}
select.closest( '.generate-element-row-content' ).find( '.generate-element-row-loading' ).remove();
};
if ( data && onload ) {
// Use pre-fetched data if we just loaded the page.
fillObjects( data );
} else {
if ( 'post' === locationType ) {
if ( 'taxonomy' === locationType ) {
actionType = 'terms';
} else {
actionType = 'posts';
}
}
$.post( ajaxurl, {
action: 'generate_elements_get_location_' + actionType,
id: locationID,
nonce: elements.nonce,
}, function( response ) {
response = JSON.parse( response );
fillObjects( response );
} );
}
} else {
parent.removeClass( 'generate-elements-rule-objects-visible' );
select.closest( '.generate-element-row-content' ).find( '.generate-element-row-loading' ).remove();
objectSelect.empty().append( '<option value="0"></option>' );
objectSelect.val( '0' );
}
}
};
$( '.condition select.condition-select' ).on( 'change', function() {
getLocationObjects( $( this ) );
$( '.elements-no-location-error' ).hide();
} );
var postObjects = [];
var termObjects = [];
$( '.generate-elements-rule-objects-visible' ).each( function() {
var _this = $( this ),
select = _this.find( 'select.condition-select' ),
location = select.val(),
locationID = location.substr( location.lastIndexOf( ':' ) + 1 ),
locationType = '';
if ( location.indexOf( ':taxonomy:' ) > 0 ) {
locationType = 'taxonomy';
} else {
locationType = location.substr( 0, location.indexOf( ':' ) );
}
if ( 'post' === locationType ) {
if ( ! postObjects.includes( locationID ) ) {
postObjects.push( locationID );
}
} else if ( 'taxonomy' === locationType && ! termObjects.includes( locationID ) ) {
termObjects.push( locationID );
}
} );
if ( postObjects.length > 0 || termObjects.length > 0 ) {
$.post( ajaxurl, {
action: 'generate_elements_get_location_objects',
posts: postObjects,
terms: termObjects,
nonce: elements.nonce,
}, function( response ) {
response = JSON.parse( response );
$( '.generate-elements-rule-objects-visible' ).each( function() {
var _this = $( this ),
select = _this.find( 'select.condition-select' );
$( '<div class="generate-element-row-loading"></div>' ).insertBefore( _this );
getLocationObjects( select, true, response );
} );
} );
}
$( '.set-featured-image a, .change-featured-image a:not(.remove-image)' ).on( 'click', function( event ) {
event.preventDefault();
// Stop propagation to prevent thickbox from activating.
event.stopPropagation();
// Open the featured image modal
wp.media.featuredImage.frame().open();
} );
wp.media.featuredImage.frame().on( 'select', function() {
$( '.set-featured-image' ).hide();
$( '.change-featured-image' ).show();
setTimeout( function() {
$( '.image-preview' ).empty();
$( '#postimagediv img' ).appendTo( '.image-preview' );
}, 500 );
} );
$( '#postimagediv' ).on( 'click', '#remove-post-thumbnail', function() {
$( '.set-featured-image' ).show();
$( '.change-featured-image' ).hide();
$( '.image-preview' ).empty();
return false;
} );
$( '.remove-image' ).on( 'click', function( e ) {
e.preventDefault();
$( '#remove-post-thumbnail' ).trigger( 'click' );
} );
$( '.generate-upload-file' ).on( 'click', function() {
if ( frame ) {
frame.open();
return;
}
var _this = $( this ),
container = _this.closest( '.media-container' );
var frame = wp.media( {
title: _this.data( 'title' ),
multiple: false,
library: { type: _this.data( 'type' ) },
button: { text: _this.data( 'insert' ) },
} );
frame.on( 'select', function() {
var attachment = frame.state().get( 'selection' ).first().toJSON();
container.find( '.media-field' ).val( attachment.id );
container.find( '.remove-field' ).show();
if ( _this.data( 'preview' ) ) {
container.find( '.gp-media-preview' ).empty().append( '<img src="' + attachment.url + '" width="50" />' ).show();
}
} );
frame.open();
} );
$( '.remove-field' ).on( 'click', function() {
var _this = $( this ),
container = _this.closest( '.media-container' );
_this.hide();
container.find( '.media-field' ).val( '' );
container.find( '.gp-media-preview' ).empty();
} );
$( '#_generate_hero_background_image' ).on( 'change', function() {
var _this = $( this );
if ( '' !== _this.val() ) {
$( '.requires-background-image' ).show();
} else {
$( '.requires-background-image' ).hide();
}
if ( 'featured-image' === _this.val() ) {
$( '.image-text' ).text( elements.fallback_image );
}
if ( 'custom-image' === _this.val() ) {
$( '.image-text' ).text( elements.custom_image );
}
} );
// Responsive controls in our settings.
$( '.responsive-controls a' ).on( 'click', function( e ) {
e.preventDefault();
var _this = $( this ),
control = _this.attr( 'data-control' ),
controlArea = _this.closest( '.generate-element-row-content' );
controlArea.find( '.padding-container' ).hide();
controlArea.find( '.padding-container.' + control ).show();
_this.siblings().removeClass( 'is-selected' );
_this.addClass( 'is-selected' );
} );
$( '#_generate_site_header_merge' ).on( 'change', function() {
var _this = $( this );
if ( '' !== _this.val() ) {
$( '.requires-header-merge' ).show();
if ( $( '#_generate_navigation_colors' ).is( ':checked' ) ) {
$( '.requires-navigation-colors' ).show();
}
if ( $( '#_generate_hero_full_screen' ).is( ':checked' ) ) {
$( '.requires-full-screen' ).show();
}
} else {
$( '.requires-header-merge' ).hide();
$( '.requires-navigation-colors' ).hide();
$( '.requires-full-screen' ).hide();
}
} );
$( '#_generate_navigation_colors' ).on( 'change', function() {
var _this = $( this );
if ( _this.is( ':checked' ) ) {
$( '.requires-navigation-colors' ).show();
} else {
$( '.requires-navigation-colors' ).hide();
}
} );
$( '#_generate_hero_full_screen' ).on( 'change', function() {
var _this = $( this );
if ( _this.is( ':checked' ) ) {
$( '.requires-full-screen' ).show();
} else {
$( '.requires-full-screen' ).hide();
}
} );
$( '#_generate_hero_background_parallax' ).on( 'change', function() {
var _this = $( this );
if ( _this.is( ':checked' ) ) {
$( '#_generate_hero_background_position' ).val( '' ).change();
$( '#_generate_hero_background_position option[value="left center"]' ).attr( 'disabled', true );
$( '#_generate_hero_background_position option[value="left bottom"]' ).attr( 'disabled', true );
$( '#_generate_hero_background_position option[value="right center"]' ).attr( 'disabled', true );
$( '#_generate_hero_background_position option[value="right bottom"]' ).attr( 'disabled', true );
$( '#_generate_hero_background_position option[value="center center"]' ).attr( 'disabled', true );
$( '#_generate_hero_background_position option[value="center bottom"]' ).attr( 'disabled', true );
} else {
$( '#_generate_hero_background_position option[value="left center"]' ).attr( 'disabled', false );
$( '#_generate_hero_background_position option[value="left bottom"]' ).attr( 'disabled', false );
$( '#_generate_hero_background_position option[value="right center"]' ).attr( 'disabled', false );
$( '#_generate_hero_background_position option[value="right bottom"]' ).attr( 'disabled', false );
$( '#_generate_hero_background_position option[value="center center"]' ).attr( 'disabled', false );
$( '#_generate_hero_background_position option[value="center bottom"]' ).attr( 'disabled', false );
}
} );
} );

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

@ -0,0 +1,17 @@
function generate_parallax_element( selector, context ) {
context = context || document;
var elements = context.querySelectorAll( selector );
return Array.prototype.slice.call( elements );
}
window.addEventListener( "scroll", function() {
var scrolledHeight= window.pageYOffset;
generate_parallax_element( ".page-hero" ).forEach( function( el, index, array ) {
var limit = el.offsetTop + el.offsetHeight;
if( scrolledHeight > el.offsetTop && scrolledHeight <= limit ) {
el.style.backgroundPositionY = ( scrolledHeight - el.offsetTop ) / hero.parallax + "px";
} else {
el.style.backgroundPositionY = "0";
}
});
});

View File

@ -0,0 +1 @@
function generate_parallax_element(e,o){var t=(o=o||document).querySelectorAll(e);return Array.prototype.slice.call(t)}window.addEventListener("scroll",function(){var r=window.pageYOffset;generate_parallax_element(".page-hero").forEach(function(e,o,t){var a=e.offsetTop+e.offsetHeight;r>e.offsetTop&&r<=a?e.style.backgroundPositionY=(r-e.offsetTop)/hero.parallax+"px":e.style.backgroundPositionY="0"})});

View File

@ -0,0 +1,469 @@
<?php
/**
* This file displays our block elements on the site.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
/**
* Build our Block Elements.
*/
class GeneratePress_Block_Element {
/**
* The element ID.
*
* @since 1.11.0
* @var int ID of the element.
*/
protected $post_id = '';
/**
* The element type.
*
* @since 1.11.0
* @var string Type of element.
*/
protected $type = '';
/**
* Has post ancestors.
*
* @since 2.0.0
* @var boolean If this post has a parent.
*/
protected $has_parent = false;
/**
* Kicks it all off.
*
* @since 1.11.0
*
* @param int $post_id The element post ID.
*/
public function __construct( $post_id ) {
$this->post_id = $post_id;
$this->type = get_post_meta( $post_id, '_generate_block_type', true );
$has_content_template_condition = get_post_meta( $post_id, '_generate_post_loop_item_display', true );
// Take over the $post_id temporarily if this is a child block.
// This allows us to inherit the parent block Display Rules.
if ( 'content-template' === $this->type && $has_content_template_condition ) {
$parent_block = wp_get_post_parent_id( $post_id );
if ( ! empty( $parent_block ) ) {
$this->has_parent = true;
$post_id = $parent_block;
}
}
$display_conditions = get_post_meta( $post_id, '_generate_element_display_conditions', true ) ? get_post_meta( $post_id, '_generate_element_display_conditions', true ) : array();
$exclude_conditions = get_post_meta( $post_id, '_generate_element_exclude_conditions', true ) ? get_post_meta( $post_id, '_generate_element_exclude_conditions', true ) : array();
$user_conditions = get_post_meta( $post_id, '_generate_element_user_conditions', true ) ? get_post_meta( $post_id, '_generate_element_user_conditions', true ) : array();
$display = apply_filters(
'generate_block_element_display',
GeneratePress_Conditions::show_data(
$display_conditions,
$exclude_conditions,
$user_conditions
),
$post_id
);
/**
* Simplify filter name.
*
* @since 2.0.0
*/
$display = apply_filters(
'generate_element_display',
$display,
$post_id
);
// Restore our actual post ID if it's been changed.
if ( 'content-template' === $this->type && $has_content_template_condition ) {
$post_id = $this->post_id;
}
if ( $display ) {
global $generate_elements;
$generate_elements[ $post_id ] = array(
'is_block_element' => true,
'type' => $this->type,
'id' => $post_id,
);
$hook = get_post_meta( $post_id, '_generate_hook', true );
$custom_hook = get_post_meta( $post_id, '_generate_custom_hook', true );
$priority = get_post_meta( $post_id, '_generate_hook_priority', true );
if ( '' === $priority ) {
$priority = 10;
}
switch ( $this->type ) {
case 'site-header':
$hook = 'generate_header';
break;
case 'site-footer':
$hook = 'generate_footer';
break;
case 'right-sidebar':
$hook = 'generate_before_right_sidebar_content';
break;
case 'left-sidebar':
$hook = 'generate_before_left_sidebar_content';
break;
case 'content-template':
$hook = 'generate_before_do_template_part';
break;
case 'loop-template':
$hook = 'generate_before_main_content';
break;
case 'search-modal':
$hook = 'generate_inside_search_modal';
break;
}
if ( 'custom' === $hook && $custom_hook ) {
$hook = $custom_hook;
}
if ( 'post-meta-template' === $this->type ) {
$post_meta_location = get_post_meta( $post_id, '_generate_post_meta_location', true );
if ( '' === $post_meta_location || 'after-post-title' === $post_meta_location ) {
$hook = 'generate_after_entry_title';
if ( is_page() ) {
$hook = 'generate_after_page_title';
}
} elseif ( 'before-post-title' === $post_meta_location ) {
$hook = 'generate_before_entry_title';
if ( is_page() ) {
$hook = 'generate_before_page_title';
}
} elseif ( 'after-content' === $post_meta_location ) {
$hook = 'generate_after_content';
}
}
if ( ! $hook ) {
return;
}
if ( 'generate_header' === $hook ) {
remove_action( 'generate_header', 'generate_construct_header' );
}
if ( 'generate_footer' === $hook ) {
remove_action( 'generate_footer', 'generate_construct_footer' );
}
if ( 'content-template' === $this->type && ! $this->has_parent ) {
add_filter( 'generate_do_template_part', array( $this, 'do_template_part' ) );
}
if ( 'loop-template' === $this->type ) {
add_filter( 'generate_has_default_loop', '__return_false' );
add_filter( 'generate_blog_columns', '__return_false' );
add_filter( 'option_generate_blog_settings', array( $this, 'filter_blog_settings' ) );
add_filter( 'post_class', array( $this, 'post_classes' ) );
}
if ( 'search-modal' === $this->type ) {
remove_action( 'generate_inside_search_modal', 'generate_do_search_fields' );
}
add_action( 'wp', array( $this, 'remove_elements' ), 100 );
add_action( esc_attr( $hook ), array( $this, 'build_hook' ), absint( $priority ) );
add_filter( 'generateblocks_do_content', array( $this, 'do_block_content' ) );
}
}
/**
* Disable our post loop items if needed.
*
* @param boolean $do Whether to display the default post loop item or not.
*/
public function do_template_part( $do ) {
if ( GeneratePress_Elements_Helper::should_render_content_template( $this->post_id ) ) {
return false;
}
return $do;
}
/**
* Tell GenerateBlocks about our block element content so it can build CSS.
*
* @since 1.11.0
* @param string $content The existing content.
*/
public function do_block_content( $content ) {
if ( has_blocks( $this->post_id ) ) {
$block_element = get_post( $this->post_id );
if ( ! $block_element || 'gp_elements' !== $block_element->post_type ) {
return $content;
}
if ( 'publish' !== $block_element->post_status || ! empty( $block_element->post_password ) ) {
return $content;
}
$content .= $block_element->post_content;
}
return $content;
}
/**
* Remove existing sidebar widgets.
*
* @since 1.11.0
* @param array $widgets The existing widgets.
*/
public function remove_sidebar_widgets( $widgets ) {
if ( 'right-sidebar' === $this->type ) {
unset( $widgets['sidebar-1'] );
}
if ( 'left-sidebar' === $this->type ) {
unset( $widgets['sidebar-2'] );
}
return $widgets;
}
/**
* Filter some of our blog settings.
*
* @param array $settings Existing blog settings.
*/
public function filter_blog_settings( $settings ) {
if ( 'loop-template' === $this->type ) {
$settings['infinite_scroll'] = false;
$settings['read_more_button'] = false;
}
return $settings;
}
/**
* Add class to our loop template item posts.
*
* @param array $classes Post classes.
*/
public function post_classes( $classes ) {
if ( 'loop-template' === $this->type && is_main_query() ) {
$classes[] = 'is-loop-template-item';
}
return $classes;
}
/**
* Remove existing elements.
*
* @since 2.0.0
*/
public function remove_elements() {
if ( 'right-sidebar' === $this->type || 'left-sidebar' === $this->type ) {
add_filter( 'sidebars_widgets', array( $this, 'remove_sidebar_widgets' ) );
add_filter( 'generate_show_default_sidebar_widgets', '__return_false' );
}
if ( 'page-hero' === $this->type ) {
$disable_title = get_post_meta( $this->post_id, '_generate_disable_title', true );
$disable_featured_image = get_post_meta( $this->post_id, '_generate_disable_featured_image', true );
$disable_primary_post_meta = get_post_meta( $this->post_id, '_generate_disable_primary_post_meta', true );
if ( $disable_title ) {
if ( is_singular() ) {
add_filter( 'generate_show_title', '__return_false' );
}
remove_action( 'generate_archive_title', 'generate_archive_title' );
remove_filter( 'get_the_archive_title', 'generate_filter_the_archive_title' );
// WooCommerce removal.
if ( class_exists( 'WooCommerce' ) ) {
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
add_filter( 'woocommerce_show_page_title', '__return_false' );
remove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description' );
remove_action( 'woocommerce_archive_description', 'woocommerce_product_archive_description' );
}
}
if ( $disable_primary_post_meta ) {
remove_action( 'generate_after_entry_title', 'generate_post_meta' );
}
if ( $disable_featured_image && is_singular() ) {
remove_action( 'generate_after_entry_header', 'generate_blog_single_featured_image' );
remove_action( 'generate_before_content', 'generate_blog_single_featured_image' );
remove_action( 'generate_after_header', 'generate_blog_single_featured_image' );
remove_action( 'generate_before_content', 'generate_featured_page_header_inside_single' );
remove_action( 'generate_after_header', 'generate_featured_page_header' );
}
}
if ( 'post-meta-template' === $this->type ) {
$post_meta_location = get_post_meta( $this->post_id, '_generate_post_meta_location', true );
$disable_primary_post_meta = get_post_meta( $this->post_id, '_generate_disable_primary_post_meta', true );
$disable_secondary_post_meta = get_post_meta( $this->post_id, '_generate_disable_secondary_post_meta', true );
if ( '' === $post_meta_location || 'after-post-title' === $post_meta_location || 'custom' === $post_meta_location ) {
if ( $disable_primary_post_meta ) {
remove_action( 'generate_after_entry_title', 'generate_post_meta' );
}
} elseif ( 'before-post-title' === $post_meta_location || 'custom' === $post_meta_location ) {
if ( $disable_primary_post_meta ) {
remove_action( 'generate_after_entry_title', 'generate_post_meta' );
}
} elseif ( 'after-content' === $post_meta_location || 'custom' === $post_meta_location ) {
if ( $disable_secondary_post_meta ) {
remove_action( 'generate_after_entry_content', 'generate_footer_meta' );
}
}
}
if ( 'post-navigation-template' === $this->type ) {
$disable_post_navigation = get_post_meta( $this->post_id, '_generate_disable_post_navigation', true );
if ( $disable_post_navigation ) {
add_filter( 'generate_footer_entry_meta_items', array( $this, 'disable_post_navigation' ) );
}
}
if ( 'archive-navigation-template' === $this->type ) {
$disable_archive_navigation = get_post_meta( $this->post_id, '_generate_disable_archive_navigation', true );
if ( $disable_archive_navigation ) {
remove_action( 'generate_after_loop', 'generate_do_post_navigation' );
}
}
}
/**
* Disable post navigation.
*
* @param array $items The post meta items.
*/
public function disable_post_navigation( $items ) {
return array_diff( $items, array( 'post-navigation' ) );
}
/**
* Builds the HTML structure for Page Headers.
*
* @since 1.11.0
*/
public function build_hook() {
$post_id = $this->post_id;
if ( 'content-template' === $this->type ) {
// Check for child templates if this isn't already one.
if ( ! $this->has_parent ) {
$children = get_posts(
array(
'post_type' => 'gp_elements',
'post_parent' => $post_id,
'order' => 'ASC',
'orderby' => 'menu_order',
'no_found_rows' => true,
'post_status' => 'publish',
'numberposts' => 20,
'fields' => 'ids',
)
);
if ( ! empty( $children ) ) {
// Loop through any child templates and overwrite $post_id if applicable.
foreach ( (array) $children as $child_id ) {
if ( GeneratePress_Elements_Helper::should_render_content_template( $child_id ) ) {
$post_id = $child_id;
break;
}
}
} else {
// No children, check if parent should render.
if ( ! GeneratePress_Elements_Helper::should_render_content_template( $post_id ) ) {
return;
}
}
} else {
// No children, check if template should render.
if ( ! GeneratePress_Elements_Helper::should_render_content_template( $post_id ) ) {
return;
}
}
// Don't display child elements - they will replace the parent element if applicable.
if ( $this->has_parent ) {
return;
}
$tag_name_value = get_post_meta( $post_id, '_generate_post_loop_item_tagname', true );
$use_theme_container = get_post_meta( $post_id, '_generate_use_theme_post_container', true );
if ( $tag_name_value ) {
$tag_name = $tag_name_value;
} else {
$tag_name = 'article';
}
printf(
'<%s id="%s" class="%s">',
esc_attr( $tag_name ),
'post-' . get_the_ID(),
implode( ' ', get_post_class( 'dynamic-content-template' ) ) // phpcs:ignore -- No escaping needed.
);
if ( $use_theme_container ) {
echo '<div class="inside-article">';
}
}
if ( 'archive-navigation-template' === $this->type || 'post-navigation-template' === $this->type ) {
$use_theme_pagination_container = get_post_meta( $post_id, '_generate_use_archive_navigation_container', true );
if ( $use_theme_pagination_container ) {
echo '<div class="paging-navigation">';
}
}
echo GeneratePress_Elements_Helper::build_content( $post_id ); // phpcs:ignore -- No escaping needed.
if ( 'content-template' === $this->type ) {
if ( $use_theme_container ) {
echo '</div>';
}
echo '</' . esc_attr( $tag_name ) . '>';
}
if ( 'archive-navigation-template' === $this->type || 'post-navigation-template' === $this->type ) {
$use_theme_pagination_container = get_post_meta( $post_id, '_generate_use_archive_navigation_container', true );
if ( $use_theme_pagination_container ) {
echo '</div>';
}
}
}
}

View File

@ -0,0 +1,447 @@
<?php
/**
* This file handles the Display Rule conditions for Elements.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
/**
* The conditions class.
*/
class GeneratePress_Conditions {
/**
* Instance.
*
* @var instance
*/
private static $instance;
/**
* Initiator
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Output our available location conditions.
*
* @since 1.7
*
* @return array
*/
public static function get_conditions() {
$types = array(
'general' => array(
'label' => esc_attr__( 'General', 'gp-premium' ),
'locations' => array(
'general:site' => esc_attr__( 'Entire Site', 'gp-premium' ),
'general:front_page' => esc_attr__( 'Front Page', 'gp-premium' ),
'general:blog' => esc_attr__( 'Blog', 'gp-premium' ),
'general:singular' => esc_attr__( 'All Singular', 'gp-premium' ),
'general:archive' => esc_attr__( 'All Archives', 'gp-premium' ),
'general:author' => esc_attr__( 'Author Archives', 'gp-premium' ),
'general:date' => esc_attr__( 'Date Archives', 'gp-premium' ),
'general:search' => esc_attr__( 'Search Results', 'gp-premium' ),
'general:no_results' => esc_attr__( 'No Search Results', 'gp-premium' ),
'general:404' => esc_attr__( '404 Template', 'gp-premium' ),
'general:is_paged' => esc_attr__( 'Paginated Results', 'gp-premium' ),
),
),
);
// Add the post types.
$post_types = get_post_types(
array(
'public' => true,
),
'objects'
);
foreach ( $post_types as $post_type_slug => $post_type ) {
if ( in_array( $post_type_slug, array( 'fl-theme-layout' ) ) ) {
continue;
}
$post_type_object = get_post_type_object( $post_type_slug );
$counts = wp_count_posts( $post_type_slug );
$count = $counts->publish + $counts->future + $counts->draft + $counts->pending + $counts->private;
// Add the post type.
$types[ $post_type_slug ] = array(
'label' => esc_html( $post_type->labels->name ),
'locations' => array(
'post:' . $post_type_slug => esc_html( $post_type->labels->singular_name ),
),
);
// Add the post type archive.
// We add this regardless of `has_archive` as we deal with that after taxonomies are added.
$types[ $post_type_slug . '_archive' ] = array(
/* translators: post type name */
'label' => sprintf( esc_html_x( '%s Archives', '%s is a singular post type name', 'gp-premium' ), $post_type->labels->singular_name ),
'locations' => array(
/* translators: post type name */
'archive:' . $post_type_slug => sprintf( esc_html_x( '%s Archive', '%s is a singular post type name', 'gp-premium' ), $post_type->labels->singular_name ),
),
);
// Add the taxonomies for the post type.
$taxonomies = get_object_taxonomies( $post_type_slug, 'objects' );
foreach ( $taxonomies as $taxonomy_slug => $taxonomy ) {
$public = $taxonomy->public && $taxonomy->show_ui;
if ( 'post_format' === $taxonomy_slug ) {
continue;
} elseif ( ! apply_filters( 'generate_elements_show_taxonomy', $public, $taxonomy ) ) {
continue;
}
$label = str_replace(
array(
$post_type->labels->name,
$post_type->labels->singular_name,
),
'',
$taxonomy->labels->singular_name
);
if ( isset( $types[ $post_type_slug . '_archive' ]['locations'] ) ) {
/* translators: '%1$s is post type label. %2$s is taxonomy label. */
$types[ $post_type_slug . '_archive' ]['locations'][ 'taxonomy:' . $taxonomy_slug ] = sprintf( esc_html_x( '%1$s %2$s Archive', '%1$s is post type label. %2$s is taxonomy label.', 'gp-premium' ), $post_type->labels->singular_name, $label );
}
if ( isset( $types[ $post_type_slug ]['locations'] ) ) {
$types[ $post_type_slug ]['locations'][ $post_type_slug . ':taxonomy:' . $taxonomy_slug ] = esc_html( $post_type->labels->singular_name . ' ' . $label );
}
}
// Remove the archives location if `has_archive` is set to false.
if ( 'post' !== $post_type_slug && empty( $post_type_object->has_archive ) ) {
unset( $types[ $post_type_slug . '_archive' ]['locations'][ 'archive:' . $post_type_slug ] );
}
// Remove the entire item if no locations exist.
if ( 0 === count( (array) $types[ $post_type_slug . '_archive' ]['locations'] ) ) {
unset( $types[ $post_type_slug . '_archive' ] );
}
}
return $types;
}
/**
* Output our available user conditions.
*
* @since 1.7
*
* @return array
*/
public static function get_user_conditions() {
$rules = array(
'general' => array(
'label' => esc_attr__( 'General', 'gp-premium' ),
'rules' => array(
'general:all' => esc_attr__( 'All Users', 'gp-premium' ),
'general:logged_in' => esc_attr__( 'Logged In', 'gp-premium' ),
'general:logged_out' => esc_attr__( 'Logged Out', 'gp-premium' ),
),
),
'role' => array(
'label' => esc_attr__( 'Roles', 'gp-premium' ),
'rules' => array(),
),
);
$roles = get_editable_roles();
foreach ( $roles as $slug => $data ) {
$rules['role']['rules'][ $slug ] = $data['name'];
}
return $rules;
}
/**
* Get our current location.
*
* @since 1.7
*
* @return array
*/
public static function get_current_location() {
global $wp_query;
global $post;
$location = null;
$object = null;
$queried_object = get_queried_object();
// Get the location string.
if ( is_front_page() ) {
$location = 'general:front_page';
} elseif ( is_home() ) {
$location = 'general:blog';
} elseif ( is_author() ) {
$location = 'general:author';
} elseif ( is_date() ) {
$location = 'general:date';
} elseif ( is_search() ) {
$location = 'general:search';
global $wp_query;
if ( 0 === $wp_query->found_posts ) {
$location = 'general:no_results';
}
} elseif ( is_404() ) {
$location = 'general:404';
} elseif ( is_category() ) {
$location = 'taxonomy:category';
if ( is_object( $queried_object ) ) {
$object = $queried_object->term_id;
}
} elseif ( is_tag() ) {
$location = 'taxonomy:post_tag';
if ( is_object( $queried_object ) ) {
$object = $queried_object->term_id;
}
} elseif ( is_tax() ) {
$location = 'taxonomy:' . get_query_var( 'taxonomy' );
if ( is_object( $queried_object ) ) {
$location = 'taxonomy:' . $queried_object->taxonomy;
$object = $queried_object->term_id;
}
} elseif ( is_post_type_archive() ) {
$post_type = $wp_query->get( 'post_type' );
if ( is_array( $post_type ) ) {
$location = 'archive:' . $post_type[0];
} else {
$location = 'archive:' . $post_type;
}
} elseif ( is_singular() ) {
if ( is_object( $post ) ) {
$location = 'post:' . $post->post_type;
}
if ( is_object( $queried_object ) ) {
$object = $queried_object->ID;
}
}
if ( is_admin() && function_exists( 'get_current_screen' ) ) {
$current_screen = get_current_screen();
if ( isset( $current_screen->is_block_editor ) && $current_screen->is_block_editor ) {
$post_id = false;
if ( isset( $_GET['post'] ) ) { // phpcs:ignore -- Just checking if it's set.
$post_id = absint( $_GET['post'] ); // phpcs:ignore -- No data processing going on.
}
if ( $post_id ) {
// Get the location string.
$front_page_id = get_option( 'page_on_front' );
$blog_id = get_option( 'page_for_posts' );
if ( (int) $post_id === (int) $front_page_id ) {
$location = 'general:front_page';
} elseif ( (int) $post_id === (int) $blog_id ) {
$location = 'general:blog';
} else {
if ( isset( $current_screen->post_type ) ) {
$location = 'post:' . $current_screen->post_type;
}
$object = $post_id;
}
} elseif ( isset( $_GET['post_type'] ) ) { // phpcs:ignore -- Just checking if it's set.
$location = 'post:' . esc_attr( $_GET['post_type'] ); // phpcs:ignore -- No data processing going on.
}
}
}
return array(
'rule' => $location,
'object' => $object,
);
}
/**
* Get info on the current user.
*
* @since 1.7
*
* @return array
*/
public static function get_current_user() {
$status = array();
if ( is_user_logged_in() ) {
$status[] = 'general:logged_in';
} else {
$status[] = 'general:logged_out';
}
$user = wp_get_current_user();
foreach ( (array) $user->roles as $role ) {
$status[] = $role;
}
return $status;
}
/**
* Figure out if we should display the element or not.
*
* @since 1.7
*
* @param array $conditionals The conditions.
* @param array $exclude The exclusions.
* @param array $roles The roles.
* @return bool
*/
public static function show_data( $conditionals, $exclude, $roles ) {
$current_location = self::get_current_location();
$show = false;
// Show depending on location conditionals.
if ( ! $show ) {
foreach ( (array) $conditionals as $conditional ) {
if ( in_array( 'general:site', $conditional ) ) {
$show = true;
} elseif ( is_singular() && in_array( 'general:singular', $conditional ) ) {
$show = true;
} elseif ( is_archive() && in_array( 'general:archive', $conditional ) ) {
$show = true;
} elseif ( ! empty( $current_location['rule'] ) && in_array( $current_location['rule'], $conditional ) ) {
if ( ! isset( $conditional['object'] ) || empty( $conditional['object'] ) ) {
$show = true;
} else {
if ( in_array( $current_location['object'], $conditional ) ) {
$show = true;
}
}
} elseif ( is_singular() && strstr( $conditional['rule'], ':taxonomy:' ) ) {
$tax = substr( $conditional['rule'], strrpos( $conditional['rule'], ':' ) + 1 );
if ( $tax && isset( $conditional['object'] ) && has_term( $conditional['object'], $tax ) ) {
$show = true;
}
} elseif ( is_front_page() && is_home() && ( in_array( 'general:blog', $conditional ) || in_array( 'general:front_page', $conditional ) ) ) {
// If the home page is the blog, both of general:blog and general:front_page apply.
$show = true;
} elseif ( in_array( 'general:is_paged', $conditional ) && is_paged() ) {
$show = true;
}
}
}
// Exclude based on exclusion conditionals.
if ( $show ) {
foreach ( (array) $exclude as $conditional ) {
if ( is_singular() && in_array( 'general:singular', $conditional ) ) {
$show = false;
} elseif ( is_archive() && in_array( 'general:archive', $conditional ) ) {
$show = false;
} elseif ( ! empty( $current_location['rule'] ) && in_array( $current_location['rule'], $conditional ) ) {
if ( ! isset( $conditional['object'] ) || empty( $conditional['object'] ) ) {
$show = false;
} else {
if ( in_array( $current_location['object'], $conditional ) ) {
$show = false;
}
}
} elseif ( is_singular() && strstr( $conditional['rule'], ':taxonomy:' ) ) {
$tax = substr( $conditional['rule'], strrpos( $conditional['rule'], ':' ) + 1 );
if ( $tax && isset( $conditional['object'] ) && has_term( $conditional['object'], $tax ) ) {
$show = false;
}
} elseif ( is_front_page() && is_home() && ( in_array( 'general:blog', $conditional ) || in_array( 'general:front_page', $conditional ) ) ) {
// If the home page is the blog, both of general:blog and general:front_page apply.
$show = false;
} elseif ( in_array( 'general:is_paged', $conditional ) && is_paged() ) {
$show = false;
}
}
}
// Exclude user roles.
if ( $show && ! empty( $roles ) ) {
$user_info = self::get_current_user();
$check = array_intersect( $roles, $user_info );
if ( ! count( $check ) > 0 && ! in_array( 'general:all', $roles ) ) {
$show = false;
}
}
return $show;
}
/**
* Returns the label for a saved location.
*
* @since 1.7
* @param string $saved_location The location.
* @return string|bool
*/
public static function get_saved_label( $saved_location ) {
$locations = self::get_conditions();
$rule = $saved_location['rule'];
$object_id = $saved_location['object'];
$object_type = '';
$label = false;
foreach ( $locations as $data ) {
if ( isset( $data['locations'][ $rule ] ) && ! $label ) {
$label = $data['locations'][ $rule ];
$object_types = explode( ':', $rule );
if ( in_array( 'taxonomy', $object_types ) && $object_id ) {
$term = get_term( $object_id );
if ( ! is_object( $term ) || is_wp_error( $term ) ) {
return false;
}
$label .= ': ' . $term->name;
} elseif ( ( in_array( 'post', $object_types ) || in_array( 'page', $object_types ) ) && $object_id ) {
$post = get_post( $object_id );
if ( ! is_object( $post ) ) {
return false;
}
$label .= ': ' . $post->post_title;
}
}
}
return $label;
}
}
GeneratePress_Conditions::get_instance();

View File

@ -0,0 +1,527 @@
<?php
/**
* This file contains helper functions for Elements.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
/**
* Helper functions.
*/
class GeneratePress_Elements_Helper {
/**
* Instance.
*
* @access private
* @var object Instance
* @since 1.7
*/
private static $instance;
/**
* Initiator.
*
* @since 1.7
* @return object initialized object of class.
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Check to see if specific theme/GPP options exist and are set.
*
* @since 1.7
*
* @param string $option Option to check.
* @return bool
*/
public static function does_option_exist( $option ) {
if ( function_exists( 'generate_get_defaults' ) ) {
$theme_settings = wp_parse_args(
get_option( 'generate_settings', array() ),
generate_get_defaults()
);
if ( 'site-title' === $option ) {
return $theme_settings['hide_title'] ? false : true;
}
if ( 'site-tagline' === $option ) {
return $theme_settings['hide_tagline'] ? false : true;
}
if ( 'retina-logo' === $option ) {
return $theme_settings['retina_logo'];
}
}
if ( 'site-logo' === $option ) {
return get_theme_mod( 'custom_logo' );
}
if ( function_exists( 'generate_menu_plus_get_defaults' ) ) {
$menu_settings = wp_parse_args(
get_option( 'generate_menu_plus_settings', array() ),
generate_menu_plus_get_defaults()
);
if ( 'navigation-as-header' === $option ) {
return $menu_settings['navigation_as_header'];
}
if ( 'mobile-logo' === $option ) {
return $menu_settings['mobile_header_logo'];
}
if ( 'navigation-logo' === $option ) {
return $menu_settings['sticky_menu_logo'];
}
if ( 'sticky-navigation' === $option ) {
return 'false' !== $menu_settings['sticky_menu'] ? true : false;
}
if ( 'sticky-navigation-logo' === $option ) {
return $menu_settings['sticky_navigation_logo'];
}
if ( 'mobile-header-branding' === $option ) {
return $menu_settings['mobile_header_branding'];
}
if ( 'sticky-mobile-header' === $option ) {
return 'disable' !== $menu_settings['mobile_header_sticky'] ? true : false;
}
}
return false;
}
/**
* Check whether we should execute PHP or not.
*/
public static function should_execute_php() {
$php = true;
if ( defined( 'DISALLOW_FILE_EDIT' ) ) {
$php = false;
}
return apply_filters( 'generate_hooks_execute_php', $php );
}
/**
* Build our HTML generated by the blocks.
*
* @since 1.11.0
*
* @param int $id The ID to check.
* @return string
*/
public static function build_content( $id ) {
if ( ! function_exists( 'do_blocks' ) ) {
return;
}
$block_element = get_post( $id );
if ( ! $block_element || 'gp_elements' !== $block_element->post_type ) {
return '';
}
if ( 'publish' !== $block_element->post_status || ! empty( $block_element->post_password ) ) {
return '';
}
$block_type = get_post_meta( $id, '_generate_block_type', true );
if ( 'site-footer' === $block_type ) {
$block_element->post_content = str_replace( '{{current_year}}', date( 'Y' ), $block_element->post_content ); // phpcs:ignore -- Prefer date().
}
// Handle embeds for block elements.
global $wp_embed;
if ( is_object( $wp_embed ) && method_exists( $wp_embed, 'autoembed' ) ) {
$block_element->post_content = $wp_embed->autoembed( $block_element->post_content );
}
return apply_filters( 'generate_do_block_element_content', do_blocks( $block_element->post_content ) );
}
/**
* Get our Element type label.
*
* @since 2.0.0
* @param string $type The type value.
*/
public static function get_element_type_label( $type ) {
switch ( $type ) {
case 'block':
$label = __( 'Block', 'gp-premium' );
break;
case 'header':
$label = __( 'Header', 'gp-premium' );
break;
case 'hook':
$label = __( 'Hook', 'gp-premium' );
break;
case 'layout':
$label = __( 'Layout', 'gp-premium' );
break;
case 'site-header':
$label = __( 'Site Header', 'gp-premium' );
break;
case 'page-hero':
$label = __( 'Page Hero', 'gp-premium' );
break;
case 'content-template':
$label = __( 'Content Template', 'gp-premium' );
break;
case 'loop-template':
$label = __( 'Loop Template', 'gp-premium' );
break;
case 'post-meta-template':
$label = __( 'Post Meta Template', 'gp-premium' );
break;
case 'post-navigation-template':
$label = __( 'Post Navigation', 'gp-premium' );
break;
case 'archive-navigation-template':
$label = __( 'Archive Navigation', 'gp-premium' );
break;
case 'right-sidebar':
$label = __( 'Right Sidebar', 'gp-premium' );
break;
case 'left-sidebar':
$label = __( 'Left Sidebar', 'gp-premium' );
break;
case 'site-footer':
$label = __( 'Site Footer', 'gp-premium' );
break;
default:
$label = esc_html( str_replace( '-', ' ', ucfirst( $type ) ) );
break;
}
return $label;
}
/**
* Check for content template conditions.
*
* @since 2.0.0
* @param int $post_id The post to check.
*/
public static function should_render_content_template( $post_id ) {
$loop_item_display = get_post_meta( $post_id, '_generate_post_loop_item_display', true );
$display = true;
if ( 'has-term' === $loop_item_display ) {
$tax = get_post_meta( $post_id, '_generate_post_loop_item_display_tax', true );
if ( $tax ) {
$term = get_post_meta( $post_id, '_generate_post_loop_item_display_term', true );
// Add support for multiple comma separated terms.
if ( ! empty( $term ) ) {
$term = str_replace( ' ', '', $term );
$term = explode( ',', $term );
}
if ( has_term( $term, $tax ) ) {
$display = true;
} else {
$display = false;
}
}
}
if ( 'has-post-meta' === $loop_item_display ) {
$post_meta_name = get_post_meta( $post_id, '_generate_post_loop_item_display_post_meta', true );
if ( $post_meta_name ) {
$post_meta = get_post_meta( get_the_ID(), $post_meta_name, true );
if ( $post_meta ) {
$display = true;
} else {
$display = false;
}
}
}
if ( 'is-first-post' === $loop_item_display ) {
global $wp_query;
if ( 0 === $wp_query->current_post && ! is_paged() ) {
$display = true;
} else {
$display = false;
}
}
return apply_filters( 'generate_should_render_content_template', $display, $post_id );
}
/**
* Build our entire list of hooks to display.
*
* @since 1.7
*
* @return array Our list of hooks.
*/
public static function get_available_hooks() {
$hooks = array(
'scripts' => array(
'group' => esc_attr__( 'Scripts/Styles', 'gp-premium' ),
'hooks' => array(
'wp_head',
'wp_body_open',
'wp_footer',
),
),
'header' => array(
'group' => esc_attr__( 'Header', 'gp-premium' ),
'hooks' => array(
'generate_before_header',
'generate_after_header',
'generate_before_header_content',
'generate_after_header_content',
'generate_before_logo',
'generate_after_logo',
'generate_header',
),
),
'navigation' => array(
'group' => esc_attr__( 'Navigation', 'gp-premium' ),
'hooks' => array(
'generate_inside_navigation',
'generate_after_primary_menu',
'generate_inside_secondary_navigation',
'generate_inside_mobile_menu',
'generate_inside_mobile_menu_bar',
'generate_inside_mobile_header',
'generate_inside_slideout_navigation',
'generate_after_slideout_navigation',
),
),
'content' => array(
'group' => esc_attr__( 'Content', 'gp-premium' ),
'hooks' => array(
'generate_inside_site_container',
'generate_inside_container',
'generate_before_main_content',
'generate_after_main_content',
'generate_before_content',
'generate_after_content',
'generate_after_entry_content',
'generate_after_primary_content_area',
'generate_before_entry_title',
'generate_after_entry_title',
'generate_after_entry_header',
'generate_before_archive_title',
'generate_after_archive_title',
'generate_after_archive_description',
),
),
'comments' => array(
'group' => esc_attr__( 'Comments', 'gp-premium' ),
'hooks' => array(
'generate_before_comments_container',
'generate_before_comments',
'generate_inside_comments',
'generate_below_comments_title',
),
),
'sidebars' => array(
'group' => esc_attr__( 'Sidebars', 'gp-premium' ),
'hooks' => array(
'generate_before_right_sidebar_content',
'generate_after_right_sidebar_content',
'generate_before_left_sidebar_content',
'generate_after_left_sidebar_content',
),
),
'footer' => array(
'group' => esc_attr__( 'Footer', 'gp-premium' ),
'hooks' => array(
'generate_before_footer',
'generate_after_footer',
'generate_after_footer_widgets',
'generate_before_footer_content',
'generate_after_footer_content',
'generate_footer',
),
),
);
if ( class_exists( 'WooCommerce' ) ) {
$hooks['navigation']['hooks'][] = 'generate_mobile_cart_items';
$hooks['woocommerce-global'] = array(
'group' => esc_attr__( 'WooCommerce - Global', 'gp-premium' ),
'hooks' => array(
'woocommerce_before_main_content',
'woocommerce_after_main_content',
'woocommerce_sidebar',
'woocommerce_breadcrumb',
),
);
$hooks['woocommerce-shop'] = array(
'group' => esc_attr__( 'WooCommerce - Shop', 'gp-premium' ),
'hooks' => array(
'woocommerce_archive_description',
'woocommerce_before_shop_loop',
'woocommerce_after_shop_loop',
'woocommerce_before_shop_loop_item_title',
'woocommerce_after_shop_loop_item_title',
),
);
$hooks['woocommerce-product'] = array(
'group' => esc_attr__( 'WooCommerce - Product', 'gp-premium' ),
'hooks' => array(
'woocommerce_before_single_product',
'woocommerce_before_single_product_summary',
'woocommerce_after_single_product_summary',
'woocommerce_single_product_summary',
'woocommerce_share',
'woocommerce_simple_add_to_cart',
'woocommerce_before_add_to_cart_form',
'woocommerce_after_add_to_cart_form',
'woocommerce_before_add_to_cart_button',
'woocommerce_after_add_to_cart_button',
'woocommerce_before_add_to_cart_quantity',
'woocommerce_after_add_to_cart_quantity',
'woocommerce_product_meta_start',
'woocommerce_product_meta_end',
'woocommerce_after_single_product',
),
);
$hooks['woocommerce-cart'] = array(
'group' => esc_attr__( 'WooCommerce - Cart', 'gp-premium' ),
'hooks' => array(
'woocommerce_before_calculate_totals',
'woocommerce_after_calculate_totals',
'woocommerce_before_cart',
'woocommerce_after_cart_table',
'woocommerce_before_cart_table',
'woocommerce_before_cart_contents',
'woocommerce_cart_contents',
'woocommerce_after_cart_contents',
'woocommerce_cart_coupon',
'woocommerce_cart_actions',
'woocommerce_before_cart_totals',
'woocommerce_cart_totals_before_order_total',
'woocommerce_cart_totals_after_order_total',
'woocommerce_proceed_to_checkout',
'woocommerce_after_cart_totals',
'woocommerce_after_cart',
),
);
$hooks['woocommerce-checkout'] = array(
'group' => esc_attr__( 'WooCommerce - Checkout', 'gp-premium' ),
'hooks' => array(
'woocommerce_before_checkout_form',
'woocommerce_checkout_before_customer_details',
'woocommerce_checkout_after_customer_details',
'woocommerce_checkout_billing',
'woocommerce_before_checkout_billing_form',
'woocommerce_after_checkout_billing_form',
'woocommerce_before_order_notes',
'woocommerce_after_order_notes',
'woocommerce_checkout_shipping',
'woocommerce_checkout_before_order_review',
'woocommerce_checkout_order_review',
'woocommerce_review_order_before_cart_contents',
'woocommerce_review_order_after_cart_contents',
'woocommerce_review_order_before_order_total',
'woocommerce_review_order_after_order_total',
'woocommerce_review_order_before_payment',
'woocommerce_review_order_before_submit',
'woocommerce_review_order_after_submit',
'woocommerce_review_order_after_payment',
'woocommerce_checkout_after_order_review',
'woocommerce_after_checkout_form',
),
);
$hooks['woocommerce-account'] = array(
'group' => esc_attr__( 'WooCommerce - Account', 'gp-premium' ),
'hooks' => array(
'woocommerce_before_account_navigation',
'woocommerce_account_navigation',
'woocommerce_after_account_navigation',
),
);
}
if ( function_exists( 'generate_is_using_flexbox' ) && generate_is_using_flexbox() ) {
$hooks['navigation']['hooks'][] = 'generate_menu_bar_items';
}
if ( defined( 'GENERATE_VERSION' ) && version_compare( GENERATE_VERSION, '3.0.0-alpha.1', '>' ) ) {
$hooks['navigation']['hooks'][] = 'generate_before_navigation';
$hooks['navigation']['hooks'][] = 'generate_after_navigation';
$hooks['navigation']['hooks'][] = 'generate_after_mobile_menu_button';
$hooks['navigation']['hooks'][] = 'generate_inside_mobile_menu_control_wrapper';
$hooks['content']['hooks'][] = 'generate_after_loop';
$hooks['content']['hooks'][] = 'generate_before_do_template_part';
$hooks['content']['hooks'][] = 'generate_after_do_template_part';
}
return apply_filters( 'generate_hooks_list', $hooks );
}
/**
* Expand the wp_kses_post sanitization function to allow iframe HTML tags
*
* @param array $tags The allowed tags, attributes, and/or attribute values.
* @param string $context Context to judge allowed tags by. Allowed values are 'post'.
* @return array
*/
public static function expand_allowed_html( $tags, $context ) {
if ( ! isset( $tags['iframe'] ) ) {
$tags['iframe'] = [
'src' => true,
'height' => true,
'width' => true,
'frameborder' => true,
'allowfullscreen' => true,
'title' => true,
];
}
$tags = apply_filters( 'generate_dynamic_content_allowed_html', $tags, $context );
return $tags;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,223 @@
<?php
/**
* This file handles the Hook Element.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
/**
* Execute our hook elements.
*
* @since 1.7
*/
class GeneratePress_Hook {
/**
* Set our content variable.
*
* @since 1.7
* @var string The content.
*/
protected $content = '';
/**
* Set our hook/action variable.
*
* @since 1.7
* @var string The hook.
*/
protected $hook = '';
/**
* Set our custom hook variable.
*
* @since 1.7
* @var string The custom hook.
*/
protected $custom_hook = '';
/**
* Set our disable site header variable.
*
* @since 1.7
* @var boolean Whether we're disabling the header.
*/
protected $disable_site_header = false;
/**
* Set our disable footer variable.
*
* @since 1.7
* @var boolean Whether we're disabling the footer.
*/
protected $disable_site_footer = false;
/**
* Set our priority variable.
*
* @since 1.7
* @var int The hook priority.
*/
protected $priority = 10;
/**
* Set our execute PHP variable.
*
* @since 1.7
* @var boolean Whether we're executing PHP.
*/
protected $php = false;
/**
* Set our execute shortcodes variable.
*
* @since 1.7
* @var boolean Whether we're executing shortcodes.
*/
protected $shortcodes = false;
/**
* Set our location variable.
*
* @since 1.7
* @var array The conditions.
*/
protected $conditional = array();
/**
* Set our exclusions variable.
*
* @since 1.7
* @var array The exclusions.
*/
protected $exclude = array();
/**
* Set our user condition variable.
*
* @since 1.7
* @var array The user roles.
*/
protected $users = array();
/**
* Set up our class and give variables their values.
*
* @param int $post_id The post ID of the element we're executing.
*
* @since 1.7
*/
public function __construct( $post_id ) {
$this->hook = get_post_meta( $post_id, '_generate_hook', true );
if ( empty( $this->hook ) ) {
return;
}
$this->content = get_post_meta( $post_id, '_generate_element_content', true );
if ( get_post_meta( $post_id, '_generate_custom_hook', true ) ) {
$this->custom_hook = get_post_meta( $post_id, '_generate_custom_hook', true );
}
if ( get_post_meta( $post_id, '_generate_hook_disable_site_header', true ) ) {
$this->disable_site_header = get_post_meta( $post_id, '_generate_hook_disable_site_header', true );
}
if ( get_post_meta( $post_id, '_generate_hook_disable_site_footer', true ) ) {
$this->disable_site_footer = get_post_meta( $post_id, '_generate_hook_disable_site_footer', true );
}
if ( get_post_meta( $post_id, '_generate_hook_priority', true ) || '0' === get_post_meta( $post_id, '_generate_hook_priority', true ) ) {
$this->priority = get_post_meta( $post_id, '_generate_hook_priority', true );
}
if ( get_post_meta( $post_id, '_generate_hook_execute_php', true ) ) {
$this->php = get_post_meta( $post_id, '_generate_hook_execute_php', true );
}
if ( get_post_meta( $post_id, '_generate_hook_execute_shortcodes', true ) ) {
$this->shortcodes = get_post_meta( $post_id, '_generate_hook_execute_shortcodes', true );
}
if ( get_post_meta( $post_id, '_generate_element_display_conditions', true ) ) {
$this->conditional = get_post_meta( $post_id, '_generate_element_display_conditions', true );
}
if ( get_post_meta( $post_id, '_generate_element_exclude_conditions', true ) ) {
$this->exclude = get_post_meta( $post_id, '_generate_element_exclude_conditions', true );
}
if ( get_post_meta( $post_id, '_generate_element_user_conditions', true ) ) {
$this->users = get_post_meta( $post_id, '_generate_element_user_conditions', true );
}
if ( 'custom' === $this->hook && $this->custom_hook ) {
$this->hook = $this->custom_hook;
}
$display = apply_filters( 'generate_hook_element_display', GeneratePress_Conditions::show_data( $this->conditional, $this->exclude, $this->users ), $post_id );
/**
* Simplify filter name.
*
* @since 2.0.0
*/
$display = apply_filters(
'generate_element_display',
$display,
$post_id
);
if ( $display ) {
global $generate_elements;
$generate_elements[ $post_id ] = array(
'is_block_element' => false,
'type' => 'hook',
'id' => $post_id,
);
if ( 'generate_header' === $this->hook && $this->disable_site_header ) {
remove_action( 'generate_header', 'generate_construct_header' );
}
if ( 'generate_footer' === $this->hook && $this->disable_site_footer ) {
remove_action( 'generate_footer', 'generate_construct_footer' );
add_filter( 'generate_footer_widgets', '__return_null' );
}
add_action( esc_attr( $this->hook ), array( $this, 'execute_hook' ), absint( $this->priority ) );
}
}
/**
* Output our hook content.
*
* @since 1.7
*/
public function execute_hook() {
$content = $this->content;
if ( $this->shortcodes ) {
$content = do_shortcode( $content );
}
if ( $this->php && GeneratePress_Elements_Helper::should_execute_php() ) {
ob_start();
eval( '?>' . $content . '<?php ' ); // phpcs:ignore -- Using eval() to execute PHP.
echo ob_get_clean(); // phpcs:ignore -- Escaping not necessary.
} else {
echo $content; // phpcs:ignore -- Escaping not necessary.
}
}
}

View File

@ -0,0 +1,550 @@
<?php
/**
* This file handles our Layout Element functionality.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
/**
* The Layout Element.
*/
class GeneratePress_Site_Layout {
/**
* Set our location variable.
*
* @since 1.7
* @var array
*/
protected $conditional = array();
/**
* Set our exclusion variable.
*
* @since 1.7
* @var array
*/
protected $exclude = array();
/**
* Set our user condition variable.
*
* @since 1.7
* @var array
*/
protected $users = array();
/**
* Set up our other options.
*
* @since 1.7
* @deprecated 1.7.3
* @var array
*/
protected static $options = array();
/**
* Sidebar layout.
*
* @since 1.7.3
* @var string
*/
protected $sidebar_layout = null;
/**
* Footer widgets layout.
*
* @since 1.7.3
* @var int
*/
protected $footer_widgets = null;
/**
* Whether to disable site header.
*
* @since 1.7.3
* @var boolean
*/
protected $disable_site_header = null;
/**
* Whether to disable mobile header.
*
* @since 1.11.0
* @var boolean
*/
protected $disable_mobile_header = null;
/**
* Whether to disable top bar.
*
* @since 1.7.3
* @var boolean
*/
protected $disable_top_bar = null;
/**
* Whether to disable primary nav.
*
* @since 1.7.3
* @var boolean
*/
protected $disable_primary_navigation = null;
/**
* Whether to disable secondary nav.
*
* @since 1.7.3
* @var boolean
*/
protected $disable_secondary_navigation = null;
/**
* Whether to disable featured image.
*
* @since 1.7.3
* @var boolean
*/
protected $disable_featured_image = null;
/**
* Whether to disable content title.
*
* @since 1.7.3
* @var boolean
*/
protected $disable_content_title = null;
/**
* Whether to disable footer.
*
* @since 1.7.3
* @var boolean
*/
protected $disable_footer = null;
/**
* Container type (full width etc..).
*
* @since 1.7.3
* @var string
*/
protected $content_area = null;
/**
* Content width.
*
* @since 1.7.3
* @var int
*/
protected $content_width = null;
/**
* Set our post ID.
*
* @since 1.7
* @var int
*/
protected static $post_id = '';
/**
* Count how many instances are set.
*
* @since 1.7
* @deprecated 1.7.3
* @var int
*/
public static $instances = 0;
/**
* Set our class and give our variables values.
*
* @since 1.7
*
* @param int $post_id The post ID of our element.
*/
public function __construct( $post_id ) {
self::$post_id = $post_id;
if ( get_post_meta( $post_id, '_generate_element_display_conditions', true ) ) {
$this->conditional = get_post_meta( $post_id, '_generate_element_display_conditions', true );
}
if ( get_post_meta( $post_id, '_generate_element_exclude_conditions', true ) ) {
$this->exclude = get_post_meta( $post_id, '_generate_element_exclude_conditions', true );
}
if ( get_post_meta( $post_id, '_generate_element_user_conditions', true ) ) {
$this->users = get_post_meta( $post_id, '_generate_element_user_conditions', true );
}
if ( get_post_meta( $post_id, '_generate_sidebar_layout', true ) ) {
$this->sidebar_layout = get_post_meta( $post_id, '_generate_sidebar_layout', true );
}
if ( get_post_meta( $post_id, '_generate_footer_widgets', true ) ) {
$this->footer_widgets = get_post_meta( $post_id, '_generate_footer_widgets', true );
}
if ( get_post_meta( $post_id, '_generate_disable_site_header', true ) ) {
$this->disable_site_header = get_post_meta( $post_id, '_generate_disable_site_header', true );
}
if ( get_post_meta( $post_id, '_generate_disable_mobile_header', true ) ) {
$this->disable_mobile_header = get_post_meta( $post_id, '_generate_disable_mobile_header', true );
}
if ( get_post_meta( $post_id, '_generate_disable_top_bar', true ) ) {
$this->disable_top_bar = get_post_meta( $post_id, '_generate_disable_top_bar', true );
}
if ( get_post_meta( $post_id, '_generate_disable_primary_navigation', true ) ) {
$this->disable_primary_navigation = get_post_meta( $post_id, '_generate_disable_primary_navigation', true );
}
if ( get_post_meta( $post_id, '_generate_disable_secondary_navigation', true ) ) {
$this->disable_secondary_navigation = get_post_meta( $post_id, '_generate_disable_secondary_navigation', true );
}
if ( get_post_meta( $post_id, '_generate_disable_featured_image', true ) ) {
$this->disable_featured_image = get_post_meta( $post_id, '_generate_disable_featured_image', true );
}
if ( get_post_meta( $post_id, '_generate_disable_content_title', true ) ) {
$this->disable_content_title = get_post_meta( $post_id, '_generate_disable_content_title', true );
}
if ( get_post_meta( $post_id, '_generate_disable_footer', true ) ) {
$this->disable_footer = get_post_meta( $post_id, '_generate_disable_footer', true );
}
if ( get_post_meta( $post_id, '_generate_content_area', true ) ) {
$this->content_area = get_post_meta( $post_id, '_generate_content_area', true );
}
if ( get_post_meta( $post_id, '_generate_content_width', true ) ) {
$this->content_width = get_post_meta( $post_id, '_generate_content_width', true );
}
$display = apply_filters( 'generate_layout_element_display', GeneratePress_Conditions::show_data( $this->conditional, $this->exclude, $this->users ), $post_id );
/**
* Simplify filter name.
*
* @since 2.0.0
*/
$display = apply_filters(
'generate_element_display',
$display,
$post_id
);
if ( $display ) {
global $generate_elements;
$generate_elements[ $post_id ] = array(
'is_block_element' => false,
'type' => 'layout',
'id' => $post_id,
);
add_action( 'wp', array( $this, 'after_setup' ), 100 );
add_action( 'wp_enqueue_scripts', array( $this, 'build_css' ), 50 );
if ( is_admin() ) {
add_action( 'current_screen', array( $this, 'after_setup' ), 100 );
add_action( 'enqueue_block_editor_assets', array( $this, 'build_css' ), 50 );
}
}
}
/**
* Return our available options.
*
* @since 1.7
* @deprecated 1.7.3
*
* @return array
*/
public static function get_options() {
return false;
}
/**
* Initiate our set layout changes.
*
* @since 1.7
*/
public function after_setup() {
if ( $this->sidebar_layout && ! self::post_meta_exists( '_generate-sidebar-layout-meta' ) ) {
add_filter( 'generate_sidebar_layout', array( $this, 'filter_options' ) );
}
if ( $this->footer_widgets && ! self::post_meta_exists( '_generate-footer-widget-meta' ) ) {
add_filter( 'generate_footer_widgets', array( $this, 'filter_options' ) );
}
if ( $this->disable_site_header ) {
remove_action( 'generate_header', 'generate_construct_header' );
}
if ( $this->disable_mobile_header ) {
remove_action( 'generate_after_header', 'generate_menu_plus_mobile_header', 5 );
}
if ( $this->disable_top_bar ) {
remove_action( 'generate_before_header', 'generate_top_bar', 5 );
remove_action( 'generate_inside_secondary_navigation', 'generate_secondary_nav_top_bar_widget', 5 );
}
if ( $this->disable_primary_navigation ) {
add_filter( 'generate_navigation_location', '__return_false', 20 );
add_filter( 'generate_disable_mobile_header_menu', '__return_true' );
}
if ( $this->disable_secondary_navigation ) {
add_filter( 'has_nav_menu', array( $this, 'disable_secondary_navigation' ), 10, 2 );
}
if ( $this->disable_featured_image ) {
remove_action( 'generate_after_entry_header', 'generate_blog_single_featured_image' );
remove_action( 'generate_before_content', 'generate_blog_single_featured_image' );
remove_action( 'generate_after_header', 'generate_blog_single_featured_image' );
remove_action( 'generate_before_content', 'generate_featured_page_header_inside_single' );
remove_action( 'generate_after_header', 'generate_featured_page_header' );
add_filter( 'body_class', array( $this, 'remove_featured_image_class' ), 20 );
}
if ( $this->disable_content_title ) {
add_filter( 'generate_show_title', '__return_false' );
}
if ( $this->disable_footer ) {
remove_action( 'generate_footer', 'generate_construct_footer' );
add_filter( 'generate_footer_widgets', '__return_null' );
}
if ( $this->content_area ) {
add_filter( 'body_class', array( $this, 'body_classes' ) );
}
if ( is_admin() ) {
if ( $this->sidebar_layout && ! self::admin_post_meta_exists( '_generate-sidebar-layout-meta' ) ) {
add_filter( 'generate_block_editor_sidebar_layout', array( $this, 'filter_options' ) );
}
if ( $this->disable_content_title ) {
add_filter( 'generate_block_editor_show_content_title', '__return_false' );
}
if ( $this->content_area ) {
add_filter( 'generate_block_editor_content_area_type', array( $this, 'set_editor_content_area' ) );
}
if ( $this->content_width ) {
add_filter( 'generate_block_editor_container_width', array( $this, 'set_editor_content_width' ) );
}
}
}
/**
* Build dynamic CSS
*/
public function build_css() {
if ( $this->content_width ) {
wp_add_inline_style( 'generate-style', '#content {max-width: ' . absint( $this->content_width ) . 'px;margin-left: auto;margin-right: auto;}' );
}
if ( is_admin() ) {
$admin_css = '';
if ( version_compare( generate_premium_get_theme_version(), '3.2.0-alpha.1', '<' ) ) {
if ( 'full-width' === $this->content_area ) {
$admin_css .= 'html .editor-styles-wrapper .wp-block{max-width: 100%}';
}
if ( $this->content_width ) {
$admin_css .= 'html .editor-styles-wrapper .wp-block{max-width: ' . absint( $this->content_width ) . 'px;}';
}
}
if ( $this->content_area ) {
$admin_css .= '#generate-layout-page-builder-container {opacity: 0.5;pointer-events: none;}';
}
if ( $admin_css ) {
wp_add_inline_style( 'wp-edit-blocks', $admin_css );
}
}
}
/**
* Check to see if our individual post metabox has a value.
*
* @since 1.7
*
* @param string $meta The meta key we're checking for.
* @return bool
*/
public static function post_meta_exists( $meta ) {
if ( ! is_singular() ) {
return false;
}
$value = get_post_meta( get_the_ID(), $meta, true );
if ( '_generate-footer-widget-meta' === $meta && '0' === $value ) {
$value = true;
}
if ( $value ) {
return true;
}
return false;
}
/**
* Check to see if our individual post metabox has a value in the admin area.
*
* @since 1.11.0
*
* @param string $meta The meta key we're checking for.
* @return bool
*/
public static function admin_post_meta_exists( $meta ) {
if ( is_admin() ) {
$current_screen = get_current_screen();
if ( isset( $current_screen->is_block_editor ) && $current_screen->is_block_editor ) {
$post_id = false;
if ( isset( $_GET['post'] ) ) { // phpcs:ignore -- No data processing happening here.
$post_id = absint( $_GET['post'] ); // phpcs:ignore -- No data processing happening here.
}
if ( $post_id ) {
$value = get_post_meta( $post_id, $meta, true );
if ( '_generate-footer-widget-meta' === $meta && '0' === $value ) {
$value = true;
}
if ( $value ) {
return true;
}
} else {
return false;
}
}
}
}
/**
* Filter our filterable options.
*
* @since 1.7
*/
public function filter_options() {
$filter = current_filter();
if ( 'generate_sidebar_layout' === $filter || 'generate_block_editor_sidebar_layout' === $filter ) {
return $this->sidebar_layout;
}
if ( 'generate_footer_widgets' === $filter ) {
if ( 'no-widgets' === $this->footer_widgets ) {
return 0;
} else {
return $this->footer_widgets;
}
}
}
/**
* Set the content area type in the editor.
*
* @param string $area Content area type.
*/
public function set_editor_content_area( $area ) {
if ( 'full-width' === $this->content_area ) {
$area = 'true';
}
if ( 'contained-container' === $this->content_area ) {
$area = 'contained';
}
return $area;
}
/**
* Set the content width in the editor.
*
* @param string $width Content width with unit.
*/
public function set_editor_content_width( $width ) {
if ( $this->content_width ) {
$width = absint( $this->content_width ) . 'px';
}
return $width;
}
/**
* Disable the Secondary Navigation if set.
*
* @since 1.7
*
* @param bool $has_nav_menu The existing value.
* @param string $location The location we're checking.
* @return bool
*/
public static function disable_secondary_navigation( $has_nav_menu, $location ) {
if ( 'secondary' === $location ) {
return false;
}
return $has_nav_menu;
}
/**
* Sets any necessary body classes.
*
* @since 1.7
*
* @param array $classes Our existing body classes.
* @return array Our new set of classes.
*/
public function body_classes( $classes ) {
if ( 'full-width' === $this->content_area ) {
$classes[] = 'full-width-content';
}
if ( 'contained' === $this->content_area ) {
$classes[] = 'contained-content';
}
return $classes;
}
/**
* Remove the featured image class if it's disabled.
*
* @since 2.1.0
* @param array $classes The body classes.
*/
public function remove_featured_image_class( $classes ) {
if ( is_singular() ) {
$classes = generate_premium_remove_featured_image_class( $classes, $this->disable_featured_image );
}
return $classes;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,508 @@
<?php
/**
* This file sets up our Elements post type.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
/**
* Start our Elements post type class.
*/
class GeneratePress_Elements_Post_Type {
/**
* Instance.
*
* @since 1.7
*
* @var instance
*/
private static $instance;
/**
* Initiator
*
* @since 1.7
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Build it.
*
* @since 1.7
*/
public function __construct() {
add_action( 'init', array( $this, 'post_type' ) );
if ( is_admin() ) {
add_action( 'admin_menu', array( $this, 'menu_item' ), 100 );
add_action( 'admin_head', array( $this, 'fix_current_item' ) );
add_filter( 'manage_gp_elements_posts_columns', array( $this, 'register_columns' ) );
add_action( 'manage_gp_elements_posts_custom_column', array( $this, 'add_columns' ), 10, 2 );
add_action( 'restrict_manage_posts', array( $this, 'build_element_type_filter' ) );
add_filter( 'pre_get_posts', array( $this, 'filter_element_types' ) );
add_filter( 'register_post_type_args', array( $this, 'set_standard_element' ), 10, 2 );
add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
add_action( 'admin_footer', array( $this, 'element_modal' ) );
self::setup_metabox();
}
}
/**
* Load the metabox.
*
* @since 1.7
*/
public function setup_metabox() {
require plugin_dir_path( __FILE__ ) . 'class-metabox.php';
}
/**
* Set up our custom post type.
*
* @since 1.7
*/
public function post_type() {
$labels = array(
'name' => _x( 'Elements', 'Post Type General Name', 'gp-premium' ),
'singular_name' => _x( 'Element', 'Post Type Singular Name', 'gp-premium' ),
'menu_name' => __( 'Elements', 'gp-premium' ),
'all_items' => __( 'All Elements', 'gp-premium' ),
'add_new' => __( 'Add New Element', 'gp-premium' ),
'add_new_item' => __( 'Add New Element', 'gp-premium' ),
'new_item' => __( 'New Element', 'gp-premium' ),
'edit_item' => __( 'Edit Element', 'gp-premium' ),
'update_item' => __( 'Update Element', 'gp-premium' ),
'search_items' => __( 'Search Element', 'gp-premium' ),
'featured_image' => __( 'Background Image', 'gp-premium' ),
'set_featured_image' => __( 'Set background image', 'gp-premium' ),
'remove_featured_image' => __( 'Remove background image', 'gp-premium' ),
'item_published' => __( 'Element published.', 'gp-premium' ),
'item_updated' => __( 'Element updated.', 'gp-premium' ),
'item_scheduled' => __( 'Element scheduled.', 'gp-premium' ),
'item_reverted_to_draft' => __( 'Element reverted to draft.', 'gp-premium' ),
);
$args = array(
'labels' => $labels,
'supports' => array( 'title', 'editor', 'thumbnail', 'custom-fields', 'page-attributes', 'revisions' ),
'hierarchical' => true,
'public' => false,
'show_ui' => true,
'show_in_menu' => false,
'can_export' => true,
'has_archive' => false,
'exclude_from_search' => true,
'show_in_rest' => true,
);
register_post_type( 'gp_elements', $args );
}
/**
* Disable editor and show_in_rest support for non-Block Elements.
*
* @since 1.11.0
* @param array $args The existing args.
* @param string $post_type The current post type.
*/
public function set_standard_element( $args, $post_type ) {
if ( 'gp_elements' === $post_type ) {
$post_id = false;
$type = false;
if ( isset( $_GET['post'] ) ) { // phpcs:ignore -- No processing happening.
$post_id = absint( $_GET['post'] ); // phpcs:ignore -- No processing happening.
}
if ( $post_id ) {
$type = get_post_meta( $post_id, '_generate_element_type', true );
} elseif ( isset( $_GET['element_type'] ) ) { // phpcs:ignore -- No processing happening.
$type = esc_html( $_GET['element_type'] ); // phpcs:ignore -- No processing happening.
}
if ( ! $type ) {
return $args;
}
if ( 'block' !== $type ) {
$args['supports'] = array( 'title', 'thumbnail' );
$args['show_in_rest'] = false;
$args['hierarchical'] = false;
}
if ( 'block' === $type ) {
$args['supports'] = array( 'title', 'editor', 'custom-fields', 'page-attributes', 'revisions' );
}
if ( 'layout' === $type ) {
$args['labels']['add_new_item'] = __( 'Add New Layout', 'gp-premium' );
$args['labels']['edit_item'] = __( 'Edit Layout', 'gp-premium' );
}
if ( 'hook' === $type ) {
$args['labels']['add_new_item'] = __( 'Add New Hook', 'gp-premium' );
$args['labels']['edit_item'] = __( 'Edit Hook', 'gp-premium' );
}
if ( 'header' === $type ) {
$args['labels']['add_new_item'] = __( 'Add New Header', 'gp-premium' );
$args['labels']['edit_item'] = __( 'Edit Header', 'gp-premium' );
}
}
return $args;
}
/**
* Register custom post type columns.
*
* @since 1.7
*
* @param array $columns Existing CPT columns.
* @return array All our CPT columns.
*/
public function register_columns( $columns ) {
$columns['element_type'] = esc_html__( 'Type', 'gp-premium' );
$columns['location'] = esc_html__( 'Location', 'gp-premium' );
$columns['exclusions'] = esc_html__( 'Exclusions', 'gp-premium' );
$columns['users'] = esc_html__( 'Users', 'gp-premium' );
$new_columns = array();
// Need to do some funky stuff to display these columns before the date.
foreach ( $columns as $key => $value ) {
if ( 'date' === $key ) {
$new_columns['element_type'] = esc_html__( 'Type', 'gp-premium' );
$new_columns['location'] = esc_html__( 'Location', 'gp-premium' );
$new_columns['exclusions'] = esc_html__( 'Exclusions', 'gp-premium' );
$new_columns['users'] = esc_html__( 'Users', 'gp-premium' );
}
$new_columns[ $key ] = $value;
}
return $new_columns;
}
/**
* Add a filter select input to the admin list.
*
* @since 1.7
*/
public function build_element_type_filter() {
$screen = function_exists( 'get_current_screen' ) ? get_current_screen() : false;
if ( ! $screen ) {
return;
}
if ( ! isset( $screen->post_type ) || 'gp_elements' !== $screen->post_type ) {
return;
}
$values = array(
'block' => esc_html__( 'Blocks', 'gp-premium' ),
'header' => esc_html__( 'Headers', 'gp-premium' ),
'hook' => esc_html__( 'Hooks', 'gp-premium' ),
'layout' => esc_html__( 'Layouts', 'gp-premium' ),
);
$current_element_type = isset( $_GET['gp_element_type_filter'] ) ? esc_html( $_GET['gp_element_type_filter'] ) : ''; // phpcs:ignore -- No processing happening.
$current_block_type = isset( $_GET['gp_elements_block_type_filter'] ) ? esc_html( $_GET['gp_elements_block_type_filter'] ) : ''; // phpcs:ignore -- No processing happening.
?>
<select name="gp_element_type_filter">
<option value=""><?php esc_html_e( 'All types', 'gp-premium' ); ?></option>
<?php
foreach ( $values as $value => $label ) {
printf(
'<option value="%1$s" %2$s>%3$s</option>',
esc_html( $value ),
$value === $current_element_type ? 'selected="selected"' : '',
esc_html( $label )
);
}
?>
</select>
<?php
if ( 'block' === $current_element_type ) {
$block_types = array(
'hook',
'site-header',
'page-hero',
'content-template',
'loop-template',
'post-meta-template',
'post-navigation-template',
'archive-navigation-template',
'right-sidebar',
'left-sidebar',
'site-footer',
);
?>
<select name="gp_elements_block_type_filter">
<option value=""><?php esc_html_e( 'All block types', 'gp-premium' ); ?></option>
<?php
foreach ( $block_types as $value ) {
printf(
'<option value="%1$s" %2$s>%3$s</option>',
esc_html( $value ),
$value === $current_block_type ? 'selected="selected"' : '',
esc_html( GeneratePress_Elements_Helper::get_element_type_label( $value ) )
);
}
?>
</select>
<?php
}
}
/**
* Filter the shown elements in the admin list if our filter is set.
*
* @since 1.7
*
* @param object $query Existing query.
*/
public function filter_element_types( $query ) {
// phpcs:ignore -- No processing happening.
if ( ! isset( $_GET['post_type'] ) || 'gp_elements' != $_GET['post_type'] ) {
return;
}
global $pagenow;
$type = isset( $_GET['gp_element_type_filter'] ) ? $_GET['gp_element_type_filter'] : ''; // phpcs:ignore -- No processing happening.
$meta_query = array();
if ( 'edit.php' === $pagenow && $query->is_main_query() && '' !== $type ) {
$meta_query[] = array(
'key' => '_generate_element_type',
'value' => esc_attr( $type ),
'compare' => '=',
);
$block_type = isset( $_GET['gp_elements_block_type_filter'] ) ? $_GET['gp_elements_block_type_filter'] : ''; // phpcs:ignore -- No processing happening.
if ( 'block' === $type && '' !== $block_type ) {
$meta_query['relation'] = 'AND';
$meta_query[] = array(
'key' => '_generate_block_type',
'value' => esc_attr( $block_type ),
'compare' => '=',
);
}
$query->set( 'meta_query', $meta_query );
}
}
/**
* Add content to our custom post type columns.
*
* @since 1.7
*
* @param string $column The name of the column.
* @param int $post_id The ID of the post row.
*/
public function add_columns( $column, $post_id ) {
switch ( $column ) {
case 'element_type':
$type = get_post_meta( $post_id, '_generate_element_type', true );
$hook_location = get_post_meta( $post_id, '_generate_hook', true );
if ( 'block' === $type ) {
echo esc_html__( 'Block', 'gp-premium' );
$block_type = get_post_meta( $post_id, '_generate_block_type', true );
if ( $block_type ) {
echo ' - ' . esc_html( GeneratePress_Elements_Helper::get_element_type_label( $block_type ) );
if ( 'hook' === $block_type && $hook_location ) {
echo '<br />';
if ( 'custom' === $hook_location ) {
$custom_hook = get_post_meta( $post_id, '_generate_custom_hook', true );
echo '<span class="hook-location">' . esc_html( $custom_hook ) . '</span>';
} else {
echo '<span class="hook-location">' . esc_html( $hook_location ) . '</span>';
}
}
}
}
if ( 'header' === $type ) {
echo esc_html__( 'Header', 'gp-premium' );
}
if ( 'hook' === $type ) {
echo esc_html__( 'Hook', 'gp-premium' );
if ( $hook_location ) {
echo '<br />';
if ( 'custom' === $hook_location ) {
$custom_hook = get_post_meta( $post_id, '_generate_custom_hook', true );
echo '<span class="hook-location">' . esc_html( $custom_hook ) . '</span>';
} else {
echo '<span class="hook-location">' . esc_html( $hook_location ) . '</span>';
}
}
}
if ( 'layout' === $type ) {
echo esc_html__( 'Layout', 'gp-premium' );
}
break;
case 'location':
$location = get_post_meta( $post_id, '_generate_element_display_conditions', true );
$parent_block = wp_get_post_parent_id( $post_id );
if ( $location ) {
foreach ( (array) $location as $data ) {
echo esc_html( GeneratePress_Conditions::get_saved_label( $data ) );
echo '<br />';
}
} elseif ( ! empty( $parent_block ) ) {
echo esc_html__( 'Inherit from parent', 'gp-premium' );
} else {
echo esc_html__( 'Not set', 'gp-premium' );
}
break;
case 'exclusions':
$location = get_post_meta( $post_id, '_generate_element_exclude_conditions', true );
if ( $location ) {
foreach ( (array) $location as $data ) {
echo esc_html( GeneratePress_Conditions::get_saved_label( $data ) );
echo '<br />';
}
}
break;
case 'users':
$users = get_post_meta( $post_id, '_generate_element_user_conditions', true );
if ( $users ) {
foreach ( (array) $users as $data ) {
if ( strpos( $data, ':' ) !== false ) {
$data = substr( $data, strpos( $data, ':' ) + 1 );
}
$return = ucwords( str_replace( '_', ' ', $data ) );
echo esc_html( $return ) . '<br />';
}
}
break;
}
}
/**
* Create our admin menu item.
*
* @since 1.7
*/
public function menu_item() {
add_submenu_page(
'themes.php',
esc_html__( 'Elements', 'gp-premium' ),
esc_html__( 'Elements', 'gp-premium' ),
apply_filters( 'generate_elements_admin_menu_capability', 'manage_options' ),
'edit.php?post_type=gp_elements'
);
}
/**
* Make sure our admin menu item is highlighted.
*
* @since 1.7
*/
public function fix_current_item() {
global $parent_file, $submenu_file, $post_type;
if ( 'gp_elements' === $post_type ) {
$parent_file = 'themes.php'; // phpcs:ignore
$submenu_file = 'edit.php?post_type=gp_elements'; // phpcs:ignore
}
}
/**
* Add scripts to the edit/post area of Elements.
*
* @since 1.11.0
* @param string $hook The current hook for the page.
*/
public function admin_scripts( $hook ) {
if ( ! function_exists( 'get_current_screen' ) ) {
return;
}
$current_screen = get_current_screen();
if ( 'edit.php' === $hook || 'post.php' === $hook ) {
if ( 'gp_elements' === $current_screen->post_type ) {
wp_enqueue_script( 'generate-elements', plugin_dir_url( __FILE__ ) . 'assets/admin/elements.js', array( 'jquery' ), GP_PREMIUM_VERSION, true );
wp_enqueue_style( 'generate-elements', plugin_dir_url( __FILE__ ) . 'assets/admin/elements.css', array(), GP_PREMIUM_VERSION );
}
}
}
/**
* Build the Add New Element modal.
*
* @since 1.11.0
*/
public function element_modal() {
if ( ! function_exists( 'get_current_screen' ) ) {
return;
}
$current_screen = get_current_screen();
if ( 'edit-gp_elements' === $current_screen->id || 'gp_elements' === $current_screen->id ) {
?>
<form method="get" class="choose-element-type-parent" action="<?php echo esc_url( admin_url( 'post-new.php' ) ); ?>" style="display: none;">
<input type="hidden" name="post_type" value="gp_elements" />
<div class="choose-element-type">
<h2><?php _e( 'Choose Element Type', 'gp-premium' ); ?></h2>
<div class="select-type-container">
<select class="select-type" name="element_type">
<option value=""><?php esc_attr_e( 'Choose...', 'gp-premium' ); ?></option>
<option value="block"><?php esc_attr_e( 'Block', 'gp-premium' ); ?></option>
<option value="hook"><?php esc_attr_e( 'Hook', 'gp-premium' ); ?></option>
<option value="layout"><?php esc_attr_e( 'Layout', 'gp-premium' ); ?></option>
<option value="header"><?php esc_attr_e( 'Header', 'gp-premium' ); ?></option>
</select>
<button class="button button-primary"><?php _e( 'Create', 'gp-premium' ); ?></button>
</div>
<button class="close-choose-element-type" aria-label="<?php esc_attr_e( 'Close', 'gp-premium' ); ?>">
<svg aria-hidden="true" data-prefix="fas" data-icon="times" class="svg-inline--fa fa-times fa-w-11" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 352 512">
<path fill="currentColor" d="M242.72 256l100.07-100.07c12.28-12.28 12.28-32.19 0-44.48l-22.24-22.24c-12.28-12.28-32.19-12.28-44.48 0L176 189.28 75.93 89.21c-12.28-12.28-32.19-12.28-44.48 0L9.21 111.45c-12.28 12.28-12.28 32.19 0 44.48L109.28 256 9.21 356.07c-12.28 12.28-12.28 32.19 0 44.48l22.24 22.24c12.28 12.28 32.2 12.28 44.48 0L176 322.72l100.07 100.07c12.28 12.28 32.2 12.28 44.48 0l22.24-22.24c12.28-12.28 12.28-32.19 0-44.48L242.72 256z"/>
</svg>
</button>
</div>
</form>
<?php
}
}
}
GeneratePress_Elements_Post_Type::get_instance();

View File

@ -0,0 +1,289 @@
<?php
/**
* This file sets up our Elements module.
*
* @since 1.7.0
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
$elements_dir = plugin_dir_path( __FILE__ );
require $elements_dir . 'class-conditions.php';
require $elements_dir . 'class-elements-helper.php';
require $elements_dir . 'class-hooks.php';
require $elements_dir . 'class-hero.php';
require $elements_dir . 'class-layout.php';
require $elements_dir . 'class-block.php';
require $elements_dir . 'class-block-elements.php';
require $elements_dir . 'class-post-type.php';
add_action( 'wp', 'generate_premium_do_elements' );
add_action( 'current_screen', 'generate_premium_do_elements' );
/**
* Execute our Elements.
*
* @since 1.7
*/
function generate_premium_do_elements() {
$args = array(
'post_type' => 'gp_elements',
'no_found_rows' => true,
'post_status' => 'publish',
'numberposts' => 500, // phpcs:ignore
'fields' => 'ids',
'suppress_filters' => false,
);
$custom_args = apply_filters(
'generate_elements_custom_args',
array(
'order' => 'ASC',
)
);
$args = array_merge( $args, $custom_args );
// Prevent Polylang from altering the query.
if ( function_exists( 'pll_get_post_language' ) ) {
$args['lang'] = '';
}
$posts = get_posts( $args );
foreach ( $posts as $post_id ) {
$post_id = apply_filters( 'generate_element_post_id', $post_id );
$type = get_post_meta( $post_id, '_generate_element_type', true );
if ( 'hook' === $type ) {
new GeneratePress_Hook( $post_id );
}
if ( 'header' === $type && ! GeneratePress_Hero::$instances ) {
new GeneratePress_Hero( $post_id );
}
if ( 'layout' === $type ) {
new GeneratePress_Site_Layout( $post_id );
}
if ( 'block' === $type ) {
new GeneratePress_Block_Element( $post_id );
}
}
}
add_filter( 'generate_dashboard_tabs', 'generate_elements_dashboard_tab' );
/**
* Add the Sites tab to our Dashboard tabs.
*
* @since 1.6
*
* @param array $tabs Existing tabs.
* @return array New tabs.
*/
function generate_elements_dashboard_tab( $tabs ) {
$screen = get_current_screen();
$tabs['Elements'] = array(
'name' => __( 'Elements', 'gp-premium' ),
'url' => admin_url( 'edit.php?post_type=gp_elements' ),
'class' => 'edit-gp_elements' === $screen->id ? 'active' : '',
);
return $tabs;
}
add_filter( 'generate_dashboard_screens', 'generate_elements_dashboard_screen' );
/**
* Add the Sites tab to our Dashboard screens.
*
* @since 2.1.0
*
* @param array $screens Existing screens.
* @return array New screens.
*/
function generate_elements_dashboard_screen( $screens ) {
$screens[] = 'edit-gp_elements';
return $screens;
}
add_filter( 'generate_element_post_id', 'generate_elements_ignore_languages' );
/**
* Disable Polylang elements if their language doesn't match.
* We disable their automatic quering so Elements with no language display by default.
*
* @since 1.8
*
* @param int $post_id The current post ID.
* @return bool|int
*/
function generate_elements_ignore_languages( $post_id ) {
if ( function_exists( 'pll_get_post_language' ) && function_exists( 'pll_current_language' ) ) {
$language = pll_get_post_language( $post_id, 'locale' );
$disable = get_post_meta( $post_id, '_generate_element_ignore_languages', true );
if ( $disable ) {
return $post_id;
}
if ( $language && $language !== pll_current_language( 'locale' ) ) { // phpcs:ignore -- Using Yoda check I am.
return false;
}
}
return $post_id;
}
add_action( 'save_post_wp_block', 'generate_elements_wp_block_update', 10, 2 );
/**
* Regenerate the GenerateBlocks CSS file when a re-usable block is saved.
*
* @since 1.11.0
* @param int $post_id The post ID.
* @param object $post The post object.
*/
function generate_elements_wp_block_update( $post_id, $post ) {
$is_autosave = wp_is_post_autosave( $post_id );
$is_revision = wp_is_post_revision( $post_id );
if ( $is_autosave || $is_revision || ! current_user_can( 'edit_post', $post_id ) ) {
return $post_id;
}
if ( isset( $post->post_content ) ) {
if ( strpos( $post->post_content, 'wp:generateblocks' ) !== false ) {
global $wpdb;
$option = get_option( 'generateblocks_dynamic_css_posts', array() );
$posts = $wpdb->get_col( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_generateblocks_reusable_blocks'" );
foreach ( (array) $posts as $id ) {
$display_conditions = get_post_meta( $id, '_generate_element_display_conditions', true );
if ( $display_conditions ) {
foreach ( (array) $display_conditions as $condition ) {
if ( 'general:site' === $condition['rule'] ) {
$option = array();
break;
}
if ( $condition['object'] && isset( $option[ $condition['object'] ] ) ) {
unset( $option[ $condition['object'] ] );
}
}
}
}
update_option( 'generateblocks_dynamic_css_posts', $option );
}
}
}
add_filter( 'generate_do_block_element_content', 'generate_add_block_element_content_filters' );
/**
* Apply content filters to our block elements.
*
* @since 1.11.0
* @param string $content The block element content.
*/
function generate_add_block_element_content_filters( $content ) {
$content = shortcode_unautop( $content );
$content = do_shortcode( $content );
if ( function_exists( 'wp_filter_content_tags' ) ) {
$content = wp_filter_content_tags( $content );
} elseif ( function_exists( 'wp_make_content_images_responsive' ) ) {
$content = wp_make_content_images_responsive( $content );
}
return $content;
}
add_action( 'admin_bar_menu', 'generate_add_elements_admin_bar', 100 );
/**
* Add the Elementd admin bar item.
*
* @since 2.0.0
*/
function generate_add_elements_admin_bar() {
$current_user_can = 'manage_options';
if ( apply_filters( 'generate_elements_metabox_ajax_allow_editors', false ) ) {
$current_user_can = 'edit_posts';
}
if ( ! current_user_can( $current_user_can ) ) {
return;
}
global $wp_admin_bar;
global $generate_elements;
$title = __( 'Elements', 'gp-premium' );
$count = ! empty( $generate_elements ) ? count( $generate_elements ) : 0;
// Prevent "Entire Site" Elements from being counted on non-edit pages in the admin.
if ( is_admin() && function_exists( 'get_current_screen' ) ) {
$screen = get_current_screen();
if ( ! isset( $screen->is_block_editor ) || ! $screen->is_block_editor ) {
$count = 0;
}
if ( 'edit' !== $screen->parent_base ) {
$count = 0;
}
}
if ( $count > 0 ) {
$title = sprintf(
/* translators: Active Element count. */
__( 'Elements (%s)', 'gp-premium' ),
$count
);
}
$wp_admin_bar->add_menu(
array(
'id' => 'gp_elements-menu',
'title' => $title,
'href' => esc_url( admin_url( 'edit.php?post_type=gp_elements' ) ),
)
);
if ( ! empty( $generate_elements ) ) {
// Prevent "Entire Site" Elements from being counted on non-edit pages in the admin.
if ( is_admin() && function_exists( 'get_current_screen' ) ) {
$screen = get_current_screen();
if ( ! isset( $screen->is_block_editor ) || ! $screen->is_block_editor ) {
return;
}
if ( 'edit' !== $screen->parent_base ) {
return;
}
}
foreach ( (array) $generate_elements as $key => $data ) {
$label = GeneratePress_Elements_Helper::get_element_type_label( $data['type'] );
$wp_admin_bar->add_menu(
array(
'id' => 'element-' . absint( $data['id'] ),
'parent' => 'gp_elements-menu',
'title' => get_the_title( $data['id'] ) . ' (' . $label . ')',
'href' => get_edit_post_link( $data['id'] ),
)
);
}
}
}

View File

@ -0,0 +1,449 @@
<?php
/**
* This file builds an external CSS file for our options.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
/**
* Build and enqueue a dynamic stylsheet if needed.
*/
class GeneratePress_External_CSS_File {
/**
* Instance.
*
* @access private
* @var object Instance
* @since 1.11.0
*/
private static $instance;
/**
* Initiator.
*
* @since 1.11.0
* @return object initialized object of class.
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Constructor.
*/
public function __construct() {
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_dynamic_css' ), 20 );
add_action( 'wp', array( $this, 'init' ), 9 );
add_action( 'customize_save_after', array( $this, 'delete_saved_time' ) );
add_action( 'customize_register', array( $this, 'add_customizer_field' ) );
add_filter( 'generate_option_defaults', array( $this, 'add_option_default' ) );
add_filter( 'generatepress_dynamic_css_print_method', array( $this, 'set_print_method' ) );
if ( ! empty( $_POST ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Just checking, false positive.
add_action( 'wp_ajax_generatepress_regenerate_css_file', array( $this, 'regenerate_css_file' ) );
}
}
/**
* Set our CSS Print Method default.
*
* @param array $defaults Our existing defaults.
*/
public function add_option_default( $defaults ) {
$defaults['css_print_method'] = 'inline';
return $defaults;
}
/**
* Add our option to the Customizer.
*
* @param object $wp_customize The Customizer object.
*/
public function add_customizer_field( $wp_customize ) {
if ( ! function_exists( 'generate_get_defaults' ) ) {
return;
}
$defaults = generate_get_defaults();
require_once GP_LIBRARY_DIRECTORY . 'customizer-helpers.php';
if ( method_exists( $wp_customize, 'register_control_type' ) ) {
$wp_customize->register_control_type( 'GeneratePress_Action_Button_Control' );
}
$wp_customize->add_setting(
'generate_settings[css_print_method]',
array(
'default' => $defaults['css_print_method'],
'type' => 'option',
'sanitize_callback' => 'generate_premium_sanitize_choices',
)
);
$wp_customize->add_control(
'generate_settings[css_print_method]',
array(
'type' => 'select',
'label' => __( 'Dynamic CSS Print Method', 'gp-premium' ),
'description' => __( 'Generating your dynamic CSS in an external file offers significant performance advantages.', 'gp-premium' ),
'section' => 'generate_general_section',
'choices' => array(
'inline' => __( 'Inline Embedding', 'gp-premium' ),
'file' => __( 'External File', 'gp-premium' ),
),
'settings' => 'generate_settings[css_print_method]',
)
);
$wp_customize->add_control(
new GeneratePress_Action_Button_Control(
$wp_customize,
'generate_regenerate_external_css_file',
array(
'section' => 'generate_general_section',
'data_type' => 'regenerate_external_css',
'nonce' => esc_html( wp_create_nonce( 'generatepress_regenerate_css_file' ) ),
'label' => __( 'Regenerate CSS File', 'gp-premium' ),
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
'active_callback' => 'generate_is_using_external_css_file_callback',
)
)
);
}
/**
* Set our CSS Print Method.
*
* @param string $method The existing method.
*/
public function set_print_method( $method ) {
if ( ! function_exists( 'generate_get_option' ) ) {
return $method;
}
return generate_get_option( 'css_print_method' );
}
/**
* Determine if we're using file mode or inline mode.
*/
public function mode() {
$mode = generate_get_css_print_method();
if ( 'file' === $mode && $this->needs_update() ) {
$data = get_option( 'generatepress_dynamic_css_data', array() );
if ( ! isset( $data['updated_time'] ) ) {
// No time set, so set the current time minus 5 seconds so the file is still generated.
$data['updated_time'] = time() - 5;
update_option( 'generatepress_dynamic_css_data', $data );
}
// Only allow processing 1 file every 5 seconds.
$current_time = (int) time();
$last_time = (int) $data['updated_time'];
if ( 5 <= ( $current_time - $last_time ) ) {
// Attempt to write to the file.
$mode = ( $this->can_write() && $this->make_css() ) ? 'file' : 'inline';
// Does again if the file exists.
if ( 'file' === $mode ) {
$mode = ( file_exists( $this->file( 'path' ) ) ) ? 'file' : 'inline';
}
}
}
return $mode;
}
/**
* Set things up.
*/
public function init() {
if ( 'file' === $this->mode() ) {
add_filter( 'generate_using_dynamic_css_external_file', '__return_true' );
add_filter( 'generate_dynamic_css_skip_cache', '__return_true', 20 );
// Remove inline CSS in GP < 3.0.0.
if ( ! function_exists( 'generate_get_dynamic_css' ) && function_exists( 'generate_enqueue_dynamic_css' ) ) {
remove_action( 'wp_enqueue_scripts', 'generate_enqueue_dynamic_css', 50 );
}
}
}
/**
* Enqueue the dynamic CSS.
*/
public function enqueue_dynamic_css() {
if ( 'file' === $this->mode() ) {
wp_enqueue_style( 'generatepress-dynamic', esc_url( $this->file( 'uri' ) ), array( 'generate-style' ), null ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
// Move the child theme after our dynamic stylesheet.
if ( is_child_theme() && wp_style_is( 'generate-child', 'enqueued' ) ) {
wp_dequeue_style( 'generate-child' );
wp_enqueue_style( 'generate-child' );
}
// Re-add no-cache CSS in GP < 3.0.0.
if ( ! function_exists( 'generate_get_dynamic_css' ) && function_exists( 'generate_no_cache_dynamic_css' ) ) {
$nocache_css = generate_no_cache_dynamic_css();
if ( function_exists( 'generate_do_icon_css' ) ) {
$nocache_css .= generate_do_icon_css();
}
wp_add_inline_style( 'generate-style', wp_strip_all_tags( $nocache_css ) );
}
}
}
/**
* Make our CSS.
*/
public function make_css() {
$content = '';
if ( function_exists( 'generate_get_dynamic_css' ) ) {
$content = generate_get_dynamic_css();
} elseif ( function_exists( 'generate_base_css' ) && function_exists( 'generate_font_css' ) && function_exists( 'generate_advanced_css' ) && function_exists( 'generate_spacing_css' ) ) {
$content = generate_base_css() . generate_font_css() . generate_advanced_css() . generate_spacing_css();
}
$content = apply_filters( 'generate_external_dynamic_css_output', $content );
if ( ! $content ) {
return false;
}
$filesystem = generate_premium_get_wp_filesystem();
if ( ! $filesystem ) {
return false;
}
// Take care of domain mapping.
if ( defined( 'DOMAIN_MAPPING' ) && DOMAIN_MAPPING ) {
if ( function_exists( 'domain_mapping_siteurl' ) && function_exists( 'get_original_url' ) ) {
$mapped_domain = domain_mapping_siteurl( false );
$original_domain = get_original_url( 'siteurl' );
$content = str_replace( $original_domain, $mapped_domain, $content );
}
}
if ( is_writable( $this->file( 'path' ) ) || ( ! file_exists( $this->file( 'path' ) ) && is_writable( dirname( $this->file( 'path' ) ) ) ) ) {
$chmod_file = 0644;
if ( defined( 'FS_CHMOD_FILE' ) ) {
$chmod_file = FS_CHMOD_FILE;
}
if ( ! $filesystem->put_contents( $this->file( 'path' ), wp_strip_all_tags( $content ), $chmod_file ) ) {
// Fail!
return false;
} else {
$this->update_saved_time();
// Success!
return true;
}
}
}
/**
* Determines if the CSS file is writable.
*/
public function can_write() {
global $blog_id;
// Get the upload directory for this site.
$upload_dir = wp_get_upload_dir();
// If this is a multisite installation, append the blogid to the filename.
$css_blog_id = ( is_multisite() && $blog_id > 1 ) ? '_blog-' . $blog_id : null;
$file_name = '/style' . $css_blog_id . '.min.css';
$folder_path = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . 'generatepress';
// Does the folder exist?
if ( file_exists( $folder_path ) ) {
// Folder exists, but is the folder writable?
if ( ! is_writable( $folder_path ) ) {
// Folder is not writable.
// Does the file exist?
if ( ! file_exists( $folder_path . $file_name ) ) {
// File does not exist, therefore it can't be created
// since the parent folder is not writable.
return false;
} else {
// File exists, but is it writable?
if ( ! is_writable( $folder_path . $file_name ) ) {
// Nope, it's not writable.
return false;
}
}
} else {
// The folder is writable.
// Does the file exist?
if ( file_exists( $folder_path . $file_name ) ) {
// File exists.
// Is it writable?
if ( ! is_writable( $folder_path . $file_name ) ) {
// Nope, it's not writable.
return false;
}
}
}
} else {
// Can we create the folder?
// returns true if yes and false if not.
return wp_mkdir_p( $folder_path );
}
// all is well!
return true;
}
/**
* Gets the css path or url to the stylesheet
*
* @param string $target path/url.
*/
public function file( $target = 'path' ) {
global $blog_id;
// Get the upload directory for this site.
$upload_dir = wp_get_upload_dir();
// If this is a multisite installation, append the blogid to the filename.
$css_blog_id = ( is_multisite() && $blog_id > 1 ) ? '_blog-' . $blog_id : null;
$file_name = 'style' . $css_blog_id . '.min.css';
$folder_path = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . 'generatepress';
// The complete path to the file.
$file_path = $folder_path . DIRECTORY_SEPARATOR . $file_name;
// Get the URL directory of the stylesheet.
$css_uri_folder = $upload_dir['baseurl'];
$css_uri = trailingslashit( $css_uri_folder ) . 'generatepress/' . $file_name;
// Take care of domain mapping.
if ( defined( 'DOMAIN_MAPPING' ) && DOMAIN_MAPPING ) {
if ( function_exists( 'domain_mapping_siteurl' ) && function_exists( 'get_original_url' ) ) {
$mapped_domain = domain_mapping_siteurl( false );
$original_domain = get_original_url( 'siteurl' );
$css_uri = str_replace( $original_domain, $mapped_domain, $css_uri );
}
}
$css_uri = set_url_scheme( $css_uri );
if ( 'path' === $target ) {
return $file_path;
} elseif ( 'url' === $target || 'uri' === $target ) {
$timestamp = ( file_exists( $file_path ) ) ? '?ver=' . filemtime( $file_path ) : '';
return $css_uri . $timestamp;
}
}
/**
* Update the our updated file time.
*/
public function update_saved_time() {
$data = get_option( 'generatepress_dynamic_css_data', array() );
$data['updated_time'] = time();
update_option( 'generatepress_dynamic_css_data', $data );
}
/**
* Delete the saved time.
*/
public function delete_saved_time() {
$data = get_option( 'generatepress_dynamic_css_data', array() );
if ( isset( $data['updated_time'] ) ) {
unset( $data['updated_time'] );
}
update_option( 'generatepress_dynamic_css_data', $data );
}
/**
* Update our plugin/theme versions.
*/
public function update_versions() {
$data = get_option( 'generatepress_dynamic_css_data', array() );
$data['theme_version'] = GENERATE_VERSION;
$data['plugin_version'] = GP_PREMIUM_VERSION;
update_option( 'generatepress_dynamic_css_data', $data );
}
/**
* Do we need to update the CSS file?
*/
public function needs_update() {
$data = get_option( 'generatepress_dynamic_css_data', array() );
$update = false;
// If there's no updated time, needs update.
// The time is set in mode().
if ( ! isset( $data['updated_time'] ) ) {
$update = true;
}
// If we haven't set our versions, do so now.
if ( ! isset( $data['theme_version'] ) && ! isset( $data['plugin_version'] ) ) {
$update = true;
$this->update_versions();
// Bail early so we don't check undefined versions below.
return $update;
}
// Version numbers have changed, needs update.
if ( (string) GENERATE_VERSION !== (string) $data['theme_version'] || (string) GP_PREMIUM_VERSION !== (string) $data['plugin_version'] ) {
$update = true;
$this->update_versions();
}
return $update;
}
/**
* Regenerate the CSS file.
*/
public function regenerate_css_file() {
check_ajax_referer( 'generatepress_regenerate_css_file', '_nonce' );
if ( ! current_user_can( 'manage_options' ) ) {
wp_send_json_error( __( 'Security check failed.', 'gp-premium' ) );
}
$this->delete_saved_time();
wp_send_json_success();
}
}
GeneratePress_External_CSS_File::get_instance();

View File

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

View File

@ -0,0 +1,87 @@
<?php
/**
* This file handles SVG icons.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
add_action( 'wp_enqueue_scripts', 'generate_enqueue_premium_icons' );
/**
* Register our GP Premium icons.
*
* @since 1.6
*/
function generate_enqueue_premium_icons() {
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
wp_register_style( 'gp-premium-icons', plugin_dir_url( __FILE__ ) . "icons/icons{$suffix}.css", array(), GP_PREMIUM_VERSION );
}
add_filter( 'generate_svg_icon', 'generate_premium_add_svg_icons', 10, 2 );
/**
* Add our premium SVG icons.
*
* @since 1.9
* @param string $output The SVG HTML output.
* @param string $icon The icon name.
*/
function generate_premium_add_svg_icons( $output, $icon ) {
$svg = '';
if ( 'shopping-bag' === $icon ) {
$svg = '<svg viewBox="0 0 518 512" aria-hidden="true" version="1.1" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em">
<g id="Union" transform="matrix(1,0,0,1,2.01969,2)">
<path d="M172,108.5C172,61.832 209.832,24 256.5,24C303.168,24 341,61.832 341,108.5L341,116C341,122.627 346.373,128 353,128C359.628,128 365,122.627 365,116L365,108.5C365,48.577 316.423,0 256.5,0C196.577,0 148,48.577 148,108.5L148,116C148,122.627 153.373,128 160,128C166.628,128 172,122.627 172,116L172,108.5Z" style="fill-rule:nonzero;"/>
<path d="M4.162,145.236C7.195,141.901 11.493,140 16,140L496,140C500.507,140 504.806,141.901 507.838,145.236C510.87,148.571 512.355,153.03 511.928,157.517L482.687,464.551C480.34,489.186 459.65,508 434.903,508L77.097,508C52.35,508 31.66,489.186 29.314,464.551L0.072,157.517C-0.355,153.03 1.13,148.571 4.162,145.236Z" style="fill-rule:nonzero;"/>
</g>
</svg>';
}
if ( 'shopping-cart' === $icon ) {
$svg = '<svg viewBox="0 0 576 512" aria-hidden="true" version="1.1" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em">
<path fill="none" d="M0 0h576v512H0z"/>
<path d="M181.54 409.6c-29.249 0-52.914 23.04-52.914 51.2 0 28.16 23.665 51.2 52.915 51.2 29.249 0 53.18-23.04 53.18-51.2 0-28.16-23.931-51.2-53.18-51.2zM22 0v51.2h53.18l95.725 194.304-35.897 62.464C115.598 342.272 141.124 384 181.54 384h319.08v-51.2h-319.08l29.249-51.2h198.096c19.943 0 37.492-10.496 46.533-26.368L550.61 89.088c9.838-16.896-2.925-37.888-23.133-37.888H133.944L108.95 0H22zm425.442 409.6c-29.25 0-52.915 23.04-52.915 51.2 0 28.16 23.665 51.2 52.915 51.2 29.249 0 53.18-23.04 53.18-51.2 0-28.16-23.931-51.2-53.18-51.2z"/>
</svg>';
}
if ( 'shopping-basket' === $icon ) {
$svg = '<svg viewBox="0 0 626 512" aria-hidden="true" version="1.1" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em">
<path d="M4.83 187.075a19.505 19.505 0 0 1 14.675-6.656h585.144a19.505 19.505 0 0 1 19.334 22.083L589.486 461.22c-3.875 29.07-28.672 50.781-58 50.781H92.668c-29.328 0-54.126-21.71-58.002-50.78L.171 202.501a19.511 19.511 0 0 1 4.659-15.427zm165.748 69.748c-.892-8.03-8.125-13.815-16.155-12.924-8.03.892-13.815 8.125-12.924 16.155l19.505 175.543c.892 8.03 8.125 13.816 16.154 12.924 8.03-.892 13.816-8.125 12.925-16.154l-19.505-175.544zm312.077 3.23c.892-8.029-4.895-15.262-12.925-16.154-8.03-.891-15.262 4.894-16.154 12.924L434.07 432.367c-.893 8.03 4.894 15.262 12.924 16.154 8.03.892 15.263-4.894 16.155-12.924l19.505-175.543zm-153.512-1.614c0-8.079-6.55-14.629-14.628-14.629-8.079 0-14.629 6.55-14.629 14.629v175.543c0 8.078 6.55 14.628 14.629 14.628s14.628-6.55 14.628-14.628V258.439z"/>
<path d="M283.41 4.285c5.715 5.712 5.715 14.975 0 20.687L146.878 161.506c-5.712 5.714-14.975 5.714-20.687 0-5.714-5.713-5.714-14.975 0-20.687L262.724 4.285c5.712-5.714 14.974-5.714 20.687 0zm57.333 0c5.712-5.714 14.975-5.714 20.687 0l136.534 136.534c5.713 5.712 5.713 14.974 0 20.687-5.713 5.714-14.975 5.714-20.688 0L340.743 24.972c-5.714-5.712-5.714-14.975 0-20.687z" />
</svg>';
}
if ( 'spinner' === $icon ) {
$svg = '<svg viewBox="0 0 512 512" aria-hidden="true" version="1.1" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em">
<path d="M288 32c0 17.673-14.327 32-32 32-17.673 0-32-14.327-32-32 0-17.673 14.327-32 32-32 17.673 0 32 14.327 32 32zM288 480c0 17.673-14.327 32-32 32-17.673 0-32-14.327-32-32 0-17.673 14.327-32 32-32 17.673 0 32 14.327 32 32zM448 256c0 17.673 14.327 32 32 32 17.673 0 32-14.327 32-32 0-17.673-14.327-32-32-32-17.673 0-32 14.327-32 32zM32 288c-17.673 0-32-14.327-32-32 0-17.673 14.327-32 32-32 17.673 0 32 14.327 32 32 0 17.673-14.327 32-32 32zM391.764 391.764c-12.496 12.497-12.496 32.759 0 45.255 12.497 12.497 32.758 12.497 45.255 0 12.497-12.496 12.497-32.758 0-45.255-12.497-12.496-32.758-12.496-45.255 0zM74.981 120.235c-12.497-12.496-12.497-32.758 0-45.254 12.496-12.497 32.758-12.497 45.254 0 12.497 12.496 12.497 32.758 0 45.254-12.496 12.497-32.758 12.497-45.254 0zM120.235 391.765c-12.496-12.497-32.758-12.497-45.254 0-12.497 12.496-12.497 32.758 0 45.254 12.496 12.497 32.758 12.497 45.254 0 12.497-12.496 12.497-32.758 0-45.254z"/>
</svg>';
}
if ( 'pro-menu-bars' === $icon ) {
$svg = '<svg viewBox="0 0 512 512" aria-hidden="true" role="img" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1em" height="1em">
<path d="M0 96c0-13.255 10.745-24 24-24h464c13.255 0 24 10.745 24 24s-10.745 24-24 24H24c-13.255 0-24-10.745-24-24zm0 160c0-13.255 10.745-24 24-24h464c13.255 0 24 10.745 24 24s-10.745 24-24 24H24c-13.255 0-24-10.745-24-24zm0 160c0-13.255 10.745-24 24-24h464c13.255 0 24 10.745 24 24s-10.745 24-24 24H24c-13.255 0-24-10.745-24-24z" />
</svg>';
}
if ( 'pro-close' === $icon ) {
$svg = '<svg viewBox="0 0 512 512" aria-hidden="true" role="img" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1em" height="1em">
<path d="M71.029 71.029c9.373-9.372 24.569-9.372 33.942 0L256 222.059l151.029-151.03c9.373-9.372 24.569-9.372 33.942 0 9.372 9.373 9.372 24.569 0 33.942L289.941 256l151.03 151.029c9.372 9.373 9.372 24.569 0 33.942-9.373 9.372-24.569 9.372-33.942 0L256 289.941l-151.029 151.03c-9.373 9.372-24.569 9.372-33.942 0-9.372-9.373-9.372-24.569 0-33.942L222.059 256 71.029 104.971c-9.372-9.373-9.372-24.569 0-33.942z" />
</svg>';
}
if ( $svg ) {
$output = sprintf(
'<span class="gp-icon %1$s">
%2$s
</span>',
$icon,
$svg
);
}
return $output;
}

View File

@ -0,0 +1,20 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<svg xmlns="http://www.w3.org/2000/svg">
<metadata>Generated by IcoMoon</metadata>
<defs>
<font id="icomoon" horiz-adv-x="1024">
<font-face units-per-em="1024" ascent="960" descent="-64" />
<missing-glyph horiz-adv-x="1024" />
<glyph unicode="&#x20;" horiz-adv-x="512" d="" />
<glyph unicode="&#xe900;" glyph-name="spinner" d="M576 896c0-35.346-28.654-64-64-64s-64 28.654-64 64c0 35.346 28.654 64 64 64s64-28.654 64-64zM576 0c0-35.346-28.654-64-64-64s-64 28.654-64 64c0 35.346 28.654 64 64 64s64-28.654 64-64zM896 448c0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64s-64-28.654-64-64zM64 384c-35.346 0-64 28.654-64 64s28.654 64 64 64c35.346 0 64-28.654 64-64s-28.654-64-64-64zM783.528 176.472c-24.992-24.994-24.992-65.518 0-90.51 24.994-24.994 65.516-24.994 90.51 0 24.994 24.992 24.994 65.516 0 90.51-24.994 24.992-65.516 24.992-90.51 0zM149.962 719.53c-24.994 24.992-24.994 65.516 0 90.508 24.992 24.994 65.516 24.994 90.508 0 24.994-24.992 24.994-65.516 0-90.508-24.992-24.994-65.516-24.994-90.508 0zM240.47 176.47c-24.992 24.994-65.516 24.994-90.508 0-24.994-24.992-24.994-65.516 0-90.508 24.992-24.994 65.516-24.994 90.508 0 24.994 24.992 24.994 65.516 0 90.508z" />
<glyph unicode="&#xe901;" glyph-name="angle-right" horiz-adv-x="384" d="M333.8 431l-235.6-232c-9.4-9.4-24.6-9.4-34 0l-14.2 14.2c-9.4 9.4-9.4 24.6 0 34l204.6 200.8-204.4 200.8c-9.4 9.4-9.4 24.6 0 34l14.2 14.2c9.4 9.4 24.6 9.4 34 0l235.6-232c9.2-9.4 9.2-24.6-0.2-34z" />
<glyph unicode="&#xe902;" glyph-name="circle" d="M512 865.477c-230.565 0-417.477-186.911-417.477-417.477s186.911-417.477 417.477-417.477c230.565 0 417.477 186.911 417.477 417.477s-186.911 417.477-417.477 417.477zM0 448c0 282.77 229.23 512 512 512s512-229.23 512-512c0-282.77-229.23-512-512-512s-512 229.23-512 512z" />
<glyph unicode="&#xe903;" glyph-name="angle-down" horiz-adv-x="660" d="M611.825 565.831c0-4.532-2.266-9.63-5.665-13.029l-263.987-263.987c-3.399-3.399-8.497-5.665-13.029-5.665s-9.63 2.266-13.029 5.665l-263.987 263.987c-3.399 3.399-5.665 8.497-5.665 13.029s2.266 9.63 5.665 13.029l28.325 28.325c3.399 3.399 7.931 5.665 13.029 5.665 4.532 0 9.63-2.266 13.029-5.665l222.633-222.633 222.633 222.633c3.399 3.399 8.497 5.665 13.029 5.665s9.63-2.266 13.029-5.665l28.325-28.325c3.399-3.399 5.665-8.497 5.665-13.029z" />
<glyph unicode="&#xe904;" glyph-name="dot-circle" d="M512 865.477c-230.565 0-417.477-186.911-417.477-417.477s186.911-417.477 417.477-417.477c230.565 0 417.477 186.911 417.477 417.477s-186.911 417.477-417.477 417.477zM0 448c0 282.77 229.23 512 512 512s512-229.23 512-512c0-282.77-229.23-512-512-512s-512 229.23-512 512zM519.877 518.892c-43.502 0-78.769-35.267-78.769-78.769s35.267-78.769 78.769-78.769c43.502 0 78.769 35.267 78.769 78.769s-35.267 78.769-78.769 78.769zM346.584 440.123c0 95.707 77.586 173.292 173.292 173.292s173.292-77.586 173.292-173.292c0-95.707-77.586-173.292-173.292-173.292s-173.292 77.586-173.292 173.292z" />
<glyph unicode="&#xf00d;" glyph-name="times" d="M142.058 817.942c18.746 18.744 49.138 18.744 67.884 0l302.058-302.060 302.058 302.060c18.746 18.744 49.138 18.744 67.884 0 18.744-18.746 18.744-49.138 0-67.884l-302.060-302.058 302.060-302.058c18.744-18.746 18.744-49.138 0-67.884-18.746-18.744-49.138-18.744-67.884 0l-302.058 302.060-302.058-302.060c-18.746-18.744-49.138-18.744-67.884 0-18.744 18.746-18.744 49.138 0 67.884l302.060 302.058-302.060 302.058c-18.744 18.746-18.744 49.138 0 67.884z" />
<glyph unicode="&#xf07a;" glyph-name="shopping-cart" horiz-adv-x="1152" d="M363.081 140.8c-58.498 0-105.829-46.080-105.829-102.4s47.33-102.4 105.829-102.4c58.498 0 106.36 46.080 106.36 102.4s-47.862 102.4-106.36 102.4zM44 960v-102.4h106.36l191.449-388.608-71.793-124.928c-38.822-68.608 12.231-152.064 93.065-152.064h638.162v102.4h-638.162l58.498 102.4h396.192c39.885 0 74.984 20.992 93.065 52.736l190.385 332.288c19.677 33.792-5.85 75.776-46.267 75.776h-787.067l-49.989 102.4h-173.899zM894.883 140.8c-58.498 0-105.829-46.080-105.829-102.4s47.33-102.4 105.829-102.4c58.498 0 106.36 46.080 106.36 102.4s-47.862 102.4-106.36 102.4z" />
<glyph unicode="&#xf0c9;" glyph-name="bars" d="M0 768c0 26.51 21.49 48 48 48h928c26.51 0 48-21.49 48-48s-21.49-48-48-48h-928c-26.51 0-48 21.49-48 48zM0 448c0 26.51 21.49 48 48 48h928c26.51 0 48-21.49 48-48s-21.49-48-48-48h-928c-26.51 0-48 21.49-48 48zM0 128c0 26.51 21.49 48 48 48h928c26.51 0 48-21.49 48-48s-21.49-48-48-48h-928c-26.51 0-48 21.49-48 48z" />
<glyph unicode="&#xf290;" glyph-name="shopping-bag" horiz-adv-x="1036" d="M348.039 739c0 93.336 75.664 169 169 169s169-75.664 169-169v-15c0-13.254 10.746-24 24-24 13.256 0 24 10.746 24 24v15c0 119.846-97.154 217-217 217s-217-97.154-217-217v-15c0-13.254 10.746-24 24-24 13.256 0 24 10.746 24 24v15zM12.363 665.528c6.066 6.67 14.662 10.472 23.676 10.472h960c9.014 0 17.612-3.802 23.676-10.472s9.034-15.588 8.18-24.562l-58.482-614.068c-4.694-49.27-46.074-86.898-95.568-86.898h-715.612c-49.494 0-90.874 37.628-95.566 86.898l-58.484 614.068c-0.854 8.974 2.116 17.892 8.18 24.562z" />
<glyph unicode="&#xf291;" glyph-name="shopping-basket" horiz-adv-x="1252" d="M9.66 585.849c7.407 8.46 18.105 13.312 29.35 13.312h1170.288c11.245 0 21.943-4.852 29.35-13.312 7.407-8.463 10.803-19.707 9.318-30.854l-68.993-517.436c-7.751-58.141-57.344-101.561-116.002-101.561h-877.633c-58.656 0-108.252 43.42-116.002 101.561l-68.993 517.436c-1.485 11.147 1.911 22.392 9.318 30.854zM341.156 446.353c-1.785 16.060-16.25 27.631-32.31 25.849-16.060-1.785-27.631-16.25-25.849-32.31l39.010-351.086c1.785-16.060 16.25-27.631 32.31-25.849 16.060 1.785 27.631 16.25 25.849 32.31l-39.010 351.086zM965.31 439.892c1.785 16.060-9.789 30.525-25.849 32.31-16.060 1.782-30.525-9.789-32.31-25.849l-39.010-351.086c-1.785-16.060 9.789-30.525 25.849-32.31 16.060-1.782 30.525 9.789 32.31 25.849l39.010 351.086zM658.287 443.123c0 16.157-13.1 29.257-29.257 29.257s-29.257-13.1-29.257-29.257v-351.086c0-16.157 13.1-29.257 29.257-29.257s29.257 13.1 29.257 29.257v351.086zM566.822 951.43c11.427-11.425 11.427-29.95 0-41.375l-273.067-273.067c-11.425-11.427-29.95-11.427-41.375 0-11.427 11.425-11.427 29.95 0 41.375l273.067 273.067c11.425 11.427 29.95 11.427 41.375 0zM681.486 951.43c11.425 11.427 29.95 11.427 41.375 0l273.067-273.067c11.427-11.425 11.427-29.95 0-41.375-11.425-11.427-29.95-11.427-41.375 0l-273.067 273.067c-11.427 11.425-11.427 29.95 0 41.375z" />
</font></defs></svg>

After

Width:  |  Height:  |  Size: 6.3 KiB

View File

@ -0,0 +1,10 @@
@font-face {
font-family: 'GP Premium';
src: url('gp-premium.eot');
src: url('gp-premium.eot#iefix') format('embedded-opentype'),
url('gp-premium.woff') format('woff'),
url('gp-premium.ttf') format('truetype'),
url('gp-premium.svg#gp-premium') format('svg');
font-weight: normal;
font-style: normal;
}

View File

@ -0,0 +1 @@
@font-face{font-family:'GP Premium';src:url(gp-premium.eot);src:url(gp-premium.eot#iefix) format('embedded-opentype'),url(gp-premium.woff) format('woff'),url(gp-premium.ttf) format('truetype'),url(gp-premium.svg#gp-premium) format('svg');font-weight:400;font-style:normal}

View File

@ -0,0 +1,743 @@
/*!
* smooth-scroll v14.2.1: Animate scrolling to anchor links
* (c) 2018 Chris Ferdinandi
* MIT License
* http://github.com/cferdinandi/smooth-scroll
*/
/**
* closest() polyfill
* @link https://developer.mozilla.org/en-US/docs/Web/API/Element/closest#Polyfill
*/
if (window.Element && !Element.prototype.closest) {
Element.prototype.closest = function(s) {
var matches = (this.document || this.ownerDocument).querySelectorAll(s),
i,
el = this;
do {
i = matches.length;
while (--i >= 0 && matches.item(i) !== el) {}
} while ((i < 0) && (el = el.parentElement));
return el;
};
}
/**
* CustomEvent() polyfill
* https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent#Polyfill
*/
(function () {
if (typeof window.CustomEvent === "function") return false;
function CustomEvent(event, params) {
params = params || { bubbles: false, cancelable: false, detail: undefined };
var evt = document.createEvent('CustomEvent');
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
return evt;
}
CustomEvent.prototype = window.Event.prototype;
window.CustomEvent = CustomEvent;
})();
/**
* requestAnimationFrame() polyfill
* By Erik Möller. Fixes from Paul Irish and Tino Zijdel.
* @link http://paulirish.com/2011/requestanimationframe-for-smart-animating/
* @link http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
* @license MIT
*/
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] ||
window[vendors[x]+'CancelRequestAnimationFrame'];
}
if (!window.requestAnimationFrame) {
window.requestAnimationFrame = function(callback, element) {
var currTime = new Date().getTime();
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
var id = window.setTimeout((function() { callback(currTime + timeToCall); }),
timeToCall);
lastTime = currTime + timeToCall;
return id;
};
}
if (!window.cancelAnimationFrame) {
window.cancelAnimationFrame = function(id) {
clearTimeout(id);
};
}
}());
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define([], (function () {
return factory(root);
}));
} else if (typeof exports === 'object') {
module.exports = factory(root);
} else {
root.SmoothScroll = factory(root);
}
})(typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : this, (function (window) {
'use strict';
//
// Default settings
//
var defaults = {
// Selectors
ignore: '[data-scroll-ignore]',
header: null,
topOnEmptyHash: true,
// Speed & Easing
speed: 500,
clip: true,
offset: 0,
easing: 'easeInOutCubic',
customEasing: null,
// History
updateURL: true,
popstate: true,
// Custom Events
emitEvents: true
};
//
// Utility Methods
//
/**
* Check if browser supports required methods
* @return {Boolean} Returns true if all required methods are supported
*/
var supports = function () {
return (
'querySelector' in document &&
'addEventListener' in window &&
'requestAnimationFrame' in window &&
'closest' in window.Element.prototype
);
};
/**
* Merge two or more objects. Returns a new object.
* @param {Object} objects The objects to merge together
* @returns {Object} Merged values of defaults and options
*/
var extend = function () {
// Variables
var extended = {};
// Merge the object into the extended object
var merge = function (obj) {
for (var prop in obj) {
if (obj.hasOwnProperty(prop)) {
extended[prop] = obj[prop];
}
}
};
// Loop through each object and conduct a merge
for (var i = 0; i < arguments.length; i++) {
merge(arguments[i]);
}
return extended;
};
/**
* Check to see if user prefers reduced motion
* @param {Object} settings Script settings
*/
var reduceMotion = function (settings) {
if ('matchMedia' in window && window.matchMedia('(prefers-reduced-motion)').matches) {
return true;
}
return false;
};
/**
* Get the height of an element.
* @param {Node} elem The element to get the height of
* @return {Number} The element's height in pixels
*/
var getHeight = function (elem) {
return parseInt(window.getComputedStyle(elem).height, 10);
};
/**
* Decode a URI, with error check
* @param {String} hash The URI to decode
* @return {String} A decoded URI (or the original string if an error is thrown)
*/
var decode = function (hash) {
var decoded;
try {
decoded = decodeURIComponent(hash);
} catch(e) {
decoded = hash;
}
return decoded;
};
/**
* Escape special characters for use with querySelector
* @author Mathias Bynens
* @link https://github.com/mathiasbynens/CSS.escape
* @param {String} id The anchor ID to escape
*/
var escapeCharacters = function (id) {
// Remove leading hash
if (id.charAt(0) === '#') {
id = id.substr(1);
}
var string = String(id);
var length = string.length;
var index = -1;
var codeUnit;
var result = '';
var firstCodeUnit = string.charCodeAt(0);
while (++index < length) {
codeUnit = string.charCodeAt(index);
// Note: theres no need to special-case astral symbols, surrogate
// pairs, or lone surrogates.
// If the character is NULL (U+0000), then throw an
// `InvalidCharacterError` exception and terminate these steps.
if (codeUnit === 0x0000) {
throw new InvalidCharacterError(
'Invalid character: the input contains U+0000.'
);
}
if (
// If the character is in the range [\1-\1F] (U+0001 to U+001F) or is
// U+007F, […]
(codeUnit >= 0x0001 && codeUnit <= 0x001F) || codeUnit == 0x007F ||
// If the character is the first character and is in the range [0-9]
// (U+0030 to U+0039), […]
(index === 0 && codeUnit >= 0x0030 && codeUnit <= 0x0039) ||
// If the character is the second character and is in the range [0-9]
// (U+0030 to U+0039) and the first character is a `-` (U+002D), […]
(
index === 1 &&
codeUnit >= 0x0030 && codeUnit <= 0x0039 &&
firstCodeUnit === 0x002D
)
) {
// http://dev.w3.org/csswg/cssom/#escape-a-character-as-code-point
result += '\\' + codeUnit.toString(16) + ' ';
continue;
}
// If the character is not handled by one of the above rules and is
// greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or
// is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to
// U+005A), or [a-z] (U+0061 to U+007A), […]
if (
codeUnit >= 0x0080 ||
codeUnit === 0x002D ||
codeUnit === 0x005F ||
codeUnit >= 0x0030 && codeUnit <= 0x0039 ||
codeUnit >= 0x0041 && codeUnit <= 0x005A ||
codeUnit >= 0x0061 && codeUnit <= 0x007A
) {
// the character itself
result += string.charAt(index);
continue;
}
// Otherwise, the escaped character.
// http://dev.w3.org/csswg/cssom/#escape-a-character
result += '\\' + string.charAt(index);
}
// Return sanitized hash
var hash;
try {
hash = decodeURIComponent('#' + result);
} catch(e) {
hash = '#' + result;
}
return hash;
};
/**
* Calculate the easing pattern
* @link https://gist.github.com/gre/1650294
* @param {String} type Easing pattern
* @param {Number} time Time animation should take to complete
* @returns {Number}
*/
var easingPattern = function (settings, time) {
var pattern;
// Default Easing Patterns
if (settings.easing === 'easeInQuad') pattern = time * time; // accelerating from zero velocity
if (settings.easing === 'easeOutQuad') pattern = time * (2 - time); // decelerating to zero velocity
if (settings.easing === 'easeInOutQuad') pattern = time < 0.5 ? 2 * time * time : -1 + (4 - 2 * time) * time; // acceleration until halfway, then deceleration
if (settings.easing === 'easeInCubic') pattern = time * time * time; // accelerating from zero velocity
if (settings.easing === 'easeOutCubic') pattern = (--time) * time * time + 1; // decelerating to zero velocity
if (settings.easing === 'easeInOutCubic') pattern = time < 0.5 ? 4 * time * time * time : (time - 1) * (2 * time - 2) * (2 * time - 2) + 1; // acceleration until halfway, then deceleration
if (settings.easing === 'easeInQuart') pattern = time * time * time * time; // accelerating from zero velocity
if (settings.easing === 'easeOutQuart') pattern = 1 - (--time) * time * time * time; // decelerating to zero velocity
if (settings.easing === 'easeInOutQuart') pattern = time < 0.5 ? 8 * time * time * time * time : 1 - 8 * (--time) * time * time * time; // acceleration until halfway, then deceleration
if (settings.easing === 'easeInQuint') pattern = time * time * time * time * time; // accelerating from zero velocity
if (settings.easing === 'easeOutQuint') pattern = 1 + (--time) * time * time * time * time; // decelerating to zero velocity
if (settings.easing === 'easeInOutQuint') pattern = time < 0.5 ? 16 * time * time * time * time * time : 1 + 16 * (--time) * time * time * time * time; // acceleration until halfway, then deceleration
// Custom Easing Patterns
if (!!settings.customEasing) pattern = settings.customEasing(time);
return pattern || time; // no easing, no acceleration
};
/**
* Determine the document's height
* @returns {Number}
*/
var getDocumentHeight = function () {
return Math.max(
document.body.scrollHeight, document.documentElement.scrollHeight,
document.body.offsetHeight, document.documentElement.offsetHeight,
document.body.clientHeight, document.documentElement.clientHeight
);
};
/**
* Calculate how far to scroll
* Clip support added by robjtede - https://github.com/cferdinandi/smooth-scroll/issues/405
* @param {Element} anchor The anchor element to scroll to
* @param {Number} headerHeight Height of a fixed header, if any
* @param {Number} offset Number of pixels by which to offset scroll
* @param {Boolean} clip If true, adjust scroll distance to prevent abrupt stops near the bottom of the page
* @returns {Number}
*/
var getEndLocation = function (anchor, headerHeight, offset, clip) {
var location = 0;
if (anchor.offsetParent) {
do {
location += anchor.offsetTop;
anchor = anchor.offsetParent;
} while (anchor);
}
location = Math.max(location - headerHeight - offset, 0);
if (clip) {
location = Math.min(location, getDocumentHeight() - window.innerHeight);
}
return location;
};
/**
* Get the height of the fixed header
* @param {Node} header The header
* @return {Number} The height of the header
*/
var getHeaderHeight = function (header) {
return !header ? 0 : (getHeight(header) + header.offsetTop);
};
/**
* Update the URL
* @param {Node} anchor The anchor that was scrolled to
* @param {Boolean} isNum If true, anchor is a number
* @param {Object} options Settings for Smooth Scroll
*/
var updateURL = function (anchor, isNum, options) {
// Bail if the anchor is a number
if (isNum) return;
// Verify that pushState is supported and the updateURL option is enabled
if (!history.pushState || !options.updateURL) return;
// Update URL
history.pushState(
{
smoothScroll: JSON.stringify(options),
anchor: anchor.id
},
document.title,
anchor === document.documentElement ? '#top' : '#' + anchor.id
);
};
/**
* Bring the anchored element into focus
* @param {Node} anchor The anchor element
* @param {Number} endLocation The end location to scroll to
* @param {Boolean} isNum If true, scroll is to a position rather than an element
*/
var adjustFocus = function (anchor, endLocation, isNum) {
// Is scrolling to top of page, blur
if (anchor === 0) {
document.body.focus();
}
// Don't run if scrolling to a number on the page
if (isNum) return;
// Otherwise, bring anchor element into focus
anchor.focus();
if (document.activeElement !== anchor) {
anchor.setAttribute('tabindex', '-1');
anchor.focus();
anchor.style.outline = 'none';
}
window.scrollTo(0 , endLocation);
};
/**
* Emit a custom event
* @param {String} type The event type
* @param {Object} options The settings object
* @param {Node} anchor The anchor element
* @param {Node} toggle The toggle element
*/
var emitEvent = function (type, options, anchor, toggle) {
if (!options.emitEvents || typeof window.CustomEvent !== 'function') return;
var event = new CustomEvent(type, {
bubbles: true,
detail: {
anchor: anchor,
toggle: toggle
}
});
document.dispatchEvent(event);
};
//
// SmoothScroll Constructor
//
var SmoothScroll = function (selector, options) {
//
// Variables
//
var smoothScroll = {}; // Object for public APIs
var settings, anchor, toggle, fixedHeader, headerHeight, eventTimeout, animationInterval;
//
// Methods
//
/**
* Cancel a scroll-in-progress
*/
smoothScroll.cancelScroll = function (noEvent) {
cancelAnimationFrame(animationInterval);
animationInterval = null;
if (noEvent) return;
emitEvent('scrollCancel', settings);
};
/**
* Start/stop the scrolling animation
* @param {Node|Number} anchor The element or position to scroll to
* @param {Element} toggle The element that toggled the scroll event
* @param {Object} options
*/
smoothScroll.animateScroll = function (anchor, toggle, options) {
// Local settings
var animateSettings = extend(settings || defaults, options || {}); // Merge user options with defaults
// Selectors and variables
var isNum = Object.prototype.toString.call(anchor) === '[object Number]' ? true : false;
var anchorElem = isNum || !anchor.tagName ? null : anchor;
if (!isNum && !anchorElem) return;
var startLocation = window.pageYOffset; // Current location on the page
if (animateSettings.header && !fixedHeader) {
// Get the fixed header if not already set
fixedHeader = document.querySelector(animateSettings.header);
}
if (!headerHeight) {
// Get the height of a fixed header if one exists and not already set
headerHeight = getHeaderHeight(fixedHeader);
}
var endLocation = isNum ? anchor : getEndLocation(anchorElem, headerHeight, parseInt((typeof animateSettings.offset === 'function' ? animateSettings.offset(anchor, toggle) : animateSettings.offset), 10), animateSettings.clip); // Location to scroll to
var distance = endLocation - startLocation; // distance to travel
var documentHeight = getDocumentHeight();
var timeLapsed = 0;
var start, percentage, position;
/**
* Stop the scroll animation when it reaches its target (or the bottom/top of page)
* @param {Number} position Current position on the page
* @param {Number} endLocation Scroll to location
* @param {Number} animationInterval How much to scroll on this loop
*/
var stopAnimateScroll = function (position, endLocation) {
// Get the current location
var currentLocation = window.pageYOffset;
// Check if the end location has been reached yet (or we've hit the end of the document)
if (position == endLocation || currentLocation == endLocation || ((startLocation < endLocation && window.innerHeight + currentLocation) >= documentHeight)) {
// Clear the animation timer
smoothScroll.cancelScroll(true);
// Bring the anchored element into focus
adjustFocus(anchor, endLocation, isNum);
// Emit a custom event
emitEvent('scrollStop', animateSettings, anchor, toggle);
// Reset start
start = null;
animationInterval = null;
return true;
}
};
/**
* Loop scrolling animation
*/
var loopAnimateScroll = function (timestamp) {
if (!start) { start = timestamp; }
timeLapsed += timestamp - start;
percentage = (timeLapsed / parseInt(animateSettings.speed, 10));
percentage = (percentage > 1) ? 1 : percentage;
position = startLocation + (distance * easingPattern(animateSettings, percentage));
window.scrollTo(0, Math.floor(position));
if (!stopAnimateScroll(position, endLocation)) {
animationInterval = window.requestAnimationFrame(loopAnimateScroll);
start = timestamp;
}
};
/**
* Reset position to fix weird iOS bug
* @link https://github.com/cferdinandi/smooth-scroll/issues/45
*/
if (window.pageYOffset === 0) {
window.scrollTo(0, 0);
}
// Update the URL
updateURL(anchor, isNum, animateSettings);
// Emit a custom event
emitEvent('scrollStart', animateSettings, anchor, toggle);
// Start scrolling animation
smoothScroll.cancelScroll(true);
window.requestAnimationFrame(loopAnimateScroll);
};
/**
* If smooth scroll element clicked, animate scroll
*/
var clickHandler = function (event) {
// Don't run if the user prefers reduced motion
if (reduceMotion(settings)) return;
// Don't run if right-click or command/control + click
if (event.button !== 0 || event.metaKey || event.ctrlKey) return;
// Check if event.target has closest() method
// By @totegi - https://github.com/cferdinandi/smooth-scroll/pull/401/
if(!('closest' in event.target))return;
// Check if a smooth scroll link was clicked
toggle = event.target.closest(selector);
if (!toggle || toggle.tagName.toLowerCase() !== 'a' || event.target.closest(settings.ignore)) return;
// Only run if link is an anchor and points to the current page
if (toggle.hostname !== window.location.hostname || toggle.pathname !== window.location.pathname || !/#/.test(toggle.href)) return;
// Get an escaped version of the hash
var hash = escapeCharacters(decode(toggle.hash));
// Get the anchored element
var anchor = settings.topOnEmptyHash && hash === '#' ? document.documentElement : document.querySelector(hash);
anchor = !anchor && hash === '#top' ? document.documentElement : anchor;
// If anchored element exists, scroll to it
if (!anchor) return;
event.preventDefault();
smoothScroll.animateScroll(anchor, toggle);
};
/**
* Animate scroll on popstate events
*/
var popstateHandler = function (event) {
// Stop if history.state doesn't exist (ex. if clicking on a broken anchor link).
// fixes `Cannot read property 'smoothScroll' of null` error getting thrown.
if (history.state === null) return;
// Only run if state is a popstate record for this instantiation
if (!history.state.smoothScroll || history.state.smoothScroll !== JSON.stringify(settings)) return;
// Only run if state includes an anchor
if (!history.state.anchor) return;
// Get the anchor
var anchor = document.querySelector(escapeCharacters(decode(history.state.anchor)));
if (!anchor) return;
// Animate scroll to anchor link
smoothScroll.animateScroll(anchor, null, {updateURL: false});
};
/**
* On window scroll and resize, only run events at a rate of 15fps for better performance
*/
var resizeThrottler = function (event) {
if (!eventTimeout) {
eventTimeout = setTimeout((function() {
eventTimeout = null; // Reset timeout
headerHeight = getHeaderHeight(fixedHeader); // Get the height of a fixed header if one exists
}), 66);
}
};
/**
* Destroy the current initialization.
*/
smoothScroll.destroy = function () {
// If plugin isn't already initialized, stop
if (!settings) return;
// Remove event listeners
document.removeEventListener('click', clickHandler, false);
window.removeEventListener('resize', resizeThrottler, false);
window.removeEventListener('popstate', popstateHandler, false);
// Cancel any scrolls-in-progress
smoothScroll.cancelScroll();
// Reset variables
settings = null;
anchor = null;
toggle = null;
fixedHeader = null;
headerHeight = null;
eventTimeout = null;
animationInterval = null;
};
/**
* Initialize Smooth Scroll
* @param {Object} options User settings
*/
smoothScroll.init = function (options) {
// feature test
if (!supports()) throw 'Smooth Scroll: This browser does not support the required JavaScript methods and browser APIs.';
// Destroy any existing initializations
smoothScroll.destroy();
// Selectors and variables
settings = extend(defaults, options || {}); // Merge user options with defaults
fixedHeader = settings.header ? document.querySelector(settings.header) : null; // Get the fixed header
headerHeight = getHeaderHeight(fixedHeader);
// When a toggle is clicked, run the click handler
document.addEventListener('click', clickHandler, false);
// If window is resized and there's a fixed header, recalculate its size
if (fixedHeader) {
window.addEventListener('resize', resizeThrottler, false);
}
// If updateURL and popState are enabled, listen for pop events
if (settings.updateURL && settings.popstate) {
window.addEventListener('popstate', popstateHandler, false);
}
};
//
// Initialize plugin
//
smoothScroll.init(options);
//
// Public APIs
//
return smoothScroll;
};
return SmoothScroll;
}));
/* GP */
var gpscroll = new SmoothScroll( gpSmoothScroll.elements.join(), {
speed: gpSmoothScroll.duration,
offset: function( anchor, toggle ) {
var body = document.body,
nav = document.querySelector( '#site-navigation' ),
stickyNav = document.querySelector( '#sticky-navigation' ),
mobileHeader = document.querySelector( '#mobile-header' ),
menuToggle = document.querySelector( '.menu-toggle' ),
offset = 0;
if ( mobileHeader && ( mobileHeader.offsetWidth || mobileHeader.offsetHeight || mobileHeader.getClientRects().length ) ) {
if ( body.classList.contains( 'mobile-header-sticky' ) ) {
offset = offset + mobileHeader.clientHeight;
}
} else if ( menuToggle && ( menuToggle.offsetWidth || menuToggle.offsetHeight || menuToggle.getClientRects().length ) ) {
if ( body.classList.contains( 'both-sticky-menu' ) || body.classList.contains( 'mobile-sticky-menu' ) ) {
if ( stickyNav ) {
offset = offset + stickyNav.clientHeight;
} else if ( nav ) {
offset = offset + nav.clientHeight;
}
}
} else if ( body.classList.contains( 'both-sticky-menu' ) || body.classList.contains( 'desktop-sticky-menu' ) ) {
if ( stickyNav ) {
offset = offset + stickyNav.clientHeight;
} else if ( nav ) {
offset = offset + nav.clientHeight;
}
}
return gpSmoothScroll.offset
? gpSmoothScroll.offset
: offset;
}
} );

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,103 @@
<?php
/**
* This file handles the smooth scroll functionality.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
add_action( 'wp_enqueue_scripts', 'generate_smooth_scroll_scripts' );
/**
* Add the smooth scroll script if enabled.
*
* @since 1.6
*/
function generate_smooth_scroll_scripts() {
if ( ! function_exists( 'generate_get_defaults' ) ) {
return;
}
$settings = wp_parse_args(
get_option( 'generate_settings', array() ),
generate_get_defaults()
);
if ( ! $settings['smooth_scroll'] ) {
return;
}
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
wp_enqueue_script( 'generate-smooth-scroll', plugin_dir_url( __FILE__ ) . "js/smooth-scroll{$suffix}.js", array(), GP_PREMIUM_VERSION, true );
wp_localize_script(
'generate-smooth-scroll',
'gpSmoothScroll',
array(
'elements' => apply_filters(
'generate_smooth_scroll_elements',
array(
'.smooth-scroll',
'li.smooth-scroll a',
)
),
'duration' => apply_filters( 'generate_smooth_scroll_duration', 800 ),
'offset' => apply_filters( 'generate_smooth_scroll_offset', '' ),
)
);
}
add_filter( 'generate_option_defaults', 'generate_smooth_scroll_default' );
/**
* Add the smooth scroll option to our defaults.
*
* @since 1.6
*
* @param array $defaults Existing defaults.
* @return array New defaults.
*/
function generate_smooth_scroll_default( $defaults ) {
$defaults['smooth_scroll'] = false;
return $defaults;
}
add_action( 'customize_register', 'generate_smooth_scroll_customizer', 99 );
/**
* Add our smooth scroll option to the Customizer.
*
* @since 1.6
*
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
*/
function generate_smooth_scroll_customizer( $wp_customize ) {
if ( ! function_exists( 'generate_get_defaults' ) ) {
return;
}
$defaults = generate_get_defaults();
require_once GP_LIBRARY_DIRECTORY . 'customizer-helpers.php';
$wp_customize->add_setting(
'generate_settings[smooth_scroll]',
array(
'default' => $defaults['smooth_scroll'],
'type' => 'option',
'sanitize_callback' => 'generate_premium_sanitize_checkbox',
)
);
$wp_customize->add_control(
'generate_settings[smooth_scroll]',
array(
'type' => 'checkbox',
'label' => __( 'Smooth scroll', 'gp-premium' ),
'description' => __( 'Initiate smooth scroll on anchor links using the <code>smooth-scroll</code> class.', 'gp-premium' ),
'section' => 'generate_general_section',
)
);
}

View File

@ -0,0 +1,307 @@
<?php
/**
* Plugin Name: GP Premium
* Plugin URI: https://generatepress.com
* Description: The entire collection of GeneratePress premium modules.
* Version: 2.4.0
* Requires at least: 5.2
* Requires PHP: 7.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.
}
define( 'GP_PREMIUM_VERSION', '2.4.0' );
define( 'GP_PREMIUM_DIR_PATH', plugin_dir_path( __FILE__ ) );
define( 'GP_PREMIUM_DIR_URL', plugin_dir_url( __FILE__ ) );
define( 'GP_LIBRARY_DIRECTORY', plugin_dir_path( __FILE__ ) . 'library/' );
define( 'GP_LIBRARY_DIRECTORY_URL', plugin_dir_url( __FILE__ ) . 'library/' );
require_once GP_PREMIUM_DIR_PATH . 'inc/class-rest.php';
if ( ! function_exists( 'generatepress_is_module_active' ) ) {
/**
* 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, $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( $constant ) ) {
return true;
}
// Not active? Return false.
return false;
}
}
if ( ! function_exists( 'generate_package_setup' ) ) {
add_action( 'plugins_loaded', 'generate_package_setup' );
/**
* Set up our translations
**/
function generate_package_setup() {
load_plugin_textdomain( 'gp-premium', false, 'gp-premium/langs/' );
}
}
if ( generatepress_is_module_active( 'generate_package_backgrounds', 'GENERATE_BACKGROUNDS' ) ) {
require_once GP_PREMIUM_DIR_PATH . 'backgrounds/generate-backgrounds.php';
}
if ( generatepress_is_module_active( 'generate_package_blog', 'GENERATE_BLOG' ) ) {
require_once GP_PREMIUM_DIR_PATH . 'blog/generate-blog.php';
}
if ( generatepress_is_module_active( 'generate_package_copyright', 'GENERATE_COPYRIGHT' ) ) {
require_once GP_PREMIUM_DIR_PATH . 'copyright/generate-copyright.php';
}
if ( generatepress_is_module_active( 'generate_package_disable_elements', 'GENERATE_DISABLE_ELEMENTS' ) ) {
require_once GP_PREMIUM_DIR_PATH . 'disable-elements/generate-disable-elements.php';
}
if ( generatepress_is_module_active( 'generate_package_elements', 'GENERATE_ELEMENTS' ) ) {
require_once GP_PREMIUM_DIR_PATH . 'elements/elements.php';
}
if ( generatepress_is_module_active( 'generate_package_secondary_nav', 'GENERATE_SECONDARY_NAV' ) ) {
require_once GP_PREMIUM_DIR_PATH . 'secondary-nav/generate-secondary-nav.php';
}
if ( generatepress_is_module_active( 'generate_package_spacing', 'GENERATE_SPACING' ) ) {
require_once GP_PREMIUM_DIR_PATH . 'spacing/generate-spacing.php';
}
if ( generatepress_is_module_active( 'generate_package_menu_plus', 'GENERATE_MENU_PLUS' ) ) {
require_once GP_PREMIUM_DIR_PATH . 'menu-plus/generate-menu-plus.php';
}
if ( generatepress_is_module_active( 'generate_package_woocommerce', 'GENERATE_WOOCOMMERCE' ) ) {
include_once ABSPATH . 'wp-admin/includes/plugin.php';
if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
require_once GP_PREMIUM_DIR_PATH . 'woocommerce/woocommerce.php';
}
}
// Deprecated modules.
if ( generatepress_is_module_active( 'generate_package_hooks', 'GENERATE_HOOKS' ) ) {
require_once GP_PREMIUM_DIR_PATH . 'hooks/generate-hooks.php';
}
if ( generatepress_is_module_active( 'generate_package_page_header', 'GENERATE_PAGE_HEADER' ) ) {
require_once GP_PREMIUM_DIR_PATH . 'page-header/generate-page-header.php';
}
if ( generatepress_is_module_active( 'generate_package_sections', 'GENERATE_SECTIONS' ) ) {
require_once GP_PREMIUM_DIR_PATH . 'sections/generate-sections.php';
}
add_action( 'after_setup_theme', 'generate_premium_load_modules' );
/**
* Load our modules after the theme has initiated.
*
* @since 2.1.0
*/
function generate_premium_load_modules() {
$is_using_dynamic_typography = function_exists( 'generate_is_using_dynamic_typography' ) && generate_is_using_dynamic_typography();
if ( ! $is_using_dynamic_typography && generatepress_is_module_active( 'generate_package_typography', 'GENERATE_TYPOGRAPHY' ) ) {
require_once GP_PREMIUM_DIR_PATH . 'typography/generate-fonts.php';
}
if ( version_compare( generate_premium_get_theme_version(), '3.1.0-alpha.1', '<' ) && generatepress_is_module_active( 'generate_package_colors', 'GENERATE_COLORS' ) ) {
require_once GP_PREMIUM_DIR_PATH . 'colors/generate-colors.php';
}
}
// 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 . 'general/enqueue-scripts.php';
require_once GP_PREMIUM_DIR_PATH . 'inc/deprecated.php';
// Load our Dashboard functions once the theme has loaded.
require_once GP_PREMIUM_DIR_PATH . 'inc/class-dashboard.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 GP_PREMIUM_DIR_PATH . 'site-library/class-site-library-rest.php';
require_once GP_PREMIUM_DIR_PATH . 'site-library/class-site-library-helper.php';
}
if ( is_admin() ) {
require_once GP_PREMIUM_DIR_PATH . 'inc/deprecated-admin.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 GP_PREMIUM_DIR_PATH . 'site-library/class-site-library.php';
}
}
if ( ! function_exists( 'generate_premium_updater' ) ) {
add_action( 'admin_init', 'generate_premium_updater', 0 );
/**
* Set up the updater
**/
function generate_premium_updater() {
if ( ! class_exists( 'GeneratePress_Premium_Plugin_Updater' ) ) {
include GP_PREMIUM_DIR_PATH . 'library/class-plugin-updater.php';
}
$license_key = get_option( 'gen_premium_license_key' );
$edd_updater = new GeneratePress_Premium_Plugin_Updater(
'https://generatepress.com',
__FILE__,
array(
'version' => GP_PREMIUM_VERSION,
'license' => trim( $license_key ),
'item_name' => 'GP Premium',
'author' => 'Tom Usborne',
'url' => home_url(),
'beta' => apply_filters( 'generate_premium_beta_tester', false ),
)
);
}
}
add_filter( 'edd_sl_plugin_updater_api_params', 'generate_premium_set_updater_api_params', 10, 3 );
/**
* Add the GeneratePress version to our updater params.
*
* @param array $api_params The array of data sent in the request.
* @param array $api_data The array of data set up in the class constructor.
* @param string $plugin_file The full path and filename of the file.
*/
function generate_premium_set_updater_api_params( $api_params, $api_data, $plugin_file ) {
/*
* Make sure $plugin_file matches your plugin's file path. You should have a constant for this
* or can use __FILE__ if this code goes in your plugin's main file.
*/
if ( __FILE__ === $plugin_file ) {
// Dynamically retrieve the current version number.
$api_params['generatepress_version'] = defined( 'GENERATE_VERSION' ) ? GENERATE_VERSION : '';
}
return $api_params;
}
if ( ! function_exists( 'generate_premium_setup' ) ) {
add_action( 'after_setup_theme', 'generate_premium_setup' );
/**
* Add useful functions to GP Premium
**/
function generate_premium_setup() {
// This used to be in the theme but the WP.org review team asked for it to be removed.
// Not wanting people to have broken shortcodes in their widgets on update, I added it into premium.
add_filter( 'widget_text', 'do_shortcode' );
}
}
if ( ! function_exists( 'generate_premium_theme_information' ) ) {
add_action( 'admin_notices', 'generate_premium_theme_information' );
/**
* Checks whether there's a theme update available and lets you know.
* Also checks to see if GeneratePress is the active theme. If not, tell them.
*
* @since 1.2.95
**/
function generate_premium_theme_information() {
$theme = wp_get_theme();
if ( 'GeneratePress' === $theme->name || 'generatepress' === $theme->template ) {
// 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' );
if ( isset( $updates_transient->response ) ) {
$updates = $updates_transient->response;
}
}
$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 ) {
printf(
'<div class="notice is-dismissible notice-info">
<p>%1$s <a href="%2$s">%3$s</a></p>
</div>',
esc_html__( 'GeneratePress has an update available.', 'gp-premium' ),
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">
<p>%1$s <a href="%3$s">%2$s</a></p>
</div>',
esc_html__( 'GP Premium requires GeneratePress to be your active theme.', 'gp-premium' ),
esc_html__( 'Install now.', 'gp-premium' ),
esc_url( admin_url( 'theme-install.php?theme=generatepress' ) )
);
}
}
}
add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'generate_add_configure_action_link' );
/**
* 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 ) );
}
add_action( 'admin_init', 'generatepress_deactivate_standalone_addons' );
/**
* Deactivate any standalone add-ons if they're active.
*
* @since 1.3.1
*/
function generatepress_deactivate_standalone_addons() {
$addons = array(
'generate-backgrounds/generate-backgrounds.php',
'generate-blog/generate-blog.php',
'generate-colors/generate-colors.php',
'generate-copyright/generate-copyright.php',
'generate-disable-elements/generate-disable-elements.php',
'generate-hooks/generate-hooks.php',
'generate-ie/generate-ie.php',
'generate-menu-plus/generate-menu-plus.php',
'generate-page-header/generate-page-header.php',
'generate-secondary-nav/generate-secondary-nav.php',
'generate-sections/generate-sections.php',
'generate-spacing/generate-spacing.php',
'generate-typography/generate-fonts.php',
);
deactivate_plugins( $addons );
}

View File

@ -0,0 +1,59 @@
#gp_hooks_settings .form-table td,
#gp_hooks_settings .form-table th {
padding: 30px;
background: #FFF;
display: block;
width: 100%;
box-sizing: border-box;
margin-bottom: 0;
}
#gp_hooks_settings .form-table th {
padding-bottom: 0;
}
#gp_hooks_settings .form-table tr {
margin-bottom: 20px;
display: block;
max-width: 100%;
border: 1px solid #e5e5e5;
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
box-sizing: border-box;
}
.execute, div.disable {
background: none repeat scroll 0 0 #f1f1f1;
display: inline-block;
padding: 10px;
font-size: 14px;
}
.admin-bar #gp_hooks_settings .sticky-scroll-box.fixed {
top: 52px;
}
#gp_hooks_settings .sticky-scroll-box.fixed {
position: fixed;
right: 18px;
top: 20px;
}
.rtl #gp_hooks_settings .sticky-scroll-box.fixed {
position: fixed;
left: 18px;
right: auto;
}
#gp_hooks_settings input[type="checkbox"] {
margin-top: 1px;
margin-right: 0px;
}
#gp_hooks_settings .form-table {
margin-top: 0;
}
.appearance_page_gp_hooks_settings #setting-error-true {
margin-left: 2px;
margin-right: 19px;
margin-top: 20px;
}

View File

@ -0,0 +1,38 @@
jQuery(document).ready(function($) {
jQuery('#hook-dropdown').on('change', function() {
var id = jQuery(this).children(":selected").attr("id");
jQuery('#gp_hooks_settings .form-table tr').hide();
jQuery('#gp_hooks_settings .form-table tr').eq(id).show();
Cookies.set('remember_hook', $('#hook-dropdown option:selected').attr('id'), { expires: 90, path: '/'});
if ( jQuery('#hook-dropdown').val() == 'all' ) {
$('#gp_hooks_settings .form-table tr').show();
Cookies.set('remember_hook', 'none', { expires: 90, path: '/'});
}
});
//checks if the cookie has been set
if( Cookies.get('remember_hook') === null || Cookies.get('remember_hook') === "" || Cookies.get('remember_hook') === "null" || Cookies.get('remember_hook') === "none" || Cookies.get('remember_hook') === undefined )
{
$('#gp_hooks_settings .form-table tr').show();
Cookies.set('remember_hook', 'none', { expires: 90, path: '/'});
} else {
$('#hook-dropdown option[id="' + Cookies.get('remember_hook') + '"]').attr('selected', 'selected');
$('#gp_hooks_settings .form-table tr').hide();
$('#gp_hooks_settings .form-table tr').eq(Cookies.get('remember_hook')).show();
}
var top = $('.sticky-scroll-box').offset().top;
$(window).scroll(function (event) {
var y = $(this).scrollTop();
if (y >= top)
$('.sticky-scroll-box').addClass('fixed');
else
$('.sticky-scroll-box').removeClass('fixed');
$('.sticky-scroll-box').width($('.sticky-scroll-box').parent().width());
});
});

View File

@ -0,0 +1,165 @@
/*!
* JavaScript Cookie v2.1.3
* https://github.com/js-cookie/js-cookie
*
* Copyright 2006, 2015 Klaus Hartl & Fagner Brack
* Released under the MIT license
*/
;(function (factory) {
var registeredInModuleLoader = false;
if (typeof define === 'function' && define.amd) {
define(factory);
registeredInModuleLoader = true;
}
if (typeof exports === 'object') {
module.exports = factory();
registeredInModuleLoader = true;
}
if (!registeredInModuleLoader) {
var OldCookies = window.Cookies;
var api = window.Cookies = factory();
api.noConflict = function () {
window.Cookies = OldCookies;
return api;
};
}
}(function () {
function extend () {
var i = 0;
var result = {};
for (; i < arguments.length; i++) {
var attributes = arguments[ i ];
for (var key in attributes) {
result[key] = attributes[key];
}
}
return result;
}
function init (converter) {
function api (key, value, attributes) {
var result;
if (typeof document === 'undefined') {
return;
}
// Write
if (arguments.length > 1) {
attributes = extend({
path: '/'
}, api.defaults, attributes);
if (typeof attributes.expires === 'number') {
var expires = new Date();
expires.setMilliseconds(expires.getMilliseconds() + attributes.expires * 864e+5);
attributes.expires = expires;
}
// We're using "expires" because "max-age" is not supported by IE
attributes.expires = attributes.expires ? attributes.expires.toUTCString() : '';
try {
result = JSON.stringify(value);
if (/^[\{\[]/.test(result)) {
value = result;
}
} catch (e) {}
if (!converter.write) {
value = encodeURIComponent(String(value))
.replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g, decodeURIComponent);
} else {
value = converter.write(value, key);
}
key = encodeURIComponent(String(key));
key = key.replace(/%(23|24|26|2B|5E|60|7C)/g, decodeURIComponent);
key = key.replace(/[\(\)]/g, escape);
var stringifiedAttributes = '';
for (var attributeName in attributes) {
if (!attributes[attributeName]) {
continue;
}
stringifiedAttributes += '; ' + attributeName;
if (attributes[attributeName] === true) {
continue;
}
stringifiedAttributes += '=' + attributes[attributeName];
}
return (document.cookie = key + '=' + value + stringifiedAttributes);
}
// Read
if (!key) {
result = {};
}
// To prevent the for loop in the first place assign an empty array
// in case there are no cookies at all. Also prevents odd result when
// calling "get()"
var cookies = document.cookie ? document.cookie.split('; ') : [];
var rdecode = /(%[0-9A-Z]{2})+/g;
var i = 0;
for (; i < cookies.length; i++) {
var parts = cookies[i].split('=');
var cookie = parts.slice(1).join('=');
if (cookie.charAt(0) === '"') {
cookie = cookie.slice(1, -1);
}
try {
var name = parts[0].replace(rdecode, decodeURIComponent);
cookie = converter.read ?
converter.read(cookie, name) : converter(cookie, name) ||
cookie.replace(rdecode, decodeURIComponent);
if (this.json) {
try {
cookie = JSON.parse(cookie);
} catch (e) {}
}
if (key === name) {
result = cookie;
break;
}
if (!key) {
result[name] = cookie;
}
} catch (e) {}
}
return result;
}
api.set = api;
api.get = function (key) {
return api.call(api, key);
};
api.getJSON = function () {
return api.apply({
json: true
}, [].slice.call(arguments));
};
api.defaults = {};
api.remove = function (key, attributes) {
api(key, '', extend(attributes, {
expires: -1
}));
};
api.withConverter = init;
return api;
}
return init(function () {});
}));

View File

@ -0,0 +1,542 @@
<?php
/**
* This file handles the legacy hook system.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
// 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',
'generate_wp_head',
'generate_before_header_php',
'generate_before_header',
'generate_before_header_content_php',
'generate_before_header_content',
'generate_after_header_content_php',
'generate_after_header_content',
'generate_after_header_php',
'generate_after_header',
'generate_before_main_content_php',
'generate_before_main_content',
'generate_before_content_php',
'generate_before_content',
'generate_after_entry_header_php',
'generate_after_entry_header',
'generate_after_content_php',
'generate_after_content',
'generate_before_right_sidebar_content_php',
'generate_before_right_sidebar_content',
'generate_after_right_sidebar_content_php',
'generate_after_right_sidebar_content',
'generate_before_left_sidebar_content_php',
'generate_before_left_sidebar_content',
'generate_after_left_sidebar_content_php',
'generate_after_left_sidebar_content',
'generate_before_footer_php',
'generate_before_footer',
'generate_after_footer_widgets_php',
'generate_after_footer_widgets',
'generate_before_footer_content_php',
'generate_before_footer_content',
'generate_after_footer_content_php',
'generate_after_footer_content',
'generate_wp_footer_php',
'generate_wp_footer',
);
return $hooks;
}
}
if ( ! function_exists( 'generate_hooks_php_check' ) ) {
add_action( 'admin_notices', 'generate_hooks_php_check' );
/**
* Checks if DISALLOW_FILE_EDIT is defined.
* If it is, tell the user to disallow PHP execution in GP Hooks.
*
* @since 1.3.1
*/
function generate_hooks_php_check() {
if ( defined( 'DISALLOW_FILE_EDIT' ) && DISALLOW_FILE_EDIT && ! defined( 'GENERATE_HOOKS_DISALLOW_PHP' ) && current_user_can( 'manage_options' ) ) {
printf(
'<div class="notice notice-error">
<p>%1$s <a href="https://docs.generatepress.com/article/disallow-php-execution/" target="_blank">%2$s</a></p>
</div>',
esc_html__( 'DISALLOW_FILE_EDIT is defined. You should also disallow PHP execution in GP Hooks.', 'gp-premium' ),
esc_html__( 'Learn how', 'gp-premium' )
);
}
}
}
if ( ! function_exists( 'generate_hooks_setup' ) ) {
function generate_hooks_setup() {
// Just to verify that we're activated.
}
}
if ( ! class_exists( 'Generate_Hooks_Settings' ) ) {
class Generate_Hooks_Settings {
private $dir;
private $file;
private $assets_dir;
private $assets_url;
private $settings_base;
private $settings;
public function __construct( $file ) {
$this->file = $file;
$this->dir = dirname( $this->file );
$this->assets_dir = trailingslashit( $this->dir ) . 'assets';
$this->assets_url = esc_url( trailingslashit( plugins_url( '/assets/', $this->file ) ) );
$this->settings_base = '';
// Initialise settings
add_action( 'admin_init', array( $this, 'init' ) );
// Register plugin settings
add_action( 'admin_init' , array( $this, 'register_settings' ) );
// Add settings page to menu
add_action( 'admin_menu' , array( $this, 'add_menu_item' ) );
// Add settings link to plugins page
add_filter( 'plugin_action_links_' . plugin_basename( $this->file ) , array( $this, 'add_settings_link' ) );
}
/**
* Initialise settings
* @return void
*/
public function init() {
$this->settings = $this->settings_fields();
}
/**
* Add settings page to admin menu
* @return void
*/
public function add_menu_item() {
$page = add_theme_page( __( 'GP Hooks', 'gp-premium' ) , __( 'GP Hooks', 'gp-premium' ) , apply_filters( 'generate_hooks_capability','manage_options' ) , 'gp_hooks_settings' , array( $this, 'settings_page' ) );
add_action( 'admin_print_styles-' . $page, array( $this, 'settings_assets' ) );
}
/**
* Load settings JS & CSS
* @return void
*/
public function settings_assets() {
wp_enqueue_script( 'gp-cookie', $this->assets_url . 'js/jquery.cookie.js', array( 'jquery' ), GENERATE_HOOKS_VERSION );
wp_enqueue_script( 'gp-hooks', $this->assets_url . 'js/admin.js', array( 'jquery', 'gp-cookie' ), GENERATE_HOOKS_VERSION );
wp_enqueue_style( 'gp-hooks', $this->assets_url . 'css/hooks.css' );
}
/**
* Add settings link to plugin list table
* @param array $links Existing links
* @return array Modified links
*/
public function add_settings_link( $links ) {
$settings_link = '<a href="options-general.php?page=gp_hooks_settings">' . __( 'GP Hooks', 'gp-premium' ) . '</a>';
array_push( $links, $settings_link );
return $links;
}
/**
* Build settings fields
* @return array Fields to be displayed on settings page
*/
private function settings_fields() {
$settings['standard'] = array(
'title' => '',
'description' => '',
'fields' => array(
array(
"name" => __( 'wp_head', 'gp-premium' ),
"id" => 'generate_wp_head',
"type" => 'textarea'
),
array(
"name" => __( 'Before Header', 'gp-premium' ),
"id" => 'generate_before_header',
"type" => 'textarea'
),
array(
"name" => __( 'Before Header Content', 'gp-premium' ),
"id" => 'generate_before_header_content',
"type" => 'textarea'
),
array(
"name" => __( 'After Header Content', 'gp-premium' ),
"id" => 'generate_after_header_content',
"type" => 'textarea'
),
array(
"name" => __( 'After Header', 'gp-premium' ),
"id" => 'generate_after_header',
"type" => 'textarea'
),
array(
"name" => __( 'Inside Content Container', 'gp-premium' ),
"id" => 'generate_before_main_content',
"type" => 'textarea'
),
array(
"name" => __( 'Before Content', 'gp-premium' ),
"id" => 'generate_before_content',
"type" => 'textarea'
),
array(
"name" => __( 'After Entry Title', 'gp-premium' ),
"id" => 'generate_after_entry_header',
"type" => 'textarea'
),
array(
"name" => __( 'After Content', 'gp-premium' ),
"id" => 'generate_after_content',
"type" => 'textarea'
),
array(
"name" => __( 'Before Right Sidebar Content', 'gp-premium' ),
"id" => 'generate_before_right_sidebar_content',
"type" => 'textarea'
),
array(
"name" => __( 'After Right Sidebar Content', 'gp-premium' ),
"id" => 'generate_after_right_sidebar_content',
"type" => 'textarea'
),
array(
"name" => __( 'Before Left Sidebar Content', 'gp-premium' ),
"id" => 'generate_before_left_sidebar_content',
"type" => 'textarea'
),
array(
"name" => __( 'After Left Sidebar Content', 'gp-premium' ),
"id" => 'generate_after_left_sidebar_content',
"type" => 'textarea'
),
array(
"name" => __( 'Before Footer', 'gp-premium' ),
"id" => 'generate_before_footer',
"type" => 'textarea'
),
array(
"name" => __( 'After Footer Widgets', 'gp-premium' ),
"id" => 'generate_after_footer_widgets',
"type" => 'textarea'
),
array(
"name" => __( 'Before Footer Content', 'gp-premium' ),
"id" => 'generate_before_footer_content',
"type" => 'textarea'
),
array(
"name" => __( 'After Footer Content', 'gp-premium' ),
"id" => 'generate_after_footer_content',
"type" => 'textarea'
),
array(
"name" => __( 'wp_footer', 'gp-premium' ),
"id" => 'generate_wp_footer',
"type" => 'textarea'
)
)
);
$settings = apply_filters( 'gp_hooks_settings_fields', $settings );
return $settings;
}
/**
* Register plugin settings
* @return void
*/
public function register_settings() {
if ( is_array( $this->settings ) ) {
foreach( $this->settings as $section => $data ) {
// Add section to page
add_settings_section( $section, $data['title'], array( $this, 'settings_section' ), 'gp_hooks_settings' );
foreach( $data['fields'] as $field ) {
// Sanitizing isn't possible, as hooks allow any HTML, JS or PHP to be added.
// Allowing PHP can be a security issue if you have admin users who you don't trust.
// In that case, you can disable the ability to add PHP in hooks like this: define( 'GENERATE_HOOKS_DISALLOW_PHP', true );
$validation = '';
if( isset( $field['callback'] ) ) {
$validation = $field['callback'];
}
// Register field
$option_name = $this->settings_base . $field['id'];
register_setting( 'gp_hooks_settings', 'generate_hooks', $validation );
// Add field to page
add_settings_field( 'generate_hooks[' . $field['id'] . ']', $field['name'], array( $this, 'display_field' ), 'gp_hooks_settings', $section, array( 'field' => $field ) );
}
}
}
}
public function settings_section( $section ) {
$html = '';
echo $html;
}
/**
* Generate HTML for displaying fields
* @param array $args Field data
* @return void
*/
public function display_field( $args ) {
$field = $args['field'];
$html = '';
$option_name = $this->settings_base . $field['id'];
$option = get_option( 'generate_hooks' );
$data = '';
if( isset( $option[$option_name] ) ) {
$data = $option[$option_name];
} elseif( isset( $field['default'] ) ) {
$data = $field['default'];
}
switch( $field['type'] ) {
case 'textarea':
$checked = '';
$checked2 = '';
if( isset( $option[$field['id'] . '_php'] ) && 'true' == $option[$field['id'] . '_php'] ){
$checked = 'checked="checked"';
}
if( isset( $option[$field['id'] . '_disable'] ) && 'true' == $option[$field['id'] . '_disable'] ){
$checked2 = 'checked="checked"';
}
$html .= '<textarea autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false" id="generate_hooks[' . esc_attr( $field['id'] ) . ']" name="generate_hooks[' . esc_attr( $field['id'] ) . ']" style="width:100%;height:200px;" cols="" rows="">' . esc_textarea( $data ) . '</textarea>';
if ( ! defined( 'GENERATE_HOOKS_DISALLOW_PHP' ) ) {
$html .= '<div class="execute"><input type="checkbox" name="generate_hooks[' . esc_attr( $field['id'] ) . '_php]" id="generate_hooks[' . esc_attr( $field['id'] ) . '_php]" value="true" ' . $checked . ' /> <label for="generate_hooks[' . esc_attr( $field['id'] ) . '_php]">' . __( 'Execute PHP', 'gp-premium' ) . '</label></div>';
}
$html .= '<div class="disable"><input type="checkbox" name="generate_hooks[' . esc_attr( $field['id'] ) . '_disable]" id="generate_hooks[' . esc_attr( $field['id'] ) . '_disable]" value="true" ' . $checked2 . ' /> <label for="generate_hooks[' . esc_attr( $field['id'] ) . '_disable]" class="disable">' . __( 'Disable Hook', 'gp-premium' ) . '</label></div>';
break;
case 'checkbox':
break;
}
echo $html;
}
/**
* Validate individual settings field
* @param string $data Inputted value
* @return string Validated value
*/
public function validate_field( $data ) {
if ( $data && strlen( $data ) > 0 && $data != '' ) {
$data = urlencode( strtolower( str_replace( ' ' , '-' , $data ) ) );
}
return $data;
}
/**
* Load settings page content
* @return void
*/
public function settings_page() {
// Build page HTML
$html = '<div class="wrap" id="gp_hooks_settings">';
$html .= '<div id="poststuff">';
$html .= '<div class="metabox-holder columns-2" id="post-body">';
$html .= '<form method="post" action="options.php" enctype="multipart/form-data">';
$html .= '<div id="post-body-content">';
// Get settings fields
ob_start();
settings_fields( 'gp_hooks_settings' );
do_settings_sections( 'gp_hooks_settings' );
$html .= ob_get_clean();
$html .= '</div>';
$html .= '<div id="postbox-container-1">';
$html .= '<div class="postbox sticky-scroll-box">';
$html .= '<h3 class="hndle">' . __( 'GP Hooks', 'gp-premium' ) . '</h3>';
$html .= '<div class="inside">';
$html .= '<p>' . __( 'Use these fields to insert anything you like throughout GeneratePress. Shortcodes are allowed, and you can even use PHP if you check the Execute PHP checkboxes.', 'gp-premium' ) . '</p>';
$html .= '<select id="hook-dropdown" style="margin-top:20px;">';
$html .= '<option value="all">' . __( 'Show all', 'gp-premium' ) . '</option>';
if( is_array( $this->settings ) ) {
foreach( $this->settings as $section => $data ) {
$count = 0;
foreach( $data['fields'] as $field ) {
$html .= '<option id="' . $count++ . '">' . $field['name'] . '</option>';
}
}
}
$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', 'gp-premium' ) ) . '" />';
$html .= '</p>';
$html .= '</div>';
$html .= '</div>';
$html .= '</div>';
$html .= '</form>';
$html .= '</div>';
$html .= '<br class="clear" />';
$html .= '</div>';
$html .= '</div>';
echo $html;
}
}
$settings = new Generate_Hooks_Settings( __FILE__ );
}
if ( ! function_exists( 'generate_update_hooks' ) ) {
add_action( 'admin_init', 'generate_update_hooks' );
/**
* Moving standalone db entries to generate_hooks db entry
*/
function generate_update_hooks() {
$generate_hooks = get_option( 'generate_hooks' );
// If we've done this before, bail
if ( ! empty( $generate_hooks ) ) {
return;
}
// One last check
if ( 'true' == $generate_hooks['updated'] ) {
return;
}
$hooks = generate_hooks_get_hooks();
$generate_new_hooks = array();
foreach ( $hooks as $hook ) {
$current_hook = get_option( $hook );
if ( isset( $current_hook ) && '' !== $current_hook ) {
$generate_new_hooks[ $hook ] = get_option( $hook );
$generate_new_hooks[ 'updated' ] = 'true';
// Let's not delete the old options yet, just in case
//delete_option( $hook );
}
}
$generate_new_hook_settings = wp_parse_args( $generate_new_hooks, $generate_hooks );
update_option( 'generate_hooks', $generate_new_hook_settings );
}
}
if ( ! function_exists( 'generate_hooks_admin_errors' ) ) {
add_action( 'admin_notices', 'generate_hooks_admin_errors' );
/**
* Add our admin notices
*/
function generate_hooks_admin_errors() {
$screen = get_current_screen();
if ( 'appearance_page_gp_hooks_settings' !== $screen->base ) {
return;
}
if ( isset( $_GET['settings-updated'] ) && 'true' == $_GET['settings-updated'] ) {
add_settings_error( 'generate-hook-notices', 'true', __( 'Hooks saved.', 'gp-premium' ), 'updated' );
}
settings_errors( 'generate-hook-notices' );
}
}
add_action( 'admin_head', 'generate_old_gp_hooks_fix_menu' );
/**
* Set our current menu in the admin while in the old Page Header pages.
*
* @since 1.7
*/
function generate_old_gp_hooks_fix_menu() {
if ( ! function_exists( 'generate_premium_do_elements' ) ) {
return;
}
global $parent_file, $submenu_file, $post_type;
$screen = get_current_screen();
if ( 'appearance_page_gp_hooks_settings' === $screen->base ) {
$parent_file = 'themes.php';
$submenu_file = 'edit.php?post_type=gp_elements';
}
remove_submenu_page( 'themes.php', 'gp_hooks_settings' );
}
add_action( 'admin_head', 'generate_hooks_add_legacy_button', 999 );
/**
* Add legacy buttons to our new GP Elements post type.
*
* @since 1.7
*/
function generate_hooks_add_legacy_button() {
if ( ! function_exists( 'generate_premium_do_elements' ) ) {
return;
}
$screen = get_current_screen();
if ( 'gp_elements' === $screen->post_type && 'edit' === $screen->base ) :
?>
<script>
jQuery( function( $ ) {
$( '<a href="<?php echo admin_url(); ?>themes.php?page=gp_hooks_settings" class="page-title-action legacy-button"><?php esc_html_e( "Legacy Hooks", "gp-premium" ); ?></a>' ).insertAfter( '.page-title-action:not(.legacy-button)' );
} );
</script>
<?php
endif;
}

View File

@ -0,0 +1,171 @@
<?php
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! function_exists( 'generate_execute_hooks' ) ) {
function generate_execute_hooks( $id ) {
$hooks = get_option( 'generate_hooks' );
$content = isset( $hooks[$id] ) ? $hooks[$id] : null;
$disable = isset( $hooks[$id . '_disable'] ) ? $hooks[$id . '_disable'] : null;
if ( ! $content || 'true' == $disable ) {
return;
}
$php = isset( $hooks[$id . '_php'] ) ? $hooks[$id . '_php'] : null;
$value = do_shortcode( $content );
if ( 'true' == $php && ! defined( 'GENERATE_HOOKS_DISALLOW_PHP' ) ) {
eval( "?>$value<?php " );
} else {
echo $value;
}
}
}
if ( ! function_exists( 'generate_hooks_wp_head' ) ) {
add_action( 'wp_head', 'generate_hooks_wp_head' );
function generate_hooks_wp_head() {
generate_execute_hooks( 'generate_wp_head' );
}
}
if ( ! function_exists( 'generate_hooks_before_header' ) ) {
add_action( 'generate_before_header', 'generate_hooks_before_header', 4 );
function generate_hooks_before_header() {
generate_execute_hooks( 'generate_before_header' );
}
}
if ( ! function_exists( 'generate_hooks_before_header_content' ) ) {
add_action( 'generate_before_header_content', 'generate_hooks_before_header_content' );
function generate_hooks_before_header_content() {
generate_execute_hooks( 'generate_before_header_content' );
}
}
if ( ! function_exists( 'generate_hooks_after_header_content' ) ) {
add_action( 'generate_after_header_content', 'generate_hooks_after_header_content' );
function generate_hooks_after_header_content() {
generate_execute_hooks( 'generate_after_header_content' );
}
}
if ( ! function_exists( 'generate_hooks_after_header' ) ) {
add_action( 'generate_after_header', 'generate_hooks_after_header' );
function generate_hooks_after_header() {
generate_execute_hooks( 'generate_after_header' );
}
}
if ( ! function_exists( 'generate_hooks_inside_main_content' ) ) {
add_action( 'generate_before_main_content', 'generate_hooks_inside_main_content', 9 );
function generate_hooks_inside_main_content() {
generate_execute_hooks( 'generate_before_main_content' );
}
}
if ( ! function_exists( 'generate_hooks_before_content' ) ) {
add_action( 'generate_before_content', 'generate_hooks_before_content' );
function generate_hooks_before_content() {
generate_execute_hooks( 'generate_before_content' );
}
}
if ( ! function_exists( 'generate_hooks_after_entry_header' ) ) {
add_action( 'generate_after_entry_header', 'generate_hooks_after_entry_header' );
function generate_hooks_after_entry_header() {
generate_execute_hooks( 'generate_after_entry_header' );
}
}
if ( ! function_exists( 'generate_hooks_after_content' ) ) {
add_action( 'generate_after_content', 'generate_hooks_after_content' );
function generate_hooks_after_content() {
generate_execute_hooks( 'generate_after_content' );
}
}
if ( ! function_exists( 'generate_hooks_before_right_sidebar_content' ) ) {
add_action( 'generate_before_right_sidebar_content', 'generate_hooks_before_right_sidebar_content', 5 );
function generate_hooks_before_right_sidebar_content() {
generate_execute_hooks( 'generate_before_right_sidebar_content' );
}
}
if ( ! function_exists( 'generate_hooks_after_right_sidebar_content' ) ) {
add_action( 'generate_after_right_sidebar_content', 'generate_hooks_after_right_sidebar_content' );
function generate_hooks_after_right_sidebar_content() {
generate_execute_hooks( 'generate_after_right_sidebar_content' );
}
}
if ( ! function_exists( 'generate_hooks_before_left_sidebar_content' ) ) {
add_action( 'generate_before_left_sidebar_content', 'generate_hooks_before_left_sidebar_content', 5 );
function generate_hooks_before_left_sidebar_content() {
generate_execute_hooks( 'generate_before_left_sidebar_content' );
}
}
if ( ! function_exists( 'generate_hooks_after_left_sidebar_content' ) ) {
add_action( 'generate_after_left_sidebar_content', 'generate_hooks_after_left_sidebar_content' );
function generate_hooks_after_left_sidebar_content() {
generate_execute_hooks( 'generate_after_left_sidebar_content' );
}
}
if ( ! function_exists( 'generate_hooks_before_footer' ) ) {
add_action( 'generate_before_footer', 'generate_hooks_before_footer' );
function generate_hooks_before_footer() {
generate_execute_hooks( 'generate_before_footer' );
}
}
if ( ! function_exists( 'generate_hooks_after_footer_widgets' ) ) {
add_action( 'generate_after_footer_widgets', 'generate_hooks_after_footer_widgets' );
function generate_hooks_after_footer_widgets() {
generate_execute_hooks( 'generate_after_footer_widgets' );
}
}
if ( ! function_exists( 'generate_hooks_before_footer_content' ) ) {
add_action( 'generate_before_footer_content', 'generate_hooks_before_footer_content' );
function generate_hooks_before_footer_content() {
generate_execute_hooks( 'generate_before_footer_content' );
}
}
if ( ! function_exists( 'generate_hooks_after_footer_content' ) ) {
add_action( 'generate_after_footer_content', 'generate_hooks_after_footer_content' );
function generate_hooks_after_footer_content() {
generate_execute_hooks( 'generate_after_footer_content' );
}
}
if ( ! function_exists( 'generate_hooks_wp_footer' ) ) {
add_action( 'wp_footer', 'generate_hooks_wp_footer' );
function generate_hooks_wp_footer() {
generate_execute_hooks( 'generate_wp_footer' );
}
}

View File

@ -0,0 +1,21 @@
<?php
/**
* The legacy hooks module.
*
* @since 1.0.0
* @deprecated 1.7.0
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
// Define the version.
if ( ! defined( 'GENERATE_HOOKS_VERSION' ) ) {
define( 'GENERATE_HOOKS_VERSION', GP_PREMIUM_VERSION );
}
// Include functions identical between standalone addon and GP Premium.
require plugin_dir_path( __FILE__ ) . 'functions/functions.php';

View File

@ -0,0 +1,401 @@
<?php
/**
* Build our admin dashboard.
*
* @package GeneratePress Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* This class adds premium sections to our Dashboard.
*/
class GeneratePress_Pro_Dashboard {
/**
* Class instance.
*
* @access private
* @var $instance Class instance.
*/
private static $instance;
/**
* Initiator
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Get started.
*/
public function __construct() {
add_action( 'after_setup_theme', array( $this, 'setup' ) );
}
/**
* Add our actions and require old Dashboard files if we need them.
*/
public function setup() {
// Load our old dashboard if we're using an old version of GeneratePress.
if ( ! class_exists( 'GeneratePress_Dashboard' ) ) {
if ( is_admin() ) {
require_once GP_PREMIUM_DIR_PATH . 'inc/legacy/dashboard.php';
require_once GP_PREMIUM_DIR_PATH . 'inc/legacy/import-export.php';
require_once GP_PREMIUM_DIR_PATH . 'inc/legacy/reset.php';
require_once GP_PREMIUM_DIR_PATH . 'inc/legacy/activation.php';
}
return;
}
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
add_action( 'generate_admin_dashboard', array( $this, 'module_list' ), 8 );
add_action( 'generate_admin_dashboard', array( $this, 'license_key' ), 5 );
add_action( 'generate_admin_dashboard', array( $this, 'import_export' ), 50 );
add_action( 'generate_admin_dashboard', array( $this, 'reset' ), 100 );
add_filter( 'generate_premium_beta_tester', array( $this, 'set_beta_tester' ) );
}
/**
* Get data for all of our pro modules.
*/
public static function get_modules() {
$modules = array(
'Backgrounds' => array(
'title' => __( 'Backgrounds', 'gp-premium' ),
'description' => __( 'Set background images for various HTML elements.', 'gp-premium' ),
'key' => 'generate_package_backgrounds',
'settings' => 'generate_background_settings',
'isActive' => 'activated' === get_option( 'generate_package_backgrounds', false ),
'exportable' => true,
),
'Blog' => array(
'title' => __( 'Blog', 'gp-premium' ),
'description' => __( 'Set blog options like infinite scroll, masonry layouts and more.', 'gp-premium' ),
'key' => 'generate_package_blog',
'settings' => 'generate_blog_settings',
'isActive' => 'activated' === get_option( 'generate_package_blog', false ),
'exportable' => true,
),
'Colors' => array(
'title' => __( 'Colors', 'gp-premium' ),
'key' => 'generate_package_colors',
'isActive' => 'activated' === get_option( 'generate_package_colors', false ),
),
'Copyright' => array(
'title' => __( 'Copyright', 'gp-premium' ),
'description' => __( 'Set a custom copyright message in your footer.', 'gp-premium' ),
'key' => 'generate_package_copyright',
'settings' => 'copyright',
'isActive' => 'activated' === get_option( 'generate_package_copyright', false ),
'exportable' => true,
),
'Disable Elements' => array(
'title' => __( 'Disable Elements', 'gp-premium' ),
'description' => __( 'Disable default theme elements on specific pages or inside a Layout Element.', 'gp-premium' ),
'key' => 'generate_package_disable_elements',
'isActive' => 'activated' === get_option( 'generate_package_disable_elements', false ),
),
'Elements' => array(
'title' => __( 'Elements', 'gp-premium' ),
'description' => __( 'Use our block editor theme builder, build advanced HTML hooks, and gain more Layout control.', 'gp-premium' ),
'key' => 'generate_package_elements',
'isActive' => 'activated' === get_option( 'generate_package_elements', false ),
),
'Hooks' => array(
'title' => __( 'Hooks', 'gp-premium' ),
'description' => __( 'This module has been deprecated. Please use Elements instead.', 'gp-premium' ),
'key' => 'generate_package_hooks',
'settings' => 'generate_hooks',
'isActive' => 'activated' === get_option( 'generate_package_hooks', false ),
'exportable' => true,
),
'Menu Plus' => array(
'title' => __( 'Menu Plus', 'gp-premium' ),
'description' => __( 'Set up a mobile header, sticky navigation or off-canvas panel.', 'gp-premium' ),
'key' => 'generate_package_menu_plus',
'settings' => 'generate_menu_plus_settings',
'isActive' => 'activated' === get_option( 'generate_package_menu_plus', false ),
'exportable' => true,
),
'Page Header' => array(
'title' => __( 'Page Header', 'gp-premium' ),
'description' => __( 'This module has been deprecated. Please use Elements instead.', 'gp-premium' ),
'key' => 'generate_package_page_header',
'settings' => 'generate_page_header_settings',
'isActive' => 'activated' === get_option( 'generate_package_page_header', false ),
'exportable' => true,
),
'Secondary Nav' => array(
'title' => __( 'Secondary Nav', 'gp-premium' ),
'description' => __( 'Add a fully-featured secondary navigation to your site.', 'gp-premium' ),
'key' => 'generate_package_secondary_nav',
'settings' => 'generate_secondary_nav_settings',
'isActive' => 'activated' === get_option( 'generate_package_secondary_nav', false ),
'exportable' => true,
),
'Sections' => array(
'title' => __( 'Sections', 'gp-premium' ),
'description' => __( 'This module has been deprecated. Please consider using our GenerateBlocks plugin instead.', 'gp-premium' ),
'key' => 'generate_package_sections',
'isActive' => 'activated' === get_option( 'generate_package_sections', false ),
),
'Spacing' => array(
'title' => __( 'Spacing', 'gp-premium' ),
'description' => __( 'Set the padding and overall spacing of your theme elements.', 'gp-premium' ),
'key' => 'generate_package_spacing',
'settings' => 'generate_spacing_settings',
'isActive' => 'activated' === get_option( 'generate_package_spacing', false ),
'exportable' => true,
),
'Typography' => array(
'title' => __( 'Typography', 'gp-premium' ),
'description' => __( 'This module has been deprecated. Switch to our dynamic typography system in Customize > General instead.', 'gp-premium' ),
'key' => 'generate_package_typography',
'isActive' => 'activated' === get_option( 'generate_package_typography', false ),
),
'WooCommerce' => array(
'title' => __( 'WooCommerce', 'gp-premium' ),
'description' => __( 'Add colors, typography, and layout options to your WooCommerce store.', 'gp-premium' ),
'key' => 'generate_package_woocommerce',
'settings' => 'generate_woocommerce_settings',
'isActive' => 'activated' === get_option( 'generate_package_woocommerce', false ),
'exportable' => true,
),
);
if ( version_compare( PHP_VERSION, '5.4', '>=' ) && ! defined( 'GENERATE_DISABLE_SITE_LIBRARY' ) ) {
$modules['Site Library'] = array(
'title' => __( 'Site Library', 'gp-premium' ),
'description' => __( 'Choose from an extensive library of professionally designed starter sites.', 'gp-premium' ),
'key' => 'generate_package_site_library',
'isActive' => 'activated' === get_option( 'generate_package_site_library', false ),
);
}
if ( function_exists( 'generate_is_using_dynamic_typography' ) && generate_is_using_dynamic_typography() ) {
unset( $modules['Typography'] );
}
if ( version_compare( generate_premium_get_theme_version(), '3.1.0-alpha.1', '>=' ) ) {
unset( $modules['Colors'] );
}
$deprecated_modules = apply_filters(
'generate_premium_deprecated_modules',
array(
'Page Header',
'Hooks',
'Sections',
)
);
foreach ( $deprecated_modules as $deprecated_module ) {
if ( isset( $modules[ $deprecated_module ] ) ) {
$modules[ $deprecated_module ]['deprecated'] = true;
}
}
ksort( $modules );
return $modules;
}
/**
* Get modules that can have their settings exported and imported.
*/
public static function get_exportable_modules() {
$modules = array(
'Core' => array(
'settings' => 'generate_settings',
'title' => __( 'Core', 'gp-premium' ),
'isActive' => true,
),
);
foreach ( self::get_modules() as $key => $data ) {
if ( ! empty( $data['exportable'] ) && $data['isActive'] ) {
$modules[ $key ] = $data;
}
}
return $modules;
}
/**
* Get options using theme_mods.
*/
public static function get_theme_mods() {
$theme_mods = array(
'font_body_variants',
'font_body_category',
'font_site_title_variants',
'font_site_title_category',
'font_site_tagline_variants',
'font_site_tagline_category',
'font_navigation_variants',
'font_navigation_category',
'font_secondary_navigation_variants',
'font_secondary_navigation_category',
'font_buttons_variants',
'font_buttons_category',
'font_heading_1_variants',
'font_heading_1_category',
'font_heading_2_variants',
'font_heading_2_category',
'font_heading_3_variants',
'font_heading_3_category',
'font_heading_4_variants',
'font_heading_4_category',
'font_heading_5_variants',
'font_heading_5_category',
'font_heading_6_variants',
'font_heading_6_category',
'font_widget_title_variants',
'font_widget_title_category',
'font_footer_variants',
'font_footer_category',
'generate_copyright',
);
if ( function_exists( 'generate_is_using_dynamic_typography' ) && generate_is_using_dynamic_typography() ) {
$theme_mods = array(
'generate_copyright',
);
}
return $theme_mods;
}
/**
* Get our setting keys.
*/
public static function get_setting_keys() {
return array(
'generate_settings',
'generate_background_settings',
'generate_blog_settings',
'generate_hooks',
'generate_page_header_settings',
'generate_secondary_nav_settings',
'generate_spacing_settings',
'generate_menu_plus_settings',
'generate_woocommerce_settings',
);
}
/**
* Returns safely the license key.
*/
public static function get_license_key() {
$license_key = get_option( 'gen_premium_license_key', '' );
if ( $license_key && strlen( $license_key ) > 4 ) {
$hidden_length = strlen( $license_key ) - 4;
$safe_part = substr( $license_key, 0, 4 );
$hidden_part = implode('', array_fill( 0, $hidden_length, '*' ) );
return $safe_part . $hidden_part;
}
return $license_key;
}
/**
* Add our scripts to the page.
*/
public function enqueue_scripts() {
if ( ! class_exists( 'GeneratePress_Dashboard' ) ) {
return;
}
$dashboard_pages = GeneratePress_Dashboard::get_pages();
$current_screen = get_current_screen();
if ( in_array( $current_screen->id, $dashboard_pages ) ) {
wp_enqueue_style(
'generate-pro-dashboard',
GP_PREMIUM_DIR_URL . 'dist/style-dashboard.css',
array( 'wp-components' ),
GP_PREMIUM_VERSION
);
if ( 'appearance_page_generate-options' === $current_screen->id ) {
wp_enqueue_script(
'generate-pro-dashboard',
GP_PREMIUM_DIR_URL . 'dist/dashboard.js',
array(),
GP_PREMIUM_VERSION,
true
);
wp_set_script_translations( 'generate-pro-dashboard', 'gp-premium', GP_PREMIUM_DIR_PATH . 'langs' );
wp_localize_script(
'generate-pro-dashboard',
'generateProDashboard',
array(
'modules' => self::get_modules(),
'exportableModules' => self::get_exportable_modules(),
'siteLibraryUrl' => admin_url( 'themes.php?page=generatepress-library' ),
'elementsUrl' => admin_url( 'edit.php?post_type=gp_elements' ),
'hasWooCommerce' => class_exists( 'WooCommerce' ),
'licenseKey' => self::get_license_key(),
'licenseKeyStatus' => get_option( 'gen_premium_license_key_status', 'deactivated' ),
'betaTester' => get_option( 'gp_premium_beta_testing', false ),
)
);
}
}
}
/**
* Enable beta testing if our option is set.
*
* @since 2.1.0
* @param boolean $value Whether beta testing is on or not.
*/
public function set_beta_tester( $value ) {
if ( get_option( 'gp_premium_beta_testing', false ) ) {
return true;
}
return $value;
}
/**
* Add the container for our start customizing app.
*/
public function module_list() {
echo '<div id="generatepress-module-list"></div>';
}
/**
* Add the container for our start customizing app.
*/
public function license_key() {
echo '<div id="generatepress-license-key"></div>';
}
/**
* Add the container for our start customizing app.
*/
public function import_export() {
echo '<div id="generatepress-import-export-pro"></div>';
}
/**
* Add the container for our reset app.
*/
public function reset() {
echo '<div id="generatepress-reset-pro"></div>';
}
}
GeneratePress_Pro_Dashboard::get_instance();

View File

@ -0,0 +1,570 @@
<?php
/**
* Rest API functions
*
* @package GenerateBlocks
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Class GenerateBlocks_Rest
*/
class GeneratePress_Pro_Rest extends WP_REST_Controller {
/**
* Instance.
*
* @access private
* @var object Instance
*/
private static $instance;
/**
* Namespace.
*
* @var string
*/
protected $namespace = 'generatepress-pro/v';
/**
* Version.
*
* @var string
*/
protected $version = '1';
/**
* Initiator.
*
* @return object initialized object of class.
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* GeneratePress_Pro_Rest constructor.
*/
public function __construct() {
add_action( 'rest_api_init', array( $this, 'register_routes' ) );
}
/**
* Register rest routes.
*/
public function register_routes() {
$namespace = $this->namespace . $this->version;
register_rest_route(
$namespace,
'/modules/',
array(
'methods' => WP_REST_Server::EDITABLE,
'callback' => array( $this, 'update_module' ),
'permission_callback' => array( $this, 'update_settings_permission' ),
)
);
register_rest_route(
$namespace,
'/license/',
array(
'methods' => WP_REST_Server::EDITABLE,
'callback' => array( $this, 'update_licensing' ),
'permission_callback' => array( $this, 'update_settings_permission' ),
)
);
register_rest_route(
$namespace,
'/beta/',
array(
'methods' => WP_REST_Server::EDITABLE,
'callback' => array( $this, 'update_beta_testing' ),
'permission_callback' => array( $this, 'update_settings_permission' ),
)
);
register_rest_route(
$namespace,
'/export/',
array(
'methods' => WP_REST_Server::EDITABLE,
'callback' => array( $this, 'export' ),
'permission_callback' => array( $this, 'update_settings_permission' ),
)
);
register_rest_route(
$namespace,
'/import/',
array(
'methods' => WP_REST_Server::EDITABLE,
'callback' => array( $this, 'import' ),
'permission_callback' => array( $this, 'update_settings_permission' ),
)
);
register_rest_route(
$namespace,
'/reset/',
array(
'methods' => WP_REST_Server::EDITABLE,
'callback' => array( $this, 'reset' ),
'permission_callback' => array( $this, 'update_settings_permission' ),
)
);
}
/**
* Get edit options permissions.
*
* @return bool
*/
public function update_settings_permission() {
return current_user_can( 'manage_options' );
}
/**
* Update modules.
*
* @param WP_REST_Request $request request object.
*
* @return mixed
*/
public function update_module( WP_REST_Request $request ) {
$module_key = $request->get_param( 'key' );
$action = $request->get_param( 'action' );
$current_setting = get_option( $module_key, false );
$modules = GeneratePress_Pro_Dashboard::get_modules();
$safe_module_keys = array();
foreach ( $modules as $key => $data ) {
$safe_module_keys[] = $data['key'];
}
if ( ! in_array( $module_key, $safe_module_keys ) ) {
return $this->failed( 'Bad module key.' );
}
$message = '';
if ( 'activate' === $action ) {
update_option( $module_key, 'activated' );
$message = __( 'Module activated.', 'gp-premium' );
}
if ( 'deactivate' === $action ) {
update_option( $module_key, 'deactivated' );
$message = __( 'Module deactivated.', 'gp-premium' );
}
return $this->success( $message );
}
/**
* Update licensing.
*
* @param WP_REST_Request $request request object.
*
* @return mixed
*/
public function update_licensing( WP_REST_Request $request ) {
$new_license_key = $request->get_param( 'key' );
$old_license = get_option( 'gen_premium_license_key', '' );
$old_status = get_option( 'gen_premium_license_key_status', 'deactivated' );
$new_license = strpos( $new_license_key, '***' ) !== false
? trim( $old_license )
: trim( $new_license_key );
if ( $new_license ) {
$api_params = array(
'edd_action' => 'activate_license',
'license' => sanitize_key( $new_license ),
'item_name' => rawurlencode( 'GP Premium' ),
'url' => home_url(),
);
} elseif ( $old_license && 'valid' === $old_status ) {
$api_params = array(
'edd_action' => 'deactivate_license',
'license' => sanitize_key( $old_license ),
'item_name' => rawurlencode( 'GP Premium' ),
'url' => home_url(),
);
}
if ( isset( $api_params ) ) {
$response = wp_remote_post(
'https://generatepress.com',
array(
'timeout' => 30,
'sslverify' => false,
'body' => $api_params,
)
);
if ( is_wp_error( $response ) || 200 !== (int) wp_remote_retrieve_response_code( $response ) ) {
if ( is_object( $response ) ) {
return $this->failed( $response->get_error_message() );
} elseif ( is_array( $response ) && isset( $response['response']['message'] ) ) {
if ( 'Forbidden' === $response['response']['message'] ) {
$message = __( '403 Forbidden. Your server is not able to communicate with generatepress.com in order to activate your license key.', 'gp-premium' );
} else {
$message = $response['response']['message'];
}
}
} else {
$license_data = json_decode( wp_remote_retrieve_body( $response ) );
if ( false === $license_data->success ) {
switch ( $license_data->error ) {
case 'expired':
$message = sprintf(
/* translators: License key expiration date. */
__( 'Your license key expired on %s.', 'gp-premium' ),
date_i18n( get_option( 'date_format' ), strtotime( $license_data->expires, current_time( 'timestamp' ) ) ) // phpcs:ignore
);
break;
case 'disabled':
case 'revoked':
$message = __( 'Your license key has been disabled.', 'gp-premium' );
break;
case 'missing':
$message = __( 'Invalid license.', 'gp-premium' );
break;
case 'invalid':
case 'site_inactive':
$message = __( 'Your license is not active for this URL.', 'gp-premium' );
break;
case 'item_name_mismatch':
/* translators: GP Premium */
$message = sprintf( __( 'This appears to be an invalid license key for %s.', 'gp-premium' ), __( 'GP Premium', 'gp-premium' ) );
break;
case 'no_activations_left':
$message = __( 'Your license key has reached its activation limit.', 'gp-premium' );
break;
default:
$message = __( 'An error occurred, please try again.', 'gp-premium' );
break;
}
}
}
update_option( 'gen_premium_license_key_status', esc_attr( $license_data->license ) );
}
update_option( 'gen_premium_license_key', sanitize_key( $new_license ) );
if ( ! isset( $api_params ) ) {
return $this->success( __( 'Settings saved.', 'gp-premium' ) );
}
if ( ! empty( $message ) ) {
return $this->failed( $message );
}
return $this->success( $license_data );
}
/**
* Update licensing.
*
* @param WP_REST_Request $request request object.
*
* @return mixed
*/
public function update_beta_testing( WP_REST_Request $request ) {
$new_beta_tester = $request->get_param( 'beta' );
if ( ! empty( $new_beta_tester ) ) {
update_option( 'gp_premium_beta_testing', true, false );
} else {
delete_option( 'gp_premium_beta_testing' );
}
if ( ! isset( $api_params ) ) {
return $this->success( __( 'Settings saved.', 'gp-premium' ) );
}
if ( ! empty( $message ) ) {
return $this->failed( $message );
}
return $this->success( $license_data );
}
/**
* Export settings.
*
* @param WP_REST_Request $request request object.
*
* @return mixed
*/
public function export( WP_REST_Request $request ) {
$exportable_modules = $request->get_param( 'items' );
if ( ! $exportable_modules ) {
$exportable_modules = GeneratePress_Pro_Dashboard::get_exportable_modules();
}
$export_type = $request->get_param( 'type' );
if ( 'all' === $export_type ) {
$data = array(
'modules' => array(),
'mods' => array(),
'options' => array(),
);
$module_settings = array();
foreach ( $exportable_modules as $exported_module_key => $exported_module_data ) {
if ( isset( $exported_module_data['settings'] ) ) {
$module_settings[] = $exported_module_data['settings'];
}
}
$modules = GeneratePress_Pro_Dashboard::get_modules();
// Export module status of the exported options.
foreach ( $modules as $module_key => $module_data ) {
if ( isset( $module_data['settings'] ) && in_array( $module_data['settings'], $module_settings ) ) {
$data['modules'][ $module_key ] = $module_data['key'];
}
}
$theme_mods = GeneratePress_Pro_Dashboard::get_theme_mods();
foreach ( $theme_mods as $theme_mod ) {
if ( 'generate_copyright' === $theme_mod ) {
if ( in_array( 'copyright', $module_settings ) ) {
$data['mods'][ $theme_mod ] = get_theme_mod( $theme_mod );
}
} else {
if ( in_array( 'generate_settings', $module_settings ) ) {
$data['mods'][ $theme_mod ] = get_theme_mod( $theme_mod );
}
}
}
$settings = GeneratePress_Pro_Dashboard::get_setting_keys();
foreach ( $settings as $setting ) {
if ( in_array( $setting, $module_settings ) ) {
$data['options'][ $setting ] = get_option( $setting );
}
}
}
if ( 'global-colors' === $export_type ) {
$data['global-colors'] = generate_get_option( 'global_colors' );
}
if ( 'typography' === $export_type ) {
$data['font-manager'] = generate_get_option( 'font_manager' );
$data['typography'] = generate_get_option( 'typography' );
}
$data = apply_filters( 'generate_export_data', $data, $export_type );
return $this->success( $data );
}
/**
* Import settings.
*
* @param WP_REST_Request $request request object.
*
* @return mixed
*/
public function import( WP_REST_Request $request ) {
$settings = $request->get_param( 'import' );
if ( empty( $settings ) ) {
$this->failed( __( 'No settings to import.', 'gp-premium' ) );
}
if ( ! empty( $settings['typography'] ) ) {
$existing_settings = get_option( 'generate_settings', array() );
$existing_settings['typography'] = $settings['typography'];
if ( ! empty( $settings['font-manager'] ) ) {
$existing_settings['font_manager'] = $settings['font-manager'];
}
update_option( 'generate_settings', $existing_settings );
} elseif ( ! empty( $settings['global-colors'] ) ) {
$existing_settings = get_option( 'generate_settings', array() );
$existing_settings['global_colors'] = $settings['global-colors'];
update_option( 'generate_settings', $existing_settings );
} else {
$modules = GeneratePress_Pro_Dashboard::get_modules();
foreach ( (array) $settings['modules'] as $key => $val ) {
if ( isset( $modules[ $key ] ) && in_array( $val, $modules[ $key ] ) ) {
update_option( $val, 'activated' );
}
}
foreach ( (array) $settings['mods'] as $key => $val ) {
if ( in_array( $key, GeneratePress_Pro_Dashboard::get_theme_mods() ) ) {
set_theme_mod( $key, $val );
}
}
foreach ( (array) $settings['options'] as $key => $val ) {
if ( in_array( $key, GeneratePress_Pro_Dashboard::get_setting_keys() ) ) {
update_option( $key, $val );
}
}
}
// 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 );
return $this->success( __( 'Settings imported.', 'gp-premium' ) );
}
/**
* Reset settings.
*
* @param WP_REST_Request $request request object.
*
* @return mixed
*/
public function reset( WP_REST_Request $request ) {
$reset_items = $request->get_param( 'items' );
if ( ! $reset_items ) {
$reset_items = GeneratePress_Pro_Dashboard::get_exportable_modules();
}
$module_settings = array();
foreach ( $reset_items as $reset_module_key => $reset_module_data ) {
if ( isset( $reset_module_data['settings'] ) ) {
$module_settings[] = $reset_module_data['settings'];
}
}
$theme_mods = GeneratePress_Pro_Dashboard::get_theme_mods();
foreach ( $theme_mods as $theme_mod ) {
if ( 'generate_copyright' === $theme_mod ) {
if ( in_array( 'copyright', $module_settings ) ) {
remove_theme_mod( $theme_mod );
}
} else {
if ( in_array( 'generate_settings', $module_settings ) ) {
remove_theme_mod( $theme_mod );
}
}
}
$settings = GeneratePress_Pro_Dashboard::get_setting_keys();
foreach ( $settings as $setting ) {
if ( in_array( $setting, $module_settings ) ) {
delete_option( $setting );
}
}
// 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 ) ) {
$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 );
}
return $this->success( __( 'Settings reset.', 'gp-premium' ) );
}
/**
* Success rest.
*
* @param mixed $response response data.
* @return mixed
*/
public function success( $response ) {
return new WP_REST_Response(
array(
'success' => true,
'response' => $response,
),
200
);
}
/**
* Failed rest.
*
* @param mixed $response response data.
* @return mixed
*/
public function failed( $response ) {
return new WP_REST_Response(
array(
'success' => false,
'response' => $response,
),
200
);
}
/**
* Error rest.
*
* @param mixed $code error code.
* @param mixed $response response data.
* @return mixed
*/
public function error( $code, $response ) {
return new WP_REST_Response(
array(
'error' => true,
'success' => false,
'error_code' => $code,
'response' => $response,
),
401
);
}
}
GeneratePress_Pro_Rest::get_instance();

View File

@ -0,0 +1,790 @@
<?php
/**
* Deprecated admin functions.
*
* @package GP Premium
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
/**
* Checks to see if we're in the Site dashboard.
*
* @since 1.6
* @deprecated 2.0.0
*
* @return bool
*/
function generate_is_sites_dashboard() {
$screen = get_current_screen();
if ( ! is_object( $screen ) ) {
return false;
}
if ( 'appearance_page_generatepress-site-library' === $screen->id ) {
return true;
}
return false;
}
/**
* Add the Sites tab to our Dashboard tabs.
*
* @since 1.6
* @deprecated 2.0.0
*
* @param array $tabs Existing tabs.
* @return array New tabs.
*/
function generate_sites_dashboard_tab( $tabs ) {
$tabs['Sites'] = array(
'name' => __( 'Site Library', 'gp-premium' ),
'url' => admin_url( 'themes.php?page=generatepress-site-library' ),
'class' => generate_is_sites_dashboard() ? 'active' : '',
);
return $tabs;
}
/**
* Register our Site Library page.
*
* @since 1.7
* @deprecated 2.0.0
*/
function generate_site_library_register() {
add_submenu_page(
'themes.php',
__( 'Site Library', 'gp-premium' ),
__( 'Site Library', 'gp-premium' ),
'manage_options',
'generatepress-site-library',
'generate_sites_container'
);
}
/**
* Set our current menu item as the GeneratePress Dashboard.
*
* @since 1.7
* @deprecated 2.0.0
*/
function generate_site_library_fix_menu() {
global $parent_file, $submenu_file, $post_type;
if ( generate_is_sites_dashboard() ) {
$parent_file = 'themes.php'; // phpcs:ignore -- Override necessary.
$submenu_file = 'generate-options'; // phpcs:ignore -- Override necessary.
}
remove_submenu_page( 'themes.php', 'generatepress-site-library' );
}
/**
* Add our scripts for the site library.
*
* @since 1.8
* @deprecated 2.0.0
*/
function generate_sites_do_enqueue_scripts() {
if ( ! generate_is_sites_dashboard() ) {
return;
}
$backup_data = get_option( '_generatepress_site_library_backup', array() );
wp_enqueue_script(
'generate-sites-admin',
GENERATE_SITES_URL . 'assets/js/admin.js',
array( 'jquery', 'wp-util', 'updates', 'generate-sites-blazy' ),
GP_PREMIUM_VERSION,
true
);
wp_enqueue_script(
'generate-sites-download',
GENERATE_SITES_URL . 'assets/js/download.js',
array( 'jquery', 'generate-sites-admin' ),
GP_PREMIUM_VERSION,
true
);
wp_enqueue_script(
'generate-sites-blazy',
GENERATE_SITES_URL . 'assets/js/blazy.min.js',
array(),
GP_PREMIUM_VERSION,
true
);
wp_localize_script(
'generate-sites-admin',
'generate_sites_params',
array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'generate_sites_nonce' ),
'importing_options' => __( 'Importing options', 'gp-premium' ),
'backing_up_options' => __( 'Backing up options', 'gp-premium' ),
'checking_demo_content' => __( 'Checking demo content', 'gp-premium' ),
'downloading_content' => __( 'Downloading content', 'gp-premium' ),
'importing_content' => __( 'Importing content', 'gp-premium' ),
'importing_site_options' => __( 'Importing site options', 'gp-premium' ),
'importing_widgets' => __( 'Importing widgets', 'gp-premium' ),
'activating_plugins' => __( 'Activating plugins', 'gp-premium' ),
'installing_plugins' => __( 'Installing plugins', 'gp-premium' ),
'automatic_plugins' => __( 'Automatic', 'gp-premium' ),
'manual_plugins' => __( 'Manual', 'gp-premium' ),
'home_url' => home_url(),
'restoreThemeOptions' => __( 'Restoring theme options', 'gp-premium' ),
'restoreSiteOptions' => __( 'Restoring site options', 'gp-premium' ),
'restoreContent' => __( 'Removing imported content', 'gp-premium' ),
'restorePlugins' => __( 'Deactivating imported plugins', 'gp-premium' ),
'restoreWidgets' => __( 'Restoring widgets', 'gp-premium' ),
'restoreCSS' => __( 'Restoring CSS', 'gp-premium' ),
'cleanUp' => __( 'Cleaning up', 'gp-premium' ),
'hasContentBackup' => ! empty( $backup_data['content'] ),
'confirmRemoval' => __( 'This process makes changes to your database. If you have existing data, be sure to create a backup as a precaution.', 'gp-premium' ),
)
);
wp_enqueue_style(
'generate-sites-admin',
GENERATE_SITES_URL . 'assets/css/admin.css',
array(),
GP_PREMIUM_VERSION
);
wp_enqueue_style(
'generate-premium-dashboard',
plugin_dir_url( dirname( __FILE__ ) ) . 'inc/assets/dashboard.css',
array(),
GP_PREMIUM_VERSION
);
}
/**
* Add a body class while in the Site Library.
*
* @since 1.8
* @deprecated 2.0.0
*
* @param array $classes Current body classes.
* @return array Existing and our new body classes
*/
function generate_sites_do_admin_body_classes( $classes ) {
if ( generate_is_sites_dashboard() ) {
$classes .= ' generate-sites';
}
return $classes;
}
/**
* Add an opening wrapper element for our Dashboard tabs and page builder links.
*
* @since 1.8
*/
function generate_sites_add_tabs_wrapper_open() {
echo '<div class="site-library-tabs-wrapper">';
}
/**
* Adds our Site dashboard container.
*
* @since 1.6
* @deprecated 2.0.0
*/
function generate_sites_container() {
?>
<div class="generate-site-library">
<div class="site-library-header">
<div class="site-library-container">
<div class="library-title">
<?php _e( 'GeneratePress Site Library', 'gp-premium' ); ?>
</div>
<div class="library-links">
<a href="https://generatepress.com/support" target="_blank"><?php _e( 'Support', 'gp-premium' ); ?></a>
<a href="https://docs.generatepress.com" target="_blank"><?php _e( 'Documentation', 'gp-premium' ); ?></a>
</div>
</div>
</div>
<div class="site-library-container">
<?php
do_action( 'generate_inside_site_library_container' );
$site_data = get_transient( 'generatepress_sites' );
$page_builders = array();
foreach ( (array) $site_data as $data ) {
if ( isset( $data['page_builder'][0] ) ) {
$page_builder = $data['page_builder'][0];
$page_builder_id = str_replace( ' ', '-', strtolower( $page_builder ) );
if ( 'no-page-builder' !== $page_builder_id ) {
$page_builders[ $page_builder_id ] = $page_builder;
}
}
}
echo '<div class="library-filters">';
if ( ! empty( $page_builders ) ) :
?>
<div class="page-builder-filter">
<label for="page-builder" class="page-builder-label"><?php _e( 'Page Builder:', 'gp-premium' ); ?></label>
<div class="filter-select">
<select id="page-builder" class="page-builder-group" data-filter-group="page-builder" data-page-builder=".no-page-builder">
<option value="no-page-builder"><?php _e( 'None', 'gp-premium' ); ?></option>
<?php
foreach ( $page_builders as $id => $name ) {
printf(
'<option value="%1$s">%2$s</option>',
esc_attr( $id ),
esc_html( $name )
);
}
?>
</select>
</div>
</div>
<?php
endif;
?>
</div>
</div> <!-- .site-library-tabs-wrapper -->
<?php // The opening wrapper for this is in generate_sites_add_tabs_wrapper_open(). ?>
<?php
$backup_data = get_option( '_generatepress_site_library_backup', array() );
$show_remove_site = false;
if ( ! empty( $backup_data ) ) {
$show_remove_site = true;
}
?>
<div class="remove-site" style="<?php echo ! $show_remove_site ? 'display: none' : ''; ?>">
<h2><?php _e( 'Existing Site Import Detected', 'gp-premium' ); ?></h2>
<div class="remove-site-content">
<p><?php _e( 'It is highly recommended that you remove the last site you imported before importing a new one.', 'gp-premium' ); ?></p>
<p><?php _e( 'This process restores your previous options, widgets and active plugins. It will also remove your imported content and CSS.', 'gp-premium' ); ?></p>
</div>
<div class="remove-site-actions">
<button class="do-remove-site button-primary"><?php _e( 'Remove Imported Site', 'gp-premium' ); ?></button>
<a class="skip-remove-site" href="#"><?php _e( 'Skip', 'gp-premium' ); ?></a>
<div class="loading" style="display: none;">
<span class="remove-site-message"></span>
<?php GeneratePress_Sites_Helper::loading_icon(); ?>
</div>
</div>
</div>
<div class="generatepress-sites generatepress-admin-block <?php echo $show_remove_site ? 'remove-site-needed' : ''; ?>" id="sites" data-page-builder=".no-page-builder">
<?php do_action( 'generate_inside_sites_container' ); ?>
</div>
<?php
printf(
'<div class="refresh-sites">
<a data-nonce="%1$s" class="button" href="#">%2$s</a>
<a class="button button-primary" href="%3$s" style="display: none;">%4$s</a>
</div>',
esc_html( wp_create_nonce( 'refresh_sites_nonce' ) ),
__( 'Refresh Sites', 'gp-premium' ),
esc_url( admin_url( 'themes.php?page=generatepress-site-library' ) ),
__( 'Reload Page', 'gp-premium' )
);
?>
</div>
</div>
<?php
}
/**
* Refresh our list of sites.
*
* @deprecated 2.0.0
*/
function generate_sites_do_refresh_list() {
check_ajax_referer( 'refresh_sites_nonce', '_nonce' );
if ( ! current_user_can( 'manage_options' ) ) {
wp_send_json_error( __( 'Security check failed.', 'gp-premium' ) );
}
delete_transient( 'generatepress_sites' );
generate_get_sites_from_library();
wp_send_json_success();
}
/**
* Get our page header meta slugs.
*
* @since 1.6
* @deprecated 2.0.0
*
* @return array
*/
function generate_sites_export_page_headers() {
$args = array(
'post_type' => get_post_types( array( 'public' => true ) ),
'showposts' => -1,
'meta_query' => array(
array(
'key' => '_generate-select-page-header',
'compare' => 'EXISTS',
),
),
);
$posts = get_posts( $args );
$new_values = array();
foreach ( $posts as $post ) {
$page_header_id = get_post_meta( $post->ID, '_generate-select-page-header', true );
if ( $page_header_id ) {
$new_values[ $post->ID ] = $page_header_id;
}
}
return $new_values;
}
/**
* Get our Element display locations.
*
* @since 1.7
* @deprecated 2.0.0
*
* @return array
*/
function generate_sites_export_elements_location() {
$args = array(
'post_type' => 'gp_elements',
'showposts' => -1,
);
$posts = get_posts( $args );
$new_values = array();
foreach ( $posts as $post ) {
$display_conditions = get_post_meta( $post->ID, '_generate_element_display_conditions', true );
if ( $display_conditions ) {
$new_values[ $post->ID ] = $display_conditions;
}
}
return $new_values;
}
/**
* Get our Element display locations.
*
* @since 1.7
* @deprecated 2.0.0
*
* @return array
*/
function generate_sites_export_elements_exclusion() {
$args = array(
'post_type' => 'gp_elements',
'showposts' => -1,
);
$posts = get_posts( $args );
$new_values = array();
foreach ( $posts as $post ) {
$display_conditions = get_post_meta( $post->ID, '_generate_element_exclude_conditions', true );
if ( $display_conditions ) {
$new_values[ $post->ID ] = $display_conditions;
}
}
return $new_values;
}
/**
* List out compatible theme modules Sites can activate.
*
* @since 1.6
* @deprecated 2.0.0
*
* @return array
*/
function generatepress_get_site_premium_modules() {
return array(
'Backgrounds' => 'generate_package_backgrounds',
'Blog' => 'generate_package_blog',
'Colors' => 'generate_package_colors',
'Copyright' => 'generate_package_copyright',
'Elements' => 'generate_package_elements',
'Disable Elements' => 'generate_package_disable_elements',
'Hooks' => 'generate_package_hooks',
'Menu Plus' => 'generate_package_menu_plus',
'Page Header' => 'generate_package_page_header',
'Secondary Nav' => 'generate_package_secondary_nav',
'Sections' => 'generate_package_sections',
'Spacing' => 'generate_package_spacing',
'Typography' => 'generate_package_typography',
'WooCommerce' => 'generate_package_woocommerce',
);
}
/**
* Don't allow Sites to modify these options.
*
* @since 1.6
* @deprecated 2.0.0
*
* @return array
*/
function generatepress_sites_disallowed_options() {
return array(
'admin_email',
'siteurl',
'home',
'blog_charset',
'blog_public',
'current_theme',
'stylesheet',
'template',
'default_role',
'mailserver_login',
'mailserver_pass',
'mailserver_port',
'mailserver_url',
'permalink_structure',
'rewrite_rules',
'users_can_register',
);
}
/**
* Add our GeneratePress Site export checkbox to the Export module.
*
* @since 1.7
* @deprecated 2.0.0
*/
function generatepress_sites_add_export_checkbox() {
if ( ! apply_filters( 'generate_show_generatepress_site_export_option', false ) ) {
return;
}
?>
<hr style="margin:10px 0;border-bottom:0;" />
<label>
<input type="checkbox" name="module_group[]" value="generatepress-site" />
<?php _ex( 'GeneratePress Site', 'Module name', 'gp-premium' ); ?>
</label>
<?php
}
/**
* Add to our export .json file.
*
* @since 1.6
* @deprecated 2.0.0
*
* @param array $data The current data being exported.
* @return array Existing and extended data.
*/
function generatepress_sites_do_site_options_export( $data ) {
// Bail if we haven't chosen to export the Site.
if ( ! in_array( 'generatepress-site', $_POST['module_group'] ) ) { // phpcs:ignore -- No processing happening here.
return $data;
}
// Modules.
$modules = generatepress_get_site_premium_modules();
$data['modules'] = array();
foreach ( $modules as $name => $key ) {
if ( 'activated' === get_option( $key ) ) {
$data['modules'][ $name ] = $key;
}
}
// Site options.
$data['site_options']['nav_menu_locations'] = get_theme_mod( 'nav_menu_locations' );
$data['site_options']['custom_logo'] = wp_get_attachment_url( get_theme_mod( 'custom_logo' ) );
$data['site_options']['show_on_front'] = get_option( 'show_on_front' );
$data['site_options']['page_on_front'] = get_option( 'page_on_front' );
$data['site_options']['page_for_posts'] = get_option( 'page_for_posts' );
// Page header.
$data['site_options']['page_header_global_locations'] = get_option( 'generate_page_header_global_locations' );
$data['site_options']['page_headers'] = generate_sites_export_page_headers();
// Elements.
$data['site_options']['element_locations'] = generate_sites_export_elements_location();
$data['site_options']['element_exclusions'] = generate_sites_export_elements_exclusion();
// Custom CSS.
if ( function_exists( 'wp_get_custom_css_post' ) ) {
$data['custom_css'] = wp_get_custom_css_post()->post_content;
}
// WooCommerce.
if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
$data['site_options']['woocommerce_shop_page_id'] = get_option( 'woocommerce_shop_page_id' );
$data['site_options']['woocommerce_cart_page_id'] = get_option( 'woocommerce_cart_page_id' );
$data['site_options']['woocommerce_checkout_page_id'] = get_option( 'woocommerce_checkout_page_id' );
$data['site_options']['woocommerce_myaccount_page_id'] = get_option( 'woocommerce_myaccount_page_id' );
$data['site_options']['woocommerce_single_image_width'] = get_option( 'woocommerce_single_image_width' );
$data['site_options']['woocommerce_thumbnail_image_width'] = get_option( 'woocommerce_thumbnail_image_width' );
$data['site_options']['woocommerce_thumbnail_cropping'] = get_option( 'woocommerce_thumbnail_cropping' );
$data['site_options']['woocommerce_shop_page_display'] = get_option( 'woocommerce_shop_page_display' );
$data['site_options']['woocommerce_category_archive_display'] = get_option( 'woocommerce_category_archive_display' );
$data['site_options']['woocommerce_default_catalog_orderby'] = get_option( 'woocommerce_default_catalog_orderby' );
}
// Elementor.
if ( is_plugin_active( 'elementor/elementor.php' ) ) {
$data['site_options']['elementor_container_width'] = get_option( 'elementor_container_width' );
$data['site_options']['elementor_cpt_support'] = get_option( 'elementor_cpt_support' );
$data['site_options']['elementor_css_print_method'] = get_option( 'elementor_css_print_method' );
$data['site_options']['elementor_default_generic_fonts'] = get_option( 'elementor_default_generic_fonts' );
$data['site_options']['elementor_disable_color_schemes'] = get_option( 'elementor_disable_color_schemes' );
$data['site_options']['elementor_disable_typography_schemes'] = get_option( 'elementor_disable_typography_schemes' );
$data['site_options']['elementor_editor_break_lines'] = get_option( 'elementor_editor_break_lines' );
$data['site_options']['elementor_exclude_user_roles'] = get_option( 'elementor_exclude_user_roles' );
$data['site_options']['elementor_global_image_lightbox'] = get_option( 'elementor_global_image_lightbox' );
$data['site_options']['elementor_page_title_selector'] = get_option( 'elementor_page_title_selector' );
$data['site_options']['elementor_scheme_color'] = get_option( 'elementor_scheme_color' );
$data['site_options']['elementor_scheme_color-picker'] = get_option( 'elementor_scheme_color-picker' );
$data['site_options']['elementor_scheme_typography'] = get_option( 'elementor_scheme_typography' );
$data['site_options']['elementor_space_between_widgets'] = get_option( 'elementor_space_between_widgets' );
$data['site_options']['elementor_stretched_section_container'] = get_option( 'elementor_stretched_section_container' );
$data['site_options']['elementor_load_fa4_shim'] = get_option( 'elementor_load_fa4_shim' );
$data['site_options']['elementor_active_kit'] = get_option( 'elementor_active_kit' );
}
// Beaver Builder.
if ( is_plugin_active( 'beaver-builder-lite-version/fl-builder.php' ) || is_plugin_active( 'bb-plugin/fl-builder.php' ) ) {
$data['site_options']['_fl_builder_enabled_icons'] = get_option( '_fl_builder_enabled_icons' );
$data['site_options']['_fl_builder_enabled_modules'] = get_option( '_fl_builder_enabled_modules' );
$data['site_options']['_fl_builder_post_types'] = get_option( '_fl_builder_post_types' );
$data['site_options']['_fl_builder_color_presets'] = get_option( '_fl_builder_color_presets' );
$data['site_options']['_fl_builder_services'] = get_option( '_fl_builder_services' );
$data['site_options']['_fl_builder_settings'] = get_option( '_fl_builder_settings' );
$data['site_options']['_fl_builder_user_access'] = get_option( '_fl_builder_user_access' );
$data['site_options']['_fl_builder_enabled_templates'] = get_option( '_fl_builder_enabled_templates' );
}
// Menu Icons.
if ( is_plugin_active( 'menu-icons/menu-icons.php' ) ) {
$data['site_options']['menu-icons'] = get_option( 'menu-icons' );
}
// Ninja Forms.
if ( is_plugin_active( 'ninja-forms/ninja-forms.php' ) ) {
$data['site_options']['ninja_forms_settings'] = get_option( 'ninja_forms_settings' );
}
// Social Warfare.
if ( is_plugin_active( 'social-warfare/social-warfare.php' ) ) {
$data['site_options']['socialWarfareOptions'] = get_option( 'socialWarfareOptions' );
}
// Elements Plus.
if ( is_plugin_active( 'elements-plus/elements-plus.php' ) ) {
$data['site_options']['elements_plus_settings'] = get_option( 'elements_plus_settings' );
}
// Ank Google Map.
if ( is_plugin_active( 'ank-google-map/ank-google-map.php' ) ) {
$data['site_options']['ank_google_map'] = get_option( 'ank_google_map' );
}
// GP Social Share.
if ( is_plugin_active( 'gp-social-share-svg/gp-social-share.php' ) ) {
$data['site_options']['gp_social_settings'] = get_option( 'gp_social_settings' );
}
// Active plugins.
$active_plugins = get_option( 'active_plugins' );
$all_plugins = get_plugins();
$ignore = apply_filters(
'generate_sites_ignore_plugins',
array(
'gp-premium/gp-premium.php',
'widget-importer-exporter/widget-importer-exporter.php',
)
);
foreach ( $ignore as $plugin ) {
unset( $all_plugins[ $plugin ] );
}
$activated_plugins = array();
foreach ( $active_plugins as $p ) {
if ( isset( $all_plugins[ $p ] ) ) {
$activated_plugins[ $all_plugins[ $p ]['Name'] ] = $p;
}
}
$data['plugins'] = $activated_plugins;
return $data;
}
/**
* Get our sites from the site server.
*
* @since 1.12.0'
* @deprecated 2.0.0
*/
function generate_get_sites_from_library() {
$remote_sites = get_transient( 'generatepress_sites' );
$trusted_authors = get_transient( 'generatepress_sites_trusted_providers' );
if ( empty( $remote_sites ) ) {
$sites = array();
$data = wp_safe_remote_get( 'https://gpsites.co/wp-json/wp/v2/sites?per_page=100' );
if ( is_wp_error( $data ) ) {
set_transient( 'generatepress_sites', 'no results', 5 * MINUTE_IN_SECONDS );
return;
}
$data = json_decode( wp_remote_retrieve_body( $data ), true );
if ( ! is_array( $data ) ) {
set_transient( 'generatepress_sites', 'no results', 5 * MINUTE_IN_SECONDS );
return;
}
foreach ( (array) $data as $site ) {
$sites[ $site['name'] ] = array(
'name' => $site['name'],
'directory' => $site['directory'],
'preview_url' => $site['preview_url'],
'author_name' => $site['author_name'],
'author_url' => $site['author_url'],
'description' => $site['description'],
'page_builder' => $site['page_builder'],
'min_version' => $site['min_version'],
'uploads_url' => $site['uploads_url'],
'plugins' => $site['plugins'],
'documentation' => $site['documentation'],
);
}
$sites = apply_filters( 'generate_add_sites', $sites );
set_transient( 'generatepress_sites', $sites, 24 * HOUR_IN_SECONDS );
}
if ( empty( $trusted_authors ) ) {
$trusted_authors = wp_safe_remote_get( 'https://gpsites.co/wp-json/sites/site' );
if ( is_wp_error( $trusted_authors ) || empty( $trusted_authors ) ) {
set_transient( 'generatepress_sites_trusted_providers', 'no results', 5 * MINUTE_IN_SECONDS );
return;
}
$trusted_authors = json_decode( wp_remote_retrieve_body( $trusted_authors ), true );
$authors = array();
foreach ( (array) $trusted_authors['trusted_author'] as $author ) {
$authors[] = $author;
}
set_transient( 'generatepress_sites_trusted_providers', $authors, 24 * HOUR_IN_SECONDS );
}
}
/**
* Fetch our sites and trusted authors. Stores them in their own transients.
* We use current_screen instead of admin_init so we can check what admin page we're on.
*
* @since 1.6
* @deprecated 2.0.0
*/
function generatepress_sites_init() {
$screen = get_current_screen();
if ( 'appearance_page_generate-options' === $screen->id || 'appearance_page_generatepress-site-library' === $screen->id ) {
generate_get_sites_from_library();
}
}
/**
* Initiate our Sites once everything has loaded.
* We use current_screen instead of admin_init so we can check what admin page we're on.
*
* @since 1.6
* @deprecated 2.0.0
*/
function generatepress_sites_output() {
if ( ! class_exists( 'GeneratePress_Site' ) ) {
return; // Bail if we don't have the needed class.
}
$sites = get_transient( 'generatepress_sites' );
if ( empty( $sites ) || ! is_array( $sites ) ) {
add_action( 'generate_inside_sites_container', 'generatepress_sites_no_results_error' );
return;
}
if ( apply_filters( 'generate_sites_randomize', false ) ) {
shuffle( $sites );
}
foreach ( $sites as $site ) {
new GeneratePress_Site( $site );
}
}
/**
* Show an error message when no sites exist.
*
* @since 1.8.2
* @deprecated 2.0.0
*/
function generatepress_sites_no_results_error() {
printf(
'<div class="no-site-library-results">
%1$s <a href="%3$s" target="_blank" rel="noopener noreferrer">%2$s</a>
</div>',
__( 'No sites found.', 'gp-premium' ),
__( 'Why?', 'gp-premium' ),
'https://docs.generatepress.com/article/site-library-unavailable/'
);
}
/**
* Build each site UI.
*
* @deprecated 2.0.0
*/
class GeneratePress_Site {
/**
* Get it rockin'
*
* @param array $config The site configuration.
*/
public function __construct( $config = array() ) {
// Do nothing.
}
}

View File

@ -0,0 +1,718 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
/**
* Backgrounds module.
*/
if ( ! function_exists( 'generate_backgrounds_customize_preview_css' ) ) {
function generate_backgrounds_customize_preview_css() {
// No longer needed.
}
}
if ( ! function_exists( 'generate_backgrounds_init' ) ) {
function generate_backgrounds_init() {
load_plugin_textdomain( 'backgrounds', false, 'gp-premium/langs/backgrounds/' );
}
}
if ( ! function_exists( 'generate_backgrounds_setup' ) ) {
function generate_backgrounds_setup() {
// This function is here just in case
// It's kept so we can check to see if Backgrounds is active elsewhere
}
}
/**
* Blog module.
*/
if ( ! function_exists( 'generate_blog_post_image' ) ) {
/**
* Build our featured image HTML
*
* @deprecated 1.5
*/
function generate_blog_post_image() {
// No longer needed
}
}
if ( ! function_exists( 'generate_get_masonry_post_width' ) ) {
/**
* Set our masonry post width
*
* @deprecated 1.5
*/
function generate_get_masonry_post_width() {
// Get our global variables
global $post, $wp_query;
// Figure out which page we're on
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
// Figure out if we're on the most recent post or not
$most_recent = ( $wp_query->current_post == 0 && $paged == 1 ) ? true : false;
// Get our Customizer options
$generate_blog_settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
$masonry_post_width = $generate_blog_settings['masonry_width'];
// Get our post meta option
$stored_meta = ( isset( $post ) ) ? get_post_meta( $post->ID, '_generate-blog-post-class', true ) : '';
// If our post meta option is set, use it
// Or else, use our Customizer option
if ( '' !== $stored_meta ) {
if ( 'width4' == $stored_meta && 'width4' == $generate_blog_settings['masonry_width'] ) {
$masonry_post_width = 'medium';
} else {
$masonry_post_width = $stored_meta;
}
}
// Return our width class
return apply_filters( 'generate_masonry_post_width', $masonry_post_width );
}
}
if ( ! function_exists( 'generate_blog_add_post_class_meta_box' ) ) {
/**
* Create our masonry meta box
*
* @deprecated 1.5
*/
function generate_blog_add_post_class_meta_box() {
$generate_blog_settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
if ( 'true' !== $generate_blog_settings['masonry'] ) {
return;
}
$post_types = apply_filters( 'generate_blog_masonry_metabox', array( 'post' ) );
add_meta_box
(
'generate_blog_post_class_meta_box', // $id
__('Masonry Post Width','generate-blog'), // $title
'generate_blog_show_post_class_metabox', // $callback
$post_types, // $page
'side', // $context
'default' // $priority
);
}
}
if ( ! function_exists( 'generate_blog_show_post_class_metabox' ) ) {
/**
* Outputs the content of the metabox
* @deprecated 1.5
*/
function generate_blog_show_post_class_metabox( $post ) {
wp_nonce_field( basename( __FILE__ ), 'generate_blog_post_class_nonce' );
$stored_meta = get_post_meta( $post->ID );
// Set defaults to avoid PHP notices
if ( isset($stored_meta['_generate-blog-post-class'][0]) ) {
$stored_meta['_generate-blog-post-class'][0] = $stored_meta['_generate-blog-post-class'][0];
} else {
$stored_meta['_generate-blog-post-class'][0] = '';
}
?>
<p>
<label for="_generate-blog-post-class" class="example-row-title"><strong><?php _e( 'Masonry Post Width', 'gp-premium' );?></strong></label><br />
<select name="_generate-blog-post-class" id="_generate-blog-post-class">
<option value="" <?php selected( $stored_meta['_generate-blog-post-class'][0], '' ); ?>><?php _e( 'Global setting', 'gp-premium' );?></option>
<option value="width2" <?php selected( $stored_meta['_generate-blog-post-class'][0], 'width2' ); ?>><?php _e( 'Small', 'gp-premium' );?></option>
<option value="width4" <?php selected( $stored_meta['_generate-blog-post-class'][0], 'width4' ); ?>><?php _e( 'Medium', 'gp-premium' );?></option>
<option value="width6" <?php selected( $stored_meta['_generate-blog-post-class'][0], 'width6' ); ?>><?php _e( 'Large', 'gp-premium' );?></option>
</select>
</p>
<?php
}
}
if ( ! function_exists( 'generate_blog_save_post_class_meta' ) ) {
/**
* Saves post class meta data
*
* @param int $post_id The post ID being saved
* @deprecated 1.5
*/
function generate_blog_save_post_class_meta( $post_id ) {
// 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_blog_post_class_nonce' ] ) && wp_verify_nonce( $_POST[ 'generate_blog_post_class_nonce' ], basename( __FILE__ ) ) ) ? true : false;
// Exits script depending on save status
if ( $is_autosave || $is_revision || ! $is_valid_nonce ) {
return;
}
// Checks for input and saves if needed
if ( isset( $_POST[ '_generate-blog-post-class' ] ) ) {
update_post_meta( $post_id, '_generate-blog-post-class', sanitize_text_field( $_POST[ '_generate-blog-post-class' ] ) );
}
}
}
if ( ! function_exists( 'generate_blog_get_next_posts_url' ) ) {
/**
* Get the URL of the next page
* This is for the AJAX load more function
*/
function generate_blog_get_next_posts_url( $max_page = 0 ) {
global $paged, $wp_query;
if ( ! $max_page ) {
$max_page = $wp_query->max_num_pages;
}
if ( ! $paged ) {
$paged = 1;
}
$nextpage = intval( $paged ) + 1;
if ( ! is_single() && ( $nextpage <= $max_page ) ) {
return next_posts( $max_page, false );
}
}
}
/**
* Fixes a bug in Safari where images with srcset won't display when using infinite scroll.
*
* @since 1.5.5
* @deprecated 1.6
*/
function generate_blog_disable_infinite_scroll_srcset() {
$settings = wp_parse_args(
get_option( 'generate_blog_settings', array() ),
generate_blog_get_defaults()
);
if ( ! is_singular() && $settings[ 'infinite_scroll' ] ) {
add_filter( 'wp_calculate_image_srcset', '__return_empty_array' );
}
}
if ( ! function_exists( 'generate_blog_init' ) ) {
function generate_blog_init() {
load_plugin_textdomain( 'generate-blog', false, 'gp-premium/langs/blog/' );
}
}
/**
* Colors module.
*/
if ( ! function_exists( 'generate_colors_init' ) ) {
function generate_colors_init() {
load_plugin_textdomain( 'generate-colors', false, 'gp-premium/langs/colors/' );
}
}
if ( ! function_exists( 'generate_colors_setup' ) ) {
function generate_colors_setup() {
// Here so we can check to see if Colors is activated
}
}
/**
* Copyright module.
*/
if ( ! function_exists( 'generate_copyright_init' ) ) {
function generate_copyright_init() {
load_plugin_textdomain( 'generate-copyright', false, 'gp-premium/langs/copyright/' );
}
}
/**
* Disable Elements module.
*/
if ( ! function_exists('generate_disable_elements_init') ) {
function generate_disable_elements_init() {
load_plugin_textdomain( 'disable-elements', false, 'gp-premium/langs/disable-elements/' );
}
}
/**
* Hooks module.
*/
if ( ! function_exists( 'generate_hooks_init' ) ) {
function generate_hooks_init() {
load_plugin_textdomain( 'generate-hooks', false, 'gp-premium/langs/hooks/' );
}
}
/**
* Import/Export module.
*/
if ( ! function_exists( 'generate_ie_init' ) ) {
function generate_ie_init() {
load_plugin_textdomain( 'generate-ie', false, 'gp-premium/langs/import-export/' );
}
}
/**
* Menu Plus module.
*/
if ( ! function_exists( 'generate_slideout_navigation_class' ) ) {
/**
* Display the classes for the slideout navigation.
*
* @since 0.1
* @param string|array $class One or more classes to add to the class list.
*/
function generate_slideout_navigation_class( $class = '' ) {
// Separates classes with a single space, collates classes for post DIV
echo 'class="' . join( ' ', generate_get_slideout_navigation_class( $class ) ) . '"';
}
}
if ( ! function_exists( 'generate_get_slideout_navigation_class' ) ) {
/**
* Retrieve the classes for the slideout navigation.
*
* @since 0.1
* @param string|array $class One or more classes to add to the class list.
* @return array Array of classes.
*/
function generate_get_slideout_navigation_class( $class = '' ) {
$classes = array();
if ( !empty($class) ) {
if ( !is_array( $class ) )
$class = preg_split('#\s+#', $class);
$classes = array_merge($classes, $class);
}
$classes = array_map('esc_attr', $classes);
return apply_filters('generate_slideout_navigation_class', $classes, $class);
}
}
if ( ! function_exists( 'generate_slideout_menu_class' ) ) {
/**
* Display the classes for the slideout navigation.
*
* @since 0.1
* @param string|array $class One or more classes to add to the class list.
*/
function generate_slideout_menu_class( $class = '' ) {
// Separates classes with a single space, collates classes for post DIV
echo 'class="' . join( ' ', generate_get_slideout_menu_class( $class ) ) . '"';
}
}
if ( ! function_exists( 'generate_get_slideout_menu_class' ) ) {
/**
* Retrieve the classes for the slideout navigation.
*
* @since 0.1
* @param string|array $class One or more classes to add to the class list.
* @return array Array of classes.
*/
function generate_get_slideout_menu_class( $class = '' ) {
$classes = array();
if ( !empty($class) ) {
if ( !is_array( $class ) )
$class = preg_split('#\s+#', $class);
$classes = array_merge($classes, $class);
}
$classes = array_map('esc_attr', $classes);
return apply_filters('generate_slideout_menu_class', $classes, $class);
}
}
if ( ! function_exists( 'generate_slideout_menu_classes' ) ) {
/**
* Adds custom classes to the menu
* @since 0.1
*/
function generate_slideout_menu_classes( $classes ) {
$classes[] = 'slideout-menu';
return $classes;
}
}
if ( ! function_exists( 'generate_slideout_navigation_classes' ) ) {
/**
* Adds custom classes to the navigation
* @since 0.1
*/
function generate_slideout_navigation_classes( $classes ){
$slideout_effect = apply_filters( 'generate_menu_slideout_effect','overlay' );
$slideout_position = apply_filters( 'generate_menu_slideout_position','left' );
$classes[] = 'main-navigation';
$classes[] = 'slideout-navigation';
return $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.
*/
if ( ! function_exists( 'generate_page_header_inside' ) ) {
/**
* Add page header inside content
* @since 0.3
*/
function generate_page_header_inside() {
if ( ! is_page() ) {
return;
}
if ( 'inside-content' == generate_get_page_header_location() ) {
generate_page_header_area( 'page-header-image', 'page-header-content' );
}
}
}
if ( ! function_exists( 'generate_page_header_single_below_title' ) ) {
/**
* Add post header below title
* @since 0.3
*/
function generate_page_header_single_below_title() {
if ( ! is_single() ) {
return;
}
if ( 'below-title' == generate_get_page_header_location() ) {
generate_page_header_area( 'page-header-image-single page-header-below-title', 'page-header-content-single page-header-below-title' );
}
}
}
if ( ! function_exists( 'generate_page_header_single_above' ) ) {
/**
* Add post header above content
* @since 0.3
*/
function generate_page_header_single_above() {
if ( ! is_single() ) {
return;
}
if ( 'above-content' == generate_get_page_header_location() ) {
generate_page_header_area( 'page-header-image-single', 'page-header-content-single' );
}
}
}
if ( ! function_exists( 'generate_page_header_single' ) ) {
/**
* Add post header inside content
* @since 0.3
*/
function generate_page_header_single() {
$image_class = 'page-header-image-single';
$content_class = 'page-header-content-single';
if ( 'below-title' == generate_get_page_header_location() ) {
$image_class = 'page-header-image-single page-header-below-title';
$content_class = 'page-header-content-single page-header-below-title';
}
if ( 'inside-content' == generate_get_page_header_location() ) {
generate_page_header_area( $image_class, $content_class );
}
}
}
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.
*/
if ( ! function_exists( 'generate_secondary_nav_init' ) ) {
function generate_secondary_nav_init() {
load_plugin_textdomain( 'secondary-nav', false, 'gp-premium/langs/secondary-nav/' );
}
}
/**
* Sections module.
*/
if ( ! function_exists( 'generate_sections_init' ) ) {
function generate_sections_init() {
load_plugin_textdomain( 'generate-sections', false, 'gp-premium/langs/sections/' );
}
}
if ( ! function_exists( 'generate_sections_metabox_init' ) ) {
/*
* Enqueue styles and scripts specific to metaboxs
*/
function generate_sections_metabox_init(){
// I prefer to enqueue the styles only on pages that are using the metaboxes
wp_enqueue_style( 'generate-sections-metabox', plugin_dir_url( __FILE__ ) . 'wpalchemy/css/meta.css');
wp_enqueue_style( 'generate-style-grid', get_template_directory_uri() . '/css/unsemantic-grid.css', false, GENERATE_VERSION, 'all' );
//make sure we enqueue some scripts just in case ( only needed for repeating metaboxes )
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'jquery-ui-core' );
wp_enqueue_script( 'jquery-ui-widget' );
wp_enqueue_script( 'jquery-ui-mouse' );
wp_enqueue_script( 'jquery-ui-sortable' );
wp_enqueue_style( 'wp-color-picker' );
// special script for dealing with repeating textareas- needs to run AFTER all the tinyMCE init scripts, so make 'editor' a requirement
wp_enqueue_script( 'generate-sections-metabox', plugin_dir_url( __FILE__ ) . 'wpalchemy/js/sections-metabox.js', array( 'jquery', 'editor', 'media-upload', 'wp-color-picker' ), GENERATE_SECTIONS_VERSION, true );
$translation_array = array(
'no_content_error' => __( 'Error: Content already detected in default editor.', 'gp-premium' ),
'use_visual_editor' => __( 'Please activate the "Visual" tab in your main editor before transferring content.', 'gp-premium' )
);
wp_localize_script( 'generate-sections-metabox', 'generate_sections', $translation_array );
}
}
/**
* Spacing module.
*/
if ( ! function_exists( 'generate_spacing_init' ) ) {
function generate_spacing_init() {
load_plugin_textdomain( 'generate-spacing', false, 'gp-premium/langs/spacing/' );
}
}
if ( ! function_exists( 'generate_spacing_setup' ) ) {
function generate_spacing_setup() {
// Here so we can check to see if Spacing is active
}
}
/**
* Typography module.
*/
if ( ! function_exists( 'generate_typography_init' ) ) {
function generate_typography_init() {
load_plugin_textdomain( 'generate-typography', false, 'gp-premium/langs/typography/' );
}
}
if ( ! function_exists( 'generate_fonts_setup' ) ) {
function generate_fonts_setup() {
// Here to check if Typography is active
}
}
/**
* WooCommerce module.
*/
if ( ! function_exists( 'generate_woocommerce_init' ) ) {
function generate_woocommerce_init() {
load_plugin_textdomain( 'generate-woocommerce', false, 'gp-premium/langs/woocommerce/' );
}
}
/**
* Use text instead of an icon if essentials are in use.
*
* @since 1.3
* @deprecated 1.6
*
* @param string $icon Existing icon HTML.
* @return string New icon HTML.
*/
function generatepress_wc_essentials_menu_icon( $icon ) {
if ( apply_filters( 'generate_fontawesome_essentials', false ) ) {
return __( 'Cart', 'gp-premium' );
}
return $icon;
}
if ( ! function_exists( 'generate_activation_styles' ) ) {
function generate_activation_styles() {
// Added to dashboard.css
}
}
if ( ! function_exists( 'generate_verify_styles' ) ) {
function generate_verify_styles() {
// Added to dashboard.css
}
}
if ( ! function_exists( 'generate_add_license_key_field' ) ) {
function generate_add_license_key_field() {
// Replaced by generatepress_premium_license_key_field()
}
}
if ( ! function_exists( 'generate_premium_license_key' ) ) {
function generate_premium_license_key() {
// Replaced by generatepress_premium_license_key_field()
}
}
if ( ! function_exists( 'generate_save_premium_license_key' ) ) {
function generate_save_premium_license_key() {
// Replaced by generatepress_premium_process_license_key()
}
}
if ( ! function_exists( 'generate_process_license_key' ) ) {
function generate_process_license_key() {
// Replaced by generatepress_premium_process_license_key()
}
}
/**
* Add the Refresh sites link after the list of sites.
*
* @since 1.6
* @deprecated 1.7
*/
function generate_sites_refresh_link() {
if ( ! generate_is_sites_dashboard() ) {
return;
}
printf(
'<div class="refresh-sites">
<a class="button" href="%1$s">%2$s</a>
</div>',
wp_nonce_url( admin_url( 'themes.php?page=generate-options&area=generate-sites' ), 'refresh_sites', 'refresh_sites_nonce' ),
__( 'Refresh Sites', 'gp-premium' )
);
}
/**
* Delete our sites transient if the Refresh sites link is clicked.
*
* @since 1.6
* @deprecated 1.12.0
*/
function generate_sites_refresh_list() {
if ( ! isset( $_GET['refresh_sites_nonce'] ) || ! wp_verify_nonce( $_GET['refresh_sites_nonce'], 'refresh_sites' ) ) {
return;
}
delete_transient( 'generatepress_sites' );
}
if ( ! function_exists( 'generate_insert_import_export' ) ) {
/**
* @deprecated 1.7
*/
function generate_insert_import_export() {
// Replaced by GeneratePress_Import_Export::build_html()
}
}
if ( ! function_exists( 'generate_ie_import_form' ) ) {
/**
* @deprecated 1.7
*/
function generate_ie_import_form() {
// Replaced by GeneratePress_Import_Export::build_html()
}
}
if ( ! function_exists( 'generate_process_settings_export' ) ) {
/**
* Process a settings export that generates a .json file of the shop settings
*
* @deprecated 1.7
*/
function generate_process_settings_export() {
// Replaced by GeneratePress_Import_Export::export()
}
}
if ( ! function_exists( 'generate_process_settings_import' ) ) {
/**
* Process a settings import from a json file
*
* @deprecated 1.7
*/
function generate_process_settings_import() {
// Replaced by GeneratePress_Import_Export::import()
}
}
if ( ! function_exists( 'generate_ie_exportable' ) ) {
/**
* @deprecated 1.7
*/
function generate_ie_exportable() {
// A check to see if other addons can add their export button
}
}
/**
* Build our dynamic CSS.
*
* @since 1.6
*/
function generate_menu_plus_make_css() {
// Replaced by generate_do_off_canvas_css()
}
/**
* Enqueue our dynamic CSS.
*
* @since 1.6
*/
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

@ -0,0 +1,152 @@
<?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 );
}
// If the theme function doesn't exist, build our own queries.
$desktop = apply_filters( 'generate_desktop_media_query', '(min-width:1025px)' );
$tablet = apply_filters( 'generate_tablet_media_query', '(min-width: 769px) and (max-width: 1024px)' );
$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,
)
);
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()
||
// AMP inlines all CSS, so inlining from the start improves CSS processing performance.
( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() )
) {
return 'inline';
}
if ( ! defined( 'GENERATE_VERSION' ) ) {
return 'inline';
}
return $mode;
}
/**
* Check to see if we have a Block Element.
*
* @since 2.0.0
* @param string $element The type of element to check.
* @param boolean $block_element Whether it's a block element or not.
*/
function generate_has_active_element( $element, $block_element ) {
global $generate_elements;
if ( ! empty( $generate_elements ) ) {
foreach ( (array) $generate_elements as $key => $data ) {
if ( $element === $data['type'] && $block_element === $data['is_block_element'] ) {
return true;
}
}
}
return false;
}
/**
* Check our GeneratePress version.
*
* @since 2.1.0
*/
function generate_premium_get_theme_version() {
return defined( 'GENERATE_VERSION' ) ? GENERATE_VERSION : false;
}
/**
* Remove the featured-image-active class if needed.
*
* @since 2.1.0
*/
function generate_premium_remove_featured_image_class( $classes, $remove_class ) {
if ( $remove_class && in_array( 'featured-image-active', $classes ) ) {
$classes = array_diff( $classes, array( 'featured-image-active' ) );
}
return $classes;
}
/**
* Returns the global $wp_filesystem with credentials set.
* Returns null in case of any errors.
*
* @return WP_Filesystem_Base|null
*/
function generate_premium_get_wp_filesystem() {
global $wp_filesystem;
$success = true;
// Initialize the file system if it has not been done yet.
if ( ! $wp_filesystem ) {
require_once ABSPATH . '/wp-admin/includes/file.php';
$constants = array(
'hostname' => 'FTP_HOST',
'username' => 'FTP_USER',
'password' => 'FTP_PASS',
'public_key' => 'FTP_PUBKEY',
'private_key' => 'FTP_PRIKEY',
);
$credentials = array();
// We provide credentials based on wp-config.php constants.
// Reference https://developer.wordpress.org/apis/wp-config-php/#wordpress-upgrade-constants.
foreach ( $constants as $key => $constant ) {
if ( defined( $constant ) ) {
$credentials[ $key ] = constant( $constant );
}
}
$success = WP_Filesystem( $credentials );
}
if ( ! $success || $wp_filesystem->errors->has_errors() ) {
return null;
}
return $wp_filesystem;
}

View File

@ -0,0 +1,623 @@
<?php
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
add_action( 'admin_enqueue_scripts', 'generatepress_premium_dashboard_scripts' );
/**
* Enqueue scripts and styles for the GP Dashboard area.
*
* @since 1.6
*/
function generatepress_premium_dashboard_scripts() {
$screen = get_current_screen();
if ( 'appearance_page_generate-options' !== $screen->base ) {
return;
}
wp_enqueue_style( 'generate-premium-dashboard', plugin_dir_url( __FILE__ ) . 'assets/dashboard.css', array(), GP_PREMIUM_VERSION );
wp_enqueue_script( 'generate-premium-dashboard', plugin_dir_url( __FILE__ ) . 'assets/dashboard.js', array( 'jquery' ), GP_PREMIUM_VERSION, true );
wp_localize_script(
'generate-premium-dashboard',
'dashboard',
array(
'deprecated_module' => esc_attr__( 'This module has been deprecated. Deactivating it will remove it from this list.', 'gp-premium' ),
)
);
}
if ( ! function_exists( 'generate_premium_notices' ) ) {
add_action( 'admin_notices', 'generate_premium_notices' );
/*
* Set up errors and messages
*/
function generate_premium_notices() {
if ( isset( $_GET['generate-message'] ) && 'addon_deactivated' == $_GET['generate-message'] ) {
add_settings_error( 'generate-premium-notices', 'addon_deactivated', __( 'Module deactivated.', 'gp-premium' ), 'updated' );
}
if ( isset( $_GET['generate-message'] ) && 'addon_activated' == $_GET['generate-message'] ) {
add_settings_error( 'generate-premium-notices', 'addon_activated', __( 'Module activated.', 'gp-premium' ), 'updated' );
}
settings_errors( 'generate-premium-notices' );
}
}
if ( ! function_exists( 'generate_license_errors' ) ) {
add_action( 'admin_notices', 'generate_license_errors' );
/*
* Set up errors and messages
*/
function generate_license_errors() {
if ( isset( $_GET['generate-message'] ) && 'deactivation_passed' == $_GET['generate-message'] ) {
add_settings_error( 'generate-license-notices', 'deactivation_passed', __( 'License deactivated.', 'gp-premium' ), 'updated' );
}
if ( isset( $_GET['generate-message'] ) && 'license_activated' == $_GET['generate-message'] ) {
add_settings_error( 'generate-license-notices', 'license_activated', __( 'License activated.', 'gp-premium' ), 'updated' );
}
if ( isset( $_GET['sl_activation'] ) && ! empty( $_GET['message'] ) ) {
switch ( $_GET['sl_activation'] ) {
case 'false':
$message = urldecode( $_GET['message'] );
add_settings_error( 'generate-license-notices', 'license_failed', $message, 'error' );
break;
case 'true':
default:
break;
}
}
settings_errors( 'generate-license-notices' );
}
}
if ( ! function_exists( 'generate_super_package_addons' ) ) {
add_action( 'generate_options_items', 'generate_super_package_addons', 5 );
/**
* Build the area that allows us to activate and deactivate modules.
*
* @since 0.1
*/
function generate_super_package_addons() {
$addons = array(
'Backgrounds' => 'generate_package_backgrounds',
'Blog' => 'generate_package_blog',
'Colors' => 'generate_package_colors',
'Copyright' => 'generate_package_copyright',
'Disable Elements' => 'generate_package_disable_elements',
'Elements' => 'generate_package_elements',
'Hooks' => 'generate_package_hooks',
'Menu Plus' => 'generate_package_menu_plus',
'Page Header' => 'generate_package_page_header',
'Secondary Nav' => 'generate_package_secondary_nav',
'Sections' => 'generate_package_sections',
'Spacing' => 'generate_package_spacing',
'Typography' => 'generate_package_typography',
'WooCommerce' => 'generate_package_woocommerce',
);
if ( version_compare( PHP_VERSION, '5.4', '>=' ) && ! defined( 'GENERATE_DISABLE_SITE_LIBRARY' ) ) {
$addons['Site Library'] = 'generate_package_site_library';
}
if ( function_exists( 'generate_is_using_dynamic_typography' ) && generate_is_using_dynamic_typography() ) {
unset( $addons['Typography'] );
}
if ( version_compare( generate_premium_get_theme_version(), '3.1.0-alpha.1', '>=' ) ) {
unset( $addons['Colors'] );
}
ksort( $addons );
$addon_count = 0;
foreach ( $addons as $k => $v ) {
if ( 'activated' == get_option( $v ) )
$addon_count++;
}
$key = get_option( 'gen_premium_license_key_status', 'deactivated' );
$version = ( defined( 'GP_PREMIUM_VERSION' ) ) ? GP_PREMIUM_VERSION : '';
?>
<div class="postbox generate-metabox generatepress-admin-block" id="modules">
<h3 class="hndle"><?php _e('GP Premium','gp-premium'); ?> <?php echo $version; ?></h3>
<div class="inside" style="margin:0;padding:0;">
<div class="premium-addons">
<form method="post">
<div class="add-on gp-clear addon-container grid-parent" style="background:#EFEFEF;border-left:5px solid #DDD;padding-left:10px !important;">
<div class="addon-name column-addon-name">
<input type="checkbox" id="generate-select-all" />
<select name="generate_mass_activate" class="mass-activate-select">
<option value=""><?php _e( 'Bulk Actions', 'gp-premium' ) ;?></option>
<option value="activate-selected"><?php _e( 'Activate','gp-premium' ) ;?></option>
<option value="deactivate-selected"><?php _e( 'Deactivate','gp-premium' ) ;?></option>
</select>
<?php wp_nonce_field( 'gp_premium_bulk_action_nonce', 'gp_premium_bulk_action_nonce' ); ?>
<input type="submit" name="generate_multi_activate" class="button mass-activate-button" value="<?php _e( 'Apply','gp-premium' ); ?>" />
</div>
</div>
<?php
$deprecated_modules = apply_filters(
'generate_premium_deprecated_modules',
array(
'Page Header',
'Hooks',
'Sections',
)
);
foreach ( $addons as $k => $v ) :
$key = get_option( $v );
if( $key == 'activated' ) { ?>
<div class="add-on activated gp-clear addon-container grid-parent">
<div class="addon-name column-addon-name" style="">
<input type="checkbox" class="addon-checkbox" name="generate_addon_checkbox[]" value="<?php echo $v; ?>" />
<?php echo $k;?>
</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', 'gp-premium' );?>"/>
</div>
</div>
<?php } else {
// Don't output deprecated modules.
if ( in_array( $k, $deprecated_modules ) ) {
continue;
}
?>
<div class="add-on gp-clear addon-container grid-parent">
<div class="addon-name column-addon-name">
<input <?php if ( 'WooCommerce' == $k && ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) { echo 'disabled'; } ?> type="checkbox" class="addon-checkbox" name="generate_addon_checkbox[]" value="<?php echo $v; ?>" />
<?php echo $k;?>
</div>
<div class="addon-action addon-addon-action" style="text-align:right;">
<?php if ( 'WooCommerce' == $k && ! is_plugin_active( 'woocommerce/woocommerce.php' ) ) { ?>
<?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', 'gp-premium' );?>"/>
<?php } ?>
</div>
</div>
<?php }
echo '<div class="gp-clear"></div>';
endforeach;
?>
</form>
</div>
</div>
</div>
<?php
}
}
if ( ! function_exists( 'generate_multi_activate' ) ) {
add_action( 'admin_init', 'generate_multi_activate' );
function generate_multi_activate() {
// Deactivate selected
if ( isset( $_POST['generate_multi_activate'] ) ) {
// If we didn't click the button, bail.
if ( ! check_admin_referer( 'gp_premium_bulk_action_nonce', 'gp_premium_bulk_action_nonce' ) ) {
return;
}
// If we're not an administrator, bail.
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
$name = ( isset( $_POST['generate_addon_checkbox'] ) ) ? $_POST['generate_addon_checkbox'] : '';
$option = ( isset( $_POST['generate_addon_checkbox'] ) ) ? $_POST['generate_mass_activate'] : '';
$autoload = null;
if ( isset( $_POST['generate_addon_checkbox'] ) ) {
if ( 'deactivate-selected' == $option ) {
foreach ( $name as $id ) {
if ( 'activated' == get_option( $id ) ) {
if ( 'generate_package_site_library' === $id ) {
$autoload = false;
}
update_option( $id, '', $autoload );
}
}
}
if ( 'activate-selected' == $option ) {
foreach ( $name as $id ) {
if ( 'activated' !== get_option( $id ) ) {
if ( 'generate_package_site_library' === $id ) {
$autoload = false;
}
update_option( $id, 'activated', $autoload );
}
}
}
wp_safe_redirect( admin_url( 'themes.php?page=generate-options' ) );
exit;
} else {
wp_safe_redirect( admin_url( 'themes.php?page=generate-options' ) );
exit;
}
}
}
}
/***********************************************
* Activate the add-on
***********************************************/
if ( ! function_exists( 'generate_activate_super_package_addons' ) ) {
add_action( 'admin_init', 'generate_activate_super_package_addons' );
function generate_activate_super_package_addons() {
$addons = array(
'Typography' => 'generate_package_typography',
'Colors' => 'generate_package_colors',
'Backgrounds' => 'generate_package_backgrounds',
'Page Header' => 'generate_package_page_header',
'Sections' => 'generate_package_sections',
'Copyright' => 'generate_package_copyright',
'Disable Elements' => 'generate_package_disable_elements',
'Elements' => 'generate_package_elements',
'Blog' => 'generate_package_blog',
'Hooks' => 'generate_package_hooks',
'Spacing' => 'generate_package_spacing',
'Secondary Nav' => 'generate_package_secondary_nav',
'Menu Plus' => 'generate_package_menu_plus',
'WooCommerce' => 'generate_package_woocommerce',
);
if ( version_compare( PHP_VERSION, '5.4', '>=' ) && ! defined( 'GENERATE_DISABLE_SITE_LIBRARY' ) ) {
$addons['Site Library'] = 'generate_package_site_library';
}
foreach( $addons as $k => $v ) :
if ( isset( $_POST[$v . '_activate_package'] ) ) {
// If we didn't click the button, bail.
if ( ! check_admin_referer( $v . '_activate_nonce', $v . '_activate_nonce' ) ) {
return;
}
// If we're not an administrator, bail.
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
$autoload = null;
if ( 'generate_package_site_library' === $v ) {
$autoload = false;
}
update_option( $v, 'activated', $autoload );
wp_safe_redirect( admin_url( 'themes.php?page=generate-options&generate-message=addon_activated' ) );
exit;
}
endforeach;
}
}
/***********************************************
* Deactivate the plugin
***********************************************/
if ( ! function_exists( 'generate_deactivate_super_package_addons' ) ) {
add_action( 'admin_init', 'generate_deactivate_super_package_addons' );
function generate_deactivate_super_package_addons() {
$addons = array(
'Typography' => 'generate_package_typography',
'Colors' => 'generate_package_colors',
'Backgrounds' => 'generate_package_backgrounds',
'Page Header' => 'generate_package_page_header',
'Sections' => 'generate_package_sections',
'Copyright' => 'generate_package_copyright',
'Disable Elements' => 'generate_package_disable_elements',
'Elements' => 'generate_package_elements',
'Blog' => 'generate_package_blog',
'Hooks' => 'generate_package_hooks',
'Spacing' => 'generate_package_spacing',
'Secondary Nav' => 'generate_package_secondary_nav',
'Menu Plus' => 'generate_package_menu_plus',
'WooCommerce' => 'generate_package_woocommerce',
);
if ( version_compare( PHP_VERSION, '5.4', '>=' ) && ! defined( 'GENERATE_DISABLE_SITE_LIBRARY' ) ) {
$addons['Site Library'] = 'generate_package_site_library';
}
foreach( $addons as $k => $v ) :
if ( isset( $_POST[$v . '_deactivate_package'] ) ) {
// If we didn't click the button, bail.
if ( ! check_admin_referer( $v . '_deactivate_nonce', $v . '_deactivate_nonce' ) ) {
return;
}
// If we're not an administrator, bail.
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
$autoload = null;
if ( 'generate_package_site_library' === $v ) {
$autoload = false;
}
update_option( $v, 'deactivated', $autoload );
wp_safe_redirect( admin_url('themes.php?page=generate-options&generate-message=addon_deactivated' ) );
exit;
}
endforeach;
}
}
if ( ! function_exists( 'generate_premium_body_class' ) ) {
add_filter( 'admin_body_class', 'generate_premium_body_class' );
/**
* Add a class or many to the body in the dashboard
*/
function generate_premium_body_class( $classes ) {
return "$classes gp_premium";
}
}
if ( ! function_exists( 'generate_activation_area' ) ) {
add_action( 'generate_admin_right_panel', 'generate_activation_area' );
function generate_activation_area() {
$license = get_option( 'gen_premium_license_key', '' );
$key = get_option( 'gen_premium_license_key_status', 'deactivated' );
if ( 'valid' == $key ) {
$message = sprintf( '<span class="license-key-message receiving-updates">%s</span>', __( 'Receiving updates', 'gp-premium' ) );
} else {
$message = sprintf( '<span class="license-key-message not-receiving-updates">%s</span>', __( 'Not receiving updates', 'gp-premium' ) );
}
?>
<form method="post" action="options.php">
<div class="postbox generate-metabox" id="generate-license-keys">
<h3 class="hndle">
<?php _e( 'Updates', 'gp-premium' );?>
<span class="license-key-info">
<?php echo $message; ?>
<a title="<?php esc_attr_e( 'Help', 'gp-premium' ); ?>" href="https://docs.generatepress.com/article/updating-gp-premium/" target="_blank" rel="noopener">[?]</a>
</span>
</h3>
<div class="inside" style="margin-bottom:0;">
<div class="license-key-container" style="position:relative;">
<p>
<input spellcheck="false" class="license-key-input" id="generate_license_key_gp_premium" name="generate_license_key_gp_premium" type="<?php echo apply_filters( 'generate_premium_license_key_field', 'password' ); ?>" value="<?php echo $license; ?>" placeholder="<?php _e( 'License Key', 'gp-premium' ); ?>" />
</p>
<p class="beta-testing-container" <?php echo ( empty( $license ) ) ? 'style="display: none;"' : '';?>>
<input type="checkbox" id="gp_premium_beta_testing" name="gp_premium_beta_testing" value="true" <?php echo ( get_option( 'gp_premium_beta_testing', false ) ) ? 'checked="checked"' : ''; ?> />
<label for="gp_premium_beta_testing"><?php _e( 'Receive beta updates', 'gp-premium' ); ?> <a title="<?php esc_attr_e( 'Help', 'gp-premium' ); ?>" href="https://docs.generatepress.com/article/beta-testing/" target="_blank" rel="noopener">[?]</a></label>
</p>
<?php wp_nonce_field( 'generate_license_key_gp_premium_nonce', 'generate_license_key_gp_premium_nonce' ); ?>
<input type="submit" class="button button-primary" name="gp_premium_license_key" value="<?php _e( 'Save', 'gp-premium' );?>" />
</div>
</div>
</div>
</form>
<?php
}
}
add_action( 'admin_init', 'generatepress_premium_process_license_key', 5 );
/**
* Process our saved license key.
*
* @since 1.6
*/
function generatepress_premium_process_license_key() {
// Has our button been clicked?
if ( isset( $_POST[ 'gp_premium_license_key' ] ) ) {
// Get out if we didn't click the button
if ( ! check_admin_referer( 'generate_license_key_gp_premium_nonce', 'generate_license_key_gp_premium_nonce' ) ) {
return;
}
// If we're not an administrator, bail.
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
// Set our beta testing option if it's checked.
if ( ! empty( $_POST['gp_premium_beta_testing'] ) ) {
update_option( 'gp_premium_beta_testing', true, false );
} else {
delete_option( 'gp_premium_beta_testing' );
}
// Grab the value being saved
$new = sanitize_key( $_POST['generate_license_key_gp_premium'] );
// Get the previously saved value
$old = get_option( 'gen_premium_license_key' );
// Still here? Update our option with the new license key
update_option( 'gen_premium_license_key', $new );
// If we have a value, run activation.
if ( '' !== $new ) {
$api_params = array(
'edd_action' => 'activate_license',
'license' => $new,
'item_name' => urlencode( 'GP Premium' ),
'url' => home_url()
);
}
// If we don't have a value (it's been cleared), run deactivation.
if ( '' == $new && 'valid' == get_option( 'gen_premium_license_key_status' ) ) {
$api_params = array(
'edd_action' => 'deactivate_license',
'license' => $old,
'item_name' => urlencode( 'GP Premium' ),
'url' => home_url()
);
}
// Nothing? Get out of here.
if ( ! isset( $api_params ) ) {
wp_safe_redirect( admin_url( 'themes.php?page=generate-options' ) );
exit;
}
// Phone home.
$license_response = wp_remote_post( 'https://generatepress.com', array(
'timeout' => 60,
'sslverify' => false,
'body' => $api_params
) );
// Make sure the response came back okay.
if ( is_wp_error( $license_response ) || 200 !== wp_remote_retrieve_response_code( $license_response ) ) {
if ( is_object( $license_response ) ) {
$message = $license_response->get_error_message();
} elseif ( is_array( $license_response ) && isset( $license_response['response']['message'] ) ) {
if ( 'Forbidden' === $license_response['response']['message'] ) {
$message = __( '403 Forbidden. Your server is not able to communicate with generatepress.com in order to activate your license key.', 'gp-premium' );
} else {
$message = $license_response['response']['message'];
}
}
} else {
// Still here? Decode our response.
$license_data = json_decode( wp_remote_retrieve_body( $license_response ) );
if ( false === $license_data->success ) {
switch ( $license_data->error ) {
case 'expired' :
$message = sprintf(
__( 'Your license key expired on %s.', 'gp-premium' ),
date_i18n( get_option( 'date_format' ), strtotime( $license_data->expires, current_time( 'timestamp' ) ) )
);
break;
case 'revoked' :
$message = __( 'Your license key has been disabled.', 'gp-premium' );
break;
case 'missing' :
$message = __( 'Invalid license.', 'gp-premium' );
break;
case 'invalid' :
case 'site_inactive' :
$message = __( 'Your license is not active for this URL.', 'gp-premium' );
break;
case 'item_name_mismatch' :
$message = __( 'This appears to be an invalid license key for GP Premium.', 'gp-premium' );
break;
case 'no_activations_left':
$message = __( 'Your license key has reached its activation limit.', 'gp-premium' );
break;
default :
$message = __( 'An error occurred, please try again.', 'gp-premium' );
break;
}
}
}
// Check if anything passed on a message constituting a failure
if ( ! empty( $message ) ) {
delete_option( 'gen_premium_license_key_status' );
$base_url = admin_url( 'themes.php?page=generate-options' );
$redirect = add_query_arg( array( 'sl_activation' => 'false', 'message' => urlencode( $message ) ), esc_url( $base_url ) );
wp_redirect( $redirect );
exit();
}
// Update our license key status
update_option( 'gen_premium_license_key_status', $license_data->license );
if ( 'valid' == $license_data->license ) {
// Validated, go tell them
wp_safe_redirect( admin_url( 'themes.php?page=generate-options&generate-message=license_activated' ) );
exit;
} elseif ( 'deactivated' == $license_data->license ) {
// Deactivated, go tell them
wp_safe_redirect( admin_url( 'themes.php?page=generate-options&generate-message=deactivation_passed' ) );
exit;
} else {
// Failed, go tell them
wp_safe_redirect( admin_url( 'themes.php?page=generate-options&generate-message=license_failed' ) );
exit;
}
}
}
if ( ! function_exists( 'generate_license_missing' ) ) {
add_action( 'in_plugin_update_message-gp-premium/gp-premium.php', 'generate_license_missing', 10, 2 );
/**
* Add a message to the plugin update area if no license key is set
*/
function generate_license_missing() {
$license = get_option( 'gen_premium_license_key_status' );
if ( 'valid' !== $license ) {
echo '&nbsp;<strong><a href="' . esc_url( admin_url('themes.php?page=generate-options' ) ) . '">' . __( 'Enter valid license key for automatic updates.', 'gp-premium' ) . '</a></strong>';
}
}
}
add_filter( 'generate_premium_beta_tester', 'generatepress_premium_beta_tester' );
/**
* Enable beta testing if our option is set.
*
* @since 1.6
*/
function generatepress_premium_beta_tester( $value ) {
if ( get_option( 'gp_premium_beta_testing', false ) ) {
return true;
}
return $value;
}

View File

@ -0,0 +1,199 @@
.generatepress-dashboard-tabs {
margin-bottom: 40px;
}
.generatepress-dashboard-tabs a {
background-color: rgba(255,255,255,0.5);
border: 1px solid #ddd;
padding: 10px 15px;
cursor: pointer;
color: #222;
display: inline-block;
text-decoration: none;
}
.generatepress-dashboard-tabs a:not(:last-child) {
border-right: 0;
}
.generatepress-dashboard-tabs a.active {
background-color: #ffffff;
border-color: #ccc;
font-weight: 500;
}
input#generate-select-all,
.addon-checkbox {
margin-right: 15px !important;
}
.gp-premium-version,
.gp-addon-count {
display: block;
color:#ccc;
}
.addon-container:before,
.addon-container:after {
content: ".";
display: block;
overflow: hidden;
visibility: hidden;
font-size: 0;
line-height: 0;
width: 0;
height: 0;
}
.addon-container:after {
clear: both;
}
.premium-addons .gp-clear {
margin: 0 !important;
border: 0;
padding: 0 !important;
}
.premium-addons .add-on.gp-clear {
padding: 15px !important;
margin: 0 !important;
box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.1) inset;
}
.premium-addons .add-on:last-child {
border: 0 !important;
}
.addon-action {
float: right;
clear: right;
}
.addon-name {
float: left;
}
.premium-addons .add-on.gp-clear.activated {
background-color:#F7FCFE !important;
border-left: 5px solid #2EA2CC !important;
font-weight: bold;
padding-left: 10px !important;
}
.premium-addons .addon-action input[type="submit"],
.premium-addons .addon-action input[type="submit"]:visited {
background: none;
border: 0;
color: #0d72b2;
padding: 0;
font-size: inherit;
cursor: pointer;
box-shadow: 0 0 0 transparent;
}
.premium-addons .addon-action input[type="submit"]:hover,
.premium-addons .addon-action input[type="submit"]:focus {
background: none;
border: 0;
color: #0f92e5;
padding: 0;
font-size: inherit;
box-shadow: 0 0 0 transparent;
}
.premium-addons input[type="submit"].hide-customizer-button,
.premium-addons input[type="submit"]:visited.hide-customizer-button {
color: #a00;
font-weight: normal;
}
.premium-addons input[type="submit"]:hover.hide-customizer-button,
.premium-addons input[type="submit"]:focus.hide-customizer-button {
color: red;
font-weight: normal;
}
.premium-addons input[type="submit"].hide-customizer-button {
display: none;
}
.premium-addons .add-on.activated:hover input[type="submit"].hide-customizer-button {
display: inline;
}
.gp_premium input[name="generate_activate_all"] {
display: none;
}
.email-container .addon-name {
width: 75%;
min-width: 150px;
}
.license-key-container {
margin-bottom:15px;
}
.license-key-container:last-child {
margin:0;
}
.license-key-info {
float: right;
text-decoration: none;
}
.license-key-container label {
font-size: 11px;
font-weight: normal;
color: #777;
display: inline-block;
margin-bottom: 0;
}
.status {
position: absolute;
right:10px;
top:-1px;
background:rgba(255,255,255,0.9);
}
.license-key-input {
width:100%;
box-sizing:border-box;
padding:10px;
}
.license-key-input::-webkit-credentials-auto-fill-button {
visibility: hidden;
pointer-events: none;
position: absolute;
right: 0;
}
.license-key-button {
position:relative;
top:1px;
width:100%;
box-sizing:border-box;
padding: 10px !important;
height:auto !important;
line-height:normal !important;
}
.license-key-message {
font-size: 80%;
font-weight: normal;
}
.license-key-message.receiving-updates {
color: green;
}
.license-key-message.not-receiving-updates {
color: red;
}
.mass-activate-select {
margin-top: 0;
}

View File

@ -0,0 +1,48 @@
jQuery( function( $ ) {
$( '#generate-select-all' ).on( 'click', function() {
if ( this.checked ) {
$( '.addon-checkbox:not(:disabled)' ).each( function() {
this.checked = true;
} );
} else {
$( '.addon-checkbox' ).each( function() {
this.checked = false;
} );
}
} );
$( '#generate_license_key_gp_premium' ).on( 'input', function() {
if ( '' !== $.trim( this.value ) ) {
$( '.beta-testing-container' ).show();
} else {
$( '.beta-testing-container' ).hide();
}
} );
$( 'input[name="generate_package_hooks_deactivate_package"]' ).on( 'click', function() {
// eslint-disable-next-line no-alert
var check = confirm( dashboard.deprecated_module );
if ( ! check ) {
return false;
}
} );
$( 'input[name="generate_package_page_header_deactivate_package"]' ).on( 'click', function() {
// eslint-disable-next-line no-alert
var check = confirm( dashboard.deprecated_module );
if ( ! check ) {
return false;
}
} );
$( 'input[name="generate_package_sections_deactivate_package"]' ).on( 'click', function() {
// eslint-disable-next-line no-alert
var check = confirm( dashboard.deprecated_module );
if ( ! check ) {
return false;
}
} );
} );

View File

@ -0,0 +1,47 @@
<?php
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
add_action( 'generate_dashboard_inside_container', 'generate_do_dashboard_tabs', 5 );
add_action( 'generate_inside_site_library_container', 'generate_do_dashboard_tabs', 5 );
add_action( 'generate_before_site_library', 'generate_do_dashboard_tabs', 5 );
/**
* Adds our tabs to the GeneratePress dashboard.
*
* @since 1.6
*/
function generate_do_dashboard_tabs() {
if ( ! defined( 'GENERATE_VERSION' ) ) {
return;
}
$screen = get_current_screen();
$tabs = apply_filters( 'generate_dashboard_tabs', array(
'Modules' => array(
'name' => __( 'Modules', 'gp-premium' ),
'url' => admin_url( 'themes.php?page=generate-options' ),
'class' => 'appearance_page_generate-options' === $screen->id ? 'active' : '',
),
) );
// Don't print any markup if we only have one tab.
if ( count( $tabs ) === 1 ) {
return;
}
?>
<div class="generatepress-dashboard-tabs">
<?php
foreach ( $tabs as $tab ) {
printf( '<a href="%1$s" class="%2$s">%3$s</a>',
esc_url( $tab['url'] ),
esc_attr( $tab['class'] ),
esc_html( $tab['name'] )
);
}
?>
</div>
<?php
}

View File

@ -0,0 +1,371 @@
<?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.
*
* @access private
* @var object Instance
* @since 1.7
*/
private static $instance;
/**
* Initiator.
*
* @since 1.7
* @return object initialized object of class.
*/
public static function get_instance() {
if ( ! isset( self::$instance ) ) {
self::$instance = new self();
}
return self::$instance;
}
/**
* Add necessary actions.
*
* @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' ) );
}
/**
* Build our export and import HTML.
*
* @since 1.7
*/
public static function build_html() {
?>
<div class="postbox generate-metabox" id="generate-ie">
<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>
<input type="checkbox" name="module_group[]" value="generate_settings" checked />
<?php _ex( 'Core', 'Module name', 'gp-premium' ); ?>
</label>
<?php if ( generatepress_is_module_active( 'generate_package_backgrounds', 'GENERATE_BACKGROUNDS' ) ) : ?>
<label>
<input type="checkbox" name="module_group[]" value="generate_background_settings" checked />
<?php _ex( 'Backgrounds', 'Module name', 'gp-premium' ); ?>
</label>
<?php endif; ?>
<?php if ( generatepress_is_module_active( 'generate_package_blog', 'GENERATE_BLOG' ) ) : ?>
<label>
<input type="checkbox" name="module_group[]" value="generate_blog_settings" checked />
<?php _ex( 'Blog', 'Module name', 'gp-premium' ); ?>
</label>
<?php endif; ?>
<?php if ( generatepress_is_module_active( 'generate_package_hooks', 'GENERATE_HOOKS' ) ) : ?>
<label>
<input type="checkbox" name="module_group[]" value="generate_hooks" checked />
<?php _ex( 'Hooks', 'Module name', 'gp-premium' ); ?>
</label>
<?php endif; ?>
<?php if ( generatepress_is_module_active( 'generate_package_page_header', 'GENERATE_PAGE_HEADER' ) ) : ?>
<label>
<input type="checkbox" name="module_group[]" value="generate_page_header_settings" checked />
<?php _ex( 'Page Header', 'Module name', 'gp-premium' ); ?>
</label>
<?php endif; ?>
<?php if ( generatepress_is_module_active( 'generate_package_secondary_nav', 'GENERATE_SECONDARY_NAV' ) ) : ?>
<label>
<input type="checkbox" name="module_group[]" value="generate_secondary_nav_settings" checked />
<?php _ex( 'Secondary Navigation', 'Module name', 'gp-premium' ); ?>
</label>
<?php endif; ?>
<?php if ( generatepress_is_module_active( 'generate_package_spacing', 'GENERATE_SPACING' ) ) : ?>
<label>
<input type="checkbox" name="module_group[]" value="generate_spacing_settings" checked />
<?php _ex( 'Spacing', 'Module name', 'gp-premium' ); ?>
</label>
<?php endif; ?>
<?php if ( generatepress_is_module_active( 'generate_package_menu_plus', 'GENERATE_MENU_PLUS' ) ) : ?>
<label>
<input type="checkbox" name="module_group[]" value="generate_menu_plus_settings" checked />
<?php _ex( 'Menu Plus', 'Module name', 'gp-premium' ); ?>
</label>
<?php endif; ?>
<?php if ( generatepress_is_module_active( 'generate_package_woocommerce', 'GENERATE_WOOCOMMERCE' ) ) : ?>
<label>
<input type="checkbox" name="module_group[]" value="generate_woocommerce_settings" checked />
<?php _ex( 'WooCommerce', 'Module name', 'gp-premium' ); ?>
</label>
<?php endif; ?>
<?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 endif; ?>
<?php do_action( 'generate_export_items' ); ?>
</div>
<p><input type="hidden" name="generate_action" value="export_settings" /></p>
<p style="margin-bottom:0">
<?php wp_nonce_field( 'generate_export_nonce', 'generate_export_nonce' ); ?>
<?php submit_button( __( 'Export', 'gp-premium' ), 'button-primary', 'submit', false, array( 'id' => '' ) ); ?>
</p>
</form>
<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"/>
</p>
<p style="margin-bottom:0">
<input type="hidden" name="generate_action" value="import_settings" />
<?php wp_nonce_field( 'generate_import_nonce', 'generate_import_nonce' ); ?>
<?php submit_button( __( 'Import', 'gp-premium' ), 'button-primary', 'submit', false, array( 'id' => '' ) ); ?>
</p>
</form>
</div>
</div>
<?php
}
/**
* Export our chosen options.
*
* @since 1.7
*/
public static function export() {
if ( empty( $_POST['generate_action'] ) || 'export_settings' !== $_POST['generate_action'] ) {
return;
}
if ( ! wp_verify_nonce( $_POST['generate_export_nonce'], 'generate_export_nonce' ) ) {
return;
}
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
$modules = self::get_modules();
$theme_mods = self::get_theme_mods();
$settings = self::get_settings();
$data = array(
'modules' => array(),
'mods' => array(),
'options' => array(),
);
foreach ( $modules as $name => $value ) {
if ( 'activated' === get_option( $value ) ) {
$data['modules'][ $name ] = $value;
}
}
foreach ( $theme_mods as $theme_mod ) {
if ( 'generate_copyright' === $theme_mod ) {
if ( in_array( 'copyright', $_POST['module_group'] ) ) {
$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 );
}
}
}
foreach ( $settings as $setting ) {
if ( in_array( $setting, $_POST['module_group'] ) ) {
$data['options'][ $setting ] = get_option( $setting );
}
}
$data = apply_filters( 'generate_export_data', $data );
nocache_headers();
header( 'Content-Type: application/json; charset=utf-8' );
header( 'Content-Disposition: attachment; filename=generate-settings-export-' . date( 'Ymd' ) . '.json' ); // phpcs:ignore -- Prefer date().
header( 'Expires: 0' );
echo wp_json_encode( $data );
exit;
}
/**
* Import our exported file.
*
* @since 1.7
*/
public static function import() {
if ( empty( $_POST['generate_action'] ) || 'import_settings' !== $_POST['generate_action'] ) {
return;
}
if ( ! wp_verify_nonce( $_POST['generate_import_nonce'], 'generate_import_nonce' ) ) {
return;
}
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
$filename = $_FILES['import_file']['name'];
$extension = end( explode( '.', $_FILES['import_file']['name'] ) );
if ( 'json' !== $extension ) {
wp_die( __( 'Please upload a valid .json file', 'gp-premium' ) );
}
$import_file = $_FILES['import_file']['tmp_name'];
if ( empty( $import_file ) ) {
wp_die( __( 'Please upload a file to import', 'gp-premium' ) );
}
// Retrieve the settings from the file and convert the json object to an array.
$settings = json_decode( file_get_contents( $import_file ), true ); // phpcs:ignore -- file_get_contents() is fine here.
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 ) {
if ( in_array( $key, self::get_theme_mods() ) ) {
set_theme_mod( $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_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;
}
/**
* List out our available modules.
*
* @since 1.7
*/
public static function get_modules() {
return array(
'Backgrounds' => 'generate_package_backgrounds',
'Blog' => 'generate_package_blog',
'Colors' => 'generate_package_colors',
'Copyright' => 'generate_package_copyright',
'Elements' => 'generate_package_elements',
'Disable Elements' => 'generate_package_disable_elements',
'Hooks' => 'generate_package_hooks',
'Menu Plus' => 'generate_package_menu_plus',
'Page Header' => 'generate_package_page_header',
'Secondary Nav' => 'generate_package_secondary_nav',
'Sections' => 'generate_package_sections',
'Spacing' => 'generate_package_spacing',
'Typography' => 'generate_package_typography',
'WooCommerce' => 'generate_package_woocommerce',
);
}
/**
* List our our set theme mods.
*
* @since 1.7
*/
public static function get_theme_mods() {
return array(
'font_body_variants',
'font_body_category',
'font_site_title_variants',
'font_site_title_category',
'font_site_tagline_variants',
'font_site_tagline_category',
'font_navigation_variants',
'font_navigation_category',
'font_secondary_navigation_variants',
'font_secondary_navigation_category',
'font_buttons_variants',
'font_buttons_category',
'font_heading_1_variants',
'font_heading_1_category',
'font_heading_2_variants',
'font_heading_2_category',
'font_heading_3_variants',
'font_heading_3_category',
'font_heading_4_variants',
'font_heading_4_category',
'font_heading_5_variants',
'font_heading_5_category',
'font_heading_6_variants',
'font_heading_6_category',
'font_widget_title_variants',
'font_widget_title_category',
'font_footer_variants',
'font_footer_category',
'generate_copyright',
);
}
/**
* List out our available settings.
*
* @since 1.7
*/
public static function get_settings() {
return array(
'generate_settings',
'generate_background_settings',
'generate_blog_settings',
'generate_hooks',
'generate_page_header_settings',
'generate_secondary_nav_settings',
'generate_spacing_settings',
'generate_menu_plus_settings',
'generate_woocommerce_settings',
);
}
}
GeneratePress_Import_Export::get_instance();

View File

@ -0,0 +1,273 @@
<?php
/**
* 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 esc_html_e( 'Reset Settings', 'gp-premium' ); ?></h3>
<div class="inside">
<form method="post">
<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>
<?php if ( generatepress_is_module_active( 'generate_package_backgrounds', 'GENERATE_BACKGROUNDS' ) ) { ?>
<label><input type="checkbox" name="module_group[]" value="generate_background_settings" checked /><?php _ex( 'Backgrounds', 'Module name', 'gp-premium' ); ?></label>
<?php } ?>
<?php if ( generatepress_is_module_active( 'generate_package_blog', 'GENERATE_BLOG' ) ) { ?>
<label><input type="checkbox" name="module_group[]" value="generate_blog_settings" checked /><?php _ex( 'Blog', 'Module name', 'gp-premium' ); ?></label>
<?php } ?>
<?php if ( generatepress_is_module_active( 'generate_package_hooks', 'GENERATE_HOOKS' ) ) { ?>
<label><input type="checkbox" name="module_group[]" value="generate_hooks" checked /><?php _ex( 'Hooks', 'Module name', 'gp-premium' ); ?></label>
<?php } ?>
<?php if ( generatepress_is_module_active( 'generate_package_page_header', 'GENERATE_PAGE_HEADER' ) ) { ?>
<label><input type="checkbox" name="module_group[]" value="generate_page_header_settings" checked /><?php _ex( 'Page Header', 'Module name', 'gp-premium' ); ?></label>
<?php } ?>
<?php if ( generatepress_is_module_active( 'generate_package_secondary_nav', 'GENERATE_SECONDARY_NAV' ) ) { ?>
<label><input type="checkbox" name="module_group[]" value="generate_secondary_nav_settings" checked /><?php _ex( 'Secondary Navigation', 'Module name', 'gp-premium' ); ?></label>
<?php } ?>
<?php if ( generatepress_is_module_active( 'generate_package_spacing', 'GENERATE_SPACING' ) ) { ?>
<label><input type="checkbox" name="module_group[]" value="generate_spacing_settings" checked /><?php _ex( 'Spacing', 'Module name', 'gp-premium' ); ?></label>
<?php } ?>
<?php if ( generatepress_is_module_active( 'generate_package_menu_plus', 'GENERATE_MENU_PLUS' ) ) { ?>
<label><input type="checkbox" name="module_group[]" value="generate_menu_plus_settings" checked /><?php _ex( 'Menu Plus', 'Module name', 'gp-premium' ); ?></label>
<?php } ?>
<?php if ( generatepress_is_module_active( 'generate_package_woocommerce', 'GENERATE_WOOCOMMERCE' ) ) { ?>
<label><input type="checkbox" name="module_group[]" value="generate_woocommerce_settings" checked /><?php _ex( 'WooCommerce', 'Module name', 'gp-premium' ); ?></label>
<?php } ?>
<?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 } ?>
</div>
<p><input type="hidden" name="generate_reset_action" value="reset_settings" /></p>
<p style="margin-bottom:0">
<?php
$warning = 'return confirm("' . __( 'Warning: This will delete your settings and can not be undone.', 'gp-premium' ) . '")';
wp_nonce_field( 'generate_reset_settings_nonce', 'generate_reset_settings_nonce' );
submit_button(
__( 'Reset', 'gp-premium' ),
'button-primary',
'submit',
false,
array(
'onclick' => esc_js( $warning ),
'id' => '',
)
);
?>
</p>
</form>
</div>
</div>
<?php
}
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'] ) {
return;
}
if ( ! wp_verify_nonce( $_POST['generate_reset_settings_nonce'], 'generate_reset_settings_nonce' ) ) {
return;
}
if ( ! current_user_can( 'manage_options' ) ) {
return;
}
$theme_mods = array(
'font_body_variants',
'font_body_category',
'font_site_title_variants',
'font_site_title_category',
'font_site_tagline_variants',
'font_site_tagline_category',
'font_navigation_variants',
'font_navigation_category',
'font_secondary_navigation_variants',
'font_secondary_navigation_category',
'font_buttons_variants',
'font_buttons_category',
'font_heading_1_variants',
'font_heading_1_category',
'font_heading_2_variants',
'font_heading_2_category',
'font_heading_3_variants',
'font_heading_3_category',
'font_heading_4_variants',
'font_heading_4_category',
'font_heading_5_variants',
'font_heading_5_category',
'font_heading_6_variants',
'font_heading_6_category',
'font_widget_title_variants',
'font_widget_title_category',
'font_footer_variants',
'font_footer_category',
'generate_copyright',
);
$settings = array(
'generate_settings',
'generate_background_settings',
'generate_blog_settings',
'generate_hooks',
'generate_page_header_settings',
'generate_secondary_nav_settings',
'generate_spacing_settings',
'generate_menu_plus_settings',
'generate_woocommerce_settings',
);
$data = array(
'mods' => array(),
'options' => array(),
);
foreach ( $theme_mods as $theme_mod ) {
if ( 'generate_copyright' === $theme_mod ) {
if ( in_array( 'copyright', $_POST['module_group'] ) ) {
remove_theme_mod( $theme_mod );
}
} else {
if ( in_array( 'generate_settings', $_POST['module_group'] ) ) {
remove_theme_mod( $theme_mod );
}
}
}
foreach ( $settings as $setting ) {
if ( in_array( $setting, $_POST['module_group'] ) ) {
delete_option( $setting );
}
}
// 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 ) ) {
$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 );
}
wp_safe_redirect( admin_url( 'themes.php?page=generate-options&status=reset' ) );
exit;
}
add_action( 'admin_head', 'generate_reset_options_css', 100 );
/**
* Add CSS to the dashboard.
*/
function generate_reset_options_css() {
$screen = get_current_screen();
if ( ! is_object( $screen ) ) {
return;
}
if ( 'appearance_page_generate-options' !== $screen->base ) {
return;
}
?>
<style>
#gen-delete {
display: none;
}
.advanced-choices {
margin-top: 10px;
font-size: 95%;
opacity: 0.9;
}
.advanced-choices:not(.show) {
display: none;
}
.advanced-choices label {
display: block;
}
.show-advanced {
font-size: 13px;
opacity: 0.8;
cursor: pointer;
}
.show-advanced:after {
content: "\f347";
font-family: dashicons;
padding-left: 2px;
padding-top: 2px;
font-size: 10px;
}
.show-advanced.active:after {
content: "\f343";
}
</style>
<?php
}
add_action( 'admin_footer', 'generate_reset_options_scripts', 100 );
/**
* Add scripts to the Dashboard.
*/
function generate_reset_options_scripts() {
$screen = get_current_screen();
if ( ! is_object( $screen ) ) {
return;
}
if ( 'appearance_page_generate-options' !== $screen->base ) {
return;
}
?>
<script>
jQuery( function( $ ) {
$( '.show-advanced' ).on( 'click', function() {
$( this ).toggleClass( 'active' );
$( this ).next( '.advanced-choices' ).toggleClass( 'show' );
} );
} );
</script>
<?php
}

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