builder
6 years ago
plugin-updates
8 years ago
settings
6 years ago
views
6 years ago
class-evf-admin-addons.php
6 years ago
class-evf-admin-assets.php
6 years ago
class-evf-admin-builder.php
7 years ago
class-evf-admin-editor.php
6 years ago
class-evf-admin-entries-table-list.php
6 years ago
class-evf-admin-entries.php
6 years ago
class-evf-admin-forms-table-list.php
6 years ago
class-evf-admin-forms.php
6 years ago
class-evf-admin-import-export.php
6 years ago
class-evf-admin-menus.php
6 years ago
class-evf-admin-notices.php
6 years ago
class-evf-admin-settings.php
6 years ago
class-evf-admin-tools.php
6 years ago
class-evf-admin-welcome.php
6 years ago
class-evf-admin.php
6 years ago
evf-admin-functions.php
6 years ago
class-evf-admin-assets.php
265 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Load assets |
| 4 | * |
| 5 | * @package EverestForms/Admin |
| 6 | * @version 1.0.0 |
| 7 | */ |
| 8 | |
| 9 | defined( 'ABSPATH' ) || exit; |
| 10 | |
| 11 | if ( class_exists( 'EVF_Admin_Assets', false ) ) { |
| 12 | return new EVF_Admin_Assets(); |
| 13 | } |
| 14 | |
| 15 | /** |
| 16 | * EVF_Admin_Assets Class. |
| 17 | */ |
| 18 | class EVF_Admin_Assets { |
| 19 | |
| 20 | /** |
| 21 | * Hook in tabs. |
| 22 | */ |
| 23 | public function __construct() { |
| 24 | add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles' ) ); |
| 25 | add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) ); |
| 26 | } |
| 27 | |
| 28 | /** |
| 29 | * Enqueue styles. |
| 30 | */ |
| 31 | public function admin_styles() { |
| 32 | $screen = get_current_screen(); |
| 33 | $screen_id = $screen ? $screen->id : ''; |
| 34 | |
| 35 | // Register admin styles. |
| 36 | wp_register_style( 'everest-forms-admin', evf()->plugin_url() . '/assets/css/admin.css', array(), EVF_VERSION ); |
| 37 | wp_register_style( 'everest-forms-admin-menu', evf()->plugin_url() . '/assets/css/menu.css', array(), EVF_VERSION ); |
| 38 | wp_register_style( 'jquery-ui-style', evf()->plugin_url() . '/assets/css/jquery-ui/jquery-ui.min.css', array(), EVF_VERSION ); |
| 39 | wp_register_style( 'jquery-confirm', evf()->plugin_url() . '/assets/css/jquery-confirm/jquery-confirm.min.css', array(), '3.3.0' ); |
| 40 | wp_register_style( 'perfect-scrollbar', evf()->plugin_url() . '/assets/css/perfect-scrollbar/perfect-scrollbar.css', array(), '1.4.0' ); |
| 41 | |
| 42 | // Add RTL support for admin styles. |
| 43 | wp_style_add_data( 'everest-forms-admin', 'rtl', 'replace' ); |
| 44 | wp_style_add_data( 'everest-forms-admin-menu', 'rtl', 'replace' ); |
| 45 | |
| 46 | // Sitewide menu CSS. |
| 47 | wp_enqueue_style( 'everest-forms-admin-menu' ); |
| 48 | |
| 49 | // Admin styles for EVF pages only. |
| 50 | if ( in_array( $screen_id, evf_get_screen_ids(), true ) ) { |
| 51 | wp_enqueue_style( 'everest-forms-admin' ); |
| 52 | wp_enqueue_style( 'jquery-confirm' ); |
| 53 | wp_enqueue_style( 'jquery-ui-style' ); |
| 54 | wp_enqueue_style( 'wp-color-picker' ); |
| 55 | |
| 56 | if ( 'everest-forms_page_evf-tools' !== $screen_id ) { |
| 57 | wp_enqueue_style( 'perfect-scrollbar' ); |
| 58 | } |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Enqueue scripts. |
| 64 | */ |
| 65 | public function admin_scripts() { |
| 66 | global $post; |
| 67 | |
| 68 | $screen = get_current_screen(); |
| 69 | $screen_id = $screen ? $screen->id : ''; |
| 70 | $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
| 71 | |
| 72 | // Register scripts. |
| 73 | wp_register_script( 'everest-forms-admin', evf()->plugin_url() . '/assets/js/admin/admin' . $suffix . '.js', array( 'jquery', 'jquery-blockui', 'jquery-ui-sortable', 'jquery-ui-widget', 'jquery-ui-core', 'tooltipster', 'wp-color-picker', 'perfect-scrollbar' ), EVF_VERSION, true ); |
| 74 | wp_register_script( 'everest-forms-extensions', evf()->plugin_url() . '/assets/js/admin/extensions' . $suffix . '.js', array( 'jquery', 'updates' ), EVF_VERSION, true ); |
| 75 | wp_register_script( 'everest-forms-email-admin', evf()->plugin_url() . '/assets/js/admin/evf-admin-email' . $suffix . '.js', array( 'jquery', 'jquery-blockui', 'jquery-ui-sortable', 'jquery-ui-widget', 'jquery-ui-core', 'tooltipster', 'wp-color-picker', 'perfect-scrollbar' ), EVF_VERSION, true ); |
| 76 | wp_register_script( 'everest-forms-editor', evf()->plugin_url() . '/assets/js/admin/editor' . $suffix . '.js', array( 'jquery' ), EVF_VERSION, true ); |
| 77 | wp_register_script( 'jquery-blockui', evf()->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array( 'jquery' ), '2.70', true ); |
| 78 | wp_register_script( 'jquery-confirm', evf()->plugin_url() . '/assets/js/jquery-confirm/jquery-confirm' . $suffix . '.js', array( 'jquery' ), '3.3.0', true ); |
| 79 | wp_register_script( 'jquery-tiptip', evf()->plugin_url() . '/assets/js/jquery-tiptip/jquery.tipTip' . $suffix . '.js', array( 'jquery' ), EVF_VERSION, true ); // @deprecated |
| 80 | wp_register_script( 'tooltipster', evf()->plugin_url() . '/assets/js/tooltipster/tooltipster.bundle' . $suffix . '.js', array( 'jquery' ), '4.6.2', true ); |
| 81 | wp_register_script( 'perfect-scrollbar', evf()->plugin_url() . '/assets/js/perfect-scrollbar/perfect-scrollbar' . $suffix . '.js', array( 'jquery' ), '1.4.0', true ); |
| 82 | wp_register_script( 'evf-clipboard', evf()->plugin_url() . '/assets/js/admin/evf-clipboard' . $suffix . '.js', array( 'jquery' ), EVF_VERSION, true ); |
| 83 | wp_register_script( 'selectWoo', evf()->plugin_url() . '/assets/js/selectWoo/selectWoo.full' . $suffix . '.js', array( 'jquery' ), '1.0.4', true ); |
| 84 | wp_register_script( 'evf-enhanced-select', evf()->plugin_url() . '/assets/js/admin/evf-enhanced-select' . $suffix . '.js', array( 'jquery', 'selectWoo' ), EVF_VERSION, true ); |
| 85 | wp_register_script( 'evf-template-controller', evf()->plugin_url() . '/assets/js/admin/form-template-controller' . $suffix . '.js', array( 'jquery' ), EVF_VERSION, true ); |
| 86 | wp_localize_script( |
| 87 | 'evf-template-controller', |
| 88 | 'evf_templates', |
| 89 | array( |
| 90 | 'evf_template_all' => EVF_Admin_Forms::get_template_data(), |
| 91 | 'i18n_get_started' => esc_html__( 'Get Started', 'everest-forms' ), |
| 92 | 'i18n_get_preview' => esc_html__( 'Preview', 'everest-forms' ), |
| 93 | 'i18n_pro_feature' => esc_html__( 'Pro', 'everest-forms' ), |
| 94 | 'template_refresh' => esc_html__( 'Updating Templates', 'everest-forms' ), |
| 95 | ) |
| 96 | ); |
| 97 | wp_localize_script( |
| 98 | 'evf-enhanced-select', |
| 99 | 'evf_enhanced_select_params', |
| 100 | array( |
| 101 | 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'everest-forms' ), |
| 102 | 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'everest-forms' ), |
| 103 | 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'everest-forms' ), |
| 104 | 'i18n_input_too_short_n' => _x( 'Please enter %qty% or more characters', 'enhanced select', 'everest-forms' ), |
| 105 | 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'everest-forms' ), |
| 106 | 'i18n_input_too_long_n' => _x( 'Please delete %qty% characters', 'enhanced select', 'everest-forms' ), |
| 107 | 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'everest-forms' ), |
| 108 | 'i18n_selection_too_long_n' => _x( 'You can only select %qty% items', 'enhanced select', 'everest-forms' ), |
| 109 | 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'everest-forms' ), |
| 110 | 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'everest-forms' ), |
| 111 | ) |
| 112 | ); |
| 113 | wp_register_script( 'evf-form-builder', evf()->plugin_url() . '/assets/js/admin/form-builder' . $suffix . '.js', array( 'jquery', 'jquery-blockui', 'tooltipster', 'jquery-ui-sortable', 'jquery-ui-widget', 'jquery-ui-core', 'jquery-ui-tabs', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-datepicker', 'jquery-confirm', 'evf-clipboard' ), EVF_VERSION, true ); |
| 114 | wp_localize_script( |
| 115 | 'evf-form-builder', |
| 116 | 'evf_data', |
| 117 | apply_filters( |
| 118 | 'everest_forms_builder_strings', |
| 119 | array( |
| 120 | 'post_id' => isset( $post->ID ) ? $post->ID : '', |
| 121 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 122 | 'tab' => isset( $_GET['tab'] ) ? evf_clean( wp_unslash( $_GET['tab'] ) ) : '', // phpcs:ignore WordPress.Security.NonceVerification, WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 123 | 'evf_field_drop_nonce' => wp_create_nonce( 'everest_forms_field_drop' ), |
| 124 | 'evf_save_form' => wp_create_nonce( 'everest_forms_save_form' ), |
| 125 | 'evf_get_next_id' => wp_create_nonce( 'everest_forms_get_next_id' ), |
| 126 | 'evf_enabled_form' => wp_create_nonce( 'everest_forms_enabled_form' ), |
| 127 | 'form_id' => isset( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : 0, // phpcs:ignore WordPress.Security.NonceVerification |
| 128 | 'field' => esc_html__( 'field', 'everest-forms' ), |
| 129 | 'i18n_ok' => esc_html__( 'OK', 'everest-forms' ), |
| 130 | 'i18n_installing' => esc_html__( 'Installing', 'everest-forms' ), |
| 131 | 'i18n_activating' => esc_html__( 'Activating', 'everest-forms' ), |
| 132 | 'i18n_install_activate' => esc_html__( 'Install & Activate', 'everest-forms' ), |
| 133 | 'i18n_install_only' => esc_html__( 'Activate Plugins', 'everest-forms' ), |
| 134 | 'i18n_copy' => esc_html__( '(copy)', 'everest-forms' ), |
| 135 | 'i18n_close' => esc_html__( 'Close', 'everest-forms' ), |
| 136 | 'i18n_cancel' => esc_html__( 'Cancel', 'everest-forms' ), |
| 137 | 'i18n_row_locked' => esc_html__( 'Row Locked', 'everest-forms' ), |
| 138 | 'i18n_row_locked_msg' => esc_html__( 'Single row cannot be deleted.', 'everest-forms' ), |
| 139 | 'i18n_field_locked' => esc_html__( 'Field Locked', 'everest-forms' ), |
| 140 | 'i18n_field_locked_msg' => esc_html__( 'This field cannot be deleted or duplicated.', 'everest-forms' ), |
| 141 | 'i18n_field_error_choice' => esc_html__( 'This item must contain at least one choice.', 'everest-forms' ), |
| 142 | 'i18n_delete_row_confirm' => esc_html__( 'Are you sure you want to delete this row?', 'everest-forms' ), |
| 143 | 'i18n_delete_field_confirm' => esc_html__( 'Are you sure you want to delete this field?', 'everest-forms' ), |
| 144 | 'i18n_duplicate_field_confirm' => esc_html__( 'Are you sure you want to duplicate this field?', 'everest-forms' ), |
| 145 | 'i18n_email_disable_message' => esc_html__( 'Turn on Email settings to manage your email notifications.', 'everest-forms' ), |
| 146 | 'i18n_upload_image_title' => esc_html__( 'Choose an image', 'everest-forms' ), |
| 147 | 'i18n_upload_image_button' => esc_html__( 'Use Image', 'everest-forms' ), |
| 148 | 'i18n_upload_image_remove' => esc_html__( 'Remove Image', 'everest-forms' ), |
| 149 | 'i18n_field_title_empty' => esc_html__( 'Empty Form Name', 'everest-forms' ), |
| 150 | 'i18n_field_title_payload' => esc_html__( 'Form name can\'t be empty.', 'everest-forms' ), |
| 151 | 'email_fields' => evf_get_all_email_fields_by_form_id( isset( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : 0 ), // phpcs:ignore WordPress.Security.NonceVerification |
| 152 | 'all_fields' => evf_get_all_form_fields_by_form_id( isset( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : 0 ), // phpcs:ignore WordPress.Security.NonceVerification |
| 153 | 'smart_tags_other' => evf()->smart_tags->other_smart_tags(), |
| 154 | ) |
| 155 | ) |
| 156 | ); |
| 157 | |
| 158 | // Builder upgrade. |
| 159 | wp_register_script( 'evf-upgrade', evf()->plugin_url() . '/assets/js/admin/upgrade.js', array( 'jquery', 'jquery-confirm' ), EVF_VERSION, false ); |
| 160 | wp_localize_script( |
| 161 | 'evf-upgrade', |
| 162 | 'evf_upgrade', |
| 163 | array( |
| 164 | 'upgrade_title' => esc_html__( 'is a PRO Feature', 'everest-forms' ), |
| 165 | 'upgrade_message' => esc_html__( 'We\'re sorry, %name% is not available on your plan.<br>Please upgrade to the PRO plan to unlock all these awesome features.', 'everest-forms' ), |
| 166 | 'upgrade_button' => esc_html__( 'Upgrade to PRO', 'everest-forms' ), |
| 167 | 'upgrade_url' => apply_filters( 'everest_forms_upgrade_url', 'https://wpeverest.com/wordpress-plugins/everest-forms/?utm_source=premium-fields&utm_medium=modal-button&utm_campaign=evf-upgrade-to-pro' ), |
| 168 | 'enable_stripe_title' => esc_html__( 'Please enable Stripe', 'everest-forms' ), |
| 169 | 'enable_stripe_message' => esc_html__( 'Enable Stripe Payment gateway in payments section to use this field.', 'everest-forms' ), |
| 170 | ) |
| 171 | ); |
| 172 | |
| 173 | // EverestForms admin pages. |
| 174 | if ( in_array( $screen_id, evf_get_screen_ids(), true ) ) { |
| 175 | wp_enqueue_script( 'everest-forms-admin' ); |
| 176 | wp_enqueue_script( 'everest-forms-email-admin' ); |
| 177 | wp_enqueue_script( 'evf-enhanced-select' ); |
| 178 | wp_enqueue_script( 'jquery-ui-sortable' ); |
| 179 | wp_enqueue_script( 'jquery-ui-autocomplete' ); |
| 180 | |
| 181 | wp_localize_script( |
| 182 | 'everest-forms-email-admin', |
| 183 | 'evf_email_params', |
| 184 | array( |
| 185 | 'i18n_email_connection' => esc_html__( 'Enter a Email nickname', 'everest-forms' ), |
| 186 | 'i18n_email_placeholder' => esc_html__( 'Eg: Support Email', 'everest-forms' ), |
| 187 | 'i18n_email_error_name' => esc_html__( 'You must provide a Email nickname', 'everest-forms' ), |
| 188 | 'i18n_email_ok' => esc_html__( 'OK', 'everest-forms' ), |
| 189 | 'ajax_email_nonce' => wp_create_nonce( 'process-ajax-nonce' ), |
| 190 | 'ajax_url' => admin_url( 'admin-ajax.php', 'relative' ), |
| 191 | 'i18n_email_cancel' => esc_html__( 'Cancel', 'everest-forms' ), |
| 192 | 'i18n_default_address' => get_option( 'admin_email' ), |
| 193 | 'from_name' => get_bloginfo( 'name', 'display' ), |
| 194 | 'email_subject' => esc_html__( 'New Form Entry', 'everest-forms' ), |
| 195 | ) |
| 196 | ); |
| 197 | |
| 198 | wp_localize_script( |
| 199 | 'everest-forms-admin', |
| 200 | 'everest_forms_admin', |
| 201 | array( |
| 202 | 'ajax_import_nonce' => wp_create_nonce( 'process-import-ajax-nonce' ), |
| 203 | 'ajax_url' => admin_url( 'admin-ajax.php', 'relative' ), |
| 204 | 'i18n_field_meta_key_error' => esc_html__( 'Please enter in meta key with alphanumeric characters, dashes and underscores.', 'everest-forms' ), |
| 205 | 'i18n_field_min_value_greater' => esc_html__( 'Minimum value is greater than Maximum value.', 'everest-forms' ), |
| 206 | 'i18n_field_max_value_smaller' => esc_html__( 'Maximum value is smaller than Minimum value.', 'everest-forms' ), |
| 207 | 'i18n_form_export_action_error' => esc_html__( 'Please select a form which you want to export.', 'everest-forms' ), |
| 208 | ) |
| 209 | ); |
| 210 | } |
| 211 | |
| 212 | // EverestForms builder pages. |
| 213 | if ( in_array( $screen_id, array( 'everest-forms_page_evf-builder' ), true ) ) { |
| 214 | wp_enqueue_media(); |
| 215 | wp_enqueue_script( 'evf-upgrade' ); |
| 216 | wp_enqueue_script( 'evf-form-builder' ); |
| 217 | |
| 218 | // EverestForms builder setup page. |
| 219 | if ( isset( $_GET['create-form'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification |
| 220 | wp_register_script( 'evf-setup', evf()->plugin_url() . '/assets/js/admin/evf-setup' . $suffix . '.js', array( 'jquery', 'everest-forms-extensions', 'evf-template-controller' ), EVF_VERSION, true ); |
| 221 | wp_enqueue_script( 'evf-setup' ); |
| 222 | wp_localize_script( |
| 223 | 'evf-setup', |
| 224 | 'evf_setup_params', |
| 225 | array( |
| 226 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 227 | 'create_form_nonce' => wp_create_nonce( 'everest_forms_create_form' ), |
| 228 | 'template_licence_check_nonce' => wp_create_nonce( 'everest_forms_template_licence_check' ), |
| 229 | 'i18n_form_name' => esc_html__( 'Give it a name.', 'everest-forms' ), |
| 230 | 'i18n_form_error_name' => esc_html__( 'You must provide a Form name', 'everest-forms' ), |
| 231 | 'upgrade_url' => apply_filters( 'everest_forms_upgrade_url', 'https://wpeverest.com/wordpress-plugins/everest-forms/?utm_source=form-template&utm_medium=button&utm_campaign=evf-upgrade-to-pro' ), |
| 232 | 'upgrade_button' => esc_html__( 'Upgrade Plan', 'everest-forms' ), |
| 233 | 'upgrade_message' => esc_html__( 'This template requires premium addons. Please upgrade to the Premium plan to unlock all these awesome Templates.', 'everest-forms' ), |
| 234 | 'upgrade_title' => esc_html__( 'is a Premium Template', 'everest-forms' ), |
| 235 | 'i18n_form_ok' => esc_html__( 'Continue', 'everest-forms' ), |
| 236 | 'i18n_form_placeholder' => esc_html__( 'Untitled Form', 'everest-forms' ), |
| 237 | 'i18n_form_title' => esc_html__( 'Uplift your form experience to the next level.', 'everest-forms' ), |
| 238 | ) |
| 239 | ); |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | // Add-ons/extensions Page. |
| 244 | if ( 'everest-forms_page_evf-addons' === $screen_id ) { |
| 245 | wp_enqueue_script( 'everest-forms-extensions' ); |
| 246 | } |
| 247 | |
| 248 | // Plugins page. |
| 249 | if ( in_array( $screen_id, array( 'plugins' ), true ) ) { |
| 250 | wp_register_script( 'evf-plugins', evf()->plugin_url() . '/assets/js/admin/plugins' . $suffix . '.js', array( 'jquery' ), EVF_VERSION, true ); |
| 251 | wp_enqueue_script( 'evf-plugins' ); |
| 252 | wp_localize_script( |
| 253 | 'evf-plugins', |
| 254 | 'evf_plugins_params', |
| 255 | array( |
| 256 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 257 | 'deactivation_nonce' => wp_create_nonce( 'deactivation-notice' ), |
| 258 | ) |
| 259 | ); |
| 260 | } |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | return new EVF_Admin_Assets(); |
| 265 |