PluginProbe
Post Grid Gutenberg Blocks – PostX / 4.0.3
Post Grid Gutenberg Blocks – PostX v4.0.3
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 / bricks_builder / bricksbuilder.php

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

77 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit; // Exit if accessed directly
5 }
6
7 class PostX_Bricks_Integration extends \Bricks\Element {
8 // Element properties
9 public $category = 'general';
10 public $name = 'postx-addon';
11 public $icon = 'ti-layout-grid2';
12
13 // Return localised element label
14 public function get_label() {
15 return esc_html__( 'PostX Template', 'ultimate-post' );
16 }
17
18 // Set builder controls
19 public function set_controls() {
20 $this->controls['template'] = array(
21 'type' => 'select',
22 'label' => esc_html__( 'Select Template', 'ultimate-post' ),
23 'options' => ultimate_post()->get_all_lists( 'ultp_templates' ),
24 'clearable' => false,
25 'default' => '',
26 'pasteStyles' => true,
27 'inline' => true,
28 );
29 $this->controls['separator'] = array(
30 'type' => 'separator',
31 );
32 $this->controls['help'] = array(
33 'type' => 'info',
34 'content' => 'Pick a Template from your saved ones. Or create a template from: <strong><i>Dashboard > PostX > Saved Templates</i></strong>',
35 );
36 }
37
38 // Render element HTML
39 public function render() {
40 $id = $this->settings['template'];
41 $root_classes[] = 'bricks-postx-wrapper';
42 $this->set_attribute( '_root', 'class', $root_classes );
43
44 $current_url = isset( $_SERVER['REQUEST_URI'] ) ? esc_url( $_SERVER['REQUEST_URI'] ) : ''; //phpcs:ignore
45 ultimate_post()->register_scripts_common();
46
47 // Render element HTML
48 echo "<div {$this->render_attributes( '_root' )}>"; //phpcs:ignore
49 if ( $id ) {
50 if ( strpos( $current_url, 'bricks=run' ) !== false || strpos( $current_url, 'bricks/v1/render_element' ) !== false ) {
51 echo ultimate_post()->set_css_style( $id, true ); //phpcs:ignore
52 } else {
53 ultimate_post()->set_css_style( $id );
54 }
55 echo '<div class="ultp-shortcode" data-postid="' . esc_attr( $id ) . '">';
56 $args = array(
57 'p' => $id,
58 'post_type' => 'ultp_templates',
59 );
60 $the_query = new \WP_Query( $args );
61 if ( $the_query->have_posts() ) {
62 while ( $the_query->have_posts() ) {
63 $the_query->the_post();
64 the_content();
65 }
66 wp_reset_postdata();
67 }
68 echo '</div>';
69 } else {
70 if ( strpos( 'bricks=run', $current_url ) !== false || strpos( $current_url, 'bricks/v1/render_element' ) !== false ) {
71 echo '<p style="text-align:center; font-size: 20px;">' . 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>';
72 }
73 }
74 echo '</div>';
75 }
76 }
77