Testimonials Widget - Version 0.2.10

Version Description

  • Character limit nows forces text truncation than preventing of testimonial to show
  • Add option - Limit number of testimonials to pull at a time
  • Sanitize widget variables
  • Fix random_order issue on testimonials widget
Download this release

Release Info

Developer comprock
Plugin Icon wp plugin Testimonials Widget
Version 0.2.10
Comparing to
See all releases

Code changes from version 0.2.9 to 0.2.10

languages/testimonials-widget.pot CHANGED
@@ -2,9 +2,9 @@
2
  # This file is distributed under the same license as the Testimonials Widget package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Testimonials Widget 0.2.3\n"
6
  "Report-Msgid-Bugs-To: http://wordpress.org/tag/testimonials-widget\n"
7
- "POT-Creation-Date: 2012-02-20 09:21:45+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -212,84 +212,92 @@ msgid ""
212
  "your WordPress blog."
213
  msgstr ""
214
 
215
- #. #-#-#-#-# testimonials-widget.pot (Testimonials Widget 0.2.3) #-#-#-#-#
216
  #. Plugin Name of the plugin/theme
217
  #: testimonials-widget-widget.php:30
218
  msgid "Testimonials Widget"
219
  msgstr ""
220
 
221
- #: testimonials-widget-widget.php:82
222
- msgid "none"
223
- msgstr ""
224
-
225
- #: testimonials-widget-widget.php:99
226
  msgid "Testimonials"
227
  msgstr ""
228
 
229
- #: testimonials-widget-widget.php:123
230
  msgid "Title"
231
  msgstr ""
232
 
233
- #: testimonials-widget-widget.php:124
234
  msgid "Minimum Height"
235
  msgstr ""
236
 
237
- #: testimonials-widget-widget.php:124
238
  msgid ""
239
  "Minimum height in px, this must be set to a value that suits your logest "
240
  "testimonial (increase this value if you find that your testimonials are "
241
  "getting cut off)."
242
  msgstr ""
243
 
244
- #: testimonials-widget-widget.php:125
245
  msgid "Show author?"
246
  msgstr ""
247
 
248
- #: testimonials-widget-widget.php:126
249
  msgid "Show source?"
250
  msgstr ""
251
 
252
- #: testimonials-widget-widget.php:127
253
  msgid "Advanced options"
254
  msgstr ""
255
 
256
- #: testimonials-widget-widget.php:129
257
  msgid "Refresh Interval"
258
  msgstr ""
259
 
260
- #: testimonials-widget-widget.php:129
261
  msgid "In seconds or 0 for no refresh."
262
  msgstr ""
263
 
264
- #: testimonials-widget-widget.php:130
265
  msgid "Random order"
266
  msgstr ""
267
 
268
- #: testimonials-widget-widget.php:130
269
  msgid ""
270
  "Unchecking this will rotate testimonials in the order added, latest first."
271
  msgstr ""
272
 
273
- #: testimonials-widget-widget.php:131
274
  msgid "Tags filter"
275
  msgstr ""
276
 
277
- #: testimonials-widget-widget.php:131
278
  msgid "Comma separated"
279
  msgstr ""
280
 
281
- #: testimonials-widget-widget.php:132
282
  msgid "Require all tags"
283
  msgstr ""
284
 
285
- #: testimonials-widget-widget.php:132
286
  msgid "Checking this will select only testimonials with all of the given tags."
287
  msgstr ""
288
 
289
- #: testimonials-widget-widget.php:133
290
  msgid "Character limit"
291
  msgstr ""
292
 
 
 
 
 
 
 
 
 
 
 
 
 
293
  #. Description of the plugin/theme
294
  msgid ""
295
  "Testimonial widget plugin helps you display testimonials in a sidebar on "
@@ -297,5 +305,9 @@ msgid ""
297
  msgstr ""
298
 
299
  #. Author of the plugin/theme
300
- msgid "comprock, j0hnsmith"
 
 
 
 
301
  msgstr ""
2
  # This file is distributed under the same license as the Testimonials Widget package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Testimonials Widget 0.2.10\n"
6
  "Report-Msgid-Bugs-To: http://wordpress.org/tag/testimonials-widget\n"
7
+ "POT-Creation-Date: 2012-07-20 06:19:51+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
212
  "your WordPress blog."
