HEX
Server: Apache/2.4.57 (Unix) OpenSSL/1.1.1k
System: Linux tam.zee-supreme-vps.net 4.18.0-513.9.1.el8_9.x86_64 #1 SMP Sat Dec 2 05:23:44 EST 2023 x86_64
User: adltc (1070)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: /home/adltc/public_html/wp-content/plugins/jet-engine/includes/modules/forms/shortcode.php
<?php
/**
 * Shortcode
 */

// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
	die;
}

if ( ! class_exists( 'Jet_Engine_Forms_Shortcode' ) ) {

	class Jet_Engine_Forms_Shortcode {

		/**
		 * A reference to an instance of this class.
		 *
		 * @since  1.0.0
		 * @access private
		 * @var    object
		 */
		private static $instance = null;

		public function __construct() {
			add_filter( 'jet-engine/shortcodes/default-atts', array( $this, 'add_forms_default_atts' ) );
			add_filter( 'jet-engine/shortcodes/forms/result', array( $this, 'do_shortcode' ), 10, 2 );

			if ( is_admin() ) {
				add_action( 'init', array( $this, 'init_admin_columns_hooks' ) );
			}
		}

		public function init_admin_columns_hooks() {
			add_filter( 'manage_' . jet_engine()->forms->slug() . '_posts_columns',       array( $this, 'edit_columns' ) );
			add_action( 'manage_' . jet_engine()->forms->slug() . '_posts_custom_column', array(  $this, 'manage_columns' ), 10, 2 );
		}

		public function add_forms_default_atts( $atts = array() ) {
			$form_atts = array(
				'_form_id'         => '',
				'fields_layout'    => 'row',
				'fields_label_tag' => 'div',
				'submit_type'      => 'reload',
				'cache_form'       => false,
			);

			return array_merge( $atts, $form_atts );
		}

		public function do_shortcode( $result = '', $atts = array() ) {

			if ( empty( $atts['_form_id'] ) ) {
				return $result;
			}

			$block_instance = jet_engine()->blocks_views->block_types->get_block_type_instance( 'booking-form' );

			if ( ! $block_instance ) {
				return $result;
			}

			return $block_instance->render_callback( $atts );
		}

		public function edit_columns( $columns = array() ) {

			$columns['form-shortcode'] = esc_html__( 'Shortcode', 'jet-engine' );

			return $columns;
		}

		public function manage_columns( $column, $post_id ) {

			if ( 'form-shortcode' !== $column ) {
				return;
			}

			$shortcode = sprintf( '[jet_engine component="forms" _form_id="%d"]', $post_id );

			printf(
				'<input type="text" readonly value="%s" style="%s" />',
				esc_attr( $shortcode ),
				'width:100%'
			);
		}

		/**
		 * Returns the instance.
		 *
		 * @since  1.0.0
		 * @access public
		 * @return object
		 */
		public static function instance() {
			// If the single instance hasn't been set, set it now.
			if ( null == self::$instance ) {
				self::$instance = new self;
			}
			return self::$instance;
		}

	}

}