PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.1.1
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.1.1
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
← All changes | WpInit/Forms.php +0 -74 10.11.1 → 11.1.1 View file →
@@ -1,74 +1,0 @@
1 -<?php
2 -
3 -namespace AcyMailing\WpInit;
4 -
5 -use AcyMailing\Classes\FormClass;
6 -
7 -class Forms
8 -{
9 - private array $formToDisplay = [];
10 -
11 - public function __construct()
12 - {
13 - $isPreview = acym_getVar('bool', 'acym_preview', false);
14 - if ($isPreview) return;
15 -
16 - if (acym_level(ACYM_ENTERPRISE)) {
17 - add_action('wp_head', [$this, 'prepareFormsToDisplay']);
18 - add_action('wp_footer', [$this, 'displayForms']);
19 - }
20 - $this->registerShortcodes();
21 - }
22 -
23 - public function prepareFormsToDisplay()
24 - {
25 - $formClass = new FormClass();
26 - $forms = $formClass->getAllFormsToDisplay();
27 -
28 - if (empty($forms)) return;
29 -
30 - $menu = acym_getMenu();
31 - if (empty($menu)) return;
32 -
33 - foreach ($forms as $form) {
34 - if (!empty($form->pages) && (in_array($menu->ID, $form->pages) || in_array('all', $form->pages))) {
35 - $this->formToDisplay[] = $formClass->renderForm($form);
36 - }
37 - }
38 -
39 - if (!empty($this->formToDisplay)) acym_initModule();
40 - }
41 -
42 - public function displayForms()
43 - {
44 - if (empty($this->formToDisplay)) return;
45 -
46 - echo implode('', $this->formToDisplay);
47 - }
48 -
49 - public function registerShortcodes()
50 - {
51 - add_shortcode('acymailing_form_shortcode', [$this, 'replaceShortcode']);
52 - }
53 -
54 - public function replaceShortcode($params)
55 - {
56 - extract(
57 - shortcode_atts(
58 - [
59 - 'id' => 0,
60 - ],
61 - $params
62 - )
63 - );
64 -
65 - if (empty($params['id'])) return;
66 -
67 - $formClass = new FormClass();
68 - $form = $formClass->getOneById($params['id']);
69 -
70 - if (empty($form->active)) return;
71 -
72 - return $formClass->renderForm($form, false, true);
73 - }
74 -}