213
  msgstr ""
214
 
215
+ #. #-#-#-#-# testimonials-widget.pot (Testimonials Widget 0.2.10) #-#-#-#-#
216
  #. Plugin Name of the plugin/theme
217
  #: testimonials-widget-widget.php:30
218
  msgid "Testimonials Widget"
219
  msgstr ""
220
 
221
+ #: testimonials-widget-widget.php:90
 
 
 
 
222
  msgid "Testimonials"
223
  msgstr ""
224
 
225
+ #: testimonials-widget-widget.php:115
226
  msgid "Title"
227
  msgstr ""
228
 
229
+ #: testimonials-widget-widget.php:116
230
  msgid "Minimum Height"
231
  msgstr ""
232
 
233
+ #: testimonials-widget-widget.php:116
234
  msgid ""
235
  "Minimum height in px, this must be set to a value that suits your logest "
236
  "testimonial (increase this value if you find that your testimonials are "
237
  "getting cut off)."
238
  msgstr ""
239
 
240
+ #: testimonials-widget-widget.php:117
241
  msgid "Show author?"
242
  msgstr ""
243
 
244
+ #: testimonials-widget-widget.php:118
245
  msgid "Show source?"
246
  msgstr ""
247
 
248
+ #: testimonials-widget-widget.php:119
249
  msgid "Advanced options"
250
  msgstr ""
251
 
252
+ #: testimonials-widget-widget.php:121
253
  msgid "Refresh Interval"
254
  msgstr ""
255
 
256
+ #: testimonials-widget-widget.php:121
257
  msgid "In seconds or 0 for no refresh."
258
  msgstr ""
259
 
260
+ #: testimonials-widget-widget.php:122
261
  msgid "Random order"
262
  msgstr ""
263
 
264
+ #: testimonials-widget-widget.php:122
265
  msgid ""
266
  "Unchecking this will rotate testimonials in the order added, latest first."
267
  msgstr ""
268
 
269
+ #: testimonials-widget-widget.php:123
270
  msgid "Tags filter"
271
  msgstr ""
272
 
273
+ #: testimonials-widget-widget.php:123
274
  msgid "Comma separated"
275
  msgstr ""
276
 
277
+ #: testimonials-widget-widget.php:124
278
  msgid "Require all tags"
279
  msgstr ""
280
 
281
+ #: testimonials-widget-widget.php:124
282
  msgid "Checking this will select only testimonials with all of the given tags."
283
  msgstr ""
284
 
285
+ #: testimonials-widget-widget.php:125
286
  msgid "Character limit"
287
  msgstr ""
288
 
289
+ #: testimonials-widget-widget.php:125
290
+ msgid "Number of characters to limit testimonial views to. Zero means no limit"
291
+ msgstr ""
292
+
293
+ #: testimonials-widget-widget.php:126
294
+ msgid "Limit"
295
+ msgstr ""
296
+
297
+ #: testimonials-widget-widget.php:126
298
+ msgid "Number of testimonials to pull at a time. Zero means no limit"
299
+ msgstr ""
300
+
301
  #. Description of the plugin/theme
302
  msgid ""
303
  "Testimonial widget plugin helps you display testimonials in a sidebar on "
305
  msgstr ""
306
 
307
  #. Author of the plugin/theme
308
+ msgid "Michael Cannon"
309
+ msgstr ""
310
+
311
+ #. Author URI of the plugin/theme
312
+ msgid "http://typo3vagabond.com/about-typo3-vagabond/hire-michael/"
313
  msgstr ""
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: comprock, j0hnsmith
3
  Donate link: http://typo3vagabond.com/about-typo3-vagabond/donate/
4
  Tags: testimonial, testimonials, quote, quotes, quotations, random quote, sidebar, widget
5
  Requires at least: 3.0
6
- Tested up to: 3.3.1
7
- Stable tag: 0.2.9
8
 
9
  Testimonials widget plugin allows you display testimonials in a widget on your WordPress blog.
10
 
@@ -30,7 +30,8 @@ You can make a simple client or portfolio rotator by using the testimonial field
30
  * Choose random or sequential order for refresh
31
  * Show only quotes with certain tags
32
  * Show only quotes with all tags
33
- * Specify a character limit to filter out longer quotes
 
