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 / wpbakery / wpbakery.php

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

79 lines 2.5 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 if ( ! class_exists( 'PostX_WPBakery_Widget' ) ) {
5
6 class PostX_WPBakery_Widget {
7
8 /**
9 * Main constructor
10 */
11 public function __construct() {
12 add_shortcode( 'postx_wpbakery_widget', __CLASS__ . '::output' );
13 if ( function_exists( 'vc_lean_map' ) ) {
14 vc_lean_map( 'postx_wpbakery_widget', __CLASS__ . '::map' );
15 }
16 }
17
18 /**
19 * Shortcode output
20 */
21 public static function output( $atts, $content = null ) {
22 $output = '';
23 $atts = vc_map_get_attributes( 'postx_wpbakery_widget', $atts );
24 $templates = $atts['saved_template'];
25
26 if ( $templates && $templates != 'empty' ) {
27 if (isset($_GET['vc_editable'])) { // @codingStandardsIgnoreLine
28 $output .= ultimate_post()->build_css_for_inline_print( $templates, true );
29 }
30
31 $args = array(
32 'p' => $templates,
33 'post_type' => 'ultp_templates',
34 );
35 $the_query = new \WP_Query( $args );
36
37 if ( $the_query->have_posts() ) {
38 while ( $the_query->have_posts() ) {
39 $the_query->the_post();
40 ob_start();
41 the_content();
42 $output .= ob_get_clean();
43 }
44 wp_reset_postdata();
45 }
46 } elseif ( isset( $_GET['vc_editable'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only WPBakery editor detection.
47 // @codingStandardsIgnoreLine
48 $output .= '<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>';
49 }
50
51 return $output;
52 }
53
54
55
56
57 public static function map() {
58 return array(
59 'name' => esc_html__( 'PostX Template', 'ultimate-post' ),
60 'description' => esc_html__( 'PostX Templates for WPBakery.', 'ultimate-post' ),
61 'base' => 'postx_wpbakery_widget',
62 'icon' => ULTP_URL . '/addons/wpbakery/wpbakery.png',
63 'params' => array(
64 array(
65 'type' => 'dropdown',
66 'heading' => esc_html__( 'Select Your Template', 'ultimate-post' ),
67 'param_name' => 'saved_template',
68 'value' => array_flip( ultimate_post()->get_all_lists( 'ultp_templates', 'empty' ) ),
69 'description' => esc_html__( 'Pick a Template from your saved ones. Or create a template from: "Dashboard > PostX > Saved Templates"', 'ultimate-post' ),
70 ),
71 ),
72 );
73 }
74 }
75
76 }
77
78 new PostX_WPBakery_Widget();
79