Skip to content

Commit

Permalink
phpcs quick fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gregrickaby committed Apr 6, 2018
1 parent 4a7d388 commit 7fa4fb3
Show file tree
Hide file tree
Showing 15 changed files with 63 additions and 44 deletions.
9 changes: 8 additions & 1 deletion inc/acf.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

/**
* Loop through and output ACF flexible content blocks for the current page.
*
* @return bool
*/
function _s_display_content_blocks() {
if ( have_rows( 'content_blocks' ) ) :
Expand Down Expand Up @@ -249,7 +251,12 @@ function _s_acf_flexible_content_layout_title( $title, $field, $layout, $i ) {
$end_date = $other_options['end_date'];

// If the block has expired, add "(expired)" to the title.
if ( _s_has_block_expired( array( 'start_date' => $start_date, 'end_date' => $end_date ) ) ) {
if ( _s_has_block_expired(
array(
'start_date' => $start_date,
'end_date' => $end_date,
) )
) {
$expired .= '<span style="color: red;">&nbsp;(' . esc_html__( 'expired', '_s' ) . ')</span>';
}

Expand Down
2 changes: 1 addition & 1 deletion inc/customizer/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function _s_customize_social_icons( $wp_customize ) {
$wp_customize->add_setting(
'_s_' . $network . '_link',
array(
'default' => '',
'default' => '',
'sanitize_callback' => 'esc_url',
)
);
Expand Down
4 changes: 3 additions & 1 deletion inc/extras.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function _s_get_attachment_id_from_url( $attachment_url = '' ) {
$attachment_url = str_replace( $upload_dir_paths['baseurl'] . '/', '', $attachment_url );

// Do something with $result.
$attachment_id = $wpdb->get_var( $wpdb->prepare( "SELECT wposts.ID FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = '_wp_attached_file' AND wpostmeta.meta_value = '%s' AND wposts.post_type = 'attachment'", $attachment_url ) ); // WPCS: db call ok , cache ok.
$attachment_id = $wpdb->get_var( $wpdb->prepare( "SELECT wposts.ID FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = '_wp_attached_file' AND wpostmeta.meta_value = %s AND wposts.post_type = 'attachment'", $attachment_url ) ); // WPCS db call ok, cache ok, placeholder ok.
}

return $attachment_id;
Expand Down Expand Up @@ -198,6 +198,7 @@ function _s_get_placeholder_unsplash( $args = array() ) {
* Display the customizer header scripts.
*
* @author Greg Rickaby
* @return string
*/
function _s_display_customizer_header_scripts() {

Expand All @@ -217,6 +218,7 @@ function _s_display_customizer_header_scripts() {
* Display the customizer footer scripts.
*
* @author Greg Rickaby
* @return string
*/
function _s_display_customizer_footer_scripts() {

Expand Down
8 changes: 6 additions & 2 deletions inc/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ function _s_body_classes( $classes ) {

/**
* Flush out the transients used in _s_categorized_blog.
*
* @return string
*/
function _s_category_transient_flusher() {
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
Expand All @@ -81,6 +83,8 @@ function _s_category_transient_flusher() {

/**
* Customize "Read More" string on <!-- more --> with the_content();
*
* @return string
*/
function _s_content_more_link() {
return ' <a class="more-link" href="' . get_permalink() . '">' . esc_html__( 'Read More', '_s' ) . '...</a>';
Expand All @@ -91,7 +95,7 @@ function _s_content_more_link() {
* Customize the [...] on the_excerpt();
*
* @param string $more The current $more string.
* @return string Replace with "Read More..."
* @return string
*/
function _s_excerpt_more( $more ) {
return sprintf( ' <a class="more-link" href="%1$s">%2$s</a>', get_permalink( get_the_ID() ), esc_html__( 'Read more...', '_s' ) );
Expand All @@ -102,7 +106,7 @@ function _s_excerpt_more( $more ) {
* Enable custom mime types.
*
* @param array $mimes Current allowed mime types.
* @return array Updated allowed mime types.
* @return array
*/
function _s_custom_mime_types( $mimes ) {
$mimes['svg'] = 'image/svg+xml';
Expand Down
11 changes: 6 additions & 5 deletions inc/scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* Register Google font.
*
* @link http://themeshaper.com/2014/08/13/how-to-add-google-fonts-to-wordpress-themes/
* @return string
*/
function _s_font_url() {

Expand All @@ -19,7 +20,7 @@ function _s_font_url() {
* supported by the following, translate this to 'off'. Do not translate
* into your own language.
*/
$roboto = esc_html_x( 'on', 'Roboto font: on or off', '_s' );
$roboto = esc_html_x( 'on', 'Roboto font: on or off', '_s' );
$open_sans = esc_html_x( 'on', 'Open Sans font: on or off', '_s' );

if ( 'off' !== $roboto || 'off' !== $open_sans ) {
Expand All @@ -34,7 +35,7 @@ function _s_font_url() {
}

$query_args = array(
'family' => urlencode( implode( '|', $font_families ) ),
'family' => rawurlencode( implode( '|', $font_families ) ),
);

$fonts_url = add_query_arg( $query_args, '//fonts.googleapis.com/css' );
Expand All @@ -50,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' ) && SCRIPT_DEBUG == true ) || ( isset( $_GET['script_debug'] ) ) ? true : false;
$debug = ( defined( 'SCRIPT_DEBUG' ) && true === SCRIPT_DEBUG ) || ( isset( $_GET['script_debug'] ) ) ? true : false;

/**
* If we are debugging the site, use a unique version every page load so as to ensure no cache issues.
Expand Down Expand Up @@ -104,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' ) && SCRIPT_DEBUG == true ) || ( isset( $_GET['script_debug'] ) ) ? true : false;
$debug = ( defined( 'SCRIPT_DEBUG' ) && true === SCRIPT_DEBUG ) || ( isset( $_GET['script_debug'] ) ) ? true : false;

/**
* If we are debugging the site, use a unique version every page load so as to ensure no cache issues.
Expand All @@ -130,7 +131,7 @@ function _s_include_svg_icons() {

// If it exists, include it.
if ( file_exists( $svg_icons ) ) {
require_once( $svg_icons );
require_once $svg_icons;
}
}
add_action( 'wp_footer', '_s_include_svg_icons', 9999 );
23 changes: 14 additions & 9 deletions inc/template-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ function _s_entry_footer() {
* Display SVG markup.
*
* @param array $args The parameters needed to display the SVG.
* @return string
*/
function _s_display_svg( $args = array() ) {

Expand Down Expand Up @@ -183,7 +184,7 @@ class="icon icon-<?php echo esc_attr( $args['icon'] ); ?>"
* Trim the title length.
*
* @param array $args Parameters include length and more.
* @return string The shortened excerpt.
* @return string
*/
function _s_get_the_title( $args = array() ) {

Expand All @@ -204,7 +205,7 @@ function _s_get_the_title( $args = array() ) {
* Limit the excerpt length.
*
* @param array $args Parameters include length and more.
* @return string The shortened excerpt.
* @return string
*/
function _s_get_the_excerpt( $args = array() ) {

Expand All @@ -225,13 +226,14 @@ function _s_get_the_excerpt( $args = array() ) {
* Echo an image, no matter what.
*
* @param string $size The image size to display. Default is thumbnail.
* @return string
*/
function _s_display_post_image( $size = 'thumbnail' ) {

// If post has a featured image, display it.
if ( has_post_thumbnail() ) {
the_post_thumbnail( $size );
return;
return false;
}

$attached_image_url = _s_get_attached_image_url( $size );
Expand All @@ -246,7 +248,7 @@ function _s_display_post_image( $size = 'thumbnail' ) {
* Return an image URL, no matter what.
*
* @param string $size The image size to return. Default is thumbnail.
* @return string The image URL.
* @return string
*/
function _s_get_post_image_url( $size = 'thumbnail' ) {

Expand All @@ -269,7 +271,7 @@ function _s_get_post_image_url( $size = 'thumbnail' ) {
* Get the URL of an image that's attached to the current post, else a placeholder image URL.
*
* @param string $size The image size to return. Default is thumbnail.
* @return string The image URL.
* @return string
*/
function _s_get_attached_image_url( $size = 'thumbnail' ) {

Expand All @@ -288,6 +290,8 @@ function _s_get_attached_image_url( $size = 'thumbnail' ) {

/**
* Echo the copyright text saved in the Customizer.
*
* @return bool
*/
function _s_display_copyright_text() {

Expand All @@ -296,7 +300,7 @@ function _s_display_copyright_text() {

// Stop if there's nothing to display.
if ( ! $copyright_text ) {
return;
return false;
}

?>
Expand All @@ -307,7 +311,7 @@ function _s_display_copyright_text() {
/**
* Get the Twitter social sharing URL for the current page.
*
* @return string The URL.
* @return string
*/
function _s_get_twitter_share_url() {
return add_query_arg(
Expand All @@ -321,7 +325,7 @@ function _s_get_twitter_share_url() {
/**
* Get the Facebook social sharing URL for the current page.
*
* @return string The URL.
* @return string
*/
function _s_get_facebook_share_url() {
return add_query_arg( 'u', rawurlencode( get_the_permalink() ), 'https://www.facebook.com/sharer/sharer.php' );
Expand All @@ -330,7 +334,7 @@ function _s_get_facebook_share_url() {
/**
* Get the LinkedIn social sharing URL for the current page.
*
* @return string The URL.
* @return string
*/
function _s_get_linkedin_share_url() {
return add_query_arg(
Expand Down Expand Up @@ -434,6 +438,7 @@ function _s_display_card( $args = array() ) {
* Display header button.
*
* @author Corey Collins
* @return string
*/
function _s_display_header_button() {

Expand Down
8 changes: 4 additions & 4 deletions template-parts/content-blocks/block-cta.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
*/

// Set up fields.
$title = get_sub_field( 'title' );
$text = get_sub_field( 'text' );
$button_url = get_sub_field( 'button_url' );
$button_text = get_sub_field( 'button_text' );
$title = get_sub_field( 'title' );
$text = get_sub_field( 'text' );
$button_url = get_sub_field( 'button_url' );
$button_text = get_sub_field( 'button_text' );
$animation_class = _s_get_animation_class();

// Start a <container> with possible block options.
Expand Down
4 changes: 2 additions & 2 deletions template-parts/content-blocks/block-fifty_media_text.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/

// Set up fields.
$image_data = get_sub_field( 'media_left' );
$text = get_sub_field( 'text_primary' );
$image_data = get_sub_field( 'media_left' );
$text = get_sub_field( 'text_primary' );
$animation_class = _s_get_animation_class();

// Start a <container> with a possible media background.
Expand Down
4 changes: 2 additions & 2 deletions template-parts/content-blocks/block-fifty_text_media.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/

// Set up fields.
$image_data = get_sub_field( 'media_right' );
$text = get_sub_field( 'text_primary' );
$image_data = get_sub_field( 'media_right' );
$text = get_sub_field( 'text_primary' );
$animation_class = _s_get_animation_class();

// Start a <container> with a possible media background.
Expand Down
4 changes: 2 additions & 2 deletions template-parts/content-blocks/block-fifty_text_only.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/

// Set up fields.
$text_primary = get_sub_field( 'text_primary' );
$text_secondary = get_sub_field( 'text_secondary' );
$text_primary = get_sub_field( 'text_primary' );
$text_secondary = get_sub_field( 'text_secondary' );
$animation_class = _s_get_animation_class();

// Start a <container> with a possible media background.
Expand Down
4 changes: 2 additions & 2 deletions template-parts/content-blocks/block-generic_content.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/

// Set up fields.
$title = get_sub_field( 'title' );
$content = get_sub_field( 'content' );
$title = get_sub_field( 'title' );
$content = get_sub_field( 'content' );
$animation_class = _s_get_animation_class();

// Start a <container> with possible block options.
Expand Down
10 changes: 5 additions & 5 deletions template-parts/content-blocks/block-hero.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

// Set up fields.
$hero = get_sub_field( 'hero_slides' );
$hero = get_sub_field( 'hero_slides' );
$slide_count = count( $hero );

// Start repeater markup...
Expand All @@ -26,10 +26,10 @@
the_row();

// Set up fields.
$title = get_sub_field( 'headline' );
$text = get_sub_field( 'text' );
$button_text = get_sub_field( 'button_text' );
$button_url = get_sub_field( 'button_url' );
$title = get_sub_field( 'headline' );
$text = get_sub_field( 'text' );
$button_text = get_sub_field( 'button_text' );
$button_url = get_sub_field( 'button_url' );
$animation_class = _s_get_animation_class();

// Start a <container> with possible block options.
Expand Down
8 changes: 4 additions & 4 deletions template-parts/content-blocks/block-recent_posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
*/

// Set up fields.
$title = get_sub_field( 'title' );
$post_count = get_sub_field( 'number_of_posts' );
$categories = get_sub_field( 'categories' );
$tags = get_sub_field( 'tags' );
$title = get_sub_field( 'title' );
$post_count = get_sub_field( 'number_of_posts' );
$categories = get_sub_field( 'categories' );
$tags = get_sub_field( 'tags' );
$animation_class = _s_get_animation_class();

// Variable to hold query args.
Expand Down
4 changes: 2 additions & 2 deletions template-parts/content-blocks/block-related_posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/

// Set up fields.
$title = get_sub_field( 'title' );
$related_posts = get_sub_field( 'related_posts' );
$title = get_sub_field( 'title' );
$related_posts = get_sub_field( 'related_posts' );
$animation_class = _s_get_animation_class();

// Display section if we have any posts.
Expand Down
4 changes: 2 additions & 2 deletions template-parts/scaffolding/scaffolding-icons.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
'parameters' => array(
'$args' => '(required) Configuration arguments.',
),
'arguments' => array(
'arguments' => array(
'icon' => '(required) The SVG icon file name. Default none',
'title' => '(optional) The title of the icon. Default: none',
'desc' => '(optional) The description of the icon. Default: none',
'fill' => '(optional) The fill color of the icon. Default: none',
'height' => '(optional) The height of the icon. Default: none',
'width' => '(optional) The width of the icon. Default: none',
),
'output' => _s_display_svg( array(
'output' => _s_display_svg( array(
'icon' => 'facebook-square',
) ),
) );
Expand Down

0 comments on commit 7fa4fb3

Please sign in to comment.