34
  * Allows for multiple widgets. Useful for using tags to keep widgets separated.
35
  * Compatible with WordPress 3.0 multi-site functionality.
36
 
@@ -168,6 +169,12 @@ Change the value of the variable `$testimonialswidget_admin_userlevel` on line 3
168
  = trunk =
169
  -
170
 
 
 
 
 
 
 
171
  = 0.2.9 =
172
  * Require Editor role for managing Testimonials
173
 
3
  Donate link: http://typo3vagabond.com/about-typo3-vagabond/donate/
4
  Tags: testimonial, testimonials, quote, quotes, quotations, random quote, sidebar, widget
5
  Requires at least: 3.0
6
+ Tested up to: 3.4.1
7
+ Stable tag: 0.2.10
8
 
9
  Testimonials widget plugin allows you display testimonials in a widget on your WordPress blog.
10
 
30
  * Choose random or sequential order for refresh
31
  * Show only quotes with certain tags
32
  * Show only quotes with all tags
33
+ * Specify a character limit to filter out longer quotes - 0 means no limit
34
+ * Limit number of testimonials to pull at a time - 0 means no limit
35
  * Allows for multiple widgets. Useful for using tags to keep widgets separated.
36
  * Compatible with WordPress 3.0 multi-site functionality.
37
 
169
  = trunk =
170
  -
171
 
172
+ = 0.2.10 =
173
+ * Character limit nows forces text truncation than preventing of testimonial to show
174
+ * Add option - Limit number of testimonials to pull at a time
175
+ * Sanitize widget variables
176
+ * Fix random_order issue on testimonials widget
177
+
178
  = 0.2.9 =
179
  * Require Editor role for managing Testimonials
180
 
testimonials-widget-widget.php CHANGED
@@ -38,30 +38,22 @@ class testimonials_widget extends WP_Widget {
38
 
39
  /* Our variables from the widget settings. */
40
  $title = apply_filters('the_title', $instance['title']);
41
- $min_height = $instance['min_height'];
42
- $show_author = $instance['show_author'];
43
- $show_source = $instance['show_source'];
44
- $random_order = $instance['random_order'];
45
- $tags_all = $instance['tags_all'];
46
- $refresh_interval = $instance['refresh_interval'];
47
- $char_limit = $instance['char_limit'];
48
- $tags = $instance['tags'];
49
 
50
- $testimonials = testimonialswidget_display_testimonials($title, $random_order, $min_height, $refresh_interval, $show_source, $show_author, $tags, $char_limit, $this->number, $tags_all);
51
 
52
  /* Before widget (defined by themes). */
53
- echo $before_widget;
54
 
55
  /* Display the widget title if one was input (before and after defined by themes). */
56
  if ( $title )
57
  echo $before_title . $title . $after_title;
58
 
59
  /* Display Widget */
60
- echo $testimonials;
61
 
62
  /* After widget (defined by themes). */
63
- echo $after_widget;
64
- }
65
 
66
  /* ---------------------------- */
67
  /* ------- Update Widget -------- */
