diff --git a/images/rss.jpg b/images/rss.jpg deleted file mode 100644 index 78cfa7f..0000000 Binary files a/images/rss.jpg and /dev/null differ diff --git a/includes/class-wpliveticker2-admin.php b/includes/class-wpliveticker2-admin.php index bc8f3f2..fc1a7ca 100644 --- a/includes/class-wpliveticker2-admin.php +++ b/includes/class-wpliveticker2-admin.php @@ -93,6 +93,14 @@ class WPLiveticker2_Admin extends WPLiveticker2 { 'wplt2-settings-page', 'wplt2_settings_general' ); + + add_settings_field( + 'show_feed', + __( 'Show RSS feed', 'wplt2' ), + array( 'WPLiveticker2_Admin', 'settings_show_feed_field' ), + 'wplt2-settings-page', + 'wplt2_settings_general' + ); } /** @@ -111,21 +119,6 @@ class WPLiveticker2_Admin extends WPLiveticker2 { public static function settings_uninstall_section() { } - /** - * Render enable css field. - * - * @return void - */ - public static function settings_enable_css_field() { - $checked = self::$_options['enable_css']; - - echo ''; - echo '
' . esc_html__( 'Disable this option to remove the default styling CSS file.', 'wplt2' ) . '
'; - } - /** * Render enable AJAX field. * @@ -156,22 +149,35 @@ class WPLiveticker2_Admin extends WPLiveticker2 { echo '' . esc_html__( 'Interval (in seconds) to update ticker if AJAX is enabled.', 'wplt2' ) . '
'; } + /** - * Render default style field. + * Render enable css field. * * @return void */ - public static function settings_default_style_field() { - $styles = wplt_get_shortcode_styles(); - $default_style = self::$_options['default_style']; + public static function settings_enable_css_field() { + $checked = self::$_options['enable_css']; - echo ''; - echo '' . esc_html__( 'The default display style.', 'wplt2' ) . '
'; + echo ''; + echo '' . esc_html__( 'Disable this option to remove the default styling CSS file.', 'wplt2' ) . '
'; + } + + /** + * Render enable css field. + * + * @return void + */ + public static function settings_show_feed_field() { + $checked = self::$_options['show_feed']; + + echo ''; + echo '' . esc_html__( 'Can be overwritten in shortcode.', 'wplt2' ) . '
'; } /** diff --git a/includes/class-wpliveticker2.php b/includes/class-wpliveticker2.php index 9eba7ae..0135bad 100644 --- a/includes/class-wpliveticker2.php +++ b/includes/class-wpliveticker2.php @@ -128,7 +128,7 @@ class WPLiveticker2 { // Post type arguments. $args = array( - 'labels' => array( + 'labels' => array( 'name' => __( 'Ticks', 'wplt2' ), 'singular_name' => __( 'Tick', 'wplt2' ), 'add_new' => __( 'Add New', 'wplt2' ), @@ -143,13 +143,15 @@ class WPLiveticker2 { 'parent_item_colon' => '', 'menu_name' => __( 'Liveticker', 'wplt2' ), ), - 'public' => false, - 'show_ui' => true, - 'show_in_menu' => true, - 'menu_icon' => 'dashicons-rss', - 'capability_type' => 'post', - 'supports' => array( 'title', 'editor', 'author' ), - 'taxonomies' => array( 'wplt2_ticker' ), + 'public' => false, + 'publicly_queryable' => true, + 'show_ui' => true, + 'show_in_menu' => true, + 'menu_icon' => 'dashicons-rss', + 'capability_type' => 'post', + 'supports' => array( 'title', 'editor', 'author' ), + 'taxonomies' => array( 'wplt2_ticker' ), + 'has_archive' => true, ); register_post_type( 'wplt2_tick', $args ); @@ -170,29 +172,39 @@ class WPLiveticker2 { $output = ''; // Check if first attribute is filled. - if ( $atts['ticker'] ) { + if ( ! empty( $atts['ticker'] ) ) { + $ticker = sanitize_text_field( $atts['ticker'] ); + // Set limit to infinite, if not set explicitly. if ( ! isset( $atts['limit'] ) ) { $atts['limit'] = - 1; } + $limit = intval( $atts['limit'] ); + + // Determine if feed link should be shown. + if ( isset( $atts['feed'] ) ) { + $show_feed = 'true' === strtolower( $atts['feed'] ) || '1' === $atts['feed']; + } else { + $show_feed = 1 === self::$_options['show_feed']; + } $output = ' '; // Show RSS feed link, if configured. - if ( 1 === self::$_options['show_feed'] ) { - // TODO. - $output .= '' . esc_html( $time ) . '' . '' . esc_html( $title ) . '
' diff --git a/includes/images/rss.jpg b/includes/images/rss.jpg deleted file mode 100644 index 78cfa7f..0000000 Binary files a/includes/images/rss.jpg and /dev/null differ diff --git a/includes/rss.php b/includes/rss.php deleted file mode 100644 index ca77be1..0000000 --- a/includes/rss.php +++ /dev/null @@ -1,65 +0,0 @@ - 'wplt_tick', - 'tax_query' => array( - array( 'taxonomy' => 'wplt_ticker', - 'field' => 'slug', - 'terms' => $arguments['ticker_slug'] - ) - ) - ); - - - global $wpdb; - - $sql = "SELECT `ID`, DATE_FORMAT(`post_date`,'%a, %d %b %Y %T') AS `post_date_rfc`, `post_content`, `post_title` FROM `".$wpdb->prefix."posts` WHERE `post_type` = 'wplt_tick' AND `post_status` = 'publish' ORDER BY `post_date` DESC;"; - $entries = $wpdb->get_results($sql); - - date_default_timezone_set("Europe/Berlin"); - - // modify header information - header("Content-Type: application/rss+xml; charset=UTF-8"); - // generate file head - $rss = ''; - $rss .= '