Ditty News Ticker - Version 2.1.10

Version Description

  • Added option to hide ticker if no ticks exist
  • Added option to hide widget if no ticks exist
  • Admin css updates
Download this release

Release Info

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

Code changes from version 2.1.9 to 2.1.10

assets/css/style-admin.css CHANGED
@@ -112,10 +112,11 @@
112
  #mtphr-dnt-code-copy .button {
113
  color: #FFF;
114
  border-color: #333333;
115
- background: #807f7f;
116
  margin: 2px 0;
117
  box-shadow: none;
118
- transition: background-color .25s ease, border-color .25s ease; }
 
119
  #mtphr-dnt-code-copy .button:hover {
120
  background-color: #999999; }
121
  #mtphr-dnt-code-copy .button:hover i {
@@ -195,6 +196,8 @@
195
  background: #FFF;
196
  border: 1px solid #dfdfdf;
197
  padding: 3px 24px 3px 3px;
 
 
198
  border-radius: 3px; }
199
 
200
  .mtphr-dnt-single-image img {
@@ -242,21 +245,11 @@
242
  overflow: hidden; }
243
 
244
  .mtphr-dnt-list-heading {
245
- display: -webkit-box;
246
- display: -ms-flexbox;
247
  display: flex;
248
- -webkit-box-orient: horizontal;
249
- -webkit-box-direction: normal;
250
- -ms-flex-direction: row;
251
- flex-direction: row;
252
- -webkit-box-align: center;
253
- -ms-flex-align: center;
254
- align-items: center;
255
- -webkit-box-pack: start;
256
- -ms-flex-pack: start;
257
- justify-content: flex-start;
258
- -ms-flex-wrap: wrap;
259
- flex-wrap: wrap;
260
  font-weight: bold;
261
  color: #FFF;
262
  text-decoration: none;
@@ -264,23 +257,20 @@
264
  padding: 5px 10px;
265
  margin: -10px -10px 10px;
266
  cursor: pointer;
267
- transition: background-color .25s ease, border-radius .25s ease; }
 
268
  .mtphr-dnt-list-heading:active, .mtphr-dnt-list-heading:focus {
269
  box-shadow: none;
270
  outline: none; }
271
  .mtphr-dnt-list-heading .dashicons-menu {
272
  color: #FFF;
273
  margin-right: 8px;
274
- -webkit-box-ordinal-group: 11;
275
- -ms-flex-order: 10;
276
- order: 10; }
277
 
278
  .mtphr-dnt-list-buttons {
279
  margin: -5px -10px;
280
  margin-left: auto;
281
- -webkit-box-ordinal-group: 21;
282
- -ms-flex-order: 20;
283
- order: 20; }
284
  .mtphr-dnt-list-buttons a {
285
  float: left;
286
  display: block;
@@ -304,21 +294,11 @@
304
  line-height: 31px; }
305
 
306
  .mtphr-dnt-list-item-contents {
307
- display: -webkit-box;
308
- display: -ms-flexbox;
309
  display: flex;
310
- -webkit-box-orient: horizontal;
311
- -webkit-box-direction: normal;
312
- -ms-flex-direction: row;
313
- flex-direction: row;
314
- -webkit-box-align: start;
315
- -ms-flex-align: start;
316
- align-items: flex-start;
317
- -webkit-box-pack: start;
318
- -ms-flex-pack: start;
319
- justify-content: flex-start;
320
- -ms-flex-wrap: wrap;
321
- flex-wrap: wrap; }
322
 
323
  .mtphr-dnt-list-field {
324
  color: #333333;
@@ -328,7 +308,7 @@
328
  .mtphr-dnt-list-placeholder {
329
  width: 100%;
330
  height: 40px;
331
- border: 3px dashed #e6e5e5;
332
  border-radius: 5px;
333
  margin: 5px 0;
334
  box-sizing: border-box; }
@@ -345,7 +325,7 @@
345
  .mtphr-dnt-sort-placeholder {
346
  width: 100%;
347
  height: 40px;
348
- border: 3px dashed #e6e5e5;
349
  border-radius: 5px;
350
  margin: 5px 0;
351
  box-sizing: border-box; }
@@ -373,7 +353,8 @@
373
  padding: 10px;
374
  border-radius: 5px;
375
  cursor: pointer;
376
- transition: background-color .25s ease, border-radius .25s ease; }
 
377
  .mtphr-dnt-sort-heading:active, .mtphr-dnt-sort-heading:focus {
378
  box-shadow: none;
379
  outline: none; }
@@ -397,7 +378,8 @@
397
  background: #FFF;
398
  border-radius: 12px;
399
  margin: -2px 8px -3px 0;
400
- transition: color .25s ease; }
 
401
  .mtphr-dnt-sort-heading .dashicons-menu {
402
  color: #333333;
403
  margin-right: 8px; }
@@ -489,7 +471,7 @@
489
  #mtphr-dnt-metabox-group-toggles a.active:hover {
490
  background-color: #58ca68; }
491
  #mtphr-dnt-metabox-group-toggles a:hover {
492
- background-color: #4d4c4c; }
493
  #mtphr-dnt-metabox-group-toggles a.focus, #mtphr-dnt-metabox-group-toggles a.active {
494
  box-shadow: none;
495
  outline: none; }
@@ -508,10 +490,11 @@
508
  .wp-core-ui #mtphr-dnt-settings-select .mtphr-dnt-button {
509
  color: #FFF;
510
  border-color: #333333;
511
- background: #807f7f;
512
  margin: 2px 0;
513
  box-shadow: none;
514
- transition: background-color .25s ease, border-color .25s ease; }
 
515
  .wp-core-ui #mtphr-dnt-settings-select .mtphr-dnt-button:hover {
516
  background-color: #999999; }
517
  .wp-core-ui #mtphr-dnt-settings-select .mtphr-dnt-button:hover i {
