PluginProbe
Post Grid Gutenberg Blocks – PostX / 2.7.8
Post Grid Gutenberg Blocks – PostX v2.7.8
5.0.39 5.0.38 5.0.37 5.0.36 5.0.35 5.0.34 5.0.33 5.0.32 5.0.31 5.0.30 5.0.29 5.0.28 5.0.27 5.0.26 5.0.25 5.0.23 5.0.24 5.0.22 5.0.21 5.0.20 5.0.19 5.0.18 5.0.17 2.1.1 2.1.2 All 237 releases
ultimate-post / addons / builder / blocks / Post_Content.php

Post_Content.php in Post Grid Gutenberg Blocks – PostX 2.7.8, at addons/builder/blocks/Post_Content.php

329 lines 12.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ULTP\blocks;
3
4 defined('ABSPATH') || exit;
5
6 class Post_Content {
7 public function __construct() {
8 add_action('init', array($this, 'register'));
9 }
10 public function get_attributes($default = false) {
11
12 $attributes = array(
13 'blockId' => [
14 'type' => 'string',
15 'default' => '',
16 ],
17
18 /*============================
19 Post Content Settings
20 ============================*/
21 'inheritWidth' => [
22 'type' => 'boolean',
23 'default' => false,
24 'style' => [
25 (object)[
26 'selector'=>'{{ULTP}} .ultp-block-wrapper .ultp-builder-content { margin:0 auto; max-width: 700px; width:100%;}'
27 ],
28 ],
29 ],
30 'contentWidth' => [
31 'type' => 'object',
32 'default' => (object)['lg' =>'', 'ulg' =>'px'],
33 'style' => [
34 (object)[
35 'depends' => [
36 (object)['key'=>'inheritWidth','condition'=>'!=','value'=>true],
37 ],
38 'selector'=>'{{ULTP}} .ultp-block-wrapper .ultp-builder-content {margin: 0 auto; max-width:{{contentWidth}}; width:100%}'
39 ],
40 ],
41 ],
42 'descColor' => [
43 'type' => 'string',
44 'default' => '',
45 'style' => [
46 (object)[
47 'selector'=>'{{ULTP}} .ultp-block-wrapper .ultp-builder-content, {{ULTP}} .ultp-block-wrapper .ultp-builder-content p {color:{{descColor}} !important;}'
48 ],
49 ],
50 ],
51 'descTypo' => [
52 'type' => 'object',
53 'default' => (object)['openTypography' => 0,'size' => (object)['lg' => '14', 'unit' => 'px'], 'height' => (object)['lg' => '', 'unit' => 'px'],'decoration' => 'none', 'transform' => '', 'family'=>'','weight'=>''],
54 'style' => [
55 (object)[
56 'selector'=>'{{ULTP}} .ultp-block-wrapper .ultp-builder-content, html :where(.editor-styles-wrapper) {{ULTP}} .ultp-block-wrapper .ultp-builder-content p'
57 ],
58 ],
59 ],
60 "contentAlign" => [
61 "type" => "string",
62 "default" => "0 auto",
63 'style' => [
64 (object)[
65 'depends' => [
66 (object)['key'=>'inheritWidth','condition'=>'!=','value'=>true],
67 ],
68 'selector'=>'{{ULTP}} .ultp-block-wrapper .ultp-builder-content {margin:{{contentAlign}} }'
69 ],
70 ],
71 ],
72
73
74 /*============================
75 Drop Cap Settings
76 ============================*/
77 'showCap' => [
78 'type' => 'boolean',
79 'default' => false,
80 ],
81 'firstCharSize' => [
82 'type' => 'string',
83 'default' => '110',
84 'style' => [
85 (object)[
86 'depends' => [
87 (object)['key'=>'showCap','condition'=>'==','value'=>true],
88 ],
89 'selector'=>'{{ULTP}} .ultp-block-wrapper > .ultp-builder-content > p:first-child::first-letter {font-size:{{firstCharSize}}px;float:left;}'
90 ],
91 ],
92 ],
93 'firstCharXSpace' => [
94 'type' => 'string',
95 'default' => '25',
96 'style' => [
97 (object)[
98 'depends' => [
99 (object)['key'=>'showCap','condition'=>'==','value'=>true],
100 ],
101 'selector'=>'{{ULTP}} .ultp-block-wrapper > .ultp-builder-content > p:first-child::first-letter {margin-right:{{firstCharXSpace}}px;}'
102 ],
103 ],
104 ],
105 'firstCharYSpace' => [
106 'type' => 'string',
107 'default' => '100',
108 'style' => [
109 (object)[
110 'depends' => [
111 (object)['key'=>'showCap','condition'=>'==','value'=>true],
112 ],
113 'selector'=>'{{ULTP}} .ultp-block-wrapper > .ultp-builder-content > p:first-child::first-letter {line-height:{{firstCharYSpace}}px;}'
114 ],
115 ],
116 ],
117 'firstLatterColor' => [
118 'type' => 'string',
119 'default' => '',
120 'style' => [
121 (object)[
122 'depends' => [
123 (object)['key'=>'showCap','condition'=>'==','value'=>true],
124 ],
125 'selector'=>'{{ULTP}} .ultp-block-wrapper > .ultp-builder-content > p:first-child::first-letter {color:{{firstLatterColor}};}'
126 ],
127 ],
128 ],
129
130
131 //--------------------------
132 // Advanced Settings
133 //--------------------------
134 'advanceId' => [
135 'type' => 'string',
136 'default' => '',
137 ],
138 'advanceZindex' => [
139 'type' => 'number',
140 'default' => '',
141 'style' => [
142 (object)[
143 'selector' => '{{ULTP}} {z-index:{{advanceZindex}};}'
144 ],
145 ],
146 ],
147 'wrapMargin' => [
148 'type' => 'object',
149 'default' => (object)['lg' =>(object)['top' => '','bottom' => '', 'unit' =>'px']],
150 'style' => [
151 (object)[
152 'selector'=>'{{ULTP}} .ultp-block-wrapper { margin:{{wrapMargin}}; }'
153 ],
154 ],
155 ],
156 'wrapOuterPadding' => [
157 'type' => 'object',
158 'default' => (object)['lg' =>(object)['top' => '','bottom' => '','left' => '', 'right' => '', 'unit' =>'px']],
159 'style' => [
160 (object)[
161 'selector'=>'{{ULTP}} .ultp-block-wrapper { padding:{{wrapOuterPadding}}; }'
162 ],
163 ],
164 ],
165 'wrapBg' => [
166 'type' => 'object',
167 'default' => (object)['openColor' => 0, 'type' => 'color', 'color' => '#f5f5f5'],
168 'style' => [
169 (object)[
170 'selector'=>'{{ULTP}} .ultp-block-wrapper'
171 ],
172 ],
173 ],
174 'wrapBorder' => [
175 'type' => 'object',
176 'default' => (object)['openBorder'=>0, 'width' =>(object)['top' => 1, 'right' => 1, 'bottom' => 1, 'left' => 1],'color' => '#009fd4','type' => 'solid'],
177 'style' => [
178 (object)[
179 'selector'=>'{{ULTP}} .ultp-block-wrapper'
180 ],
181 ],
182 ],
183 'wrapShadow' => [
184 'type' => 'object',
185 'default' => (object)['openShadow' => 0, 'width' => (object)['top' => 1, 'right' => 1, 'bottom' => 1, 'left' => 1],'color' => '#009fd4'],
186 'style' => [
187 (object)[
188 'selector'=>'{{ULTP}} .ultp-block-wrapper'
189 ],
190 ],
191 ],
192 'wrapRadius' => [
193 'type' => 'object',
194 'default' => (object)['lg' =>'', 'unit' =>'px'],
195 'style' => [
196 (object)[
197 'selector'=>'{{ULTP}} .ultp-block-wrapper { border-radius:{{wrapRadius}}; }'
198 ],
199 ],
200 ],
201 'wrapHoverBackground' => [
202 'type' => 'object',
203 'default' => (object)['openColor' => 0, 'type' => 'color', 'color' => '#037fff'],
204 'style' => [
205 (object)[
206 'selector'=>'{{ULTP}} .ultp-block-wrapper:hover'
207 ],
208 ],
209 ],
210 'wrapHoverBorder' => [
211 'type' => 'object',
212 'default' => (object)['openBorder'=>0, 'width' => (object)['top' => 1, 'right' => 1, 'bottom' => 1, 'left' => 1],'color' => '#009fd4','type' => 'solid'],
213 'style' => [
214 (object)[
215 'selector'=>'{{ULTP}} .ultp-block-wrapper:hover'
216 ],
217 ],
218 ],
219 'wrapHoverRadius' => [
220 'type' => 'object',
221 'default' => (object)['lg' =>'', 'unit' =>'px'],
222 'style' => [
223 (object)[
224 'selector'=>'{{ULTP}} .ultp-block-wrapper:hover { border-radius:{{wrapHoverRadius}}; }'
225 ],
226 ],
227 ],
228 'wrapHoverShadow' => [
229 'type' => 'object',
230 'default' => (object)['openShadow' => 0, 'width' => (object)['top' => 1, 'right' => 1, 'bottom' => 1, 'left' => 1],'color' => '#009fd4'],
231 'style' => [
232 (object)[
233 'selector'=>'{{ULTP}} .ultp-block-wrapper:hover'
234 ],
235 ],
236 ],
237 'hideExtraLarge' => [
238 'type' => 'boolean',
239 'default' => false,
240 'style' => [
241 (object)[
242 'selector' => '{{ULTP}} {display:none;}'
243 ],
244 ],
245 ],
246 'hideDesktop' => [
247 'type' => 'boolean',
248 'default' => false,
249 'style' => [
250 (object)[
251 'selector' => '{{ULTP}} {display:none;}'
252 ],
253 ],
254 ],
255 'hideTablet' => [
256 'type' => 'boolean',
257 'default' => false,
258 'style' => [
259 (object)[
260 'selector' => '{{ULTP}} {display:none;}'
261 ],
262 ],
263 ],
264 'hideMobile' => [
265 'type' => 'boolean',
266 'default' => false,
267 'style' => [
268 (object)[
269 'selector' => '{{ULTP}} {display:none;}'
270 ],
271 ],
272 ],
273 'advanceCss' => [
274 'type' => 'string',
275 'default' => '',
276 'style' => [
277 (object)[
278 'selector' => '{{ULTP}} {display:none;}'
279 ],
280 ],
281 ],
282 );
283
284 if ($default) {
285 $temp = array();
286 foreach ($attributes as $key => $value) {
287 if (isset($value['default'])) {
288 $temp[$key] = $value['default'];
289 }
290 }
291 return $temp;
292 } else {
293 return $attributes;
294 }
295 }
296
297 public function register() {
298 register_block_type( 'ultimate-post/post-content',
299 array(
300 'editor_script' => 'ultp-blocks-editor-script',
301 'editor_style' => 'ultp-blocks-editor-css',
302 'attributes' => $this->get_attributes(),
303 'render_callback' => array($this, 'content')
304 )
305 );
306 }
307 public function content($attr, $noAjax) {
308 $block_name = 'post-content';
309 $wrapper_before = $wrapper_after = $content = '';
310
311 $post_id = get_the_ID();
312 $post_content = get_the_content();
313 $post_type = get_post_type();
314 if ($post_type != 'ultp_builder' && $post_type != 'revision') {
315 $post_content = apply_filters('the_content', $post_content);
316 $post_content = str_replace(']]>', ']]&gt;', $post_content);
317 }
318 if ($post_content) {
319 $wrapper_before .= '<div '.($attr['advanceId']?'id="'.$attr['advanceId'].'" ':'').' class="wp-block-ultimate-post-'.$block_name.' ultp-block-'.$attr["blockId"].(isset($attr["className"])?' '.$attr["className"]:'').''.(isset($attr["align"])? ' align' .$attr["align"]:'').'">';
320 $wrapper_before .= '<div class="ultp-block-wrapper">';
321 $content .= '<div class="ultp-builder-content" data-postid="'.$post_id.'">';
322 $content .= $post_content;
323 $content .= '</div>';
324 $wrapper_after .= '</div>';
325 $wrapper_after .= '</div>';
326 }
327 return $wrapper_before.$content.$wrapper_after;
328 }
329 }