add optional shortcode support for tick content (#18) (#19)
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
If the new option is enabled, tick content will be piped through do_shortcode() to parse nested shortcode content. Disabled by default as it is not necessary in most cases.
This commit is contained in:
parent
109efd341b
commit
f50dfe92c7
@ -85,6 +85,7 @@ caching time of 12 hours obviously makes no sense.
|
|||||||
* Requires WordPress 4.7 or above
|
* Requires WordPress 4.7 or above
|
||||||
* Migrated AJAX to REST API
|
* Migrated AJAX to REST API
|
||||||
* Resolved Javascript compatibility issues with IE11
|
* Resolved Javascript compatibility issues with IE11
|
||||||
|
* Added optional shortcode support for tick content
|
||||||
|
|
||||||
### 1.1.1 - 2021-03-20
|
### 1.1.1 - 2021-03-20
|
||||||
|
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 52 KiB |
@ -107,6 +107,15 @@ class Admin extends SCLiveticker {
|
|||||||
'scliveticker_settings_general',
|
'scliveticker_settings_general',
|
||||||
array( 'label_for' => esc_attr( self::OPTION ) . '-show-feed' )
|
array( 'label_for' => esc_attr( self::OPTION ) . '-show-feed' )
|
||||||
);
|
);
|
||||||
|
|
||||||
|
add_settings_field(
|
||||||
|
'enable_shortcode',
|
||||||
|
__( 'Shortcode support', 'stklcode-liveticker' ),
|
||||||
|
array( __CLASS__, 'settings_enable_shortcode_field' ),
|
||||||
|
'scliveticker-settings-page',
|
||||||
|
'scliveticker_settings_general',
|
||||||
|
array( 'label_for' => esc_attr( self::OPTION ) . '-enable-shortcode' )
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -178,6 +187,21 @@ class Admin extends SCLiveticker {
|
|||||||
echo '<p class="description">' . esc_html__( 'Can be overwritten in shortcode.', 'stklcode-liveticker' ) . '</p>';
|
echo '<p class="description">' . esc_html__( 'Can be overwritten in shortcode.', 'stklcode-liveticker' ) . '</p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render enable css field.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.2
|
||||||
|
*/
|
||||||
|
public static function settings_enable_shortcode_field() {
|
||||||
|
$checked = self::$options['enable_shortcode'];
|
||||||
|
|
||||||
|
echo '<input id="' . esc_attr( self::OPTION ) . '-enable-shortcode" type="checkbox" name="' . esc_attr( self::OPTION ) . '[enable_shortcode]" value="1" ' . checked( $checked, 1, false ) . ' /> ';
|
||||||
|
esc_html_e( 'Enable', 'stklcode-liveticker' );
|
||||||
|
echo '<p class="description">' . esc_html__( 'Enable shortcode processing in tick content.', 'stklcode-liveticker' ) . '</p>';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render the settings page.
|
* Render the settings page.
|
||||||
*
|
*
|
||||||
@ -201,6 +225,7 @@ class Admin extends SCLiveticker {
|
|||||||
$result['poll_interval'] = isset( $input['poll_interval'] ) ? intval( $input['poll_interval'] ) : $defaults['poll_interval'];
|
$result['poll_interval'] = isset( $input['poll_interval'] ) ? intval( $input['poll_interval'] ) : $defaults['poll_interval'];
|
||||||
$result['enable_css'] = isset( $input['enable_css'] ) ? intval( $input['enable_css'] ) : 0;
|
$result['enable_css'] = isset( $input['enable_css'] ) ? intval( $input['enable_css'] ) : 0;
|
||||||
$result['show_feed'] = isset( $input['show_feed'] ) ? intval( $input['show_feed'] ) : 0;
|
$result['show_feed'] = isset( $input['show_feed'] ) ? intval( $input['show_feed'] ) : 0;
|
||||||
|
$result['enable_shortcode'] = isset( $input['enable_shortcode'] ) ? intval( $input['enable_shortcode'] ) : 0;
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
@ -422,6 +422,7 @@ class SCLiveticker {
|
|||||||
'poll_interval' => 60,
|
'poll_interval' => 60,
|
||||||
'enable_css' => 1,
|
'enable_css' => 1,
|
||||||
'show_feed' => 0,
|
'show_feed' => 0,
|
||||||
|
'enable_shortcode' => 0,
|
||||||
'reset_settings' => 0,
|
'reset_settings' => 0,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -437,6 +438,10 @@ class SCLiveticker {
|
|||||||
* @return string HTML code of tick.
|
* @return string HTML code of tick.
|
||||||
*/
|
*/
|
||||||
private static function tick_html( $time, $title, $content, $id ) {
|
private static function tick_html( $time, $title, $content, $id ) {
|
||||||
|
if ( self::$options['enable_shortcode'] ) {
|
||||||
|
$content = do_shortcode( $content );
|
||||||
|
}
|
||||||
|
|
||||||
return '<li class="sclt-tick" data-sclt-tick-id="' . esc_attr( $id ) . '">'
|
return '<li class="sclt-tick" data-sclt-tick-id="' . esc_attr( $id ) . '">'
|
||||||
. '<span class="sclt-tick-time">' . esc_html( $time ) . '</span>'
|
. '<span class="sclt-tick-time">' . esc_html( $time ) . '</span>'
|
||||||
. '<span class="sclt-tick-title">' . esc_html( $title ) . '</span>'
|
. '<span class="sclt-tick-title">' . esc_html( $title ) . '</span>'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user