@@ -69,17 +61,16 @@ class testimonials_widget extends WP_Widget {
69
  function update( $new_instance, $old_instance ) {
70
  $instance = $old_instance;
71
 
72
- $instance['title'] = strip_tags(stripslashes($new_instance['title']));
73
- $instance['min_height'] = strip_tags(stripslashes($new_instance['min_height']));
74
- $instance['show_author'] = (isset($new_instance['show_author']) && $new_instance['show_author'])?1:0;
75
- $instance['show_source'] = (isset($new_instance['show_source']) && $new_instance['show_source'])?1:0;
76
- $instance['refresh_interval'] = strip_tags(stripslashes($new_instance['refresh_interval']));
77
- $instance['random_order'] = (isset($new_instance['random_order']) && $new_instance['random_order'])?1:0;
78
  $instance['tags_all'] = (isset($new_instance['tags_all']) && $new_instance['tags_all'])?1:0;
79
- $instance['tags'] = strip_tags(stripslashes($new_instance['tags']));
80
- $instance['char_limit'] = strip_tags(stripslashes($new_instance['char_limit']));
81
- if(!$instance['char_limit'])
82
- $instance['char_limit'] = __('none', 'testimonials-widget');
83
 
84
  return $instance;
85
  }
@@ -104,7 +95,8 @@ class testimonials_widget extends WP_Widget {
104
  'tags_all' => 0,
105
  'refresh_interval' => 10,
106
  'tags' => '',
107
- 'char_limit' => 500
 
108
  );
109
  $instance = wp_parse_args( (array) $instance, $defaults );
110
 
@@ -130,7 +122,8 @@ class testimonials_widget extends WP_Widget {
130
  echo '<p><input type="checkbox" id="'.$this->get_field_id( 'random_order' ).'" name="'.$this->get_field_name( 'random_order' ).'" value="1"'.$random_order_checked.' /> <label for="'.$this->get_field_id( 'random_order' ).'">'.__('Random order', 'testimonials-widget').'</label><br/><span class="setting-description"><small>'.__('Unchecking this will rotate testimonials in the order added, latest first.', 'testimonials-widget').'</small></span></p>';
131
  echo '<p><label for="'.$this->get_field_id( 'tags' ).'">'.__('Tags filter', 'testimonials-widget').' </label><input class="widefat" type="text" id="'.$this->get_field_id( 'tags' ).'" name="'.$this->get_field_name( 'tags' ).'" value="'.htmlspecialchars($instance['tags'], ENT_QUOTES).'" /><br/><span class="setting-description"><small>'.__('Comma separated', 'testimonials-widget').'</small></span></p>';
132
  echo '<p><input type="checkbox" id="'.$this->get_field_id( 'tags_all' ).'" name="'.$this->get_field_name( 'tags_all' ).'" value="1"'.$tags_all_checked.' /> <label for="'.$this->get_field_id( 'tags_all' ).'">'.__('Require all tags', 'testimonials-widget').'</label><br/><span class="setting-description"><small>'.__('Checking this will select only testimonials with all of the given tags.', 'testimonials-widget').'</small></span></p>';
133
- echo '<p><label for="'.$this->get_field_id( 'char_limit' ).'">'.__('Character limit', 'testimonials-widget').' </label><input class="widefat" type="text" id="'.$this->get_field_id( 'char_limit' ).'" name="'.$this->get_field_name( 'char_limit' ).'" value="'.htmlspecialchars($instance['char_limit'], ENT_QUOTES).'" /></p>';
 
134
  echo '</div>';
135
  }
136
  }
38
 
39
  /* Our variables from the widget settings. */
40
  $title = apply_filters('the_title', $instance['title']);
 
 
 
 
 
 
 
 
41
 
42
+ $testimonials = testimonialswidget_display_testimonials( $instance, $this->number );
43
 
44
  /* Before widget (defined by themes). */
45
+ echo $before_widget;
46
 
47
  /* Display the widget title if one was input (before and after defined by themes). */
48
  if ( $title )
49
  echo $before_title . $title . $after_title;
50
 
51
  /* Display Widget */
52
+ echo $testimonials;
53
 
54
  /* After widget (defined by themes). */
55
+ echo $after_widget;
56
+ }
57
 
58
  /* ---------------------------- */
59
  /* ------- Update Widget -------- */
61
  function update( $new_instance, $old_instance ) {
62
  $instance = $old_instance;
63
 
64
+ $instance['title'] = wp_kses_data($new_instance['title']);
65
+ $instance['min_height'] = intval($new_instance['min_height']);
66
+ $instance['show_author'] = (isset($new_instance['show_author']) && $new_instance['show_author']) ? true : false;
67
+ $instance['show_source'] = (isset($new_instance['show_source']) && $new_instance['show_source']) ? true : false;
68
+ $instance['refresh_interval'] = intval($new_instance['refresh_interval']);
69
+ $instance['random_order'] = (isset($new_instance['random_order']) && $new_instance['random_order']) ? true : false;
70
  $instance['tags_all'] = (isset($new_instance['tags_all']) && $new_instance['tags_all'])?1:0;
71
+ $instance['tags'] = wp_filter_nohtml_kses($new_instance['tags']);
72
+ $instance['char_limit'] = intval($new_instance['char_limit']);
73
+ $instance['limit'] = intval($new_instance['limit']);
 
74
 
75
  return $instance;
76
  }
95
  'tags_all' => 0,
96
  'refresh_interval' => 10,
97
  'tags' => '',
98
+ 'char_limit' => 500,
99
+ 'limit' => 10
100
  );
