2020 * @subpackage Hello_Asso/public
2121 * @author HelloAsso
2222 */
23- class Hello_Asso_Public {
23+ class Hello_Asso_Public
24+ {
2425
2526 /**
2627 * The ID of this plugin.
@@ -47,19 +48,20 @@ class Hello_Asso_Public {
4748 * @param string $plugin_name The name of the plugin.
4849 * @param string $version The version of this plugin.
4950 */
50- public function __construct ( $ plugin_name , $ version ) {
51+ public function __construct ($ plugin_name , $ version )
52+ {
5153
5254 $ this ->plugin_name = $ plugin_name ;
5355 $ this ->version = $ version ;
54-
5556 }
5657
5758 /**
5859 * Register the stylesheets for the public-facing side of the site.
5960 *
6061 * @since 1.0.0
6162 */
62- public function enqueue_styles () {
63+ public function enqueue_styles ()
64+ {
6365
6466 /**
6567 * This function is provided for demonstration purposes only.
@@ -73,16 +75,16 @@ public function enqueue_styles() {
7375 * class.
7476 */
7577
76- wp_enqueue_style ( $ this ->plugin_name , esc_html (plugin_dir_url ( __FILE__ )) . 'css/hello-asso-public.css ' , array (), $ this ->version , 'all ' );
77-
78+ wp_enqueue_style ($ this ->plugin_name , esc_html (plugin_dir_url (__FILE__ )) . 'css/hello-asso-public.css ' , array (), $ this ->version , 'all ' );
7879 }
7980
8081 /**
8182 * Register the JavaScript for the public-facing side of the site.
8283 *
8384 * @since 1.0.0
8485 */
85- public function enqueue_scripts () {
86+ public function enqueue_scripts ()
87+ {
8688
8789 /**
8890 * This function is provided for demonstration purposes only.
@@ -96,56 +98,49 @@ public function enqueue_scripts() {
9698 * class.
9799 */
98100
99- wp_enqueue_script ( $ this ->plugin_name , esc_html (plugin_dir_url ( __FILE__ )) . 'js/hello-asso-public.js ' , array ( 'jquery ' ), $ this ->version , false );
100-
101+ wp_enqueue_script ($ this ->plugin_name , esc_html (plugin_dir_url (__FILE__ )) . 'js/hello-asso-public.js ' , array ('jquery ' ), $ this ->version , false );
101102 }
102103
103104 public function loadShortcode ()
104- {
105- add_shortcode ( 'helloasso ' , 'ha_shortcode ' );
105+ {
106+ add_shortcode ('helloasso ' , 'ha_shortcode ' );
106107
107108 function ha_shortcode ($ atts )
108109 {
109110 $ url = $ atts ['campaign ' ];
110111 $ type = $ atts ['type ' ];
111112 $ allowed_styles = array (
112- 'style ' => array (
113- 'width ' => array (),
114- 'height ' => array (),
115- 'border ' => array (),
113+ 'style ' => array (
114+ 'width ' => array (),
115+ 'height ' => array (),
116+ 'border ' => array (),
116117 ),
117118 );
118119
119120 $ pattern = '/^\d+px$/ ' ;
120121
121- if ($ type == "widget-bouton " )
122- {
122+ if ($ type == "widget-bouton " ) {
123123 $ height = preg_match ($ pattern , $ atts ['height ' ] ?? 0 ) ? $ atts ['height ' ] : "70px " ;
124- $ styleIframe = 'style="width:200px; height: ' . $ height . '; border:none;" ' ;
125- }
126- else if ($ type == "widget " )
127- {
124+ $ styleIframe = 'style="width:200px; height: ' . $ height . '; border:none;" ' ;
125+ } else if ($ type == "widget " ) {
128126 $ height = preg_match ($ pattern , $ atts ['height ' ] ?? 0 ) ? $ atts ['height ' ] : "750px " ;
129- $ styleIframe = 'style="width:100%; height: ' . $ height . '; border:none;" ' ;
130- }
131- else if ($ type == "widget-vignette " )
132- {
127+ $ styleIframe = 'style="width:100%; height: ' . $ height . '; border:none;" ' ;
128+ } else if ($ type == "widget-vignette " ) {
133129 $ height = preg_match ($ pattern , $ atts ['height ' ] ?? 0 ) ? $ atts ['height ' ] : "450px " ;
134- $ styleIframe = 'style="width:350px; height: ' . $ height . '; border:none;" ' ;
130+ $ styleIframe = 'style="width:350px; height: ' . $ height . '; border:none;" ' ;
135131 } else {
136132 $ type = "" ;
137133 }
138134
139- if (!str_starts_with ($ url , "https://www.helloasso.com/ " )) {
135+ if (!str_starts_with ($ url , "https://www.helloasso.com/ " ) && ! str_starts_with ( $ url , " https://www.helloasso-sandbox .com/ " )) {
140136 $ url = "" ;
141137 }
142138
143139 ob_start ();
144- ?>
145- <iframe src="<?= esc_url ($ url ); ?> <?= esc_html ($ type ); ?> " id="idIframe" <?= wp_kses ($ styleIframe , $ allowed_styles ); ?> border="0"></iframe>
146- <?php
140+ ?>
141+ <iframe src="<?= esc_url ($ url ); ?> <?= esc_html ($ type ); ?> " id="idIframe" <?= wp_kses ($ styleIframe , $ allowed_styles ); ?> border="0"></iframe>
142+ <?php
147143 return ob_get_clean ();
148144 }
149145 }
150-
151146}
0 commit comments