PluginProbe ʕ •ᴥ•ʔ
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI / 1.3.3
Everest Forms – Contact Form, Payment Form, Quiz, Survey & Custom Form Builder with AI v1.3.3
3.6.0 3.5.3 3.5.2 3.5.1 3.5.0 3.4.8 3.4.7 3.4.6 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5.1 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.10 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.6.1 1.6.7 1.7.0 1.7.0.1 1.7.0.2 1.7.0.3 1.7.1 1.7.2 1.7.2.1 1.7.2.2 1.7.3 1.7.4 1.7.5 1.7.5.1 1.7.5.2 1.7.6 1.7.7 1.7.7.1 1.7.7.2 1.7.8 1.7.9 1.8.0 1.8.0.1 1.8.1 1.8.2 1.8.2.1 1.8.2.2 1.8.2.3 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9.0 1.9.0.1 1.9.1 1.9.2 1.9.3 1.9.4 1.9.4.1 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.0.1 2.0.1 2.0.2 2.0.3 2.0.3.1 2.0.4 2.0.4.1 2.0.5 2.0.6 2.0.7 2.0.8 2.0.8.1 2.0.9 3.0.0 3.0.0.1 3.0.1 3.0.2 3.0.3 3.0.3.1 3.0.4 3.0.4.1 3.0.4.2 3.0.5 3.0.5.1 3.0.5.2 3.0.6 3.0.6.1 3.0.7.1 3.0.8 3.0.8.1 3.0.9 3.0.9.1 3.0.9.2 3.0.9.3 3.0.9.4 3.0.9.5 3.1.0 3.1.1 3.1.2 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.3.0 3.4.0 3.4.1 3.4.2 3.4.2.1 3.4.3 3.4.4 3.4.5 trunk 1.0 1.0.1 1.0.2 1.0.3
everest-forms / includes / admin / class-evf-admin-forms.php
everest-forms / includes / admin Last commit date
builder 7 years ago plugin-updates 8 years ago settings 7 years ago views 7 years ago class-evf-admin-addons.php 8 years ago class-evf-admin-assets.php 7 years ago class-evf-admin-builder.php 8 years ago class-evf-admin-editor.php 8 years ago class-evf-admin-entries-table-list.php 7 years ago class-evf-admin-entries.php 7 years ago class-evf-admin-forms-table-list.php 7 years ago class-evf-admin-forms.php 8 years ago class-evf-admin-menus.php 7 years ago class-evf-admin-notices.php 7 years ago class-evf-admin-settings.php 7 years ago class-evf-admin-status.php 8 years ago class-evf-admin.php 8 years ago evf-admin-functions.php 8 years ago
class-evf-admin-forms.php
171 lines
1 <?php
2 /**
3 * EverestForms Admin Forms Class
4 *
5 * @package EverestForms\Admin
6 * @since 1.2.0
7 */
8
9 defined( 'ABSPATH' ) || exit;
10
11 /**
12 * EVF_Admin_Forms class.
13 */
14 class EVF_Admin_Forms {
15
16 /**
17 * Initialize the forms admin actions.
18 */
19 public function __construct() {
20 add_action( 'admin_init', array( $this, 'actions' ) );
21 add_action( 'deleted_post', array( $this, 'delete_entries' ) );
22 }
23
24 /**
25 * Check if is forms page.
26 *
27 * @return bool
28 */
29 private function is_forms_page() {
30 return isset( $_GET['page'] ) && 'evf-builder' === $_GET['page']; // WPCS: input var okay, CSRF ok.
31 }
32
33 /**
34 * Page output.
35 */
36 public static function page_output() {
37 global $current_tab;
38
39 if ( isset( $_GET['form_id'] ) && $current_tab ) {
40 $form = EVF()->form->get( absint( $_GET['form_id'] ) );
41 $form_id = $form ? absint( $form->ID ) : absint( $_GET['form_id'] );
42 $form_data = $form ? evf_decode( $form->post_content ) : false;
43
44 include 'views/html-admin-page-builder.php';
45 } elseif ( isset( $_GET['create-form'] ) ) {
46 include 'views/html-admin-page-builder-setup.php';
47 } else {
48 self::table_list_output();
49 }
50 }
51
52 /**
53 * Table list output.
54 */
55 public static function table_list_output() {
56 global $forms_table_list;
57
58 $forms_table_list->process_bulk_action();
59 $forms_table_list->prepare_items();
60 ?>
61 <div class="wrap">
62 <h1 class="wp-heading-inline"><?php esc_html_e( 'All Forms', 'everest-forms' ); ?></h1>
63 <a href="<?php echo esc_url( admin_url( 'admin.php?page=evf-builder&create-form=1' ) ); ?>" class="page-title-action"><?php esc_html_e( 'Add New', 'everest-forms' ); ?></a>
64 <hr class="wp-header-end">
65
66 <?php settings_errors(); ?>
67
68 <form id="form-list" method="post">
69 <input type="hidden" name="page" value="everest-forms"/>
70 <?php
71 $forms_table_list->views();
72 $forms_table_list->search_box( __( 'Search Forms', 'everest-forms' ), 'everest-forms' );
73 $forms_table_list->display();
74
75 wp_nonce_field( 'save', 'everest-forms_nonce' );
76 ?>
77 </form>
78 </div>
79 <?php
80 }
81
82 /**
83 * Forms admin actions.
84 */
85 public function actions() {
86 if ( $this->is_forms_page() ) {
87 // Empty trash.
88 if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) { // WPCS: input var okay, CSRF ok.
89 $this->empty_trash();
90 }
91
92 // Duplicate form.
93 if ( isset( $_REQUEST['action'] ) && 'duplicate_form' === $_REQUEST['action'] ) { // WPCS: input var okay, CSRF ok.
94 $this->duplicate_form();
95 }
96 }
97 }
98
99 /**
100 * Empty Trash.
101 */
102 private function empty_trash() {
103 check_admin_referer( 'bulk-forms' );
104
105 $count = 0;
106 $form_ids = get_posts( array(
107 'post_type' => 'everest_form',
108 'ignore_sticky_posts' => true,
109 'nopaging' => true,
110 'post_status' => 'trash',
111 'fields' => 'ids',
112 ) );
113
114 foreach ( $form_ids as $form_id ) {
115 if ( wp_delete_post( $form_id, true ) ) {
116 $count ++;
117 }
118 }
119
120 add_settings_error(
121 'empty_trash',
122 'empty_trash',
123 /* translators: %d: number of forms */
124 sprintf( _n( '%d form permanently deleted.', '%d forms permanently deleted.', $count, 'everest-forms' ), $count ),
125 'updated'
126 );
127 }
128
129 /**
130 * Duplicate form.
131 */
132 private function duplicate_form() {
133 if ( empty( $_REQUEST['form_id'] ) ) {
134 wp_die( __( 'No form to duplicate has been supplied!', 'everest-forms' ) );
135 }
136
137 $form_id = isset( $_REQUEST['form_id'] ) ? absint( $_REQUEST['form_id'] ) : '';
138
139 check_admin_referer( 'everest-forms-duplicate-form_' . $form_id );
140
141 $duplicate_id = evf()->form->duplicate( $form_id );
142
143 // Redirect to the edit screen for the new form page.
144 wp_redirect( admin_url( 'admin.php?page=evf-builder&tab=fields&form_id=' . $duplicate_id ) );
145 exit;
146 }
147
148 /**
149 * Remove entry and its associated meta.
150 *
151 * When form is deleted then it also deletes its entries meta.
152 *
153 * @param int $post_id
154 */
155 public function delete_entries( $postid ) {
156 global $wpdb;
157
158 $entries = evf_get_entries_ids( $postid );
159
160 // Delete entry.
161 if ( ! empty( $entries ) ) {
162 foreach ( $entries as $entry_id ) {
163 $wpdb->delete( $wpdb->prefix . 'evf_entries', array( 'entry_id' => $entry_id ), array( '%d' ) );
164 $wpdb->delete( $wpdb->prefix . 'evf_entrymeta', array( 'entry_id' => $entry_id ), array( '%d' ) );
165 }
166 }
167 }
168 }
169
170 new EVF_Admin_Forms();
171