PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 4.0.1
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v4.0.1
4.0.3 4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 341 releases
profile-builder / admin / advanced-settings / includes / shortcodes / format-date.php

format-date.php in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 4.0.1, at admin/advanced-settings/includes/shortcodes/format-date.php

40 lines 912 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // Exit if accessed directly
3 if ( ! defined( 'ABSPATH' ) ) exit;
4
5 add_shortcode( 'wppb-format-date', 'wppb_toolbox_format_date_handler' );
6 function wppb_toolbox_format_date_handler( $atts ){
7 $a = shortcode_atts( array(
8 'date' => null,
9 'format' => null,
10 ),$atts );
11
12 if ($a['date'] === null)
13 return;
14
15 if ($a['format'] === null)
16 return esc_html( $a['date'] );
17
18 $format = wppb_toolbox_sanitize_date_format( $a['format'] );
19
20 if ( $format === '' )
21 return esc_html( $a['date'] );
22
23 $date = strtotime($a['date']);
24
25 return esc_html( date( $format, $date ) );
26 }
27
28 /**
29 * Keep letters, digits, and date separators; drop markup and other symbols.
30 *
31 * @param string $format User-supplied date format.
32 * @return string
33 */
34 function wppb_toolbox_sanitize_date_format( $format ) {
35 if ( ! is_string( $format ) )
36 return '';
37
38 return preg_replace( '/[^\p{L}0-9 \-\/.,:\\\\()]/u', '', $format );
39 }
40