ensure php adheres to coding standards according to PHP CodeSniffer / wpcs. closes #326

This commit is contained in:
James Koster 2016-02-25 14:46:06 +00:00
parent 6b136e0251
commit a3ec0358fa
7 changed files with 130 additions and 77 deletions

View file

@ -3,6 +3,7 @@
* Storefront Admin Class * Storefront Admin Class
* *
* @author WooThemes * @author WooThemes
* @package storefront
* @since 2.0.0 * @since 2.0.0
*/ */
@ -11,7 +12,9 @@ if ( ! defined( 'ABSPATH' ) ) {
} }
if ( ! class_exists( 'Storefront_Admin' ) ) : if ( ! class_exists( 'Storefront_Admin' ) ) :
/**
* The Storefront admin class
*/
class Storefront_Admin { class Storefront_Admin {
/** /**
@ -37,7 +40,7 @@ if ( ! class_exists( 'Storefront_Admin' ) ) :
public function activation_admin_notice() { public function activation_admin_notice() {
global $pagenow; global $pagenow;
if ( is_admin() && 'themes.php' == $pagenow && isset( $_GET['activated'] ) ) { // input var okay. if ( is_admin() && 'themes.php' == $pagenow && isset( $_GET['activated'] ) ) { // Input var okay.
add_action( 'admin_notices', array( $this, 'storefront_welcome_admin_notice' ), 99 ); add_action( 'admin_notices', array( $this, 'storefront_welcome_admin_notice' ), 99 );
} }
} }
@ -143,7 +146,7 @@ if ( ! class_exists( 'Storefront_Admin' ) ) :
/** /**
* Get product data from json * Get product data from json
* *
* @param string $url URL to the json file * @param string $url URL to the json file.
* @param string $transient Name the transient. * @param string $transient Name the transient.
* @return [type] [description] * @return [type] [description]
*/ */

View file

@ -36,7 +36,7 @@ $child_themes = $storefront_admin::get_storefront_product_data( 'http://d3t0oe
} }
} }
} else { } else {
echo '<div class="storefront-notice">' . __( 'We\'re currently unable to retrieve these products. Please double check your internet connection or try back later.', 'storefront' ) . '</div>'; echo '<div class="storefront-notice">' . esc_attr__( 'We\'re currently unable to retrieve these products. Please double check your internet connection or try back later.', 'storefront' ) . '</div>';
} }
?> ?>
</ul> </ul>
@ -58,7 +58,7 @@ $child_themes = $storefront_admin::get_storefront_product_data( 'http://d3t0oe
foreach ( $child_theme as $product ) { foreach ( $child_theme as $product ) {
$price = $product->price; $price = $product->price;
if ( $price == '&#36;0.00' ) { if ( '&#36;0.00' == $price ) {
$price = __( 'Free!', 'storefront' ); $price = __( 'Free!', 'storefront' );
} }
@ -71,14 +71,14 @@ $child_themes = $storefront_admin::get_storefront_product_data( 'http://d3t0oe
<a href="<?php echo esc_url( $link ); ?>"> <a href="<?php echo esc_url( $link ); ?>">
<img src="<?php echo esc_url( $image ); ?>" alt="<?php echo esc_attr( $title ); ?>" /> <img src="<?php echo esc_url( $image ); ?>" alt="<?php echo esc_attr( $title ); ?>" />
<span class="child-theme-title"><?php echo esc_attr( $title ); ?></span> <span class="child-theme-title"><?php echo esc_attr( $title ); ?></span>
<span class="price"><?php echo $price; ?></span> <span class="price"><?php echo esc_attr( $price ); ?></span>
</a> </a>
</div> </div>
<?php <?php
} }
} }
} else { } else {
echo '<div class="storefront-notice">' . __( 'We\'re currently unable to retrieve these products. Please double check your internet connection or try back later.', 'storefront' ) . '</div>'; echo '<div class="storefront-notice">' . esc_attr__( 'We\'re currently unable to retrieve these products. Please double check your internet connection or try back later.', 'storefront' ) . '</div>';
} }
?> ?>
<div class="more-button"> <div class="more-button">

