Initial commit

This commit is contained in:
2020-04-07 13:03:04 +00:00
committed by Gitium
commit 00f842d9bf
1673 changed files with 471161 additions and 0 deletions

View File

@ -0,0 +1,61 @@
<?php
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) exit;
if ( ! class_exists( 'GeneratePress_Backgrounds_CSS' ) ) {
class GeneratePress_Backgrounds_CSS {
protected $_selector = '';
protected $_selector_output = '';
protected $_css = '';
protected $_output = '';
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;
}
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('" : "";
$url_end = ( '' !== $url ) ? "')" : "";
$this->_css .= $property . ':' . $url_start . $value . $url_end . ';';
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;
}
public function css_output() {
// Add current selector's rules to output
$this->add_selector_rules_to_output();
// Output minified css
return $this->_output;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,424 @@
<?php
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) exit;
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.
*/
function generate_backgrounds_secondary_nav_customizer( $wp_customize ) {
// Bail if we don't have our defaults
if ( ! function_exists( 'generate_secondary_nav_get_defaults' ) ) {
return;
}
// Make sure Secondary Nav is activated
if ( ! $wp_customize->get_section( 'secondary_nav_section' ) ) {
return;
}
// Get our defaults
$defaults = generate_secondary_nav_get_defaults();
if ( method_exists( $wp_customize, 'register_control_type' ) ) {
$wp_customize->register_control_type( 'GeneratePress_Section_Shortcut_Control' );
}
// Get our controls
require_once GP_LIBRARY_DIRECTORY . 'customizer-helpers.php';
// Add our section
$wp_customize->add_section(
'secondary_bg_images_section',
array(
'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,
)
)
);
// Background
$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' ),
)
)
);
// Repeat
$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
)
);
// Item background
$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' ),
)
)
);
// Item repeat
$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
)
);
// Item hover
$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' ),
)
)
);
// Item hover repeat
$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,
)
);
// Current background
$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' ),
)
)
);
// Current repeat
$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,
)
);
// Sub-navigation section
$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,
)
);
// Item background
$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' ),
)
)
);
// Item repeat
$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
)
);
// Item hover
$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' ),
)
)
);
// Item hover repeat
$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,
)
);
// Current background
$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' ),
)
)
);
// Current background repeat
$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
/*
Addon Name: Generate Backgrounds
Author: Thomas Usborne
Author URI: http://edge22.com
*/
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Define the version
if ( ! defined( 'GENERATE_BACKGROUNDS_VERSION' ) ) {
define( 'GENERATE_BACKGROUNDS_VERSION', GP_PREMIUM_VERSION );
}
// Include functions identical between standalone addon and GP Premium
require plugin_dir_path( __FILE__ ) . 'functions/functions.php';

View File

@ -0,0 +1,157 @@
<?php
defined( 'WPINC' ) or die;
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 = ( true == $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
$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;
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.
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 ' . esc_attr( 'grid-' . esc_attr( $columns ) ) . ' tablet-grid-50 mobile-grid-100"></div>' : ''
);
}
}
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 );
}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,224 @@
.post-image-above-header .inside-article .post-image,
.post-image-above-header .inside-article .featured-image {
margin-top:0;
margin-bottom:2em;
}
.post-image-aligned-left .inside-article .post-image,
.post-image-aligned-left .inside-article .featured-image {
margin-top:0;
margin-right:2em;
float:left;
text-align: left;
}
.post-image-aligned-center .post-image,
.post-image-aligned-center .featured-image {
text-align:center;
}
.post-image-aligned-right .inside-article .post-image,
.post-image-aligned-right .inside-article .featured-image {
margin-top:0;
margin-left:2em;
float:right;
text-align: right;
}
.post-image-below-header.post-image-aligned-right .inside-article .post-image,
.post-image-below-header.post-image-aligned-right .inside-article .featured-image,
.post-image-below-header.post-image-aligned-center .inside-article .featured-image,
.post-image-below-header.post-image-aligned-left .inside-article .post-image,
.post-image-below-header.post-image-aligned-left .inside-article .featured-image {
margin-top:2em;
}
.post-image-aligned-left > .featured-image,
.post-image-aligned-right > .featured-image {
float: none;
margin-left: auto;
margin-right: auto;
}
.post-image-aligned-left .featured-image {
text-align: left;
}
.post-image-aligned-right .featured-image {
text-align: right;
}
.post-image-aligned-left .inside-article:before,
.post-image-aligned-left .inside-article:after,
.post-image-aligned-right .inside-article:before,
.post-image-aligned-right .inside-article:after {
content: "";
display: table;
}
.post-image-aligned-left .inside-article:after,
.post-image-aligned-right .inside-article:after {
clear: both;
}
.post-image-aligned-left .inside-article,
.post-image-aligned-right .inside-article {
zoom: 1; /* For IE 6/7 (trigger hasLayout) */
}
.one-container.right-sidebar.post-image-aligned-center .no-featured-image-padding .post-image,
.one-container.both-right.post-image-aligned-center .no-featured-image-padding .post-image,
.one-container.right-sidebar.post-image-aligned-center .no-featured-image-padding .featured-image,
.one-container.both-right.post-image-aligned-center .no-featured-image-padding .featured-image {
margin-right: 0;
}
.one-container.left-sidebar.post-image-aligned-center .no-featured-image-padding .post-image,
.one-container.both-left.post-image-aligned-center .no-featured-image-padding .post-image,
.one-container.left-sidebar.post-image-aligned-center .no-featured-image-padding .featured-image,
.one-container.both-left.post-image-aligned-center .no-featured-image-padding .featured-image {
margin-left: 0;
}
.one-container.both-sidebars.post-image-aligned-center .no-featured-image-padding .post-image,
.one-container.both-sidebars.post-image-aligned-center .no-featured-image-padding .featured-image,
.one-container.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;
}
.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: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-flex-flow: row wrap;
-ms-flex-flow: row wrap;
flex-flow: row wrap;
-webkit-align-items: stretch;
-ms-flex-align: stretch;
align-items: stretch;
}
.generate-columns-container:not(.masonry-container) .generate-columns {
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
}
.generate-columns .inside-article {
width: 100%;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
.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 {
-webkit-box-flex: 1;
-webkit-flex: 1 1 100%;
-ms-flex: 1 1 100%;
flex: 1 1 100%;
clear: both;
}
.generate-columns-container .paging-navigation {
margin-bottom: 0;
}
.no-sidebar .generate-columns-container .inside-article > * {
max-width: none;
}
.load-more:not(.has-svg-icon) .button.loading:before {
content: "\e900";
display: inline-block;
font-family: "GP Premium";
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
-webkit-animation: spin 2s infinite linear;
animation: spin 2s infinite linear;
margin-right: 7px;
}
.load-more .button:not(.loading) .gp-icon {
display: none;
}
.load-more .gp-icon svg {
-webkit-animation: spin 2s infinite linear;
animation: spin 2s infinite linear;
margin-right: 7px;
}
@keyframes spin {
0% {
-webkit-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
transform: rotate(360deg);
}
}
@media (max-width: 767px) {
.generate-columns-activated .generate-columns-container {
margin-left: 0;
margin-right: 0;
}
.generate-columns-container > * {
padding-left: 0;
}
.generate-columns-container .page-header {
margin-left: 0;
}
}
@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;
}
.load-more {
display: block;
text-align:center;
margin-bottom: 0;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,55 @@
<?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_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_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_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,540 @@
<?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() {
$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[] = 'jquery-masonry';
$deps[] = 'imagesloaded';
}
if ( $settings[ 'infinite_scroll' ] && ! is_singular() && ! is_404() ) {
$deps[] = 'infinitescroll';
wp_enqueue_script( 'infinitescroll', plugin_dir_url( __FILE__ ) . 'js/infinite-scroll.pkgd.min.js', array( 'jquery' ), '3.0.1', 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() ) ) {
wp_enqueue_script( 'generate-blog', plugin_dir_url( __FILE__ ) . 'js/scripts.min.js', $deps, GENERATE_BLOG_VERSION, true );
wp_localize_script( 'generate-blog', 'blog', array(
'more' => $settings['masonry_load_more'],
'loading' => $settings['masonry_loading'],
'icon' => function_exists( 'generate_get_svg_icon' ) ? generate_get_svg_icon( 'spinner' ) : '',
) );
}
wp_enqueue_style( 'generate-blog', plugin_dir_url( __FILE__ ) . 'css/style-min.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 ) {
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()
);
// 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';
}
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()
);
// 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 .= '}';
}
return $return;
}
}
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 empty, return
if ( '' == $generate_settings['read_more'] ) {
return '';
}
return apply_filters( 'generate_excerpt_more_output', sprintf( ' ... <a title="%1$s" class="read-more" href="%2$s">%3$s</a>',
the_title_attribute( 'echo=0' ),
esc_url( get_permalink( get_the_ID() ) ),
wp_kses_post( $generate_settings['read_more'] )
) );
}
}
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 empty, return
if ( '' == $generate_settings['read_more'] ) {
return '';
}
return apply_filters( 'generate_content_more_link_output', sprintf( '<p class="read-more-container"><a title="%1$s" class="read-more content-read-more" href="%2$s">%3$s%4$s</a></p>',
the_title_attribute( 'echo=0' ),
esc_url( get_permalink( get_the_ID() ) . apply_filters( 'generate_more_jump','#more-' . get_the_ID() ) ),
wp_kses_post( $generate_settings['read_more'] ),
'<span class="screen-reader-text">' . get_the_title() . '</span>'
) );
}
}
/**
* 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( 'next_post_link', 'generate_disable_post_navigation' );
add_filter( 'previous_post_link', 'generate_disable_post_navigation' );
/**
* Remove the single post navigation
*
* @since 1.5
*/
function generate_disable_post_navigation( $navigation ) {
return generate_disable_post_thing( $navigation, 'single_post_navigation' );
}
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 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;
}
return sprintf( '%5$s<p class="read-more-container"><a title="%1$s" class="read-more button" href="%2$s">%3$s%4$s</a></p>',
the_title_attribute( 'echo=0' ),
esc_url( get_permalink( get_the_ID() ) . apply_filters( 'generate_more_jump','#more-' . get_the_ID() ) ),
wp_kses_post( $settings['read_more'] ),
'<span class="screen-reader-text">' . get_the_title() . '</span>',
'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;
}
$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;
}

View File

