PluginProbe
Post Grid Gutenberg Blocks – PostX / 5.1.0
Post Grid Gutenberg Blocks – PostX v5.1.0
5.1.1 5.1.0 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 All 240 releases
ultimate-post / addons / divi / divi.php

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

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