@@ -529,7 +512,7 @@
529
  .wp-core-ui #mtphr-dnt-settings-select .mtphr-dnt-button.button-primary i {
530
  opacity: 1; }
531
  .wp-core-ui #mtphr-dnt-settings-select .mtphr-dnt-button.mtphr-dnt-get-more {
532
- background: #4d4c4c; }
533
  .wp-core-ui #mtphr-dnt-settings-select .mtphr-dnt-button.mtphr-dnt-get-more:hover {
534
  background-color: #595959; }
535
  .wp-core-ui #mtphr-dnt-settings-select .mtphr-dnt-button i {
@@ -537,7 +520,8 @@
537
  line-height: 16px;
538
  margin: 2px 0 0 -5px;
539
  opacity: .5;
540
- transition: opacity .25s ease; }
 
541
  .wp-core-ui #mtphr-dnt-settings-select .mtphr-dnt-button i:before {
542
  vertical-align: middle; }
543
  .wp-core-ui #mtphr-dnt-settings-select .mtphr-dnt-button i.fontastic {
@@ -564,7 +548,7 @@
564
 
565
  .mtphr-dnt-heading {
566
  background-color: #f2f2f2;
567
- border-bottom: 1px solid #e6e5e5;
568
  margin: -20px -20px 20px;
569
  padding: 10px 20px; }
570
  .mtphr-dnt-heading h3 {
@@ -599,6 +583,7 @@
599
  color: #999999; }
600
 
601
  .mtphr-dnt-field {
 
602
  margin-bottom: 20px; }
603
  .mtphr-dnt-field-group .mtphr-dnt-field:last-child {
604
  margin-bottom: 0; }
112
  #mtphr-dnt-code-copy .button {
113
  color: #FFF;
114
  border-color: #333333;
115
+ background: gray;
116
  margin: 2px 0;
117
  box-shadow: none;
118
+ -webkit-transition: background-color 0.25s ease, border-color 0.25s ease;
119
+ transition: background-color 0.25s ease, border-color 0.25s ease; }
120
  #mtphr-dnt-code-copy .button:hover {
121
  background-color: #999999; }
122
  #mtphr-dnt-code-copy .button:hover i {
196
  background: #FFF;
197
  border: 1px solid #dfdfdf;
198
  padding: 3px 24px 3px 3px;
199
+ -webkit-border-radius: 3px;
200
+ -moz-border-radius: 3px;
201
  border-radius: 3px; }
202
 
203
  .mtphr-dnt-single-image img {
245
  overflow: hidden; }
246
 
247
  .mtphr-dnt-list-heading {
 
 
248
  display: flex;
249
+ flex-direction: row;
250
+ align-items: center;
251
+ justify-content: flex-start;
252
+ flex-wrap: wrap;
 
 
 
 
 
 
 
 
253
  font-weight: bold;
254
  color: #FFF;
255
  text-decoration: none;
257
  padding: 5px 10px;
258
  margin: -10px -10px 10px;
259
  cursor: pointer;
260
+ -webkit-transition: background-color 0.25s ease, border-radius 0.25s ease;
261
+ transition: background-color 0.25s ease, border-radius 0.25s ease; }
262
  .mtphr-dnt-list-heading:active, .mtphr-dnt-list-heading:focus {
263
  box-shadow: none;
264
  outline: none; }
265
  .mtphr-dnt-list-heading .dashicons-menu {
266
  color: #FFF;
267
  margin-right: 8px;
268
+ order: 10; }
 
 
269
 
270
  .mtphr-dnt-list-buttons {
271
  margin: -5px -10px;
272
  margin-left: auto;
273
+ order: 20; }
 
 
274
  .mtphr-dnt-list-buttons a {
275
  float: left;
276
  display: block;
294
  line-height: 31px; }
295
 
296
  .mtphr-dnt-list-item-contents {
 
 
297
  display: flex;
298
+ flex-direction: row;
299
+ align-items: flex-start;
300
+ justify-content: flex-start;
301
+ flex-wrap: wrap; }
 
 
 
 
 
 
 
 
302
 
303
  .mtphr-dnt-list-field {
304
  color: #333333;
308
  .mtphr-dnt-list-placeholder {
309
  width: 100%;
310
  height: 40px;
311
+ border: 3px dashed #e6e6e6;
312
  border-radius: 5px;
313
  margin: 5px 0;
314
  box-sizing: border-box; }
325
  .mtphr-dnt-sort-placeholder {
326
  width: 100%;
327
  height: 40px;
328
+ border: 3px dashed #e6e6e6;
329
  border-radius: 5px;
330
  margin: 5px 0;
331
  box-sizing: border-box; }
353
  padding: 10px;
354
  border-radius: 5px;
355
  cursor: pointer;
356
+ -webkit-transition: background-color 0.25s ease, border-radius 0.25s ease;
357
+ transition: background-color 0.25s ease, border-radius 0.25s ease; }
358
  .mtphr-dnt-sort-heading:active, .mtphr-dnt-sort-heading:focus {
359
  box-shadow: none;
360
  outline: none; }
378
  background: #FFF;
379
  border-radius: 12px;
380
  margin: -2px 8px -3px 0;
381
+ -webkit-transition: color 0.25s ease;
382
+ transition: color 0.25s ease; }
383
  .mtphr-dnt-sort-heading .dashicons-menu {
384
  color: #333333;
385
  margin-right: 8px; }
471
  #mtphr-dnt-metabox-group-toggles a.active:hover {
472
  background-color: #58ca68; }
473
  #mtphr-dnt-metabox-group-toggles a:hover {
474
+ background-color: #4d4d4d; }
475
  #mtphr-dnt-metabox-group-toggles a.focus, #mtphr-dnt-metabox-group-toggles a.active {
476
  box-shadow: none;
