<?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;
}
}
}| nama | waktu | ukuran | owner | perm | aksi |
|---|---|---|---|---|---|
| .. | |||||
| block-types/ | 2026-07-21 14:15 | 80.59 KB | 76129f60960:kunden | dxwrx-r--r | |
| gateways/ | 2026-07-21 14:15 | 24.27 KB | 76129f60960:kunden | dxwrx-r--r | |
| generators/ | 2026-07-21 14:15 | 5.13 KB | 76129f60960:kunden | dxwrx-r--r | |
| handlers/ | 2026-07-21 14:15 | 5.56 KB | 76129f60960:kunden | dxwrx-r--r | |
| render/ | 2026-07-21 14:15 | 3.42 KB | 76129f60960:kunden | dxwrx-r--r | |
| tabs/ | 2026-07-21 14:15 | 6.19 KB | 76129f60960:kunden | dxwrx-r--r | |
| widgets/ | 2026-07-21 14:15 | 76.25 KB | 76129f60960:kunden | dxwrx-r--r | |
| builder.php | 2026-07-21 14:15 | 40.83 KB | 76129f60960:kunden | -xw-x----- | |
| captcha.php | 2026-07-21 14:15 | 4.56 KB | 76129f60960:kunden | -xw-x----- | |
| dashboard-tab.php | 2026-07-21 14:15 | 412 B | 76129f60960:kunden | -xw-x----- | |
| editor.php | 2026-07-21 14:15 | 24.09 KB | 76129f60960:kunden | -xw-x----- | |
| export-import.php | 2026-07-21 14:15 | 8.05 KB | 76129f60960:kunden | -xw-x----- | |
| file-upload.php | 2026-07-21 14:15 | 17.44 KB | 76129f60960:kunden | -xw-x----- | |
| forms.php | 2026-07-21 14:15 | 3.4 KB | 76129f60960:kunden | -xw-x----- | |
| handler.php | 2026-07-21 14:15 | 15.89 KB | 76129f60960:kunden | -xw-x----- | |
| manager.php | 2026-07-21 14:15 | 16.46 KB | 76129f60960:kunden | -xw-x----- | |
| messages.php | 2026-07-21 14:15 | 4.35 KB | 76129f60960:kunden | -xw-x----- | |
| notifications.php | 2026-07-21 14:15 | 42.06 KB | 76129f60960:kunden | -xw-x----- | |
| preset.php | 2026-07-21 14:15 | 12.9 KB | 76129f60960:kunden | -xw-x----- | |
| shortcode.php | 2026-07-21 14:15 | 2.38 KB | 76129f60960:kunden | -xw-x----- | |