Ditty News Ticker - Version 3.0.22

Version Description

  • Dashboard menu order updates
Download this release

Release Info

Developer metaphorcreations
Plugin Icon 128x128 Ditty News Ticker
Version 3.0.22
Comparing to
See all releases

Code changes from version 3.0.21 to 3.0.22

ditty-news-ticker.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin Name: Ditty (formerly Ditty News Ticker)
5
  * Plugin URI: https://www.metaphorcreations.com/ditty
6
  * Description: Formerly Ditty News Ticker. Ditty is a multi-functional data display plugin.
7
- * Version: 3.0.21
8
  * Author: Metaphor Creations
9
  * Author URI: https://www.metaphorcreations.com
10
  * License: GPL-2.0+
@@ -20,7 +20,7 @@ if ( ! defined( 'WPINC' ) ) {
20
 
21
  // Plugin version.
22
  if ( ! defined( 'DITTY_VERSION' ) ) {
23
- define( 'DITTY_VERSION', '3.0.21' );
24
  }
25
 
26
  // Plugin Folder Path.
4
  * Plugin Name: Ditty (formerly Ditty News Ticker)
5
  * Plugin URI: https://www.metaphorcreations.com/ditty
6
  * Description: Formerly Ditty News Ticker. Ditty is a multi-functional data display plugin.
7
+ * Version: 3.0.22
8
  * Author: Metaphor Creations
9
  * Author URI: https://www.metaphorcreations.com
10
  * License: GPL-2.0+
20
 
21
  // Plugin version.
22
  if ( ! defined( 'DITTY_VERSION' ) ) {
23
+ define( 'DITTY_VERSION', '3.0.22' );
24
  }
25
 
26
  // Plugin Folder Path.
includes/class-ditty-item-type.php CHANGED
@@ -109,12 +109,16 @@ class Ditty_Item_Type {
109
  * Setup the type settings
110
  *
111
  * @access public
112
- * @since 3.21
113
  */
114
  public function settings( $item_values = false, $action = 'render' ) {
115
  $values = $this->get_values( $item_values );
116
  $fields = $this->fields( $values );
117
- ditty_fields( $fields, $values, $action );
 
 
 
 
118
  }
119
 
120
  /**
109
  * Setup the type settings
110
  *
111
  * @access public
112
+ * @since 3.0.22
113
  */
114
  public function settings( $item_values = false, $action = 'render' ) {
115
  $values = $this->get_values( $item_values );
116
  $fields = $this->fields( $values );
117
+ if ( 'return' == $action ) {
118
+ return ditty_fields( $fields, $values, $action );
119
+ } else {
120
+ ditty_fields( $fields, $values, $action );
121
+ }
122
  }
123
 
124
  /**
includes/class-ditty-item.php CHANGED
@@ -207,7 +207,8 @@ class Ditty_Item {
207
  */
208
  public function get_setting_fields() {
209
  $item_type_object = $this->get_type_object();
210
- return $item_type_object->settings( $this->get_value() );
 
211
  }
212
 
213
  /**
207
  */
208
  public function get_setting_fields() {
209
  $item_type_object = $this->get_type_object();
210
+ $settings = $item_type_object->settings( $this->get_value(), 'return' );
211
+ return $settings;
212
  }
213
 
214
  /**
includes/hooks.php CHANGED
@@ -158,7 +158,7 @@ add_filter( 'admin_body_class', 'ditty_dashboard_menu_classes', 99 );
158
  /**
159
  * Reorder the menu items
160
  *
161
- * @since 3.0.21
162
  */
163
  function ditty_dashboard_menu_order( $menu_ord ) {
164
  global $submenu;
@@ -168,7 +168,6 @@ function ditty_dashboard_menu_order( $menu_ord ) {
168
  }
169
 
170
  $current_menu = $submenu['edit.php?post_type=ditty'];
171
- $current_order = array();
172
  $new_menu = array();
173
  $extra_items = array();
174
  $order = apply_filters( 'ditty_dashboard_menu_order', array(
@@ -183,31 +182,24 @@ function ditty_dashboard_menu_order( $menu_ord ) {
183
  'mtphr_dnt_settings',
184
  ), $current_menu );
185
 
186
- // Find any extra items that aren't in the order list
187
  if ( is_array( $current_menu ) && count( $current_menu ) > 0 ) {
188
  foreach ( $current_menu as $i => $item ) {
189
- $current_order[] = $item[2];
190
- if ( ! in_array( $item[2], $order ) ) {
 
 
 
191
  $extra_items[] = $item;
192
  }
193
  }
194
  }
195
 
196
- // Trim out any extra items in the order so we don't hit an infinite loop
197
- $order = array_intersect( $order, $current_order );
198
-
199
- // Set the order of the new menu
200
- while( count( $order ) > 0 ) {
201
- if ( is_array( $current_menu ) && count( $current_menu ) > 0 ) {
202
- foreach ( $current_menu as $i => $item ) {
203
- if ( count( $order) > 0 && $order[0] == $item[2] ) {
204
- $new_menu[] = $item;
205
- array_shift( $order );
206
- }
207
- }
208
- }
209
- }
210
-
211
  // Add extra menu items not in the order list
212
  if ( is_array( $extra_items ) && count( $extra_items ) > 0 ) {
213
  foreach ( $extra_items as $i => $item ) {
158
  /**
159
  * Reorder the menu items
160
  *
161
+ * @since 3.0.22
162
  */
163
  function ditty_dashboard_menu_order( $menu_ord ) {
164
  global $submenu;
168
  }
169
 
170
  $current_menu = $submenu['edit.php?post_type=ditty'];
 
171
  $new_menu = array();
172
  $extra_items = array();
173
  $order = apply_filters( 'ditty_dashboard_menu_order', array(
182
  'mtphr_dnt_settings',
183
  ), $current_menu );
184
 
185
+ // Find any extra items that aren't in the order list & find the new order
186
  if ( is_array( $current_menu ) && count( $current_menu ) > 0 ) {
187
  foreach ( $current_menu as $i => $item ) {
188
+ if ( in_array( $item[2], $order ) ) {
189
+ $key = array_search( $item[2], $order );
190
+ $item['order'] = $key;
191
+ $new_menu[] = $item;
192
+ } else {
193
  $extra_items[] = $item;
194
  }
195
  }
196
  }
197
 
198
+ // Sort the new menu by the order key
199
+ usort( $new_menu, function( $a, $b ) {
200
+ return $a['order'] - $b['order'];
201
+ } );
202
+
 
 
 
 
 
 
 
 
 
 
203
  // Add extra menu items not in the order list
204
  if ( is_array( $extra_items ) && count( $extra_items ) > 0 ) {
205
  foreach ( $extra_items as $i => $item ) {
includes/layout-tag-fields.php CHANGED
@@ -41,6 +41,14 @@ function ditty_item_type_layout_tag_fields( $fields, $item_type, $values ) {
41
  $field['type'] = 'select';
42
  $field['options'] = ditty_layout_link_target_options();
43
  break;
 
 
 
 
 
 
 
 
44
  default:
45
  break;
46
  }
@@ -50,6 +58,7 @@ function ditty_item_type_layout_tag_fields( $fields, $item_type, $values ) {
50
  $tag_name = sprintf( esc_html__( '%s Settings', 'ditty-news-ticker' ), ucwords( implode( ' ', explode( '_', $tag ) ) ) );
51
  $fields["layout_tag_{$tag}"] = array(
52
  'type' => 'group',
 
53
  'id' => "layout_tag_{$tag}",
54
  'collapsible' => true,
55
  'default_state' => 'collapsed',
41
  $field['type'] = 'select';
42
  $field['options'] = ditty_layout_link_target_options();
43
  break;
44
+ case 'ago':
45
+ $field['type'] = 'select';
46
+ $field['options'] = array(
47
+ '' => esc_html__( 'Use layout value', 'ditty-news-ticker' ),
48
+ 'no' => esc_html__( 'No', 'ditty-news-ticker' ),
49
+ 'yes' => esc_html__( 'Yes', 'ditty-news-ticker' ),
50
+ );
51
+ break;
52
  default:
53
  break;
54
  }
58
  $tag_name = sprintf( esc_html__( '%s Settings', 'ditty-news-ticker' ), ucwords( implode( ' ', explode( '_', $tag ) ) ) );
59
  $fields["layout_tag_{$tag}"] = array(
60
  'type' => 'group',
61
+ 'tab' => esc_html__( 'Layout Elements', 'ditty-news-ticker' ),
62
  'id' => "layout_tag_{$tag}",
63
  'collapsible' => true,
64
  'default_state' => 'collapsed',
includes/layout-tags.php CHANGED
@@ -2,7 +2,7 @@
2
  /**
3
  * Return all possible layout tags
4
  *
5
- * @since 3.0.12
6
  * @var html
7
  */
8
  function ditty_layout_tags( $item_type = false, $item_value = false ) {
@@ -229,8 +229,8 @@ function ditty_layout_tags( $item_type = false, $item_value = false ) {
229
  'description' => __( 'Render the item date/time.', 'ditty-news-ticker' ),
230
  'atts' => array(
231
  'wrapper' => 'div',
232
- 'format' => get_option( 'date_format' ),
233
  'ago' => '',
 
234
  'ago_string' => __( '%s ago', 'ditty-news-ticker' ),
235
  'before' => '',
236
  'after' => '',
2
  /**
3
  * Return all possible layout tags
4
  *
5
+ * @since 3.0.22
6
  * @var html
7
  */
8
  function ditty_layout_tags( $item_type = false, $item_value = false ) {
229
  'description' => __( 'Render the item date/time.', 'ditty-news-ticker' ),
230
  'atts' => array(
231
  'wrapper' => 'div',
 
232
  'ago' => '',
233
+ 'format' => get_option( 'date_format' ),
234
  'ago_string' => __( '%s ago', 'ditty-news-ticker' ),
235
  'before' => '',
236
  'after' => '',
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: ticker, post ticker, news ticker, content aggregator, latest posts, live refresh, rotator, data rotator, lists, data, aggregator
5
  Requires at least: 4.5
6
  Tested up to: 5.9.3
7
- Stable tag: 3.0.21
8
  License: GPL2
9
 
10
  Formerly Ditty News Ticker. Ditty is a multi-functional data display plugin.
@@ -66,6 +66,9 @@ The most common cause for an unresponsive Ditty (when using scroll or rotate mod
66
 
67
  == Changelog ==
68
 
 
 
 
69
  = 3.0.21 =
70
  * Dashboard menu order updates
71
 
4
  Tags: ticker, post ticker, news ticker, content aggregator, latest posts, live refresh, rotator, data rotator, lists, data, aggregator
5
  Requires at least: 4.5
6
  Tested up to: 5.9.3
7
+ Stable tag: 3.0.22
8
  License: GPL2
9
 
10
  Formerly Ditty News Ticker. Ditty is a multi-functional data display plugin.
66
 
67
  == Changelog ==
68
 
69
+ = 3.0.22 =
70
+ * Dashboard menu order updates
71
+
72
  = 3.0.21 =
73
  * Dashboard menu order updates
74