477
  outline: none; }
490
  .wp-core-ui #mtphr-dnt-settings-select .mtphr-dnt-button {
491
  color: #FFF;
492
  border-color: #333333;
493
+ background: gray;
494
  margin: 2px 0;
495
  box-shadow: none;
496
+ -webkit-transition: background-color 0.25s ease, border-color 0.25s ease;
497
+ transition: background-color 0.25s ease, border-color 0.25s ease; }
498
  .wp-core-ui #mtphr-dnt-settings-select .mtphr-dnt-button:hover {
499
  background-color: #999999; }
500
  .wp-core-ui #mtphr-dnt-settings-select .mtphr-dnt-button:hover i {
512
  .wp-core-ui #mtphr-dnt-settings-select .mtphr-dnt-button.button-primary i {
513
  opacity: 1; }
514
  .wp-core-ui #mtphr-dnt-settings-select .mtphr-dnt-button.mtphr-dnt-get-more {
515
+ background: #4d4d4d; }
516
  .wp-core-ui #mtphr-dnt-settings-select .mtphr-dnt-button.mtphr-dnt-get-more:hover {
517
  background-color: #595959; }
518
  .wp-core-ui #mtphr-dnt-settings-select .mtphr-dnt-button i {
520
  line-height: 16px;
521
  margin: 2px 0 0 -5px;
522
  opacity: .5;
523
+ -webkit-transition: opacity 0.25s ease;
524
+ transition: opacity 0.25s ease; }
525
  .wp-core-ui #mtphr-dnt-settings-select .mtphr-dnt-button i:before {
526
  vertical-align: middle; }
527
  .wp-core-ui #mtphr-dnt-settings-select .mtphr-dnt-button i.fontastic {
548
 
549
  .mtphr-dnt-heading {
550
  background-color: #f2f2f2;
551
+ border-bottom: 1px solid #e6e6e6;
552
  margin: -20px -20px 20px;
553
  padding: 10px 20px; }
554
  .mtphr-dnt-heading h3 {
583
  color: #999999; }
584
 
585
  .mtphr-dnt-field {
586
+ flex: 1;
587
  margin-bottom: 20px; }
588
  .mtphr-dnt-field-group .mtphr-dnt-field:last-child {
589
  margin-bottom: 0; }
assets/sass/style-admin.scss CHANGED
@@ -738,6 +738,7 @@ $red: hsl(0, 100%, 50%);
738
  }
739
  }
740
  .mtphr-dnt-field {
 
741
  margin-bottom: 20px;
742
  .mtphr-dnt-field-group &:last-child {
743
  margin-bottom: 0;
738
  }
739
  }
