builder
2 months ago
form-migrator
3 months ago
plugin-updates
8 years ago
settings
2 months ago
views
2 months ago
class-evf-admin-addons.php
5 months ago
class-evf-admin-assets.php
2 months ago
class-evf-admin-builder.php
2 months ago
class-evf-admin-dashboard.php
3 months ago
class-evf-admin-editor.php
4 years ago
class-evf-admin-embed-wizard.php
2 years ago
class-evf-admin-entries-table-list.php
2 months ago
class-evf-admin-entries.php
2 months ago
class-evf-admin-form-templates.php
3 months ago
class-evf-admin-forms-table-list.php
5 months ago
class-evf-admin-forms.php
5 months ago
class-evf-admin-import-export.php
4 years ago
class-evf-admin-menus.php
3 months ago
class-evf-admin-notices.php
5 months ago
class-evf-admin-preview-confirmation.php
1 year ago
class-evf-admin-settings.php
3 months ago
class-evf-admin-tools.php
2 months ago
class-evf-admin-welcome.php
2 years ago
class-evf-admin.php
2 months ago
class-evf-base-list-table.php
5 months ago
evf-admin-functions.php
2 months ago
class-evf-admin-assets.php
570 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 | add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_dashboard_scripts' ), 1 ); |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * Enqueue styles. |
| 31 | */ |
| 32 | public function admin_styles() { |
| 33 | $screen = get_current_screen(); |
| 34 | $screen_id = $screen ? $screen->id : ''; |
| 35 | |
| 36 | // Register admin styles. |
| 37 | wp_register_style( 'everest-forms-admin', evf()->plugin_url() . '/assets/css/admin.css', array(), EVF_VERSION ); |
| 38 | wp_register_style( 'everest-forms-admin-menu', evf()->plugin_url() . '/assets/css/menu.css', array(), EVF_VERSION ); |
| 39 | wp_register_style( 'jquery-ui-style', evf()->plugin_url() . '/assets/css/jquery-ui/jquery-ui.min.css', array(), EVF_VERSION ); |
| 40 | wp_register_style( 'jquery-confirm', evf()->plugin_url() . '/assets/css/jquery-confirm/jquery-confirm.min.css', array(), '3.3.0' ); |
| 41 | wp_register_style( 'perfect-scrollbar', evf()->plugin_url() . '/assets/css/perfect-scrollbar/perfect-scrollbar.css', array(), '1.4.0' ); |
| 42 | wp_register_style( 'flatpickr', evf()->plugin_url() . '/assets/css/flatpickr.css', array(), EVF_VERSION ); |
| 43 | |
| 44 | // Add RTL support for admin styles. |
| 45 | wp_style_add_data( 'everest-forms-admin', 'rtl', 'replace' ); |
| 46 | wp_style_add_data( 'everest-forms-admin-menu', 'rtl', 'replace' ); |
| 47 | |
| 48 | |
| 49 | |
| 50 | // Sitewide menu CSS. |
| 51 | |
| 52 | |
| 53 | // Admin styles for EVF pages only. |
| 54 | if ( in_array( $screen_id, evf_get_screen_ids(), true ) ) { |
| 55 | // Show hint in codemirror. |
| 56 | wp_enqueue_style( 'wp-codemirror' ); |
| 57 | wp_enqueue_style( 'codemirror-hint-css', evf()->plugin_url() . '/assets/css/code-mirror/show-hint.min.css', array( 'wp-codemirror' ), EVF_VERSION ); |
| 58 | wp_enqueue_style( 'everest-forms-admin-menu' ); |
| 59 | wp_enqueue_style( 'everest-forms-admin' ); |
| 60 | wp_enqueue_style( 'jquery-confirm' ); |
| 61 | wp_enqueue_style( 'jquery-ui-style' ); |
| 62 | wp_enqueue_style( 'wp-color-picker' ); |
| 63 | wp_enqueue_style( 'flatpickr' ); |
| 64 | |
| 65 | if ( 'everest-forms_page_evf-tools' !== $screen_id ) { |
| 66 | wp_enqueue_style( 'perfect-scrollbar' ); |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Enqueue scripts. |
| 73 | */ |
| 74 | public function admin_scripts() { |
| 75 | global $post; |
| 76 | |
| 77 | $screen = get_current_screen(); |
| 78 | $screen_id = $screen ? $screen->id : ''; |
| 79 | $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
| 80 | |
| 81 | // Register scripts. |
| 82 | wp_register_script( 'selectWoo', evf()->plugin_url() . '/assets/js/selectWoo/selectWoo.full' . $suffix . '.js', array( 'jquery' ), '1.0.8', true ); |
| 83 | 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-clipboard', 'selectWoo' ), EVF_VERSION, true ); |
| 84 | wp_register_script( 'everest-forms-extensions', evf()->plugin_url() . '/assets/js/admin/extensions' . $suffix . '.js', array( 'jquery', 'updates', 'wp-i18n' ), EVF_VERSION, true ); |
| 85 | 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 ); |
| 86 | wp_register_script( 'everest-forms-editor', evf()->plugin_url() . '/assets/js/admin/editor' . $suffix . '.js', array( 'jquery' ), EVF_VERSION, true ); |
| 87 | wp_register_script( 'jquery-blockui', evf()->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array( 'jquery' ), '2.70', true ); |
| 88 | wp_register_script( 'jquery-confirm', evf()->plugin_url() . '/assets/js/jquery-confirm/jquery-confirm' . $suffix . '.js', array( 'jquery' ), '3.3.0', true ); |
| 89 | wp_register_script( 'jquery-tiptip', evf()->plugin_url() . '/assets/js/jquery-tiptip/jquery.tipTip' . $suffix . '.js', array( 'jquery' ), EVF_VERSION, true ); // @deprecated |
| 90 | wp_register_script( 'tooltipster', evf()->plugin_url() . '/assets/js/tooltipster/tooltipster.bundle' . $suffix . '.js', array( 'jquery' ), '4.6.2', true ); |
| 91 | wp_register_script( 'perfect-scrollbar', evf()->plugin_url() . '/assets/js/perfect-scrollbar/perfect-scrollbar' . $suffix . '.js', array( 'jquery' ), '1.5.0', true ); |
| 92 | wp_register_script( 'evf-clipboard', evf()->plugin_url() . '/assets/js/admin/evf-clipboard' . $suffix . '.js', array( 'jquery' ), EVF_VERSION, true ); |
| 93 | wp_register_script( 'evf-enhanced-select', evf()->plugin_url() . '/assets/js/admin/evf-enhanced-select' . $suffix . '.js', array( 'jquery', 'selectWoo' ), EVF_VERSION, true ); |
| 94 | wp_register_script( 'evf-template-controller', evf()->plugin_url() . '/assets/js/admin/form-template-controller' . $suffix . '.js', array( 'jquery' ), EVF_VERSION, true ); |
| 95 | wp_register_script( 'flatpickr', evf()->plugin_url() . '/assets/js/flatpickr/flatpickr' . $suffix . '.js', array( 'jquery' ), '4.6.3', true ); |
| 96 | wp_register_script( 'evf-file-uploader', evf()->plugin_url() . '/assets/js/admin/evf-file-uploader' . $suffix . '.js', array(), EVF_VERSION, true ); |
| 97 | // Register admin scripts for survey fields. |
| 98 | wp_register_script( 'everest-forms-survey-polls-quiz-builder', evf()->plugin_url() . "/assets/js/admin/everest-forms-survey-polls-quiz-builder{$suffix}.js", array( 'jquery', 'wp-util', 'underscore', 'jquery-ui-sortable' ), EVF_VERSION, true ); |
| 99 | wp_register_script( 'random-color', evf()->plugin_url() . "/assets/js/admin/randomColor{$suffix}.js", array(), EVF_VERSION, true ); |
| 100 | wp_register_script( 'chart', evf()->plugin_url() . "/assets/js/admin/chart{$suffix}.js", array(), EVF_VERSION, true ); |
| 101 | wp_register_script( 'print_this', evf()->plugin_url() . '/assets/js/admin/printThis.min.js', array(), EVF_VERSION, true ); |
| 102 | wp_register_script( 'progress_bar', evf()->plugin_url() . "/assets/js/admin/progressbar{$suffix}.js", array(), EVF_VERSION, true ); |
| 103 | wp_register_script( 'evf-import-entries-form-csv', evf()->plugin_url() . '/assets/js/admin/tool-import-entries' . $suffix . '.js', array( 'jquery' ), EVF_VERSION, true ); |
| 104 | |
| 105 | //Disable drag for jquery confirm. |
| 106 | // wp_add_inline_script( |
| 107 | // 'jquery-confirm', |
| 108 | // '(function($){if(window.Jconfirm&&window.Jconfirm.prototype){window.Jconfirm.prototype.initDraggable=function(){this.draggable=false;this.resetDrag();};}})(jQuery);', |
| 109 | // 'after' |
| 110 | // ); |
| 111 | /** |
| 112 | * Roles and permission. |
| 113 | * |
| 114 | * @since 3.0.8 |
| 115 | */ |
| 116 | wp_register_script( 'evf-tool-roles-and-permission', evf()->plugin_url() . '/dist/rolesandpermission.min.js', array( 'wp-element', 'react', 'react-dom', 'wp-api-fetch', 'wp-i18n', 'wp-blocks' ), EVF_VERSION, true ); |
| 117 | |
| 118 | wp_localize_script( |
| 119 | 'evf-file-uploader', |
| 120 | 'evf_file_uploader', |
| 121 | array( |
| 122 | 'upload_file' => __( 'Upload Image', 'everest-forms' ), |
| 123 | ) |
| 124 | ); |
| 125 | wp_localize_script( |
| 126 | 'evf-template-controller', |
| 127 | 'evf_templates', |
| 128 | array( |
| 129 | 'evf_template_all' => EVF_Admin_Form_Templates::get_template_data(), |
| 130 | 'i18n_get_started' => esc_html__( 'Get Started', 'everest-forms' ), |
| 131 | 'i18n_get_preview' => esc_html__( 'Preview', 'everest-forms' ), |
| 132 | 'i18n_pro_feature' => esc_html__( 'Pro', 'everest-forms' ), |
| 133 | 'template_refresh' => esc_html__( 'Updating Templates', 'everest-forms' ), |
| 134 | 'evf_plugin_url' => esc_url( evf()->plugin_url() ), |
| 135 | ) |
| 136 | ); |
| 137 | wp_localize_script( |
| 138 | 'evf-enhanced-select', |
| 139 | 'evf_enhanced_select_params', |
| 140 | array( |
| 141 | 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'everest-forms' ), |
| 142 | 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'everest-forms' ), |
| 143 | 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'everest-forms' ), |
| 144 | 'i18n_input_too_short_n' => _x( 'Please enter %qty% or more characters', 'enhanced select', 'everest-forms' ), |
| 145 | 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'everest-forms' ), |
| 146 | 'i18n_input_too_long_n' => _x( 'Please delete %qty% characters', 'enhanced select', 'everest-forms' ), |
| 147 | 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'everest-forms' ), |
| 148 | 'i18n_selection_too_long_n' => _x( 'You can only select %qty% items', 'enhanced select', 'everest-forms' ), |
| 149 | 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'everest-forms' ), |
| 150 | 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'everest-forms' ), |
| 151 | 'i18n_select_all' => _x( 'Select All', 'enhanced select', 'everest-forms' ), |
| 152 | 'i18n_unselect_all' => _x( 'Unselect All', 'enhanced select', 'everest-forms' ), |
| 153 | ) |
| 154 | ); |
| 155 | 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', 'flatpickr' ), EVF_VERSION, true ); |
| 156 | wp_localize_script( |
| 157 | 'evf-form-builder', |
| 158 | 'evf_data', |
| 159 | apply_filters( |
| 160 | 'everest_forms_builder_strings', |
| 161 | array( |
| 162 | 'post_id' => isset( $post->ID ) ? $post->ID : '', |
| 163 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 164 | 'tab' => isset( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : '', // phpcs:ignore WordPress.Security.NonceVerification. |
| 165 | 'evf_field_drop_nonce' => wp_create_nonce( 'everest_forms_field_drop' ), |
| 166 | 'evf_add_row_nonce' => wp_create_nonce( 'everest_forms_add_row' ), |
| 167 | 'evf_save_form' => wp_create_nonce( 'everest_forms_save_form' ), |
| 168 | 'evf_embed_form' => wp_create_nonce( 'everest_forms_embed_form' ), |
| 169 | 'evf_goto_edit_page' => wp_create_nonce( 'everest_forms_goto_edit_page' ), |
| 170 | 'evf_get_next_id' => wp_create_nonce( 'everest_forms_get_next_id' ), |
| 171 | 'evf_enabled_form' => wp_create_nonce( 'everest_forms_enabled_form' ), |
| 172 | 'form_id' => isset( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : 0, // phpcs:ignore WordPress.Security.NonceVerification |
| 173 | 'field' => esc_html__( 'field', 'everest-forms' ), |
| 174 | 'i18n_ok' => esc_html__( 'OK', 'everest-forms' ), |
| 175 | 'i18n_installing' => esc_html__( 'Installing', 'everest-forms' ), |
| 176 | 'i18n_activating' => esc_html__( 'Activating', 'everest-forms' ), |
| 177 | 'i18n_install_activate' => esc_html__( 'Install & Activate', 'everest-forms' ), |
| 178 | 'i18n_install_only' => esc_html__( 'Activate Plugins', 'everest-forms' ), |
| 179 | 'i18n_copy' => esc_html__( '(copy)', 'everest-forms' ), |
| 180 | 'i18n_close' => esc_html__( 'Close', 'everest-forms' ), |
| 181 | 'i18n_cancel' => esc_html__( 'Cancel', 'everest-forms' ), |
| 182 | 'i18n_row_locked' => esc_html__( 'Row Locked', 'everest-forms' ), |
| 183 | 'i18n_single_row_locked_msg' => esc_html__( 'Single row cannot be deleted.', 'everest-forms' ), |
| 184 | 'i18n_field_locked' => esc_html__( 'Field Locked', 'everest-forms' ), |
| 185 | 'i18n_field_locked_msg' => esc_html__( 'This field cannot be deleted or duplicated.', 'everest-forms' ), |
| 186 | 'i18n_row_locked_msg' => esc_html__( 'This row cannot be deleted or duplicated.', 'everest-forms' ), |
| 187 | 'i18n_field_error_choice' => esc_html__( 'This item must contain at least one choice.', 'everest-forms' ), |
| 188 | 'i18n_delete_row_confirm' => esc_html__( 'Are you sure you want to delete this row?', 'everest-forms' ), |
| 189 | 'i18n_delete_field_confirm' => esc_html__( 'Are you sure you want to delete this field?', 'everest-forms' ), |
| 190 | 'i18n_duplicate_field_confirm' => esc_html__( 'Are you sure you want to duplicate this field?', 'everest-forms' ), |
| 191 | 'i18n_duplicate_row_confirm' => esc_html__( 'Are you sure you want to duplicate this row?', 'everest-forms' ), |
| 192 | 'i18n_email_disable_message' => esc_html__( 'Turn on Email settings to manage your email notification.', 'everest-forms' ), |
| 193 | 'i18n_upload_image_title' => esc_html__( 'Choose an image', 'everest-forms' ), |
| 194 | 'i18n_upload_image_button' => esc_html__( 'Use Image', 'everest-forms' ), |
| 195 | 'i18n_upload_image_remove' => esc_html__( 'Remove Image', 'everest-forms' ), |
| 196 | 'i18n_field_title_empty' => esc_html__( 'Empty Form Name', 'everest-forms' ), |
| 197 | 'i18n_shortcut_key_title' => esc_html__( 'keyboard Shortcut Keys', 'everest-forms' ), |
| 198 | 'i18n_shortcut_keys' => array( |
| 199 | 'Ctrl+S' => esc_html__( 'Save Builder', 'everest-forms' ), |
| 200 | 'Ctrl+W' => esc_html__( 'Close Builder', 'everest-forms' ), |
| 201 | 'Ctrl+P' => esc_html__( 'Preview Form', 'everest-forms' ), |
| 202 | 'Ctrl+E' => esc_html__( 'Go to Entries', 'everest-forms' ), |
| 203 | 'Ctrl+H' => esc_html__( 'Open Help', 'everest-forms' ), |
| 204 | ), |
| 205 | 'i18n_field_title_payload' => esc_html__( 'Form name can\'t be empty.', 'everest-forms' ), |
| 206 | 'email_fields' => evf_get_all_email_fields_by_form_id( isset( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : 0 ), // phpcs:ignore WordPress.Security.NonceVerification |
| 207 | 'all_fields' => evf_get_all_form_fields_by_form_id( isset( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : 0 ), // phpcs:ignore WordPress.Security.NonceVerification |
| 208 | 'smart_tags_other' => evf()->smart_tags->other_smart_tags(), |
| 209 | 'regex_expression_lists' => evf()->smart_tags->regex_expression_lists(), |
| 210 | 'entries_url' => ! empty( $_GET['form_id'] ) ? esc_url( admin_url( 'admin.php?page=evf-entries&form_id=' . absint( $_GET['form_id'] ) ) ) : '', // phpcs:ignore WordPress.Security.NonceVerification |
| 211 | 'preview_url' => ! empty( $_GET['form_id'] ) ? esc_url( // phpcs:ignore WordPress.Security.NonceVerification |
| 212 | add_query_arg( |
| 213 | array( |
| 214 | 'form_id' => absint( $_GET['form_id'] ), // phpcs:ignore WordPress.Security.NonceVerification |
| 215 | 'evf_preview' => 'true', |
| 216 | ), |
| 217 | home_url() |
| 218 | ) |
| 219 | ) : '', |
| 220 | 'form_one_time_draggable_fields' => evf_get_one_time_draggable_fields(), |
| 221 | 'i18n_privacy_policy_consent_message' => esc_html__( 'I allow this website to collect and store the submitted data.', 'everest-forms' ), |
| 222 | 'is_pro' => ( ! defined( 'EFP_PLUGIN_FILE' ) ) ? false : true, |
| 223 | 'select_form_tags_placeholder' => __( 'Please choose a tags from the list, or type in a new tag if you\'d like to add one.', 'everest-forms' ), |
| 224 | ) |
| 225 | ) |
| 226 | ); |
| 227 | |
| 228 | // Builder upgrade. |
| 229 | wp_register_script( 'evf-upgrade', evf()->plugin_url() . '/assets/js/admin/upgrade.js', array( 'jquery', 'jquery-confirm' ), EVF_VERSION, false ); |
| 230 | wp_localize_script( |
| 231 | 'evf-upgrade', |
| 232 | 'evf_upgrade', |
| 233 | array( |
| 234 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 235 | 'upgrade_title' => esc_html__( 'is a PRO Feature', 'everest-forms' ), |
| 236 | 'upgrade_message' => esc_html__( 'We\'re sorry, the %name% is not available on your plan.<br>Please upgrade to the PRO plan to unlock all these awesome features.', 'everest-forms' ), |
| 237 | 'upgrade_button' => esc_html__( 'Upgrade to PRO', 'everest-forms' ), |
| 238 | 'upgrade_url' => apply_filters( 'everest_forms_upgrade_url', 'https://everestforms.net/upgrade/?utm_medium=evf-form-builder&utm_source=evf-free&utm_campaign=builder-pro-field-popup&utm_content=Upgrade%20to%20Pro' ), |
| 239 | 'upgrade_integration_url_form' => apply_filters( 'everest_forms_upgrade_integration_url', 'https://everestforms.net/upgrade/?utm_medium=evf-form-setting&utm_source=evf-free&utm_campaign=form-setting-pro-popup&utm_content=Upgrade%20to%20Pro' ), |
| 240 | 'upgrade_integration_url' => apply_filters( 'everest_forms_upgrade_integration_url', 'https://everestforms.net/upgrade/?utm_medium=evf-global-setting&utm_source=evf-free&utm_campaign=integration-setting-popup' ), |
| 241 | 'enable_stripe_title' => esc_html__( 'Please enable Stripe', 'everest-forms' ), |
| 242 | 'recaptcha_title' => esc_html__( 'reCaptcha', 'everest-forms' ), |
| 243 | 'recaptcha_api_key_message' => esc_html__( 'Please enter a reCaptcha key on Everest Forms>Settings>Captcha>reCaptcha.', 'everest-forms' ), |
| 244 | 'hcaptcha_title' => esc_html__( 'hCaptcha', 'everest-forms' ), |
| 245 | 'hcaptcha_api_key_message' => esc_html__( 'Please enter a hCaptcha key on Everest Forms>Settings>Captcha>hCaptcha.', 'everest-forms' ), |
| 246 | 'turnstile_title' => esc_html__( ' Cloudflare Turnstile', 'everest-forms' ), |
| 247 | 'turnstile_api_key_message' => esc_html__( 'Please enter a Cloudflare Turnstile key on Everest Forms>Settings>Captcha>Cloudflare Turnstile.', 'everest-forms' ), |
| 248 | 'enable_stripe_message' => esc_html__( 'Enable Stripe Payment gateway in payments section to use this field.', 'everest-forms' ), |
| 249 | 'enable_authorize_net_title' => esc_html__( 'Please enable Authorize.Net', 'everest-forms' ), |
| 250 | 'enable_authorize_net_message' => esc_html__( 'Enable Authorize.Net Payment gateway in payments section to use this field.', 'everest-forms' ), |
| 251 | 'enable_square_title' => esc_html( 'Please enable Square', 'everest-forms' ), |
| 252 | 'enable_square_message' => esc_html__( 'Enable Square Payment gateway in payments section to use this field.', 'everest-forms' ), |
| 253 | 'enable_recurring_period_title' => esc_html__( 'Enable Recurring Subscription', 'everest-forms' ), |
| 254 | 'enable_recurring_period_message' => esc_html__( 'Recurring Subscription Payment is disabled. Please enable it in the to use the Subscription Plan field.', 'everest-forms' ), |
| 255 | 'evf_install_and_active_nonce' => wp_create_nonce( 'install_and_active_nonce' ), |
| 256 | 'upgrade_plan_title' => esc_html__( 'is a Premium Addon', 'everest-forms' ), |
| 257 | 'upgrade_plan_message' => esc_html__( 'This addon requires premium plan. Please upgrade to the Premium plan to unlock all these awesome field.', 'everest-forms' ), |
| 258 | 'upgrade_plan_button' => esc_html__( 'Upgrade Plan', 'everest-forms' ), |
| 259 | 'admin_url' => admin_url(), |
| 260 | 'vedio_links' => array( |
| 261 | 'dropdown' => 'kDYAKElqNtM', |
| 262 | ), |
| 263 | 'evf_one_time_draggable_title' => esc_html__( 'File upload', 'everest-forms' ), |
| 264 | 'evf_one_time_draggable_message' => esc_html__( 'field can only be used once. To use it multiple times, please upgrade to the pro version.', 'everest-forms' ), |
| 265 | 'evf_file_upload_free_file_limit_message' => esc_html__( 'You can upload only one file at a time. To upload more than one file at a time, please upgrade to the pro version.', 'everest-forms' ), |
| 266 | |
| 267 | ) |
| 268 | ); |
| 269 | |
| 270 | // EverestForms admin pages. |
| 271 | if ( in_array( $screen_id, evf_get_screen_ids(), true ) ) { |
| 272 | wp_enqueue_script( 'everest-forms-admin' ); |
| 273 | wp_enqueue_script( 'everest-forms-email-admin' ); |
| 274 | wp_enqueue_script( 'evf-enhanced-select' ); |
| 275 | wp_enqueue_script( 'jquery-ui-sortable' ); |
| 276 | wp_enqueue_script( 'jquery-ui-autocomplete' ); |
| 277 | wp_enqueue_script( 'evf-upgrade' ); |
| 278 | |
| 279 | wp_localize_script( |
| 280 | 'everest-forms-email-admin', |
| 281 | 'evf_email_params', |
| 282 | array( |
| 283 | 'i18n_email_connection' => esc_html__( 'Enter a Email nickname', 'everest-forms' ), |
| 284 | 'i18n_email_placeholder' => esc_html__( 'Eg: Support Email', 'everest-forms' ), |
| 285 | 'i18n_email_error_name' => esc_html__( 'You must provide a Email nickname', 'everest-forms' ), |
| 286 | 'i18n_email_ok' => esc_html__( 'OK', 'everest-forms' ), |
| 287 | 'ajax_email_nonce' => wp_create_nonce( 'process-ajax-nonce' ), |
| 288 | 'ajax_url' => admin_url( 'admin-ajax.php', 'relative' ), |
| 289 | 'i18n_email_cancel' => esc_html__( 'Cancel', 'everest-forms' ), |
| 290 | 'i18n_default_address' => get_option( 'admin_email' ), |
| 291 | 'from_name' => get_bloginfo( 'name', 'display' ), |
| 292 | 'email_subject' => esc_html__( 'New Form Entry', 'everest-forms' ), |
| 293 | ) |
| 294 | ); |
| 295 | |
| 296 | wp_localize_script( |
| 297 | 'everest-forms-admin', |
| 298 | 'everest_forms_admin', |
| 299 | array( |
| 300 | 'ajax_import_nonce' => wp_create_nonce( 'process-import-ajax-nonce' ), |
| 301 | 'evf_search_addons' => wp_create_nonce( 'everest_forms_search_addons' ), |
| 302 | 'ajax_url' => admin_url( 'admin-ajax.php', 'relative' ), |
| 303 | 'i18n_field_meta_key_error' => esc_html__( 'Please enter in meta key with alphanumeric characters, dashes and underscores.', 'everest-forms' ), |
| 304 | 'i18n_field_min_value_greater' => esc_html__( 'Minimum value is greater than Maximum value.', 'everest-forms' ), |
| 305 | 'i18n_field_max_value_smaller' => esc_html__( 'Maximum value is smaller than Minimum value.', 'everest-forms' ), |
| 306 | 'i18n_field_def_value_greater' => esc_html__( 'Default value is greater than Maximum value.', 'everest-forms' ), |
| 307 | 'i18n_field_def_value_smaller' => esc_html__( 'Default value is smaller than Minimum value.', 'everest-forms' ), |
| 308 | 'i18n_form_export_action_error' => esc_html__( 'Please select a form which you want to export.', 'everest-forms' ), |
| 309 | 'i18n_log_copied' => esc_html__( 'Copied!', 'everest-forms' ), |
| 310 | 'smart_smtp_install_and_activate_nonce' => wp_create_nonce( 'everest-forms-smart-smtp-installation-nonce' ), |
| 311 | ) |
| 312 | ); |
| 313 | |
| 314 | wp_localize_script( |
| 315 | 'everest-forms-admin', |
| 316 | 'evf_admin_manage_tags', |
| 317 | array( |
| 318 | 'ajax_manage_tags_nonce' => wp_create_nonce( 'ajax_manage_tags_nonce' ), |
| 319 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 320 | 'manage_tags_title' => __( 'Are you sure want to delete selected tags?', 'everest-forms' ), |
| 321 | 'manage_tags_desc' => __( |
| 322 | 'Delete tags that you\'re no longer using. Deleting a tag will remove it from a form, but will not delete the form itself.', |
| 323 | 'everest-forms' |
| 324 | ), |
| 325 | ) |
| 326 | ); |
| 327 | |
| 328 | wp_localize_script( |
| 329 | 'evf-import-entries-form-csv', |
| 330 | 'evf_import_entries_obj', |
| 331 | array( |
| 332 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 333 | 'nonce' => wp_create_nonce( 'evf-import-entries' ), |
| 334 | ) |
| 335 | ); |
| 336 | |
| 337 | wp_localize_script( |
| 338 | 'evf-tool-roles-and-permission', |
| 339 | 'evf_roles_and_permission', |
| 340 | array( |
| 341 | 'security' => wp_create_nonce( 'wp_rest' ), |
| 342 | 'restURL' => rest_url(), |
| 343 | 'not_found_image' => evf()->plugin_url() . '/assets/images/not-found-image.png', |
| 344 | ) |
| 345 | ); |
| 346 | |
| 347 | wp_localize_script( |
| 348 | 'everest-forms-admin', |
| 349 | 'everest_forms_admin_locate', |
| 350 | array( |
| 351 | 'ajax_locate_nonce' => wp_create_nonce( 'process-locate-ajax-nonce' ), |
| 352 | 'ajax_url' => admin_url( 'admin-ajax.php', 'relative' ), |
| 353 | 'form_found_error' => esc_html__( 'Form not found in content', 'everest-forms' ), |
| 354 | 'form_found' => esc_html__( 'Form found in page:', 'everest-forms' ), |
| 355 | ) |
| 356 | ); |
| 357 | |
| 358 | wp_localize_script( |
| 359 | 'everest-forms-admin', |
| 360 | 'everest_forms_admin_generate_restapi_key', |
| 361 | array( |
| 362 | 'ajax_restapi_key_nonce' => wp_create_nonce( 'process-restapi-api-ajax-nonce' ), |
| 363 | 'ajax_url' => admin_url( 'admin-ajax.php', 'relative' ), |
| 364 | ) |
| 365 | ); |
| 366 | |
| 367 | wp_localize_script( |
| 368 | 'everest-forms-admin', |
| 369 | 'everest_forms_admin_form_migrator', |
| 370 | array( |
| 371 | 'evf_fm_dismiss_notice_nonce' => wp_create_nonce( 'evf_fm_dismiss_notice_nonce' ), |
| 372 | 'ajax_url' => admin_url( 'admin-ajax.php', 'relative' ), |
| 373 | ) |
| 374 | ); |
| 375 | } |
| 376 | |
| 377 | // EverestForms builder pages. |
| 378 | if ( in_array( $screen_id, array( 'everest-forms_page_evf-builder' ), true ) ) { |
| 379 | wp_enqueue_media(); |
| 380 | wp_enqueue_script( 'evf-upgrade' ); |
| 381 | wp_enqueue_script( 'evf-form-builder' ); |
| 382 | |
| 383 | wp_enqueue_script( 'wp-codemirror' ); |
| 384 | // Enqueue additional scripts for hints if not included by default. |
| 385 | // wp_enqueue_script( 'codemirror-hint', evf()->plugin_url() . '/assets/js/code-mirror/show-hint' . $suffix . '.js', array( 'wp-codemirror' ), EVF_VERSION, true ); |
| 386 | |
| 387 | // De-register scripts. |
| 388 | wp_dequeue_script( 'colorpick' ); |
| 389 | |
| 390 | // EverestForms builder setup page. |
| 391 | if ( isset( $_GET['create-form'] ) || isset( $_GET['form_id'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification |
| 392 | 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 ); |
| 393 | wp_enqueue_script( 'evf-setup' ); |
| 394 | wp_localize_script( |
| 395 | 'evf-setup', |
| 396 | 'evf_setup_params', |
| 397 | array( |
| 398 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 399 | 'create_form_nonce' => wp_create_nonce( 'everest_forms_create_form' ), |
| 400 | 'evf_active_nonce' => wp_create_nonce( 'evf_active_nonce' ), |
| 401 | 'template_licence_check_nonce' => wp_create_nonce( 'everest_forms_template_licence_check' ), |
| 402 | 'i18n_form_name' => esc_html__( 'Give it a name.', 'everest-forms' ), |
| 403 | 'i18n_form_error_name' => esc_html__( 'You must provide a Form name', 'everest-forms' ), |
| 404 | 'upgrade_url' => apply_filters( 'everest_forms_upgrade_url', 'https://everestforms.net/upgrade/?utm_medium=evf-template-page&utm_source=evf-free&utm_campaign=template-premium-popup' ), |
| 405 | 'upgrade_button' => esc_html__( 'Upgrade Plan', 'everest-forms' ), |
| 406 | 'upgrade_message' => esc_html__( 'This template requires premium addons. Please upgrade to the Premium plan to unlock all these awesome Templates.', 'everest-forms' ), |
| 407 | 'upgrade_title' => esc_html__( 'is a Premium Template', 'everest-forms' ), |
| 408 | 'i18n_form_ok' => esc_html__( 'Continue', 'everest-forms' ), |
| 409 | 'i18n_form_placeholder' => esc_html__( 'Untitled Form', 'everest-forms' ), |
| 410 | 'i18n_form_title' => esc_html__( 'Uplift your form experience to the next level.', 'everest-forms' ), |
| 411 | 'i18n_installing' => esc_html__( 'installing', 'everest-forms' ), |
| 412 | 'save_changes_text' => esc_html__( 'Save and Reload', 'everest-forms' ), |
| 413 | 'reload_text' => esc_html__( 'Just Reload', 'everest-forms' ), |
| 414 | 'active_confirmation_title' => esc_html__( 'Activation Successful.', 'everest-forms' ), |
| 415 | 'install_confirmation_title' => esc_html__( 'Installation Successful.', 'everest-forms' ), |
| 416 | 'install_confirmation_message' => esc_html__( 'Addons have been installed and Activated. You have to reload the page', 'everest-forms' ), |
| 417 | 'active_confirmation_message' => esc_html__( 'Addons have been Activated. You have to reload the page', 'everest-forms' ), |
| 418 | 'download_failed' => esc_html__( 'Download Failed', 'everest-forms' ), |
| 419 | 'installing_title' => esc_html__( 'Installing...', 'everest-forms' ), |
| 420 | 'activate_title' => esc_html__( 'Activating...', 'everest-forms' ), |
| 421 | 'installing_message' => esc_html__( 'Please wait while the addon is being installed.', 'everest-forms' ), |
| 422 | 'activate_message' => esc_html__( 'Please wait while the addon is being activated.', 'everest-forms' ), |
| 423 | ) |
| 424 | ); |
| 425 | } |
| 426 | } |
| 427 | |
| 428 | if ( in_array( $screen_id, evf_get_screen_ids(), true ) ) { |
| 429 | wp_enqueue_style( 'everest-forms-survey-polls-quiz-admin' ); |
| 430 | wp_enqueue_script( 'everest-forms-survey-polls-quiz-builder' ); |
| 431 | wp_enqueue_script( 'random-color' ); |
| 432 | // wp_enqueue_script( 'chart' ); //for future use. |
| 433 | if ( isset( $_GET['page'], $_GET['tab'] ) && $_GET['page'] === 'evf-tools' && $_GET['tab'] === 'roles_and_permission' ) { |
| 434 | wp_enqueue_script( 'evf-tool-roles-and-permission' ); |
| 435 | } |
| 436 | |
| 437 | wp_enqueue_script( 'progress_bar' ); |
| 438 | wp_enqueue_script( 'evf-import-entries-form-csv' ); |
| 439 | wp_enqueue_script( 'print_this' ); |
| 440 | wp_localize_script( |
| 441 | 'everest-forms-survey-polls-quiz-builder', |
| 442 | 'everest_forms_survey_polls_quiz_builder', |
| 443 | array( |
| 444 | 'ajax_url' => admin_url( 'admin-ajax.php', 'relative' ), |
| 445 | 'admin_url' => admin_url(), |
| 446 | 'ajax_nonce' => wp_create_nonce( 'process-ajax-nonce' ), |
| 447 | 'i18n_field_less_than_highest_point_error' => esc_html__( 'Please enter in a value less than the highest rating point.', 'everest-forms' ), |
| 448 | 'i18n_field_greater_than_lowest_point_error' => esc_html__( 'Please enter in a value greater than the lowest rating point.', 'everest-forms' ), |
| 449 | 'i18n_field_lowest_rating_lower_than_min_value_error' => esc_html__( 'Please enter in a value greater or equal to 0.', 'everest-forms' ), |
| 450 | 'i18n_field_highest_rating_greater_than_max_value_error' => esc_html__( 'Please enter in a value less than 100.', 'everest-forms' ), |
| 451 | 'i18n_field_from_score_greater_than_to_score' => esc_html__( 'Please enter in a value greater than From Score.', 'everest-forms' ), |
| 452 | 'i18n_field_to_score_is_empty_error' => esc_html__( 'Please enter in a value to add more feedback.', 'everest-forms' ), |
| 453 | ) |
| 454 | ); |
| 455 | } |
| 456 | |
| 457 | // Tools page. |
| 458 | if ( 'everest-forms_page_evf-tools' === $screen_id ) { |
| 459 | wp_register_script( 'evf-admin-tools', evf()->plugin_url() . '/assets/js/admin/tools' . $suffix . '.js', array( 'jquery' ), EVF_VERSION, true ); |
| 460 | wp_enqueue_script( 'evf-admin-tools' ); |
| 461 | wp_localize_script( |
| 462 | 'evf-admin-tools', |
| 463 | 'everest_forms_admin_tools', |
| 464 | array( |
| 465 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 466 | 'delete_log_confirmation' => esc_js( esc_html__( 'Are you sure you want to delete this log?', 'everest-forms' ) ), |
| 467 | 'delete_all_log_confirmation' => esc_js( esc_html__( 'Are you sure you want to delete all logs?', 'everest-forms' ) ), |
| 468 | ) |
| 469 | ); |
| 470 | wp_localize_script( |
| 471 | 'evf-admin-tools', |
| 472 | 'everest_forms_form_migrator', |
| 473 | array( |
| 474 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 475 | 'evf_form_migrator_forms_list_nonce' => wp_create_nonce( 'evf_form_migrator_forms_list_nonce' ), |
| 476 | 'evf_form_migrator_nonce' => wp_create_nonce( 'evf_form_migrator_nonce' ), |
| 477 | 'evf_form_entry_migrator_nonce' => wp_create_nonce( 'evf_form_entry_migrator_nonce' ), |
| 478 | ) |
| 479 | ); |
| 480 | } |
| 481 | |
| 482 | // Add-ons/extensions page. |
| 483 | if ( 'everest-forms_page_evf-addons' === $screen_id ) { |
| 484 | wp_enqueue_script( 'everest-forms-extensions' ); |
| 485 | } |
| 486 | } |
| 487 | |
| 488 | /** |
| 489 | * Enqueue dashboard scripts (React). |
| 490 | * |
| 491 | * ADD THIS ENTIRE METHOD AFTER __construct() AND BEFORE admin_styles() |
| 492 | */ |
| 493 | /** |
| 494 | * Enqueue dashboard scripts (React). |
| 495 | */ |
| 496 | public function enqueue_dashboard_scripts() { |
| 497 | $screen_id = get_current_screen()->id; |
| 498 | if ( ! in_array( $screen_id, evf_get_screen_ids(), true ) ) { |
| 499 | return; |
| 500 | } |
| 501 | |
| 502 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 503 | $current_page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; |
| 504 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 505 | $current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : 'general'; |
| 506 | |
| 507 | wp_enqueue_script( |
| 508 | 'evf-dashboard-header', |
| 509 | evf()->plugin_url() . '/dist/dashboardHeader.min.js', |
| 510 | array( 'wp-element', 'wp-i18n' ), |
| 511 | EVF_VERSION, |
| 512 | true |
| 513 | ); |
| 514 | |
| 515 | $script_handle = 'evf-dashboard-header'; |
| 516 | |
| 517 | // Enqueue dashboard app on free analytics page so FreeAnalyticsContent mounts on #evf-analytics-root. |
| 518 | if ( 'evf-analytics' === $current_page && ! defined( 'EFP_PLUGIN_FILE' ) ) { |
| 519 | wp_enqueue_style( |
| 520 | 'evf-dashboard-style', |
| 521 | evf()->plugin_url() . '/dist/dashboard.css', |
| 522 | array(), |
| 523 | EVF_VERSION |
| 524 | ); |
| 525 | wp_enqueue_script( |
| 526 | 'evf-dashboard-script', |
| 527 | evf()->plugin_url() . '/dist/dashboard.min.js', |
| 528 | array( 'wp-element', 'wp-hooks', 'react', 'react-dom' ), |
| 529 | EVF_VERSION, |
| 530 | true |
| 531 | ); |
| 532 | } |
| 533 | |
| 534 | if ( 'evf-entries' === $current_page ) { |
| 535 | $page_type = 'entries'; |
| 536 | } elseif ( 'evf-settings' === $current_page ) { |
| 537 | $page_type = 'settings'; |
| 538 | } elseif ( 'everest-forms-analytics' === $current_page || 'evf-analytics' === $current_page ) { |
| 539 | $page_type = 'analytics'; |
| 540 | } else { |
| 541 | $page_type = $current_page; |
| 542 | } |
| 543 | |
| 544 | wp_localize_script( |
| 545 | $script_handle, |
| 546 | '_EVF_DASHBOARD_', |
| 547 | array( |
| 548 | 'version' => EVF_VERSION, |
| 549 | 'isPro' => defined( 'EFP_PLUGIN_FILE' ), |
| 550 | 'showAnalyticsTab' => is_plugin_active( 'everest-forms-form-analytics/everest-forms-form-analytics.php' ), |
| 551 | 'upgradeURL' => 'https://everestforms.net/pricing/?', |
| 552 | 'adminURL' => admin_url( 'admin.php' ), |
| 553 | 'ajaxURL' => admin_url( 'admin-ajax.php' ), |
| 554 | 'evfRestApiNonce' => wp_create_nonce( 'wp_rest' ), |
| 555 | 'restURL' => rest_url(), |
| 556 | 'nonce' => wp_create_nonce( 'evf_admin' ), |
| 557 | 'pageType' => $page_type, |
| 558 | 'currentPage' => $current_page, |
| 559 | 'currentTab' => $current_tab, |
| 560 | 'allStepsCompleted' => ( |
| 561 | EVF_Admin_Dashboard::is_spam_protection_completed() |
| 562 | && (bool) get_option( 'everest_forms_test_email_sent', false ) |
| 563 | ) ? '1' : '0', |
| 564 | ) |
| 565 | ); |
| 566 | } |
| 567 | } |
| 568 | |
| 569 | return new EVF_Admin_Assets(); |
| 570 |