modified file bootstrap-buttons.css
This commit is contained in:
@ -1,449 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file builds an external CSS file for our options.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
/**
|
||||
* Build and enqueue a dynamic stylsheet if needed.
|
||||
*/
|
||||
class GeneratePress_External_CSS_File {
|
||||
/**
|
||||
* Instance.
|
||||
*
|
||||
* @access private
|
||||
* @var object Instance
|
||||
* @since 1.11.0
|
||||
*/
|
||||
private static $instance;
|
||||
|
||||
/**
|
||||
* Initiator.
|
||||
*
|
||||
* @since 1.11.0
|
||||
* @return object initialized object of class.
|
||||
*/
|
||||
public static function get_instance() {
|
||||
if ( ! isset( self::$instance ) ) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_dynamic_css' ), 20 );
|
||||
add_action( 'wp', array( $this, 'init' ), 9 );
|
||||
add_action( 'customize_save_after', array( $this, 'delete_saved_time' ) );
|
||||
add_action( 'customize_register', array( $this, 'add_customizer_field' ) );
|
||||
add_filter( 'generate_option_defaults', array( $this, 'add_option_default' ) );
|
||||
add_filter( 'generatepress_dynamic_css_print_method', array( $this, 'set_print_method' ) );
|
||||
|
||||
if ( ! empty( $_POST ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Just checking, false positive.
|
||||
add_action( 'wp_ajax_generatepress_regenerate_css_file', array( $this, 'regenerate_css_file' ) );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set our CSS Print Method default.
|
||||
*
|
||||
* @param array $defaults Our existing defaults.
|
||||
*/
|
||||
public function add_option_default( $defaults ) {
|
||||
$defaults['css_print_method'] = 'inline';
|
||||
|
||||
return $defaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add our option to the Customizer.
|
||||
*
|
||||
* @param object $wp_customize The Customizer object.
|
||||
*/
|
||||
public function add_customizer_field( $wp_customize ) {
|
||||
if ( ! function_exists( 'generate_get_defaults' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$defaults = generate_get_defaults();
|
||||
|
||||
require_once GP_LIBRARY_DIRECTORY . 'customizer-helpers.php';
|
||||
|
||||
if ( method_exists( $wp_customize, 'register_control_type' ) ) {
|
||||
$wp_customize->register_control_type( 'GeneratePress_Action_Button_Control' );
|
||||
}
|
||||
|
||||
$wp_customize->add_setting(
|
||||
'generate_settings[css_print_method]',
|
||||
array(
|
||||
'default' => $defaults['css_print_method'],
|
||||
'type' => 'option',
|
||||
'sanitize_callback' => 'generate_premium_sanitize_choices',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
'generate_settings[css_print_method]',
|
||||
array(
|
||||
'type' => 'select',
|
||||
'label' => __( 'Dynamic CSS Print Method', 'gp-premium' ),
|
||||
'description' => __( 'Generating your dynamic CSS in an external file offers significant performance advantages.', 'gp-premium' ),
|
||||
'section' => 'generate_general_section',
|
||||
'choices' => array(
|
||||
'inline' => __( 'Inline Embedding', 'gp-premium' ),
|
||||
'file' => __( 'External File', 'gp-premium' ),
|
||||
),
|
||||
'settings' => 'generate_settings[css_print_method]',
|
||||
)
|
||||
);
|
||||
|
||||
$wp_customize->add_control(
|
||||
new GeneratePress_Action_Button_Control(
|
||||
$wp_customize,
|
||||
'generate_regenerate_external_css_file',
|
||||
array(
|
||||
'section' => 'generate_general_section',
|
||||
'data_type' => 'regenerate_external_css',
|
||||
'nonce' => esc_html( wp_create_nonce( 'generatepress_regenerate_css_file' ) ),
|
||||
'label' => __( 'Regenerate CSS File', 'gp-premium' ),
|
||||
'settings' => ( isset( $wp_customize->selective_refresh ) ) ? array() : 'blogname',
|
||||
'active_callback' => 'generate_is_using_external_css_file_callback',
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set our CSS Print Method.
|
||||
*
|
||||
* @param string $method The existing method.
|
||||
*/
|
||||
public function set_print_method( $method ) {
|
||||
if ( ! function_exists( 'generate_get_option' ) ) {
|
||||
return $method;
|
||||
}
|
||||
|
||||
return generate_get_option( 'css_print_method' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if we're using file mode or inline mode.
|
||||
*/
|
||||
public function mode() {
|
||||
$mode = generate_get_css_print_method();
|
||||
|
||||
if ( 'file' === $mode && $this->needs_update() ) {
|
||||
$data = get_option( 'generatepress_dynamic_css_data', array() );
|
||||
|
||||
if ( ! isset( $data['updated_time'] ) ) {
|
||||
// No time set, so set the current time minus 5 seconds so the file is still generated.
|
||||
$data['updated_time'] = time() - 5;
|
||||
update_option( 'generatepress_dynamic_css_data', $data );
|
||||
}
|
||||
|
||||
// Only allow processing 1 file every 5 seconds.
|
||||
$current_time = (int) time();
|
||||
$last_time = (int) $data['updated_time'];
|
||||
|
||||
if ( 5 <= ( $current_time - $last_time ) ) {
|
||||
|
||||
// Attempt to write to the file.
|
||||
$mode = ( $this->can_write() && $this->make_css() ) ? 'file' : 'inline';
|
||||
|
||||
// Does again if the file exists.
|
||||
if ( 'file' === $mode ) {
|
||||
$mode = ( file_exists( $this->file( 'path' ) ) ) ? 'file' : 'inline';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set things up.
|
||||
*/
|
||||
public function init() {
|
||||
if ( 'file' === $this->mode() ) {
|
||||
add_filter( 'generate_using_dynamic_css_external_file', '__return_true' );
|
||||
add_filter( 'generate_dynamic_css_skip_cache', '__return_true', 20 );
|
||||
|
||||
// Remove inline CSS in GP < 3.0.0.
|
||||
if ( ! function_exists( 'generate_get_dynamic_css' ) && function_exists( 'generate_enqueue_dynamic_css' ) ) {
|
||||
remove_action( 'wp_enqueue_scripts', 'generate_enqueue_dynamic_css', 50 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enqueue the dynamic CSS.
|
||||
*/
|
||||
public function enqueue_dynamic_css() {
|
||||
if ( 'file' === $this->mode() ) {
|
||||
wp_enqueue_style( 'generatepress-dynamic', esc_url( $this->file( 'uri' ) ), array( 'generate-style' ), null ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
|
||||
|
||||
// Move the child theme after our dynamic stylesheet.
|
||||
if ( is_child_theme() && wp_style_is( 'generate-child', 'enqueued' ) ) {
|
||||
wp_dequeue_style( 'generate-child' );
|
||||
wp_enqueue_style( 'generate-child' );
|
||||
}
|
||||
|
||||
// Re-add no-cache CSS in GP < 3.0.0.
|
||||
if ( ! function_exists( 'generate_get_dynamic_css' ) && function_exists( 'generate_no_cache_dynamic_css' ) ) {
|
||||
$nocache_css = generate_no_cache_dynamic_css();
|
||||
|
||||
if ( function_exists( 'generate_do_icon_css' ) ) {
|
||||
$nocache_css .= generate_do_icon_css();
|
||||
}
|
||||
|
||||
wp_add_inline_style( 'generate-style', wp_strip_all_tags( $nocache_css ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Make our CSS.
|
||||
*/
|
||||
public function make_css() {
|
||||
$content = '';
|
||||
|
||||
if ( function_exists( 'generate_get_dynamic_css' ) ) {
|
||||
$content = generate_get_dynamic_css();
|
||||
} elseif ( function_exists( 'generate_base_css' ) && function_exists( 'generate_font_css' ) && function_exists( 'generate_advanced_css' ) && function_exists( 'generate_spacing_css' ) ) {
|
||||
$content = generate_base_css() . generate_font_css() . generate_advanced_css() . generate_spacing_css();
|
||||
}
|
||||
|
||||
$content = apply_filters( 'generate_external_dynamic_css_output', $content );
|
||||
|
||||
if ( ! $content ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$filesystem = generate_premium_get_wp_filesystem();
|
||||
|
||||
if ( ! $filesystem ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Take care of domain mapping.
|
||||
if ( defined( 'DOMAIN_MAPPING' ) && DOMAIN_MAPPING ) {
|
||||
if ( function_exists( 'domain_mapping_siteurl' ) && function_exists( 'get_original_url' ) ) {
|
||||
$mapped_domain = domain_mapping_siteurl( false );
|
||||
$original_domain = get_original_url( 'siteurl' );
|
||||
|
||||
$content = str_replace( $original_domain, $mapped_domain, $content );
|
||||
}
|
||||
}
|
||||
|
||||
if ( is_writable( $this->file( 'path' ) ) || ( ! file_exists( $this->file( 'path' ) ) && is_writable( dirname( $this->file( 'path' ) ) ) ) ) {
|
||||
$chmod_file = 0644;
|
||||
|
||||
if ( defined( 'FS_CHMOD_FILE' ) ) {
|
||||
$chmod_file = FS_CHMOD_FILE;
|
||||
}
|
||||
|
||||
if ( ! $filesystem->put_contents( $this->file( 'path' ), wp_strip_all_tags( $content ), $chmod_file ) ) {
|
||||
|
||||
// Fail!
|
||||
return false;
|
||||
|
||||
} else {
|
||||
|
||||
$this->update_saved_time();
|
||||
|
||||
// Success!
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the CSS file is writable.
|
||||
*/
|
||||
public function can_write() {
|
||||
global $blog_id;
|
||||
|
||||
// Get the upload directory for this site.
|
||||
$upload_dir = wp_get_upload_dir();
|
||||
|
||||
// If this is a multisite installation, append the blogid to the filename.
|
||||
$css_blog_id = ( is_multisite() && $blog_id > 1 ) ? '_blog-' . $blog_id : null;
|
||||
|
||||
$file_name = '/style' . $css_blog_id . '.min.css';
|
||||
$folder_path = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . 'generatepress';
|
||||
|
||||
// Does the folder exist?
|
||||
if ( file_exists( $folder_path ) ) {
|
||||
// Folder exists, but is the folder writable?
|
||||
if ( ! is_writable( $folder_path ) ) {
|
||||
// Folder is not writable.
|
||||
// Does the file exist?
|
||||
if ( ! file_exists( $folder_path . $file_name ) ) {
|
||||
// File does not exist, therefore it can't be created
|
||||
// since the parent folder is not writable.
|
||||
return false;
|
||||
} else {
|
||||
// File exists, but is it writable?
|
||||
if ( ! is_writable( $folder_path . $file_name ) ) {
|
||||
// Nope, it's not writable.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// The folder is writable.
|
||||
// Does the file exist?
|
||||
if ( file_exists( $folder_path . $file_name ) ) {
|
||||
// File exists.
|
||||
// Is it writable?
|
||||
if ( ! is_writable( $folder_path . $file_name ) ) {
|
||||
// Nope, it's not writable.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Can we create the folder?
|
||||
// returns true if yes and false if not.
|
||||
return wp_mkdir_p( $folder_path );
|
||||
}
|
||||
|
||||
// all is well!
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the css path or url to the stylesheet
|
||||
*
|
||||
* @param string $target path/url.
|
||||
*/
|
||||
public function file( $target = 'path' ) {
|
||||
global $blog_id;
|
||||
|
||||
// Get the upload directory for this site.
|
||||
$upload_dir = wp_get_upload_dir();
|
||||
|
||||
// If this is a multisite installation, append the blogid to the filename.
|
||||
$css_blog_id = ( is_multisite() && $blog_id > 1 ) ? '_blog-' . $blog_id : null;
|
||||
|
||||
$file_name = 'style' . $css_blog_id . '.min.css';
|
||||
$folder_path = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . 'generatepress';
|
||||
|
||||
// The complete path to the file.
|
||||
$file_path = $folder_path . DIRECTORY_SEPARATOR . $file_name;
|
||||
|
||||
// Get the URL directory of the stylesheet.
|
||||
$css_uri_folder = $upload_dir['baseurl'];
|
||||
|
||||
$css_uri = trailingslashit( $css_uri_folder ) . 'generatepress/' . $file_name;
|
||||
|
||||
// Take care of domain mapping.
|
||||
if ( defined( 'DOMAIN_MAPPING' ) && DOMAIN_MAPPING ) {
|
||||
if ( function_exists( 'domain_mapping_siteurl' ) && function_exists( 'get_original_url' ) ) {
|
||||
$mapped_domain = domain_mapping_siteurl( false );
|
||||
$original_domain = get_original_url( 'siteurl' );
|
||||
$css_uri = str_replace( $original_domain, $mapped_domain, $css_uri );
|
||||
}
|
||||
}
|
||||
|
||||
$css_uri = set_url_scheme( $css_uri );
|
||||
|
||||
if ( 'path' === $target ) {
|
||||
return $file_path;
|
||||
} elseif ( 'url' === $target || 'uri' === $target ) {
|
||||
$timestamp = ( file_exists( $file_path ) ) ? '?ver=' . filemtime( $file_path ) : '';
|
||||
return $css_uri . $timestamp;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the our updated file time.
|
||||
*/
|
||||
public function update_saved_time() {
|
||||
$data = get_option( 'generatepress_dynamic_css_data', array() );
|
||||
$data['updated_time'] = time();
|
||||
|
||||
update_option( 'generatepress_dynamic_css_data', $data );
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete the saved time.
|
||||
*/
|
||||
public function delete_saved_time() {
|
||||
$data = get_option( 'generatepress_dynamic_css_data', array() );
|
||||
|
||||
if ( isset( $data['updated_time'] ) ) {
|
||||
unset( $data['updated_time'] );
|
||||
}
|
||||
|
||||
update_option( 'generatepress_dynamic_css_data', $data );
|
||||
}
|
||||
|
||||
/**
|
||||
* Update our plugin/theme versions.
|
||||
*/
|
||||
public function update_versions() {
|
||||
$data = get_option( 'generatepress_dynamic_css_data', array() );
|
||||
|
||||
$data['theme_version'] = GENERATE_VERSION;
|
||||
$data['plugin_version'] = GP_PREMIUM_VERSION;
|
||||
|
||||
update_option( 'generatepress_dynamic_css_data', $data );
|
||||
}
|
||||
|
||||
/**
|
||||
* Do we need to update the CSS file?
|
||||
*/
|
||||
public function needs_update() {
|
||||
$data = get_option( 'generatepress_dynamic_css_data', array() );
|
||||
$update = false;
|
||||
|
||||
// If there's no updated time, needs update.
|
||||
// The time is set in mode().
|
||||
if ( ! isset( $data['updated_time'] ) ) {
|
||||
$update = true;
|
||||
}
|
||||
|
||||
// If we haven't set our versions, do so now.
|
||||
if ( ! isset( $data['theme_version'] ) && ! isset( $data['plugin_version'] ) ) {
|
||||
$update = true;
|
||||
$this->update_versions();
|
||||
|
||||
// Bail early so we don't check undefined versions below.
|
||||
return $update;
|
||||
}
|
||||
|
||||
// Version numbers have changed, needs update.
|
||||
if ( (string) GENERATE_VERSION !== (string) $data['theme_version'] || (string) GP_PREMIUM_VERSION !== (string) $data['plugin_version'] ) {
|
||||
$update = true;
|
||||
$this->update_versions();
|
||||
}
|
||||
|
||||
return $update;
|
||||
}
|
||||
|
||||
/**
|
||||
* Regenerate the CSS file.
|
||||
*/
|
||||
public function regenerate_css_file() {
|
||||
check_ajax_referer( 'generatepress_regenerate_css_file', '_nonce' );
|
||||
|
||||
if ( ! current_user_can( 'manage_options' ) ) {
|
||||
wp_send_json_error( __( 'Security check failed.', 'gp-premium' ) );
|
||||
}
|
||||
|
||||
$this->delete_saved_time();
|
||||
|
||||
wp_send_json_success();
|
||||
}
|
||||
}
|
||||
|
||||
GeneratePress_External_CSS_File::get_instance();
|
@ -1,81 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file adds global scripts.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
add_action( 'enqueue_block_editor_assets', 'generate_premium_enqueue_editor_scripts' );
|
||||
/**
|
||||
* Add scripts to the non-Elements block editor.
|
||||
*
|
||||
* @since 2.0.0
|
||||
*/
|
||||
function generate_premium_enqueue_editor_scripts() {
|
||||
global $pagenow;
|
||||
|
||||
$deps = array( 'wp-blocks', 'wp-i18n', 'wp-element', 'wp-editor' );
|
||||
|
||||
if ( 'widgets.php' === $pagenow ) {
|
||||
unset( $deps[3] );
|
||||
}
|
||||
|
||||
wp_enqueue_script(
|
||||
'gp-premium-editor',
|
||||
GP_PREMIUM_DIR_URL . 'dist/editor.js',
|
||||
$deps,
|
||||
filemtime( GP_PREMIUM_DIR_PATH . 'dist/editor.js' ),
|
||||
true
|
||||
);
|
||||
|
||||
wp_set_script_translations( 'gp-premium-editor', 'gp-premium', GP_PREMIUM_DIR_PATH . 'langs' );
|
||||
|
||||
global $generate_elements;
|
||||
$active_elements = array();
|
||||
|
||||
if ( class_exists( 'GeneratePress_Elements_Helper' ) && ! empty( $generate_elements ) ) {
|
||||
foreach ( (array) $generate_elements as $key => $data ) {
|
||||
$type = esc_html( GeneratePress_Elements_Helper::get_element_type_label( $data['type'] ) );
|
||||
|
||||
$active_elements[] = array(
|
||||
'type' => $type,
|
||||
'name' => get_the_title( $data['id'] ),
|
||||
'url' => get_edit_post_link( $data['id'] ),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$post_type_is_public = false;
|
||||
|
||||
if ( get_post_type() ) {
|
||||
$post_type = get_post_type_object( get_post_type() );
|
||||
|
||||
if ( is_object( $post_type ) && ! empty( $post_type->public ) ) {
|
||||
$post_type_is_public = true;
|
||||
}
|
||||
}
|
||||
|
||||
wp_localize_script(
|
||||
'gp-premium-editor',
|
||||
'gpPremiumEditor',
|
||||
array(
|
||||
'isBlockElement' => 'gp_elements' === get_post_type(),
|
||||
'activeElements' => $active_elements,
|
||||
'elementsUrl' => esc_url( admin_url( 'edit.php?post_type=gp_elements' ) ),
|
||||
'postTypeIsPublic' => $post_type_is_public,
|
||||
)
|
||||
);
|
||||
|
||||
wp_enqueue_style(
|
||||
'gp-premium-editor',
|
||||
GP_PREMIUM_DIR_URL . 'dist/editor.css',
|
||||
array( 'wp-edit-blocks' ),
|
||||
filemtime( GP_PREMIUM_DIR_PATH . 'dist/editor.css' )
|
||||
);
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles SVG icons.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'generate_enqueue_premium_icons' );
|
||||
/**
|
||||
* Register our GP Premium icons.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
function generate_enqueue_premium_icons() {
|
||||
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
||||
|
||||
wp_register_style( 'gp-premium-icons', plugin_dir_url( __FILE__ ) . "icons/icons{$suffix}.css", array(), GP_PREMIUM_VERSION );
|
||||
}
|
||||
|
||||
add_filter( 'generate_svg_icon', 'generate_premium_add_svg_icons', 10, 2 );
|
||||
/**
|
||||
* Add our premium SVG icons.
|
||||
*
|
||||
* @since 1.9
|
||||
* @param string $output The SVG HTML output.
|
||||
* @param string $icon The icon name.
|
||||
*/
|
||||
function generate_premium_add_svg_icons( $output, $icon ) {
|
||||
$svg = '';
|
||||
|
||||
if ( 'shopping-bag' === $icon ) {
|
||||
$svg = '<svg viewBox="0 0 518 512" aria-hidden="true" version="1.1" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em">
|
||||
<g id="Union" transform="matrix(1,0,0,1,2.01969,2)">
|
||||
<path d="M172,108.5C172,61.832 209.832,24 256.5,24C303.168,24 341,61.832 341,108.5L341,116C341,122.627 346.373,128 353,128C359.628,128 365,122.627 365,116L365,108.5C365,48.577 316.423,0 256.5,0C196.577,0 148,48.577 148,108.5L148,116C148,122.627 153.373,128 160,128C166.628,128 172,122.627 172,116L172,108.5Z" style="fill-rule:nonzero;"/>
|
||||
<path d="M4.162,145.236C7.195,141.901 11.493,140 16,140L496,140C500.507,140 504.806,141.901 507.838,145.236C510.87,148.571 512.355,153.03 511.928,157.517L482.687,464.551C480.34,489.186 459.65,508 434.903,508L77.097,508C52.35,508 31.66,489.186 29.314,464.551L0.072,157.517C-0.355,153.03 1.13,148.571 4.162,145.236Z" style="fill-rule:nonzero;"/>
|
||||
</g>
|
||||
</svg>';
|
||||
}
|
||||
|
||||
if ( 'shopping-cart' === $icon ) {
|
||||
$svg = '<svg viewBox="0 0 576 512" aria-hidden="true" version="1.1" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em">
|
||||
<path fill="none" d="M0 0h576v512H0z"/>
|
||||
<path d="M181.54 409.6c-29.249 0-52.914 23.04-52.914 51.2 0 28.16 23.665 51.2 52.915 51.2 29.249 0 53.18-23.04 53.18-51.2 0-28.16-23.931-51.2-53.18-51.2zM22 0v51.2h53.18l95.725 194.304-35.897 62.464C115.598 342.272 141.124 384 181.54 384h319.08v-51.2h-319.08l29.249-51.2h198.096c19.943 0 37.492-10.496 46.533-26.368L550.61 89.088c9.838-16.896-2.925-37.888-23.133-37.888H133.944L108.95 0H22zm425.442 409.6c-29.25 0-52.915 23.04-52.915 51.2 0 28.16 23.665 51.2 52.915 51.2 29.249 0 53.18-23.04 53.18-51.2 0-28.16-23.931-51.2-53.18-51.2z"/>
|
||||
</svg>';
|
||||
}
|
||||
|
||||
if ( 'shopping-basket' === $icon ) {
|
||||
$svg = '<svg viewBox="0 0 626 512" aria-hidden="true" version="1.1" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em">
|
||||
<path d="M4.83 187.075a19.505 19.505 0 0 1 14.675-6.656h585.144a19.505 19.505 0 0 1 19.334 22.083L589.486 461.22c-3.875 29.07-28.672 50.781-58 50.781H92.668c-29.328 0-54.126-21.71-58.002-50.78L.171 202.501a19.511 19.511 0 0 1 4.659-15.427zm165.748 69.748c-.892-8.03-8.125-13.815-16.155-12.924-8.03.892-13.815 8.125-12.924 16.155l19.505 175.543c.892 8.03 8.125 13.816 16.154 12.924 8.03-.892 13.816-8.125 12.925-16.154l-19.505-175.544zm312.077 3.23c.892-8.029-4.895-15.262-12.925-16.154-8.03-.891-15.262 4.894-16.154 12.924L434.07 432.367c-.893 8.03 4.894 15.262 12.924 16.154 8.03.892 15.263-4.894 16.155-12.924l19.505-175.543zm-153.512-1.614c0-8.079-6.55-14.629-14.628-14.629-8.079 0-14.629 6.55-14.629 14.629v175.543c0 8.078 6.55 14.628 14.629 14.628s14.628-6.55 14.628-14.628V258.439z"/>
|
||||
<path d="M283.41 4.285c5.715 5.712 5.715 14.975 0 20.687L146.878 161.506c-5.712 5.714-14.975 5.714-20.687 0-5.714-5.713-5.714-14.975 0-20.687L262.724 4.285c5.712-5.714 14.974-5.714 20.687 0zm57.333 0c5.712-5.714 14.975-5.714 20.687 0l136.534 136.534c5.713 5.712 5.713 14.974 0 20.687-5.713 5.714-14.975 5.714-20.688 0L340.743 24.972c-5.714-5.712-5.714-14.975 0-20.687z" />
|
||||
</svg>';
|
||||
}
|
||||
|
||||
if ( 'spinner' === $icon ) {
|
||||
$svg = '<svg viewBox="0 0 512 512" aria-hidden="true" version="1.1" xmlns="http://www.w3.org/2000/svg" width="1em" height="1em">
|
||||
<path d="M288 32c0 17.673-14.327 32-32 32-17.673 0-32-14.327-32-32 0-17.673 14.327-32 32-32 17.673 0 32 14.327 32 32zM288 480c0 17.673-14.327 32-32 32-17.673 0-32-14.327-32-32 0-17.673 14.327-32 32-32 17.673 0 32 14.327 32 32zM448 256c0 17.673 14.327 32 32 32 17.673 0 32-14.327 32-32 0-17.673-14.327-32-32-32-17.673 0-32 14.327-32 32zM32 288c-17.673 0-32-14.327-32-32 0-17.673 14.327-32 32-32 17.673 0 32 14.327 32 32 0 17.673-14.327 32-32 32zM391.764 391.764c-12.496 12.497-12.496 32.759 0 45.255 12.497 12.497 32.758 12.497 45.255 0 12.497-12.496 12.497-32.758 0-45.255-12.497-12.496-32.758-12.496-45.255 0zM74.981 120.235c-12.497-12.496-12.497-32.758 0-45.254 12.496-12.497 32.758-12.497 45.254 0 12.497 12.496 12.497 32.758 0 45.254-12.496 12.497-32.758 12.497-45.254 0zM120.235 391.765c-12.496-12.497-32.758-12.497-45.254 0-12.497 12.496-12.497 32.758 0 45.254 12.496 12.497 32.758 12.497 45.254 0 12.497-12.496 12.497-32.758 0-45.254z"/>
|
||||
</svg>';
|
||||
}
|
||||
|
||||
if ( 'pro-menu-bars' === $icon ) {
|
||||
$svg = '<svg viewBox="0 0 512 512" aria-hidden="true" role="img" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1em" height="1em">
|
||||
<path d="M0 96c0-13.255 10.745-24 24-24h464c13.255 0 24 10.745 24 24s-10.745 24-24 24H24c-13.255 0-24-10.745-24-24zm0 160c0-13.255 10.745-24 24-24h464c13.255 0 24 10.745 24 24s-10.745 24-24 24H24c-13.255 0-24-10.745-24-24zm0 160c0-13.255 10.745-24 24-24h464c13.255 0 24 10.745 24 24s-10.745 24-24 24H24c-13.255 0-24-10.745-24-24z" />
|
||||
</svg>';
|
||||
}
|
||||
|
||||
if ( 'pro-close' === $icon ) {
|
||||
$svg = '<svg viewBox="0 0 512 512" aria-hidden="true" role="img" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1em" height="1em">
|
||||
<path d="M71.029 71.029c9.373-9.372 24.569-9.372 33.942 0L256 222.059l151.029-151.03c9.373-9.372 24.569-9.372 33.942 0 9.372 9.373 9.372 24.569 0 33.942L289.941 256l151.03 151.029c9.372 9.373 9.372 24.569 0 33.942-9.373 9.372-24.569 9.372-33.942 0L256 289.941l-151.029 151.03c-9.373 9.372-24.569 9.372-33.942 0-9.372-9.373-9.372-24.569 0-33.942L222.059 256 71.029 104.971c-9.372-9.373-9.372-24.569 0-33.942z" />
|
||||
</svg>';
|
||||
}
|
||||
|
||||
if ( $svg ) {
|
||||
$output = sprintf(
|
||||
'<span class="gp-icon %1$s">
|
||||
%2$s
|
||||
</span>',
|
||||
$icon,
|
||||
$svg
|
||||
);
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
Binary file not shown.
@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" standalone="no"?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
|
||||
<svg xmlns="http://www.w3.org/2000/svg">
|
||||
<metadata>Generated by IcoMoon</metadata>
|
||||
<defs>
|
||||
<font id="icomoon" horiz-adv-x="1024">
|
||||
<font-face units-per-em="1024" ascent="960" descent="-64" />
|
||||
<missing-glyph horiz-adv-x="1024" />
|
||||
<glyph unicode=" " horiz-adv-x="512" d="" />
|
||||
<glyph unicode="" glyph-name="spinner" d="M576 896c0-35.346-28.654-64-64-64s-64 28.654-64 64c0 35.346 28.654 64 64 64s64-28.654 64-64zM576 0c0-35.346-28.654-64-64-64s-64 28.654-64 64c0 35.346 28.654 64 64 64s64-28.654 64-64zM896 448c0-35.346 28.654-64 64-64s64 28.654 64 64c0 35.346-28.654 64-64 64s-64-28.654-64-64zM64 384c-35.346 0-64 28.654-64 64s28.654 64 64 64c35.346 0 64-28.654 64-64s-28.654-64-64-64zM783.528 176.472c-24.992-24.994-24.992-65.518 0-90.51 24.994-24.994 65.516-24.994 90.51 0 24.994 24.992 24.994 65.516 0 90.51-24.994 24.992-65.516 24.992-90.51 0zM149.962 719.53c-24.994 24.992-24.994 65.516 0 90.508 24.992 24.994 65.516 24.994 90.508 0 24.994-24.992 24.994-65.516 0-90.508-24.992-24.994-65.516-24.994-90.508 0zM240.47 176.47c-24.992 24.994-65.516 24.994-90.508 0-24.994-24.992-24.994-65.516 0-90.508 24.992-24.994 65.516-24.994 90.508 0 24.994 24.992 24.994 65.516 0 90.508z" />
|
||||
<glyph unicode="" glyph-name="angle-right" horiz-adv-x="384" d="M333.8 431l-235.6-232c-9.4-9.4-24.6-9.4-34 0l-14.2 14.2c-9.4 9.4-9.4 24.6 0 34l204.6 200.8-204.4 200.8c-9.4 9.4-9.4 24.6 0 34l14.2 14.2c9.4 9.4 24.6 9.4 34 0l235.6-232c9.2-9.4 9.2-24.6-0.2-34z" />
|
||||
<glyph unicode="" glyph-name="circle" d="M512 865.477c-230.565 0-417.477-186.911-417.477-417.477s186.911-417.477 417.477-417.477c230.565 0 417.477 186.911 417.477 417.477s-186.911 417.477-417.477 417.477zM0 448c0 282.77 229.23 512 512 512s512-229.23 512-512c0-282.77-229.23-512-512-512s-512 229.23-512 512z" />
|
||||
<glyph unicode="" glyph-name="angle-down" horiz-adv-x="660" d="M611.825 565.831c0-4.532-2.266-9.63-5.665-13.029l-263.987-263.987c-3.399-3.399-8.497-5.665-13.029-5.665s-9.63 2.266-13.029 5.665l-263.987 263.987c-3.399 3.399-5.665 8.497-5.665 13.029s2.266 9.63 5.665 13.029l28.325 28.325c3.399 3.399 7.931 5.665 13.029 5.665 4.532 0 9.63-2.266 13.029-5.665l222.633-222.633 222.633 222.633c3.399 3.399 8.497 5.665 13.029 5.665s9.63-2.266 13.029-5.665l28.325-28.325c3.399-3.399 5.665-8.497 5.665-13.029z" />
|
||||
<glyph unicode="" glyph-name="dot-circle" d="M512 865.477c-230.565 0-417.477-186.911-417.477-417.477s186.911-417.477 417.477-417.477c230.565 0 417.477 186.911 417.477 417.477s-186.911 417.477-417.477 417.477zM0 448c0 282.77 229.23 512 512 512s512-229.23 512-512c0-282.77-229.23-512-512-512s-512 229.23-512 512zM519.877 518.892c-43.502 0-78.769-35.267-78.769-78.769s35.267-78.769 78.769-78.769c43.502 0 78.769 35.267 78.769 78.769s-35.267 78.769-78.769 78.769zM346.584 440.123c0 95.707 77.586 173.292 173.292 173.292s173.292-77.586 173.292-173.292c0-95.707-77.586-173.292-173.292-173.292s-173.292 77.586-173.292 173.292z" />
|
||||
<glyph unicode="" glyph-name="times" d="M142.058 817.942c18.746 18.744 49.138 18.744 67.884 0l302.058-302.060 302.058 302.060c18.746 18.744 49.138 18.744 67.884 0 18.744-18.746 18.744-49.138 0-67.884l-302.060-302.058 302.060-302.058c18.744-18.746 18.744-49.138 0-67.884-18.746-18.744-49.138-18.744-67.884 0l-302.058 302.060-302.058-302.060c-18.746-18.744-49.138-18.744-67.884 0-18.744 18.746-18.744 49.138 0 67.884l302.060 302.058-302.060 302.058c-18.744 18.746-18.744 49.138 0 67.884z" />
|
||||
<glyph unicode="" glyph-name="shopping-cart" horiz-adv-x="1152" d="M363.081 140.8c-58.498 0-105.829-46.080-105.829-102.4s47.33-102.4 105.829-102.4c58.498 0 106.36 46.080 106.36 102.4s-47.862 102.4-106.36 102.4zM44 960v-102.4h106.36l191.449-388.608-71.793-124.928c-38.822-68.608 12.231-152.064 93.065-152.064h638.162v102.4h-638.162l58.498 102.4h396.192c39.885 0 74.984 20.992 93.065 52.736l190.385 332.288c19.677 33.792-5.85 75.776-46.267 75.776h-787.067l-49.989 102.4h-173.899zM894.883 140.8c-58.498 0-105.829-46.080-105.829-102.4s47.33-102.4 105.829-102.4c58.498 0 106.36 46.080 106.36 102.4s-47.862 102.4-106.36 102.4z" />
|
||||
<glyph unicode="" glyph-name="bars" d="M0 768c0 26.51 21.49 48 48 48h928c26.51 0 48-21.49 48-48s-21.49-48-48-48h-928c-26.51 0-48 21.49-48 48zM0 448c0 26.51 21.49 48 48 48h928c26.51 0 48-21.49 48-48s-21.49-48-48-48h-928c-26.51 0-48 21.49-48 48zM0 128c0 26.51 21.49 48 48 48h928c26.51 0 48-21.49 48-48s-21.49-48-48-48h-928c-26.51 0-48 21.49-48 48z" />
|
||||
<glyph unicode="" glyph-name="shopping-bag" horiz-adv-x="1036" d="M348.039 739c0 93.336 75.664 169 169 169s169-75.664 169-169v-15c0-13.254 10.746-24 24-24 13.256 0 24 10.746 24 24v15c0 119.846-97.154 217-217 217s-217-97.154-217-217v-15c0-13.254 10.746-24 24-24 13.256 0 24 10.746 24 24v15zM12.363 665.528c6.066 6.67 14.662 10.472 23.676 10.472h960c9.014 0 17.612-3.802 23.676-10.472s9.034-15.588 8.18-24.562l-58.482-614.068c-4.694-49.27-46.074-86.898-95.568-86.898h-715.612c-49.494 0-90.874 37.628-95.566 86.898l-58.484 614.068c-0.854 8.974 2.116 17.892 8.18 24.562z" />
|
||||
<glyph unicode="" glyph-name="shopping-basket" horiz-adv-x="1252" d="M9.66 585.849c7.407 8.46 18.105 13.312 29.35 13.312h1170.288c11.245 0 21.943-4.852 29.35-13.312 7.407-8.463 10.803-19.707 9.318-30.854l-68.993-517.436c-7.751-58.141-57.344-101.561-116.002-101.561h-877.633c-58.656 0-108.252 43.42-116.002 101.561l-68.993 517.436c-1.485 11.147 1.911 22.392 9.318 30.854zM341.156 446.353c-1.785 16.060-16.25 27.631-32.31 25.849-16.060-1.785-27.631-16.25-25.849-32.31l39.010-351.086c1.785-16.060 16.25-27.631 32.31-25.849 16.060 1.785 27.631 16.25 25.849 32.31l-39.010 351.086zM965.31 439.892c1.785 16.060-9.789 30.525-25.849 32.31-16.060 1.782-30.525-9.789-32.31-25.849l-39.010-351.086c-1.785-16.060 9.789-30.525 25.849-32.31 16.060-1.782 30.525 9.789 32.31 25.849l39.010 351.086zM658.287 443.123c0 16.157-13.1 29.257-29.257 29.257s-29.257-13.1-29.257-29.257v-351.086c0-16.157 13.1-29.257 29.257-29.257s29.257 13.1 29.257 29.257v351.086zM566.822 951.43c11.427-11.425 11.427-29.95 0-41.375l-273.067-273.067c-11.425-11.427-29.95-11.427-41.375 0-11.427 11.425-11.427 29.95 0 41.375l273.067 273.067c11.425 11.427 29.95 11.427 41.375 0zM681.486 951.43c11.425 11.427 29.95 11.427 41.375 0l273.067-273.067c11.427-11.425 11.427-29.95 0-41.375-11.425-11.427-29.95-11.427-41.375 0l-273.067 273.067c-11.427 11.425-11.427 29.95 0 41.375z" />
|
||||
</font></defs></svg>
|
Before Width: | Height: | Size: 6.3 KiB |
Binary file not shown.
Binary file not shown.
@ -1,10 +0,0 @@
|
||||
@font-face {
|
||||
font-family: 'GP Premium';
|
||||
src: url('gp-premium.eot');
|
||||
src: url('gp-premium.eot#iefix') format('embedded-opentype'),
|
||||
url('gp-premium.woff') format('woff'),
|
||||
url('gp-premium.ttf') format('truetype'),
|
||||
url('gp-premium.svg#gp-premium') format('svg');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
@ -1 +0,0 @@
|
||||
@font-face{font-family:'GP Premium';src:url(gp-premium.eot);src:url(gp-premium.eot#iefix) format('embedded-opentype'),url(gp-premium.woff) format('woff'),url(gp-premium.ttf) format('truetype'),url(gp-premium.svg#gp-premium) format('svg');font-weight:400;font-style:normal}
|
@ -1,741 +0,0 @@
|
||||
/*!
|
||||
* smooth-scroll v14.2.1: Animate scrolling to anchor links
|
||||
* (c) 2018 Chris Ferdinandi
|
||||
* MIT License
|
||||
* http://github.com/cferdinandi/smooth-scroll
|
||||
*/
|
||||
|
||||
/**
|
||||
* closest() polyfill
|
||||
* @link https://developer.mozilla.org/en-US/docs/Web/API/Element/closest#Polyfill
|
||||
*/
|
||||
if (window.Element && !Element.prototype.closest) {
|
||||
Element.prototype.closest = function(s) {
|
||||
var matches = (this.document || this.ownerDocument).querySelectorAll(s),
|
||||
i,
|
||||
el = this;
|
||||
do {
|
||||
i = matches.length;
|
||||
while (--i >= 0 && matches.item(i) !== el) {}
|
||||
} while ((i < 0) && (el = el.parentElement));
|
||||
return el;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* CustomEvent() polyfill
|
||||
* https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent/CustomEvent#Polyfill
|
||||
*/
|
||||
(function () {
|
||||
|
||||
if (typeof window.CustomEvent === "function") return false;
|
||||
|
||||
function CustomEvent(event, params) {
|
||||
params = params || { bubbles: false, cancelable: false, detail: undefined };
|
||||
var evt = document.createEvent('CustomEvent');
|
||||
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
|
||||
return evt;
|
||||
}
|
||||
|
||||
CustomEvent.prototype = window.Event.prototype;
|
||||
|
||||
window.CustomEvent = CustomEvent;
|
||||
})();
|
||||
/**
|
||||
* requestAnimationFrame() polyfill
|
||||
* By Erik Möller. Fixes from Paul Irish and Tino Zijdel.
|
||||
* @link http://paulirish.com/2011/requestanimationframe-for-smart-animating/
|
||||
* @link http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
|
||||
* @license MIT
|
||||
*/
|
||||
(function() {
|
||||
var lastTime = 0;
|
||||
var vendors = ['ms', 'moz', 'webkit', 'o'];
|
||||
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
|
||||
window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
|
||||
window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] ||
|
||||
window[vendors[x]+'CancelRequestAnimationFrame'];
|
||||
}
|
||||
|
||||
if (!window.requestAnimationFrame) {
|
||||
window.requestAnimationFrame = function(callback, element) {
|
||||
var currTime = new Date().getTime();
|
||||
var timeToCall = Math.max(0, 16 - (currTime - lastTime));
|
||||
var id = window.setTimeout((function() { callback(currTime + timeToCall); }),
|
||||
timeToCall);
|
||||
lastTime = currTime + timeToCall;
|
||||
return id;
|
||||
};
|
||||
}
|
||||
|
||||
if (!window.cancelAnimationFrame) {
|
||||
window.cancelAnimationFrame = function(id) {
|
||||
clearTimeout(id);
|
||||
};
|
||||
}
|
||||
}());
|
||||
|
||||
(function (root, factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define([], (function () {
|
||||
return factory(root);
|
||||
}));
|
||||
} else if (typeof exports === 'object') {
|
||||
module.exports = factory(root);
|
||||
} else {
|
||||
root.SmoothScroll = factory(root);
|
||||
}
|
||||
})(typeof global !== 'undefined' ? global : typeof window !== 'undefined' ? window : this, (function (window) {
|
||||
|
||||
'use strict';
|
||||
|
||||
//
|
||||
// Default settings
|
||||
//
|
||||
|
||||
var defaults = {
|
||||
// Selectors
|
||||
ignore: '[data-scroll-ignore]',
|
||||
header: null,
|
||||
topOnEmptyHash: true,
|
||||
|
||||
// Speed & Easing
|
||||
speed: 500,
|
||||
clip: true,
|
||||
offset: 0,
|
||||
easing: 'easeInOutCubic',
|
||||
customEasing: null,
|
||||
|
||||
// History
|
||||
updateURL: true,
|
||||
popstate: true,
|
||||
|
||||
// Custom Events
|
||||
emitEvents: true
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Utility Methods
|
||||
//
|
||||
|
||||
/**
|
||||
* Check if browser supports required methods
|
||||
* @return {Boolean} Returns true if all required methods are supported
|
||||
*/
|
||||
var supports = function () {
|
||||
return (
|
||||
'querySelector' in document &&
|
||||
'addEventListener' in window &&
|
||||
'requestAnimationFrame' in window &&
|
||||
'closest' in window.Element.prototype
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Merge two or more objects. Returns a new object.
|
||||
* @param {Object} objects The objects to merge together
|
||||
* @returns {Object} Merged values of defaults and options
|
||||
*/
|
||||
var extend = function () {
|
||||
|
||||
// Variables
|
||||
var extended = {};
|
||||
|
||||
// Merge the object into the extended object
|
||||
var merge = function (obj) {
|
||||
for (var prop in obj) {
|
||||
if (obj.hasOwnProperty(prop)) {
|
||||
extended[prop] = obj[prop];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// Loop through each object and conduct a merge
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
merge(arguments[i]);
|
||||
}
|
||||
|
||||
return extended;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Check to see if user prefers reduced motion
|
||||
* @param {Object} settings Script settings
|
||||
*/
|
||||
var reduceMotion = function (settings) {
|
||||
if ('matchMedia' in window && window.matchMedia('(prefers-reduced-motion)').matches) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the height of an element.
|
||||
* @param {Node} elem The element to get the height of
|
||||
* @return {Number} The element's height in pixels
|
||||
*/
|
||||
var getHeight = function (elem) {
|
||||
return parseInt(window.getComputedStyle(elem).height, 10);
|
||||
};
|
||||
|
||||
/**
|
||||
* Decode a URI, with error check
|
||||
* @param {String} hash The URI to decode
|
||||
* @return {String} A decoded URI (or the original string if an error is thrown)
|
||||
*/
|
||||
var decode = function (hash) {
|
||||
var decoded;
|
||||
try {
|
||||
decoded = decodeURIComponent(hash);
|
||||
} catch(e) {
|
||||
decoded = hash;
|
||||
}
|
||||
return decoded;
|
||||
};
|
||||
|
||||
/**
|
||||
* Escape special characters for use with querySelector
|
||||
* @author Mathias Bynens
|
||||
* @link https://github.com/mathiasbynens/CSS.escape
|
||||
* @param {String} id The anchor ID to escape
|
||||
*/
|
||||
var escapeCharacters = function (id) {
|
||||
|
||||
// Remove leading hash
|
||||
if (id.charAt(0) === '#') {
|
||||
id = id.substr(1);
|
||||
}
|
||||
|
||||
var string = String(id);
|
||||
var length = string.length;
|
||||
var index = -1;
|
||||
var codeUnit;
|
||||
var result = '';
|
||||
var firstCodeUnit = string.charCodeAt(0);
|
||||
while (++index < length) {
|
||||
codeUnit = string.charCodeAt(index);
|
||||
// Note: there’s no need to special-case astral symbols, surrogate
|
||||
// pairs, or lone surrogates.
|
||||
|
||||
// If the character is NULL (U+0000), then throw an
|
||||
// `InvalidCharacterError` exception and terminate these steps.
|
||||
if (codeUnit === 0x0000) {
|
||||
throw new InvalidCharacterError(
|
||||
'Invalid character: the input contains U+0000.'
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
// If the character is in the range [\1-\1F] (U+0001 to U+001F) or is
|
||||
// U+007F, […]
|
||||
(codeUnit >= 0x0001 && codeUnit <= 0x001F) || codeUnit == 0x007F ||
|
||||
// If the character is the first character and is in the range [0-9]
|
||||
// (U+0030 to U+0039), […]
|
||||
(index === 0 && codeUnit >= 0x0030 && codeUnit <= 0x0039) ||
|
||||
// If the character is the second character and is in the range [0-9]
|
||||
// (U+0030 to U+0039) and the first character is a `-` (U+002D), […]
|
||||
(
|
||||
index === 1 &&
|
||||
codeUnit >= 0x0030 && codeUnit <= 0x0039 &&
|
||||
firstCodeUnit === 0x002D
|
||||
)
|
||||
) {
|
||||
// http://dev.w3.org/csswg/cssom/#escape-a-character-as-code-point
|
||||
result += '\\' + codeUnit.toString(16) + ' ';
|
||||
continue;
|
||||
}
|
||||
|
||||
// If the character is not handled by one of the above rules and is
|
||||
// greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or
|
||||
// is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to
|
||||
// U+005A), or [a-z] (U+0061 to U+007A), […]
|
||||
if (
|
||||
codeUnit >= 0x0080 ||
|
||||
codeUnit === 0x002D ||
|
||||
codeUnit === 0x005F ||
|
||||
codeUnit >= 0x0030 && codeUnit <= 0x0039 ||
|
||||
codeUnit >= 0x0041 && codeUnit <= 0x005A ||
|
||||
codeUnit >= 0x0061 && codeUnit <= 0x007A
|
||||
) {
|
||||
// the character itself
|
||||
result += string.charAt(index);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Otherwise, the escaped character.
|
||||
// http://dev.w3.org/csswg/cssom/#escape-a-character
|
||||
result += '\\' + string.charAt(index);
|
||||
|
||||
}
|
||||
|
||||
// Return sanitized hash
|
||||
var hash;
|
||||
try {
|
||||
hash = decodeURIComponent('#' + result);
|
||||
} catch(e) {
|
||||
hash = '#' + result;
|
||||
}
|
||||
return hash;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Calculate the easing pattern
|
||||
* @link https://gist.github.com/gre/1650294
|
||||
* @param {String} type Easing pattern
|
||||
* @param {Number} time Time animation should take to complete
|
||||
* @returns {Number}
|
||||
*/
|
||||
var easingPattern = function (settings, time) {
|
||||
var pattern;
|
||||
|
||||
// Default Easing Patterns
|
||||
if (settings.easing === 'easeInQuad') pattern = time * time; // accelerating from zero velocity
|
||||
if (settings.easing === 'easeOutQuad') pattern = time * (2 - time); // decelerating to zero velocity
|
||||
if (settings.easing === 'easeInOutQuad') pattern = time < 0.5 ? 2 * time * time : -1 + (4 - 2 * time) * time; // acceleration until halfway, then deceleration
|
||||
if (settings.easing === 'easeInCubic') pattern = time * time * time; // accelerating from zero velocity
|
||||
if (settings.easing === 'easeOutCubic') pattern = (--time) * time * time + 1; // decelerating to zero velocity
|
||||
if (settings.easing === 'easeInOutCubic') pattern = time < 0.5 ? 4 * time * time * time : (time - 1) * (2 * time - 2) * (2 * time - 2) + 1; // acceleration until halfway, then deceleration
|
||||
if (settings.easing === 'easeInQuart') pattern = time * time * time * time; // accelerating from zero velocity
|
||||
if (settings.easing === 'easeOutQuart') pattern = 1 - (--time) * time * time * time; // decelerating to zero velocity
|
||||
if (settings.easing === 'easeInOutQuart') pattern = time < 0.5 ? 8 * time * time * time * time : 1 - 8 * (--time) * time * time * time; // acceleration until halfway, then deceleration
|
||||
if (settings.easing === 'easeInQuint') pattern = time * time * time * time * time; // accelerating from zero velocity
|
||||
if (settings.easing === 'easeOutQuint') pattern = 1 + (--time) * time * time * time * time; // decelerating to zero velocity
|
||||
if (settings.easing === 'easeInOutQuint') pattern = time < 0.5 ? 16 * time * time * time * time * time : 1 + 16 * (--time) * time * time * time * time; // acceleration until halfway, then deceleration
|
||||
|
||||
// Custom Easing Patterns
|
||||
if (!!settings.customEasing) pattern = settings.customEasing(time);
|
||||
|
||||
return pattern || time; // no easing, no acceleration
|
||||
};
|
||||
|
||||
/**
|
||||
* Determine the document's height
|
||||
* @returns {Number}
|
||||
*/
|
||||
var getDocumentHeight = function () {
|
||||
return Math.max(
|
||||
document.body.scrollHeight, document.documentElement.scrollHeight,
|
||||
document.body.offsetHeight, document.documentElement.offsetHeight,
|
||||
document.body.clientHeight, document.documentElement.clientHeight
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Calculate how far to scroll
|
||||
* Clip support added by robjtede - https://github.com/cferdinandi/smooth-scroll/issues/405
|
||||
* @param {Element} anchor The anchor element to scroll to
|
||||
* @param {Number} headerHeight Height of a fixed header, if any
|
||||
* @param {Number} offset Number of pixels by which to offset scroll
|
||||
* @param {Boolean} clip If true, adjust scroll distance to prevent abrupt stops near the bottom of the page
|
||||
* @returns {Number}
|
||||
*/
|
||||
var getEndLocation = function (anchor, headerHeight, offset, clip) {
|
||||
var location = 0;
|
||||
if (anchor.offsetParent) {
|
||||
do {
|
||||
location += anchor.offsetTop;
|
||||
anchor = anchor.offsetParent;
|
||||
} while (anchor);
|
||||
}
|
||||
location = Math.max(location - headerHeight - offset, 0);
|
||||
if (clip) {
|
||||
location = Math.min(location, getDocumentHeight() - window.innerHeight);
|
||||
}
|
||||
return location;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the height of the fixed header
|
||||
* @param {Node} header The header
|
||||
* @return {Number} The height of the header
|
||||
*/
|
||||
var getHeaderHeight = function (header) {
|
||||
return !header ? 0 : (getHeight(header) + header.offsetTop);
|
||||
};
|
||||
|
||||
/**
|
||||
* Update the URL
|
||||
* @param {Node} anchor The anchor that was scrolled to
|
||||
* @param {Boolean} isNum If true, anchor is a number
|
||||
* @param {Object} options Settings for Smooth Scroll
|
||||
*/
|
||||
var updateURL = function (anchor, isNum, options) {
|
||||
|
||||
// Bail if the anchor is a number
|
||||
if (isNum) return;
|
||||
|
||||
// Verify that pushState is supported and the updateURL option is enabled
|
||||
if (!history.pushState || !options.updateURL) return;
|
||||
|
||||
// Update URL
|
||||
history.pushState(
|
||||
{
|
||||
smoothScroll: JSON.stringify(options),
|
||||
anchor: anchor.id
|
||||
},
|
||||
document.title,
|
||||
anchor === document.documentElement ? '#top' : '#' + anchor.id
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Bring the anchored element into focus
|
||||
* @param {Node} anchor The anchor element
|
||||
* @param {Number} endLocation The end location to scroll to
|
||||
* @param {Boolean} isNum If true, scroll is to a position rather than an element
|
||||
*/
|
||||
var adjustFocus = function (anchor, endLocation, isNum) {
|
||||
|
||||
// Is scrolling to top of page, blur
|
||||
if (anchor === 0) {
|
||||
document.body.focus();
|
||||
}
|
||||
|
||||
// Don't run if scrolling to a number on the page
|
||||
if (isNum) return;
|
||||
|
||||
// Otherwise, bring anchor element into focus
|
||||
anchor.focus();
|
||||
if (document.activeElement !== anchor) {
|
||||
anchor.setAttribute('tabindex', '-1');
|
||||
anchor.focus();
|
||||
anchor.style.outline = 'none';
|
||||
}
|
||||
window.scrollTo(0 , endLocation);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Emit a custom event
|
||||
* @param {String} type The event type
|
||||
* @param {Object} options The settings object
|
||||
* @param {Node} anchor The anchor element
|
||||
* @param {Node} toggle The toggle element
|
||||
*/
|
||||
var emitEvent = function (type, options, anchor, toggle) {
|
||||
if (!options.emitEvents || typeof window.CustomEvent !== 'function') return;
|
||||
var event = new CustomEvent(type, {
|
||||
bubbles: true,
|
||||
detail: {
|
||||
anchor: anchor,
|
||||
toggle: toggle
|
||||
}
|
||||
});
|
||||
document.dispatchEvent(event);
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// SmoothScroll Constructor
|
||||
//
|
||||
|
||||
var SmoothScroll = function (selector, options) {
|
||||
|
||||
//
|
||||
// Variables
|
||||
//
|
||||
|
||||
var smoothScroll = {}; // Object for public APIs
|
||||
var settings, anchor, toggle, fixedHeader, headerHeight, eventTimeout, animationInterval;
|
||||
|
||||
|
||||
//
|
||||
// Methods
|
||||
//
|
||||
|
||||
/**
|
||||
* Cancel a scroll-in-progress
|
||||
*/
|
||||
smoothScroll.cancelScroll = function (noEvent) {
|
||||
cancelAnimationFrame(animationInterval);
|
||||
animationInterval = null;
|
||||
if (noEvent) return;
|
||||
emitEvent('scrollCancel', settings);
|
||||
};
|
||||
|
||||
/**
|
||||
* Start/stop the scrolling animation
|
||||
* @param {Node|Number} anchor The element or position to scroll to
|
||||
* @param {Element} toggle The element that toggled the scroll event
|
||||
* @param {Object} options
|
||||
*/
|
||||
smoothScroll.animateScroll = function (anchor, toggle, options) {
|
||||
|
||||
// Local settings
|
||||
var animateSettings = extend(settings || defaults, options || {}); // Merge user options with defaults
|
||||
|
||||
// Selectors and variables
|
||||
var isNum = Object.prototype.toString.call(anchor) === '[object Number]' ? true : false;
|
||||
var anchorElem = isNum || !anchor.tagName ? null : anchor;
|
||||
if (!isNum && !anchorElem) return;
|
||||
var startLocation = window.pageYOffset; // Current location on the page
|
||||
if (animateSettings.header && !fixedHeader) {
|
||||
// Get the fixed header if not already set
|
||||
fixedHeader = document.querySelector(animateSettings.header);
|
||||
}
|
||||
if (!headerHeight) {
|
||||
// Get the height of a fixed header if one exists and not already set
|
||||
headerHeight = getHeaderHeight(fixedHeader);
|
||||
}
|
||||
var endLocation = isNum ? anchor : getEndLocation(anchorElem, headerHeight, parseInt((typeof animateSettings.offset === 'function' ? animateSettings.offset(anchor, toggle) : animateSettings.offset), 10), animateSettings.clip); // Location to scroll to
|
||||
var distance = endLocation - startLocation; // distance to travel
|
||||
var documentHeight = getDocumentHeight();
|
||||
var timeLapsed = 0;
|
||||
var start, percentage, position;
|
||||
|
||||
/**
|
||||
* Stop the scroll animation when it reaches its target (or the bottom/top of page)
|
||||
* @param {Number} position Current position on the page
|
||||
* @param {Number} endLocation Scroll to location
|
||||
* @param {Number} animationInterval How much to scroll on this loop
|
||||
*/
|
||||
var stopAnimateScroll = function (position, endLocation) {
|
||||
|
||||
// Get the current location
|
||||
var currentLocation = window.pageYOffset;
|
||||
|
||||
// Check if the end location has been reached yet (or we've hit the end of the document)
|
||||
if (position == endLocation || currentLocation == endLocation || ((startLocation < endLocation && window.innerHeight + currentLocation) >= documentHeight)) {
|
||||
|
||||
// Clear the animation timer
|
||||
smoothScroll.cancelScroll(true);
|
||||
|
||||
// Bring the anchored element into focus
|
||||
adjustFocus(anchor, endLocation, isNum);
|
||||
|
||||
// Emit a custom event
|
||||
emitEvent('scrollStop', animateSettings, anchor, toggle);
|
||||
|
||||
// Reset start
|
||||
start = null;
|
||||
animationInterval = null;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Loop scrolling animation
|
||||
*/
|
||||
var loopAnimateScroll = function (timestamp) {
|
||||
if (!start) { start = timestamp; }
|
||||
timeLapsed += timestamp - start;
|
||||
percentage = (timeLapsed / parseInt(animateSettings.speed, 10));
|
||||
percentage = (percentage > 1) ? 1 : percentage;
|
||||
position = startLocation + (distance * easingPattern(animateSettings, percentage));
|
||||
window.scrollTo(0, Math.floor(position));
|
||||
if (!stopAnimateScroll(position, endLocation)) {
|
||||
animationInterval = window.requestAnimationFrame(loopAnimateScroll);
|
||||
start = timestamp;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Reset position to fix weird iOS bug
|
||||
* @link https://github.com/cferdinandi/smooth-scroll/issues/45
|
||||
*/
|
||||
if (window.pageYOffset === 0) {
|
||||
window.scrollTo(0, 0);
|
||||
}
|
||||
|
||||
// Update the URL
|
||||
updateURL(anchor, isNum, animateSettings);
|
||||
|
||||
// Emit a custom event
|
||||
emitEvent('scrollStart', animateSettings, anchor, toggle);
|
||||
|
||||
// Start scrolling animation
|
||||
smoothScroll.cancelScroll(true);
|
||||
window.requestAnimationFrame(loopAnimateScroll);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* If smooth scroll element clicked, animate scroll
|
||||
*/
|
||||
var clickHandler = function (event) {
|
||||
|
||||
// Don't run if the user prefers reduced motion
|
||||
if (reduceMotion(settings)) return;
|
||||
|
||||
// Don't run if right-click or command/control + click
|
||||
if (event.button !== 0 || event.metaKey || event.ctrlKey) return;
|
||||
|
||||
// Check if event.target has closest() method
|
||||
// By @totegi - https://github.com/cferdinandi/smooth-scroll/pull/401/
|
||||
if(!('closest' in event.target))return;
|
||||
|
||||
// Check if a smooth scroll link was clicked
|
||||
toggle = event.target.closest(selector);
|
||||
if (!toggle || toggle.tagName.toLowerCase() !== 'a' || event.target.closest(settings.ignore)) return;
|
||||
|
||||
// Only run if link is an anchor and points to the current page
|
||||
if (toggle.hostname !== window.location.hostname || toggle.pathname !== window.location.pathname || !/#/.test(toggle.href)) return;
|
||||
|
||||
// Get an escaped version of the hash
|
||||
var hash = escapeCharacters(decode(toggle.hash));
|
||||
|
||||
// Get the anchored element
|
||||
var anchor = settings.topOnEmptyHash && hash === '#' ? document.documentElement : document.querySelector(hash);
|
||||
anchor = !anchor && hash === '#top' ? document.documentElement : anchor;
|
||||
|
||||
// If anchored element exists, scroll to it
|
||||
if (!anchor) return;
|
||||
event.preventDefault();
|
||||
smoothScroll.animateScroll(anchor, toggle);
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Animate scroll on popstate events
|
||||
*/
|
||||
var popstateHandler = function (event) {
|
||||
// Stop if history.state doesn't exist (ex. if clicking on a broken anchor link).
|
||||
// fixes `Cannot read property 'smoothScroll' of null` error getting thrown.
|
||||
if (history.state === null) return;
|
||||
|
||||
// Only run if state is a popstate record for this instantiation
|
||||
if (!history.state.smoothScroll || history.state.smoothScroll !== JSON.stringify(settings)) return;
|
||||
|
||||
// Only run if state includes an anchor
|
||||
if (!history.state.anchor) return;
|
||||
|
||||
// Get the anchor
|
||||
var anchor = document.querySelector(escapeCharacters(decode(history.state.anchor)));
|
||||
if (!anchor) return;
|
||||
|
||||
// Animate scroll to anchor link
|
||||
smoothScroll.animateScroll(anchor, null, {updateURL: false});
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* On window scroll and resize, only run events at a rate of 15fps for better performance
|
||||
*/
|
||||
var resizeThrottler = function (event) {
|
||||
if (!eventTimeout) {
|
||||
eventTimeout = setTimeout((function() {
|
||||
eventTimeout = null; // Reset timeout
|
||||
headerHeight = getHeaderHeight(fixedHeader); // Get the height of a fixed header if one exists
|
||||
}), 66);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Destroy the current initialization.
|
||||
*/
|
||||
smoothScroll.destroy = function () {
|
||||
|
||||
// If plugin isn't already initialized, stop
|
||||
if (!settings) return;
|
||||
|
||||
// Remove event listeners
|
||||
document.removeEventListener('click', clickHandler, false);
|
||||
window.removeEventListener('resize', resizeThrottler, false);
|
||||
window.removeEventListener('popstate', popstateHandler, false);
|
||||
|
||||
// Cancel any scrolls-in-progress
|
||||
smoothScroll.cancelScroll();
|
||||
|
||||
// Reset variables
|
||||
settings = null;
|
||||
anchor = null;
|
||||
toggle = null;
|
||||
fixedHeader = null;
|
||||
headerHeight = null;
|
||||
eventTimeout = null;
|
||||
animationInterval = null;
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize Smooth Scroll
|
||||
* @param {Object} options User settings
|
||||
*/
|
||||
smoothScroll.init = function (options) {
|
||||
|
||||
// feature test
|
||||
if (!supports()) throw 'Smooth Scroll: This browser does not support the required JavaScript methods and browser APIs.';
|
||||
|
||||
// Destroy any existing initializations
|
||||
smoothScroll.destroy();
|
||||
|
||||
// Selectors and variables
|
||||
settings = extend(defaults, options || {}); // Merge user options with defaults
|
||||
fixedHeader = settings.header ? document.querySelector(settings.header) : null; // Get the fixed header
|
||||
headerHeight = getHeaderHeight(fixedHeader);
|
||||
|
||||
// When a toggle is clicked, run the click handler
|
||||
document.addEventListener('click', clickHandler, false);
|
||||
|
||||
// If window is resized and there's a fixed header, recalculate its size
|
||||
if (fixedHeader) {
|
||||
window.addEventListener('resize', resizeThrottler, false);
|
||||
}
|
||||
|
||||
// If updateURL and popState are enabled, listen for pop events
|
||||
if (settings.updateURL && settings.popstate) {
|
||||
window.addEventListener('popstate', popstateHandler, false);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Initialize plugin
|
||||
//
|
||||
|
||||
smoothScroll.init(options);
|
||||
|
||||
|
||||
//
|
||||
// Public APIs
|
||||
//
|
||||
|
||||
return smoothScroll;
|
||||
|
||||
};
|
||||
|
||||
return SmoothScroll;
|
||||
|
||||
}));
|
||||
|
||||
/* GP */
|
||||
var gpscroll = new SmoothScroll( 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
@ -1,102 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* This file handles the smooth scroll functionality.
|
||||
*
|
||||
* @package GP Premium
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // No direct access, please.
|
||||
}
|
||||
|
||||
add_action( 'wp_enqueue_scripts', 'generate_smooth_scroll_scripts' );
|
||||
/**
|
||||
* Add the smooth scroll script if enabled.
|
||||
*
|
||||
* @since 1.6
|
||||
*/
|
||||
function generate_smooth_scroll_scripts() {
|
||||
if ( ! function_exists( 'generate_get_defaults' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$settings = wp_parse_args(
|
||||
get_option( 'generate_settings', array() ),
|
||||
generate_get_defaults()
|
||||
);
|
||||
|
||||
if ( ! $settings['smooth_scroll'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
||||
|
||||
wp_enqueue_script( 'generate-smooth-scroll', plugin_dir_url( __FILE__ ) . "js/smooth-scroll{$suffix}.js", array(), GP_PREMIUM_VERSION, true );
|
||||
|
||||
wp_localize_script(
|
||||
'generate-smooth-scroll',
|
||||
'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',
|
||||
)
|
||||
);
|
||||
}
|
Reference in New Issue
Block a user