@ -0,0 +1,286 @@
<?php
defined( 'WPINC' ) or die;
if ( ! defined( 'GP_IMAGE_RESIZER' ) ) {
require_once GP_LIBRARY_DIRECTORY . 'image-processing-queue/image-processing-queue.php';
}
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' ] ) {
$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[ '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' );
/**
* Filter our core featured image so we can include support for resized images.
*
* @since 1.5
* @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()
);
$image_atts = generate_get_blog_image_attributes();
$image_id = get_post_thumbnail_id( get_the_ID(), 'full' );
if ( ( function_exists( 'is_woocommerce' ) && is_woocommerce() ) || ! $settings['post_image'] ) {
return false;
}
if ( $image_atts && function_exists( 'ipq_get_theme_image' ) ) {
$image_html = ipq_get_theme_image( $image_id,
array(
array( $image_atts[ 'width' ], $image_atts[ 'height' ], $image_atts[ 'crop' ] )
),
array(
'itemprop' => 'image',
)
);
} else {
return $output;
}
return apply_filters( 'generate_resized_featured_image_output', sprintf(
'<div class="post-image">
<a href="%1$s">
%2$s
</a>
</div>',
esc_url( get_permalink() ),
$image_html
), $image_html );
}
/**
* 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_atts = generate_get_blog_image_attributes();
$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;
}
if ( $image_atts && function_exists( 'ipq_get_theme_image' ) ) {
$image_html = ipq_get_theme_image( $image_id,
array(
array( $image_atts[ 'width' ], $image_atts[ 'height' ], $image_atts[ 'crop' ] )
),
array(
'itemprop' => 'image',
)
);
} else {
$image_html = apply_filters( 'post_thumbnail_html',
wp_get_attachment_image( $image_id, apply_filters( 'generate_page_header_default_size', 'full' ), '',
array(
'itemprop' => 'image',
)
),
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 );
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 ( '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;
}
}

View File

@ -0,0 +1,95 @@
jQuery( document ).ready( function($) {
// Featured image controls
var featured_image_archive_controls = [
'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_width',
'generate_blog_settings-post_image_height',
'post_image_apply_sizes',
];
$.each( featured_image_archive_controls, function( index, value ) {
$( '#customize-control-' + value ).attr( 'data-control-section', 'featured-image-archives' );
} );
var featured_image_single_controls = [
'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_width',
'generate_blog_settings-single_post_image_height',
'single_post_image_apply_sizes',
];
$.each( featured_image_single_controls, 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 featured_image_page_controls = [
'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_width',
'generate_blog_settings-page_post_image_height',
'page_post_image_apply_sizes',
];
$.each( featured_image_page_controls, 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 post_meta_archive_controls = [
'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( post_meta_archive_controls, function( index, value ) {
$( '#customize-control-' + value ).attr( 'data-control-section', 'post-meta-archives' );
} );
var post_meta_single_controls = [
'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( post_meta_single_controls, 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,78 @@
/**
* 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( newval ) {
if ( $( '.masonry-container' )[0] ) {
var $initiate = 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] ) {
var $initiate = 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 = $( 'article' ).first().parent();
$container.on( 'load.infiniteScroll', function( event, response, path ) {
$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,80 @@
jQuery( document ).ready( function( $ ) {
var $masonry_container = $( '.masonry-container' );
var msnry = false;
if ( $masonry_container.length ) {
var $grid = $masonry_container.masonry({
columnWidth: '.grid-sizer',
itemSelector: 'none',
stamp: '.page-header',
percentPosition: true,
stagger: 30,
visibleStyle: { transform: 'translateY(0)', opacity: 1 },
hiddenStyle: { transform: 'translateY(5px)', opacity: 0 },
} );
msnry = $grid.data( 'masonry' );
$grid.imagesLoaded( function() {
$grid.masonry( 'layout' );
$grid.removeClass( 'are-images-unloaded' );
$( '.load-more' ).removeClass( 'are-images-unloaded' );
$( '#nav-below' ).css( 'opacity', '1' );
$grid.masonry( 'option', { itemSelector: '.masonry-post' });
var $items = $grid.find( '.masonry-post' );
$grid.masonry( 'appended', $items );
} );
$( '#nav-below' ).insertAfter( '.masonry-container' );
$( window ).on( "orientationchange", function( event ) {
$grid.masonry( 'layout' );
} );
}
if ( $( '.infinite-scroll' ).length && $( '.nav-links .next' ).length ) {
var $container = $( '#main article' ).first().parent();
var $button = $( '.load-more a' );
var svgIcon = '';
if ( blog.icon ) {
svgIcon = blog.icon;
}
$container.infiniteScroll( {
path: '.nav-links .next',
append: '#main article',
history: false,
outlayer: msnry,
loadOnScroll: $button.length ? false : true,
button: $button.length ? '.load-more a' : null,
scrollThreshold: $button.length ? false : 600,
} );
$button.on( 'click', function( e ) {
$( this ).html( svgIcon + blog.loading ).addClass( 'loading' );
} );
$container.on( 'append.infiniteScroll', function( event, response, path, items ) {
if ( ! $( '.generate-columns-container' ).length ) {
$container.append( $button.parent() );
}
$( items ).find( 'img' ).each( function( index, img ) {
img.outerHTML = img.outerHTML;
} );
if ( $grid ) {
$grid.imagesLoaded( function() {
$grid.masonry( 'layout' );
} );
}
$button.html( svgIcon + blog.more ).removeClass( 'loading' );
} );
$container.on( 'last.infiniteScroll', function() {
$( '.load-more' ).hide();
} );
}
} );

View File

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

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,17 @@
<?php
/*
Add-on Name: Generate Blog
Author: Thomas Usborne
Author URI: http://edge22.com
*/
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) exit;
// Define the version
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';

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,613 @@
/**
* 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',
'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',
'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',
'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',
'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{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{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', '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',
'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',
'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', '.generate-back-to-top,.generate-back-to-top:visited', 'background-color', 'transparent' );
/**
* Back to top text color
* Empty: text_color
*/
generate_colors_live_update( 'back_to_top_text_color', '.generate-back-to-top,.generate-back-to-top:visited', 'color', '', 'text_color' );
/**
* Back to top background color hover
* Empty: transparent
*/
generate_colors_live_update( 'back_to_top_background_color_hover', '.generate-back-to-top:hover,.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', '.generate-back-to-top:hover,.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,384 @@
<?php
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.
*/
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,378 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please
}
add_action( 'customize_preview_init', 'generate_menu_plus_live_preview_scripts', 20 );
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
*/
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,882 @@
<?php
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! function_exists( 'generate_colors_wc_customizer' ) ) {
add_action( 'customize_register', 'generate_colors_wc_customizer', 100 );
/**
* Adds our WooCommerce color options
*/
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','generate-woocommerce' ),
'description' => __( 'Primary button colors can be set <a href="#">here</a>.','generate-woocommerce' ),
'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,19 @@
<?php
/*
Addon Name: Generate Colors
Author: Thomas Usborne
Author URI: http://edge22.com
*/
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Define the version
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,210 @@
<?php
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! function_exists( 'generate_copyright_customize_register' ) ) {
add_action( 'customize_register', 'generate_copyright_customize_register' );
/**
* Add our copyright options to the Customizer
*/
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' );
}
// Copyright
$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'),
'&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'),
'&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
*/
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'),
'&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,20 @@
/**
* 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,19 @@
<?php
/*
Addon Name: Generate Copyright
Author: Thomas Usborne
Author URI: http://edge22.com
*/
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// 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,357 @@
<?php
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
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}';
}
if ( ( ! 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
*/
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 / Page Header', 'gp-premium' );?>">
<input type="checkbox" name="_generate-disable-post-image" id="meta-generate-disable-post-image" value="true" <?php checked( $stored_meta['_generate-disable-post-image'][0], 'true' ); ?>>
<?php _e( 'Featured Image / Page Header', 'gp-premium' );?>
</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
*/
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 = filter_input( INPUT_POST, $key, FILTER_SANITIZE_STRING );
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 );
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_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 the header
if ( ! empty( $disable_header ) && false !== $disable_header && function_exists( 'generate_construct_header' ) ) {
remove_action( 'generate_header','generate_construct_header' );
}
// Remove the navigation
if ( ! empty( $disable_nav ) && false !== $disable_nav && function_exists( 'generate_get_navigation_location' ) ) {
add_filter( 'generate_navigation_location','__return_false', 20 );
}
// 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
*/
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-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>
<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 / Page Header', 'gp-premium' );?>">
<input type="checkbox" name="_generate-disable-post-image" id="meta-generate-disable-post-image" value="true" <?php checked( $stored_meta['_generate-disable-post-image'][0], 'true' ); ?>>
<?php _e( 'Featured Image / Page Header', 'gp-premium' );?>
</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
*/
function generate_premium_save_disable_elements_meta( $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 = filter_input( INPUT_POST, $key, FILTER_SANITIZE_STRING );
if ( $value ) {
update_post_meta( $post_id, $key, $value );
} else {
delete_post_meta( $post_id, $key );
}
}
}

View File

@ -0,0 +1,19 @@
<?php
/*
Addon Name: Generate Disable Elements
Author: Thomas Usborne
Author URI: http://edge22.com
*/
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// 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,337 @@
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;
-webkit-transition: all 0.18s ease-out 0.18s;
-moz-transition: all 0.18s ease-out 0.18s;
-ms-transition: all 0.18s ease-out 0.18s;
-o-transition: all 0.18s ease-out 0.18s;
transition: all 0.18s ease-out 0.18s;
font-weight: normal !important;
font-style: normal !important;
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;
-webkit-transition: all 0.18s ease-out 0.18s;
-moz-transition: all 0.18s ease-out 0.18s;
-ms-transition: all 0.18s ease-out 0.18s;
-o-transition: all 0.18s ease-out 0.18s;
transition: all 0.18s ease-out 0.18s;
content: '';
position: absolute;
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 {
-webkit-transition: none;
-moz-transition: none;
-ms-transition: none;
-o-transition: none;
transition: none; }
[data-balloon][data-balloon-pos="up"]:after {
bottom: 100%;
left: 50%;
margin-bottom: 11px;
-webkit-transform: translate(-50%, 10px);
-moz-transform: translate(-50%, 10px);
-ms-transform: translate(-50%, 10px);
transform: translate(-50%, 10px);
-webkit-transform-origin: top;
-moz-transform-origin: top;
-ms-transform-origin: top;
transform-origin: top; }
[data-balloon][data-balloon-pos="up"]:before {
bottom: 100%;
left: 50%;
margin-bottom: 5px;
-webkit-transform: translate(-50%, 10px);
-moz-transform: translate(-50%, 10px);
-ms-transform: translate(-50%, 10px);
transform: translate(-50%, 10px);
-webkit-transform-origin: top;
-moz-transform-origin: top;
-ms-transform-origin: top;
transform-origin: top; }
[data-balloon][data-balloon-pos="up"]:hover:after, [data-balloon][data-balloon-pos="up"][data-balloon-visible]:after {
-webkit-transform: translate(-50%, 0);
-moz-transform: translate(-50%, 0);
-ms-transform: translate(-50%, 0);
transform: translate(-50%, 0); }
[data-balloon][data-balloon-pos="up"]:hover:before, [data-balloon][data-balloon-pos="up"][data-balloon-visible]:before {
-webkit-transform: translate(-50%, 0);
-moz-transform: translate(-50%, 0);
-ms-transform: translate(-50%, 0);
transform: translate(-50%, 0); }
[data-balloon][data-balloon-pos="up-left"]:after {
bottom: 100%;
left: 0;
margin-bottom: 11px;
-webkit-transform: translate(0, 10px);
-moz-transform: translate(0, 10px);
-ms-transform: translate(0, 10px);
transform: translate(0, 10px);
-webkit-transform-origin: top;
-moz-transform-origin: top;
-ms-transform-origin: top;
transform-origin: top; }
[data-balloon][data-balloon-pos="up-left"]:before {
bottom: 100%;
left: 5px;
margin-bottom: 5px;
-webkit-transform: translate(0, 10px);
-moz-transform: translate(0, 10px);
-ms-transform: translate(0, 10px);
transform: translate(0, 10px);
-webkit-transform-origin: top;
-moz-transform-origin: top;
-ms-transform-origin: top;
transform-origin: top; }
[data-balloon][data-balloon-pos="up-left"]:hover:after, [data-balloon][data-balloon-pos="up-left"][data-balloon-visible]:after {
-webkit-transform: translate(0, 0);
-moz-transform: translate(0, 0);
-ms-transform: translate(0, 0);
transform: translate(0, 0); }
[data-balloon][data-balloon-pos="up-left"]:hover:before, [data-balloon][data-balloon-pos="up-left"][data-balloon-visible]:before {
-webkit-transform: translate(0, 0);
-moz-transform: translate(0, 0);
-ms-transform: translate(0, 0);
transform: translate(0, 0); }
[data-balloon][data-balloon-pos="up-right"]:after {
bottom: 100%;
right: 0;
margin-bottom: 11px;
-webkit-transform: translate(0, 10px);
-moz-transform: translate(0, 10px);
-ms-transform: translate(0, 10px);
transform: translate(0, 10px);
-webkit-transform-origin: top;
-moz-transform-origin: top;
-ms-transform-origin: top;
transform-origin: top; }
[data-balloon][data-balloon-pos="up-right"]:before {
bottom: 100%;
right: 5px;
margin-bottom: 5px;
-webkit-transform: translate(0, 10px);
-moz-transform: translate(0, 10px);
-ms-transform: translate(0, 10px);
transform: translate(0, 10px);
-webkit-transform-origin: top;
-moz-transform-origin: top;
-ms-transform-origin: top;
transform-origin: top; }
[data-balloon][data-balloon-pos="up-right"]:hover:after, [data-balloon][data-balloon-pos="up-right"][data-balloon-visible]:after {
-webkit-transform: translate(0, 0);
-moz-transform: translate(0, 0);
-ms-transform: translate(0, 0);
transform: translate(0, 0); }
[data-balloon][data-balloon-pos="up-right"]:hover:before, [data-balloon][data-balloon-pos="up-right"][data-balloon-visible]:before {
-webkit-transform: translate(0, 0);
-moz-transform: translate(0, 0);
-ms-transform: translate(0, 0);
transform: translate(0, 0); }
[data-balloon][data-balloon-pos='down']:after {
left: 50%;
margin-top: 11px;
top: 100%;
-webkit-transform: translate(-50%, -10px);
-moz-transform: translate(-50%, -10px);
-ms-transform: translate(-50%, -10px);
transform: translate(-50%, -10px); }
[data-balloon][data-balloon-pos='down']:before {
background: no-repeat url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20width%3D%2236px%22%20height%3D%2212px%22%3E%3Cpath%20fill%3D%22rgba(17, 17, 17, 0.9)%22%20transform%3D%22rotate(180 18 6)%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E");
background-size: 100% auto;
width: 18px;
height: 6px;
left: 50%;
margin-top: 5px;
top: 100%;
-webkit-transform: translate(-50%, -10px);
-moz-transform: translate(-50%, -10px);
-ms-transform: translate(-50%, -10px);
transform: translate(-50%, -10px); }
[data-balloon][data-balloon-pos='down']:hover:after, [data-balloon][data-balloon-pos='down'][data-balloon-visible]:after {
-webkit-transform: translate(-50%, 0);
-moz-transform: translate(-50%, 0);
-ms-transform: translate(-50%, 0);
transform: translate(-50%, 0); }
[data-balloon][data-balloon-pos='down']:hover:before, [data-balloon][data-balloon-pos='down'][data-balloon-visible]:before {
-webkit-transform: translate(-50%, 0);
-moz-transform: translate(-50%, 0);
-ms-transform: translate(-50%, 0);
transform: translate(-50%, 0); }
[data-balloon][data-balloon-pos='down-left']:after {
left: 0;
margin-top: 11px;
top: 100%;
-webkit-transform: translate(0, -10px);
-moz-transform: translate(0, -10px);
-ms-transform: translate(0, -10px);
transform: translate(0, -10px); }
[data-balloon][data-balloon-pos='down-left']:before {
background: no-repeat url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20width%3D%2236px%22%20height%3D%2212px%22%3E%3Cpath%20fill%3D%22rgba(17, 17, 17, 0.9)%22%20transform%3D%22rotate(180 18 6)%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E");
background-size: 100% auto;
width: 18px;
height: 6px;
left: 5px;
margin-top: 5px;
top: 100%;
-webkit-transform: translate(0, -10px);
-moz-transform: translate(0, -10px);
-ms-transform: translate(0, -10px);
transform: translate(0, -10px); }
[data-balloon][data-balloon-pos='down-left']:hover:after, [data-balloon][data-balloon-pos='down-left'][data-balloon-visible]:after {
-webkit-transform: translate(0, 0);
-moz-transform: translate(0, 0);
-ms-transform: translate(0, 0);
transform: translate(0, 0); }
[data-balloon][data-balloon-pos='down-left']:hover:before, [data-balloon][data-balloon-pos='down-left'][data-balloon-visible]:before {
-webkit-transform: translate(0, 0);
-moz-transform: translate(0, 0);
-ms-transform: translate(0, 0);
transform: translate(0, 0); }
[data-balloon][data-balloon-pos='down-right']:after {
right: 0;
margin-top: 11px;
top: 100%;
-webkit-transform: translate(0, -10px);
-moz-transform: translate(0, -10px);
-ms-transform: translate(0, -10px);
transform: translate(0, -10px); }
[data-balloon][data-balloon-pos='down-right']:before {
background: no-repeat url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20width%3D%2236px%22%20height%3D%2212px%22%3E%3Cpath%20fill%3D%22rgba(17, 17, 17, 0.9)%22%20transform%3D%22rotate(180 18 6)%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E");
background-size: 100% auto;
width: 18px;
height: 6px;
right: 5px;
margin-top: 5px;
top: 100%;
-webkit-transform: translate(0, -10px);
-moz-transform: translate(0, -10px);
-ms-transform: translate(0, -10px);
transform: translate(0, -10px); }
[data-balloon][data-balloon-pos='down-right']:hover:after, [data-balloon][data-balloon-pos='down-right'][data-balloon-visible]:after {
-webkit-transform: translate(0, 0);
-moz-transform: translate(0, 0);
-ms-transform: translate(0, 0);
transform: translate(0, 0); }
[data-balloon][data-balloon-pos='down-right']:hover:before, [data-balloon][data-balloon-pos='down-right'][data-balloon-visible]:before {
-webkit-transform: translate(0, 0);
-moz-transform: translate(0, 0);
-ms-transform: translate(0, 0);
transform: translate(0, 0); }
[data-balloon][data-balloon-pos='left']:after {
margin-right: 11px;
right: 100%;
top: 50%;
-webkit-transform: translate(10px, -50%);
-moz-transform: translate(10px, -50%);
-ms-transform: translate(10px, -50%);
transform: translate(10px, -50%); }
[data-balloon][data-balloon-pos='left']:before {
background: no-repeat url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20width%3D%2212px%22%20height%3D%2236px%22%3E%3Cpath%20fill%3D%22rgba(17, 17, 17, 0.9)%22%20transform%3D%22rotate(-90 18 18)%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E");
background-size: 100% auto;
width: 6px;
height: 18px;
margin-right: 5px;
right: 100%;
top: 50%;
-webkit-transform: translate(10px, -50%);
-moz-transform: translate(10px, -50%);
-ms-transform: translate(10px, -50%);
transform: translate(10px, -50%); }
[data-balloon][data-balloon-pos='left']:hover:after, [data-balloon][data-balloon-pos='left'][data-balloon-visible]:after {
-webkit-transform: translate(0, -50%);
-moz-transform: translate(0, -50%);
-ms-transform: translate(0, -50%);
transform: translate(0, -50%); }
[data-balloon][data-balloon-pos='left']:hover:before, [data-balloon][data-balloon-pos='left'][data-balloon-visible]:before {
-webkit-transform: translate(0, -50%);
-moz-transform: translate(0, -50%);
-ms-transform: translate(0, -50%);
transform: translate(0, -50%); }
[data-balloon][data-balloon-pos='right']:after {
left: 100%;
margin-left: 11px;
top: 50%;
-webkit-transform: translate(-10px, -50%);
-moz-transform: translate(-10px, -50%);
-ms-transform: translate(-10px, -50%);
transform: translate(-10px, -50%); }
[data-balloon][data-balloon-pos='right']:before {
background: no-repeat url("data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http://www.w3.org/2000/svg%22%20width%3D%2212px%22%20height%3D%2236px%22%3E%3Cpath%20fill%3D%22rgba(17, 17, 17, 0.9)%22%20transform%3D%22rotate(90 6 6)%22%20d%3D%22M2.658,0.000%20C-13.615,0.000%2050.938,0.000%2034.662,0.000%20C28.662,0.000%2023.035,12.002%2018.660,12.002%20C14.285,12.002%208.594,0.000%202.658,0.000%20Z%22/%3E%3C/svg%3E");
background-size: 100% auto;
width: 6px;
height: 18px;
left: 100%;
margin-left: 5px;
top: 50%;
-webkit-transform: translate(-10px, -50%);
-moz-transform: translate(-10px, -50%);
-ms-transform: translate(-10px, -50%);
transform: translate(-10px, -50%); }
[data-balloon][data-balloon-pos='right']:hover:after, [data-balloon][data-balloon-pos='right'][data-balloon-visible]:after {
-webkit-transform: translate(0, -50%);
-moz-transform: translate(0, -50%);
-ms-transform: translate(0, -50%);
transform: translate(0, -50%); }
[data-balloon][data-balloon-pos='right']:hover:before, [data-balloon][data-balloon-pos='right'][data-balloon-visible]:before {
-webkit-transform: translate(0, -50%);
-moz-transform: translate(0, -50%);
-ms-transform: translate(0, -50%);
transform: translate(0, -50%); }
[data-balloon][data-balloon-length='small']:after {
white-space: normal;
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,446 @@
.no-element-type #titlediv,
.no-element-type h1.wp-heading-inline,
.no-element-type h1.wp-heading-inline + .page-title-action,
.no-element-type #submitdiv,
.no-element-type .postbox:not(#generate_premium_elements),
.no-element-type .notice,
.no-element-type .error,
.element-settings.no-element-type {
opacity: 0;
height: 0;
overflow: hidden;
}
#generate_premium_elements {
background-color: transparent;
border: 0;
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 {
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: -webkit-box;
display: -ms-flexbox;
display: flex;
margin-bottom: 10px;
}
#generate_premium_elements .condition .select2 {
-webkit-box-flex: 1;
-ms-flex-positive: 1;
flex-grow: 1;
}
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: -ms-flexbox;
display: flex;
width: 100%;
overflow: hidden;
}
ul.element-metabox-tabs li {
width: auto;
-ms-flex: none;
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;
}
select.select-type {
position: relative;
padding: 10px 15px;
margin: 0;
background-color: #fff;
box-shadow: 0 0 0 1px rgba(200, 215, 225, 0.5), 0 1px 2px #e9eff3;
width: 100%;
overflow: hidden;
height: auto;
border: 0;
cursor: pointer;
}
select.select-type:hover {
background-color: #fafafa;
}
.dark-mode select.select-type:hover {
background-color: #23282d;
}
.element-metabox-tabs li:not([data-tab="display-rules"]):not([data-tab="internal-notes"]),
.generate-elements-settings:not([data-tab="display-rules"]):not([data-tab="internal-notes"]) {
display: none;
}
.element-settings.header .element-metabox-tabs li[data-type="header"],
.element-settings.hook .element-metabox-tabs li[data-type="hook"],
.element-settings.layout .element-metabox-tabs li[data-type="layout"] {
display: block;
}
.element-settings.header table[data-tab="hero"],
.element-settings.hook table[data-tab="hook-settings"],
.element-settings.layout table[data-tab="sidebars"] {
display: table;
}
.element-settings.layout #generate-element-content {
display: none;
}
.padding-container {
display: -webkit-box;
display: -ms-flexbox;
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 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;
top: -2.5px;
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: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
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;
}
.choose-element-type-parent:before {
content: "";
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
}
.choose-element-type {
position: fixed;
width: 500px;
background: #fff;
left: calc(50% - 250px);
padding: 50px;
box-sizing: border-box;
box-shadow: 0 0 20px rgba(0,0,0,0.05);
border: 1px solid #ddd;
z-index: 11;
}
#poststuff .choose-element-type h2 {
font-size: 30px;
text-align: center;
margin-bottom: 30px;
padding: 0;
line-height: 1;
}
.layout-radio-item {
margin-bottom: 3px;
}
.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 {
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;
}
.generate-element-row-content .color-alpha {
height: 100% !important;
}

