PluginProbe
Post Grid Gutenberg Blocks – PostX / 4.0.3
Post Grid Gutenberg Blocks – PostX v4.0.3
5.0.41 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 All 238 releases
ultimate-post / addons / divi / divi.php

divi.php in Post Grid Gutenberg Blocks – PostX 4.0.3, at addons/divi/divi.php

73 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 add_action( 'et_builder_ready', 'ultp_postx_template_divi_modules' );
3
4 function ultp_postx_template_divi_modules() {
5
6 if ( ! class_exists( 'ET_Builder_Module' ) ) { return; }
7
8 class PostX_Template_Module extends ET_Builder_Module {
9
10 public $slug = 'ultp_postx_template';
11 public $vb_support = 'partial';
12
13 function init() {
14 $this->name = esc_html__( 'PostX Template', 'ultimate-post' );
15 $this->icon_path = plugin_dir_path( __FILE__ ) . 'icon.svg';
16 }
17
18 function get_fields() {
19 return array(
20 'templates' => array(
21 'label' => esc_html__( 'Select Your Template', 'ultimate-post' ),
22 'type' => 'select',
23 'options' => ultimate_post()->get_all_lists('ultp_templates', 'none'),
24 'default' => 'none',
25 'description' => esc_html__( 'Pick a Template from your saved ones. Or create a template from: <strong><i>Dashboard > PostX > Saved Templates</i></strong>', 'ultimate-post' ),
26 )
27 );
28 }
29
30 function render( $attrs, $render_slug, $content = null ) {
31 $templates = $this->props['templates'];
32
33 $output = '';
34 $content = '';
35 $body_class = get_body_class();
36 if ( $templates && $templates != 'none' ) {
37 $args = array( 'p' => $templates, 'post_type' => 'ultp_templates');
38 $the_query = new \WP_Query($args);
39 if ($the_query->have_posts()) {
40 while ($the_query->have_posts()) {
41 $the_query->the_post();
42 ob_start();
43 the_content();
44 if (in_array('et-fb', $body_class)) {
45 echo ultimate_post()->set_css_style($templates, true); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
46 } else {
47 ultimate_post()->register_scripts_common();
48 ultimate_post()->set_css_style($templates);
49 }
50 $content = ob_get_clean();
51 }
52 wp_reset_postdata();
53 }
54 } else {
55 if (in_array('et-fb', $body_class)) {
56 $content = '<p style="text-align:center;">'.sprintf( esc_html__( 'Pick a Template from your saved ones. Or create a template from: %s.' , 'ultimate-post' ) . ' ', '<strong><i>' . esc_html( 'Dashboard > PostX > Saved Templates', 'ultimate-post' ) . '</i></strong>' ).'</p>';
57 }
58 }
59
60 // Render module content
61 $output = sprintf(
62 '<div class="ultp-shortcode" data-postid="%1$s">%2$s</div>',
63 esc_html($templates),
64 et_sanitized_previously($content)
65 );
66
67 return $this->_render_module_wrapper( $output, $render_slug );
68 }
69 }
70
71 new PostX_Template_Module;
72 }
73