740
  .mtphr-dnt-field {
741
+ flex: 1;
742
  margin-bottom: 20px;
743
  .mtphr-dnt-field-group &:last-child {
744
  margin-bottom: 0;
ditty-news-ticker.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://dittynewsticker.com/
5
  Description: Ditty News Ticker is a multi-functional data display plugin
6
  Text Domain: ditty-news-ticker
7
  Domain Path: languages
8
- Version: 2.1.9
9
  Author: Metaphor Creations
10
  Author URI: http://www.metaphorcreations.com
11
  Contributors: metaphorcreations
@@ -31,7 +31,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31
 
32
 
33
 
34
- define ( 'MTPHR_DNT_VERSION', '2.1.9' );
35
  define ( 'MTPHR_DNT_DIR', trailingslashit(plugin_dir_path(__FILE__)) );
36
 
37
 
5
  Description: Ditty News Ticker is a multi-functional data display plugin
6
  Text Domain: ditty-news-ticker
7
  Domain Path: languages
8
+ Version: 2.1.10
9
  Author: Metaphor Creations
10
  Author URI: http://www.metaphorcreations.com
11
  Contributors: metaphorcreations
31
 
32
 
33
 
34
+ define ( 'MTPHR_DNT_VERSION', '2.1.10' );
35
  define ( 'MTPHR_DNT_DIR', trailingslashit(plugin_dir_path(__FILE__)) );
36
 
37
 
includes/admin/fields/fields.php CHANGED
@@ -209,7 +209,13 @@ function mtphr_dnt_field_text( $args=array() ) {
209
 
210
  echo '<div class="'.$class.'">';
211
  echo mtphr_dnt_subheading( $args );
212
- echo '<label>'.$before.'<input type="text" name="'.$name.'" value="'.$value.'"'.$width.' '.$placeholder.mtphr_dnt_field_atts($args).' />'.$after.'</label>';
 
 
 
 
 
 
213
  echo '</div>';
214
 
215
  mtphr_dnt_field_append( $args );
209
 
210
  echo '<div class="'.$class.'">';
211
  echo mtphr_dnt_subheading( $args );
212
+ if( $before != '' || $after != '' ) {
213
+ echo '<label>'.$before;
214
+ }
215
+ echo '<input type="text" name="'.$name.'" value="'.$value.'"'.$width.' '.$placeholder.mtphr_dnt_field_atts($args).' />';
216
+ if( $before != '' || $after != '' ) {
217
+ echo $after.'</label>';
218
+ }
219
  echo '</div>';
220
 
221
  mtphr_dnt_field_append( $args );
includes/admin/meta-boxes.php CHANGED
@@ -965,7 +965,7 @@ function mtphr_dnt_list_fields() {
965
 
966
 
967
  /* --------------------------------------------------------- */
968
- /* !Return the global values - 2.0.2 */
969
  /* --------------------------------------------------------- */
970
 
971
  if( !function_exists('mtphr_dnt_global_values') ) {
@@ -977,6 +977,7 @@ function mtphr_dnt_global_values() {
977
  'ajax' => '',
978
  'title' => '',
979
  'inline_title' => '',
 
980
  'shuffle' => '',
981
  'width' => 0,
982
  'offset' => 20,
@@ -997,6 +998,7 @@ function mtphr_dnt_global_values() {
997
  'ajax' => get_post_meta( $post->ID, '_mtphr_dnt_ajax', true ),
998
  'title' => get_post_meta( $post->ID, '_mtphr_dnt_title', true ),
999
  'inline_title' => get_post_meta( $post->ID, '_mtphr_dnt_inline_title', true ),
 
1000
  'shuffle' => get_post_meta( $post->ID, '_mtphr_dnt_shuffle', true ),
1001
  'width' => get_post_meta( $post->ID, '_mtphr_dnt_ticker_width', true ),
1002
  'offset' => get_post_meta( $post->ID, '_mtphr_dnt_offset', true ),
@@ -1010,6 +1012,11 @@ function mtphr_dnt_global_values() {
1010
  'grid_padding' => get_post_meta( $post->ID, '_mtphr_dnt_grid_padding', true ),
1011
  'grid_remove_padding' => get_post_meta( $post->ID, '_mtphr_dnt_grid_remove_padding', true ),
1012
  );
 
 
 
 
 
1013
  foreach( $values as $i=>$value ) {
1014
  if( $value == '' ) {
1015
  unset($values[$i]);
@@ -1059,6 +1066,14 @@ function mtphr_dnt_global_fields() {
1059
  'type' => 'container',
1060
  'append' => array(
1061
 
 
 
 
 
 
 
 
 
1062
  /* !Shuffle ticks - 2.0.4 */
1063
  'shuffle' => array(
1064
  'type' => 'checkbox',
@@ -1177,7 +1192,7 @@ function mtphr_dnt_global_fields() {
1177
 
1178
 
1179
  /* --------------------------------------------------------- */
1180
- /* !Save the custom meta - 2.1.6 */
1181
  /* --------------------------------------------------------- */
1182
 
1183
  if( !function_exists('mtphr_dnt_metabox_save') ) {
@@ -1362,6 +1377,7 @@ function mtphr_dnt_metabox_save( $post_id ) {
1362
  //$ajax = isset($_POST['_mtphr_dnt_ajax']) ? $_POST['_mtphr_dnt_ajax'] : '';
1363
  $title = isset($_POST['_mtphr_dnt_title']) ? $_POST['_mtphr_dnt_title'] : '';
1364
  $inline_title = isset($_POST['_mtphr_dnt_inline_title']) ? $_POST['_mtphr_dnt_inline_title'] : '';
 
1365
  $shuffle = isset($_POST['_mtphr_dnt_shuffle']) ? $_POST['_mtphr_dnt_shuffle'] : '';
1366
  $width = isset($_POST['_mtphr_dnt_ticker_width']) ? intval($_POST['_mtphr_dnt_ticker_width']) : 0;
1367
  $offset = isset($_POST['_mtphr_dnt_offset']) ? intval($_POST['_mtphr_dnt_offset']) : 20;
@@ -1378,6 +1394,7 @@ function mtphr_dnt_metabox_save( $post_id ) {
1378
  //update_post_meta( $post_id, '_mtphr_dnt_ajax', $ajax );
1379
  update_post_meta( $post_id, '_mtphr_dnt_title', $title );
1380
  update_post_meta( $post_id, '_mtphr_dnt_inline_title', $inline_title );
 
1381
  update_post_meta( $post_id, '_mtphr_dnt_shuffle', $shuffle );
1382
  update_post_meta( $post_id, '_mtphr_dnt_ticker_width', $width );
1383
  update_post_meta( $post_id, '_mtphr_dnt_offset', $offset );
965
 
966
 
967
  /* --------------------------------------------------------- */
968
+ /* !Return the global values - 2.1.10 */
969
  /* --------------------------------------------------------- */
970
 
971
  if( !function_exists('mtphr_dnt_global_values') ) {
977
  'ajax' => '',
978
  'title' => '',
979
  'inline_title' => '',
980
+ 'hide' => '',
981
  'shuffle' => '',
982
  'width' => 0,
983
  'offset' => 20,
998
  'ajax' => get_post_meta( $post->ID, '_mtphr_dnt_ajax', true ),
999
  'title' => get_post_meta( $post->ID, '_mtphr_dnt_title', true ),
1000
  'inline_title' => get_post_meta( $post->ID, '_mtphr_dnt_inline_title', true ),
1001
+ 'hide' => get_post_meta( $post->ID, '_mtphr_dnt_hide', true ),
1002
  'shuffle' => get_post_meta( $post->ID, '_mtphr_dnt_shuffle', true ),
1003
  'width' => get_post_meta( $post->ID, '_mtphr_dnt_ticker_width', true ),
1004
  'offset' => get_post_meta( $post->ID, '_mtphr_dnt_offset', true ),
1012
  'grid_padding' => get_post_meta( $post->ID, '_mtphr_dnt_grid_padding', true ),
1013
  'grid_remove_padding' => get_post_meta( $post->ID, '_mtphr_dnt_grid_remove_padding', true ),
1014
  );
1015
+
1016
+ if( !isset($_GET['post']) ) {
1017
+ $values['hide'] = 'on';
1018
+ }
1019
+
1020
  foreach( $values as $i=>$value ) {
1021
  if( $value == '' ) {
1022
  unset($values[$i]);
1066
  'type' => 'container',
1067
  'append' => array(
1068
 
1069
+ /* !Hide ticker - 2.0.4 */
1070
+ 'hide' => array(
1071
+ 'type' => 'checkbox',
1072
+ 'name' => '_mtphr_dnt_hide',
1073
+ 'value' => $values['hide'],
1074
+ 'label' => __('Hide ticker if no ticks exist', 'ditty-news-ticker')
1075
+ ),
1076
+
1077
  /* !Shuffle ticks - 2.0.4 */
1078
  'shuffle' => array(
1079
  'type' => 'checkbox',
1192
 
1193
 
1194
  /* --------------------------------------------------------- */
1195
+ /* !Save the custom meta - 2.1.10 */
1196
  /* --------------------------------------------------------- */
1197
 
1198
  if( !function_exists('mtphr_dnt_metabox_save') ) {
1377
  //$ajax = isset($_POST['_mtphr_dnt_ajax']) ? $_POST['_mtphr_dnt_ajax'] : '';
1378
  $title = isset($_POST['_mtphr_dnt_title']) ? $_POST['_mtphr_dnt_title'] : '';
1379
  $inline_title = isset($_POST['_mtphr_dnt_inline_title']) ? $_POST['_mtphr_dnt_inline_title'] : '';
1380
+ $hide = isset($_POST['_mtphr_dnt_hide']) ? $_POST['_mtphr_dnt_hide'] : '';
1381
  $shuffle = isset($_POST['_mtphr_dnt_shuffle']) ? $_POST['_mtphr_dnt_shuffle'] : '';
1382
  $width = isset($_POST['_mtphr_dnt_ticker_width']) ? intval($_POST['_mtphr_dnt_ticker_width']) : 0;
1383
  $offset = isset($_POST['_mtphr_dnt_offset']) ? intval($_POST['_mtphr_dnt_offset']) : 20;
1394
  //update_post_meta( $post_id, '_mtphr_dnt_ajax', $ajax );
1395
  update_post_meta( $post_id, '_mtphr_dnt_title', $title );
1396
  update_post_meta( $post_id, '_mtphr_dnt_inline_title', $inline_title );
1397
+ update_post_meta( $post_id, '_mtphr_dnt_hide', $hide );
1398
  update_post_meta( $post_id, '_mtphr_dnt_shuffle', $shuffle );
1399
  update_post_meta( $post_id, '_mtphr_dnt_ticker_width', $width );
1400
  update_post_meta( $post_id, '_mtphr_dnt_offset', $offset );
includes/filters.php CHANGED
@@ -273,3 +273,28 @@ function mtphr_dnt_playpause() {
273
  add_action( 'mtphr_dnt_after', 'mtphr_dnt_playpause' );
274
 
275
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
273
  add_action( 'mtphr_dnt_after', 'mtphr_dnt_playpause' );
274
 
275
 
276
+ /**
277
+ * Remove the widget if there are no ticks
278
+ *
279
+ * @access public
280
+ * @since 2.1.10
281
+ */
282
+
283
+ function mtphr_dnt_remove_widgets( $params ) {
284
+
285
+ if( !is_admin() ) {
286
+
287
+ $i = count($params);
288
+ while( $i --> 0 ) {
289
+ if( isset($params[$i]['widget_id']) && (strpos($params[$i]['widget_id'], 'mtphr-dnt-widget') !== false) ) {
290
+ echo '<pre>';print_r($params);echo '</pre>';
291
+ //unset( $params[$i] );
292
+ }
293
+ }
294
+ }
295
+
296
+ return $params;
297
+ }
298
+ //add_filter( 'dynamic_sidebar_params', 'mtphr_dnt_remove_widgets' );
299
+
300
+
includes/functions.php CHANGED
@@ -80,7 +80,7 @@ function get_mtphr_dnt_ticker( $id='', $class='', $atts=false ) {
80
  /**
81
  * Render the ticker
82
  *
83
- * @since 2.0.9
84
  */
85
  function render_mtphr_dnt_ticker( $id='', $class='', $meta_data=false ) {
86
 
@@ -121,102 +121,105 @@ function render_mtphr_dnt_ticker( $id='', $class='', $meta_data=false ) {
121
  // Save the metadata in a global variable
122
  $mtphr_dnt_meta_data = $meta_data;
123
 
124
- ob_start();
125
-
126
- // Add a unique id
127
- $tick_id = 'mtphr-dnt-'.$id;
128
- if( isset($_mtphr_dnt_unique_id) && ($_mtphr_dnt_unique_id != '') ) {
129
- $tick_id = 'mtphr-dnt-'.$id.'-'.sanitize_html_class( $_mtphr_dnt_unique_id );
130
- }
131
-
132
- // Check for a set width
133
- $ticker_width = '';
134
- if( isset($_mtphr_dnt_ticker_width) && ($_mtphr_dnt_ticker_width != 0) ) {
135
- $ticker_width = ' style="width:'.intval($_mtphr_dnt_ticker_width).'px"';
136
- }
137
-
138
- echo '<div'.$ticker_width.' id="'.$tick_id.'" '.mtphr_dnt_ticker_class( $id, $class, $meta_data ).'>';
139
- echo '<div class="mtphr-dnt-wrapper mtphr-dnt-clearfix">';
140
-
141
- // Create and save element styles
142
- $margin='';$padding='';
143
-
144
- if( $_mtphr_dnt_mode == 'scroll' ) {
145
- $padding = ( intval($_mtphr_dnt_scroll_padding) != 0 ) ? 'padding-top:'.intval($_mtphr_dnt_scroll_padding).'px;padding-bottom:'.intval($_mtphr_dnt_scroll_padding).'px;' : '';
146
- $margin = ( intval($_mtphr_dnt_scroll_margin) != 0 ) ? 'margin-top:'.intval($_mtphr_dnt_scroll_margin).'px;margin-bottom:'.intval($_mtphr_dnt_scroll_margin).'px;' : '';
147
- } elseif( $_mtphr_dnt_mode == 'rotate' ) {
148
- $padding = ( intval($_mtphr_dnt_rotate_padding) != 0 ) ? 'padding-top:'.intval($_mtphr_dnt_rotate_padding).'px;padding-bottom:'.intval($_mtphr_dnt_rotate_padding).'px;' : '';
149
- $margin = ( intval($_mtphr_dnt_rotate_margin) != 0 ) ? 'margin-top:'.intval($_mtphr_dnt_rotate_margin).'px;margin-bottom:'.intval($_mtphr_dnt_rotate_margin).'px;' : '';
150
- } elseif( $_mtphr_dnt_mode == 'list' ) {
151
- $padding = ( intval($_mtphr_dnt_list_padding) != 0 ) ? 'padding-top:'.intval($_mtphr_dnt_list_padding).'px;padding-bottom:'.intval($_mtphr_dnt_list_padding).'px;' : '';
152
- $margin = ( intval($_mtphr_dnt_list_margin) != 0 ) ? 'margin-top:'.intval($_mtphr_dnt_list_margin).'px;margin-bottom:'.intval($_mtphr_dnt_list_margin).'px;' : '';
153
- }
154
 
155
- // Filter the variables
156
- $padding = apply_filters( 'mtphr_dnt_tick_container_padding', $padding );
157
- $margin = apply_filters( 'mtphr_dnt_tick_container_margin', $margin );
158
-
159
- // Create the container style
160
- $container_style = ( $padding != '' || $margin != '' ) ? ' style="'.$padding.$margin.'"' : '';
161
 
162
- // Open the ticker container
163
- do_action( 'mtphr_dnt_before', $id, $meta_data );
164
- echo '<div class="mtphr-dnt-tick-container"'.$container_style.'>';
165
- do_action( 'mtphr_dnt_contents_before', $id, $meta_data );
166
- echo '<div class="mtphr-dnt-tick-contents">';
167
- do_action( 'mtphr_dnt_top', $id, $meta_data );
 
 
 
 
 
 
 
 
 
 
 
168
 
169
- // Print out the ticks
170
- if( is_array($dnt_ticks) ) {
171
-
172
- // Grab the paged ticks
173
- if( $_mtphr_dnt_mode == 'list' && (isset($_mtphr_dnt_list_tick_paging) && $_mtphr_dnt_list_tick_paging) ) {
174
- $page = isset( $_GET['tickpage'] ) ? $_GET['tickpage'] : 1;
175
- $offset = ($page-1) * $_mtphr_dnt_list_tick_count;
176
- $dnt_ticks = array_slice( $dnt_ticks, $offset, $_mtphr_dnt_list_tick_count );
177
- }
 
178
 
179
- // Randomize the ticks
180
- if( isset($_mtphr_dnt_shuffle) && $_mtphr_dnt_shuffle ) {
181
- shuffle( $dnt_ticks );
182
- }
183
- $total = count($dnt_ticks);
184
-
185
- $html .= ob_get_clean();
186
-
187
- foreach( $dnt_ticks as $i => $tick_obj ) {
 
 
 
 
 
 
 
188
 
189
- ob_start();
190
-
191
- mtphr_dnt_tick_open( $tick_obj, $i, $id, $meta_data, $total );
 
 
 
 
 
 
 
 
 
192
 
193
- $tick = ( is_array($tick_obj) && isset($tick_obj['tick']) ) ? $tick_obj['tick'] : $tick_obj;
194
- echo $tick;
195
 
196
- mtphr_dnt_tick_close( $tick_obj, $i, $id, $meta_data, $total );
 
 
197
 
198
- $html .= ob_get_clean();
 
 
 
 
 
 
 
 
 
 
199
  }
200
-
201
- ob_start();
202
- }
203
-
204
- // Close the ticker container
205
- do_action( 'mtphr_dnt_bottom', $id, $meta_data );
206
  echo '</div>';
207
- do_action( 'mtphr_dnt_contents_after', $id, $meta_data, $total_ticks );
 
208
  echo '</div>';
209
- do_action( 'mtphr_dnt_after', $id, $meta_data, $total_ticks );
210
-
211
  echo '</div>';
212
- echo '</div>';
213
-
214
- // Restore the original $wp_query
215
- $wp_query = null;
216
- $wp_query = $original_query;
217
- wp_reset_postdata();
218
 
219
- $html .= ob_get_clean();
 
 
 
 
 
 
220
 
221
  return $html;
222
  }
80
  /**
81
  * Render the ticker
82
  *
83
+ * @since 2.1.10
84
  */
85
  function render_mtphr_dnt_ticker( $id='', $class='', $meta_data=false ) {
86
 
121
  // Save the metadata in a global variable
122
  $mtphr_dnt_meta_data = $meta_data;
123
 
124
+ if( !(isset($_mtphr_dnt_hide) && $_mtphr_dnt_hide == 'on') || $total_ticks > 0 ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
 
126
+ ob_start();
 
 
 
 
 
127
 
128
+ // Add a unique id
129
+ $tick_id = 'mtphr-dnt-'.$id;
130
+ if( isset($_mtphr_dnt_unique_id) && ($_mtphr_dnt_unique_id != '') ) {
131
+ $tick_id = 'mtphr-dnt-'.$id.'-'.sanitize_html_class( $_mtphr_dnt_unique_id );
132
+ }
133
+
134
+ // Check for a set width
135
+ $ticker_width = '';
136
+ if( isset($_mtphr_dnt_ticker_width) && ($_mtphr_dnt_ticker_width != 0) ) {
137
+ $ticker_width = ' style="width:'.intval($_mtphr_dnt_ticker_width).'px"';
138
+ }
139
+
140
+ echo '<div'.$ticker_width.' id="'.$tick_id.'" '.mtphr_dnt_ticker_class( $id, $class, $meta_data ).'>';
141
+ echo '<div class="mtphr-dnt-wrapper mtphr-dnt-clearfix">';
142
+
143
+ // Create and save element styles
144
+ $margin='';$padding='';
145
 
146
+ if( $_mtphr_dnt_mode == 'scroll' ) {
147
+ $padding = ( intval($_mtphr_dnt_scroll_padding) != 0 ) ? 'padding-top:'.intval($_mtphr_dnt_scroll_padding).'px;padding-bottom:'.intval($_mtphr_dnt_scroll_padding).'px;' : '';
148
+ $margin = ( intval($_mtphr_dnt_scroll_margin) != 0 ) ? 'margin-top:'.intval($_mtphr_dnt_scroll_margin).'px;margin-bottom:'.intval($_mtphr_dnt_scroll_margin).'px;' : '';
149
+ } elseif( $_mtphr_dnt_mode == 'rotate' ) {
150
+ $padding = ( intval($_mtphr_dnt_rotate_padding) != 0 ) ? 'padding-top:'.intval($_mtphr_dnt_rotate_padding).'px;padding-bottom:'.intval($_mtphr_dnt_rotate_padding).'px;' : '';
151
+ $margin = ( intval($_mtphr_dnt_rotate_margin) != 0 ) ? 'margin-top:'.intval($_mtphr_dnt_rotate_margin).'px;margin-bottom:'.intval($_mtphr_dnt_rotate_margin).'px;' : '';
152
+ } elseif( $_mtphr_dnt_mode == 'list' ) {
153
+ $padding = ( intval($_mtphr_dnt_list_padding) != 0 ) ? 'padding-top:'.intval($_mtphr_dnt_list_padding).'px;padding-bottom:'.intval($_mtphr_dnt_list_padding).'px;' : '';
154
+ $margin = ( intval($_mtphr_dnt_list_margin) != 0 ) ? 'margin-top:'.intval($_mtphr_dnt_list_margin).'px;margin-bottom:'.intval($_mtphr_dnt_list_margin).'px;' : '';
155
+ }
156
 
157
+ // Filter the variables
158
+ $padding = apply_filters( 'mtphr_dnt_tick_container_padding', $padding );
159
+ $margin = apply_filters( 'mtphr_dnt_tick_container_margin', $margin );
160
+
161
+ // Create the container style
162
+ $container_style = ( $padding != '' || $margin != '' ) ? ' style="'.$padding.$margin.'"' : '';
163
+
164
+ // Open the ticker container
165
+ do_action( 'mtphr_dnt_before', $id, $meta_data );
166
+ echo '<div class="mtphr-dnt-tick-container"'.$container_style.'>';
167
+ do_action( 'mtphr_dnt_contents_before', $id, $meta_data );
168
+ echo '<div class="mtphr-dnt-tick-contents">';
169
+ do_action( 'mtphr_dnt_top', $id, $meta_data );
170
+
171
+ // Print out the ticks
172
+ if( is_array($dnt_ticks) ) {
173
 
174
+ // Grab the paged ticks
175
+ if( $_mtphr_dnt_mode == 'list' && (isset($_mtphr_dnt_list_tick_paging) && $_mtphr_dnt_list_tick_paging) ) {
176
+ $page = isset( $_GET['tickpage'] ) ? $_GET['tickpage'] : 1;
177
+ $offset = ($page-1) * $_mtphr_dnt_list_tick_count;
178
+ $dnt_ticks = array_slice( $dnt_ticks, $offset, $_mtphr_dnt_list_tick_count );
179
+ }
180
+
181
+ // Randomize the ticks
182
+ if( isset($_mtphr_dnt_shuffle) && $_mtphr_dnt_shuffle ) {
183
+ shuffle( $dnt_ticks );
184
+ }
185
+ $total = count($dnt_ticks);
186
 
187
+ $html .= ob_get_clean();
 
188
 
189
+ foreach( $dnt_ticks as $i => $tick_obj ) {
190
+
191
+ ob_start();
192
 
193
+ mtphr_dnt_tick_open( $tick_obj, $i, $id, $meta_data, $total );
194
+
195
+ $tick = ( is_array($tick_obj) && isset($tick_obj['tick']) ) ? $tick_obj['tick'] : $tick_obj;
196
+ echo $tick;
197
+
198
+ mtphr_dnt_tick_close( $tick_obj, $i, $id, $meta_data, $total );
199
+
200
+ $html .= ob_get_clean();
201
+ }
202
+
203
+ ob_start();
204
  }
205
+
206
+ // Close the ticker container
207
+ do_action( 'mtphr_dnt_bottom', $id, $meta_data );
208
+ echo '</div>';
209
+ do_action( 'mtphr_dnt_contents_after', $id, $meta_data, $total_ticks );
 
210
  echo '</div>';
211
+ do_action( 'mtphr_dnt_after', $id, $meta_data, $total_ticks );
212
+
213
  echo '</div>';
 
 
214
  echo '</div>';
 
 
 
 
 
 
215
 
216
+ // Restore the original $wp_query
217
+ $wp_query = null;
218
+ $wp_query = $original_query;
219
+ wp_reset_postdata();
220
+
221
+ $html .= ob_get_clean();
222
+ }
223
 
224
  return $html;
225
  }
includes/widget.php CHANGED
@@ -3,7 +3,7 @@
3
  /**
4
  * Create a class for the widget
5
  *
6
- * @since 2.1.5
7
  */
8
  class mtphr_dnt_widget extends WP_Widget {
9
 
@@ -30,14 +30,9 @@ class mtphr_dnt_widget extends WP_Widget {
30
 
31
  $ticker = $instance['ticker'];
32
  $ticker_title = isset( $instance['ticker_title'] );
 
33
 
34
- // Before widget (defined by themes)
35
- echo $before_widget;
36
-
37
- // Title of widget (before and after defined by themes)
38
- if ( $title ) {
39
- echo $before_title . $title . $after_title;
40
- }
41
 
42
  // Set custom attributes
43
  $atts = array();
@@ -54,6 +49,8 @@ class mtphr_dnt_widget extends WP_Widget {
54
  // Add in_widget attribute for customization
55
  $atts['in_widget'] = 1;
56
 
 
 
57
  // Display the ticker
58
  if( $ticker != '' ) {
59
  if( function_exists('ditty_news_ticker') ) {
@@ -61,8 +58,24 @@ class mtphr_dnt_widget extends WP_Widget {
61
  }
62
  }
63
 
64
- // After widget (defined by themes)
65
- echo $after_widget;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  }
67
 
68
  /** @see WP_Widget::update */
@@ -74,6 +87,7 @@ class mtphr_dnt_widget extends WP_Widget {
74
  $instance['title'] = sanitize_text_field( $new_instance['title'] );
75
  $instance['ticker'] = $new_instance['ticker'];
76
  $instance['ticker_title'] = $new_instance['ticker_title'];
 
77
 
78
  return $instance;
79
  }
@@ -85,7 +99,8 @@ class mtphr_dnt_widget extends WP_Widget {
85
  $defaults = array(
86
  'title' => '',
87
  'ticker' => '',
88
- 'ticker_title' => ''
 
89
  );
90
 
91
  $instance = wp_parse_args( (array) $instance, $defaults ); ?>
@@ -118,6 +133,12 @@ class mtphr_dnt_widget extends WP_Widget {
118
  <input class="checkbox" type="checkbox" <?php checked( $instance['ticker_title'], 'on' ); ?> id="<?php echo $this->get_field_id( 'ticker_title' ); ?>" name="<?php echo $this->get_field_name( 'ticker_title' ); ?>" />
119
  <label for="<?php echo $this->get_field_id( 'ticker_title' ); ?>"><?php _e( 'Display Ticker Title?', 'ditty-news-ticker' ); ?></label>
120
  </p>
 
 
 
 
 
 
121
 
122
  <?php
123
  }
3
  /**
4
  * Create a class for the widget
5
  *
6
+ * @since 2.1.10
7
  */
8
  class mtphr_dnt_widget extends WP_Widget {
9
 
30
 
31
  $ticker = $instance['ticker'];
32
  $ticker_title = isset( $instance['ticker_title'] );
33
+ $ticker_hide = isset( $instance['ticker_hide'] );
34
 
35
+ global $mtphr_dnt_meta_data;
 
 
 
 
 
 
36
 
37
  // Set custom attributes
38
  $atts = array();
49
  // Add in_widget attribute for customization
50
  $atts['in_widget'] = 1;
51
 
52
+ ob_start();
53
+
54
  // Display the ticker
55
  if( $ticker != '' ) {
56
  if( function_exists('ditty_news_ticker') ) {
58
  }
59
  }
60
 
61
+ $ticker_output = ob_get_clean();
62
+
63
+ // Only display the widget if ticks exist
64
+ if( !$ticker_hide || intval($mtphr_dnt_meta_data['_mtphr_dnt_total_ticks']) > 0 ) {
65
+
66
+ // Before widget (defined by themes)
67
+ echo $before_widget;
68
+
69
+ // Title of widget (before and after defined by themes)
70
+ if ( $title ) {
71
+ echo $before_title . $title . $after_title;
72
+ }
73
+
74
+ echo $ticker_output;
75
+
76
+ // After widget (defined by themes)
77
+ echo $after_widget;
78
+ }
79
  }
80
 
81
  /** @see WP_Widget::update */
87
  $instance['title'] = sanitize_text_field( $new_instance['title'] );
88
  $instance['ticker'] = $new_instance['ticker'];
89
  $instance['ticker_title'] = $new_instance['ticker_title'];
90
+ $instance['ticker_hide'] = $new_instance['ticker_hide'];
91
 
92
  return $instance;
93
  }
99
  $defaults = array(
100
  'title' => '',
101
  'ticker' => '',
102
+ 'ticker_title' => '',
103
+ 'ticker_hide' => 'on',
104
  );
105
 
106
  $instance = wp_parse_args( (array) $instance, $defaults ); ?>
133
  <input class="checkbox" type="checkbox" <?php checked( $instance['ticker_title'], 'on' ); ?> id="<?php echo $this->get_field_id( 'ticker_title' ); ?>" name="<?php echo $this->get_field_name( 'ticker_title' ); ?>" />
134
  <label for="<?php echo $this->get_field_id( 'ticker_title' ); ?>"><?php _e( 'Display Ticker Title?', 'ditty-news-ticker' ); ?></label>
135
  </p>
136
+
137
+ <!-- Hide Ticker: Checkbox -->
138
+ <p>
139
+ <input class="checkbox" type="checkbox" <?php checked( $instance['ticker_hide'], 'on' ); ?> id="<?php echo $this->get_field_id( 'ticker_hide' ); ?>" name="<?php echo $this->get_field_name( 'ticker_hide' ); ?>" />
140
+ <label for="<?php echo $this->get_field_id( 'ticker_hide' ); ?>"><?php _e( 'Hide widget if no ticks exist?', 'ditty-news-ticker' ); ?></label>
141
+ </p>
142
 
143
  <?php
144
  }
readme.txt CHANGED
@@ -72,6 +72,11 @@ The most common cause for an unresponsive ticker (when using scroll or rotate mo
72
 
73
  == Changelog ==
74
 
 
 
 
 
 
75
  = 2.1.9 =
76
  * Bug fixes
77
 
@@ -431,4 +436,4 @@ The most common cause for an unresponsive ticker (when using scroll or rotate mo
431
 
432
  == Upgrade Notice ==
433
 
434
- Bug fixes
72
 
73
  == Changelog ==
74
 
75
+ = 2.1.10 =
76
+ * Added option to hide ticker if no ticks exist
77
+ * Added option to hide widget if no ticks exist
78
+ * Admin css updates
79
+
80
  = 2.1.9 =
81
  * Bug fixes
82
 
436
 
437
  == Upgrade Notice ==
438
 
439
+ Added options to hide tickers if no ticks exist