View File

@ -0,0 +1,386 @@
jQuery(document).ready(function( $ ) {
if ( $( '.element-settings' ).hasClass( 'header' ) || $( '.element-settings' ).hasClass( 'hook' ) ) {
$( function() {
if ( elements.settings) {
wp.codeEditor.initialize( "generate-element-content", elements.settings );
}
} );
}
if ( $( '.choose-element-type-parent' ).is( ':visible' ) ) {
$( '.select-type' ).focus();
}
$( 'select[name="_generate_element_type"]' ).on( 'change', function() {
var _this = $( this ),
element = _this.val();
if ( '' == element ) {
return;
}
$( '.element-settings' ).addClass( element ).removeClass( 'no-element-type' ).css( 'opacity', '' );
$( 'body' ).removeClass( 'no-element-type' );
var active_tab = $( '.element-metabox-tabs' ).find( 'li:visible:first' );
active_tab.addClass( 'is-selected' );
$( '.generate-elements-settings[data-tab="' + active_tab.attr( 'data-tab' ) + '"]' ).show();
if ( 'layout' === element ) {
$( '#generate-element-content' ).hide();
}
if ( 'header' === element ) {
$( 'body' ).addClass( 'header-element-type' );
}
if ( elements.settings && 'layout' !== element ) {
$( function() {
wp.codeEditor.initialize( "generate-element-content", elements.settings );
} );
}
_this.closest( '.choose-element-type-parent' ).hide();
} );
$( '#_generate_hook' ).on( 'change', function() {
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( 'header' ) ) {
if ( 'hero' !== tab ) {
$( '#generate-element-content' ).next( '.CodeMirror' ).hide();
} else {
$( '#generate-element-content' ).next( '.CodeMirror' ).show();
}
}
} );
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 get_location_objects = function( _this, onload = false ) {
var select = _this,
parent = select.parent(),
location = select.val(),
object_select = parent.find( '.condition-object-select' ),
locationString = '',
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 ) {
var locationType = 'taxonomy';
} else {
var locationType = location.substr( 0, location.indexOf( ':' ) );
}
var locationID = location.substr( location.lastIndexOf( ':' ) + 1 );
locationString = location;
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>' );
}
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 = $.parseJSON( response );
var objects = response.objects;
var blank = {
'id': '',
'name': 'All ' + response.label,
};
if ( location.indexOf( ':taxonomy:' ) > 0 ) {
blank.name = elements.choose;
}
objects.unshift( blank );
object_select.empty();
$.each( objects, function( key, value ) {
object_select.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 ) {
object_select.val( object_select.attr( 'data-saved-value' ) );
}
select.closest( '.generate-element-row-content' ).find( '.generate-element-row-loading' ).remove();
} );
} else {
parent.removeClass( 'generate-elements-rule-objects-visible' );
select.closest( '.generate-element-row-content' ).find( '.generate-element-row-loading' ).remove();
object_select.empty().append( '<option value="0"></option>' );
object_select.val( '0' );
}
//remove.show();
}
};
$( '.condition select.condition-select' ).on( 'change', function() {
get_location_objects( $( this ) );
} );
$( '.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 );
get_location_objects( select, true );
} );
$( '.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' ),
control_area = _this.closest( '.generate-element-row-content' );
control_area.find( '.padding-container' ).hide();
control_area.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

File diff suppressed because one or more lines are too long

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,367 @@
<?php
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
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:404' => esc_attr__( '404 Template', '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.
if ( 'post' == $post_type_slug || ! empty( $post_type_object->has_archive ) ) {
$types[ $post_type_slug . '_archive' ] = array(
'label' => sprintf( esc_html_x( '%s Archives', '%s is a singular post type name', 'gp-premium' ), $post_type->labels->singular_name ),
'locations' => array(
'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'] ) ) {
$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 );
}
}
}
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';
} 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() ) {
$location = 'archive:' . $wp_query->get( 'post_type' );
} elseif ( is_singular() ) {
if ( is_object( $post ) ) {
$location = 'post:' . $post->post_type;
}
if ( is_object( $queried_object ) ) {
$object = $queried_object->ID;
}
}
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
*
* @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;
}
}
}
// 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;
}
}
}
// 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
* @return string|bool
*/
static public 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,108 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
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
*
* @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;
}
public static function should_execute_php() {
$php = true;
if ( defined( 'DISALLOW_FILE_EDIT' ) ) {
$php = false;
}
return apply_filters( 'generate_hooks_execute_php', $php );
}
}

View File

