PluginProbe
Plugins List / 2.6.1
Plugins List v2.6.1
trunk 0.2.1 0.2.2 1.0 2.0 2.1 2.2.7 2.3.2 2.4.4 2.5.2 2.6 2.6.1 2.7
← All changes | plugins-list.php +401 -49 2.4.42.6.1 View file →
@@ -1,15 +1,30 @@
1 1 <?php
2 2 /**
3 -Plugin Name: Plugins List
4 -Plugin URI: https://github.com/dartiss/plugins-list
5 -Description: 🔌 Allows you to insert a list of the WordPress plugins you are using into any post/page.
6 -Version: 2.4.4
7 -Author: David Artiss
8 -Author URI: https://artiss.blog
9 -Text Domain: plugins-list
10 -
11 -@package plugins-list
3 + * Plugins List
4 + *
5 + * @package plugins-list
6 + * @author David Artiss
7 + * @license GPL-2.0-or-later
8 + *
9 + * Plugin Name: Plugins List
10 + * Plugin URI: https://wordpress.org/plugins/plugins-list/
11 + * Description: 🔌 Allows you to insert a list of the WordPress plugins you are using into any post/page.
12 + * Version: 2.6.1
13 + * Requires at least: 4.6
14 + * Requires PHP: 7.4
15 + * Author: David Artiss
16 + * Author URI: https://artiss.blog
17 + * Text Domain: plugins-list
18 + * License: GPL v2 or later
19 + * License URI: http://www.gnu.org/licenses/gpl-2.0.txt
20 + *
21 + * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
22 + * General Public License version 2, as published by the Free Software Foundation. You may NOT assume
23 + * that you can use any other version of the GPL.
24 + *
25 + * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
26 + * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 27 */
13 28
14 29 define( 'DEFAULT_PLUGIN_LIST_FORMAT', '<li>{{LinkedTitle}} by {{LinkedAuthor}}.</li>' );
15 30
@@ -24,9 +39,9 @@
24 39 * @param string $links Current links.
25 40 * @param string $file File in use.
26 41 * @return string Links, now with settings added.
27 42 */
28 -function set_plugins_list_meta( $links, $file ) {
43 +function pll_set_plugins_meta( $links, $file ) {
29 44
30 45 if ( false !== strpos( $file, 'plugins-list.php' ) ) {
31 46
32 47 $links = array_merge( $links, array( '<a href="https://github.com/dartiss/plugins-list">' . __( 'Github', 'plugins-list' ) . '</a>' ) );
@@ -40,9 +55,9 @@
40 55
41 56 return $links;
42 57 }
43 58
44 -add_filter( 'plugin_row_meta', 'set_plugins_list_meta', 10, 2 );
59 +add_filter( 'plugin_row_meta', 'pll_set_plugins_meta', 10, 2 );
45 60
46 61 /**
47 62 * Main Shortcode Function
48 63 *
@@ -47,14 +62,14 @@
47 62 * Main Shortcode Function
48 63 *
49 64 * Extract shortcode parameters and call main function to output results
50 65 *
51 - * @uses get_plugins_list Get the list of plugins
66 + * @uses pll_get_plugins_list Get the list of plugins
52 67 *
53 - * @param string $paras Shortcode parameters.
54 - * @return stri Output.
68 + * @param string $paras Shortcode parameters.
69 + * @return string Output.
55 70 */
56 -function plugins_list_shortcode( $paras ) {
71 +function pll_add_shortcode( $paras ) {
57 72
58 73 $atts = shortcode_atts(
59 74 array(
60 75 'format' => '',
@@ -59,22 +74,29 @@
59 74 array(
60 75 'format' => '',
61 76 'show_inactive' => '',
62 77 'show_active' => '',
78 + 'show_recent' => '',
63 79 'cache' => '',
64 80 'nofollow' => '',
65 81 'target' => '',
66 82 'by_author' => '',
83 + 'chars' => '',
84 + 'words' => '',
85 + 'emoji' => '',
86 + 'end' => '',
67 87 ),
68 88 $paras
69 89 );
70 90
71 - $output = get_plugins_list( $atts['format'], $atts['show_inactive'], $atts['show_active'], $atts['cache'], $atts['nofollow'], $atts['target'], $atts['by_author'] );
91 + // Pass the shortcode parameters onto a function to generate the plugins list.
72 92
93 + $output = pll_get_plugins_list( $atts['format'], $atts['show_inactive'], $atts['show_active'], $atts['show_recent'], $atts['cache'], $atts['nofollow'], $atts['target'], $atts['by_author'], $atts['chars'], $atts['words'], $atts['emoji'], $atts['end'] );
94 +
73 95 return $output;
74 96 }
75 97
76 -add_shortcode( 'plugins_list', 'plugins_list_shortcode' );
98 +add_shortcode( 'plugins_list', 'pll_add_shortcode' );
77 99
78 100 /**
79 101 * Number of plugins shortcode
80 102 *
@@ -79,14 +101,14 @@
79 101 * Number of plugins shortcode
80 102 *
81 103 * Shortcode to return number of plugins
82 104 *
83 - * @uses get_plugin_number Get the number of plugins
105 + * @uses pll_get_plugin_number Get the number of plugins
84 106 *
85 - * @param string $paras Shortcode parameters.
86 - * @return string Output.
107 + * @param string $paras Shortcode parameters.
108 + * @return string Output.
87 109 */
88 -function plugin_number_shortcode( $paras ) {
110 +function pll_add_number_shortcode( $paras ) {
89 111
90 112 $atts = shortcode_atts(
91 113 array(
92 114 'active' => 'true',
@@ -95,14 +117,14 @@
95 117 ),
96 118 $paras
97 119 );
98 120
99 - $output = get_plugin_number( $atts['active'], $atts['inactive'], $atts['cache'] );
121 + $output = pll_get_plugin_number( $atts['active'], $atts['inactive'], $atts['cache'] );
100 122
101 123 return $output;
102 124 }
103 125
104 -add_shortcode( 'plugins_number', 'plugin_number_shortcode' );
126 +add_shortcode( 'plugins_number', 'add_add_number_shortcode' );
105 127
106 128 /**
107 129 * Get Plugins List
108 130 *
@@ -107,21 +129,26 @@
107 129 * Get Plugins List
108 130 *
109 131 * Get list of plugins and, optionally, format them
110 132 *
111 - * @uses format_plugin_list Format the plugin list
112 - * @uses get_plugin_list_data Get the plugin data
133 + * @uses pll_format_plugin_list Format the plugin list
134 + * @uses pll_get_data Get the plugin data
113 135 *
114 136 * @param string $format Requires format.
115 137 * @param string $show_inactive Whether to format or not.
116 138 * @param string $show_active Whether to show active or not.
139 + * @param string $show_recent Whether to show recenty active or not.
117 140 * @param string $cache Cache time.
118 141 * @param string $nofollow Whether to add nofollow to link.
119 142 * @param string $target Link target.
120 143 * @param string $by_author Which author.
144 + * @param string $characters Maximum characters for description.
145 + * @param string $words Maximum words for description.
146 + * @param string $emoji True or false, whether to strip emoji from description.
147 + * @param string $end When the description is truncated, what to place at the end of the string.
121 148 * @return string Output.
122 149 */
123 -function get_plugins_list( $format, $show_inactive, $show_active, $cache, $nofollow, $target, $by_author ) {
150 +function pll_get_plugins_list( $format, $show_inactive, $show_active, $show_recent, $cache, $nofollow, $target, $by_author, $characters, $words, $emoji, $end ) {
124 151
125 152 // Set default values.
126 153
127 154 if ( '' === $format ) {
@@ -132,8 +159,11 @@
132 159 }
133 160 if ( '' === $show_active ) {
134 161 $show_active = 'true';
135 162 }
163 + if ( '' === $show_recent ) {
164 + $show_recent = 'true';
165 + }
136 166 if ( '' === $cache ) {
137 167 $cache = 5;
138 168 }
139 169 if ( $nofollow ) {
@@ -148,12 +178,20 @@
148 178 }
149 179 if ( '' !== $by_author ) {
150 180 $by_author = 'true';
151 181 }
182 + if ( 'false' === $emoji ) {
183 + $emoji = false;
184 + } else {
185 + $emoji = true;
186 + }
187 + if ( '' === $end ) {
188 + $end = '&#8230;';
189 + }
152 190
153 191 // Get plugin data.
154 192
155 - $plugins = get_plugin_list_data( $cache );
193 + $plugins = pll_get_data( $cache );
156 194
157 195 // Sort the plugin array if required in author sequence.
158 196
159 197 if ( 'true' === $by_author ) {
@@ -158,14 +196,22 @@
158 196
159 197 if ( 'true' === $by_author ) {
160 198 uasort(
161 199 $plugins,
162 - function( $a, $b ) {
200 + function ( $a, $b ) {
163 201 return strtoupper( $a['Author'] ) <=> strtoupper( $b['Author'] );
164 202 }
165 203 );
166 204 }
167 205
206 + // Get array of recently activate plugins.
207 +
208 + if ( is_network_admin() ) {
209 + $recently_activated = get_site_option( 'recently_activated', array() );
210 + } else {
211 + $recently_activated = get_option( 'recently_activated', array() );
212 + }
213 +
168 214 // Extract each plugin and format the output.
169 215
170 216 $output = '';
171 217
@@ -170,18 +216,33 @@
170 216 $output = '';
171 217
172 218 foreach ( $plugins as $plugin_file => $plugin_data ) {
173 219
174 - if ( ( is_plugin_active( $plugin_file ) && 'true' === $show_active ) || ( ! is_plugin_active( $plugin_file ) && 'true' === $show_inactive ) ) {
220 + // Work out whether plugin is active or not.
175 221
176 - $output .= format_plugin_list( $plugin_data, $format, $nofollow, $target );
222 + $plugin_active = false;
223 + if ( is_plugin_active( $plugin_file ) ) {
224 + $plugin_active = true;
177 225 }
226 +
227 + // Was this recently active?
228 +
229 + $recently_active = false;
230 + if ( is_array( $recently_activated ) && array_key_exists( $plugin_file, $recently_activated ) ) {
231 + $recently_active = true;
232 + }
233 +
234 + // Depending on whhat was requested, format the current plugin for output.
235 +
236 + if ( ( $recently_active && 'true' === $show_recent ) || ( $plugin_active && 'true' === $show_active ) || ( ! $plugin_active && 'true' === $show_inactive ) ) {
237 +
238 + $output .= pll_format_plugin_list( $plugin_data, $format, $nofollow, $target, $characters, $words, $emoji, $end, $plugin_active );
239 + }
178 240 }
179 241
180 242 // Return the code, with HTML comments.
181 243
182 244 return "\n" . $output . "\n";
183 -
184 245 }
185 246
186 247 /**
187 248 * Get Plugin number
@@ -189,20 +250,20 @@
189 250 * Get number of plugins
190 251 *
191 252 * @since 2.2
192 253 *
193 - * @uses get_plugin_list_data Get the plugin data
254 + * @uses pll_get_data Get the plugin data
194 255 *
195 256 * @param string $show_active Whether to include active plugins or not.
196 257 * @param string $show_inactive Whether to include inactive plugins or not.
197 258 * @param string $cache Cache time.
198 - * @return string Plugin number.
259 + * @return string Plugin number.
199 260 */
200 -function get_plugin_number( $show_active, $show_inactive, $cache ) {
261 +function pll_get_plugin_number( $show_active, $show_inactive, $cache ) {
201 262
202 263 // Get plugin data.
203 264
204 - $plugins = get_plugin_list_data( $cache );
265 + $plugins = pll_get_data( $cache );
205 266
206 267 // Get count.
207 268
208 269 if ( 'true' === $show_inactive && 'true' === $show_active ) {
@@ -210,9 +271,9 @@
210 271 } else {
211 272 $output = 0;
212 273 foreach( $plugins as $plugin_file => $plugin_data ) { // @codingStandardsIgnoreLine -- require $plugin_data for array values but not doing anything with it
213 274 if ( is_plugin_active( $plugin_file ) ) {
214 - $output++;
275 + ++$output;
215 276 }
216 277 }
217 278 if ( 'true' === $show_inactive ) {
218 279 $output = count( $plugins ) - $output; }
@@ -225,14 +286,14 @@
225 286 * Get Plugins data
226 287 *
227 288 * Get plugin data and cache it
228 289 *
229 - * @uses format_plugin_list Format the plugin list.
290 + * @uses pll_format_plugin_list Format the plugin list.
230 291 *
231 292 * @param string $cache Cache time.
232 293 * @return string Plugin data.
233 294 */
234 -function get_plugin_list_data( $cache ) {
295 +function pll_get_data( $cache ) {
235 296
236 297 // Attempt to get plugin list from cache.
237 298
238 299 if ( ! $cache ) {
@@ -260,15 +321,20 @@
260 321 * Format the plugin list
261 322 *
262 323 * @uses replace_plugin_list_tags Replace the tags
263 324 *
264 - * @param string $plugin_data The plugin list.
265 - * @param string $format Format to use.
266 - * @param string $nofollow Nofollow text.
267 - * @param string $target Target text.
268 - * @return string Output.
325 + * @param string $plugin_data The plugin list.
326 + * @param string $format Format to use.
327 + * @param string $nofollow Nofollow text.
328 + * @param string $target Target text.
329 + * @param string $characters Maximum characters for description.
330 + * @param string $words Maximum words for description.
331 + * @param string $emoji True or false, whether to strip emoji from description.
332 + * @param string $end When the description is truncated, what to place at the end of the string.
333 + * @param string $plugin_active True or false, whether the plugin is active or not.
334 + * @return string Output.
269 335 */
270 -function format_plugin_list( $plugin_data, $format, $nofollow, $target ) {
336 +function pll_format_plugin_list( $plugin_data, $format, $nofollow, $target, $characters, $words, $emoji, $end, $plugin_active ) {
271 337
272 338 // Allowed tag.
273 339
274 340 $plugins_allowedtags = array(
@@ -284,14 +350,69 @@
284 350 );
285 351
286 352 // Sanitize all displayed data.
287 353
288 - $plugin_data['Title'] = wp_kses( $plugin_data['Title'], $plugins_allowedtags );
289 - $plugin_data['PluginURI'] = wp_kses( $plugin_data['PluginURI'], $plugins_allowedtags );
290 - $plugin_data['AuthorURI'] = wp_kses( $plugin_data['AuthorURI'], $plugins_allowedtags );
291 - $plugin_data['Version'] = wp_kses( $plugin_data['Version'], $plugins_allowedtags );
292 - $plugin_data['Author'] = wp_kses( $plugin_data['Author'], $plugins_allowedtags );
354 + $plugin_data['Title'] = wp_kses( $plugin_data['Title'], $plugins_allowedtags );
355 + $plugin_data['PluginURI'] = wp_kses( $plugin_data['PluginURI'], $plugins_allowedtags );
356 + $plugin_data['AuthorURI'] = wp_kses( $plugin_data['AuthorURI'], $plugins_allowedtags );
357 + $plugin_data['Version'] = wp_kses( $plugin_data['Version'], $plugins_allowedtags );
358 + $plugin_data['Author'] = wp_kses( $plugin_data['Author'], $plugins_allowedtags );
359 + $plugin_data['RequiresWP'] = wp_kses( $plugin_data['RequiresWP'], $plugins_allowedtags );
360 + $plugin_data['RequiresPHP'] = wp_kses( $plugin_data['RequiresPHP'], $plugins_allowedtags );
293 361
362 + // Get plugin activity status.
363 +
364 + if ( $plugin_active ) {
365 + $plugin_data['Active'] = __( 'Active', 'plugins-list' );
366 + } else {
367 + $plugin_data['Active'] = __( 'Inactive', 'plugins-list' );
368 + }
369 +
370 + // Strip emoji, HTML and unnecessary space from the description.
371 +
372 + if ( false === $emoji ) {
373 + $plugin_data['Description'] = remove_emoji_from_plugin_desc( $plugin_data['Description'] );
374 + }
375 + $plugin_data['Description'] = strip_spaces_from_plugin_desc( wp_strip_all_tags( $plugin_data['Description'] ) );
376 +
377 + // Truncate the description, if required.
378 +
379 + if ( '' !== $characters || '' !== $words ) {
380 +
381 + // Use WordPress function to truncate description at a set number of words (ellipsis added automatically).
382 +
383 + if ( '' !== $words ) {
384 + $word_limited = wp_trim_words( $plugin_data['Description'], $words, $end );
385 + $plugin_data['Description'] = $word_limited;
386 + }
387 +
388 + // Manually truncate description to a set number of characters. This is done cleanly, however, by doing so to
389 + // the previous space. Then an ellipsis is added.
390 +
391 + if ( '' !== $characters ) {
392 + $character_limited = $plugin_data['Description'];
393 + // Make sure the description is greater than the required length.
394 + if ( strlen( $character_limited ) > $characters ) {
395 + $space = strrpos( substr( $character_limited, 0, $characters + 1 ), ' ' );
396 +
397 + if ( false === $space ) {
398 + // If there is no space before the truncation length, just truncate.
399 + $character_limited = substr( $character_limited, 0, $characters );
400 + } else {
401 + // If there is a space within the truncated area, trim to that.
402 + $character_limited = substr( $character_limited, 0, $space );
403 + }
404 + $plugin_data['Description'] = rtrim( $character_limited ) . $end;
405 + }
406 + }
407 +
408 + // If both words and character limits are used, take whichever results in the shortest result.
409 +
410 + if ( ( '' !== $characters && '' !== $words ) && ( $word_limited < $character_limited ) ) {
411 + $plugin_data['Description'] = $word_limited;
412 + }
413 + }
414 +
294 415 // Replace the tags.
295 416
296 417 $format = replace_plugin_list_tags( $plugin_data, $format, $nofollow, $target );
297 418
@@ -319,8 +440,11 @@
319 440 '{{AuthorURI}}' => $plugin_data['AuthorURI'],
320 441 '{{Version}}' => $plugin_data['Version'],
321 442 '{{Description}}' => $plugin_data['Description'],
322 443 '{{Author}}' => $plugin_data['Author'],
444 + '{{RequiresWP}}' => $plugin_data['RequiresWP'],
445 + '{{RequiresPHP}}' => $plugin_data['RequiresPHP'],
446 + '{{Active}}' => $plugin_data['Active'],
323 447 '{{LinkedTitle}}' => "<a href='" . $plugin_data['PluginURI'] . "' title='" . $plugin_data['Title'] . "'" . $nofollow . $target . '>' . $plugin_data['Title'] . '</a>',
324 448 '{{LinkedAuthor}}' => "<a href='" . $plugin_data['AuthorURI'] . "' title='" . $plugin_data['Author'] . "'" . $nofollow . $target . '>' . $plugin_data['Author'] . '</a>',
325 449 '#Title#' => $plugin_data['Title'],
326 450 '#PluginURI#' => $plugin_data['PluginURI'],
@@ -327,8 +451,11 @@
327 451 '#AuthorURI#' => $plugin_data['AuthorURI'],
328 452 '#Version#' => $plugin_data['Version'],
329 453 '#Description#' => $plugin_data['Description'],
330 454 '#Author#' => $plugin_data['Author'],
455 + '#RequiresWP#' => $plugin_data['RequiresWP'],
456 + '#RequiresPHP#' => $plugin_data['RequiresPHP'],
457 + '#Active#' => $plugin_data['Active'],
331 458 '#LinkedTitle#' => "<a href='" . $plugin_data['PluginURI'] . "' title='" . $plugin_data['Title'] . "'" . $nofollow . $target . '>' . $plugin_data['Title'] . '</a>',
332 459 '#LinkedAuthor#' => "<a href='" . $plugin_data['AuthorURI'] . "' title='" . $plugin_data['Author'] . "'" . $nofollow . $target . '>' . $plugin_data['Author'] . '</a>',
333 460 '{{' => '<',
334 461 '}}' => '>',
@@ -336,6 +463,231 @@
336 463 '}' => '>',
337 464 )
338 465 );
339 466
467 + // Remove all HTML tags other than those used for formatting.
468 +
469 + $allowed_tags = array(
470 + 'a' => array(
471 + 'href' => array(),
472 + 'hreflang' => array(),
473 + 'rel' => array(),
474 + 'target' => array(),
475 + 'type' => array(),
476 + 'class' => array(),
477 + 'style' => array(),
478 + ),
479 + 'b' => array(),
480 + 'big' => array(),
481 + 'blockquote' => array(
482 + 'cite' => array(),
483 + 'class' => array(),
484 + 'style' => array(),
485 + ),
486 + 'br' => array(),
487 + 'caption' => array(),
488 + 'center' => array(),
489 + 'cite' => array(),
490 + 'code' => array(
491 + 'pre' => array(),
492 + 'class' => array(),
493 + 'style' => array(),
494 + ),
495 + 'col' => array(
496 + 'span' => array(),
497 + 'class' => array(),
498 + 'style' => array(),
499 + ),
500 + 'colgroup' => array(
501 + 'span' => array(),
502 + 'class' => array(),
503 + 'style' => array(),
504 + ),
505 + 'div' => array(
506 + 'class' => array(),
507 + 'style' => array(),
508 + ),
509 + 'em' => array(
510 + 'class' => array(),
511 + 'style' => array(),
512 + ),
513 + 'font' => array(
514 + 'class' => array(),
515 + 'style' => array(),
516 + ),
517 + 'h1' => array(
518 + 'class' => array(),
519 + 'style' => array(),
520 + ),
521 + 'h2' => array(
522 + 'class' => array(),
523 + 'style' => array(),
524 + ),
525 + 'h3' => array(
526 + 'class' => array(),
527 + 'style' => array(),
528 + ),
529 + 'h4' => array(
530 + 'class' => array(),
531 + 'style' => array(),
532 + ),
533 + 'h5' => array(
534 + 'class' => array(),
535 + 'style' => array(),
536 + ),
537 + 'h6' => array(
538 + 'class' => array(),
539 + 'style' => array(),
540 + ),
541 + 'hr' => array(
542 + 'class' => array(),
543 + 'style' => array(),
544 + ),
545 + 'i' => array(
546 + 'class' => array(),
547 + 'style' => array(),
548 + ),
549 + 'img' => array(
550 + 'src' => array(),
551 + 'alt' => array(),
552 + 'class' => array(),
553 + 'style' => array(),
554 + ),
555 + 'li' => array(
556 + 'class' => array(),
557 + 'style' => array(),
558 + ),
559 + 'ol' => array(
560 + 'start' => array(),
561 + 'type' => array(),
562 + 'class' => array(),
563 + 'style' => array(),
564 + ),
565 + 'p' => array(
566 + 'class' => array(),
567 + 'style' => array(),
568 + ),
569 + 'pre' => array(
570 + 'code' => array(),
571 + 'samp' => array(),
572 + 'class' => array(),
573 + 'style' => array(),
574 + ),
575 + 'q' => array(
576 + 'cite' => array(),
577 + 'class' => array(),
578 + 'style' => array(),
579 + ),
580 + 's' => array(
581 + 'class' => array(),
582 + 'style' => array(),
583 + ),
584 + 'small' => array(
585 + 'class' => array(),
586 + 'style' => array(),
587 + ),
588 + 'span' => array(
589 + 'class' => array(),
590 + 'style' => array(),
591 + ),
592 + 'strike' => array(
593 + 'class' => array(),
594 + 'style' => array(),
595 + ),
596 + 'strong' => array(
597 + 'class' => array(),
598 + 'style' => array(),
599 + ),
600 + 'style' => array(
601 + 'type' => array(),
602 + 'class' => array(),
603 + 'style' => array(),
604 + ),
605 + 'sub' => array(
606 + 'class' => array(),
607 + 'style' => array(),
608 + ),
609 + 'sup' => array(
610 + 'class' => array(),
611 + 'style' => array(),
612 + ),
613 + 'table' => array(
614 + 'class' => array(),
615 + 'style' => array(),
616 + ),
617 + 'td' => array(
618 + 'colspan' => array(),
619 + 'headers' => array(),
620 + 'rowspan' => array(),
621 + 'class' => array(),
622 + 'style' => array(),
623 + ),
624 + 'th' => array(
625 + 'colspan' => array(),
626 + 'headers' => array(),
627 + 'rowspan' => array(),
628 + 'scope' => array(),
629 + 'class' => array(),
630 + 'style' => array(),
631 + ),
632 + 'tr' => array(
633 + 'class' => array(),
634 + 'style' => array(),
635 + ),
636 + 'u' => array(
637 + 'class' => array(),
638 + 'style' => array(),
639 + ),
640 + 'ul' => array(
641 + 'class' => array(),
642 + 'style' => array(),
643 + ),
644 + );
645 +
646 + $format = wp_kses( $format, $allowed_tags );
647 +
340 648 return $format;
649 +}
650 +
651 +/**
652 + * Remove emoji
653 + *
654 + * Function to strip emoji from the plugin description.
655 + *
656 + * @param string $description The plugin description.
657 + * @return string Stripped description.
658 + */
659 +function remove_emoji_from_plugin_desc( $description ) {
660 +
661 + $symbols = "\x{1F100}-\x{1F1FF}" // Enclosed Alphanumeric Supplement.
662 + . "\x{1F300}-\x{1F5FF}" // Miscellaneous Symbols and Pictographs.
663 + . "\x{1F600}-\x{1F64F}" // Emoticons.
664 + . "\x{1F680}-\x{1F6FF}" // Transport And Map Symbols.
665 + . "\x{1F900}-\x{1F9FF}" // Supplemental Symbols and Pictographs.
666 + . "\x{2600}-\x{26FF}" // Miscellaneous Symbols.
667 + . "\x{2700}-\x{27BF}"; // Dingbats.
668 +
669 + $description = preg_replace( '/[' . $symbols . ']+/u', '', $description );
670 +
671 + return $description;
672 +}
673 +
674 +/**
675 + * Strip spaces
676 + *
677 + * Function to strip extra spaces from the plugin description.
678 + *
679 + * @param string $description The plugin description.
680 + * @return string Stripped description.
681 + */
682 +function strip_spaces_from_plugin_desc( $description ) {
683 +
684 + $continue = true;
685 + while ( true === $continue ) {
686 + $replace = str_replace( ' ', ' ', $description );
687 + if ( $replace === $description ) {
688 + $continue = false;
689 + }
690 + $description = $replace;
691 + }
692 + return trim( $description );
341 693 }