PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.0.3
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.0.3
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 / Core / wordpress / content.php

content.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress 11.0.3, at back/Core/wordpress/content.php

250 lines 7.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 defined('ABSPATH') || die('Restricted Access');
4
5 function acym_cmsModal(
6 bool $isIframe,
7 string $content,
8 string $buttonText,
9 bool $isButton,
10 string $modalTitle,
11 ?string $identifier = null,
12 int $width = 800,
13 int $height = 400
14 ): string {
15 // Use the WP's thickbox library
16 add_thickbox();
17
18 $class = $isButton ? ' button' : '';
19
20 if ($isIframe) {
21 return '<a href="'.$content.'&TB_iframe=true&width='.$width.'&height='.$height.'" class="thickbox'.esc_attr($class).'">'.esc_html(acym_translation($buttonText)).'</a>';
22 } else {
23 if (empty($identifier)) {
24 $identifier = 'identifier_'.acym_rand(1000, 9000);
25 }
26
27 return '<div id="'.esc_attr($identifier).'" style="display:none;">'.$content.'</div>
28 <a href="#TB_inline?width='.$width.'&height='.$height.'&inlineId='.esc_attr($identifier).'" class="thickbox'.esc_attr($class).'">'.esc_html(
29 acym_translation($buttonText)
30 ).'</a>';
31 }
32 }
33
34 function acym_CMSArticleTitle(int $id): string
35 {
36 $title = acym_loadResult('SELECT post_title FROM #__posts WHERE ID = '.intval($id));
37
38 return empty($title) ? '' : $title;
39 }
40
41 function acym_getArticleURL(int $id, bool $popup, string $text): string
42 {
43 if (empty($id)) {
44 return '';
45 }
46
47 $url = get_permalink($id);
48
49 if ($popup) {
50 $url .= (strpos($url, '?') ? '&' : '?').acym_noTemplate();
51 $url = acym_frontModal($url, $text, false);
52 } else {
53 $url = '<a title="'.acym_translation($text, true).'" href="'.esc_attr($url).'" target="_blank">'.acym_translation($text).'</a>';
54 }
55
56 return $url;
57 }
58
59 function acym_articleSelectionPage(): string
60 {
61 return admin_url('admin-ajax.php').'?action=acymailing_router&page=acymailing_configuration&ctrl=configuration&task=getarticles&'.acym_getFormToken();
62 }
63
64 function acym_getPageOverride(string $ctrl, string $view, bool $forceBackend = false): string
65 {
66 return ACYM_OVERRIDES.$ctrl.DS.$view.'.php';
67 }
68
69 function acym_cmsCleanHtml(string $html): string
70 {
71 if (strpos($html, '<!-- wp:') === false) return $html;
72
73 // Replace special WP content in inserted posts and pages
74 $elementsToRemove = [
75 'shortcode',
76 'core-embed/.*',
77 'video .*',
78 'audio .*',
79 ];
80
81 $replacements = [
82 '#<!-- wp:core-embed/vimeo.*"url":"([^"]+)".+<!-- /wp:core-embed/vimeo -->#Uis' => '{vimeo}$1{/vimeo}',
83 '#<!-- wp:core-embed/youtube.*"url":"([^"]+)".+<!-- /wp:core-embed/youtube -->#Uis' => '{youtube}$1{/youtube}',
84 '#<!-- wp:embed .*"url":"([^"]+)".+"providerNameSlug":"vimeo".+<!-- /wp:embed -->#Uis' => '{vimeo}$1{/vimeo}',
85 '#<!-- wp:embed .*"url":"([^"]+)".+"providerNameSlug":"youtube".+<!-- /wp:embed -->#Uis' => '{youtube}$1{/youtube}',
86 '#<a [^>]*wp-block-file__button[^>]*>[^<]*</a>#Uis' => '',
87 ];
88
89 foreach ($elementsToRemove as $oneElement) {
90 $replacements['#<!-- wp:'.$oneElement.' -->.*<!-- /wp:'.$oneElement.' -->#Uis'] = '';
91 }
92
93 $cleanText = preg_replace(array_keys($replacements), $replacements, $html);
94 if (!empty($cleanText)) $html = $cleanText;
95
96 // Display the WP content correctly
97 $html .= '<style type="text/css">
98 /* Handle media-text blocks */
99 .wp-block-media-text {
100 display: grid;
101 grid-template-rows: auto;
102 align-items: center;
103 grid-template-areas: "media-text-media media-text-content";
104 grid-template-columns: 50% auto;
105 }
106 .wp-block-media-text .wp-block-media-text__media {
107 grid-area: media-text-media;
108 margin: 0;
109 }
110 .wp-block-media-text .wp-block-media-text__content {
111 word-break: break-word;
112 grid-area: media-text-content;
113 padding: 0 8%;
114 }
115
116 /* Handle multi column blocks */
117 .wp-block-columns {
118 display: flex !important;
119 flex-wrap: nowrap;
120 }
121 .wp-block-columns .wp-block-column {
122 flex-basis: 100%;
123 flex-grow: 0;
124 }
125
126 /* Handle WP tables */
127 table.wp-block-table td {
128 padding: 1em 1.41575em !important;
129 }
130
131 /* Handle preformatted content */
132 .wp-block-preformatted, .wp-block-code, .wp-block-verse {
133 padding: 1.618em;
134 }
135
136 /* Handle download files */
137 .wp-block-file {
138 margin: 20px 0;
139 }
140
141 /* Handle cover blocks */
142 .wp-block-cover, .wp-block-cover-image {
143 -webkit-box-orient: horizontal;
144 -webkit-box-direction: normal;
145 -webkit-flex-flow: row wrap;
146 flex-flow: row wrap;
147 position: relative;
148 background-color: #000;
149 background-size: cover;
150 background-position: 50%;
151 min-height: 430px;
152 width: 100%;
153 margin: 0 0 1.5em;
154 display: flex;
155 justify-content: center;
156 align-items: center;
157 overflow: hidden;
158 }
159 .wp-block-cover-image.has-background-dim:before, .wp-block-cover.has-background-dim:before {
160 content: "";
161 position: absolute;
162 top: 0;
163 left: 0;
164 bottom: 0;
165 right: 0;
166 background-color: inherit;
167 opacity: .5;
168 z-index: 1;
169 }
170 .wp-block-cover p {
171 font-size: 1.618em;
172 font-weight: 300;
173 line-height: 1.618;
174 padding: 1em;
175 color: #fff !important;
176 z-index: 1;
177 }
178
179 /* Handle galleries */
180 .wp-block-gallery {
181 margin: 0 0 1.41575em;
182 display: flex;
183 flex-wrap: wrap;
184 list-style-type: none;
185 padding: 0;
186 }
187 .blocks-gallery-item {
188 margin-left: auto;
189 margin-right: auto;
190 }
191 </style>';
192
193 return $html;
194 }
195
196 function acym_getAlias(string $name): string
197 {
198 return sanitize_title_with_dashes(remove_accents($name));
199 }
200
201 function acym_getAllPages(): array
202 {
203 $allPges = get_pages();
204 if (empty($allPges)) return [];
205
206 $return = [];
207
208 foreach ($allPges as $page) {
209 $return[$page->ID] = $page->post_title;
210 }
211
212 return $return;
213 }
214
215 function acym_getArticles(string $search): array
216 {
217 $return = [];
218
219 $search_results = new WP_Query(
220 [
221 's' => $search,
222 'post_status' => 'publish',
223 'ignore_sticky_posts' => 1,
224 'post_type' => ['page', 'post'],
225 'posts_per_page' => 20,
226 ]
227 );
228
229 if ($search_results->have_posts()) {
230 while ($search_results->have_posts()) {
231 $search_results->the_post();
232 $return[] = [$search_results->post->ID, $search_results->post->post_title];
233 }
234 }
235
236 return $return;
237 }
238
239 function acym_getArticleById(int $id): array
240 {
241 $post = get_post($id);
242
243 if (empty($post)) return [];
244
245 return [
246 'id' => $post->ID,
247 'title' => $post->post_title,
248 ];
249 }
250