@ -0,0 +1,913 @@
<?php
class GeneratePress_Hero {
/**
* Our conditionals for this header.
*
* @since 1.7
*/
protected $conditional = array();
/**
* Our exclusions for this header.
*
* @since 1.7
*/
protected $exclude = array();
/**
* Our user conditionals for this header.
*
* @since 1.7
*/
protected $users = array();
/**
* Our array of available options.
*
* @since 1.7
*/
protected static $options = array();
/**
* The element ID.
*
* @since 1.7
*/
protected static $post_id = '';
/**
* How many times this class has been called per page.
*
* @since 1.7
*/
public static $instances = 0;
/**
* Get our current instance.
*
* @since 1.7
*/
protected static $hero = '';
/**
* Kicks it all off.
*
* @since 1.7
*
* @param int The element post ID.
*/
function __construct( $post_id ) {
self::$post_id = $post_id;
// We need this to reference our instance in remove_hentry().
self::$hero = $this;
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 );
}
$display = apply_filters( 'generate_header_element_display', GeneratePress_Conditions::show_data( $this->conditional, $this->exclude, $this->users ), $post_id );
if ( $display ) {
$location = apply_filters( 'generate_page_hero_location', 'generate_after_header', $post_id );
add_action( $location, array( $this, 'build_hero' ), 9 );
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue' ), 100 );
add_action( 'wp', array( $this, 'after_setup' ), 100 );
self::$instances++;
}
}
/**
* Add necessary scripts and styles.
*
* @since 1.7
*/
public function enqueue() {
$options = self::get_options();
wp_add_inline_style( 'generate-style', self::build_css() );
if ( $options['parallax'] ) {
wp_enqueue_script( 'generate-hero-parallax', plugin_dir_url( __FILE__ ) . '/assets/js/parallax.min.js', array(), GP_PREMIUM_VERSION, true );
wp_localize_script( 'generate-hero-parallax', 'hero', array(
'parallax' => apply_filters( 'generate_hero_parallax_speed', 2 ),
) );
}
}
/**
* Builds the HTML structure for Page Headers.
*
* @since 1.7
*/
public function build_hero() {
$options = self::get_options();
if ( empty( $options['content'] ) ) {
return;
}
$options['container_classes'] = implode( ' ', array(
'page-hero',
'contained' === $options['container'] ? 'grid-container grid-parent' : '',
$options['classes'],
) );
$options['inner_container_classes'] = implode( ' ', array(
'inside-page-hero',
'full-width' !== $options['inner_container'] ? 'grid-container grid-parent' : '',
) );
$options['content'] = self::template_tags( $options['content'] );
$options['content'] = do_shortcode( $options['content'] );
echo apply_filters( 'generate_page_hero_output', sprintf(
'<div class="%1$s">
<div class="%2$s">
%3$s
</div>
</div>',
trim( $options['container_classes'] ),
trim( $options['inner_container_classes'] ),
$options['content']
), $options );
}
/**
* Builds all of our custom CSS for Page Headers.
*
* @since 1.7
*
* @return string Dynamic CSS.
*/
public static function build_css() {
$options = self::get_options();
// Initiate our CSS class
require_once GP_LIBRARY_DIRECTORY . 'class-make-css.php';
$css = new GeneratePress_Pro_CSS;
$image_url = false;
if ( $options['background_image'] && function_exists( 'get_the_post_thumbnail_url' ) ) {
if ( 'featured-image' === $options['background_image'] ) {
if ( is_singular() ) {
$image_url = get_the_post_thumbnail_url( get_the_ID(), 'full' );
}
if ( ! $image_url ) {
$image_url = get_the_post_thumbnail_url( self::$post_id, 'full' );
}
}
if ( 'custom-image' === $options['background_image'] ) {
$image_url = get_the_post_thumbnail_url( self::$post_id, 'full' );
}
}
$image_url = apply_filters( 'generate_page_hero_background_image_url', $image_url, $options );
// Figure out desktop units.
$options['padding_top_unit'] = $options['padding_top_unit'] ? $options['padding_top_unit'] : 'px';
$options['padding_right_unit'] = $options['padding_right_unit'] ? $options['padding_right_unit'] : 'px';
$options['padding_bottom_unit'] = $options['padding_bottom_unit'] ? $options['padding_bottom_unit'] : 'px';
$options['padding_left_unit'] = $options['padding_left_unit'] ? $options['padding_left_unit'] : 'px';
// Figure out mobile units.
$options['padding_top_unit_mobile'] = $options['padding_top_unit_mobile'] ? $options['padding_top_unit_mobile'] : 'px';
$options['padding_right_unit_mobile'] = $options['padding_right_unit_mobile'] ? $options['padding_right_unit_mobile'] : 'px';
$options['padding_bottom_unit_mobile'] = $options['padding_bottom_unit_mobile'] ? $options['padding_bottom_unit_mobile'] : 'px';
$options['padding_left_unit_mobile'] = $options['padding_left_unit_mobile'] ? $options['padding_left_unit_mobile'] : 'px';
$css->set_selector( '.page-hero' );
if ( $options['background_color'] ) {
$css->add_property( 'background-color', esc_attr( $options['background_color'] ) );
}
if ( $image_url ) {
$css->add_property( 'background-image', 'url(' . esc_url( $image_url ) . ')' );
$css->add_property( 'background-size', 'cover' );
if ( $options['background_color'] && $options['background_overlay'] ) {
$css->add_property( 'background-image', 'linear-gradient(0deg, ' . $options['background_color'] . ',' . $options['background_color'] . '), url(' . $image_url . ')' );
}
if ( $options['background_position'] ) {
$css->add_property( 'background-position', esc_attr( $options['background_position'] ) );
}
$css->add_property( 'background-repeat', 'no-repeat' );
}
if ( $options['text_color'] ) {
$css->add_property( 'color', esc_attr( $options['text_color'] ) );
}
if ( $options['padding_top'] ) {
$css->add_property( 'padding-top', absint( $options['padding_top'] ), false, esc_html( $options['padding_top_unit'] ) );
}
if ( $options['padding_right'] ) {
$css->add_property( 'padding-right', absint( $options['padding_right'] ), false, esc_html( $options['padding_right_unit'] ) );
}
if ( $options['padding_bottom'] ) {
$css->add_property( 'padding-bottom', absint( $options['padding_bottom'] ), false, esc_html( $options['padding_bottom_unit'] ) );
}
if ( $options['padding_left'] ) {
$css->add_property( 'padding-left', absint( $options['padding_left'] ), false, esc_html( $options['padding_left_unit'] ) );
}
if ( $options['horizontal_alignment'] ) {
$css->add_property( 'text-align', esc_html( $options['horizontal_alignment'] ) );
}
$css->add_property( 'box-sizing', 'border-box' );
if ( $options['site_header_merge'] && $options['full_screen'] ) {
$css->add_property( 'min-height', '100vh' );
if ( $options['vertical_alignment'] ) {
$css->add_property( 'display', '-webkit-flex' );
$css->add_property( 'display', '-ms-flex' );
$css->add_property( 'display', 'flex' );
if ( 'center' === $options['vertical_alignment'] ) {
$css->add_property( '-webkit-box', 'center' );
$css->add_property( '-ms-flex-pack', 'center' );
$css->add_property( 'justify-content', 'center' );
} elseif ( 'bottom' === $options['vertical_alignment'] ) {
$css->add_property( '-webkit-box', 'end' );
$css->add_property( '-ms-flex-pack', 'end' );
$css->add_property( 'justify-content', 'flex-end' );
}
$css->add_property( '-webkit-box-orient', 'vertical' );
$css->add_property( '-webkit-box-direction', 'normal' );
$css->add_property( '-ms-flex-direction', 'column' );
$css->add_property( 'flex-direction', 'column' );
$css->set_selector( '.page-hero .inside-page-hero' );
$css->add_property( 'width', '100%' );
}
}
$css->set_selector( '.page-hero h1, .page-hero h2, .page-hero h3, .page-hero h4, .page-hero h5, .page-hero h6' );
if ( $options['text_color'] ) {
$css->add_property( 'color', esc_attr( $options['text_color'] ) );
}
$css->set_selector( '.inside-page-hero > *:last-child' );
$css->add_property( 'margin-bottom', '0px' );
$css->set_selector( '.page-hero a, .page-hero a:visited' );
if ( $options['link_color'] ) {
$css->add_property( 'color', esc_attr( $options['link_color'] ) );
}
if ( $options['content'] ) {
$css->set_selector( '.page-hero time.updated' );
$css->add_property( 'display', 'none' );
}
$css->set_selector( '.page-hero a:hover' );
if ( $options['link_color_hover'] ) {
$css->add_property( 'color', esc_attr( $options['link_color_hover'] ) );
}
if ( '' !== $options['site_header_merge'] ) {
if ( 'merge-desktop' === $options['site_header_merge'] ) {
$css->start_media_query( apply_filters( 'generate_not_mobile_media_query', '(min-width: 769px)' ) );
}
$header_background = $options['header_background_color'] ? $options['header_background_color'] : 'transparent';
if ( $options['site_header_height'] ) {
$css->set_selector( '.page-hero' );
if ( $options['padding_top'] ) {
$css->add_property( 'padding-top', 'calc(' . absint( $options['padding_top'] ) . esc_html( $options['padding_top_unit'] ) . ' + ' . absint( $options['site_header_height'] ) . 'px)' );
} else {
$css->add_property( 'padding-top', absint( $options['site_header_height'] ), false, 'px' );
}
}
$css->set_selector( '.header-wrap' );
$css->add_property( 'position', 'absolute' );
$css->add_property( 'left', '0px' );
$css->add_property( 'right', '0px' );
$css->add_property( 'z-index', '10' );
$css->set_selector( '.header-wrap .site-header' );
$css->add_property( 'background', $header_background );
$css->set_selector( '.header-wrap .main-title a, .header-wrap .main-title a:hover, .header-wrap .main-title a:visited' );
$css->add_property( 'color', esc_attr( $options['header_title_color'] ) );
if ( ! GeneratePress_Elements_Helper::does_option_exist( 'navigation-as-header' ) ) {
$css->set_selector( '.header-wrap .mobile-header-navigation:not(.navigation-stick):not(.toggled) .main-title a, .header-wrap .mobile-header-navigation:not(.navigation-stick):not(.toggled) .main-title a:hover, .header-wrap .mobile-header-navigation:not(.navigation-stick):not(.toggled) .main-title a:visited' );
$css->add_property( 'color', esc_attr( $options['header_title_color'] ) );
}
if ( function_exists( 'generate_get_color_defaults' ) ) {
$color_settings = wp_parse_args(
get_option( 'generate_settings', array() ),
generate_get_color_defaults()
);
if ( GeneratePress_Elements_Helper::does_option_exist( 'navigation-as-header' ) ) {
$css->set_selector( '.header-wrap .toggled .main-title a, .header-wrap .toggled .main-title a:hover, .header-wrap .toggled .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' );
$css->add_property( 'color', esc_attr( $color_settings['site_title_color'] ) );
}
}
$css->set_selector( '.header-wrap .site-description' );
$css->add_property( 'color', esc_attr( $options['header_tagline_color'] ) );
if ( $options['navigation_colors'] ) {
$navigation_background = $options['navigation_background_color'] ? $options['navigation_background_color'] : 'transparent';
$navigation_background_hover = $options['navigation_background_color_hover'] ? $options['navigation_background_color_hover'] : 'transparent';
$navigation_background_current = $options['navigation_background_color_current'] ? $options['navigation_background_color_current'] : 'transparent';
$css->set_selector( '.header-wrap #site-navigation:not(.toggled), .header-wrap #mobile-header:not(.toggled):not(.navigation-stick)' );
$css->add_property( 'background', $navigation_background );
$css->set_selector( '.header-wrap #site-navigation:not(.toggled) .main-nav > ul > li > a, .header-wrap #mobile-header:not(.toggled):not(.navigation-stick) .main-nav > ul > li > a, .header-wrap .main-navigation:not(.toggled):not(.navigation-stick) .menu-toggle, .header-wrap .main-navigation:not(.toggled):not(.navigation-stick) .menu-toggle:hover, .main-navigation:not(.toggled):not(.navigation-stick) .mobile-bar-items a, .main-navigation:not(.toggled):not(.navigation-stick) .mobile-bar-items a:hover, .main-navigation:not(.toggled):not(.navigation-stick) .mobile-bar-items a:focus' );
$css->add_property( 'color', esc_attr( $options['navigation_text_color' ] ) );
$css->set_selector( '.header-wrap #site-navigation:not(.toggled) .main-nav > ul > li:hover > a, .header-wrap #site-navigation:not(.toggled) .main-nav > ul > li:focus > a, .header-wrap #site-navigation:not(.toggled) .main-nav > ul > li.sfHover > a, .header-wrap #mobile-header:not(.toggled) .main-nav > ul > li:hover > a' );
$css->add_property( 'background', $navigation_background_hover );
if ( '' !== $options[ 'navigation_text_color_hover' ] ) {
$css->add_property( 'color', esc_attr( $options[ 'navigation_text_color_hover' ] ) );
} else {
$css->add_property( 'color', esc_attr( $options[ 'navigation_text_color' ] ) );
}
$css->set_selector( '.header-wrap #site-navigation:not(.toggled) .main-nav > ul > li[class*="current-menu-"] > a, .header-wrap #mobile-header:not(.toggled) .main-nav > ul > li[class*="current-menu-"] > a, .header-wrap #site-navigation:not(.toggled) .main-nav > ul > li[class*="current-menu-"]:hover > a, .header-wrap #mobile-header:not(.toggled) .main-nav > ul > li[class*="current-menu-"]:hover > a' );
$css->add_property( 'background', $navigation_background_current );
if ( '' !== $options[ 'navigation_text_color_current' ] ) {
$css->add_property( 'color', esc_attr( $options[ 'navigation_text_color_current' ] ) );
} else {
$css->add_property( 'color', esc_attr( $options[ 'navigation_text_color' ] ) );
}
}
if ( $options['site_logo'] && GeneratePress_Elements_Helper::does_option_exist( 'navigation-as-header' ) ) {
$css->set_selector( '.main-navigation .site-logo, .main-navigation.toggled .page-hero-logo, .main-navigation.navigation-stick .page-hero-logo' );
$css->add_property( 'display', 'none' );
$css->set_selector( '.main-navigation .page-hero-logo, .main-navigation.toggled .site-logo:not(.page-hero-logo), #mobile-header .mobile-header-logo' );
$css->add_property( 'display', 'block' );
if ( ! GeneratePress_Elements_Helper::does_option_exist( 'sticky-navigation-logo' ) ) {
$css->set_selector( '.main-navigation.navigation-stick .site-logo:not(.page-hero-logo)' );
$css->add_property( 'display', 'block' );
$css->set_selector( '.main-navigation.navigation-stick .page-hero-logo' );
$css->add_property( 'display', 'none' );
}
}
if ( $options['navigation_logo'] && GeneratePress_Elements_Helper::does_option_exist( 'sticky-navigation' ) ) {
$css->set_selector( '#site-navigation:not(.navigation-stick):not(.toggled) .navigation-logo:not(.page-hero-navigation-logo)' );
$css->add_property( 'display', 'none' );
$css->set_selector( '#sticky-navigation .page-hero-navigation-logo, #site-navigation.navigation-stick .page-hero-navigation-logo, #site-navigation.toggled .page-hero-navigation-logo' );
$css->add_property( 'display', 'none' );
}
if ( $options['mobile_logo'] && GeneratePress_Elements_Helper::does_option_exist( 'mobile-logo' ) ) {
$css->set_selector( '#mobile-header:not(.navigation-stick):not(.toggled) .mobile-header-logo:not(.page-hero-mobile-logo)' );
$css->add_property( 'display', 'none' );
$css->set_selector( '#mobile-header.navigation-stick .page-hero-mobile-logo, #mobile-header.toggled .page-hero-mobile-logo' );
$css->add_property( 'display', 'none' );
}
if ( $options['site_logo'] && GeneratePress_Elements_Helper::does_option_exist( 'site-logo' ) ) {
$css->set_selector( '.site-logo:not(.page-hero-logo)' );
$css->add_property( 'display', 'none' );
}
if ( 'merge-desktop' === $options['site_header_merge'] ) {
$css->stop_media_query();
}
if ( class_exists( 'Elementor\Plugin' ) ) {
$css->set_selector( '.elementor-editor-active .header-wrap' );
$css->add_property( 'pointer-events', 'none' );
}
}
$css->start_media_query( generate_premium_get_media_query( 'mobile' ) );
$css->set_selector( '.page-hero' );
if ( $options['padding_top_mobile'] || '0' === $options['padding_top_mobile'] ) {
$css->add_property( 'padding-top', absint( $options['padding_top_mobile'] ), false, esc_html( $options['padding_top_unit_mobile'] ) );
}
if ( 'merge' === $options['site_header_merge'] && $options['site_header_height_mobile'] ) {
if ( $options['padding_top_mobile'] || '0' === $options['padding_top_mobile'] ) {
$css->add_property( 'padding-top', 'calc(' . absint( $options['padding_top_mobile'] ) . esc_html( $options['padding_top_unit_mobile'] ) . ' + ' . absint( $options['site_header_height_mobile'] ) . 'px)' );
} elseif ( $options['padding_top'] ) {
$css->add_property( 'padding-top', 'calc(' . absint( $options['padding_top'] ) . esc_html( $options['padding_top_unit'] ) . ' + ' . absint( $options['site_header_height_mobile'] ) . 'px)' );
} else {
$css->add_property( 'padding-top', absint( $options['site_header_height_mobile'] ), false, 'px' );
}
}
if ( $options['padding_right_mobile'] || '0' === $options['padding_right_mobile'] ) {
$css->add_property( 'padding-right', absint( $options['padding_right_mobile'] ), false, esc_html( $options['padding_right_unit_mobile'] ) );
}
if ( $options['padding_bottom_mobile'] || '0' === $options['padding_bottom_mobile'] ) {
$css->add_property( 'padding-bottom', absint( $options['padding_bottom_mobile'] ), false, esc_html( $options['padding_bottom_unit_mobile'] ) );
}
if ( $options['padding_left_mobile'] || '0' === $options['padding_left_mobile'] ) {
$css->add_property( 'padding-left', absint( $options['padding_left_mobile'] ), false, esc_html( $options['padding_left_unit_mobile'] ) );
}
if ( GeneratePress_Elements_Helper::does_option_exist( 'site-logo' ) && 'merge-desktop' === $options['site_header_merge'] ) {
$css->set_selector( '.inside-header .page-hero-logo, .main-navigation .page-hero-logo, #mobile-header .page-hero-mobile-logo' );
$css->add_property( 'display', 'none' );
}
$css->stop_media_query();
return apply_filters( 'generate_page_hero_css_output', $css->css_output(), $options );
}
/**
* Put all of our meta options within an array.
*
* @since 1.7
*
* @return array All Page Header options.
*/
public static function get_options() {
$post_id = self::$post_id;
return apply_filters( 'generate_hero_options', array(
'element_id' => $post_id,
'content' => get_post_meta( $post_id, '_generate_element_content', true ),
'classes' => get_post_meta( $post_id, '_generate_hero_custom_classes', true ),
'container' => get_post_meta( $post_id, '_generate_hero_container', true ),
'inner_container' => get_post_meta( $post_id, '_generate_hero_inner_container', true ),
'horizontal_alignment' => get_post_meta( $post_id, '_generate_hero_horizontal_alignment', true ),
'full_screen' => get_post_meta( $post_id, '_generate_hero_full_screen', true ),
'vertical_alignment' => get_post_meta( $post_id, '_generate_hero_vertical_alignment', true ),
'padding_top' => get_post_meta( $post_id, '_generate_hero_padding_top', true ),
'padding_top_unit' => get_post_meta( $post_id, '_generate_hero_padding_top_unit', true ),
'padding_right' => get_post_meta( $post_id, '_generate_hero_padding_right', true ),
'padding_right_unit' => get_post_meta( $post_id, '_generate_hero_padding_right_unit', true ),
'padding_bottom' => get_post_meta( $post_id, '_generate_hero_padding_bottom', true ),
'padding_bottom_unit' => get_post_meta( $post_id, '_generate_hero_padding_bottom_unit', true ),
'padding_left' => get_post_meta( $post_id, '_generate_hero_padding_left', true ),
'padding_left_unit' => get_post_meta( $post_id, '_generate_hero_padding_left_unit', true ),
'padding_top_mobile' => get_post_meta( $post_id, '_generate_hero_padding_top_mobile', true ),
'padding_top_unit_mobile' => get_post_meta( $post_id, '_generate_hero_padding_top_unit_mobile', true ),
'padding_right_mobile' => get_post_meta( $post_id, '_generate_hero_padding_right_mobile', true ),
'padding_right_unit_mobile' => get_post_meta( $post_id, '_generate_hero_padding_right_unit_mobile', true ),
'padding_bottom_mobile' => get_post_meta( $post_id, '_generate_hero_padding_bottom_mobile', true ),
'padding_bottom_unit_mobile' => get_post_meta( $post_id, '_generate_hero_padding_bottom_unit_mobile', true ),
'padding_left_mobile' => get_post_meta( $post_id, '_generate_hero_padding_left_mobile', true ),
'padding_left_unit_mobile' => get_post_meta( $post_id, '_generate_hero_padding_left_unit_mobile', true ),
'background_image' => get_post_meta( $post_id, '_generate_hero_background_image', true ),
'disable_featured_image' => get_post_meta( $post_id, '_generate_hero_disable_featured_image', true ),
'background_overlay' => get_post_meta( $post_id, '_generate_hero_background_overlay', true ),
'background_position' => get_post_meta( $post_id, '_generate_hero_background_position', true ),
'parallax' => get_post_meta( $post_id, '_generate_hero_background_parallax', true ),
'background_color' => get_post_meta( $post_id, '_generate_hero_background_color', true ),
'text_color' => get_post_meta( $post_id, '_generate_hero_text_color', true ),
'link_color' => get_post_meta( $post_id, '_generate_hero_link_color', true ),
'link_color_hover' => get_post_meta( $post_id, '_generate_hero_background_link_color_hover', true ),
'site_header_merge' => get_post_meta( $post_id, '_generate_site_header_merge', true ),
'site_header_height' => get_post_meta( $post_id, '_generate_site_header_height', true ),
'site_header_height_mobile' => get_post_meta( $post_id, '_generate_site_header_height_mobile', true ),
'site_logo' => get_post_meta( $post_id, '_generate_site_logo', true ),
'retina_logo' => get_post_meta( $post_id, '_generate_retina_logo', true ),
'navigation_logo' => get_post_meta( $post_id, '_generate_navigation_logo', true ),
'mobile_logo' => get_post_meta( $post_id, '_generate_mobile_logo', true ),
'navigation_location' => get_post_meta( $post_id, '_generate_navigation_location', true ),
'header_background_color' => get_post_meta( $post_id, '_generate_site_header_background_color', true ),
'header_title_color' => get_post_meta( $post_id, '_generate_site_header_title_color', true ),
'header_tagline_color' => get_post_meta( $post_id, '_generate_site_header_tagline_color', true ),
'navigation_colors' => get_post_meta( $post_id, '_generate_navigation_colors', true ),
'navigation_background_color' => get_post_meta( $post_id, '_generate_navigation_background_color', true ),
'navigation_text_color' => get_post_meta( $post_id, '_generate_navigation_text_color', true ),
'navigation_background_color_hover' => get_post_meta( $post_id, '_generate_navigation_background_color_hover', true ),
'navigation_text_color_hover' => get_post_meta( $post_id, '_generate_navigation_text_color_hover', true ),
'navigation_background_color_current' => get_post_meta( $post_id, '_generate_navigation_background_color_current', true ),
'navigation_text_color_current' => get_post_meta( $post_id, '_generate_navigation_text_color_current', true ),
) );
}
/**
* Does the bulk of the work after everything has initialized.
*
* @since 1.7
*/
public function after_setup() {
$options = self::get_options();
if ( $options['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 ( $options['site_logo'] && GeneratePress_Elements_Helper::does_option_exist( 'site-logo' ) ) {
if ( '' !== $options['site_header_merge'] ) {
add_action( 'generate_after_logo', array( $this, 'add_site_logo' ) );
} else {
add_filter( 'theme_mod_custom_logo', array( $this, 'replace_logo' ) );
if ( $options['retina_logo'] && GeneratePress_Elements_Helper::does_option_exist( 'retina-logo' ) ) {
add_filter( 'generate_retina_logo', array( $this, 'replace_logo' ) );
}
}
}
if ( $options['navigation_logo'] && GeneratePress_Elements_Helper::does_option_exist( 'navigation-logo' ) ) {
if ( $options['site_header_merge'] && GeneratePress_Elements_Helper::does_option_exist( 'sticky-navigation' ) ) {
add_action( 'generate_inside_navigation', array( $this, 'add_navigation_logo' ) );
} else {
add_filter( 'generate_navigation_logo', array( $this, 'replace_logo' ) );
}
}
if ( $options['mobile_logo'] && GeneratePress_Elements_Helper::does_option_exist( 'mobile-logo' ) ) {
if ( 'merge' === $options['site_header_merge'] ) {
add_action( 'generate_inside_mobile_header', array( $this, 'add_mobile_header_logo' ) );
} else {
add_filter( 'generate_mobile_header_logo', array( $this, 'replace_logo' ) );
}
}
if ( $options['navigation_location'] ) {
add_filter( 'generate_navigation_location', array( $this, 'navigation_location' ) );
}
if ( '' !== $options['site_header_merge'] ) {
add_action( 'generate_before_header', array( $this, 'merged_header_start' ), 1 );
add_action( 'generate_after_header', array( $this, 'merged_header_end' ), 8 );
if ( 'contained' === $options['container'] ) {
add_filter( 'generate_header_class', array( $this, 'site_header_classes' ) );
}
}
if ( $options['content'] ) {
self::remove_template_elements();
}
}
/**
* Returns our custom logos if set within the Page Header.
*
* @since 1.7
*
* @return string New URLs to images.
*/
public static function replace_logo() {
$filter = current_filter();
$options = self::get_options();
if ( 'theme_mod_custom_logo' === $filter ) {
return $options['site_logo'];
}
if ( 'generate_retina_logo' === $filter ) {
return wp_get_attachment_url( $options['retina_logo'] );
}
if ( 'generate_navigation_logo' === $filter ) {
return wp_get_attachment_url( $options['navigation_logo'] );
}
if ( 'generate_mobile_header_logo' === $filter ) {
return wp_get_attachment_url( $options['mobile_logo'] );
}
}
/**
* Adds a new site logo element if our header is merged on desktop only.
*
* @since 1.7
*/
public static function add_site_logo() {
$options = self::get_options();
$logo_url = wp_get_attachment_url( $options['site_logo'] );
$retina_logo_url = wp_get_attachment_url( $options['retina_logo'] );
if ( ! $logo_url ) {
return;
}
$attr = apply_filters( 'generate_page_hero_logo_attributes', array(
'class' => 'header-image',
'alt' => esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
'src' => $logo_url,
'title' => esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
) );
if ( '' !== $retina_logo_url ) {
$attr['srcset'] = $logo_url . ' 1x, ' . $retina_logo_url . ' 2x';
// Add dimensions to image if retina is set. This fixes a container width bug in Firefox.
$data = wp_get_attachment_metadata( $options['site_logo'] );
if ( ! empty( $data ) ) {
$attr['width'] = $data['width'];
$attr['height'] = $data['height'];
}
}
$attr = array_map( 'esc_attr', $attr );
$html_attr = '';
foreach ( $attr as $name => $value ) {
$html_attr .= " $name=" . '"' . $value . '"';
}
echo apply_filters( 'generate_page_hero_logo_output', sprintf( // WPCS: XSS ok, sanitization ok.
'<div class="site-logo page-hero-logo">
<a href="%1$s" title="%2$s" rel="home">
<img %3$s />
</a>
</div>',
esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ),
esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
$html_attr
), $logo_url, $html_attr );
}
/**
* Adds the custom navigation logo if needed.
* Only needed if there's a sticky navigation.
*
* @since 1.7
*/
public static function add_navigation_logo() {
$options = self::get_options();
printf(
'<div class="site-logo sticky-logo navigation-logo page-hero-navigation-logo">
<a href="%1$s" title="%2$s" rel="home">
<img class="header-image" src="%3$s" alt="%4$s" />
</a>
</div>',
esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ),
esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
esc_url( wp_get_attachment_url( $options['navigation_logo'] ) ),
esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) )
);
}
/**
* Adds the custom mobile header if needed.
* Only needed if there's a sticky navigation.
*
* @since 1.7
*/
public static function add_mobile_header_logo() {
$options = self::get_options();
if ( 'title' === GeneratePress_Elements_Helper::does_option_exist( 'mobile-header-branding' ) ) {
return;
}
printf(
'<div class="site-logo mobile-header-logo page-hero-mobile-logo">
<a href="%1$s" title="%2$s" rel="home">
<img class="header-image" src="%3$s" alt="%4$s" />
</a>
</div>',
esc_url( apply_filters( 'generate_logo_href' , home_url( '/' ) ) ),
esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) ),
esc_url( wp_get_attachment_url( $options['mobile_logo'] ) ),
esc_attr( apply_filters( 'generate_logo_title', get_bloginfo( 'name', 'display' ) ) )
);
}
/**
* Set the navigation location if set.
*
* @since 1.7
*
* @return string The navigation location.
*/
public static function navigation_location() {
$options = self::get_options();
if ( 'no-navigation' === $options['navigation_location'] ) {
return '';
} else {
return $options['navigation_location'];
}
}
/**
* The opening merged header element.
*
* @since 1.7
*/
public static function merged_header_start() {
echo '<div class="header-wrap">';
}
/**
* The closing merged header element.
*
* @since 1.7
*/
public static function merged_header_end() {
echo '</div><!-- .header-wrap -->';
}
/**
* Adds classes to the site header.
*
* @since 1.7
*
* @param $classes Existing classes.
* @return array New classes.
*/
public static function site_header_classes( $classes ) {
$classes[] = 'grid-container';
$classes[] = 'grid-parent';
return $classes;
}
/**
* Checks if template tags exist, and removes those elements from elsewhere.
*
* @since 1.7
*/
public static function remove_template_elements() {
$options = self::get_options();
if ( strpos( $options[ 'content' ], '{{post_title}}' ) !== false ) {
add_filter( 'generate_show_title', '__return_false' );
remove_action( 'generate_archive_title', 'generate_archive_title' );
add_filter( 'post_class', array( self::$hero, 'remove_hentry' ) );
}
if ( strpos( $options[ 'content' ], '{{post_date}}' ) !== false ) {
add_filter( 'generate_post_date', '__return_false' );
add_filter( 'post_class', array( self::$hero, 'remove_hentry' ) );
}
if ( strpos( $options[ 'content' ], '{{post_author}}' ) !== false ) {
add_filter( 'generate_post_author', '__return_false' );
add_filter( 'post_class', array( self::$hero, 'remove_hentry' ) );
}
if ( strpos( $options[ 'content' ], '{{post_terms.category}}' ) !== false ) {
add_filter( 'generate_show_categories', '__return_false' );
}
if ( strpos( $options[ 'content' ], '{{post_terms.post_tag}}' ) !== false ) {
add_filter( 'generate_show_tags', '__return_false' );
}
}
/**
* Checks for template tags and replaces them.
*
* @since 1.7
*
* @param $content The content to check.
* @return mixed The content with the template tags replaced.
*/
public static function template_tags( $content ) {
$search = array();
$replace = array();
$search[] = '{{post_title}}';
$post_title = '';
if ( is_singular() ) {
$post_title = get_the_title();
} elseif ( is_tax() || is_category() || is_tag() ) {
$post_title = get_queried_object()->name;
} elseif ( is_post_type_archive() ) {
$post_title = post_type_archive_title( '', false );
} elseif ( is_archive() && function_exists( 'get_the_archive_title' ) ) {
$post_title = get_the_archive_title();
} elseif ( is_home() ) {
$post_title = __( 'Blog', 'gp-premium' );
}
$replace[] = apply_filters( 'generate_page_hero_post_title', $post_title );
if ( is_singular() ) {
$time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time>';
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
$time_string = '<time class="updated" datetime="%3$s" itemprop="dateModified">%4$s</time>' . $time_string;
}
$time_string = sprintf( $time_string,
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() ),
esc_attr( get_the_modified_date( 'c' ) ),
esc_html( get_the_modified_date() )
);
$search[] = '{{post_date}}';
$replace[] = apply_filters( 'generate_page_hero_post_date', $time_string );
// Author
global $post;
$author_id = $post->post_author;
$author = sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author"><a class="url fn n" href="%1$s" title="%2$s" rel="author" itemprop="url"><span class="author-name" itemprop="name">%3$s</span></a></span>',
esc_url( get_author_posts_url( $author_id ) ),
esc_attr( sprintf( __( 'View all posts by %s', 'gp-premium' ), get_the_author_meta( 'display_name', $author_id ) ) ),
esc_html( get_the_author_meta( 'display_name', $author_id ) )
);
$search[] = '{{post_author}}';
$replace[] = apply_filters( 'generate_page_hero_post_author', $author );
// Post terms
if ( strpos( $content, '{{post_terms' ) !== false ) {
$data = preg_match_all( '/{{post_terms.([^}]*)}}/', $content, $matches );
foreach ( $matches[1] as $match ) {
$search[] = '{{post_terms.' . $match . '}}';
$terms = get_the_term_list( get_the_ID(), $match, apply_filters( 'generate_page_hero_terms_before', '' ), apply_filters( 'generate_page_hero_terms_separator', ', ' ), apply_filters( 'generate_page_hero_terms_after', '' ) );
if ( ! is_wp_error( $terms ) ) {
$replace[] = $terms;
}
}
}
// Custom field
if ( strpos( $content, '{{custom_field' ) !== false ) {
$data = preg_match_all( '/{{custom_field.([^}]*)}}/', $content, $matches );
foreach ( $matches[1] as $match ) {
if ( null !== get_post_meta( get_the_ID(), $match, true ) && '_thumbnail_id' !== $match ) {
$search[] = '{{custom_field.' . $match . '}}';
$replace[] = get_post_meta( get_the_ID(), $match, true );
}
}
$thumbnail_id = get_post_meta( get_the_ID(), '_thumbnail_id', true );
if ( null !== $thumbnail_id ) {
$search[] = '{{custom_field._thumbnail_id}}';
$replace[] = wp_get_attachment_image( $thumbnail_id, apply_filters( 'generate_hero_thumbnail_id_size', 'medium' ) );
}
}
}
// Taxonomy description
if ( is_tax() || is_category() || is_tag() ) {
if ( strpos( $content, '{{custom_field' ) !== false ) {
$search[] = '{{custom_field.description}}';
$replace[] = term_description( get_queried_object()->term_id, get_queried_object()->taxonomy );
}
}
return str_replace( $search, $replace, $content );
}
/**
* When the post title, author or date are in the Page Hero, they appear outside of the
* hentry element. This causes errors in Google Search Console.
*
* @since 1.7
*
* @param array $classes
* @return array
*/
public function remove_hentry( $classes ) {
$classes = array_diff( $classes, array( 'hentry' ) );
return $classes;
}
}