View file

@ -1,9 +1,32 @@
<?php <?php
/** /**
* Class to create a custom arbitrary html control for dividers etc * Class to create a custom arbitrary html control for dividers etc
*
* @author WooThemes
* @package storefront
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* The arbitrary control class
*/ */
class Arbitrary_Storefront_Control extends WP_Customize_Control { class Arbitrary_Storefront_Control extends WP_Customize_Control {
/**
* The settings var
*
* @var string $settings the blog name.
*/
public $settings = 'blogname'; public $settings = 'blogname';
/**
* The description var
*
* @var string $description the control description.
*/
public $description = ''; public $description = '';
/** /**

View file

@ -1,12 +1,23 @@
<?php <?php
/** /**
* Class to create a Customizer control for displaying information * Class to create a Customizer control for displaying information
*
* @author WooThemes
* @package storefront
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* The 'more' Storefront control class
*/ */
class More_Storefront_Control extends WP_Customize_Control { class More_Storefront_Control extends WP_Customize_Control {
/** /**
* Render the content on the theme customizer page * Render the content on the theme customizer page
*/ */
public function render_content() { public function render_content() {
?> ?>
<label style="overflow: hidden; zoom: 1;"> <label style="overflow: hidden; zoom: 1;">

View file

@ -10,6 +10,15 @@
* *
* @link https://github.com/reduxframework/kirki/ * @link https://github.com/reduxframework/kirki/
* @link http://ottopress.com/2012/making-a-custom-control-for-the-theme-customizer/ * @link http://ottopress.com/2012/making-a-custom-control-for-the-theme-customizer/
* @package storefront
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* The radio image class.
*/ */
class Storefront_Custom_Radio_Image_Control extends WP_Customize_Control { class Storefront_Custom_Radio_Image_Control extends WP_Customize_Control {

View file

@ -114,6 +114,7 @@ function storefront_adjust_color_brightness( $hex, $steps ) {
* Checks that the input matches one of the available choices * Checks that the input matches one of the available choices
* *
* @param array $input the available choices. * @param array $input the available choices.
* @param array $setting the setting object.
* @since 1.3.0 * @since 1.3.0
*/ */
function storefront_sanitize_choices( $input, $setting ) { function storefront_sanitize_choices( $input, $setting ) {

View file

@ -23,7 +23,7 @@ if ( ! function_exists( 'storefront_html_tag_schema' ) ) {
/** /**
* Schema type * Schema type
* *
* @return string schema itemprop type * @return void
*/ */
function storefront_html_tag_schema() { function storefront_html_tag_schema() {
$schema = 'http://schema.org/'; $schema = 'http://schema.org/';
@ -31,13 +31,9 @@ if ( ! function_exists( 'storefront_html_tag_schema' ) ) {
if ( is_singular( 'post' ) ) { if ( is_singular( 'post' ) ) {
$type = 'Article'; $type = 'Article';
} } elseif ( is_author() ) {
elseif ( is_author() ) {
$type = 'ProfilePage'; $type = 'ProfilePage';
} } elseif ( is_search() ) {
elseif ( is_search() ) {
$type = 'SearchResultsPage'; $type = 'SearchResultsPage';
} }
@ -50,6 +46,8 @@ if ( ! function_exists( 'storefront_comment' ) ) {
* Storefront comment template * Storefront comment template
* *
* @param array $comment the comment array. * @param array $comment the comment array.
* @param array $args the comment args.
* @param int $depth the comment depth.
* @since 1.0.0 * @since 1.0.0
*/ */
function storefront_comment( $comment, $args, $depth ) { function storefront_comment( $comment, $args, $depth ) {
@ -119,17 +117,18 @@ if ( ! function_exists( 'storefront_footer_widgets' ) ) {
<section class="footer-widgets col-<?php echo intval( $widget_columns ); ?> fix"> <section class="footer-widgets col-<?php echo intval( $widget_columns ); ?> fix">
<?php $i = 0; while ( $i < $widget_columns ) : $i++; ?> <?php
$i = 0;
while ( $i < $widget_columns ) : $i++;
<?php if ( is_active_sidebar( 'footer-' . $i ) ) : ?> if ( is_active_sidebar( 'footer-' . $i ) ) : ?>
<section class="block footer-widget-<?php echo intval( $i ); ?>"> <section class="block footer-widget-<?php echo intval( $i ); ?>">
<?php dynamic_sidebar( 'footer-' . intval( $i ) ); ?> <?php dynamic_sidebar( 'footer-' . intval( $i ) ); ?>
</section> </section>
<?php endif; ?> <?php endif;
endwhile; ?>
<?php endwhile; ?>
</section><!-- /.footer-widgets --> </section><!-- /.footer-widgets -->
@ -180,17 +179,17 @@ if ( ! function_exists( 'storefront_footer_widgets' ) ) {
<section class="footer-widgets col-<?php echo intval( $widget_columns ); ?> fix"> <section class="footer-widgets col-<?php echo intval( $widget_columns ); ?> fix">
<?php $i = 0; while ( $i < $widget_columns ) : $i++; ?> <?php
$i = 0;
<?php if ( is_active_sidebar( 'footer-' . $i ) ) : ?> while ( $i < $widget_columns ) : $i++;
if ( is_active_sidebar( 'footer-' . $i ) ) : ?>
<section class="block footer-widget-<?php echo intval( $i ); ?>"> <section class="block footer-widget-<?php echo intval( $i ); ?>">
<?php dynamic_sidebar( 'footer-' . intval( $i ) ); ?> <?php dynamic_sidebar( 'footer-' . intval( $i ) ); ?>
</section> </section>
<?php endif; ?> <?php endif;
endwhile; ?>
<?php endwhile; ?>
</section><!-- /.footer-widgets --> </section><!-- /.footer-widgets -->
@ -297,7 +296,7 @@ if ( ! function_exists( 'storefront_secondary_navigation' ) ) {
*/ */
function storefront_secondary_navigation() { function storefront_secondary_navigation() {
?> ?>
<nav class="secondary-navigation" role="navigation" aria-label="<?php _e( 'Secondary Navigation', 'storefront' ); ?>"> <nav class="secondary-navigation" role="navigation" aria-label="<?php esc_html_e( 'Secondary Navigation', 'storefront' ); ?>">
<?php <?php
wp_nav_menu( wp_nav_menu(
array( array(
@ -371,7 +370,8 @@ if ( ! function_exists( 'storefront_post_header' ) ) {
* *
* @since 1.0.0 * @since 1.0.0
*/ */
function storefront_post_header() { ?> function storefront_post_header() {
?>
<header class="entry-header"> <header class="entry-header">
<?php <?php
if ( is_single() ) { if ( is_single() ) {
@ -541,7 +541,7 @@ if ( ! function_exists( 'storefront_posted_on' ) ) {
'itemprop' => array(), 'itemprop' => array(),
'class' => array(), 'class' => array(),
), ),
) ); ) );
} }
} }
@ -551,6 +551,7 @@ if ( ! function_exists( 'storefront_product_categories' ) ) {
* Hooked into the `homepage` action in the homepage template * Hooked into the `homepage` action in the homepage template
* *
* @since 1.0.0 * @since 1.0.0
* @param array $args the product section args.
* @return void * @return void
*/ */
function storefront_product_categories( $args ) { function storefront_product_categories( $args ) {
@ -567,20 +568,20 @@ if ( ! function_exists( 'storefront_product_categories' ) ) {
echo '<section class="storefront-product-section storefront-product-categories">'; echo '<section class="storefront-product-section storefront-product-categories">';
do_action( 'storefront_homepage_before_product_categories' ); do_action( 'storefront_homepage_before_product_categories' );
echo '<h2 class="section-title">' . wp_kses_post( $args['title'] ) . '</h2>'; echo '<h2 class="section-title">' . wp_kses_post( $args['title'] ) . '</h2>';
do_action( 'storefront_homepage_after_product_categories_title' ); do_action( 'storefront_homepage_after_product_categories_title' );
echo storefront_do_shortcode( 'product_categories', array( echo storefront_do_shortcode( 'product_categories', array(
'number' => intval( $args['limit'] ), 'number' => intval( $args['limit'] ),
'columns' => intval( $args['columns'] ), 'columns' => intval( $args['columns'] ),
'orderby' => esc_attr( $args['orderby'] ), 'orderby' => esc_attr( $args['orderby'] ),
'parent' => esc_attr( $args['child_categories'] ), 'parent' => esc_attr( $args['child_categories'] ),
) ); ) );
do_action( 'storefront_homepage_after_product_categories' ); do_action( 'storefront_homepage_after_product_categories' );
echo '</section>'; echo '</section>';
} }
@ -593,6 +594,7 @@ if ( ! function_exists( 'storefront_recent_products' ) ) {
* Hooked into the `homepage` action in the homepage template * Hooked into the `homepage` action in the homepage template
* *
* @since 1.0.0 * @since 1.0.0
* @param array $args the product section args.
* @return void * @return void
*/ */
function storefront_recent_products( $args ) { function storefront_recent_products( $args ) {
@ -607,18 +609,18 @@ if ( ! function_exists( 'storefront_recent_products' ) ) {
echo '<section class="storefront-product-section storefront-recent-products">'; echo '<section class="storefront-product-section storefront-recent-products">';
do_action( 'storefront_homepage_before_recent_products' ); do_action( 'storefront_homepage_before_recent_products' );
echo '<h2 class="section-title">' . wp_kses_post( $args['title'] ) . '</h2>'; echo '<h2 class="section-title">' . wp_kses_post( $args['title'] ) . '</h2>';
do_action( 'storefront_homepage_after_recent_products_title' ); do_action( 'storefront_homepage_after_recent_products_title' );
echo storefront_do_shortcode( 'recent_products', array( echo storefront_do_shortcode( 'recent_products', array(
'per_page' => intval( $args['limit'] ), 'per_page' => intval( $args['limit'] ),
'columns' => intval( $args['columns'] ), 'columns' => intval( $args['columns'] ),
) ); ) );
do_action( 'storefront_homepage_after_recent_products' ); do_action( 'storefront_homepage_after_recent_products' );
echo '</section>'; echo '</section>';
} }
@ -631,6 +633,7 @@ if ( ! function_exists( 'storefront_featured_products' ) ) {
* Hooked into the `homepage` action in the homepage template * Hooked into the `homepage` action in the homepage template
* *
* @since 1.0.0 * @since 1.0.0
* @param array $args the product section args.
* @return void * @return void
*/ */
function storefront_featured_products( $args ) { function storefront_featured_products( $args ) {
@ -647,20 +650,20 @@ if ( ! function_exists( 'storefront_featured_products' ) ) {
echo '<section class="storefront-product-section storefront-featured-products">'; echo '<section class="storefront-product-section storefront-featured-products">';
do_action( 'storefront_homepage_before_featured_products' ); do_action( 'storefront_homepage_before_featured_products' );
echo '<h2 class="section-title">' . wp_kses_post( $args['title'] ) . '</h2>'; echo '<h2 class="section-title">' . wp_kses_post( $args['title'] ) . '</h2>';
do_action( 'storefront_homepage_after_featured_products_title' ); do_action( 'storefront_homepage_after_featured_products_title' );
echo storefront_do_shortcode( 'featured_products', array( echo storefront_do_shortcode( 'featured_products', array(
'per_page' => intval( $args['limit'] ), 'per_page' => intval( $args['limit'] ),
'columns' => intval( $args['columns'] ), 'columns' => intval( $args['columns'] ),
'orderby' => esc_attr( $args['orderby'] ), 'orderby' => esc_attr( $args['orderby'] ),
'order' => esc_attr( $args['order'] ), 'order' => esc_attr( $args['order'] ),
) ); ) );
do_action( 'storefront_homepage_after_featured_products' ); do_action( 'storefront_homepage_after_featured_products' );
echo '</section>'; echo '</section>';
} }
@ -673,6 +676,7 @@ if ( ! function_exists( 'storefront_popular_products' ) ) {
* Hooked into the `homepage` action in the homepage template * Hooked into the `homepage` action in the homepage template
* *
* @since 1.0.0 * @since 1.0.0
* @param array $args the product section args.
* @return void * @return void
*/ */
function storefront_popular_products( $args ) { function storefront_popular_products( $args ) {
@ -687,18 +691,18 @@ if ( ! function_exists( 'storefront_popular_products' ) ) {
echo '<section class="storefront-product-section storefront-popular-products">'; echo '<section class="storefront-product-section storefront-popular-products">';
do_action( 'storefront_homepage_before_popular_products' ); do_action( 'storefront_homepage_before_popular_products' );
echo '<h2 class="section-title">' . wp_kses_post( $args['title'] ) . '</h2>'; echo '<h2 class="section-title">' . wp_kses_post( $args['title'] ) . '</h2>';
do_action( 'storefront_homepage_after_popular_products_title' ); do_action( 'storefront_homepage_after_popular_products_title' );
echo storefront_do_shortcode( 'top_rated_products', array( echo storefront_do_shortcode( 'top_rated_products', array(
'per_page' => intval( $args['limit'] ), 'per_page' => intval( $args['limit'] ),
'columns' => intval( $args['columns'] ), 'columns' => intval( $args['columns'] ),
) ); ) );
do_action( 'storefront_homepage_after_popular_products' ); do_action( 'storefront_homepage_after_popular_products' );
echo '</section>'; echo '</section>';
} }
@ -709,6 +713,8 @@ if ( ! function_exists( 'storefront_on_sale_products' ) ) {
/** /**
* Display On Sale Products * Display On Sale Products
* Hooked into the `homepage` action in the homepage template * Hooked into the `homepage` action in the homepage template
*
* @param array $args the product section args.
* @since 1.0.0 * @since 1.0.0
* @return void * @return void
*/ */
@ -724,18 +730,18 @@ if ( ! function_exists( 'storefront_on_sale_products' ) ) {
echo '<section class="storefront-product-section storefront-on-sale-products">'; echo '<section class="storefront-product-section storefront-on-sale-products">';
do_action( 'storefront_homepage_before_on_sale_products' ); do_action( 'storefront_homepage_before_on_sale_products' );
echo '<h2 class="section-title">' . wp_kses_post( $args['title'] ) . '</h2>'; echo '<h2 class="section-title">' . wp_kses_post( $args['title'] ) . '</h2>';
do_action( 'storefront_homepage_after_on_sale_products_title' ); do_action( 'storefront_homepage_after_on_sale_products_title' );
echo storefront_do_shortcode( 'sale_products', array( echo storefront_do_shortcode( 'sale_products', array(
'per_page' => intval( $args['limit'] ), 'per_page' => intval( $args['limit'] ),
'columns' => intval( $args['columns'] ), 'columns' => intval( $args['columns'] ),
) ); ) );
do_action( 'storefront_homepage_after_on_sale_products' ); do_action( 'storefront_homepage_after_on_sale_products' );
echo '</section>'; echo '</section>';
} }