PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 10.1.4
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v10.1.4
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
acymailing / back / Helpers / global / module.php

module.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress 10.1.4, at back/Helpers/global/module.php

88 lines 3.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 function acym_getModuleFormName()
4 {
5 static $i = 1;
6
7 return 'formAcym'.rand(1000, 9999).$i++;
8 }
9
10 function acym_initModule($params = null, $options = [])
11 {
12 if (acym_isAjax()) {
13 return;
14 }
15
16 if (!file_exists(ACYM_ROOT.'plugins'.DS.'system'.DS.'modulesanywhere')) {
17 static $loaded = false;
18 if ($loaded) {
19 return;
20 }
21 $loaded = true;
22 }
23
24 if (!is_null($params) && method_exists($params, 'get')) {
25 $nameCaption = $params->get('nametext');
26 $emailCaption = $params->get('emailtext');
27 $jsLoading = $params->get('includejs');
28 $options['loadJsInModule'] = $jsLoading === 'module';
29 $options['defer'] = in_array($jsLoading, ['all', 'defer']);
30 $options['async'] = in_array($jsLoading, ['all', 'async']);
31 }
32
33 if (empty($nameCaption)) {
34 $nameCaption = acym_translation('ACYM_NAME');
35 }
36 if (empty($emailCaption)) {
37 $emailCaption = acym_translation('ACYM_EMAIL');
38 }
39
40 $js = "
41 if(typeof acymModule === 'undefined'){
42 var acymModule = [];
43 acymModule['emailRegex'] = /^".acym_getEmailRegex(true)."$/i;
44 acymModule['NAMECAPTION'] = '".str_replace("'", "\'", $nameCaption)."';
45 acymModule['NAME_MISSING'] = '".str_replace("'", "\'", acym_translation('ACYM_MISSING_NAME'))."';
46 acymModule['EMAILCAPTION'] = '".str_replace("'", "\'", $emailCaption)."';
47 acymModule['VALID_EMAIL'] = '".str_replace("'", "\'", acym_translation('ACYM_VALID_EMAIL'))."';
48 acymModule['VALID_EMAIL_CONFIRMATION'] = '".str_replace("'", "\'", acym_translation('ACYM_VALID_EMAIL_CONFIRMATION'))."';
49 acymModule['CAPTCHA_MISSING'] = '".str_replace("'", "\'", acym_translation('ACYM_WRONG_CAPTCHA'))."';
50 acymModule['NO_LIST_SELECTED'] = '".str_replace("'", "\'", acym_translation('ACYM_SELECT_LIST'))."';
51 acymModule['NO_LIST_SELECTED_UNSUB'] = '".str_replace("'", "\'", acym_translation('ACYM_SELECT_LIST_UNSUB'))."';
52 acymModule['ACCEPT_TERMS'] = '".str_replace("'", "\'", acym_translation('ACYM_ACCEPT_TERMS'))."';
53 }
54 ";
55
56 $config = acym_config();
57 $version = str_replace('.', '', $config->get('version'));
58
59 global $acymEmailMisspelledLoaded;
60 $spellChecker = empty($acymEmailMisspelledLoaded) && !empty($config->get('email_spellcheck'));
61 if ($spellChecker) $acymEmailMisspelledLoaded = true;
62
63 if (!empty($options['loadJsInModule'])) {
64 if ($spellChecker) echo '<script type="text/javascript" src="'.ACYM_JS.'libraries/email-misspelled.min.js?v='.$version.'"></script>';
65 echo '<script type="text/javascript" src="'.ACYM_JS.'module.min.js?v='.$version.'"></script>';
66 echo '<script type="text/javascript">'.$js.'</script>';
67 } else {
68 $scriptOptions = ['defer' => !empty($options['defer'])];
69 if (!empty($options['async'])) {
70 $scriptOptions['async'] = true;
71 }
72
73 if ($spellChecker) {
74 acym_addScript(false, ACYM_JS.'libraries/email-misspelled.min.js?v='.$version, $scriptOptions);
75 }
76 $scriptName = acym_addScript(false, ACYM_JS.'module.min.js?v='.$version, $scriptOptions);
77 acym_addScript(true, $js, array_merge($scriptOptions, ['dependencies' => ['script_name' => $scriptName]]));
78 }
79
80 if ('wordpress' === ACYM_CMS && !in_array(acym_getVar('string', 'action'), ['elementor', 'elementor_ajax'])) {
81 if ($spellChecker) wp_enqueue_style('style_email_spellchecker', ACYM_CSS.'libraries/email-misspelled.min.css?v='.$version);
82 wp_enqueue_style('style_acymailing_module', ACYM_CSS.'module.min.css?v='.$version);
83 } else {
84 if ($spellChecker) acym_addStyle(false, ACYM_CSS.'libraries/email-misspelled.min.css?v='.$version);
85 acym_addStyle(false, ACYM_CSS.'module.min.css?v='.$version);
86 }
87 }
88