View File

@ -0,0 +1,189 @@
<?php
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
*/
protected $content = '';
/**
* Set our hook/action variable.
*
* @since 1.7
*/
protected $hook = '';
/**
* Set our custom hook variable.
*
* @since 1.7
*/
protected $custom_hook = '';
/**
* Set our disable site header variable.
*
* @since 1.7
*/
protected $disable_site_header = false;
/**
* Set our disable footer variable.
*
* @since 1.7
*/
protected $disable_site_footer = false;
/**
* Set our priority variable.
*
* @since 1.7
*/
protected $priority = 10;
/**
* Set our execute PHP variable.
*
* @since 1.7
*/
protected $php = false;
/**
* Set our execute shortcodes variable.
*
* @since 1.7
*/
protected $shortcodes = false;
/**
* Set our location variable.
*
* @since 1.7
*/
protected $conditional = array();
/**
* Set our exclusions variable.
*
* @since 1.7
*/
protected $exclude = array();
/**
* Set our user condition variable.
*
* @since 1.7
*/
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
*/
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 );
if ( $display ) {
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();
// @codingStandardsIgnoreStart
eval( '?>' . $content . '<?php ' );
// @codingStandardsIgnoreEnd
echo ob_get_clean();
} else {
echo $content;
}
}
}

View File

