Code style corrections
This commit is contained in:
parent
c42dd6c8d2
commit
5158b8fdb7
@ -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 '<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' );
|
||||
echo '</label>';
|
||||
echo '<p class="description">' . esc_html__( 'Interval (in seconds) to update ticker if AJAX is enabled.', 'wplt2' ) . '</p>';
|
||||
|
@ -59,9 +59,8 @@ class WPLiveticker2_Widget extends WP_Widget {
|
||||
echo $before_title . esc_html( $title ) . $after_title;
|
||||
}
|
||||
|
||||
?>
|
||||
<ul class="wplt2-widget">
|
||||
<?php
|
||||
echo '<ul class="wplt2-widget">';
|
||||
|
||||
$args = array(
|
||||
'post_type' => 'wplt2_tick',
|
||||
'tax_query' => array(
|
||||
@ -75,29 +74,24 @@ class WPLiveticker2_Widget extends WP_Widget {
|
||||
|
||||
$wp_query = new WP_Query( $args );
|
||||
$cnt = 0;
|
||||
while ( $wp_query->have_posts() ) :
|
||||
while ( $wp_query->have_posts() && ( $count <= 0 || ++ $cnt < $count ) ) {
|
||||
$wp_query->the_post();
|
||||
?>
|
||||
<li>
|
||||
<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 ) ) {
|
||||
echo '_new';
|
||||
} ?>"><br /><?php echo the_title(); ?></span></li>
|
||||
<?php
|
||||
if ( $count > 0 && ++ $cnt === $count ) {
|
||||
break;
|
||||
echo '<li>'
|
||||
. '<span class="wplt2-widget-time">' . esc_html( get_the_time( 'd.m.Y - H.i' ) ) . '</span>'
|
||||
. '<span class="wplt-widget-content'
|
||||
. ( ( '1' === $highlight && get_the_time( 'U' ) > ( time() - $highlight_time ) ) ? '_new' : '' )
|
||||
. '"><br>' . the_title() . '</span></li>';
|
||||
}
|
||||
endwhile;
|
||||
?>
|
||||
</ul>
|
||||
|
||||
<?php
|
||||
echo '</ul>';
|
||||
|
||||
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
|
||||
echo $after_widget;
|
||||
?>
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
@ -116,6 +110,7 @@ class WPLiveticker2_Widget extends WP_Widget {
|
||||
* Outputs the settings update form.
|
||||
*
|
||||
* @param array $instance Current settings.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function form( $instance ) {
|
||||
@ -149,6 +144,7 @@ class WPLiveticker2_Widget extends WP_Widget {
|
||||
'highlight_time' => '0',
|
||||
'ajax' => '0',
|
||||
);
|
||||
|
||||
return array_merge( $default, $instance );
|
||||
}
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ class WPLiveticker2 {
|
||||
|
||||
// Show RSS feed link, if configured.
|
||||
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>';
|
||||
}
|
||||
}// End if().
|
||||
@ -264,14 +264,14 @@ class WPLiveticker2 {
|
||||
// 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,7 +338,7 @@ 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 '<li class="wplt2-tick">'
|
||||
. '<p><span class="wplt2-tick_time">' . esc_html( $time ) . '</span>'
|
||||
. '<span class="wplt2-tick-title">' . esc_html( $title ) . '</span></p>'
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -24,13 +24,15 @@ defined( 'ABSPATH' ) || exit;
|
||||
</td>
|
||||
<td>
|
||||
<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 ) . '"';
|
||||
if ( $category === $cat->slug ) {
|
||||
echo ' selected="selected"';
|
||||
}
|
||||
echo '>' . esc_html( $cat->name ) . '</option>';
|
||||
} ?>
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
Loading…
x
Reference in New Issue
Block a user