Code style corrections
This commit is contained in:
parent
c42dd6c8d2
commit
5158b8fdb7
@ -75,21 +75,24 @@ class WPLiveticker2_Admin extends WPLiveticker2 {
|
|||||||
__( 'Use AJAX', 'wplt2' ),
|
__( 'Use AJAX', 'wplt2' ),
|
||||||
array( 'WPLiveticker2_Admin', 'settings_enable_ajax_field' ),
|
array( 'WPLiveticker2_Admin', 'settings_enable_ajax_field' ),
|
||||||
'wplt2-settings-page',
|
'wplt2-settings-page',
|
||||||
'wplt2_settings_general' );
|
'wplt2_settings_general'
|
||||||
|
);
|
||||||
|
|
||||||
add_settings_field(
|
add_settings_field(
|
||||||
'poll_interval',
|
'poll_interval',
|
||||||
__( 'AJAX poll interval', 'wplt2' ),
|
__( 'AJAX poll interval', 'wplt2' ),
|
||||||
array( 'WPLiveticker2_Admin', 'settings_poll_interval_field' ),
|
array( 'WPLiveticker2_Admin', 'settings_poll_interval_field' ),
|
||||||
'wplt2-settings-page',
|
'wplt2-settings-page',
|
||||||
'wplt2_settings_general' );
|
'wplt2_settings_general'
|
||||||
|
);
|
||||||
|
|
||||||
add_settings_field(
|
add_settings_field(
|
||||||
'enable_css',
|
'enable_css',
|
||||||
__( 'Default CSS Styles', 'wplt2' ),
|
__( 'Default CSS Styles', 'wplt2' ),
|
||||||
array( 'WPLiveticker2_Admin', 'settings_enable_css_field' ),
|
array( 'WPLiveticker2_Admin', 'settings_enable_css_field' ),
|
||||||
'wplt2-settings-page',
|
'wplt2-settings-page',
|
||||||
'wplt2_settings_general' );
|
'wplt2_settings_general'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -144,10 +147,10 @@ class WPLiveticker2_Admin extends WPLiveticker2 {
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function settings_poll_interval_field() {
|
public static function settings_poll_interval_field() {
|
||||||
$pollInterval = self::$_options['poll_interval'];
|
$poll_interval = self::$_options['poll_interval'];
|
||||||
|
|
||||||
echo '<label for="' . esc_attr( self::OPTION ) . '[poll_interval]">';
|
echo '<label for="' . esc_attr( self::OPTION ) . '[poll_interval]">';
|
||||||
echo '<input type="number" name="' . esc_attr( self::OPTION ) . '[poll_interval]" value="' . esc_attr( $pollInterval ) . '"/> ';
|
echo '<input type="number" name="' . esc_attr( self::OPTION ) . '[poll_interval]" value="' . esc_attr( $poll_interval ) . '"/> ';
|
||||||
esc_html_e( 'seconds', 'wplt2' );
|
esc_html_e( 'seconds', 'wplt2' );
|
||||||
echo '</label>';
|
echo '</label>';
|
||||||
echo '<p class="description">' . esc_html__( 'Interval (in seconds) to update ticker if AJAX is enabled.', 'wplt2' ) . '</p>';
|
echo '<p class="description">' . esc_html__( 'Interval (in seconds) to update ticker if AJAX is enabled.', 'wplt2' ) . '</p>';
|
||||||
|
@ -34,7 +34,7 @@ class WPLiveticker2_Widget extends WP_Widget {
|
|||||||
* @param array $instance The settings for the particular instance of the widget.
|
* @param array $instance The settings for the particular instance of the widget.
|
||||||
*/
|
*/
|
||||||
public function widget( $args, $instance ) {
|
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'] : '';
|
$before_widget = isset( $args['before_widget'] ) ? $args['before_widget'] : '';
|
||||||
$after_widget = isset( $args['after_widget'] ) ? $args['after_widget'] : '';
|
$after_widget = isset( $args['after_widget'] ) ? $args['after_widget'] : '';
|
||||||
$before_title = isset( $args['before_title'] ) ? $args['before_title'] : '';
|
$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;
|
echo $before_title . esc_html( $title ) . $after_title;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
echo '<ul class="wplt2-widget">';
|
||||||
<ul class="wplt2-widget">
|
|
||||||
<?php
|
$args = array(
|
||||||
$args = array(
|
'post_type' => 'wplt2_tick',
|
||||||
'post_type' => 'wplt2_tick',
|
'tax_query' => array(
|
||||||
'tax_query' => array(
|
array(
|
||||||
array(
|
'taxonomy' => 'wplt2_ticker',
|
||||||
'taxonomy' => 'wplt2_ticker',
|
'field' => 'slug',
|
||||||
'field' => 'slug',
|
'terms' => $category,
|
||||||
'terms' => $category,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
|
);
|
||||||
|
|
||||||
$wp_query = new WP_Query( $args );
|
$wp_query = new WP_Query( $args );
|
||||||
$cnt = 0;
|
$cnt = 0;
|
||||||
while ( $wp_query->have_posts() ) :
|
while ( $wp_query->have_posts() && ( $count <= 0 || ++ $cnt < $count ) ) {
|
||||||
$wp_query->the_post();
|
$wp_query->the_post();
|
||||||
?>
|
echo '<li>'
|
||||||
<li>
|
. '<span class="wplt2-widget-time">' . esc_html( get_the_time( 'd.m.Y - H.i' ) ) . '</span>'
|
||||||
<span class="wplt2-widget-time"><?php echo esc_html( get_the_time( 'd.m.Y - H.i' ) ); ?></span><span class="wplt-widget-content<?php if ( '1' === $highlight && get_the_time( 'U' ) > ( time() - $highlight_time ) ) {
|
. '<span class="wplt-widget-content'
|
||||||
echo '_new';
|
. ( ( '1' === $highlight && get_the_time( 'U' ) > ( time() - $highlight_time ) ) ? '_new' : '' )
|
||||||
} ?>"><br /><?php echo the_title(); ?></span></li>
|
. '"><br>' . the_title() . '</span></li>';
|
||||||
<?php
|
}
|
||||||
if ( $count > 0 && ++ $cnt === $count ) {
|
|
||||||
break;
|
echo '</ul>';
|
||||||
}
|
|
||||||
endwhile;
|
|
||||||
?>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
if ( $link ) {
|
if ( $link ) {
|
||||||
print '<p class="wplt2-widget-link"><a href="' . esc_attr( $link ) . '">' . esc_html__( 'show all', 'wplt2' ) . '...</a></p>';
|
echo '<p class="wplt2-widget-link">'
|
||||||
|
. '<a href="' . esc_attr( $link ) . '">' . esc_html__( 'show all', 'wplt2' ) . '...</a>'
|
||||||
|
. '</p>';
|
||||||
}
|
}
|
||||||
// @codingStandardsIgnoreLine
|
// @codingStandardsIgnoreLine
|
||||||
echo $after_widget;
|
echo $after_widget;
|
||||||
?>
|
|
||||||
<?php
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -116,6 +110,7 @@ class WPLiveticker2_Widget extends WP_Widget {
|
|||||||
* Outputs the settings update form.
|
* Outputs the settings update form.
|
||||||
*
|
*
|
||||||
* @param array $instance Current settings.
|
* @param array $instance Current settings.
|
||||||
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function form( $instance ) {
|
public function form( $instance ) {
|
||||||
@ -149,6 +144,7 @@ class WPLiveticker2_Widget extends WP_Widget {
|
|||||||
'highlight_time' => '0',
|
'highlight_time' => '0',
|
||||||
'ajax' => '0',
|
'ajax' => '0',
|
||||||
);
|
);
|
||||||
|
|
||||||
return array_merge( $default, $instance );
|
return array_merge( $default, $instance );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -179,8 +179,8 @@ class WPLiveticker2 {
|
|||||||
$output = '<ul class="wplt2-ticker';
|
$output = '<ul class="wplt2-ticker';
|
||||||
if ( 1 === self::$_options['enable_ajax'] ) {
|
if ( 1 === self::$_options['enable_ajax'] ) {
|
||||||
$output .= ' wplt2-ticker-ajax" '
|
$output .= ' wplt2-ticker-ajax" '
|
||||||
. 'data-wplt2-ticker="' . $atts['ticker'] . '" '
|
. 'data-wplt2-ticker="' . $atts['ticker'] . '" '
|
||||||
. 'data-wplt2-limit="' . $atts['limit'];
|
. 'data-wplt2-limit="' . $atts['limit'];
|
||||||
}
|
}
|
||||||
$output .= '">';
|
$output .= '">';
|
||||||
|
|
||||||
@ -207,7 +207,7 @@ class WPLiveticker2 {
|
|||||||
|
|
||||||
// Show RSS feed link, if configured.
|
// Show RSS feed link, if configured.
|
||||||
if ( 1 === self::$_options['show_feed'] ) {
|
if ( 1 === self::$_options['show_feed'] ) {
|
||||||
// TODO
|
// TODO.
|
||||||
$output .= '<a href="/feed/liveticker/' . esc_html( $atts['ticker'] ) . '"><img class="wplt2_rss" src="/wp-content/plugins/wp-liveticker2/images/rss.jpg" alt="RSS" /></a>';
|
$output .= '<a href="/feed/liveticker/' . esc_html( $atts['ticker'] ) . '"><img class="wplt2_rss" src="/wp-content/plugins/wp-liveticker2/images/rss.jpg" alt="RSS" /></a>';
|
||||||
}
|
}
|
||||||
}// End if().
|
}// End if().
|
||||||
@ -259,19 +259,19 @@ class WPLiveticker2 {
|
|||||||
*/
|
*/
|
||||||
public static function ajax_update() {
|
public static function ajax_update() {
|
||||||
// TODO: re-enable security checks.
|
// TODO: re-enable security checks.
|
||||||
// check_ajax_referer( 'wplt2_update-ticks' );
|
// check_ajax_referer( 'wplt2_update-ticks' );
|
||||||
|
|
||||||
// Extract update requests.
|
// Extract update requests.
|
||||||
if ( isset( $_POST['update'] ) && is_array( $_POST['update'] ) ) {
|
if ( isset( $_POST['update'] ) && is_array( $_POST['update'] ) ) {
|
||||||
$res = array();
|
$res = array();
|
||||||
foreach ( $_POST['update'] as $updateReq ) {
|
foreach ( wp_unslash( $_POST['update'] ) as $update_req ) {
|
||||||
if ( isset ( $updateReq['s'] ) ) {
|
if ( isset( $update_req['s'] ) ) {
|
||||||
$slug = $updateReq['s'];
|
$slug = $update_req['s'];
|
||||||
$limit = ( isset ( $updateReq['l'] ) ) ? intval( $updateReq['l'] ) : - 1;
|
$limit = ( isset( $update_req['l'] ) ) ? intval( $update_req['l'] ) : - 1;
|
||||||
$lastPoll = ( isset ( $updateReq['t'] ) ) ? intval( $updateReq['t'] ) : 0;
|
$last_poll = ( isset( $update_req['t'] ) ) ? intval( $update_req['t'] ) : 0;
|
||||||
|
|
||||||
// Query new ticks from DB.
|
// Query new ticks from DB.
|
||||||
$queryArgs = array(
|
$query_args = array(
|
||||||
'post_type' => 'wplt2_tick',
|
'post_type' => 'wplt2_tick',
|
||||||
'posts_per_page' => $limit,
|
'posts_per_page' => $limit,
|
||||||
'tax_query' => array(
|
'tax_query' => array(
|
||||||
@ -279,11 +279,11 @@ class WPLiveticker2 {
|
|||||||
'taxonomy' => 'wplt2_ticker',
|
'taxonomy' => 'wplt2_ticker',
|
||||||
'field' => 'slug',
|
'field' => 'slug',
|
||||||
'terms' => $slug,
|
'terms' => $slug,
|
||||||
)
|
),
|
||||||
)
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
$query = new WP_Query( $queryArgs );
|
$query = new WP_Query( $query_args );
|
||||||
|
|
||||||
$out = '';
|
$out = '';
|
||||||
while ( $query->have_posts() ) {
|
while ( $query->have_posts() ) {
|
||||||
@ -338,10 +338,10 @@ class WPLiveticker2 {
|
|||||||
* @param string $title Tick title.
|
* @param string $title Tick title.
|
||||||
* @param string $content Tick content.
|
* @param string $content Tick content.
|
||||||
*/
|
*/
|
||||||
private static function tick_html( $time, $title, $content ) {
|
public static function tick_html( $time, $title, $content = null ) {
|
||||||
return '<li class="wplt2-tick">'
|
return '<li class="wplt2-tick">'
|
||||||
. '<p><span class="wplt2-tick_time">' . esc_html( $time ) . '</span>'
|
. '<p><span class="wplt2-tick_time">' . esc_html( $time ) . '</span>'
|
||||||
. '<span class="wplt2-tick-title">' . esc_html( $title ) . '</span></p>'
|
. '<span class="wplt2-tick-title">' . esc_html( $title ) . '</span></p>'
|
||||||
. '<p class="wplt2-tick-content">' . $content . '</p></li>';
|
. '<p class="wplt2-tick-content">' . $content . '</p></li>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,9 @@ ul.wplt2-ticker {
|
|||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
li.wplt2-tick {
|
ul.wplt2-ticker > li.wplt2-tick {
|
||||||
background-color: #F5F5F5;
|
background-color: #F5F5F5;
|
||||||
|
list-style-type: none;
|
||||||
margin: 0.1em;
|
margin: 0.1em;
|
||||||
padding: 0.1em 0.3em;
|
padding: 0.1em 0.3em;
|
||||||
}
|
}
|
||||||
|
@ -24,13 +24,15 @@ defined( 'ABSPATH' ) || exit;
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select id="<?php echo esc_attr( $this->get_field_id( 'category' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'category' ) ); ?>">
|
<select id="<?php echo esc_attr( $this->get_field_id( 'category' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'category' ) ); ?>">
|
||||||
<?php foreach ( $categories as $cat ) {
|
<?php
|
||||||
|
foreach ( $categories as $cat ) {
|
||||||
echo '<option value="' . esc_attr( $cat->slug ) . '"';
|
echo '<option value="' . esc_attr( $cat->slug ) . '"';
|
||||||
if ( $category === $cat->slug ) {
|
if ( $category === $cat->slug ) {
|
||||||
echo ' selected="selected"';
|
echo ' selected="selected"';
|
||||||
}
|
}
|
||||||
echo '>' . esc_html( $cat->name ) . '</option>';
|
echo '>' . esc_html( $cat->name ) . '</option>';
|
||||||
} ?>
|
}
|
||||||
|
?>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user