@ -0,0 +1,296 @@
<?php
class GeneratePress_Site_Layout {
/**
* Set our location variable.
*
* @since 1.7
*/
protected $conditional = array();
/**
* Set our exclusion variable.
*
* @since 1.7
*/
protected $exclude = array();
/**
* Set our user condition variable.
*
* @since 1.7
*/
protected $users = array();
/**
* Set up our other options.
*
* @since 1.7
* @deprecated 1.7.3
*/
protected static $options = array();
/**
* Set up options.
*
* @since 1.7.3
*/
protected $sidebar_layout = null;
protected $footer_widgets = null;
protected $disable_site_header = null;
protected $disable_top_bar = null;
protected $disable_primary_navigation = null;
protected $disable_secondary_navigation = null;
protected $disable_featured_image = null;
protected $disable_content_title = null;
protected $disable_footer = null;
protected $content_area = null;
protected $content_width = null;
/**
* Set our post ID.
*
* @since 1.7
*/
protected static $post_id = '';
/**
* Count how many instances are set.
*
* @since 1.7
* @deprecated 1.7.3
*/
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.
*/
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_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 );
if ( $display ) {
add_action( 'wp', array( $this, 'after_setup' ), 100 );
add_action( 'wp_enqueue_scripts', 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_top_bar ) {
remove_action( 'generate_before_header', 'generate_top_bar', 5 );
}
if ( $this->disable_primary_navigation ) {
add_filter( 'generate_navigation_location', '__return_false', 20 );
remove_action( 'generate_after_header', 'generate_menu_plus_mobile_header', 5 );
}
if ( $this->disable_secondary_navigation ) {
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' );
}
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' ) );
}
}
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;}' );
}
}
/**
* 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;
}
/**
* Filter our filterable options.
*
* @since 1.7
*/
public function filter_options() {
$filter = current_filter();
if ( 'generate_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;
}
}
}
/**
* Disable the Secondary Navigation if set.
*
* @since 1.7
*
* @param bool $has_nav_menu
* @param string $location
* @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;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,277 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
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' ) );
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_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' ),
);
$args = array(
'labels' => $labels,
'supports' => array( 'title', 'thumbnail' ),
'hierarchical' => false,
'public' => false,
'show_ui' => true,
'show_in_menu' => false,
'can_export' => true,
'has_archive' => false,
'exclude_from_search' => true,
);
register_post_type( 'gp_elements', $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() {
if ( 'gp_elements' !== get_post_type() ) {
return;
}
$values = array(
'header' => esc_html__( 'Headers', 'gp-premium' ),
'hook' => esc_html__( 'Hooks', 'gp-premium' ),
'layout' => esc_html__( 'Layouts', 'gp-premium' ),
);
?>
<select name="gp_element_type_filter">
<option value=""><?php esc_html_e( 'All types', 'gp-premium' ); ?></option>
<?php
$current = isset( $_GET['gp_element_type_filter'] )? esc_html( $_GET['gp_element_type_filter'] ) : '';
foreach ( $values as $value => $label ) {
printf(
'<option value="%1$s" %2$s>%3$s</option>',
esc_html( $value ),
$value === $current ? 'selected="selected"' : '',
$label
);
}
?>
</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 ) {
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'] : '';
if ( 'edit.php' === $pagenow && $query->is_main_query() && '' !== $type ) {
$query->set( 'meta_key', '_generate_element_type' );
$query->set( 'meta_value', esc_attr( $type ) );
}
}
/**
* 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 );
if ( 'header' === $type ) {
echo esc_html__( 'Header', 'gp-premium' );
}
if ( 'hook' === $type ) {
echo esc_html__( 'Hook', 'gp-premium' );
}
if ( 'layout' === $type ) {
echo esc_html__( 'Layout', 'gp-premium' );
}
break;
case 'location' :
$location = get_post_meta( $post_id, '_generate_element_display_conditions', true );
if ( $location ) {
foreach ( ( array ) $location as $data ) {
echo GeneratePress_Conditions::get_saved_label( $data );
echo '<br />';
}
}
break;
case 'exclusions' :
$location = get_post_meta( $post_id, '_generate_element_exclude_conditions', true );
if ( $location ) {
foreach ( ( array ) $location as $data ) {
echo GeneratePress_Conditions::get_saved_label( $data );
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 $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';
$submenu_file = 'edit.php?post_type=gp_elements';
}
}
}
GeneratePress_Elements_Post_Type::get_instance();

View File

@ -0,0 +1,99 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
require plugin_dir_path( __FILE__ ) . 'class-elements-helper.php';
require plugin_dir_path( __FILE__ ) . 'class-hooks.php';
require plugin_dir_path( __FILE__ ) . 'class-hero.php';
require plugin_dir_path( __FILE__ ) . 'class-layout.php';
require plugin_dir_path( __FILE__ ) . 'class-conditions.php';
require plugin_dir_path( __FILE__ ) . 'class-post-type.php';
add_action( 'wp', '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,
'fields' => 'ids',
'order' => 'ASC',
'suppress_filters' => false,
);
// 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 );
}
}
}
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 ) {
$tabs['Elements'] = array(
'name' => __( 'Elements', 'gp-premium' ),
'url' => admin_url( 'edit.php?post_type=gp_elements' ),
'class' => '',
);
return $tabs;
}
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
* @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' ) ) {
return false;
}
}
return $post_id;
}

View File

@ -0,0 +1,80 @@
<?php
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
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
*/
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.ttf') format('truetype'),
url('gp-premium.woff') format('woff'),
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.ttf) format('truetype'),url(gp-premium.woff) format('woff'),url(gp-premium.svg#gp-premium) format('svg');font-weight:400;font-style:normal}

View File

@ -0,0 +1,741 @@
/*!
* 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 scroll = new SmoothScroll( smooth.elements.join(), {
speed: smooth.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 offset;
}
} );

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,94 @@
<?php
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
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',
'smooth',
array(
'elements' => apply_filters( 'generate_smooth_scroll_elements', array(
'.smooth-scroll',
'li.smooth-scroll a',
) ),
'duration' => apply_filters( 'generate_smooth_scroll_duration', 800 )
)
);
}
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,285 @@
<?php
/*
Plugin Name: GP Premium
Plugin URI: https://generatepress.com
Description: The entire collection of GeneratePress premium modules.
Version: 1.9.1
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
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
// Set our version
define( 'GP_PREMIUM_VERSION', '1.9.1' );
// Set our library directory
define( 'GP_LIBRARY_DIRECTORY', plugin_dir_path( __FILE__ ) . 'library/' );
define( 'GP_LIBRARY_DIRECTORY_URL', plugin_dir_url( __FILE__ ) . 'library/' );
if ( ! function_exists( 'generatepress_is_module_active' ) ) {
/**
* Check to see if an add-ons is active
* module: Check the database entry
* definition: Check to see if defined in wp-config.php
**/
function generatepress_is_module_active( $module, $definition ) {
// If we don't have the module or definition, bail.
if ( ! $module && ! $definition ) {
return false;
}
// If our module is active, return true.
if ( 'activated' == get_option( $module ) || defined( $definition ) ) {
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/' );
}
}
// Backgrounds
if ( generatepress_is_module_active( 'generate_package_backgrounds', 'GENERATE_BACKGROUNDS' ) ) {
require_once plugin_dir_path( __FILE__ ) . 'backgrounds/generate-backgrounds.php';
}
// Blog
if ( generatepress_is_module_active( 'generate_package_blog', 'GENERATE_BLOG' ) ) {
require_once plugin_dir_path( __FILE__ ) . 'blog/generate-blog.php';
}
// Colors
if ( generatepress_is_module_active( 'generate_package_colors', 'GENERATE_COLORS' ) ) {
require_once plugin_dir_path( __FILE__ ) . 'colors/generate-colors.php';
}
// Copyright
if ( generatepress_is_module_active( 'generate_package_copyright', 'GENERATE_COPYRIGHT' ) ) {
require_once plugin_dir_path( __FILE__ ) . 'copyright/generate-copyright.php';
}
// Disable Elements
if ( generatepress_is_module_active( 'generate_package_disable_elements', 'GENERATE_DISABLE_ELEMENTS' ) ) {
require_once plugin_dir_path( __FILE__ ) . 'disable-elements/generate-disable-elements.php';
}
// Elements
if ( generatepress_is_module_active( 'generate_package_elements', 'GENERATE_ELEMENTS' ) ) {
require_once plugin_dir_path( __FILE__ ) . 'elements/elements.php';
}
// Hooks
if ( generatepress_is_module_active( 'generate_package_hooks', 'GENERATE_HOOKS' ) ) {
require_once plugin_dir_path( __FILE__ ) . 'hooks/generate-hooks.php';
}
// Page Header
if ( generatepress_is_module_active( 'generate_package_page_header', 'GENERATE_PAGE_HEADER' ) ) {
require_once plugin_dir_path( __FILE__ ) . 'page-header/generate-page-header.php';
}
// Secondary Navigation
if ( generatepress_is_module_active( 'generate_package_secondary_nav', 'GENERATE_SECONDARY_NAV' ) ) {
require_once plugin_dir_path( __FILE__ ) . 'secondary-nav/generate-secondary-nav.php';
}
// Spacing
if ( generatepress_is_module_active( 'generate_package_spacing', 'GENERATE_SPACING' ) ) {
require_once plugin_dir_path( __FILE__ ) . 'spacing/generate-spacing.php';
}
// Typography
if ( generatepress_is_module_active( 'generate_package_typography', 'GENERATE_TYPOGRAPHY' ) ) {
require_once plugin_dir_path( __FILE__ ) . 'typography/generate-fonts.php';
}
// Sections
if ( generatepress_is_module_active( 'generate_package_sections', 'GENERATE_SECTIONS' ) ) {
require_once plugin_dir_path( __FILE__ ) . 'sections/generate-sections.php';
}
// Menu Plus
if ( generatepress_is_module_active( 'generate_package_menu_plus', 'GENERATE_MENU_PLUS' ) ) {
require_once plugin_dir_path( __FILE__ ) . 'menu-plus/generate-menu-plus.php';
}
// WooCommerce
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 plugin_dir_path( __FILE__ ) . 'woocommerce/woocommerce.php';
}
}
// General
require_once plugin_dir_path( __FILE__ ) . 'inc/functions.php';
require_once plugin_dir_path( __FILE__ ) . 'general/smooth-scroll.php';
require_once plugin_dir_path( __FILE__ ) . 'general/icons.php';
// Deprecated functions.
require_once plugin_dir_path( __FILE__ ) . 'inc/deprecated.php';
// Load admin-only files.
if ( is_admin() ) {
require_once plugin_dir_path( __FILE__ ) . 'inc/reset.php';
require_once plugin_dir_path( __FILE__ ) . 'import-export/generate-ie.php';
if ( generatepress_is_module_active( 'generate_package_site_library', 'GENERATE_SITE_LIBRARY' ) && version_compare( PHP_VERSION, '5.4', '>=' ) && ! defined( 'GENERATE_DISABLE_SITE_LIBRARY' ) ) {
require_once plugin_dir_path( __FILE__ ) . 'sites/sites.php';
}
require_once plugin_dir_path( __FILE__ ) . 'inc/activation.php';
require_once plugin_dir_path( __FILE__ ) . 'inc/dashboard.php';
}
if ( ! function_exists( 'generate_premium_updater' ) ) {
add_action( 'admin_init', 'generate_premium_updater', 0 );
/**
* Set up the updater
**/
function generate_premium_updater() {
// Load EDD SL Plugin Updater
if ( ! class_exists( 'EDD_SL_Plugin_Updater' ) ) {
include( dirname( __FILE__ ) . '/library/EDD_SL_Plugin_Updater.php' );
}
// retrieve our license key from the DB
$license_key = get_option( 'gen_premium_license_key' );
// setup the updater
$edd_updater = new EDD_SL_Plugin_Updater( 'https://generatepress.com', __FILE__, array(
'version' => GP_PREMIUM_VERSION,
'license' => trim( $license_key ),
'item_name' => 'GP Premium',
'author' => 'Tom Usborne',
'url' => home_url(),
'beta' => apply_filters( 'generate_premium_beta_tester', false ),
)
);
}
}
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() {
// Get our theme data
$theme = wp_get_theme();
// If we're using GeneratePress
if ( 'GeneratePress' == $theme->name || 'generatepress' == $theme->template ) {
// Get our information on updates
// Taken from https://developer.wordpress.org/reference/functions/wp_prepare_themes_for_js/
$updates = array();
if ( current_user_can( 'update_themes' ) ) {
$updates_transient = get_site_transient( 'update_themes' );
if ( isset( $updates_transient->response ) ) {
$updates = $updates_transient->response;
}
}
// Check what admin page we're on
$screen = get_current_screen();
// If a GeneratePress update exists, and we're not on the themes page.
// No need to tell people an update exists on the themes page, WP does that for us.
if ( isset( $updates[ 'generatepress' ] ) && 'themes' !== $screen->base ) {
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="https://generatepress.com/install-generatepress" target="_blank">%2$s</a></p>
</div>',
esc_html__( 'GP Premium requires GeneratePress to be your active theme.', 'gp-premium' ),
esc_html__( 'Install now.', 'gp-premium' )
);
}
}
}
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
*/
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,66 @@
#gp_hooks_settings .form-table td,
#gp_hooks_settings .form-table th {
padding: 30px;
background: #FFF;
display: block;
width: 100%;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
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;
-moz-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
-webkit-box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.04);
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
.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,534 @@
<?php
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Add any necessary files
require plugin_dir_path( __FILE__ ) . 'hooks.php';
if ( ! function_exists( 'generate_hooks_get_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' , 'generate-hooks' ) ) . '" />';
$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( document ).ready( 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,19 @@
<?php
/*
Addon Name: Generate Hooks
Author: Thomas Usborne
Author URI: http://edge22.com
*/
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// 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,358 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
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 _e( 'Export Settings', 'gp-premium' );?></h3>
<div class="inside">
<form method="post">
<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>
</div>
</div>
<div class="postbox generate-metabox" id="generate-ie">
<h3 class="hndle"><?php _e( 'Import Settings', 'gp-premium' );?></h3>
<div class="inside">
<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( 'm-d-Y' ) . '.json' );
header( "Expires: 0" );
echo 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 ( $extension != 'json' ) {
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 );
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' );
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,19 @@
<?php
/*
Addon Name: Generate Import Export
Author: Thomas Usborne
Author URI: http://edge22.com
*/
// No direct access, please
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Define the version
if ( ! defined( 'GENERATE_IE_VERSION' ) ) {
define( 'GENERATE_IE_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,597 @@
<?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';
}
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
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' );?>"/>
</div>
</div>
<?php } else {
if ( 'Page Header' === $k || 'Hooks' === $k ) {
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' );?>"/>
<?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 ) ) {
$message = $license_response->get_error_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,204 @@
.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;
}
.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;
-moz-box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.1) inset;
-webkit-box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.1) inset;
box-shadow: 0 -1px 0 rgba(0, 0, 0, 0.1) inset;
}
.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;
-moz-box-shadow: 0 0 0 transparent;
-webkit-box-shadow: 0 0 0 transparent;
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;
-moz-box-shadow: 0 0 0 transparent;
-webkit-box-shadow: 0 0 0 transparent;
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,37 @@
jQuery( document ).ready(function( $ ) {
$( '#generate-select-all' ).on( 'click', function( event ) {
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() {
var check = confirm( dashboard.deprecated_module );
if ( ! check ) {
return false;
}
} );
$( 'input[name="generate_package_page_header_deactivate_package"]' ).on( 'click', function() {
var check = confirm( dashboard.deprecated_module );
if ( ! check ) {
return false;
}
} );
});

View File

@ -0,0 +1,42 @@
<?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 );
/**
* Adds our tabs to the GeneratePress dashboard.
*
* @since 1.6
*/
function generate_do_dashboard_tabs() {
$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,663 @@
<?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;
}
}
/**
* 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 );
}
}
}
/**
* 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' )
);
}
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.
}

View File

@ -0,0 +1,25 @@
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // No direct access, please.
}
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 ];
}

View File

@ -0,0 +1,247 @@
<?php
defined( 'WPINC' ) or die;
add_action( 'generate_admin_right_panel', 'generate_premium_reset_metabox', 25 );
function generate_premium_reset_metabox() {
?>
<div class="postbox generate-metabox" id="generate-reset">
<h3 class="hndle"><?php _e( 'Reset Settings', 'gp-premium' );?></h3>
<div class="inside">
<form method="post">
<span class="show-advanced"><?php _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' );
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_option( 'generate_dynamic_css_output' );
delete_option( 'generate_dynamic_css_cached_version' );
// 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 );
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 );
function generate_reset_options_scripts() {
$screen = get_current_screen();
if ( ! is_object( $screen ) ) {
return;
}
if ( 'appearance_page_generate-options' !== $screen->base ) {
return;
}
?>
<script>
jQuery( document ).ready( function($) {
$( '.show-advanced' ).on( 'click', function() {
$( this ).toggleClass( 'active' );
$( this ).next( '.advanced-choices' ).toggleClass( 'show' );
} );
} );
</script>
<?php
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,572 @@
<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
/**
* Allows plugins to use their own update API.
*
* @author Easy Digital Downloads
* @version 1.6.18
*/
class EDD_SL_Plugin_Updater {
private $api_url = '';
private $api_data = array();
private $name = '';
private $slug = '';
private $version = '';
private $wp_override = false;
private $cache_key = '';
private $health_check_timeout = 5;
/**
* Class constructor.
*
* @uses plugin_basename()
* @uses hook()
*
* @param string $_api_url The URL pointing to the custom API endpoint.
* @param string $_plugin_file Path to the plugin file.
* @param array $_api_data Optional data to send with API calls.
*/
public function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
global $edd_plugin_data;
$this->api_url = trailingslashit( $_api_url );
$this->api_data = $_api_data;
$this->name = plugin_basename( $_plugin_file );
$this->slug = basename( $_plugin_file, '.php' );
$this->version = $_api_data['version'];
$this->wp_override = isset( $_api_data['wp_override'] ) ? (bool) $_api_data['wp_override'] : false;
$this->beta = ! empty( $this->api_data['beta'] ) ? true : false;
$this->cache_key = 'edd_sl_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
$edd_plugin_data[ $this->slug ] = $this->api_data;
/**
* Fires after the $edd_plugin_data is setup.
*
* @since x.x.x
*
* @param array $edd_plugin_data Array of EDD SL plugin data.
*/
do_action( 'post_edd_sl_plugin_updater_setup', $edd_plugin_data );
// Set up hooks.
$this->init();
}
/**
* Set up WordPress filters to hook into WP's update process.
*
* @uses add_filter()
*
* @return void
*/
public function init() {
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
remove_action( 'after_plugin_row_' . $this->name, 'wp_plugin_update_row', 10 );
add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 );
add_action( 'admin_init', array( $this, 'show_changelog' ) );
}
/**
* Check for Updates at the defined API endpoint and modify the update array.
*
* This function dives into the update API just when WordPress creates its update array,
* then adds a custom API call and injects the custom plugin data retrieved from the API.
* It is reassembled from parts of the native WordPress plugin update code.
* See wp-includes/update.php line 121 for the original wp_update_plugins() function.
*
* @uses api_request()
*
* @param array $_transient_data Update array build by WordPress.
* @return array Modified update array with custom plugin data.
*/
public function check_update( $_transient_data ) {
global $pagenow;
if ( ! is_object( $_transient_data ) ) {
$_transient_data = new stdClass;
}
if ( 'plugins.php' == $pagenow && is_multisite() ) {
return $_transient_data;
}
if ( ! empty( $_transient_data->response ) && ! empty( $_transient_data->response[ $this->name ] ) && false === $this->wp_override ) {
return $_transient_data;
}
$version_info = $this->get_cached_version_info();
if ( false === $version_info ) {
$version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
$this->set_version_info_cache( $version_info );
}
if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
$_transient_data->response[ $this->name ] = $version_info;
// Make sure the plugin property is set to the plugin's name/location. See issue 1463 on Software Licensing's GitHub repo.
$_transient_data->response[ $this->name ]->plugin = $this->name;
}
$_transient_data->last_checked = time();
$_transient_data->checked[ $this->name ] = $this->version;
}
return $_transient_data;
}
/**
* show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise!
*
* @param string $file
* @param array $plugin
*/
public function show_update_notification( $file, $plugin ) {
if ( is_network_admin() ) {
return;
}
if( ! current_user_can( 'update_plugins' ) ) {
return;
}
if( ! is_multisite() ) {
return;
}
if ( $this->name != $file ) {
return;
}
// Remove our filter on the site transient
remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
$update_cache = get_site_transient( 'update_plugins' );
$update_cache = is_object( $update_cache ) ? $update_cache : new stdClass();
if ( empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
$version_info = $this->get_cached_version_info();
if ( false === $version_info ) {
$version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug, 'beta' => $this->beta ) );
// Since we disabled our filter for the transient, we aren't running our object conversion on banners, sections, or icons. Do this now:
if ( isset( $version_info->banners ) && ! is_array( $version_info->banners ) ) {
$version_info->banners = $this->convert_object_to_array( $version_info->banners );
}
if ( isset( $version_info->sections ) && ! is_array( $version_info->sections ) ) {
$version_info->sections = $this->convert_object_to_array( $version_info->sections );
}
if ( isset( $version_info->icons ) && ! is_array( $version_info->icons ) ) {
$version_info->icons = $this->convert_object_to_array( $version_info->icons );
}
$this->set_version_info_cache( $version_info );
}
if ( ! is_object( $version_info ) ) {
return;
}
if ( version_compare( $this->version, $version_info->new_version, '<' ) ) {
$update_cache->response[ $this->name ] = $version_info;
}
$update_cache->last_checked = time();
$update_cache->checked[ $this->name ] = $this->version;
set_site_transient( 'update_plugins', $update_cache );
} else {
$version_info = $update_cache->response[ $this->name ];
}
// Restore our filter
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
// build a plugin list row, with update notification
$wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
# <tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange">
echo '<tr class="plugin-update-tr" id="' . $this->slug . '-update" data-slug="' . $this->slug . '" data-plugin="' . $this->slug . '/' . $file . '">';
echo '<td colspan="3" class="plugin-update colspanchange">';
echo '<div class="update-message notice inline notice-warning notice-alt">';
$changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' );
if ( empty( $version_info->download_link ) ) {
printf(
__( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s.', 'easy-digital-downloads' ),
esc_html( $version_info->name ),
'<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
esc_html( $version_info->new_version ),
'</a>'
);
} else {
printf(
__( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s or %5$supdate now%6$s.', 'easy-digital-downloads' ),
esc_html( $version_info->name ),
'<a target="_blank" class="thickbox" href="' . esc_url( $changelog_link ) . '">',
esc_html( $version_info->new_version ),
'</a>',
'<a href="' . esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) ) .'">',
'</a>'
);
}
do_action( "in_plugin_update_message-{$file}", $plugin, $version_info );
echo '</div></td></tr>';
}
}
/**
* Updates information on the "View version x.x details" page with custom data.
*
* @uses api_request()
*
* @param mixed $_data
* @param string $_action
* @param object $_args
* @return object $_data
*/
public function plugins_api_filter( $_data, $_action = '', $_args = null ) {
if ( $_action != 'plugin_information' ) {
return $_data;
}
if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) {
return $_data;
}
$to_send = array(
'slug' => $this->slug,
'is_ssl' => is_ssl(),
'fields' => array(
'banners' => array(),
'reviews' => false,
'icons' => array(),
)
);
$cache_key = 'edd_api_request_' . md5( serialize( $this->slug . $this->api_data['license'] . $this->beta ) );
// Get the transient where we store the api request for this plugin for 24 hours
$edd_api_request_transient = $this->get_cached_version_info( $cache_key );
//If we have no transient-saved value, run the API, set a fresh transient with the API value, and return that value too right now.
if ( empty( $edd_api_request_transient ) ) {
$api_response = $this->api_request( 'plugin_information', $to_send );
// Expires in 3 hours
$this->set_version_info_cache( $api_response, $cache_key );
if ( false !== $api_response ) {
$_data = $api_response;
}
} else {
$_data = $edd_api_request_transient;
}
// Convert sections into an associative array, since we're getting an object, but Core expects an array.
if ( isset( $_data->sections ) && ! is_array( $_data->sections ) ) {
$_data->sections = $this->convert_object_to_array( $_data->sections );
}
// Convert banners into an associative array, since we're getting an object, but Core expects an array.
if ( isset( $_data->banners ) && ! is_array( $_data->banners ) ) {
$_data->banners = $this->convert_object_to_array( $_data->banners );
}
// Convert icons into an associative array, since we're getting an object, but Core expects an array.
if ( isset( $_data->icons ) && ! is_array( $_data->icons ) ) {
$_data->icons = $this->convert_object_to_array( $_data->icons );
}
if( ! isset( $_data->plugin ) ) {
$_data->plugin = $this->name;
}
return $_data;
}
/**
* Convert some objects to arrays when injecting data into the update API
*
* Some data like sections, banners, and icons are expected to be an associative array, however due to the JSON
* decoding, they are objects. This method allows us to pass in the object and return an associative array.
*
* @since 3.6.5
*
* @param stdClass $data
*
* @return array
*/
private function convert_object_to_array( $data ) {
$new_data = array();
foreach ( $data as $key => $value ) {
$new_data[ $key ] = $value;
}
return $new_data;
}
/**
* Disable SSL verification in order to prevent download update failures
*
* @param array $args
* @param string $url
* @return object $array
*/
public function http_request_args( $args, $url ) {
$verify_ssl = $this->verify_ssl();
if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
$args['sslverify'] = $verify_ssl;
}
return $args;
}
/**
* Calls the API and, if successfull, returns the object delivered by the API.
*
* @uses get_bloginfo()
* @uses wp_remote_post()
* @uses is_wp_error()
*
* @param string $_action The requested action.
* @param array $_data Parameters for the API action.
* @return false|object
*/
private function api_request( $_action, $_data ) {
global $wp_version, $edd_plugin_url_available;
$verify_ssl = $this->verify_ssl();
// Do a quick status check on this domain if we haven't already checked it.
$store_hash = md5( $this->api_url );
if ( ! is_array( $edd_plugin_url_available ) || ! isset( $edd_plugin_url_available[ $store_hash ] ) ) {
$test_url_parts = parse_url( $this->api_url );
$scheme = ! empty( $test_url_parts['scheme'] ) ? $test_url_parts['scheme'] : 'http';
$host = ! empty( $test_url_parts['host'] ) ? $test_url_parts['host'] : '';
$port = ! empty( $test_url_parts['port'] ) ? ':' . $test_url_parts['port'] : '';
if ( empty( $host ) ) {
$edd_plugin_url_available[ $store_hash ] = false;
} else {
$test_url = $scheme . '://' . $host . $port;
$response = wp_remote_get( $test_url, array( 'timeout' => $this->health_check_timeout, 'sslverify' => $verify_ssl ) );
$edd_plugin_url_available[ $store_hash ] = is_wp_error( $response ) ? false : true;
}
}
if ( false === $edd_plugin_url_available[ $store_hash ] ) {
return;
}
$data = array_merge( $this->api_data, $_data );
if ( $data['slug'] != $this->slug ) {
return;
}
if( $this->api_url == trailingslashit ( home_url() ) ) {
return false; // Don't allow a plugin to ping itself
}
$api_params = array(
'edd_action' => 'get_version',
'license' => ! empty( $data['license'] ) ? $data['license'] : '',
'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
'version' => isset( $data['version'] ) ? $data['version'] : false,
'slug' => $data['slug'],
'author' => $data['author'],
'url' => home_url(),
'beta' => ! empty( $data['beta'] ),
);
$request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) );
if ( ! is_wp_error( $request ) ) {
$request = json_decode( wp_remote_retrieve_body( $request ) );
}
if ( $request && isset( $request->sections ) ) {
$request->sections = maybe_unserialize( $request->sections );
} else {
$request = false;
}
if ( $request && isset( $request->banners ) ) {
$request->banners = maybe_unserialize( $request->banners );
}
if ( $request && isset( $request->icons ) ) {
$request->icons = maybe_unserialize( $request->icons );
}
if( ! empty( $request->sections ) ) {
foreach( $request->sections as $key => $section ) {
$request->$key = (array) $section;
}
}
return $request;
}
public function show_changelog() {
global $edd_plugin_data;
if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
return;
}
if( empty( $_REQUEST['plugin'] ) ) {
return;
}
if( empty( $_REQUEST['slug'] ) ) {
return;
}
if( ! current_user_can( 'update_plugins' ) ) {
wp_die( __( 'You do not have permission to install plugin updates', 'easy-digital-downloads' ), __( 'Error', 'easy-digital-downloads' ), array( 'response' => 403 ) );
}
$data = $edd_plugin_data[ $_REQUEST['slug'] ];
$beta = ! empty( $data['beta'] ) ? true : false;
$cache_key = md5( 'edd_plugin_' . sanitize_key( $_REQUEST['plugin'] ) . '_' . $beta . '_version_info' );
$version_info = $this->get_cached_version_info( $cache_key );
if( false === $version_info ) {
$api_params = array(
'edd_action' => 'get_version',
'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
'slug' => $_REQUEST['slug'],
'author' => $data['author'],
'url' => home_url(),
'beta' => ! empty( $data['beta'] )
);
$verify_ssl = $this->verify_ssl();
$request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => $verify_ssl, 'body' => $api_params ) );
if ( ! is_wp_error( $request ) ) {
$version_info = json_decode( wp_remote_retrieve_body( $request ) );
}
if ( ! empty( $version_info ) && isset( $version_info->sections ) ) {
$version_info->sections = maybe_unserialize( $version_info->sections );
} else {
$version_info = false;
}
if( ! empty( $version_info ) ) {
foreach( $version_info->sections as $key => $section ) {
$version_info->$key = (array) $section;
}
}
$this->set_version_info_cache( $version_info, $cache_key );
}
if( ! empty( $version_info ) && isset( $version_info->sections['changelog'] ) ) {
echo '<div style="background:#fff;padding:10px;">' . $version_info->sections['changelog'] . '</div>';
}
exit;
}
public function get_cached_version_info( $cache_key = '' ) {
if( empty( $cache_key ) ) {
$cache_key = $this->cache_key;
}
$cache = get_option( $cache_key );
if( empty( $cache['timeout'] ) || time() > $cache['timeout'] ) {
return false; // Cache is expired
}
// We need to turn the icons into an array, thanks to WP Core forcing these into an object at some point.
$cache['value'] = json_decode( $cache['value'] );
if ( ! empty( $cache['value']->icons ) ) {
$cache['value']->icons = (array) $cache['value']->icons;
}
return $cache['value'];
}
public function set_version_info_cache( $value = '', $cache_key = '' ) {
if( empty( $cache_key ) ) {
$cache_key = $this->cache_key;
}
$data = array(
'timeout' => strtotime( '+3 hours', time() ),
'value' => json_encode( $value )
);
update_option( $cache_key, $data, 'no' );
}
/**
* Returns if the SSL of the store should be verified.
*
* @since 1.6.13
* @return bool
*/
private function verify_ssl() {
return (bool) apply_filters( 'edd_sl_api_request_verify_ssl', true, $this );
}
}

