From 3f68ac5b8d2a92756a58b234d5e1c9058034d73d Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Sun, 29 May 2016 20:45:38 -0400 Subject: [PATCH] Update for PHP CodeSniffer request --- index.php | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/index.php b/index.php index 9188b49..7786dc5 100644 --- a/index.php +++ b/index.php @@ -176,10 +176,10 @@ function miproduct_related_products() { */ function miproduct_save_meta() { global $post; - if ( !wp_verify_nonce( $_POST['miproductmeta-meta-noncename'], 'miproductmeta-meta-noncename' ) ) { + if ( ! wp_verify_nonce( $_POST['miproductmeta-meta-noncename'], 'miproductmeta-meta-noncename' ) ) { return $post->ID; } - if ( !current_user_can( 'edit_post', $post->ID ) ) { + if ( ! current_user_can( 'edit_post', $post->ID ) ) { return $post->ID; } $features = filter_var( $_POST['miproduct_features'], FILTER_SANITIZE_STRING ); @@ -422,9 +422,9 @@ function michsci_admin_custom_columns( $column ) { * Add shortcode function. This will call the correct function based on the * front end search. * - * @param mixed $atts + * @param mixed $atts Attribute array. * @access public - * @return void + * @return type */ function michsci_shortcode( $atts ) { extract( shortcode_atts( array( 'limit' => '10' ), $atts ) ); @@ -438,7 +438,7 @@ function michsci_shortcode( $atts ) { $cat_id = $product_category->term_id; } } - $term = get_term_by( 'id', $_REQUEST[ MICHSCI_CATEGORY_NAME ],'michsci_category' ); + $term = get_term_by( 'id', $_REQUEST[ MICHSCI_CATEGORY_NAME ], 'michsci_category' ); $name = $term->name; if ( ! $name ) { @@ -557,6 +557,7 @@ function michsci_get_terms_dropdown( $cat_id ) { function michsci_list_products( $text_query ) { global $wpdb, $wp; + // TODO: $cat_id is not initialized! $cat = get_term( $cat_id, MICHSCI_CATEGORY_NAME ); $args = array( 'posts_per_page' => -1, @@ -579,10 +580,10 @@ function michsci_list_products( $text_query ) { ); } - $products = get_posts( $args ); + $products = get_posts( $args ); $total_products = count( $products ); - $current_url = esc_url( add_query_arg( $wp->query_string, '', home_url( $wp->request ) ) ); - $iterator = 1; + $current_url = esc_url( add_query_arg( $wp->query_string, '', home_url( $wp->request ) ) ); + $iterator = 1; foreach ( $products as $product ) { $product_terms = wp_get_post_terms( $product->ID, MICHSCI_CATEGORY_NAME, 'name' ); @@ -606,7 +607,7 @@ function michsci_list_products( $text_query ) { * * Create a list of categories. * - * @param bool $cat_id Category id. + * @param bool $cat_id Parent Category to Display. * * @access public * @return void @@ -675,8 +676,8 @@ function michsci_show_category( $cat_id ) { $term = get_terms( MICHSCI_CATEGORY_NAME, array( - 'child_of' => $cat_id, - 'hide_empty' => true, + 'child_of' => $cat_id, + 'hide_empty' => true, ) ); include 'views/category_detail.php'; -- 2.17.1