From 46a1ed27d8312cb25cfb496f2b725eb9a9339c33 Mon Sep 17 00:00:00 2001 From: Corey Collins Date: Fri, 26 Oct 2018 13:46:34 -0500 Subject: [PATCH 1/6] =?UTF-8?q?Removes=20our=20WDS=20placeholder=20functio?= =?UTF-8?q?n=20=E2=80=93=20placeholder.wdslab.com=20no=20longer=20appears?= =?UTF-8?q?=20to=20be=20a=20thing?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/extras.php | 57 -------------------------------------------------- 1 file changed, 57 deletions(-) diff --git a/inc/extras.php b/inc/extras.php index 7392727f2..6e9af6579 100644 --- a/inc/extras.php +++ b/inc/extras.php @@ -66,63 +66,6 @@ function _s_get_attachment_id_from_url( $attachment_url = '' ) { return $attachment_id; } -/** - * Returns an that can be used anywhere a placeholder image is needed - * in a theme. The image is a simple colored block with the image dimensions - * displayed in the middle. - * - * @author Ben Lobaugh - * @throws Exception Details of missing parameters. - * @param array $args {. - * @type int $width - * @type int $height - * @type string $background_color - * @type string $text_color - * } - * @return string - */ -function _s_get_placeholder_image( $args = array() ) { - $default_args = array( - 'width' => '', - 'height' => '', - 'background_color' => 'dddddd', - 'text_color' => '000000', - ); - - $args = wp_parse_args( $args, $default_args ); - - // Extract the vars we want to work with. - $width = $args['width']; - $height = $args['height']; - $background_color = $args['background_color']; - $text_color = $args['text_color']; - - // Perform some quick data validation. - if ( ! is_numeric( $width ) ) { - throw new Exception( esc_html__( 'Width must be an integer', '_s' ) ); - } - - if ( ! is_numeric( $height ) ) { - throw new Exception( esc_html__( 'Height must be an integer', '_s' ) ); - } - - if ( ! ctype_xdigit( $background_color ) ) { - throw new Exception( esc_html__( 'Please provide a valid hex color value for background_color', '_s' ) ); - } - - if ( ! ctype_xdigit( $text_color ) ) { - throw new Exception( esc_html__( 'Please provide a valid hex color value for text_color', '_s' ) ); - } - - // Set up the url to the image. - $url = "http://placeholder.wdslab.com/i/{$width}x$height/$background_color/$text_color"; - - // Text that will be utilized by screen readers. - $alt = apply_filters( '_s_placeholder_image_alt', esc_html__( 'WebDevStudios Placeholder Image', '_s' ) ); - - return "$alt"; -} - /** * Returns an photo from Unsplash.com wrapped in an that can be used * in a theme. There are limited category and search capabilities to attempt From 9e429951a28adc14a0a6f3dbb2f0b15eb9c2869c Mon Sep 17 00:00:00 2001 From: Corey Collins Date: Fri, 26 Oct 2018 13:48:30 -0500 Subject: [PATCH 2/6] =?UTF-8?q?Moves=20the=20header=20and=20footer=20scrip?= =?UTF-8?q?t=20hooks=20into=20hooks=20since=20they=E2=80=99re=20hooks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/extras.php | 41 ----------------------------------------- inc/hooks.php | 46 ++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 42 insertions(+), 45 deletions(-) diff --git a/inc/extras.php b/inc/extras.php index 6e9af6579..2b625e671 100644 --- a/inc/extras.php +++ b/inc/extras.php @@ -137,47 +137,6 @@ function _s_get_placeholder_unsplash( $args = array() ) { return "$alt"; } -/** - * Display the customizer header scripts. - * - * @author Greg Rickaby - * @return string - */ -function _s_display_customizer_header_scripts() { - - // Check for header scripts. - $scripts = get_theme_mod( '_s_header_scripts' ); - - // None? Bail... - if ( ! $scripts ) { - return false; - } - - // Otherwise, echo the scripts! - echo force_balance_tags( $scripts ); // WPCS XSS OK. -} - -/** - * Display the customizer footer scripts. - * - * @author Greg Rickaby - * @return string - */ -function _s_display_customizer_footer_scripts() { - - // Check for footer scripts. - $scripts = get_theme_mod( '_s_footer_scripts' ); - - // None? Bail... - if ( ! $scripts ) { - return false; - } - - // Otherwise, echo the scripts! - echo force_balance_tags( $scripts ); // WPCS XSS OK. -} - - /** * Shortcode to display copyright year. * diff --git a/inc/hooks.php b/inc/hooks.php index a65c22f7f..38e0bdb40 100644 --- a/inc/hooks.php +++ b/inc/hooks.php @@ -126,14 +126,52 @@ function _s_custom_mime_types( $mimes ) { */ add_filter( 'cancel_comment_reply_link', '__return_false' ); -// Additional scripts from Customizer. -add_action( 'wp_head', '_s_display_customizer_header_scripts', 999 ); -add_action( 'wp_footer', '_s_display_customizer_footer_scripts', 999 ); - // Create shortcode for SVG. // Usage [svg icon="facebook-square" title="facebook" desc="like us on facebook" fill="#000000" height="20px" width="20px"]. add_shortcode( 'svg', '_s_display_svg' ); +/** + * Display the customizer header scripts. + * + * @author Greg Rickaby + * @return string + */ +function _s_display_customizer_header_scripts() { + + // Check for header scripts. + $scripts = get_theme_mod( '_s_header_scripts' ); + + // None? Bail... + if ( ! $scripts ) { + return false; + } + + // Otherwise, echo the scripts! + echo force_balance_tags( $scripts ); // WPCS XSS OK. +} +add_action( 'wp_head', '_s_display_customizer_header_scripts', 999 ); + +/** + * Display the customizer footer scripts. + * + * @author Greg Rickaby + * @return string + */ +function _s_display_customizer_footer_scripts() { + + // Check for footer scripts. + $scripts = get_theme_mod( '_s_footer_scripts' ); + + // None? Bail... + if ( ! $scripts ) { + return false; + } + + // Otherwise, echo the scripts! + echo force_balance_tags( $scripts ); // WPCS XSS OK. +} +add_action( 'wp_footer', '_s_display_customizer_footer_scripts', 999 ); + /** * Adds OG tags to the head for better social sharing. * From 28325e5cde95d5e6ff1f12cbd9c26c75a0dd282b Mon Sep 17 00:00:00 2001 From: Corey Collins Date: Fri, 26 Oct 2018 13:50:10 -0500 Subject: [PATCH 3/6] Sets default width and height on the Unsplash template tag, otherwise it fails if no args are provided --- inc/extras.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/inc/extras.php b/inc/extras.php index 2b625e671..8b618b521 100644 --- a/inc/extras.php +++ b/inc/extras.php @@ -82,9 +82,10 @@ function _s_get_attachment_id_from_url( $attachment_url = '' ) { * @return string */ function _s_get_placeholder_unsplash( $args = array() ) { + $default_args = array( - 'width' => '', - 'height' => '', + 'width' => 200, + 'height' => 200, 'category' => '', 'keywords' => '', ); From 940db600f7c06c02e803368e29d8fed70a3c62de Mon Sep 17 00:00:00 2001 From: Corey Collins Date: Fri, 26 Oct 2018 13:54:49 -0500 Subject: [PATCH 4/6] =?UTF-8?q?Moves=20the=20ACF=20color=20picker=20filter?= =?UTF-8?q?=20into=20the=20ACF=20file=20since=20it=E2=80=99s=20ACF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/acf.php | 25 +++++++++++++++++++++++++ inc/extras.php | 25 ------------------------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/inc/acf.php b/inc/acf.php index fc69767bf..78e62a214 100644 --- a/inc/acf.php +++ b/inc/acf.php @@ -368,3 +368,28 @@ function _s_acf_load_color_picker_field_choices( $field ) { return $field; } add_filter( 'acf/load_field/name=color_picker', '_s_acf_load_color_picker_field_choices' ); + +/** + * Get the theme colors for this project. Set these first in the Sass partial then migrate them over here. + * + * @return array The array of our color names and hex values. + * @author Corey Collins + */ +function _s_get_theme_colors() { + return array( + esc_html__( 'Alto', '_s' ) => '#ddd', + esc_html__( 'Black', '_s' ) => '#000', + esc_html__( 'Blue', '_s' ) => '#21759b', + esc_html__( 'Cod Gray', '_s' ) => '#111', + esc_html__( 'Dove Gray', '_s' ) => '#666', + esc_html__( 'Gallery', '_s' ) => '#eee', + esc_html__( 'Gray', '_s' ) => '#808080', + esc_html__( 'Gray Alt', '_s' ) => '#929292', + esc_html__( 'Light Yellow', '_s' ) => '#fff9c0', + esc_html__( 'Mineshaft', '_s' ) => '#333', + esc_html__( 'Silver', '_s' ) => '#ccc', + esc_html__( 'Silver Chalice', '_s' ) => '#aaa', + esc_html__( 'White', '_s' ) => '#fff', + esc_html__( 'Whitesmoke', '_s' ) => '#f1f1f1', + ); +} diff --git a/inc/extras.php b/inc/extras.php index 8b618b521..b2a17e513 100644 --- a/inc/extras.php +++ b/inc/extras.php @@ -166,28 +166,3 @@ function _s_copyright_year( $atts ) { return esc_html( $args['starting_year'] . $args['separator'] . $current_year ); } add_shortcode( '_s_copyright_year', '_s_copyright_year', 15 ); - -/** - * Get the theme colors for this project. Set these first in the Sass partial then migrate them over here. - * - * @return array The array of our color names and hex values. - * @author Corey Collins - */ -function _s_get_theme_colors() { - return array( - esc_html__( 'Alto', '_s' ) => '#ddd', - esc_html__( 'Black', '_s' ) => '#000', - esc_html__( 'Blue', '_s' ) => '#21759b', - esc_html__( 'Cod Gray', '_s' ) => '#111', - esc_html__( 'Dove Gray', '_s' ) => '#666', - esc_html__( 'Gallery', '_s' ) => '#eee', - esc_html__( 'Gray', '_s' ) => '#808080', - esc_html__( 'Gray Alt', '_s' ) => '#929292', - esc_html__( 'Light Yellow', '_s' ) => '#fff9c0', - esc_html__( 'Mineshaft', '_s' ) => '#333', - esc_html__( 'Silver', '_s' ) => '#ccc', - esc_html__( 'Silver Chalice', '_s' ) => '#aaa', - esc_html__( 'White', '_s' ) => '#fff', - esc_html__( 'Whitesmoke', '_s' ) => '#f1f1f1', - ); -} From 13d078b00689e86135eaf4e3a1ac57dde5e818ef Mon Sep 17 00:00:00 2001 From: Corey Collins Date: Fri, 26 Oct 2018 14:01:56 -0500 Subject: [PATCH 5/6] =?UTF-8?q?Removes=20the=20commented=20out=20sidebars?= =?UTF-8?q?=20from=20our=20registration.=20We=20have=20one=20example=20on?= =?UTF-8?q?=20how=20to=20add=20a=20sidebar,=20I=20don=E2=80=99t=20think=20?= =?UTF-8?q?we=20need=20two=20commented=20out=20lines?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- functions.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/functions.php b/functions.php index 237c3b4c6..14ac63970 100644 --- a/functions.php +++ b/functions.php @@ -106,8 +106,6 @@ function _s_widgets_init() { // Define sidebars. $sidebars = array( 'sidebar-1' => esc_html__( 'Sidebar 1', '_s' ), - // 'sidebar-2' => esc_html__( 'Sidebar 2', '_s' ), - // 'sidebar-3' => esc_html__( 'Sidebar 3', '_s' ), ); // Loop through each sidebar and register. From ec035d463d5bb96395dab8ecb418ee3959c2a6c8 Mon Sep 17 00:00:00 2001 From: Corey Collins Date: Fri, 26 Oct 2018 14:04:00 -0500 Subject: [PATCH 6/6] Ignores the nonce verification PHPCS warnings on our debug mode checkers --- inc/scripts.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/scripts.php b/inc/scripts.php index d8ed271a2..008753369 100644 --- a/inc/scripts.php +++ b/inc/scripts.php @@ -51,7 +51,7 @@ function _s_scripts() { /** * If WP is in script debug, or we pass ?script_debug in a URL - set debug to true. */ - $debug = ( defined( 'SCRIPT_DEBUG' ) && true === SCRIPT_DEBUG ) || ( isset( $_GET['script_debug'] ) ) ? true : false; // phpcs:ignore + $debug = ( defined( 'SCRIPT_DEBUG' ) && true === SCRIPT_DEBUG ) || ( isset( $_GET['script_debug'] ) ) ? true : false; // WPCS: CSRF OK. /** * If we are debugging the site, use a unique version every page load so as to ensure no cache issues. @@ -105,7 +105,7 @@ function _s_customizer_scripts() { /** * If WP is in script debug, or we pass ?script_debug in a URL - set debug to true. */ - $debug = ( defined( 'SCRIPT_DEBUG' ) && true === SCRIPT_DEBUG ) || ( isset( $_GET['script_debug'] ) ) ? true : false; // phpcs:ignore + $debug = ( defined( 'SCRIPT_DEBUG' ) && true === SCRIPT_DEBUG ) || ( isset( $_GET['script_debug'] ) ) ? true : false; // WPCS: CSRF OK. /** * If we are debugging the site, use a unique version every page load so as to ensure no cache issues.