View File

@ -0,0 +1,163 @@
<?php
/**
* WP Async Request
*
* @package WP-Background-Processing
*/
if ( ! class_exists( 'WP_Async_Request' ) ) {
/**
* Abstract WP_Async_Request class.
*
* @abstract
*/
abstract class WP_Async_Request {
/**
* Prefix
*
* (default value: 'wp')
*
* @var string
* @access protected
*/
protected $prefix = 'wp';
/**
* Action
*
* (default value: 'async_request')
*
* @var string
* @access protected
*/
protected $action = 'async_request';
/**
* Identifier
*
* @var mixed
* @access protected
*/
protected $identifier;
/**
* Data
*
* (default value: array())
*
* @var array
* @access protected
*/
protected $data = array();
/**
* Initiate new async request
*/
public function __construct() {
$this->identifier = $this->prefix . '_' . $this->action;
add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) );
add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) );
}
/**
* Set data used during the request
*
* @param array $data Data.
*
* @return $this
*/
public function data( $data ) {
$this->data = $data;
return $this;
}
/**
* Dispatch the async request
*
* @return array|WP_Error
*/
public function dispatch() {
$url = add_query_arg( $this->get_query_args(), $this->get_query_url() );
$args = $this->get_post_args();
return wp_remote_post( esc_url_raw( $url ), $args );
}
/**
* Get query args
*
* @return array
*/
protected function get_query_args() {
if ( property_exists( $this, 'query_args' ) ) {
return $this->query_args;
}
return array(
'action' => $this->identifier,
'nonce' => wp_create_nonce( $this->identifier ),
);
}
/**
* Get query URL
*
* @return string
*/
protected function get_query_url() {
if ( property_exists( $this, 'query_url' ) ) {
return $this->query_url;
}
return admin_url( 'admin-ajax.php' );
}
/**
* Get post args
*
* @return array
*/
protected function get_post_args() {
if ( property_exists( $this, 'post_args' ) ) {
return $this->post_args;
}
return array(
'timeout' => 0.01,
'blocking' => false,
'body' => $this->data,
'cookies' => $_COOKIE,
'sslverify' => apply_filters( 'https_local_ssl_verify', false ),
);
}
/**
* Maybe handle
*
* Check for correct nonce and pass to handler.
*/
public function maybe_handle() {
// Don't lock up other requests while processing
session_write_close();
check_ajax_referer( $this->identifier, 'nonce' );
$this->handle();
wp_die();
}
/**
* Handle
*
* Override this method to perform any actions required
* during the async request.
*/
abstract protected function handle();
}
}

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