101
  $instance = wp_parse_args( (array) $instance, $defaults );
102
 
122
  echo '<p><input type="checkbox" id="'.$this->get_field_id( 'random_order' ).'" name="'.$this->get_field_name( 'random_order' ).'" value="1"'.$random_order_checked.' /> <label for="'.$this->get_field_id( 'random_order' ).'">'.__('Random order', 'testimonials-widget').'</label><br/><span class="setting-description"><small>'.__('Unchecking this will rotate testimonials in the order added, latest first.', 'testimonials-widget').'</small></span></p>';
123
  echo '<p><label for="'.$this->get_field_id( 'tags' ).'">'.__('Tags filter', 'testimonials-widget').' </label><input class="widefat" type="text" id="'.$this->get_field_id( 'tags' ).'" name="'.$this->get_field_name( 'tags' ).'" value="'.htmlspecialchars($instance['tags'], ENT_QUOTES).'" /><br/><span class="setting-description"><small>'.__('Comma separated', 'testimonials-widget').'</small></span></p>';
124
  echo '<p><input type="checkbox" id="'.$this->get_field_id( 'tags_all' ).'" name="'.$this->get_field_name( 'tags_all' ).'" value="1"'.$tags_all_checked.' /> <label for="'.$this->get_field_id( 'tags_all' ).'">'.__('Require all tags', 'testimonials-widget').'</label><br/><span class="setting-description"><small>'.__('Checking this will select only testimonials with all of the given tags.', 'testimonials-widget').'</small></span></p>';
125
+ echo '<p><label for="'.$this->get_field_id( 'char_limit' ).'">'.__('Character limit', 'testimonials-widget').' </label><input class="widefat" type="text" id="'.$this->get_field_id( 'char_limit' ).'" name="'.$this->get_field_name( 'char_limit' ).'" value="'.htmlspecialchars($instance['char_limit'], ENT_QUOTES).'" /><br/><span class="setting-description"><small>'.__('Number of characters to limit testimonial views to. Zero means no limit', 'testimonials-widget').'</small></span></p>';
126
+ echo '<p><label for="'.$this->get_field_id( 'limit' ).'">'.__('Limit', 'testimonials-widget').' </label><input class="widefat" type="text" id="'.$this->get_field_id( 'limit' ).'" name="'.$this->get_field_name( 'limit' ).'" value="'.htmlspecialchars($instance['limit'], ENT_QUOTES).'" /><br/><span class="setting-description"><small>'.__('Number of testimonials to pull at a time. Zero means no limit', 'testimonials-widget').'</small></span></p>';
127
  echo '</div>';
128
  }
129
  }
testimonials-widget.php CHANGED
@@ -2,14 +2,13 @@
2
  /*
3
  Plugin Name: Testimonials Widget
4
  Description: Testimonial widget plugin helps you display testimonials in a sidebar on your WordPress blog.
5
- Version: 0.2.9
6
  Author: Michael Cannon
7
  Author URI: http://typo3vagabond.com/about-typo3-vagabond/hire-michael/
8
  License: GPL2
9
  */
10
 
