From 5158b8fdb713958910b1b26139b4a7eabd2e35dd Mon Sep 17 00:00:00 2001
From: Stefan Kalscheuer
Date: Sat, 9 Dec 2017 11:19:53 +0100
Subject: [PATCH] Code style corrections
---
includes/class-wpliveticker2-admin.php | 13 ++++--
includes/class-wpliveticker2-widget.php | 62 ++++++++++++-------------
includes/class-wpliveticker2.php | 34 +++++++-------
styles/wp-liveticker2.css | 3 +-
views/widget-form.php | 6 ++-
5 files changed, 60 insertions(+), 58 deletions(-)
diff --git a/includes/class-wpliveticker2-admin.php b/includes/class-wpliveticker2-admin.php
index c782d8b..bc8f3f2 100644
--- a/includes/class-wpliveticker2-admin.php
+++ b/includes/class-wpliveticker2-admin.php
@@ -75,21 +75,24 @@ class WPLiveticker2_Admin extends WPLiveticker2 {
__( 'Use AJAX', 'wplt2' ),
array( 'WPLiveticker2_Admin', 'settings_enable_ajax_field' ),
'wplt2-settings-page',
- 'wplt2_settings_general' );
+ 'wplt2_settings_general'
+ );
add_settings_field(
'poll_interval',
__( 'AJAX poll interval', 'wplt2' ),
array( 'WPLiveticker2_Admin', 'settings_poll_interval_field' ),
'wplt2-settings-page',
- 'wplt2_settings_general' );
+ 'wplt2_settings_general'
+ );
add_settings_field(
'enable_css',
__( 'Default CSS Styles', 'wplt2' ),
array( 'WPLiveticker2_Admin', 'settings_enable_css_field' ),
'wplt2-settings-page',
- 'wplt2_settings_general' );
+ 'wplt2_settings_general'
+ );
}
/**
@@ -144,10 +147,10 @@ class WPLiveticker2_Admin extends WPLiveticker2 {
* @return void
*/
public static function settings_poll_interval_field() {
- $pollInterval = self::$_options['poll_interval'];
+ $poll_interval = self::$_options['poll_interval'];
echo '';
echo '' . esc_html__( 'Interval (in seconds) to update ticker if AJAX is enabled.', 'wplt2' ) . '
';
diff --git a/includes/class-wpliveticker2-widget.php b/includes/class-wpliveticker2-widget.php
index 236e3b6..6403c73 100644
--- a/includes/class-wpliveticker2-widget.php
+++ b/includes/class-wpliveticker2-widget.php
@@ -34,7 +34,7 @@ class WPLiveticker2_Widget extends WP_Widget {
* @param array $instance The settings for the particular instance of the widget.
*/
public function widget( $args, $instance ) {
- $instance = self::fill_options_with_defaults( $instance );
+ $instance = self::fill_options_with_defaults( $instance );
$before_widget = isset( $args['before_widget'] ) ? $args['before_widget'] : '';
$after_widget = isset( $args['after_widget'] ) ? $args['after_widget'] : '';
$before_title = isset( $args['before_title'] ) ? $args['before_title'] : '';
@@ -59,45 +59,39 @@ class WPLiveticker2_Widget extends WP_Widget {
echo $before_title . esc_html( $title ) . $after_title;
}
- ?>
- ';
- ' . esc_html__( 'show all', 'wplt2' ) . '...
';
+ echo ''
+ . '' . esc_html__( 'show all', 'wplt2' ) . '...'
+ . '
';
}
// @codingStandardsIgnoreLine
echo $after_widget;
- ?>
- '0',
'ajax' => '0',
);
+
return array_merge( $default, $instance );
}
}
diff --git a/includes/class-wpliveticker2.php b/includes/class-wpliveticker2.php
index 14224ba..2b29115 100644
--- a/includes/class-wpliveticker2.php
+++ b/includes/class-wpliveticker2.php
@@ -179,8 +179,8 @@ class WPLiveticker2 {
$output = '';
}
}// End if().
@@ -259,19 +259,19 @@ class WPLiveticker2 {
*/
public static function ajax_update() {
// TODO: re-enable security checks.
- // check_ajax_referer( 'wplt2_update-ticks' );
+ // check_ajax_referer( 'wplt2_update-ticks' );
// Extract update requests.
if ( isset( $_POST['update'] ) && is_array( $_POST['update'] ) ) {
$res = array();
- foreach ( $_POST['update'] as $updateReq ) {
- if ( isset ( $updateReq['s'] ) ) {
- $slug = $updateReq['s'];
- $limit = ( isset ( $updateReq['l'] ) ) ? intval( $updateReq['l'] ) : - 1;
- $lastPoll = ( isset ( $updateReq['t'] ) ) ? intval( $updateReq['t'] ) : 0;
+ foreach ( wp_unslash( $_POST['update'] ) as $update_req ) {
+ if ( isset( $update_req['s'] ) ) {
+ $slug = $update_req['s'];
+ $limit = ( isset( $update_req['l'] ) ) ? intval( $update_req['l'] ) : - 1;
+ $last_poll = ( isset( $update_req['t'] ) ) ? intval( $update_req['t'] ) : 0;
// Query new ticks from DB.
- $queryArgs = array(
+ $query_args = array(
'post_type' => 'wplt2_tick',
'posts_per_page' => $limit,
'tax_query' => array(
@@ -279,11 +279,11 @@ class WPLiveticker2 {
'taxonomy' => 'wplt2_ticker',
'field' => 'slug',
'terms' => $slug,
- )
- )
+ ),
+ ),
);
- $query = new WP_Query( $queryArgs );
+ $query = new WP_Query( $query_args );
$out = '';
while ( $query->have_posts() ) {
@@ -338,10 +338,10 @@ class WPLiveticker2 {
* @param string $title Tick title.
* @param string $content Tick content.
*/
- private static function tick_html( $time, $title, $content ) {
+ public static function tick_html( $time, $title, $content = null ) {
return '- '
- . '
' . esc_html( $time ) . ''
- . '' . esc_html( $title ) . '
'
- . '' . $content . '
';
+ . '' . esc_html( $time ) . ''
+ . '' . esc_html( $title ) . '
'
+ . '' . $content . '
';
}
}
diff --git a/styles/wp-liveticker2.css b/styles/wp-liveticker2.css
index d26a266..2d4678a 100644
--- a/styles/wp-liveticker2.css
+++ b/styles/wp-liveticker2.css
@@ -2,8 +2,9 @@ ul.wplt2-ticker {
list-style-type: none;
}
-li.wplt2-tick {
+ul.wplt2-ticker > li.wplt2-tick {
background-color: #F5F5F5;
+ list-style-type: none;
margin: 0.1em;
padding: 0.1em 0.3em;
}
diff --git a/views/widget-form.php b/views/widget-form.php
index 777c46e..b51d441 100644
--- a/views/widget-form.php
+++ b/views/widget-form.php
@@ -24,13 +24,15 @@ defined( 'ABSPATH' ) || exit;
|