lightspeeddevelopment /
lsx
| 1 | <?php |
||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 2 | |||
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
||
|
0 ignored issues
–
show
|
|||
| 4 | exit; |
||
| 5 | } |
||
| 6 | |||
| 7 | /** |
||
| 8 | * Recent Reviews Widget. |
||
| 9 | * |
||
| 10 | * @author WooThemes |
||
| 11 | * @category Widgets |
||
| 12 | * @package WooCommerce/Widgets |
||
| 13 | * @version 2.3.0 |
||
| 14 | * @extends WC_Widget |
||
| 15 | */ |
||
| 16 | class LSX_WC_Widget_Recent_Reviews extends WC_Widget { |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Constructor. |
||
| 20 | */ |
||
| 21 | public function __construct() { |
||
|
0 ignored issues
–
show
|
|||
| 22 | $this->widget_cssclass = 'woocommerce widget_recent_reviews'; |
||
| 23 | $this->widget_description = __( 'Display a list of your most recent reviews on your site.', 'lsx' ); |
||
| 24 | $this->widget_id = 'woocommerce_recent_reviews'; |
||
| 25 | $this->widget_name = __( 'WooCommerce recent reviews', 'lsx' ); |
||
| 26 | $this->settings = array( |
||
| 27 | 'title' => array( |
||
| 28 | 'type' => 'text', |
||
| 29 | 'std' => __( 'Recent reviews', 'lsx' ), |
||
| 30 | 'label' => __( 'Title', 'lsx' ), |
||
| 31 | ), |
||
| 32 | 'number' => array( |
||
| 33 | 'type' => 'number', |
||
| 34 | 'step' => 1, |
||
| 35 | 'min' => 1, |
||
| 36 | 'max' => '', |
||
| 37 | 'std' => 10, |
||
| 38 | 'label' => __( 'Number of reviews to show', 'lsx' ), |
||
| 39 | ), |
||
| 40 | ); |
||
| 41 | |||
| 42 | parent::__construct(); |
||
| 43 | } |
||
|
0 ignored issues
–
show
|
|||
| 44 | |||
| 45 | /** |
||
| 46 | * Output widget. |
||
| 47 | * |
||
| 48 | * @see WP_Widget |
||
| 49 | * |
||
| 50 | * @param array $args |
||
|
0 ignored issues
–
show
|
|||
| 51 | * @param array $instance |
||
|
0 ignored issues
–
show
|
|||
| 52 | */ |
||
| 53 | public function widget( $args, $instance ) { |
||
| 54 | if ( $this->get_cached_widget( $args ) ) { |
||
|
0 ignored issues
–
show
|
|||
| 55 | return; |
||
| 56 | } |
||
|
0 ignored issues
–
show
|
|||
| 57 | ob_start(); |
||
| 58 | $number = ! empty( $instance['number'] ) ? absint( $instance['number'] ) : $this->settings['number']['std']; |
||
| 59 | $comments = get_comments( |
||
| 60 | array( |
||
| 61 | 'number' => $number, |
||
| 62 | 'status' => 'approve', |
||
| 63 | 'post_status' => 'publish', |
||
| 64 | 'post_type' => 'product', |
||
| 65 | 'parent' => 0, |
||
| 66 | ) |
||
| 67 | ); |
||
| 68 | |||
| 69 | if ( $comments ) { |
||
|
0 ignored issues
–
show
|
|||
| 70 | $this->widget_start( $args, $instance ); |
||
| 71 | |||
| 72 | echo wp_kses_post( apply_filters( 'woocommerce_before_widget_product_list', '<ul class="product_list_widget">' ) ); |
||
| 73 | |||
| 74 | global $stored_comment, $_product, $rating; |
||
| 75 | |||
| 76 | the_comment(); |
||
| 77 | foreach ( (array) $comments as $comment ) { |
||
|
0 ignored issues
–
show
|
|||
| 78 | $_product = wc_get_product( $comment->comment_post_ID ); |
||
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 7 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. Loading history...
|
|||
| 79 | $rating = intval( get_comment_meta( $comment->comment_ID, 'rating', true ) ); |
||
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 9 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. Loading history...
|
|||
| 80 | $stored_comment = $comment; |
||
| 81 | |||
| 82 | wc_get_template( 'content-widget-review.php' ); |
||
| 83 | } |
||
| 84 | |||
| 85 | echo wp_kses_post( apply_filters( 'woocommerce_after_widget_product_list', '</ul>' ) ); |
||
| 86 | |||
| 87 | $this->widget_end( $args ); |
||
| 88 | } |
||
|
0 ignored issues
–
show
|
|||
| 89 | $content = ob_get_clean(); |
||
| 90 | echo wp_kses_post( $content ); |
||
| 91 | $this->cache_widget( $args, $content ); |
||
| 92 | } |
||
|
0 ignored issues
–
show
|
|||
| 93 | } |
||
| 94 |