11
  /* Copyright 2012 Michael Cannon
12
- Copyright 2011 j0hnsmith
13
 
14
  This program is free software; you can redistribute it and/or modify
15
  it under the terms of the GNU General Public License as published by
@@ -56,14 +55,10 @@ require_once('testimonials-widget-widget.php');
56
  require_once('testimonials-widget-admin.php');
57
 
58
 
59
- function testimonialswidget_display_testimonials($title = '', $random = 1, $min_height, $refresh_interval = 10, $show_source = 0, $show_author = 1, $tags = '', $char_limit = 500, $widget_number = '', $tags_all = 0) {
60
- $conditions = " WHERE public = 'yes'";
61
 
62
- if($char_limit && is_numeric($char_limit)) {
63
- $conditions .= " AND CHAR_LENGTH(testimonial) <= ".$char_limit;
64
- } else {
65
- $options['char_limit'] = 0;
66
- }
67
 
68
  if($tags) {
69
  $taglist = explode(',', $tags);
@@ -82,12 +77,15 @@ function testimonialswidget_display_testimonials($title = '', $random = 1, $min_
82
  $conditions .= " AND ({$tag_conditions})";
83
  }
84
 
85
- if($random) {
86
  $conditions .= " ORDER BY RAND()";
87
  } else {
88
  $conditions .= " ORDER BY testimonial_id DESC";
89
  }
90
 
 
 
 
91
  if ( 0 == $refresh_interval )
92
  $conditions .= " LIMIT 1";
93
 
@@ -129,7 +127,16 @@ EOF;
129
  $html .= '<div class="'.$id.' '.$id_base.'">';
130
  $first = true;
131
 
 
 
 
 
 
 
132
  foreach ($testimonials as $testimonial) {
 
 
 
133
 
134
  if (!$first) {
135
  $html .= '<div class="testimonialswidget_testimonial">';
@@ -277,7 +284,7 @@ function testimonialswidget_list_shortcode($atts, $content = null) {
277
  $conditions .= " AND ({$tag_conditions})";
278
  }
279
 
280
- if($random) {
281
  $conditions .= " ORDER BY RAND()";
282
  } else {
283
  $conditions .= " ORDER BY testimonial_id DESC";
@@ -319,4 +326,18 @@ function testimonialswidget_list_shortcode($atts, $content = null) {
319
 
320
  add_shortcode('testimonialswidget_list', 'testimonialswidget_list_shortcode');
321
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
322
  ?>
2
  /*
3
  Plugin Name: Testimonials Widget
4
  Description: Testimonial widget plugin helps you display testimonials in a sidebar on your WordPress blog.
5
+ Version: 0.2.10
6
  Author: Michael Cannon
7
  Author URI: http://typo3vagabond.com/about-typo3-vagabond/hire-michael/
8
  License: GPL2
9
  */
10
 
11
  /* Copyright 2012 Michael Cannon
 
12
 
13
  This program is free software; you can redistribute it and/or modify
14
  it under the terms of the GNU General Public License as published by
55
  require_once('testimonials-widget-admin.php');
56
 
57
 
58
+ function testimonialswidget_display_testimonials( $args, $widget_number = '' ) {
59
+ extract( $args );
60
 
61
+ $conditions = " WHERE public = 'yes'";
 
 
 
 
62
 
63
  if($tags) {
64
  $taglist = explode(',', $tags);
77
  $conditions .= " AND ({$tag_conditions})";
78
  }
79
 
80
+ if($random_order) {
81
  $conditions .= " ORDER BY RAND()";
82
  } else {
83
  $conditions .= " ORDER BY testimonial_id DESC";
84
  }
85
 
86
+ if ( $limit )
87
+ $conditions .= " LIMIT {$limit}";
88
+
89
  if ( 0 == $refresh_interval )
90
  $conditions .= " LIMIT 1";
91
 
127
  $html .= '<div class="'.$id.' '.$id_base.'">';
128
  $first = true;
129
 
130
+ if( $char_limit && is_numeric($char_limit) ) {
131
+ $char_limit = intval( $char_limit );
132
+ } else {
133
+ $char_limit = false;
134
+ }
135
+
136
  foreach ($testimonials as $testimonial) {
137
+ if( $char_limit ) {
138
+ $testimonial['testimonial'] = testimonialswidget_truncate( $testimonial['testimonial'], $char_limit );
139
+ }
140
 
141
  if (!$first) {
142
  $html .= '<div class="testimonialswidget_testimonial">';
284
  $conditions .= " AND ({$tag_conditions})";
285
  }
286
 
287
+ if ( $random ) {
288
  $conditions .= " ORDER BY RAND()";
289
  } else {
290
  $conditions .= " ORDER BY testimonial_id DESC";
326
 
327
  add_shortcode('testimonialswidget_list', 'testimonialswidget_list_shortcode');
328
 
329
+ // Original PHP code as myTruncate2 by Chirp Internet: www.chirp.com.au
330
+ function testimonialswidget_truncate( $string, $char_limit, $break = ' ', $pad = '…' ) {
331
+ // return with no change if string is shorter than $char_limit
332
+ if( strlen( $string ) <= $char_limit )
333
+ return $string;
334
+
335
+ $string = substr( $string, 0, $char_limit );
336
+ if( false !== ( $breakpoint = strrpos( $string, $break ) ) ) {
337
+ $string = substr( $string, 0, $breakpoint );
338
+ }
339
+
340
+ return $string . $pad;
341
+ }
342
+
343
  ?>