PluginProbe
Post Grid Gutenberg Blocks – PostX / 5.1.1
Post Grid Gutenberg Blocks – PostX v5.1.1
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 / bricks_builder / bricksbuilder.php

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

71 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
46 // Render element HTML
47 echo "<div {$this->render_attributes( '_root' )}>"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Bricks API attribute string; the only attribute this element sets is the fixed class bricks-postx-wrapper.
48 if ( $id ) {
49 echo ultimate_post()->build_css_for_inline_print( $id, 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().
50 echo '<div class="ultp-shortcode" data-postid="' . esc_attr( $id ) . '">';
51 $args = array(
52 'p' => $id,
53 'post_type' => 'ultp_templates',
54 );
55 $the_query = new \WP_Query( $args );
56 if ( $the_query->have_posts() ) {
57 while ( $the_query->have_posts() ) {
58 $the_query->the_post();
59 the_content();
60 }
61 wp_reset_postdata();
62 }
63 echo '</div>';
64 } elseif ( strpos( 'bricks=run', $current_url ) !== false || strpos( $current_url, 'bricks/v1/render_element' ) !== false ) {
65 /* translators: %s: Menu path to the Saved Templates screen. */
66 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>';
67 }
68 echo '</div>';
69 }
70 }
71