2020 * @subpackage Hello_Asso/admin
2121 * @author HelloAsso
2222 */
23- class Hello_Asso_Admin {
23+ class Hello_Asso_Admin
24+ {
2425
2526 /**
2627 * The ID of this plugin.
@@ -47,7 +48,8 @@ class Hello_Asso_Admin {
4748 * @param string $version The version of this plugin.
4849 * @since 1.0.0
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 ;
@@ -58,7 +60,8 @@ public function __construct($plugin_name, $version) {
5860 *
5961 * @since 1.0.0
6062 */
61- public function enqueue_styles () {
63+ public function enqueue_styles ()
64+ {
6265
6366 /**
6467 * This function is provided for demonstration purposes only.
@@ -75,7 +78,8 @@ public function enqueue_styles() {
7578 wp_enqueue_style ($ this ->plugin_name , esc_url (plugin_dir_url (__FILE__ )) . 'css/hello-asso-admin.css ' , array (), $ this ->version , 'all ' );
7679 }
7780
78- public function add_menu () {
81+ public function add_menu ()
82+ {
7983 $ urlIcon = esc_url (plugin_dir_url (__FILE__ )) . 'img/icon-28x28.svg ' ;
8084 add_menu_page ('HelloAsso ' , 'HelloAsso ' , 'manage_options ' , 'hello-asso ' , 'content_dashboard ' , $ urlIcon , 10 );
8185
@@ -88,7 +92,8 @@ public function add_menu() {
8892 'content_dashboard ' //callback function
8993 );
9094
91- function content_dashboard () {
95+ function content_dashboard ()
96+ {
9297 require ('view/dashboard.php ' );
9398 }
9499
@@ -109,17 +114,6 @@ function content_dashboard() {
109114 $ incrementArray = 1 ;
110115 }
111116
112- if (strtolower ($ campain ['formType ' ]) == "event " ) {
113-
114- $ startDate = $ campain ['startDate ' ] ?? '' ;
115- if (time () > strtotime ($ startDate )) {
116- $ incrementArray = 0 ;
117- } else {
118- $ incrementArray = 1 ;
119- }
120- }
121-
122-
123117 if ($ incrementArray == 1 ) {
124118 $ nbCampaign ++;
125119 }
@@ -238,22 +232,27 @@ function content_dashboard() {
238232 );
239233 }
240234
241- function content_campaigns () {
235+ function content_campaigns ()
236+ {
242237 require ('view/campaign.php ' );
243238 }
244239
245- function error_1 () {
240+ function error_1 ()
241+ {
246242 require ('view/error_1.php ' );
247243 }
248244
249- function error_2 () {
245+ function error_2 ()
246+ {
250247 require ('view/error_2.php ' );
251248 }
252249 }
253250
254- public function add_to_gutenberg () {
251+ public function add_to_gutenberg ()
252+ {
255253
256- function loadGutenbergBlock () {
254+ function loadGutenbergBlock ()
255+ {
257256 wp_enqueue_script (
258257 'ha-gutenberg ' ,
259258 esc_url (plugin_dir_url (__FILE__ )) . 'js/ha-gutenberg.js ' ,
@@ -266,8 +265,10 @@ function loadGutenbergBlock() {
266265 }
267266
268267
269- public function add_button_tinymce () {
270- function wporg_add_custom_box () {
268+ public function add_button_tinymce ()
269+ {
270+ function wporg_add_custom_box ()
271+ {
271272 $ screens = ['post ' , 'page ' ];
272273 foreach ($ screens as $ screen ) {
273274 add_meta_box (
@@ -281,19 +282,20 @@ function wporg_add_custom_box() {
281282
282283 add_action ('add_meta_boxes ' , 'wporg_add_custom_box ' );
283284
284- function wporg_custom_box_html ($ post ) {
285- ?>
286- <div id="ha-popup" class="ha-overlay">
287- <div class="ha-popup">
288- <main>
289- <a class="close" href="#">×</a>
290- <button type="button" class="ha-btn ha-btn-secondary ha-return" style="display: none;"
291- onclick="haReturn()">
292- <img src="<?= esc_url (plugin_dir_url (__FILE__ )); ?> view/icons/back.svg"/> Retour
293- </button>
294- <section class="content-tab" id="content1"></section>
295- </div>
296- </div>
285+ function wporg_custom_box_html ($ post )
286+ {
287+ ?>
288+ <div id="ha-popup" class="ha-overlay">
289+ <div class="ha-popup">
290+ <main>
291+ <a class="close" href="#">×</a>
292+ <button type="button" class="ha-btn ha-btn-secondary ha-return" style="display: none;"
293+ onclick="haReturn()">
294+ <img src="<?= esc_url (plugin_dir_url (__FILE__ )); ?> view/icons/back.svg" /> Retour
295+ </button>
296+ <section class="content-tab" id="content1"></section>
297+ </div>
298+ </div>
297299 <?php
298300 if (get_option ('ha-slug ' ) == '' ) {
299301 $ pageWidget = "ha-no-sync " ;
@@ -313,52 +315,52 @@ function wporg_custom_box_html($post) {
313315 }
314316 }
315317 ?>
316- <a href="#ha-popup" id="ha-popup-open"
317- onclick="loadViewCampaign('<?= esc_url (admin_url ()); ?> admin.php?page=<?= esc_html ($ pageWidget ); ?> &from=tinymce', '<?= esc_html ($ type ); ?> ')">Charger
318- mes campagnes</a>
318+ <a href="#ha-popup" id="ha-popup-open"
319+ onclick="loadViewCampaign('<?= esc_url (admin_url ()); ?> admin.php?page=<?= esc_html ($ pageWidget ); ?> &from=tinymce', '<?= esc_html ($ type ); ?> ')">Charger
320+ mes campagnes</a>
319321
320- <?php
322+ <?php
321323 }
322324
323325
324326 add_action ('media_buttons ' , function ($ editor_id ) { ?>
325- <span style="display: inline-block">
327+ <span style="display: inline-block">
326328 <div class="ha-dropdown">
327329 <a href="#" onclick="ha_dropdown()" class="ha-dropbtn ha-open-dropdown">
328330 <span class="ha-open-dropdown" style="margin-right: 8px;">Code court</span>
329331 <svg xmlns="http://www.w3.org/2000/svg" class="ha-open-dropdown" viewBox="0 0 200 43.5"
330- style="width: 80px;">
332+ style="width: 80px;">
331333 <style>
332334 .st38 {
333- fill: #fff;
334- }
335+ fill: #fff;
336+ }
335337 </style>
336338 <path d="M71.1 19.3v13.3h-6.6v-12c0-1.4-.4-1.8-1-1.8-.7 0-1.5.6-2.2 1.8v12h-6.6v-25l6.6-.7v9.4c1.5-1.6 3-2.3 5-2.3 3-.1 4.8 1.9 4.8 5.3zM90.3 25.5H79.6c.4 2.6 1.6 3 3.6 3 1.3 0 2.5-.5 4-1.6l2.7 3.7c-2 1.7-4.7 2.7-7.3 2.7-6.5 0-9.6-4.1-9.6-9.6 0-5.3 3-9.7 8.9-9.7 5.2 0 8.7 3.4 8.7 9.4-.1.5-.2 1.4-.3 2.1zm-6.3-4c0-1.8-.4-3.3-2.1-3.3-1.4 0-2.1.8-2.4 3.6H84v-.3zM92.1 27.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9 3.4 1.1 5.2 2.5 5.2 5.8 0 3.7-3.5 6.2-8.4 6.2-3.1 0-6-1.1-7.8-2.9l3.1-3.5c1.3 1 2.9 1.8 4.5 1.8 1.2 0 1.9-.4 1.9-1.1 0-.9-.4-1.1-3.4-2-3.3-1-5.2-2.9-5.2-5.8 0-3.2 2.8-5.8 7.7-5.8 2.6-.1 5.1.8 6.8 2.3zM200 23.6c0 5.9-3.5 9.6-9.2 9.6-5.6 0-9.2-3.4-9.2-9.7 0-5.9 3.5-9.6 9.2-9.6 5.6 0 9.2 3.5 9.2 9.7zm-11.5 0c0 3.6.7 4.9 2.4 4.9 1.6 0 2.4-1.4 2.4-4.9 0-3.6-.7-4.9-2.4-4.9s-2.5 1.5-2.4 4.9z"
337- class="st38"/>
339+ class="st38" />
338340 <linearGradient id="SVGID_1_" x1="4.322" x2="24.268" y1="33.651" y2="-.503"
339- gradientTransform="matrix(1 0 0 -1 0 44.736)"
340- gradientUnits="userSpaceOnUse">
341- <stop offset="0" stop-color="#498a63"/>
342- <stop offset=".25" stop-color="#61b984"/>
341+ gradientTransform="matrix(1 0 0 -1 0 44.736)"
342+ gradientUnits="userSpaceOnUse">
343+ <stop offset="0" stop-color="#498a63" />
344+ <stop offset=".25" stop-color="#61b984" />
343345 </linearGradient>
344346 <path fill="url(#SVGID_1_)"
345- d="M12.9 34.9c-6.6-7.6-2.2-26.8.6-26.8C8.1 7.9-1.1 11.5.2 24.4c1.5 12 12.3 20.4 24.1 18.9 3.8-.5 7.3-2 10.3-4.3-10.4 7.5-17.4.8-21.7-4.1z"/>
347+ d="M12.9 34.9c-6.6-7.6-2.2-26.8.6-26.8C8.1 7.9-1.1 11.5.2 24.4c1.5 12 12.3 20.4 24.1 18.9 3.8-.5 7.3-2 10.3-4.3-10.4 7.5-17.4.8-21.7-4.1z" />
346348 <linearGradient id="SVGID_2_" x1="19.889" x2="40.524" y1="3.627" y2="36.697"
347- gradientTransform="matrix(1 0 0 -1 0 44.736)"
348- gradientUnits="userSpaceOnUse">
349- <stop offset="0" stop-color="#89356d"/>
350- <stop offset=".21" stop-color="#b94794"/>
349+ gradientTransform="matrix(1 0 0 -1 0 44.736)"
350+ gradientUnits="userSpaceOnUse">
351+ <stop offset="0" stop-color="#89356d" />
352+ <stop offset=".21" stop-color="#b94794" />
351353 </linearGradient>
352354 <path fill="url(#SVGID_2_)"
353- d="M37.2 21.9C31.7 33 14.8 37.7 12.9 34.8c3.3 4.9 11.5 11.6 21.8 4 9.4-7.3 11.1-21 3.8-30.5-2.3-3-5.4-5.3-8.9-6.8 11.7 5.3 10.5 14.6 7.6 20.4z"/>
355+ d="M37.2 21.9C31.7 33 14.8 37.7 12.9 34.8c3.3 4.9 11.5 11.6 21.8 4 9.4-7.3 11.1-21 3.8-30.5-2.3-3-5.4-5.3-8.9-6.8 11.7 5.3 10.5 14.6 7.6 20.4z" />
354356 <linearGradient id="SVGID_3_" x1="3.242" x2="37.689" y1="35.782" y2="23.384"
355- gradientTransform="matrix(1 0 0 -1 0 44.736)"
356- gradientUnits="userSpaceOnUse">
357- <stop offset=".6" stop-color="#f59c1c"/>
358- <stop offset="1" stop-color="#c7702b"/>
357+ gradientTransform="matrix(1 0 0 -1 0 44.736)"
358+ gradientUnits="userSpaceOnUse">
359+ <stop offset=".6" stop-color="#f59c1c" />
360+ <stop offset="1" stop-color="#c7702b" />
359361 </linearGradient>
360362 <path fill="url(#SVGID_3_)"
361- d="M13.5 8.1c11.9-1.3 25.4 11 23.7 13.9 3.3-5.8 4.1-15.1-7.5-20.4C18.6-2.9 6 2.5 1.6 13.7.2 17.2-.3 21 .2 24.7-.6 11.9 9.1 8.5 13.5 8.1z"/>
363+ d="M13.5 8.1c11.9-1.3 25.4 11 23.7 13.9 3.3-5.8 4.1-15.1-7.5-20.4C18.6-2.9 6 2.5 1.6 13.7.2 17.2-.3 21 .2 24.7-.6 11.9 9.1 8.5 13.5 8.1z" />
362364 </svg>
363365 </a>
364366 <div id="ha-dropdown" class="ha-dropdown-content">
@@ -384,22 +386,22 @@ class="st38"/>
384386 }
385387 ?>
386388 <a href="#ha-popup"
387- onclick="loadViewCampaign('<?= esc_url (admin_url ()); ?> admin.php?page=<?= esc_html ($ pageWidget ); ?> &from=tinymce', '<?= esc_html ($ type ); ?> ')">Charger mes campagnes</a>
389+ onclick="loadViewCampaign('<?= esc_url (admin_url ()); ?> admin.php?page=<?= esc_html ($ pageWidget ); ?> &from=tinymce', '<?= esc_html ($ type ); ?> ')">Charger mes campagnes</a>
388390 </div>
389391 </div>
390392 </span>
391- <div id="ha-popup" class="ha-overlay">
392- <div class="ha-popup">
393- <main>
394- <a class="close" href="#">×</a>
395- <button type="button" class="ha-btn ha-btn-secondary ha-return" style="display: none;"
396- onclick="haReturn()">
397- <img src="<?= esc_url (plugin_dir_url (__FILE__ )); ?> view/icons/back.svg"/> Retour
398- </button>
399- <section class="content-tab" id="content1"></section>
400- </div>
401- </div>
402- <?php
393+ <div id="ha-popup" class="ha-overlay">
394+ <div class="ha-popup">
395+ <main>
396+ <a class="close" href="#">×</a>
397+ <button type="button" class="ha-btn ha-btn-secondary ha-return" style="display: none;"
398+ onclick="haReturn()">
399+ <img src="<?= esc_url (plugin_dir_url (__FILE__ )); ?> view/icons/back.svg" /> Retour
400+ </button>
401+ <section class="content-tab" id="content1"></section>
402+ </div>
403+ </div>
404+ <?php
403405 });
404406 }
405407
@@ -408,7 +410,8 @@ class="st38"/>
408410 *
409411 * @since 1.0.0
410412 */
411- public function enqueue_scripts () {
413+ public function enqueue_scripts ()
414+ {
412415
413416 /**
414417 * This function is provided for demonstration purposes only.
@@ -436,12 +439,14 @@ public function enqueue_scripts() {
436439 }
437440
438441
439- public function loadAjax () {
442+ public function loadAjax ()
443+ {
440444
441445 add_action ('wp_ajax_ha_ajax ' , 'ha_ajax ' );
442446 add_action ('wp_ajax_nopriv_ha_ajax ' , 'ha_ajax ' );
443447
444- function sanitizeArray ($ data = array ()) {
448+ function sanitizeArray ($ data = array ())
449+ {
445450 if (!is_array ($ data ) || !count ($ data )) {
446451 return array ();
447452 }
@@ -456,10 +461,11 @@ function sanitizeArray($data = array()) {
456461 return $ data ;
457462 }
458463
459- function ha_ajax () {
464+ function ha_ajax ()
465+ {
460466 check_ajax_referer ('helloassosecuritytoken11 ' , 'security ' );
461-
462- if ( ! is_user_logged_in () || ! current_user_can ('manage_options ' ) ) {
467+
468+ if (! is_user_logged_in () || ! current_user_can ('manage_options ' )) {
463469 wp_die ('Vous n’avez pas les droits nécessaires pour exécuter cette action. ' );
464470 }
465471
@@ -490,7 +496,6 @@ function ha_ajax() {
490496 // increade current campain with campain
491497 $ campaign = array_merge ($ currentCampain , $ campaign );
492498 update_option ('ha-campaign ' , $ campaign );
493-
494499 } else {
495500 echo 'Erreur de format des données ' ;
496501 }
0 commit comments