Rebase trunk.
This commit is contained in:
commit
637a0d44df
18 changed files with 307 additions and 1675 deletions
|
@ -6,138 +6,154 @@
|
|||
*/
|
||||
|
||||
if ( ! function_exists( 'independent_publisher_2_setup' ) ) :
|
||||
/**
|
||||
* Sets up theme defaults and registers support for various WordPress features.
|
||||
*
|
||||
* Note that this function is hooked into the after_setup_theme hook, which
|
||||
* runs before the init hook. The init hook is too late for some features, such
|
||||
* as indicating support for post thumbnails.
|
||||
*/
|
||||
function independent_publisher_2_setup() {
|
||||
/*
|
||||
* Make theme available for translation.
|
||||
* Translations can be filed in the /languages/ directory.
|
||||
* If you're building a theme based on Independent Publisher 2, use a find and replace
|
||||
* to change 'independent-publisher-2' to the name of your theme in all the template files
|
||||
*/
|
||||
load_theme_textdomain( 'independent-publisher-2', get_template_directory() . '/languages' );
|
||||
|
||||
// Add default posts and comments RSS feed links to head.
|
||||
add_theme_support( 'automatic-feed-links' );
|
||||
|
||||
/*
|
||||
* Let WordPress manage the document title.
|
||||
* By adding theme support, we declare that this theme does not use a
|
||||
* hard-coded <title> tag in the document head, and expect WordPress to
|
||||
* provide it for us.
|
||||
*/
|
||||
add_theme_support( 'title-tag' );
|
||||
|
||||
|
||||
add_theme_support( 'customize_selective_refresh_widgets' );
|
||||
|
||||
/*
|
||||
* Enable support for Post Thumbnails on posts and pages.
|
||||
*
|
||||
* @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
|
||||
*/
|
||||
add_theme_support( 'post-thumbnails' );
|
||||
set_post_thumbnail_size( 740, 430, true );
|
||||
add_image_size( 'independent-publisher-2-banner', 1440, 600, true );
|
||||
add_image_size( 'independent-publisher-2-full-width', 1100, 9999 );
|
||||
|
||||
// This theme uses wp_nav_menu() in one location.
|
||||
register_nav_menus( array(
|
||||
'menu-1' => esc_html__( 'Header', 'independent-publisher-2' ),
|
||||
) );
|
||||
|
||||
/**
|
||||
* Add custom logo support
|
||||
* Sets up theme defaults and registers support for various WordPress features.
|
||||
*
|
||||
* Note that this function is hooked into the after_setup_theme hook, which
|
||||
* runs before the init hook. The init hook is too late for some features, such
|
||||
* as indicating support for post thumbnails.
|
||||
*/
|
||||
add_theme_support( 'custom-logo', array(
|
||||
'height' => 300,
|
||||
'width' => 1500,
|
||||
'flex-width' => true,
|
||||
) );
|
||||
function independent_publisher_2_setup() {
|
||||
/*
|
||||
* Make theme available for translation.
|
||||
* Translations can be filed in the /languages/ directory.
|
||||
* If you're building a theme based on Independent Publisher 2, use a find and replace
|
||||
* to change 'independent-publisher-2' to the name of your theme in all the template files
|
||||
*/
|
||||
load_theme_textdomain( 'independent-publisher-2', get_template_directory() . '/languages' );
|
||||
|
||||
/*
|
||||
* Switch default core markup for search form, comment form, and comments
|
||||
* to output valid HTML5.
|
||||
*/
|
||||
add_theme_support( 'html5', array(
|
||||
'search-form',
|
||||
'comment-form',
|
||||
'comment-list',
|
||||
'gallery',
|
||||
'caption',
|
||||
) );
|
||||
// Add default posts and comments RSS feed links to head.
|
||||
add_theme_support( 'automatic-feed-links' );
|
||||
|
||||
// Set up the WordPress core custom background feature.
|
||||
add_theme_support( 'custom-background', apply_filters( 'independent_publisher_2_custom_background_args', array(
|
||||
'default-color' => 'ffffff',
|
||||
) ) );
|
||||
/*
|
||||
* Let WordPress manage the document title.
|
||||
* By adding theme support, we declare that this theme does not use a
|
||||
* hard-coded <title> tag in the document head, and expect WordPress to
|
||||
* provide it for us.
|
||||
*/
|
||||
add_theme_support( 'title-tag' );
|
||||
|
||||
// Load regular editor styles into the new block-based editor.
|
||||
add_theme_support( 'editor-styles' );
|
||||
add_theme_support( 'customize_selective_refresh_widgets' );
|
||||
|
||||
// Add support for Block Styles.
|
||||
add_theme_support( 'wp-block-styles' );
|
||||
/*
|
||||
* Enable support for Post Thumbnails on posts and pages.
|
||||
*
|
||||
* @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
|
||||
*/
|
||||
add_theme_support( 'post-thumbnails' );
|
||||
set_post_thumbnail_size( 740, 430, true );
|
||||
add_image_size( 'independent-publisher-2-banner', 1440, 600, true );
|
||||
add_image_size( 'independent-publisher-2-full-width', 1100, 9999 );
|
||||
|
||||
// Add support for responsive embeds.
|
||||
add_theme_support( 'responsive-embeds' );
|
||||
// This theme uses wp_nav_menu() in one location.
|
||||
register_nav_menus(
|
||||
array(
|
||||
'menu-1' => esc_html__( 'Header', 'independent-publisher-2' ),
|
||||
)
|
||||
);
|
||||
|
||||
// Add support for full and wide align images.
|
||||
add_theme_support( 'align-wide' );
|
||||
/**
|
||||
* Add custom logo support
|
||||
*/
|
||||
add_theme_support(
|
||||
'custom-logo',
|
||||
array(
|
||||
'height' => 300,
|
||||
'width' => 1500,
|
||||
'flex-width' => true,
|
||||
)
|
||||
);
|
||||
|
||||
// Add support for custom color scheme.
|
||||
add_theme_support( 'editor-color-palette', array(
|
||||
array(
|
||||
'name' => __( 'Medium Blue', 'independent-publisher-2' ),
|
||||
'slug' => 'medium-blue',
|
||||
'color' => '#0087be',
|
||||
),
|
||||
array(
|
||||
'name' => __( 'Bright Blue', 'independent-publisher-2' ),
|
||||
'slug' => 'bright-blue',
|
||||
'color' => '#00aadc',
|
||||
),
|
||||
array(
|
||||
'name' => __( 'Dark Gray', 'independent-publisher-2' ),
|
||||
'slug' => 'dark-gray',
|
||||
'color' => '#4d4d4b',
|
||||
),
|
||||
array(
|
||||
'name' => __( 'Light Gray', 'independent-publisher-2' ),
|
||||
'slug' => 'light-gray',
|
||||
'color' => '#b3b3b1',
|
||||
),
|
||||
array(
|
||||
'name' => __( 'White', 'independent-publisher-2' ),
|
||||
'slug' => 'white',
|
||||
'color' => '#fff',
|
||||
),
|
||||
) );
|
||||
}
|
||||
/*
|
||||
* Switch default core markup for search form, comment form, and comments
|
||||
* to output valid HTML5.
|
||||
*/
|
||||
add_theme_support(
|
||||
'html5',
|
||||
array(
|
||||
'search-form',
|
||||
'comment-form',
|
||||
'comment-list',
|
||||
'gallery',
|
||||
'caption',
|
||||
)
|
||||
);
|
||||
|
||||
// Set up the WordPress core custom background feature.
|
||||
add_theme_support(
|
||||
'custom-background',
|
||||
apply_filters(
|
||||
'independent_publisher_2_custom_background_args',
|
||||
array(
|
||||
'default-color' => 'ffffff',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// Load regular editor styles into the new block-based editor.
|
||||
add_theme_support( 'editor-styles' );
|
||||
|
||||
// Add support for Block Styles.
|
||||
add_theme_support( 'wp-block-styles' );
|
||||
|
||||
// Add support for responsive embeds.
|
||||
add_theme_support( 'responsive-embeds' );
|
||||
|
||||
// Add support for full and wide align images.
|
||||
add_theme_support( 'align-wide' );
|
||||
|
||||
// Add support for custom color scheme.
|
||||
add_theme_support(
|
||||
'editor-color-palette',
|
||||
array(
|
||||
array(
|
||||
'name' => __( 'Medium Blue', 'independent-publisher-2' ),
|
||||
'slug' => 'medium-blue',
|
||||
'color' => '#0087be',
|
||||
),
|
||||
array(
|
||||
'name' => __( 'Bright Blue', 'independent-publisher-2' ),
|
||||
'slug' => 'bright-blue',
|
||||
'color' => '#00aadc',
|
||||
),
|
||||
array(
|
||||
'name' => __( 'Dark Gray', 'independent-publisher-2' ),
|
||||
'slug' => 'dark-gray',
|
||||
'color' => '#4d4d4b',
|
||||
),
|
||||
array(
|
||||
'name' => __( 'Light Gray', 'independent-publisher-2' ),
|
||||
'slug' => 'light-gray',
|
||||
'color' => '#b3b3b1',
|
||||
),
|
||||
array(
|
||||
'name' => __( 'White', 'independent-publisher-2' ),
|
||||
'slug' => 'white',
|
||||
'color' => '#fff',
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
endif; // independent_publisher_2_setup
|
||||
add_action( 'after_setup_theme', 'independent_publisher_2_setup' );
|
||||
|
||||
if ( ! function_exists( 'independent_publisher_2_word_count' ) ) :
|
||||
/**
|
||||
* Gets the number of words in the post content.
|
||||
*
|
||||
* @link http://php.net/str_word_count
|
||||
* @link http://php.net/number_format
|
||||
*/
|
||||
function independent_publisher_2_word_count() {
|
||||
$content = get_post_field( 'post_content', get_the_ID() );
|
||||
$count = str_word_count( strip_tags( $content ) );
|
||||
$time = $count / 250; //Roughly 250 wpm reading time
|
||||
// if time less than 1 explicitly set to 1.
|
||||
if( $time < 1 ) {
|
||||
$time = 1;
|
||||
/**
|
||||
* Gets the number of words in the post content.
|
||||
*
|
||||
* @link http://php.net/str_word_count
|
||||
* @link http://php.net/number_format
|
||||
*/
|
||||
function independent_publisher_2_word_count() {
|
||||
$content = get_post_field( 'post_content', get_the_ID() );
|
||||
$count = str_word_count( strip_tags( $content ) );
|
||||
$time = $count / 250; //Roughly 250 wpm reading time
|
||||
// if time less than 1 explicitly set to 1.
|
||||
if ( $time < 1 ) {
|
||||
$time = 1;
|
||||
}
|
||||
return number_format( $time );
|
||||
}
|
||||
return number_format( $time );
|
||||
}
|
||||
endif; // independent_publisher_2_word_count
|
||||
|
||||
/**
|
||||
|
@ -158,42 +174,50 @@ add_action( 'after_setup_theme', 'independent_publisher_2_content_width', 0 );
|
|||
* @link http://codex.wordpress.org/Function_Reference/register_sidebar
|
||||
*/
|
||||
function independent_publisher_2_widgets_init() {
|
||||
register_sidebar( array(
|
||||
'name' => esc_html__( 'Sidebar', 'independent-publisher-2' ),
|
||||
'id' => 'sidebar-1',
|
||||
'description' => '',
|
||||
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
|
||||
'after_widget' => '</aside>',
|
||||
'before_title' => '<h1 class="widget-title">',
|
||||
'after_title' => '</h1>',
|
||||
) );
|
||||
register_sidebar( array(
|
||||
'name' => esc_html__( 'Footer 1', 'independent-publisher-2' ),
|
||||
'id' => 'sidebar-2',
|
||||
'description' => '',
|
||||
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
|
||||
'after_widget' => '</aside>',
|
||||
'before_title' => '<h1 class="widget-title">',
|
||||
'after_title' => '</h1>',
|
||||
) );
|
||||
register_sidebar( array(
|
||||
'name' => esc_html__( 'Footer 2', 'independent-publisher-2' ),
|
||||
'id' => 'sidebar-3',
|
||||
'description' => '',
|
||||
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
|
||||
'after_widget' => '</aside>',
|
||||
'before_title' => '<h1 class="widget-title">',
|
||||
'after_title' => '</h1>',
|
||||
) );
|
||||
register_sidebar( array(
|
||||
'name' => esc_html__( 'Footer 3', 'independent-publisher-2' ),
|
||||
'id' => 'sidebar-4',
|
||||
'description' => '',
|
||||
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
|
||||
'after_widget' => '</aside>',
|
||||
'before_title' => '<h1 class="widget-title">',
|
||||
'after_title' => '</h1>',
|
||||
) );
|
||||
register_sidebar(
|
||||
array(
|
||||
'name' => esc_html__( 'Sidebar', 'independent-publisher-2' ),
|
||||
'id' => 'sidebar-1',
|
||||
'description' => '',
|
||||
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
|
||||
'after_widget' => '</aside>',
|
||||
'before_title' => '<h1 class="widget-title">',
|
||||
'after_title' => '</h1>',
|
||||
)
|
||||
);
|
||||
register_sidebar(
|
||||
array(
|
||||
'name' => esc_html__( 'Footer 1', 'independent-publisher-2' ),
|
||||
'id' => 'sidebar-2',
|
||||
'description' => '',
|
||||
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
|
||||
'after_widget' => '</aside>',
|
||||
'before_title' => '<h1 class="widget-title">',
|
||||
'after_title' => '</h1>',
|
||||
)
|
||||
);
|
||||
register_sidebar(
|
||||
array(
|
||||
'name' => esc_html__( 'Footer 2', 'independent-publisher-2' ),
|
||||
'id' => 'sidebar-3',
|
||||
'description' => '',
|
||||
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
|
||||
'after_widget' => '</aside>',
|
||||
'before_title' => '<h1 class="widget-title">',
|
||||
'after_title' => '</h1>',
|
||||
)
|
||||
);
|
||||
register_sidebar(
|
||||
array(
|
||||
'name' => esc_html__( 'Footer 3', 'independent-publisher-2' ),
|
||||
'id' => 'sidebar-4',
|
||||
'description' => '',
|
||||
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
|
||||
'after_widget' => '</aside>',
|
||||
'before_title' => '<h1 class="widget-title">',
|
||||
'after_title' => '</h1>',
|
||||
)
|
||||
);
|
||||
}
|
||||
add_action( 'widgets_init', 'independent_publisher_2_widgets_init' );
|
||||
|
||||
|
@ -217,17 +241,20 @@ function independent_publisher_2_scripts() {
|
|||
}
|
||||
|
||||
// If there's an active Video widget, and it's (hopefully) in the footer widget area
|
||||
if ( is_active_widget( '','', 'media_video' ) && ( is_active_sidebar( 'sidebar-2' ) || is_active_sidebar( 'sidebar-3' ) || is_active_sidebar( 'sidebar-4' ) ) ) {
|
||||
if ( is_active_widget( '', '', 'media_video' ) && ( is_active_sidebar( 'sidebar-2' ) || is_active_sidebar( 'sidebar-3' ) || is_active_sidebar( 'sidebar-4' ) ) ) {
|
||||
wp_enqueue_script( 'independent-publisher-2-video-widget', get_template_directory_uri() . '/js/video-widget.js', array( 'jquery' ), '20170608', true );
|
||||
}
|
||||
|
||||
wp_enqueue_script( 'independent-publisher-2-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20170315', true );
|
||||
|
||||
if ( independent_publisher_2_has_header_image() ) {
|
||||
wp_add_inline_style( 'independent-publisher-2-style', sprintf(
|
||||
'#hero-header { background: url("%s") no-repeat center; background-size: cover; background-attachment: scroll; }',
|
||||
esc_url( get_header_image() )
|
||||
) );
|
||||
wp_add_inline_style(
|
||||
'independent-publisher-2-style',
|
||||
sprintf(
|
||||
'#hero-header { background: url("%s") no-repeat center; background-size: cover; background-attachment: scroll; }',
|
||||
esc_url( get_header_image() )
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ( is_singular() ) {
|
||||
|
@ -250,10 +277,13 @@ function independent_publisher_2_scripts() {
|
|||
//Grab the first URL
|
||||
$banner = $banner_matches[0][0];
|
||||
|
||||
wp_add_inline_style( 'independent-publisher-2-style', sprintf(
|
||||
'#hero-header { background: url("%s") no-repeat center; background-size: cover; background-attachment: scroll; }',
|
||||
esc_url( $banner )
|
||||
) );
|
||||
wp_add_inline_style(
|
||||
'independent-publisher-2-style',
|
||||
sprintf(
|
||||
'#hero-header { background: url("%s") no-repeat center; background-size: cover; background-attachment: scroll; }',
|
||||
esc_url( $banner )
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@
|
|||
--global--font-size-xxl: 32px;
|
||||
--global--font-size-xxxl: 48px;
|
||||
--global--letter-spacing: normal;
|
||||
/* Font Weight */
|
||||
--global--font-weight: normal;
|
||||
/* Line Height */
|
||||
--global--line-height-base: 1;
|
||||
--global--line-height-body: 1.7;
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -26,6 +26,9 @@ $typescale-ratio: 1.2; // Run ratio math on 1em == $typescale-base * $typescale-
|
|||
--global--font-size-xxxl: 48px;
|
||||
--global--letter-spacing: normal;
|
||||
|
||||
/* Font Weight */
|
||||
--global--font-weight: normal;
|
||||
|
||||
/* Line Height */
|
||||
--global--line-height-base: #{$typescale-base / ( $typescale-base * 0 + 1 )};
|
||||
--global--line-height-body: 1.7;
|
||||
|
|
|
@ -72,7 +72,7 @@ html {
|
|||
// body resets
|
||||
body {
|
||||
font-size: var(--global--font-size-base); /* #{$typescale-base}; */
|
||||
font-weight: normal;
|
||||
font-weight: var(--global--font-weight);
|
||||
color: var(--global--color-foreground);
|
||||
text-align: left;
|
||||
background-color: var(--global--color-background);
|
||||
|
|
|
@ -28,6 +28,8 @@ body {
|
|||
--global--font-secondary: 'Fira Sans', Helvetica, Arial, sans-serif;
|
||||
--global--font-code: monospace, monospace;
|
||||
--global--font-ui: var(--global--font-secondary);
|
||||
/* Font Weight */
|
||||
--global--font-weight: normal;
|
||||
/* Font Size */
|
||||
--global--font-size-root: 18px;
|
||||
--global--font-size-ratio: 1.2;
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
--global--font-secondary: 'Fira Sans', Helvetica, Arial, sans-serif;
|
||||
--global--font-code: monospace, monospace;
|
||||
--global--font-ui: var(--global--font-secondary);
|
||||
/* Font Weight */
|
||||
--global--font-weight: normal;
|
||||
/* Font Size */
|
||||
--global--font-size-root: 18px;
|
||||
--global--font-size-ratio: 1.2;
|
||||
|
|
|
@ -26,7 +26,7 @@ class Seedlet_Custom_Colors {
|
|||
array( '--global--color-primary', '#000000', __( 'Primary Color', 'seedlet' ) ),
|
||||
array( '--global--color-secondary', '#3C8067', __( 'Secondary Color', 'seedlet' ) ),
|
||||
array( '--global--color-tertiary', '#FAFBF6', __( 'Tertiary Color', 'seedlet' ) ),
|
||||
array( '--global--color-border', '#EFEFEF', __( 'Borders Color', 'seedlet' ) )
|
||||
array( '--global--color-border', '#EFEFEF', __( 'Borders Color', 'seedlet' ) ),
|
||||
);
|
||||
|
||||
/**
|
||||
|
@ -61,7 +61,7 @@ class Seedlet_Custom_Colors {
|
|||
* @param string $background Optional. Hexadecimal colour value of the background colour. Default is: <code>FFFFFF</code> aka white.
|
||||
* @return string Hexadecimal colour value. <code>false</code> on errors.
|
||||
*/
|
||||
function seedlet_color_blend_by_opacity( $foreground, $opacity, $background=null ) {
|
||||
function seedlet_color_blend_by_opacity( $foreground, $opacity, $background = null ) {
|
||||
static $colors_rgb = array(); // stores colour values already passed through the hexdec() functions below.
|
||||
|
||||
if ( ! is_null( $foreground ) ) {
|
||||
|
@ -78,53 +78,55 @@ class Seedlet_Custom_Colors {
|
|||
|
||||
$pattern = '~^[a-f0-9]{6,6}$~i'; // accept only valid hexadecimal colour values.
|
||||
|
||||
if ( !@preg_match($pattern, $foreground) or !@preg_match($pattern, $background) ) {
|
||||
if ( ! @preg_match( $pattern, $foreground ) or ! @preg_match( $pattern, $background ) ) {
|
||||
echo $foreground;
|
||||
trigger_error( "Invalid hexadecimal color value(s) found", E_USER_WARNING );
|
||||
trigger_error( 'Invalid hexadecimal color value(s) found', E_USER_WARNING );
|
||||
return false;
|
||||
}
|
||||
|
||||
$opacity = intval( $opacity ); // validate opacity data/number.
|
||||
|
||||
if ( $opacity > 100 || $opacity < 0 ) {
|
||||
trigger_error( "Opacity percentage error, valid numbers are between 0 - 100", E_USER_WARNING );
|
||||
if ( $opacity > 100 || $opacity < 0 ) {
|
||||
trigger_error( 'Opacity percentage error, valid numbers are between 0 - 100', E_USER_WARNING );
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( $opacity == 100 ) // $transparency == 0
|
||||
if ( $opacity == 100 ) { // $transparency == 0
|
||||
return strtoupper( $foreground );
|
||||
if ( $opacity == 0 ) // $transparency == 100
|
||||
}
|
||||
if ( $opacity == 0 ) { // $transparency == 100
|
||||
return strtoupper( $background );
|
||||
|
||||
// calculate $transparency value.
|
||||
$transparency = 100-$opacity;
|
||||
|
||||
if ( !isset($colors_rgb[$foreground]) ) { // do this only ONCE per script, for each unique colour.
|
||||
$f = array(
|
||||
'r'=>hexdec($foreground[0].$foreground[1]),
|
||||
'g'=>hexdec($foreground[2].$foreground[3]),
|
||||
'b'=>hexdec($foreground[4].$foreground[5])
|
||||
);
|
||||
$colors_rgb[$foreground] = $f;
|
||||
} else { // if this function is used 100 times in a script, this block is run 99 times. Efficient.
|
||||
$f = $colors_rgb[$foreground];
|
||||
}
|
||||
|
||||
if ( !isset($colors_rgb[$background]) ) { // do this only ONCE per script, for each unique colour.
|
||||
$b = array(
|
||||
'r'=>hexdec($background[0].$background[1]),
|
||||
'g'=>hexdec($background[2].$background[3]),
|
||||
'b'=>hexdec($background[4].$background[5])
|
||||
// calculate $transparency value.
|
||||
$transparency = 100 - $opacity;
|
||||
|
||||
if ( ! isset( $colors_rgb[ $foreground ] ) ) { // do this only ONCE per script, for each unique colour.
|
||||
$f = array(
|
||||
'r' => hexdec( $foreground[0] . $foreground[1] ),
|
||||
'g' => hexdec( $foreground[2] . $foreground[3] ),
|
||||
'b' => hexdec( $foreground[4] . $foreground[5] ),
|
||||
);
|
||||
$colors_rgb[$background] = $b;
|
||||
$colors_rgb[ $foreground ] = $f;
|
||||
} else { // if this function is used 100 times in a script, this block is run 99 times. Efficient.
|
||||
$f = $colors_rgb[ $foreground ];
|
||||
}
|
||||
|
||||
if ( ! isset( $colors_rgb[ $background ] ) ) { // do this only ONCE per script, for each unique colour.
|
||||
$b = array(
|
||||
'r' => hexdec( $background[0] . $background[1] ),
|
||||
'g' => hexdec( $background[2] . $background[3] ),
|
||||
'b' => hexdec( $background[4] . $background[5] ),
|
||||
);
|
||||
$colors_rgb[ $background ] = $b;
|
||||
} else { // if this FUNCTION is used 100 times in a SCRIPT, this block will run 99 times. Efficient.
|
||||
$b = $colors_rgb[$background];
|
||||
$b = $colors_rgb[ $background ];
|
||||
}
|
||||
|
||||
$add = array(
|
||||
'r'=>( $b['r']-$f['r'] ) / 100,
|
||||
'g'=>( $b['g']-$f['g'] ) / 100,
|
||||
'b'=>( $b['b']-$f['b'] ) / 100
|
||||
'r' => ( $b['r'] - $f['r'] ) / 100,
|
||||
'g' => ( $b['g'] - $f['g'] ) / 100,
|
||||
'b' => ( $b['b'] - $f['b'] ) / 100,
|
||||
);
|
||||
|
||||
$f['r'] += intval( $add['r'] * $transparency );
|
||||
|
@ -144,10 +146,13 @@ class Seedlet_Custom_Colors {
|
|||
/**
|
||||
* Create color options panel.
|
||||
*/
|
||||
$wp_customize->add_section( 'seedlet_options', array(
|
||||
'capability' => 'edit_theme_options',
|
||||
'title' => esc_html__( 'Colors', 'seedlet' ),
|
||||
) );
|
||||
$wp_customize->add_section(
|
||||
'seedlet_options',
|
||||
array(
|
||||
'capability' => 'edit_theme_options',
|
||||
'title' => esc_html__( 'Colors', 'seedlet' ),
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* Create toggle between default and custom colors.
|
||||
|
@ -182,21 +187,23 @@ class Seedlet_Custom_Colors {
|
|||
$wp_customize->add_setting(
|
||||
"seedlet_$variable[0]",
|
||||
array(
|
||||
'default' => esc_html( $variable[1] ),
|
||||
'sanitize_callback' => 'sanitize_hex_color'
|
||||
'default' => esc_html( $variable[1] ),
|
||||
'sanitize_callback' => 'sanitize_hex_color',
|
||||
)
|
||||
);
|
||||
$wp_customize->add_control( new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
"seedlet_$variable[0]",
|
||||
array(
|
||||
'section' => 'seedlet_options',
|
||||
'label' => $variable[2],
|
||||
'active_callback' => function() use ( $wp_customize ) {
|
||||
return ( 'custom' === $wp_customize->get_setting( 'custom_colors_active' )->value() );
|
||||
},
|
||||
$wp_customize->add_control(
|
||||
new WP_Customize_Color_Control(
|
||||
$wp_customize,
|
||||
"seedlet_$variable[0]",
|
||||
array(
|
||||
'section' => 'seedlet_options',
|
||||
'label' => $variable[2],
|
||||
'active_callback' => function() use ( $wp_customize ) {
|
||||
return ( 'custom' === $wp_customize->get_setting( 'custom_colors_active' )->value() );
|
||||
},
|
||||
)
|
||||
)
|
||||
) );
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -213,11 +220,11 @@ class Seedlet_Custom_Colors {
|
|||
|
||||
// Check to see if a custom background color has been set that is needed for our color calculation
|
||||
// If this check isn't present, the color calculation generates a warning that an invalid color has been supplied
|
||||
$theme_mod_bg_color = empty( get_theme_mod( "seedlet_--global--color-background" ) ) ? '#FFFFFF' : get_theme_mod( "seedlet_--global--color-background" );
|
||||
$theme_mod_bg_color = empty( get_theme_mod( 'seedlet_--global--color-background' ) ) ? '#FFFFFF' : get_theme_mod( 'seedlet_--global--color-background' );
|
||||
|
||||
foreach ( $this->seedlet_custom_color_variables as $variable ) {
|
||||
|
||||
if ( ! empty ( get_theme_mod( "seedlet_$variable[0]" ) ) ) {
|
||||
if ( ! empty( get_theme_mod( "seedlet_$variable[0]" ) ) ) {
|
||||
|
||||
$theme_mod_variable_name = $variable[0];
|
||||
$theme_mod_default_color = $variable[1];
|
||||
|
@ -225,28 +232,28 @@ class Seedlet_Custom_Colors {
|
|||
$opacity_integer = 70;
|
||||
$adjusted_color = $this->seedlet_color_blend_by_opacity( $theme_mod_custom_color, $opacity_integer, $theme_mod_bg_color );
|
||||
|
||||
$theme_css .= $theme_mod_variable_name . ":" . $theme_mod_custom_color . ";";
|
||||
$theme_css .= $theme_mod_variable_name . ':' . $theme_mod_custom_color . ';';
|
||||
|
||||
if ( $theme_mod_variable_name === '--global--color-primary' && $theme_mod_default_color !== $theme_mod_custom_color ) {
|
||||
$theme_css .= "--global--color-primary-hover: " . $adjusted_color . ";";
|
||||
$theme_css .= '--global--color-primary-hover: ' . $adjusted_color . ';';
|
||||
}
|
||||
|
||||
if ( $theme_mod_variable_name === '--global--color-secondary' && $theme_mod_default_color !== $theme_mod_custom_color ) {
|
||||
$theme_css .= "--global--color-secondary-hover: " . $adjusted_color . ";";
|
||||
$theme_css .= '--global--color-secondary-hover: ' . $adjusted_color . ';';
|
||||
}
|
||||
|
||||
if ( $theme_mod_variable_name === '--global--color-foreground' && $theme_mod_default_color !== $theme_mod_custom_color ) {
|
||||
$theme_css .= "--global--color-foreground-low-contrast: " . $adjusted_color . ";";
|
||||
$theme_css .= '--global--color-foreground-low-contrast: ' . $adjusted_color . ';';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$theme_css .= "}";
|
||||
$theme_css .= '}';
|
||||
|
||||
// Text selection colors
|
||||
$selection_background = $this->seedlet_color_blend_by_opacity( get_theme_mod( "seedlet_--global--color-primary" ), 5, $theme_mod_bg_color ) . ";";
|
||||
$theme_css .= "::selection { background-color: " . $selection_background . "}";
|
||||
$theme_css .= "::-moz-selection { background-color: ". $selection_background . "}";
|
||||
$selection_background = $this->seedlet_color_blend_by_opacity( get_theme_mod( 'seedlet_--global--color-primary' ), 5, $theme_mod_bg_color ) . ';';
|
||||
$theme_css .= '::selection { background-color: ' . $selection_background . '}';
|
||||
$theme_css .= '::-moz-selection { background-color: ' . $selection_background . '}';
|
||||
|
||||
return $theme_css;
|
||||
}
|
||||
|
@ -279,23 +286,23 @@ class Seedlet_Custom_Colors {
|
|||
function on_customize_controls_enqueue_scripts() {
|
||||
$handle = 'seedlet-wcag-validate-customizer-color-contrast';
|
||||
$src = get_template_directory_uri() . '/assets/js/customizer-validate-wcag-color-contrast.js';
|
||||
$deps = [ 'customize-controls' ];
|
||||
$deps = array( 'customize-controls' );
|
||||
|
||||
$exports = [
|
||||
'validate_color_contrast' => [
|
||||
$exports = array(
|
||||
'validate_color_contrast' => array(
|
||||
// key = current color control , values = array with color controls to check color contrast against
|
||||
'seedlet_--global--color-primary' => [ "seedlet_--global--color-background" ],
|
||||
'seedlet_--global--color-secondary' => [ "seedlet_--global--color-background" ],
|
||||
'seedlet_--global--color-foreground' => [ "seedlet_--global--color-background" ],
|
||||
'seedlet_--global--color-background' => [ "seedlet_--global--color-foreground" ],
|
||||
],
|
||||
];
|
||||
'seedlet_--global--color-primary' => array( 'seedlet_--global--color-background' ),
|
||||
'seedlet_--global--color-secondary' => array( 'seedlet_--global--color-background' ),
|
||||
'seedlet_--global--color-foreground' => array( 'seedlet_--global--color-background' ),
|
||||
'seedlet_--global--color-background' => array( 'seedlet_--global--color-foreground' ),
|
||||
),
|
||||
);
|
||||
|
||||
wp_enqueue_script( $handle, $src, $deps );
|
||||
wp_script_add_data( $handle, 'data', sprintf( 'var seedletValidateWCAGColorContrastExports = %s;', wp_json_encode( $exports ) ) );
|
||||
|
||||
// Custom color contrast validation text
|
||||
wp_localize_script( $handle, 'seedletValidateContrastText', esc_html__( 'This color combination may be hard for people to read. Try using a brighter background color and/or a darker foreground color.', 'seedlet' ));
|
||||
wp_localize_script( $handle, 'seedletValidateContrastText', esc_html__( 'This color combination may be hard for people to read. Try using a brighter background color and/or a darker foreground color.', 'seedlet' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -91,6 +91,8 @@ Included in theme screenshot and in block patterns.
|
|||
--global--font-size-xxl: 32px;
|
||||
--global--font-size-xxxl: 48px;
|
||||
--global--letter-spacing: normal;
|
||||
/* Font Weight */
|
||||
--global--font-weight: normal;
|
||||
/* Line Height */
|
||||
--global--line-height-base: 1;
|
||||
--global--line-height-body: 1.7;
|
||||
|
@ -916,7 +918,7 @@ html {
|
|||
body {
|
||||
font-size: var(--global--font-size-base);
|
||||
/* 1em; */
|
||||
font-weight: normal;
|
||||
font-weight: var(--global--font-weight);
|
||||
color: var(--global--color-foreground);
|
||||
text-align: right;
|
||||
background-color: var(--global--color-background);
|
||||
|
|
|
@ -91,6 +91,8 @@ Included in theme screenshot and in block patterns.
|
|||
--global--font-size-xxl: 32px;
|
||||
--global--font-size-xxxl: 48px;
|
||||
--global--letter-spacing: normal;
|
||||
/* Font Weight */
|
||||
--global--font-weight: normal;
|
||||
/* Line Height */
|
||||
--global--line-height-base: 1;
|
||||
--global--line-height-body: 1.7;
|
||||
|
@ -916,7 +918,7 @@ html {
|
|||
body {
|
||||
font-size: var(--global--font-size-base);
|
||||
/* 1em; */
|
||||
font-weight: normal;
|
||||
font-weight: var(--global--font-weight);
|
||||
color: var(--global--color-foreground);
|
||||
text-align: left;
|
||||
background-color: var(--global--color-background);
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -2,7 +2,7 @@
|
|||
border-bottom: 1px solid transparent;
|
||||
transition: all 0.1s ease;
|
||||
|
||||
&:hover {
|
||||
&:hover:not(.wp-block-button__link) {
|
||||
color: var( --global--color-primary-hover );
|
||||
border-bottom: 1px solid var( --global--color-primary-hover );
|
||||
}
|
||||
|
|
1437
spearhead/package-lock.json
generated
1437
spearhead/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -17,6 +17,19 @@
|
|||
"npm-run-all": "^4.1.5",
|
||||
"rtlcss": "^2.4.0"
|
||||
},
|
||||
"rtlcssConfig": {
|
||||
"options": {
|
||||
"autoRename": false,
|
||||
"autoRenameStrict": false,
|
||||
"blacklist": {},
|
||||
"clean": true,
|
||||
"greedy": false,
|
||||
"processUrls": false,
|
||||
"stringMap": []
|
||||
},
|
||||
"plugins": [],
|
||||
"map": false
|
||||
},
|
||||
"scripts": {
|
||||
"start": "npm run watch",
|
||||
"build:style": "node-sass assets/sass/style.scss style.css --output-style expanded --indent-type tab --indent-width 1 --source-map true",
|
||||
|
|
|
@ -149,7 +149,7 @@ Tags: one-column, flexible-header, accessibility-ready, custom-colors, custom-me
|
|||
transition: all 0.1s ease;
|
||||
}
|
||||
|
||||
.has-link-color a:hover, a:hover {
|
||||
.has-link-color a:hover:not(.wp-block-button__link), a:hover:not(.wp-block-button__link) {
|
||||
color: var(--global--color-primary-hover);
|
||||
border-bottom: 1px solid var(--global--color-primary-hover);
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ Tags: one-column, flexible-header, accessibility-ready, custom-colors, custom-me
|
|||
transition: all 0.1s ease;
|
||||
}
|
||||
|
||||
.has-link-color a:hover, a:hover {
|
||||
.has-link-color a:hover:not(.wp-block-button__link), a:hover:not(.wp-block-button__link) {
|
||||
color: var(--global--color-primary-hover);
|
||||
border-bottom: 1px solid var(--global--color-primary-hover);
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -12,6 +12,8 @@
|
|||
--global--color-foreground-light: #333333;
|
||||
--global--color-background: #fff;
|
||||
--global--color-border: var(--global--color-secondary);
|
||||
/* Font Weight */
|
||||
--global--font-weight: 500;
|
||||
/* Font Size */
|
||||
--global--font-size-xs: 14px;
|
||||
--global--font-size-sm: 16px;
|
||||
|
|
Loading…
Reference in a new issue