PluginProbe
weForms – Easy Drag & Drop Contact Form Builder For WordPress / 1.3.2
weForms – Easy Drag & Drop Contact Form Builder For WordPress v1.3.2
1.6.7 1.6.8 1.6.9 1.6.12 1.6.13 1.6.14 1.6.15 1.6.16 1.6.17 1.6.18 1.6.19 1.6.2 1.6.20 1.6.21 1.6.22 1.6.23 1.6.24 1.6.25 1.6.26 1.6.27 1.6.28 1.6.3 1.6.4 1.6.5 1.6.6 All 74 releases
← All changes | includes/admin/class-shortcode-button.php +129 -125 1.6.31.3.2 View file →
@@ -1,125 +1,129 @@
1 -<?php
2 -
3 -/**
4 - * weForms Shortcode Button class
5 - *
6 - * @since 1.2.9
7 - */
8 -class Weforms_Form_Button {
9 -
10 - /**
11 - * Constructor for shortcode class
12 - */
13 - public function __construct() {
14 - add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_scripts' ] );
15 - add_action( 'media_buttons', [ $this, 'add_media_button' ], 20 );
16 - add_action( 'admin_footer', [ $this, 'media_thickbox_content' ] );
17 - }
18 -
19 - /**
20 - * Enqueue scripts and styles for form builder
21 - *
22 - * @global string $pagenow
23 - *
24 - * @return void
25 - */
26 - public function enqueue_scripts() {
27 - global $pagenow;
28 -
29 - if ( !in_array( $pagenow, [ 'post.php', 'post-new.php'] ) ) {
30 - return;
31 - }
32 -
33 - wp_enqueue_script( 'weforms-shortcode', WEFORMS_ASSET_URI . '/js/weforms-shortcode.js', ['jquery'] );
34 - }
35 -
36 - /**
37 - * Adds a media button (for inserting a form) to the Post Editor
38 - *
39 - * @param int $editor_id The editor ID
40 - *
41 - * @return void
42 - */
43 - public function add_media_button( $editor_id ) {
44 - ?>
45 - <a href="#TB_inline?width=480&amp;inlineId=weforms-media-dialog" class="button thickbox insert-form" data-editor="<?php echo esc_attr( $editor_id ); ?>" title="<?php esc_html_e( 'Add a Form', 'weforms' ); ?>">
46 - <?php echo '<span class="wp-media-buttons-icon dashicons dashicons-welcome-widgets-menus"></span>' . esc_html_e( ' Add Contact Form', 'weforms' ); ?>
47 - </a>
48 - <?php
49 - }
50 -
51 - /**
52 - * Prints the thickbox popup content
53 - *
54 - * @return void
55 - */
56 - public function media_thickbox_content() {
57 - global $pagenow;
58 -
59 - if ( !in_array( $pagenow, [ 'post.php', 'post-new.php'] ) ) {
60 - return;
61 - } ?>
62 -
63 - <div id="weforms-media-dialog" style="display: none;">
64 -
65 - <div class="weforms-popup-container">
66 - <?php
67 -
68 - $all_forms = weforms()->form->all();
69 - $options = sprintf( "<option value='%s'>%s</option>", 0, __( '&mdash; Select Form &mdash;', 'weforms' ) );
70 -
71 - foreach ( $all_forms['forms'] as $form ) {
72 - $options .= sprintf( "<option value='%s'>%s</option>", esc_attr( $form->id ), esc_attr( $form->name ) );
73 - } ?>
74 -
75 - <div class="weforms-form-div">
76 - <label><h3><?php esc_html_e( 'Select a form to insert', 'weforms' ); ?></h3></label>
77 - <select id="weforms-form-select">
78 - <?php echo wp_kses( $options, array( 'option' => array( 'value' => array() ) ) ); ?>
79 - </select>
80 - </div>
81 -
82 - <div class="submit-button weforms-submit-div">
83 - <button id="weforms-form-insert" class="button-primary"><?php esc_html_e( 'Insert Form', 'weforms' ); ?></button>
84 - <button id="weforms-form-close" class="button-secondary" style="margin-left: 5px;" onClick="tb_remove();"><?php esc_html_e( 'Close', 'weforms' ); ?></a></button>
85 - </div>
86 -
87 - </div>
88 - </div>
89 -
90 - <style type="text/css">
91 -
92 - .weforms-form-div {
93 - padding: 10px;
94 - clear: left;
95 - }
96 - .weforms-submit-div {
97 - padding: 10px;
98 - clear: left;
99 - float: left;
100 - width: 90%;
101 - }
102 - </style>
103 -
104 - <?php
105 - }
106 -
107 - /**
108 - * * Singleton object
109 - *
110 - * @staticvar boolean $instance
111 - *
112 - * @return \self
113 - */
114 - public static function init() {
115 - static $instance = false;
116 -
117 - if ( !$instance ) {
118 - $instance = new Weforms_Form_Button();
119 - }
120 -
121 - return $instance;
122 - }
123 -}
124 -
125 -Weforms_Form_Button::init();
1 +<?php
2 +
3 +/**
4 + * weForms Shortcode Button class
5 + *
6 + * @since 1.2.9
7 + */
8 +class Weforms_Form_Button {
9 +
10 + /**
11 + * Constructor for shortcode class
12 + */
13 + public function __construct() {
14 + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
15 + add_action( 'media_buttons', array( $this, 'add_media_button' ), 20 );
16 + add_action( 'admin_footer', array( $this, 'media_thickbox_content' ) );
17 + }
18 +
19 +
20 + /**
21 + * Enqueue scripts and styles for form builder
22 + *
23 + * @global string $pagenow
24 + * @return void
25 + */
26 + function enqueue_scripts() {
27 + global $pagenow;
28 +
29 + if ( !in_array( $pagenow, array( 'post.php', 'post-new.php') ) ) {
30 + return;
31 + }
32 +
33 + wp_enqueue_script( 'weforms-shortcode', WEFORMS_ASSET_URI . '/weforms-shortcode.js', array('jquery') );
34 + }
35 +
36 + /**
37 + * Adds a media button (for inserting a form) to the Post Editor
38 + *
39 + * @param int $editor_id The editor ID
40 + * @return void
41 + */
42 + function add_media_button( $editor_id ) {
43 + ?>
44 + <a href="#TB_inline?width=480&amp;inlineId=weforms-media-dialog" class="button thickbox insert-form" data-editor="<?php echo esc_attr( $editor_id ); ?>" title="<?php _e( 'Add a Form', 'weforms' ); ?>">
45 + <?php echo '<span class="wp-media-buttons-icon dashicons dashicons-welcome-widgets-menus"></span>' . __( ' Add Contact Form', 'weforms' ); ?>
46 + </a>
47 + <?php
48 +
49 + }
50 +
51 + /**
52 + * Prints the thickbox popup content
53 + *
54 + * @return void
55 + */
56 + public function media_thickbox_content() {
57 + global $pagenow;
58 +
59 + if ( !in_array( $pagenow, array( 'post.php', 'post-new.php') ) ) {
60 + return;
61 + }
62 + ?>
63 +
64 + <div id="weforms-media-dialog" style="display: none;">
65 +
66 + <div class="weforms-popup-container">
67 + <?php
68 +
69 + $all_forms = weforms()->form->all();
70 + $options = sprintf( "<option value='%s'>%s</option>", 0, __('Select Form', 'weforms') );
71 + foreach ( $all_forms['forms'] as $form ) {
72 + $options.= sprintf( "<option value='%s'>%s</option>", $form->id, $form->name );
73 + }
74 + ?>
75 +
76 + <div class="weforms-form-div">
77 + <label><h3><?php _e( 'Select a form to insert', 'weforms' ); ?></h3></label>
78 + <select id="weforms-form-select">
79 + <?php echo $options; ?>
80 + </select>
81 + </div>
82 +
83 + <div class="submit-button weforms-submit-div">
84 + <button id="weforms-form-insert" class="button-primary"><?php _e( 'Insert Form', 'weforms' ); ?></button>
85 + <button id="weforms-form-close" class="button-secondary" style="margin-left: 5px;" onClick="tb_remove();"><?php _e( 'Close', 'weforms' ); ?></a></button>
86 + </div>
87 +
88 + </div>
89 + </div>
90 +
91 + <style type="text/css">
92 +
93 + .weforms-form-div {
94 + padding: 10px;
95 + clear: left;
96 + }
97 + .weforms-submit-div {
98 + padding: 10px;
99 + clear: left;
100 + float: left;
101 + width: 25%;
102 + }
103 + </style>
104 +
105 + <?php
106 + }
107 +
108 +
109 +
110 + /**
111 + * * Singleton object
112 + *
113 + * @staticvar boolean $instance
114 + *
115 + * @return \self
116 + */
117 + public static function init() {
118 + static $instance = false;
119 +
120 + if ( !$instance ) {
121 + $instance = new Weforms_Form_Button();
122 + }
123 +
124 + return $instance;
125 + }
126 +
127 +}
128 +
129 +Weforms_Form_Button::init();