Slideshow - Version 2.1.17

Version Description

  • Fixed: Invalid argument being supplied for the foreach loop in SlideshowPluginPostType on line 352
  • Fixed: Undefined index being thrown by URL target setting on slideshow creation.
  • Video slide now accepts YouTube URLs as well.
Download this release

Release Info

Developer stefanboonstra
Plugin Icon 128x128 Slideshow
Version 2.1.17
Comparing to
See all releases

Code changes from version 2.1.16 to 2.1.17

classes/SlideshowPlugin.php CHANGED
@@ -67,27 +67,31 @@ class SlideshowPlugin {
67
  // Get stored slide settings and convert them to array([slide-key] => array([setting-name] => [value]));
68
  $slidesPreOrder = array();
69
  $slideSettings = SlideshowPluginPostType::getSettings($post->ID, SlideshowPluginPostType::$prefixes['slide-list'], false);
70
- foreach($slideSettings as $key => $value){
71
- $key = explode('_', $key);
72
- if(is_numeric($key[1]))
73
- $slidesPreOrder[$key[1]][$key[2]] = $value;
74
- }
 
75
 
76
  // Create array ordered by the 'order' key of the slides array: array([order-key] => [slide-key]);
77
  $slidesOrder = array();
78
- foreach($slidesPreOrder as $key => $value)
79
- if(isset($value['order']) && is_numeric($value['order']) && $value['order'] > 0)
80
- $slidesOrder[$value['order']][] = $key;
 
 
81
  ksort($slidesOrder);
82
 
83
  // Order slides by the order key.
84
  $slides = array();
85
- foreach($slidesOrder as $value)
86
- if(is_array($value))
87
- foreach($value as $slideId){
88
- $slides[] = $slidesPreOrder[$slideId];
89
- unset($slidesPreOrder[$slideId]);
90
- }
 
91
 
92
  // Add remaining (unordered) slides to the end of the array.
93
  $slides = array_merge($slides, $slidesPreOrder);
@@ -124,9 +128,10 @@ class SlideshowPlugin {
124
 
125
  // Filter settings to only contain settings, then remove prefix
126
  $settings = array();
127
- foreach($allSettings as $key => $value)
128
- if(SlideshowPluginPostType::$prefixes['settings'] == substr($key, 0, strlen(SlideshowPluginPostType::$prefixes['settings'])))
129
- $settings[substr($key, strlen(SlideshowPluginPostType::$prefixes['settings']))] = $value;
 
130
 
131
  // Include output file that stores output in $output.
132
  $output = '';
67
  // Get stored slide settings and convert them to array([slide-key] => array([setting-name] => [value]));
68
  $slidesPreOrder = array();
69
  $slideSettings = SlideshowPluginPostType::getSettings($post->ID, SlideshowPluginPostType::$prefixes['slide-list'], false);
70
+ if(is_array($slideSettings) && count($slideSettings) > 0)
71
+ foreach($slideSettings as $key => $value){
72
+ $key = explode('_', $key);
73
+ if(is_numeric($key[1]))
74
+ $slidesPreOrder[$key[1]][$key[2]] = $value;
75
+ }
76
 
77
  // Create array ordered by the 'order' key of the slides array: array([order-key] => [slide-key]);
78
  $slidesOrder = array();
79
+ if(count($slidesPreOrder) > 0){
80
+ foreach($slidesPreOrder as $key => $value)
81
+ if(isset($value['order']) && is_numeric($value['order']) && $value['order'] > 0)
82
+ $slidesOrder[$value['order']][] = $key;
83
+ }
84
  ksort($slidesOrder);
85
 
86
  // Order slides by the order key.
87
  $slides = array();
88
+ if(count($slidesOrder) > 0)
89
+ foreach($slidesOrder as $value)
90
+ if(is_array($value))
91
+ foreach($value as $slideId){
92
+ $slides[] = $slidesPreOrder[$slideId];
93
+ unset($slidesPreOrder[$slideId]);
94
+ }
95
 
96
  // Add remaining (unordered) slides to the end of the array.
97
  $slides = array_merge($slides, $slidesPreOrder);
128
 
129
  // Filter settings to only contain settings, then remove prefix
130
  $settings = array();
131
+ if(is_array($allSettings) && count($allSettings) > 0)
132
+ foreach($allSettings as $key => $value)
133
+ if(SlideshowPluginPostType::$prefixes['settings'] == substr($key, 0, strlen(SlideshowPluginPostType::$prefixes['settings'])))
134
+ $settings[substr($key, strlen(SlideshowPluginPostType::$prefixes['settings']))] = $value;
135
 
136
  // Include output file that stores output in $output.
137
  $output = '';
classes/SlideshowPluginPostType.php CHANGED
@@ -169,36 +169,41 @@ class SlideshowPluginPostType {
169
  // Get stored slide settings and convert them to array([slide-key] => array([setting-name] => [value]));
170
  $slidesPreOrder = array();
171
  $settings = self::getSettings($post->ID, self::$prefixes['slide-list']);
172
- foreach($settings as $key => $value){
173
- $key = explode('_', $key);
174
- if(is_numeric($key[1]))
175
- $slidesPreOrder[$key[1]][$key[2]] = $value;
176
- }
 
177
 
178
  // Save slide keys from the $slidePreOrder array in the array itself for later use
179
- foreach($slidesPreOrder as $key => $value){
180
- $slidesPreOrder[$key]['id'] = $key;
 
181
 
182
- // Save highest slide id
183
- if($key > $highestSlideId)
184
- $highestSlideId = $key;
185
- }
186
 
187
  // Create array ordered by the 'order' key of the slides array: array([order-key] => [slide-key]);
188
  $slidesOrder = array();
189
- foreach($slidesPreOrder as $key => $value)
190
- if(isset($value['order']) && is_numeric($value['order']) && $value['order'] > 0)
191
- $slidesOrder[$value['order']][] = $key;
 
 
192
  ksort($slidesOrder);
193
 
194
  // Order slides by the order key.
195
  $slides = array();
196
- foreach($slidesOrder as $value)
197
- if(is_array($value))
198
- foreach($value as $slideId){
199
- $slides[] = $slidesPreOrder[$slideId];
200
- unset($slidesPreOrder[$slideId]);
201
- }
 
202
 
203
  // Add remaining (unordered) slides to the end of the array.
204
  $slides = array_merge($slides, $slidesPreOrder);
@@ -270,10 +275,12 @@ class SlideshowPluginPostType {
270
 
271
  // Filter new data from $_POST
272
  $newData = array();
273
- foreach($_POST as $key => $value)
274
- foreach(self::$prefixes as $prefix)
275
- if($prefix == substr($key, 0, strlen($prefix)))
276
- $newData[$key] = htmlspecialchars($value);
 
 
277
 
278
  // Save settings
279
  update_post_meta(
@@ -315,14 +322,15 @@ class SlideshowPluginPostType {
315
  $settings = self::getSettings($postId, $prefix, $cacheEnabled);
316
 
317
  $simpleSettings = array();
318
- foreach($settings as $key => $value){
319
- if(!is_array($value))
320
- continue;
 
321
 
322
- if(empty($value[1]) && !is_numeric($value[1]))
323
- $simpleSettings[$key] = $value[2];
324
- else $simpleSettings[$key] = $value[1];
325
- }
326
 
327
  return $simpleSettings;
328
  }
@@ -352,16 +360,18 @@ class SlideshowPluginPostType {
352
  );
353
 
354
  // Fill data with settings
355
- foreach($data as $key => $value)
356
- if(isset($currentSettings[$key])){
357
- $data[$key][1] = $currentSettings[$key];
358
- unset($currentSettings[$key]);
359
- }
 
360
 
361
  // Load settings that are not there by default into data (slides in particular)
362
- foreach($currentSettings as $key => $value)
363
- if(!isset($data[$key]))
364
- $data[$key] = $value;
 
365
 
366
  $settings = $data;
367
  if($cacheEnabled)
@@ -371,9 +381,10 @@ class SlideshowPluginPostType {
371
  }
372
 
373
  if(isset($prefix))
374
- foreach($settings as $key => $value)
375
- if($prefix != substr($key, 0, strlen($prefix)))
376
- unset($settings[$key]);
 
377
 
378
  return $settings;
379
  }
@@ -471,54 +482,62 @@ class SlideshowPluginPostType {
471
 
472
  if(!isset(self::$inputFields) || !$cacheEnabled){
473
  $inputFields = array();
474
- foreach($settings as $key => $value){
475
- if(!is_array($value))
476
- continue;
477
-
478
- $inputField = '';
479
- $displayValue = (empty($value[1]) && !is_numeric($value[1]) ? $value[2] : $value[1]);
480
- $class = ((isset($value[5]))? 'depends-on-field-value ' . $value[5][0] . ' ' . $value[5][1] . ' ': '') . $key;
481
- switch($value[0]){
482
- case 'text':
483
- $inputField .= '<input
484
- type="text"
485
- name="' . $key . '"
486
- class="' . $class . '"
487
- value="' . $displayValue . '"
488
- />';
489
- break;
490
- case 'textarea':
491
- $inputField .= '<textarea
492
- name="' . $key . '"
493
- class="' . $class . '"
494
- rows="20"
495
- cols="60"
496
- >' . $displayValue . '</textarea>';
497
- break;
498
- case 'select':
499
- $inputField .= '<select name="' . $key . '" class="' . $class . '">';
500
- foreach($value[4] as $optionKey => $optionValue)
501
- $inputField .= '<option value="' . $optionKey . '" ' . selected($displayValue, $optionKey, false) . '>
502
- ' . $optionValue . '
503
- </option>';
504
- $inputField .= '</select>';
505
- break;
506
- case 'radio':
507
- foreach($value[4] as $radioKey => $radioValue)
508
- $inputField .= '<label><input
509
- type="radio"
510
  name="' . $key . '"
511
  class="' . $class . '"
512
- value="' . $radioKey . '" ' .
513
- checked($displayValue, $radioKey, false) .
514
- ' />' . $radioValue . '</label><br />';
515
- break;
516
- default:
517
- $inputField = null;
518
- break;
519
- };
520
-
521
- $inputFields[$key] = $inputField;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
522
  }
523
 
524
  if($cacheEnabled)
169
  // Get stored slide settings and convert them to array([slide-key] => array([setting-name] => [value]));
170
  $slidesPreOrder = array();
171
  $settings = self::getSettings($post->ID, self::$prefixes['slide-list']);
172
+ if(is_array($settings) && count($settings) > 0)
173
+ foreach($settings as $key => $value){
174
+ $key = explode('_', $key);
175
+ if(is_numeric($key[1]))
176
+ $slidesPreOrder[$key[1]][$key[2]] = $value;
177
+ }
178
 
179
  // Save slide keys from the $slidePreOrder array in the array itself for later use
180
+ if(count($slidesPreOrder) > 0)
181
+ foreach($slidesPreOrder as $key => $value){
182
+ $slidesPreOrder[$key]['id'] = $key;
183
 
184
+ // Save highest slide id
185
+ if($key > $highestSlideId)
186
+ $highestSlideId = $key;
187
+ }
188
 
189
  // Create array ordered by the 'order' key of the slides array: array([order-key] => [slide-key]);
190
  $slidesOrder = array();
191
+ if(count($slidesPreOrder) > 0){
192
+ foreach($slidesPreOrder as $key => $value)
193
+ if(isset($value['order']) && is_numeric($value['order']) && $value['order'] > 0)
194
+ $slidesOrder[$value['order']][] = $key;
195
+ }
196
  ksort($slidesOrder);
197
 
198
  // Order slides by the order key.
199
  $slides = array();
200
+ if(count($slidesOrder) > 0)
201
+ foreach($slidesOrder as $value)
202
+ if(is_array($value))
203
+ foreach($value as $slideId){
204
+ $slides[] = $slidesPreOrder[$slideId];
205
+ unset($slidesPreOrder[$slideId]);
206
+ }
207
 
208
  // Add remaining (unordered) slides to the end of the array.
209
  $slides = array_merge($slides, $slidesPreOrder);
275
 
276
  // Filter new data from $_POST
277
  $newData = array();
278
+ if(is_array($_POST) && count($_POST) > 0)
279
+ foreach($_POST as $key => $value)
280
+ if(is_array(self::$prefixes) && count(self::$prefixes) > 0)
281
+ foreach(self::$prefixes as $prefix)
282
+ if($prefix == substr($key, 0, strlen($prefix)))
283
+ $newData[$key] = htmlspecialchars($value);
284
 
285
  // Save settings
286
  update_post_meta(
322
  $settings = self::getSettings($postId, $prefix, $cacheEnabled);
323
 
324
  $simpleSettings = array();
325
+ if(is_array($settings) && count($settings) > 0)
326
+ foreach($settings as $key => $value){
327
+ if(!is_array($value))
328
+ continue;
329
 
330
+ if(empty($value[1]) && !is_numeric($value[1]))
331
+ $simpleSettings[$key] = $value[2];
332
+ else $simpleSettings[$key] = $value[1];
333
+ }
334
 
335
  return $simpleSettings;
336
  }
360
  );
361
 
362
  // Fill data with settings
363
+ if(is_array($data) && count($data) > 0)
364
+ foreach($data as $key => $value)
365
+ if(isset($currentSettings[$key])){
366
+ $data[$key][1] = $currentSettings[$key];
367
+ unset($currentSettings[$key]);
368
+ }
369
 
370
  // Load settings that are not there by default into data (slides in particular)
371
+ if(is_array($currentSettings) && count($currentSettings) > 0)
372
+ foreach($currentSettings as $key => $value)
373
+ if(!isset($data[$key]))
374
+ $data[$key] = $value;
375
 
376
  $settings = $data;
377
  if($cacheEnabled)
381
  }
382
 
383
  if(isset($prefix))
384
+ if(is_array($settings) && count($settings) > 0)
385
+ foreach($settings as $key => $value)
386
+ if($prefix != substr($key, 0, strlen($prefix)))
387
+ unset($settings[$key]);
388
 
389
  return $settings;
390
  }
482
 
483
  if(!isset(self::$inputFields) || !$cacheEnabled){
484
  $inputFields = array();
485
+ if(is_array($settings) && count($settings) > 0){
486
+ foreach($settings as $key => $value){
487
+ if(!is_array($value))
488
+ continue;
489
+
490
+ $inputField = '';
491
+ $displayValue = (empty($value[1]) && !is_numeric($value[1]) ? $value[2] : $value[1]);
492
+ $class = ((isset($value[5]))? 'depends-on-field-value ' . $value[5][0] . ' ' . $value[5][1] . ' ': '') . $key;
493
+ switch($value[0]){
494
+ case 'text':
495
+ $inputField .= '<input
496
+ type="text"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
497
  name="' . $key . '"
498
  class="' . $class . '"
499
+ value="' . $displayValue . '"
500
+ />';
501
+ break;
502
+ case 'textarea':
503
+ $inputField .= '<textarea
504
+ name="' . $key . '"
505
+ class="' . $class . '"
506
+ rows="20"
507
+ cols="60"
508
+ >' . $displayValue . '</textarea>';
509
+ break;
510
+ case 'select':
511
+ $inputField .= '<select name="' . $key . '" class="' . $class . '">';
512
+ if(is_array($value[4]) && count($value[4]) > 0){
513
+ foreach($value[4] as $optionKey => $optionValue){
514
+ $inputField .= '<option value="' . $optionKey . '" ' . selected($displayValue, $optionKey, false) . '>
515
+ ' . $optionValue . '
516
+ </option>';
517
+ }
518
+ }
519
+ $inputField .= '</select>';
520
+ break;
521
+ case 'radio':
522
+ if(is_array($value[4]) && count($value[4]) > 0){
523
+ foreach($value[4] as $radioKey => $radioValue){
524
+ $inputField .= '<label><input
525
+ type="radio"
526
+ name="' . $key . '"
527
+ class="' . $class . '"
528
+ value="' . $radioKey . '" ' .
529
+ checked($displayValue, $radioKey, false) .
530
+ ' />' . $radioValue . '</label><br />';
531
+ }
532
+ }
533
+ break;
534
+ default:
535
+ $inputField = null;
536
+ break;
537
+ };
538
+
539
+ $inputFields[$key] = $inputField;
540
+ }
541
  }
542
 
543
  if($cacheEnabled)
classes/SlideshowPluginSecurity.php CHANGED
@@ -63,72 +63,77 @@ class SlideshowPluginSecurity {
63
  $allowedElements = self::$allowedElements;
64
 
65
  // Loop through allowed elements decoding their HTML special chars and allowed attributes.
66
- foreach($allowedElements as $element => $attributes){
 
67
 
68
- $position = 0;
69
 
70
- while(($position = stripos($text, $element, $position)) !== false){ // While element tags found
71
 
72
- $openingTag = '<';
73
- $encodedOpeningTag = htmlspecialchars($openingTag);
74
 
75
- if(substr($text, $position - strlen($encodedOpeningTag), strlen($encodedOpeningTag)) == $encodedOpeningTag){ // Check if an opening tag '<' can be found before the tag name
76
 
77
- // Replace encoded opening tag
78
- $text = substr_replace($text, '<', $position - strlen($encodedOpeningTag), strlen($encodedOpeningTag));
79
- $position -= strlen($encodedOpeningTag) - strlen($openingTag);
80
 
81
- // Get the position of the first element closing tag
82
- $closingTag = '>';
83
- $encodedClosingTag = htmlspecialchars($closingTag);
84
- $closingTagPosition = stripos($text, $encodedClosingTag, $position);
85
 
86
- // Replace encoded closing tag
87
- if($closingTagPosition !== false)
88
- $text = substr_replace($text, '>', $closingTagPosition, strlen($encodedClosingTag));
89
 
90
- $elementAttributes = null;
91
- if(isset($attributes['attributes']) && is_array($attributes['attributes']))
92
- $elementAttributes = $attributes['attributes'];
93
- elseif(isset($attributes['attributes']) && $attributes['attributes'] == 'default')
94
- $elementAttributes = self::$defaultAllowedAttributes;
95
- else
96
- continue;
97
 
98
- $tagText = substr($text, $position, $closingTagPosition - $position);
 
99
 
100
- // Decode allowed attributes
101
- foreach($elementAttributes as $attribute){
102
 
103
- $attributeOpener = $attribute . '=' . htmlspecialchars('"');
 
104
 
105
- $attributePosition = 0;
106
- if(($attributePosition = stripos($tagText, $attributeOpener, $attributePosition)) !== false){ // Attribute was found
107
 
108
- $attributeClosingPosition = 0;
109
- if(($attributeClosingPosition = stripos($tagText, htmlspecialchars('"'), $attributePosition + strlen($attributeOpener))) === false) // If no closing position of attribute was found, skip.
110
- continue;
111
 
112
- // Open the attribute
113
- $tagText = str_ireplace($attributeOpener, $attribute . '="', $tagText);
 
 
 
 
 
 
 
 
 
114
 
115
- // Close the attribute
116
- $attributeClosingPosition -= strlen($attributeOpener) - strlen($attribute . '="');
117
- $tagText = substr_replace($tagText, '"', $attributeClosingPosition, strlen(htmlspecialchars('"')));
118
  }
119
 
 
 
120
  }
121
 
122
- // Put the attributes of the tag back in place
123
- $text = substr_replace($text, $tagText, $position, $closingTagPosition - $position);
124
  }
125
 
126
- $position++;
 
 
127
  }
128
-
129
- // Decode closing tags
130
- if(isset($attributes['endTag']) && $attributes['endTag'])
131
- $text = str_ireplace(htmlspecialchars('</' . $element . '>'), '</' . $element . '>', $text);
132
  }
133
 
134
  return $text;
63
  $allowedElements = self::$allowedElements;
64
 
65
  // Loop through allowed elements decoding their HTML special chars and allowed attributes.
66
+ if(is_array($allowedElements) && count($allowedElements) > 0){
67
+ foreach($allowedElements as $element => $attributes){
68
 
69
+ $position = 0;
70
 
71
+ while(($position = stripos($text, $element, $position)) !== false){ // While element tags found
72
 
73
+ $openingTag = '<';
74
+ $encodedOpeningTag = htmlspecialchars($openingTag);
75
 
76
+ if(substr($text, $position - strlen($encodedOpeningTag), strlen($encodedOpeningTag)) == $encodedOpeningTag){ // Check if an opening tag '<' can be found before the tag name
77
 
78
+ // Replace encoded opening tag
79
+ $text = substr_replace($text, '<', $position - strlen($encodedOpeningTag), strlen($encodedOpeningTag));
80
+ $position -= strlen($encodedOpeningTag) - strlen($openingTag);
81
 
82
+ // Get the position of the first element closing tag
83
+ $closingTag = '>';
84
+ $encodedClosingTag = htmlspecialchars($closingTag);
85
+ $closingTagPosition = stripos($text, $encodedClosingTag, $position);
86
 
87
+ // Replace encoded closing tag
88
+ if($closingTagPosition !== false)
89
+ $text = substr_replace($text, '>', $closingTagPosition, strlen($encodedClosingTag));
90
 
91
+ $elementAttributes = null;
92
+ if(isset($attributes['attributes']) && is_array($attributes['attributes']))
93
+ $elementAttributes = $attributes['attributes'];
94
+ elseif(isset($attributes['attributes']) && $attributes['attributes'] == 'default')
95
+ $elementAttributes = self::$defaultAllowedAttributes;
96
+ else
97
+ continue;
98
 
99
+ if(!is_array($elementAttributes))
100
+ continue;
101
 
102
+ $tagText = substr($text, $position, $closingTagPosition - $position);
 
103
 
104
+ // Decode allowed attributes
105
+ foreach($elementAttributes as $attribute){
106
 
107
+ $attributeOpener = $attribute . '=' . htmlspecialchars('"');
 
108
 
109
+ $attributePosition = 0;
110
+ if(($attributePosition = stripos($tagText, $attributeOpener, $attributePosition)) !== false){ // Attribute was found
 
111
 
112
+ $attributeClosingPosition = 0;
113
+ if(($attributeClosingPosition = stripos($tagText, htmlspecialchars('"'), $attributePosition + strlen($attributeOpener))) === false) // If no closing position of attribute was found, skip.
114
+ continue;
115
+
116
+ // Open the attribute
117
+ $tagText = str_ireplace($attributeOpener, $attribute . '="', $tagText);
118
+
119
+ // Close the attribute
120
+ $attributeClosingPosition -= strlen($attributeOpener) - strlen($attribute . '="');
121
+ $tagText = substr_replace($tagText, '"', $attributeClosingPosition, strlen(htmlspecialchars('"')));
122
+ }
123
 
 
 
 
124
  }
125
 
126
+ // Put the attributes of the tag back in place
127
+ $text = substr_replace($text, $tagText, $position, $closingTagPosition - $position);
128
  }
129
 
130
+ $position++;
 
131
  }
132
 
133
+ // Decode closing tags
134
+ if(isset($attributes['endTag']) && $attributes['endTag'])
135
+ $text = str_ireplace(htmlspecialchars('</' . $element . '>'), '</' . $element . '>', $text);
136
  }
 
 
 
 
137
  }
138
 
139
  return $text;
classes/SlideshowPluginShortcode.php CHANGED
@@ -81,12 +81,13 @@ class SlideshowPluginShortcode {
81
  */
82
  static function insertSlideshow($content){
83
  // Loop through post ids
84
- foreach(self::$postIds as $postId){
85
- $updatedContent = preg_replace("/" . self::$bookmark . "/", SlideshowPlugin::prepare($postId), $content, 1);
 
86
 
87
- if(is_string($updatedContent))
88
- $content = $updatedContent;
89
- }
90
 
91
  // Reset postIds, so a shortcode in a next post can be used
92
  self::$postIds = array();
81
  */
82
  static function insertSlideshow($content){
83
  // Loop through post ids
84
+ if(is_array(self::$postIds) && count(self::$postIds) > 0)
85
+ foreach(self::$postIds as $postId){
86
+ $updatedContent = preg_replace("/" . self::$bookmark . "/", SlideshowPlugin::prepare($postId), $content, 1);
87
 
88
+ if(is_string($updatedContent))
89
+ $content = $updatedContent;
90
+ }
91
 
92
  // Reset postIds, so a shortcode in a next post can be used
93
  self::$postIds = array();
classes/SlideshowPluginSlideInserter.php CHANGED
@@ -77,9 +77,11 @@ class SlideshowPluginSlideInserter {
77
 
78
  $search = 'slide_' . $_POST['slideId'] . '_';
79
  $settings = get_post_meta($_POST['postId'], 'settings', true);
80
- foreach($settings as $key => $setting)
81
- if(strtolower(substr($key, 0, strlen($search))) == strtolower($search))
82
- unset($settings[$key]);
 
 
83
  update_post_meta($_POST['postId'], 'settings', $settings);
84
 
85
  die;
77
 
78
  $search = 'slide_' . $_POST['slideId'] . '_';
79
  $settings = get_post_meta($_POST['postId'], 'settings', true);
80
+ if(is_array($settings) && count($settings) > 0){
81
+ foreach($settings as $key => $setting)
82
+ if(strtolower(substr($key, 0, strlen($search))) == strtolower($search))
83
+ unset($settings[$key]);
84
+ }
85
  update_post_meta($_POST['postId'], 'settings', $settings);
86
 
87
  die;
readme.txt CHANGED
@@ -5,7 +5,7 @@ Donate link: http://stefanboonstra.com/donate-to-slideshow/
5
  Tags: slideshow, slider, slide, slides, show, images, image, photo, gallery, galleries, jquery, javascript, video, text
6
  Requires at least: 3.3
7
  Tested up to: 3.4.2
8
- Stable tag: 2.1.16
9
  License: GPLv2
10
 
11
  Integrate a fancy slideshow in just five steps. - Rainbows. Rainbows everywhere.
@@ -112,6 +112,11 @@ slideshow may not be styled.
112
  * Multiple slideshows can now be shown with each its separate styling.
113
  * Users can now search insertable images by post id.
114
 
 
 
 
 
 
115
  = 2.1.16 =
116
  * Security update enabling HTML in slides again, but only allowing it in a very strict format without any scripts.
117
  * Added shortcode editor, which provides a more convenient way of inserting slideshows in your posts and pages.
5
  Tags: slideshow, slider, slide, slides, show, images, image, photo, gallery, galleries, jquery, javascript, video, text
6
  Requires at least: 3.3
7
  Tested up to: 3.4.2
8
+ Stable tag: 2.1.17
9
  License: GPLv2
10
 
11
  Integrate a fancy slideshow in just five steps. - Rainbows. Rainbows everywhere.
112
  * Multiple slideshows can now be shown with each its separate styling.
113
  * Users can now search insertable images by post id.
114
 
115
+ = 2.1.17 =
116
+ * Fixed: Invalid argument being supplied for the foreach loop in SlideshowPluginPostType on line 352
117
+ * Fixed: Undefined index being thrown by URL target setting on slideshow creation.
118
+ * Video slide now accepts YouTube URLs as well.
119
+
120
  = 2.1.16 =
121
  * Security update enabling HTML in slides again, but only allowing it in a very strict format without any scripts.
122
  * Added shortcode editor, which provides a more convenient way of inserting slideshows in your posts and pages.
slideshow.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Slideshow
4
  Plugin URI: http://wordpress.org/extend/plugins/slideshow-jquery-image-gallery/
5
  Description: This plugin offers a slideshow that is easily deployable in your website. Add any image that has already been uploaded to add to your slideshow. Options and styles are customizable for every single slideshow on your website.
6
- Version: 2.1.16
7
  Requires at least: 3.3
8
  Author: StefanBoonstra
9
  Author URI: http://stefanboonstra.com
@@ -21,7 +21,7 @@
21
  class SlideshowPluginMain {
22
 
23
  /** Variables */
24
- static $version = '2.1.16';
25
 
26
  /**
27
  * Bootstraps the application by assigning the right functions to
@@ -68,60 +68,65 @@ class SlideshowPluginMain {
68
  ));
69
 
70
  // Loop through posts
71
- foreach($posts as $post){
72
-
73
- // Stores highest slide id.
74
- $highestSlideId = -1;
75
-
76
- // Get stored slide settings and convert them to array([slide-key] => array([setting-name] => [value]));
77
- $slidesPreOrder = array();
78
- $settings = SlideshowPluginPostType::getSettings($post->ID, SlideshowPluginPostType::$prefixes['slide-list'], true);
79
- foreach($settings as $key => $value){
80
- $key = explode('_', $key);
81
- if(is_numeric($key[1]))
82
- $slidesPreOrder[$key[1]][$key[2]] = $value;
83
- }
84
-
85
- // Save slide keys from the $slidePreOrder array in the array itself for later use
86
- foreach($slidesPreOrder as $key => $value){
87
- // Save highest slide id
88
- if($key > $highestSlideId)
89
- $highestSlideId = $key;
90
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
 
92
- // Get defaults
93
- $defaultData = SlideshowPluginPostType::getDefaultData(false);
94
-
95
- // Get old data
96
- $oldData = get_post_meta($post->ID, SlideshowPluginPostType::$settingsMetaKey, true);
97
- if(!is_array(($oldData)))
98
- $oldData = array();
99
-
100
- // Get attachments
101
- $attachments = get_posts(array(
102
- 'numberposts' => -1,
103
- 'offset' => 0,
104
- 'post_type' => 'attachment',
105
- 'post_parent' => $post->ID
106
- ));
107
-
108
- // Get data from attachments
109
- $newData = array();
110
- foreach($attachments as $attachment){
111
- $highestSlideId++;
112
- $newData['slide_' . $highestSlideId . '_postId'] = $attachment->ID;
113
- $newData['slide_' . $highestSlideId . '_type'] = 'attachment';
114
  }
115
-
116
- // Save settings
117
- update_post_meta(
118
- $post->ID,
119
- SlideshowPluginPostType::$settingsMetaKey,
120
- array_merge(
121
- $defaultData,
122
- $oldData,
123
- $newData
124
- ));
125
  }
126
 
127
  update_option('slideshow-plugin-updated-from-v1-x-x-to-v2-0-1', 'updated');
3
  Plugin Name: Slideshow
4
  Plugin URI: http://wordpress.org/extend/plugins/slideshow-jquery-image-gallery/
5
  Description: This plugin offers a slideshow that is easily deployable in your website. Add any image that has already been uploaded to add to your slideshow. Options and styles are customizable for every single slideshow on your website.
6
+ Version: 2.1.17
7
  Requires at least: 3.3
8
  Author: StefanBoonstra
9
  Author URI: http://stefanboonstra.com
21
  class SlideshowPluginMain {
22
 
23
  /** Variables */
24
+ static $version = '2.1.17';
25
 
26
  /**
27
  * Bootstraps the application by assigning the right functions to
68
  ));
69
 
70
  // Loop through posts
71
+ if(is_array($posts) && count($posts) > 0){
72
+ foreach($posts as $post){
73
+
74
+ // Stores highest slide id.
75
+ $highestSlideId = -1;
76
+
77
+ // Get stored slide settings and convert them to array([slide-key] => array([setting-name] => [value]));
78
+ $slidesPreOrder = array();
79
+ $settings = SlideshowPluginPostType::getSettings($post->ID, SlideshowPluginPostType::$prefixes['slide-list'], true);
80
+ if(is_array($settings) && count($settings) > 0)
81
+ foreach($settings as $key => $value){
82
+ $key = explode('_', $key);
83
+ if(is_numeric($key[1]))
84
+ $slidesPreOrder[$key[1]][$key[2]] = $value;
85
+ }
86
+
87
+ // Save slide keys from the $slidePreOrder array in the array itself for later use
88
+ if(count($slidesPreOrder) > 0)
89
+ foreach($slidesPreOrder as $key => $value){
90
+ // Save highest slide id
91
+ if($key > $highestSlideId)
92
+ $highestSlideId = $key;
93
+ }
94
+
95
+ // Get defaults
96
+ $defaultData = SlideshowPluginPostType::getDefaultData(false);
97
+
98
+ // Get old data
99
+ $oldData = get_post_meta($post->ID, SlideshowPluginPostType::$settingsMetaKey, true);
100
+ if(!is_array(($oldData)))
101
+ $oldData = array();
102
+
103
+ // Get attachments
104
+ $attachments = get_posts(array(
105
+ 'numberposts' => -1,
106
+ 'offset' => 0,
107
+ 'post_type' => 'attachment',
108
+ 'post_parent' => $post->ID
109
+ ));
110
 
111
+ // Get data from attachments
112
+ $newData = array();
113
+ if(is_array($attachments) && count($attachments) > 0)
114
+ foreach($attachments as $attachment){
115
+ $highestSlideId++;
116
+ $newData['slide_' . $highestSlideId . '_postId'] = $attachment->ID;
117
+ $newData['slide_' . $highestSlideId . '_type'] = 'attachment';
118
+ }
119
+
120
+ // Save settings
121
+ update_post_meta(
122
+ $post->ID,
123
+ SlideshowPluginPostType::$settingsMetaKey,
124
+ array_merge(
125
+ $defaultData,
126
+ $oldData,
127
+ $newData
128
+ ));
 
 
 
 
129
  }
 
 
 
 
 
 
 
 
 
 
130
  }
131
 
132
  update_option('slideshow-plugin-updated-from-v1-x-x-to-v2-0-1', 'updated');
views/SlideshowPlugin/slideshow.php CHANGED
@@ -39,6 +39,20 @@
39
  if(isset($slide['videoId']))
40
  $videoId = htmlspecialchars($slide['videoId']);
41
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  $elementVideoId = 'youtube-player-' . rand() . '-' . $videoId;
43
  ?>
44
 
39
  if(isset($slide['videoId']))
40
  $videoId = htmlspecialchars($slide['videoId']);
41
 
42
+ // If the video ID contains 'v=', it means a URL has been passed. Retrieve the video ID.
43
+ $idPosition = null;
44
+ if(($idPosition = stripos($videoId, 'v=')) !== false){
45
+ // The video ID, which perhaps still has some arguments behind it.
46
+ $videoId = substr($videoId, $idPosition + 2);
47
+
48
+ // Explode on extra arguments (&).
49
+ $videoId = explode('&', $videoId);
50
+
51
+ // The first element is the video ID
52
+ if(is_array($videoId) && isset($videoId[0]))
53
+ $videoId = $videoId[0];
54
+ }
55
+
56
  $elementVideoId = 'youtube-player-' . rand() . '-' . $videoId;
57
  ?>
58
 
views/SlideshowPluginPostType/slides.php CHANGED
@@ -19,13 +19,16 @@
19
  </script>
20
 
21
  <ul class="sortable-slides-list">
 
22
  <?php foreach($slides as $key => $slide):
23
  // General values
24
- $id = $url = $order = '';
25
  if(isset($slide['id']))
26
  $id = $slide['id'];
27
  if(isset($slide['url']))
28
  $url = $slide['url'];
 
 
29
  if(isset($slide['order']))
30
  $order = $slide['order'];
31
  ?>
@@ -52,8 +55,8 @@
52
  <p style="float: left; padding: 0 5px;">
53
  <input type="text" name="slide_<?php echo $id; ?>_url" value="<?php echo $url; ?>" /><br />
54
  <select name="slide_<?php echo $id; ?>_urlTarget">
55
- <option value="_self" <?php selected('_self', $slide['urlTarget']); ?>><?php _e('Same window', 'slideshow-plugin'); ?></option>
56
- <option value="_blank" <?php selected('_blank', $slide['urlTarget']); ?>><?php _e('New window', 'slideshow-plugin'); ?></option>
57
  </select>
58
  </p>
59
  <p style="float: left; line-height: 50px;">
@@ -107,8 +110,8 @@
107
  <p style="float: left; padding: 0 5px;">
108
  <input type="text" name="slide_<?php echo $id; ?>_url" value="<?php echo $url; ?>" /><br />
109
  <select name="slide_<?php echo $id; ?>_urlTarget">
110
- <option value="_self" <?php selected('_self', $slide['urlTarget']); ?>><?php _e('Same window', 'slideshow-plugin'); ?></option>
111
- <option value="_blank" <?php selected('_blank', $slide['urlTarget']); ?>><?php _e('New window', 'slideshow-plugin'); ?></option>
112
  </select>
113
  </p>
114
  <p style="float: left; line-height: 50px;">
@@ -133,6 +136,7 @@
133
  </p>
134
  </li>
135
  <?php endforeach; ?>
 
136
  </ul>
137
 
138
  <div class="text-slide-template" style="display: none;">
19
  </script>
20
 
21
  <ul class="sortable-slides-list">
22
+ <?php if(count($slides) > 0): ?>
23
  <?php foreach($slides as $key => $slide):
24
  // General values
25
+ $id = $url = $target = $order = '';
26
  if(isset($slide['id']))
27
  $id = $slide['id'];
28
  if(isset($slide['url']))
29
  $url = $slide['url'];
30
+ if(isset($slide['urlTarget']))
31
+ $target = $slide['urlTarget'];
32
  if(isset($slide['order']))
33
  $order = $slide['order'];
34
  ?>
55
  <p style="float: left; padding: 0 5px;">
56
  <input type="text" name="slide_<?php echo $id; ?>_url" value="<?php echo $url; ?>" /><br />
57
  <select name="slide_<?php echo $id; ?>_urlTarget">
58
+ <option value="_self" <?php selected('_self', $target); ?>><?php _e('Same window', 'slideshow-plugin'); ?></option>
59
+ <option value="_blank" <?php selected('_blank', $target); ?>><?php _e('New window', 'slideshow-plugin'); ?></option>
60
  </select>
61
  </p>
62
  <p style="float: left; line-height: 50px;">
110
  <p style="float: left; padding: 0 5px;">
111
  <input type="text" name="slide_<?php echo $id; ?>_url" value="<?php echo $url; ?>" /><br />
112
  <select name="slide_<?php echo $id; ?>_urlTarget">
113
+ <option value="_self" <?php selected('_self', $target); ?>><?php _e('Same window', 'slideshow-plugin'); ?></option>
114
+ <option value="_blank" <?php selected('_blank', $target); ?>><?php _e('New window', 'slideshow-plugin'); ?></option>
115
  </select>
116
  </p>
117
  <p style="float: left; line-height: 50px;">
136
  </p>
137
  </li>
138
  <?php endforeach; ?>
139
+ <?php endif; ?>
140
  </ul>
141
 
142
  <div class="text-slide-template" style="display: none;">
views/SlideshowPluginWidget/form.php CHANGED
@@ -7,8 +7,10 @@
7
  <label for="<?php echo $this->get_field_id('slideshowId'); ?>"><?php _e('Slideshow', 'slideshow-plugin'); ?></label>
8
  <select class="widefat" id="<?php echo $this->get_field_id('slideshowId'); ?>" name="<?php echo $this->get_field_name('slideshowId'); ?>" value="<?php echo (is_numeric($instance['slideshowId']))? $instance['slideshowId'] : ''; ?>" style="width:100%">
9
  <option value="-1" <?php selected($instance['slideshowId'], -1); ?>><?php _e('Random Slideshow', 'slideshow-plugin'); ?></option>
 
10
  <?php foreach($slideshows as $slideshow): ?>
11
  <option value="<?php echo $slideshow->ID ?>" <?php selected($instance['slideshowId'], $slideshow->ID); ?>><?php echo $slideshow->post_title ?></option>
12
  <?php endforeach; ?>
 
13
  </select>
14
  </p>
7
  <label for="<?php echo $this->get_field_id('slideshowId'); ?>"><?php _e('Slideshow', 'slideshow-plugin'); ?></label>
8
  <select class="widefat" id="<?php echo $this->get_field_id('slideshowId'); ?>" name="<?php echo $this->get_field_name('slideshowId'); ?>" value="<?php echo (is_numeric($instance['slideshowId']))? $instance['slideshowId'] : ''; ?>" style="width:100%">
9
  <option value="-1" <?php selected($instance['slideshowId'], -1); ?>><?php _e('Random Slideshow', 'slideshow-plugin'); ?></option>
10
+ <?php if(count($slideshows) > 0): ?>
11
  <?php foreach($slideshows as $slideshow): ?>
12
  <option value="<?php echo $slideshow->ID ?>" <?php selected($instance['slideshowId'], $slideshow->ID); ?>><?php echo $slideshow->post_title ?></option>
13
  <?php endforeach; ?>
14
+ <?php endif; ?>
15
  </select>
16
  </p>