builder
3 weeks ago
form-migrator
3 weeks ago
plugin-updates
8 years ago
settings
3 weeks ago
views
3 weeks ago
class-evf-admin-addons.php
4 months ago
class-evf-admin-assets.php
5 days ago
class-evf-admin-builder.php
2 months ago
class-evf-admin-dashboard.php
3 weeks 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 weeks ago
class-evf-admin-forms-table-list.php
4 months ago
class-evf-admin-forms.php
4 months ago
class-evf-admin-import-export.php
3 weeks ago
class-evf-admin-menus.php
3 weeks ago
class-evf-admin-notices.php
4 months ago
class-evf-admin-preview-confirmation.php
11 months ago
class-evf-admin-settings.php
3 weeks 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
4 months ago
evf-admin-functions.php
3 weeks ago
class-evf-admin-assets.php
710 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 | if ( ! defined( 'EFP_PLUGIN_FILE' ) ) { |
| 29 | add_action( 'everest_forms_field_options_after_advanced-options', array( $this, 'output_conditional_logic_upsell' ), 10, 2 ); |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Output the Conditional Logic upsell panel for free users. |
| 35 | * |
| 36 | * Hooked into everest_forms_field_options_after_advanced-options so it fires |
| 37 | * for both page-rendered fields and AJAX-dropped fields. |
| 38 | * |
| 39 | * @param array $field Field data. |
| 40 | * @param object $field_obj Field class instance. |
| 41 | */ |
| 42 | public function output_conditional_logic_upsell( $field, $field_obj ) { |
| 43 | if ( ( isset( $field_obj->type ) && 'hidden' === $field_obj->type ) || ( isset( $field['type'] ) && 'hidden' === $field['type'] ) ) { |
| 44 | return; |
| 45 | } |
| 46 | |
| 47 | $field_id = esc_attr( $field['id'] ); |
| 48 | $upgrade_url = 'https://everestforms.net/pricing/?utm_source=WordPress&utm_medium=evf-field-options&utm_campaign=conditional-logic-upsell&utm_content=Upgrade+to+Pro'; |
| 49 | ?> |
| 50 | <div class="everest-forms-field-option-group everest-forms-field-option-group-advanced everest-forms-hide closed evf-cl-upsell-group" |
| 51 | id="everest-forms-field-option-conditional-logic-<?php echo $field_id; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>"> |
| 52 | <a href="#" class="everest-forms-field-option-group-toggle"> |
| 53 | <?php esc_html_e( 'Conditional Logic', 'everest-forms' ); ?> |
| 54 | <span class="evf-cl-pro-badge"> |
| 55 | <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 18 18" aria-hidden="true" focusable="false"><rect width="16.889" height="16.889" x=".444" y=".444" fill="#ff8c39" stroke="#ff8c39" stroke-width=".889" rx="2.222"></rect><path fill="#efefef" d="m8.89 4.444 2.666 7.111H6.223z"></path><path fill="#fff" fill-rule="evenodd" d="m4.445 6.222.635 5.333h7.619l.635-5.333-4.445 3.666zm8.254 5.841h-7.62v1.27h7.62z" clip-rule="evenodd"></path></svg> |
| 56 | </span> |
| 57 | <i class="handlediv"></i> |
| 58 | </a> |
| 59 | <div class="everest-forms-field-option-group-inner" style="display:none;"> |
| 60 | |
| 61 | <div class="evf-cl-upgrade-notice"> |
| 62 | <p><?php esc_html_e( 'Upgrade to Pro to use conditional logic in your forms.', 'everest-forms' ); ?></p> |
| 63 | </div> |
| 64 | |
| 65 | <ul class="evf-cl-features"> |
| 66 | <?php |
| 67 | $features = array( |
| 68 | __( 'Show or hide fields based on user answers', 'everest-forms' ), |
| 69 | __( 'Combine rules with AND / OR logic', 'everest-forms' ), |
| 70 | __( 'Works with text, select, checkbox & more', 'everest-forms' ), |
| 71 | ); |
| 72 | foreach ( $features as $feature ) : |
| 73 | ?> |
| 74 | <li> |
| 75 | <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"> |
| 76 | <path fill-rule="evenodd" d="M16.707 5.293a1 1 0 0 1 0 1.414l-8 8a1 1 0 0 1-1.414 0l-4-4a1 1 0 0 1 1.414-1.414L8 12.586l7.293-7.293a1 1 0 0 1 1.414 0z" clip-rule="evenodd"/> |
| 77 | </svg> |
| 78 | <?php echo wp_kses_post( $feature ); ?> |
| 79 | </li> |
| 80 | <?php endforeach; ?> |
| 81 | </ul> |
| 82 | |
| 83 | <a href="<?php echo esc_url( $upgrade_url ); ?>" target="_blank" rel="noopener noreferrer" class="evf-cl-upgrade-btn"> |
| 84 | <?php esc_html_e( 'Upgrade to Pro', 'everest-forms' ); ?> |
| 85 | <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14" width="14" height="14" aria-hidden="true" focusable="false"><path fill="#efefef" d="m7 1.167 3.5 9.333h-7z"></path><path fill="#fff" fill-rule="evenodd" d="M12 12.834H2v-1.667h10zm0-2.334H2l-.833-7L7 8.312 12.833 3.5z" clip-rule="evenodd"></path></svg> |
| 86 | </a> |
| 87 | |
| 88 | </div> |
| 89 | </div> |
| 90 | <?php |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * Enqueue styles. |
| 95 | */ |
| 96 | public function admin_styles() { |
| 97 | $screen = get_current_screen(); |
| 98 | $screen_id = $screen ? $screen->id : ''; |
| 99 | |
| 100 | // Register admin styles. |
| 101 | $admin_css_path = evf()->plugin_path() . '/assets/css/admin.css'; |
| 102 | $admin_css_ver = file_exists( $admin_css_path ) ? filemtime( $admin_css_path ) : EVF_VERSION; |
| 103 | wp_register_style( 'everest-forms-admin', evf()->plugin_url() . '/assets/css/admin.css', array(), $admin_css_ver ); |
| 104 | |
| 105 | // Locked (Pro/addon) field upsell styles — kept in a dedicated file so the |
| 106 | // rules are not accidentally nested inside admin.scss's structure. |
| 107 | $locked_css_path = evf()->plugin_path() . '/assets/css/evf-locked-fields.css'; |
| 108 | $locked_css_ver = file_exists( $locked_css_path ) ? filemtime( $locked_css_path ) : EVF_VERSION; |
| 109 | wp_register_style( 'everest-forms-locked-fields', evf()->plugin_url() . '/assets/css/evf-locked-fields.css', array( 'everest-forms-admin' ), $locked_css_ver ); |
| 110 | |
| 111 | wp_register_style( 'everest-forms-admin-menu', evf()->plugin_url() . '/assets/css/menu.css', array(), EVF_VERSION ); |
| 112 | wp_register_style( 'jquery-ui-style', evf()->plugin_url() . '/assets/css/jquery-ui/jquery-ui.min.css', array(), EVF_VERSION ); |
| 113 | wp_register_style( 'jquery-confirm', evf()->plugin_url() . '/assets/css/jquery-confirm/jquery-confirm.min.css', array(), '3.3.0' ); |
| 114 | wp_register_style( 'perfect-scrollbar', evf()->plugin_url() . '/assets/css/perfect-scrollbar/perfect-scrollbar.css', array(), '1.4.0' ); |
| 115 | wp_register_style( 'flatpickr', evf()->plugin_url() . '/assets/css/flatpickr.css', array(), EVF_VERSION ); |
| 116 | |
| 117 | // Add RTL support for admin styles. |
| 118 | wp_style_add_data( 'everest-forms-admin', 'rtl', 'replace' ); |
| 119 | wp_style_add_data( 'everest-forms-admin-menu', 'rtl', 'replace' ); |
| 120 | |
| 121 | |
| 122 | |
| 123 | // Sitewide menu CSS. |
| 124 | |
| 125 | |
| 126 | // Admin styles for EVF pages only. |
| 127 | if ( in_array( $screen_id, evf_get_screen_ids(), true ) ) { |
| 128 | // Show hint in codemirror. |
| 129 | wp_enqueue_style( 'wp-codemirror' ); |
| 130 | wp_enqueue_style( 'codemirror-hint-css', evf()->plugin_url() . '/assets/css/code-mirror/show-hint.min.css', array( 'wp-codemirror' ), EVF_VERSION ); |
| 131 | wp_enqueue_style( 'everest-forms-admin-menu' ); |
| 132 | wp_enqueue_style( 'everest-forms-admin' ); |
| 133 | wp_enqueue_style( 'everest-forms-locked-fields' ); |
| 134 | wp_enqueue_style( 'jquery-confirm' ); |
| 135 | wp_enqueue_style( 'jquery-ui-style' ); |
| 136 | wp_enqueue_style( 'wp-color-picker' ); |
| 137 | wp_enqueue_style( 'flatpickr' ); |
| 138 | |
| 139 | if ( 'everest-forms_page_evf-tools' !== $screen_id ) { |
| 140 | wp_enqueue_style( 'perfect-scrollbar' ); |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * Enqueue scripts. |
| 147 | */ |
| 148 | public function admin_scripts() { |
| 149 | global $post; |
| 150 | |
| 151 | $screen = get_current_screen(); |
| 152 | $screen_id = $screen ? $screen->id : ''; |
| 153 | $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
| 154 | |
| 155 | // Register scripts. |
| 156 | wp_register_script( 'selectWoo', evf()->plugin_url() . '/assets/js/selectWoo/selectWoo.full' . $suffix . '.js', array( 'jquery' ), '1.0.8', true ); |
| 157 | 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 ); |
| 158 | wp_register_script( 'everest-forms-extensions', evf()->plugin_url() . '/assets/js/admin/extensions' . $suffix . '.js', array( 'jquery', 'updates', 'wp-i18n' ), EVF_VERSION, true ); |
| 159 | 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 ); |
| 160 | wp_register_script( 'everest-forms-editor', evf()->plugin_url() . '/assets/js/admin/editor' . $suffix . '.js', array( 'jquery' ), EVF_VERSION, true ); |
| 161 | wp_register_script( 'jquery-blockui', evf()->plugin_url() . '/assets/js/jquery-blockui/jquery.blockUI' . $suffix . '.js', array( 'jquery' ), '2.70', true ); |
| 162 | wp_register_script( 'jquery-confirm', evf()->plugin_url() . '/assets/js/jquery-confirm/jquery-confirm' . $suffix . '.js', array( 'jquery' ), '3.3.0', true ); |
| 163 | wp_register_script( 'jquery-tiptip', evf()->plugin_url() . '/assets/js/jquery-tiptip/jquery.tipTip' . $suffix . '.js', array( 'jquery' ), EVF_VERSION, true ); // @deprecated |
| 164 | wp_register_script( 'tooltipster', evf()->plugin_url() . '/assets/js/tooltipster/tooltipster.bundle' . $suffix . '.js', array( 'jquery' ), '4.6.2', true ); |
| 165 | wp_register_script( 'perfect-scrollbar', evf()->plugin_url() . '/assets/js/perfect-scrollbar/perfect-scrollbar' . $suffix . '.js', array( 'jquery' ), '1.5.0', true ); |
| 166 | wp_register_script( 'evf-clipboard', evf()->plugin_url() . '/assets/js/admin/evf-clipboard' . $suffix . '.js', array( 'jquery' ), EVF_VERSION, true ); |
| 167 | wp_register_script( 'evf-enhanced-select', evf()->plugin_url() . '/assets/js/admin/evf-enhanced-select' . $suffix . '.js', array( 'jquery', 'selectWoo' ), EVF_VERSION, true ); |
| 168 | wp_register_script( 'evf-template-controller', evf()->plugin_url() . '/assets/js/admin/form-template-controller' . $suffix . '.js', array( 'jquery' ), EVF_VERSION, true ); |
| 169 | wp_register_script( 'flatpickr', evf()->plugin_url() . '/assets/js/flatpickr/flatpickr' . $suffix . '.js', array( 'jquery' ), '4.6.3', true ); |
| 170 | wp_register_script( 'evf-file-uploader', evf()->plugin_url() . '/assets/js/admin/evf-file-uploader' . $suffix . '.js', array(), EVF_VERSION, true ); |
| 171 | // Register admin scripts for survey fields. |
| 172 | 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 ); |
| 173 | wp_register_script( 'random-color', evf()->plugin_url() . "/assets/js/admin/randomColor{$suffix}.js", array(), EVF_VERSION, true ); |
| 174 | wp_register_script( 'chart', evf()->plugin_url() . "/assets/js/admin/chart{$suffix}.js", array(), EVF_VERSION, true ); |
| 175 | wp_register_script( 'print_this', evf()->plugin_url() . '/assets/js/admin/printThis.min.js', array(), EVF_VERSION, true ); |
| 176 | wp_register_script( 'progress_bar', evf()->plugin_url() . "/assets/js/admin/progressbar{$suffix}.js", array(), EVF_VERSION, true ); |
| 177 | wp_register_script( 'evf-import-entries-form-csv', evf()->plugin_url() . '/assets/js/admin/tool-import-entries' . $suffix . '.js', array( 'jquery' ), EVF_VERSION, true ); |
| 178 | |
| 179 | //Disable drag for jquery confirm. |
| 180 | // wp_add_inline_script( |
| 181 | // 'jquery-confirm', |
| 182 | // '(function($){if(window.Jconfirm&&window.Jconfirm.prototype){window.Jconfirm.prototype.initDraggable=function(){this.draggable=false;this.resetDrag();};}})(jQuery);', |
| 183 | // 'after' |
| 184 | // ); |
| 185 | /** |
| 186 | * Roles and permission. |
| 187 | * |
| 188 | * @since 3.0.8 |
| 189 | */ |
| 190 | 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 ); |
| 191 | |
| 192 | wp_localize_script( |
| 193 | 'evf-file-uploader', |
| 194 | 'evf_file_uploader', |
| 195 | array( |
| 196 | 'upload_file' => __( 'Upload Image', 'everest-forms' ), |
| 197 | ) |
| 198 | ); |
| 199 | wp_localize_script( |
| 200 | 'evf-template-controller', |
| 201 | 'evf_templates', |
| 202 | array( |
| 203 | 'evf_template_all' => EVF_Admin_Form_Templates::get_template_data(), |
| 204 | 'i18n_get_started' => esc_html__( 'Get Started', 'everest-forms' ), |
| 205 | 'i18n_get_preview' => esc_html__( 'Preview', 'everest-forms' ), |
| 206 | 'i18n_pro_feature' => esc_html__( 'Pro', 'everest-forms' ), |
| 207 | 'template_refresh' => esc_html__( 'Updating Templates', 'everest-forms' ), |
| 208 | 'evf_plugin_url' => esc_url( evf()->plugin_url() ), |
| 209 | ) |
| 210 | ); |
| 211 | wp_localize_script( |
| 212 | 'evf-enhanced-select', |
| 213 | 'evf_enhanced_select_params', |
| 214 | array( |
| 215 | 'i18n_no_matches' => _x( 'No matches found', 'enhanced select', 'everest-forms' ), |
| 216 | 'i18n_ajax_error' => _x( 'Loading failed', 'enhanced select', 'everest-forms' ), |
| 217 | 'i18n_input_too_short_1' => _x( 'Please enter 1 or more characters', 'enhanced select', 'everest-forms' ), |
| 218 | 'i18n_input_too_short_n' => _x( 'Please enter %qty% or more characters', 'enhanced select', 'everest-forms' ), |
| 219 | 'i18n_input_too_long_1' => _x( 'Please delete 1 character', 'enhanced select', 'everest-forms' ), |
| 220 | 'i18n_input_too_long_n' => _x( 'Please delete %qty% characters', 'enhanced select', 'everest-forms' ), |
| 221 | 'i18n_selection_too_long_1' => _x( 'You can only select 1 item', 'enhanced select', 'everest-forms' ), |
| 222 | 'i18n_selection_too_long_n' => _x( 'You can only select %qty% items', 'enhanced select', 'everest-forms' ), |
| 223 | 'i18n_load_more' => _x( 'Loading more results…', 'enhanced select', 'everest-forms' ), |
| 224 | 'i18n_searching' => _x( 'Searching…', 'enhanced select', 'everest-forms' ), |
| 225 | 'i18n_select_all' => _x( 'Select All', 'enhanced select', 'everest-forms' ), |
| 226 | 'i18n_unselect_all' => _x( 'Unselect All', 'enhanced select', 'everest-forms' ), |
| 227 | ) |
| 228 | ); |
| 229 | 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 ); |
| 230 | wp_localize_script( |
| 231 | 'evf-form-builder', |
| 232 | 'evf_data', |
| 233 | apply_filters( |
| 234 | 'everest_forms_builder_strings', |
| 235 | array( |
| 236 | 'post_id' => isset( $post->ID ) ? $post->ID : '', |
| 237 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 238 | 'tab' => isset( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : '', // phpcs:ignore WordPress.Security.NonceVerification. |
| 239 | 'evf_field_drop_nonce' => wp_create_nonce( 'everest_forms_field_drop' ), |
| 240 | 'evf_add_row_nonce' => wp_create_nonce( 'everest_forms_add_row' ), |
| 241 | 'evf_save_form' => wp_create_nonce( 'everest_forms_save_form' ), |
| 242 | 'evf_embed_form' => wp_create_nonce( 'everest_forms_embed_form' ), |
| 243 | 'evf_goto_edit_page' => wp_create_nonce( 'everest_forms_goto_edit_page' ), |
| 244 | 'evf_get_next_id' => wp_create_nonce( 'everest_forms_get_next_id' ), |
| 245 | 'evf_enabled_form' => wp_create_nonce( 'everest_forms_enabled_form' ), |
| 246 | 'form_id' => isset( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : 0, // phpcs:ignore WordPress.Security.NonceVerification |
| 247 | 'field' => esc_html__( 'field', 'everest-forms' ), |
| 248 | 'i18n_ok' => esc_html__( 'OK', 'everest-forms' ), |
| 249 | 'i18n_installing' => esc_html__( 'Installing', 'everest-forms' ), |
| 250 | 'i18n_activating' => esc_html__( 'Activating', 'everest-forms' ), |
| 251 | 'i18n_install_activate' => esc_html__( 'Install & Activate', 'everest-forms' ), |
| 252 | 'i18n_install_only' => esc_html__( 'Activate Plugins', 'everest-forms' ), |
| 253 | 'i18n_copy' => esc_html__( '(copy)', 'everest-forms' ), |
| 254 | 'i18n_close' => esc_html__( 'Close', 'everest-forms' ), |
| 255 | 'i18n_cancel' => esc_html__( 'Cancel', 'everest-forms' ), |
| 256 | 'i18n_row_locked' => esc_html__( 'Row Locked', 'everest-forms' ), |
| 257 | 'i18n_single_row_locked_msg' => esc_html__( 'Single row cannot be deleted.', 'everest-forms' ), |
| 258 | 'i18n_field_locked' => esc_html__( 'Field Locked', 'everest-forms' ), |
| 259 | 'i18n_field_locked_msg' => esc_html__( 'This field cannot be deleted or duplicated.', 'everest-forms' ), |
| 260 | 'i18n_row_locked_msg' => esc_html__( 'This row cannot be deleted or duplicated.', 'everest-forms' ), |
| 261 | 'i18n_field_error_choice' => esc_html__( 'This item must contain at least one choice.', 'everest-forms' ), |
| 262 | 'i18n_delete_row_confirm' => esc_html__( 'Are you sure you want to delete this row?', 'everest-forms' ), |
| 263 | 'i18n_delete_field_confirm' => esc_html__( 'Are you sure you want to delete this field?', 'everest-forms' ), |
| 264 | 'i18n_duplicate_field_confirm' => esc_html__( 'Are you sure you want to duplicate this field?', 'everest-forms' ), |
| 265 | 'i18n_duplicate_row_confirm' => esc_html__( 'Are you sure you want to duplicate this row?', 'everest-forms' ), |
| 266 | 'i18n_email_disable_message' => esc_html__( 'Turn on Email settings to manage your email notification.', 'everest-forms' ), |
| 267 | 'i18n_upload_image_title' => esc_html__( 'Choose an image', 'everest-forms' ), |
| 268 | 'i18n_upload_image_button' => esc_html__( 'Use Image', 'everest-forms' ), |
| 269 | 'i18n_upload_image_remove' => esc_html__( 'Remove Image', 'everest-forms' ), |
| 270 | 'i18n_field_title_empty' => esc_html__( 'Empty Form Name', 'everest-forms' ), |
| 271 | 'i18n_shortcut_key_title' => esc_html__( 'keyboard Shortcut Keys', 'everest-forms' ), |
| 272 | 'i18n_shortcut_keys' => array( |
| 273 | 'Ctrl+S' => esc_html__( 'Save Builder', 'everest-forms' ), |
| 274 | 'Ctrl+W' => esc_html__( 'Close Builder', 'everest-forms' ), |
| 275 | 'Ctrl+P' => esc_html__( 'Preview Form', 'everest-forms' ), |
| 276 | 'Ctrl+E' => esc_html__( 'Go to Entries', 'everest-forms' ), |
| 277 | 'Ctrl+H' => esc_html__( 'Open Help', 'everest-forms' ), |
| 278 | ), |
| 279 | 'i18n_field_title_payload' => esc_html__( 'Form name can\'t be empty.', 'everest-forms' ), |
| 280 | 'email_fields' => evf_get_all_email_fields_by_form_id( isset( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : 0 ), // phpcs:ignore WordPress.Security.NonceVerification |
| 281 | 'all_fields' => evf_get_all_form_fields_by_form_id( isset( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : 0 ), // phpcs:ignore WordPress.Security.NonceVerification |
| 282 | 'smart_tags_other' => evf()->smart_tags->other_smart_tags(), |
| 283 | 'regex_expression_lists' => evf()->smart_tags->regex_expression_lists(), |
| 284 | '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 |
| 285 | 'preview_url' => ! empty( $_GET['form_id'] ) ? esc_url( // phpcs:ignore WordPress.Security.NonceVerification |
| 286 | add_query_arg( |
| 287 | array( |
| 288 | 'form_id' => absint( $_GET['form_id'] ), // phpcs:ignore WordPress.Security.NonceVerification |
| 289 | 'evf_preview' => 'true', |
| 290 | ), |
| 291 | home_url() |
| 292 | ) |
| 293 | ) : '', |
| 294 | 'form_one_time_draggable_fields' => evf_get_one_time_draggable_fields(), |
| 295 | 'i18n_privacy_policy_consent_message' => esc_html__( 'I allow this website to collect and store the submitted data.', 'everest-forms' ), |
| 296 | 'is_pro' => ( ! defined( 'EFP_PLUGIN_FILE' ) ) ? false : true, |
| 297 | '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' ), |
| 298 | 'i18n_expiry_trial_min_date' => esc_html__( 'Expiry must be on or after the trial ends (%s).', 'everest-forms' ), |
| 299 | 'i18n_expiry_trial_blocked_day' => esc_html__( 'This date is within the trial period and cannot be used as the expiry date.', 'everest-forms' ), |
| 300 | ) |
| 301 | ) |
| 302 | ); |
| 303 | |
| 304 | // Builder upgrade. |
| 305 | wp_register_script( 'evf-upgrade', evf()->plugin_url() . '/assets/js/admin/upgrade.js', array( 'jquery', 'jquery-confirm' ), EVF_VERSION, false ); |
| 306 | // BUGFIX: `assets/js/admin/upgrade.js` reads global `evf_data` (for example in `limit_file_upload()`). |
| 307 | // On non-builder screens this caused `evf_data is not defined` because it was only localized to `evf-form-builder`. |
| 308 | // Localize the required `evf_data` keys directly to `evf-upgrade` to satisfy the script contract everywhere it runs. |
| 309 | wp_localize_script( |
| 310 | 'evf-upgrade', |
| 311 | 'evf_data', |
| 312 | array( |
| 313 | 'is_pro' => defined( 'EFP_PLUGIN_FILE' ), |
| 314 | 'i18n_ok' => esc_html__( 'OK', 'everest-forms' ), |
| 315 | 'i18n_close' => esc_html__( 'Close', 'everest-forms' ), |
| 316 | ) |
| 317 | ); |
| 318 | wp_localize_script( |
| 319 | 'evf-upgrade', |
| 320 | 'evf_upgrade', |
| 321 | array( |
| 322 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 323 | 'upgrade_title' => esc_html__( 'is a PRO Feature', 'everest-forms' ), |
| 324 | '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' ), |
| 325 | 'upgrade_button' => esc_html__( 'Upgrade to PRO', 'everest-forms' ), |
| 326 | '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' ), |
| 327 | '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' ), |
| 328 | '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' ), |
| 329 | 'enable_stripe_title' => esc_html__( 'Please enable Stripe', 'everest-forms' ), |
| 330 | 'recaptcha_title' => esc_html__( 'reCaptcha', 'everest-forms' ), |
| 331 | 'recaptcha_api_key_message' => esc_html__( 'Please enter a reCaptcha key on Everest Forms>Settings>Captcha>reCaptcha.', 'everest-forms' ), |
| 332 | 'hcaptcha_title' => esc_html__( 'hCaptcha', 'everest-forms' ), |
| 333 | 'hcaptcha_api_key_message' => esc_html__( 'Please enter a hCaptcha key on Everest Forms>Settings>Captcha>hCaptcha.', 'everest-forms' ), |
| 334 | 'turnstile_title' => esc_html__( ' Cloudflare Turnstile', 'everest-forms' ), |
| 335 | 'turnstile_api_key_message' => esc_html__( 'Please enter a Cloudflare Turnstile key on Everest Forms>Settings>Captcha>Cloudflare Turnstile.', 'everest-forms' ), |
| 336 | 'enable_stripe_message' => esc_html__( 'Enable Stripe Payment gateway in payments section to use this field.', 'everest-forms' ), |
| 337 | 'enable_authorize_net_title' => esc_html__( 'Please enable Authorize.Net', 'everest-forms' ), |
| 338 | 'enable_authorize_net_message' => esc_html__( 'Enable Authorize.Net Payment gateway in payments section to use this field.', 'everest-forms' ), |
| 339 | 'enable_square_title' => esc_html( 'Please enable Square', 'everest-forms' ), |
| 340 | 'enable_square_message' => esc_html__( 'Enable Square Payment gateway in payments section to use this field.', 'everest-forms' ), |
| 341 | 'enable_recurring_period_title' => esc_html__( 'Enable Recurring Subscription', 'everest-forms' ), |
| 342 | 'enable_recurring_period_message' => esc_html__( 'Recurring Subscription Payment is disabled. Please enable it in the to use the Subscription Plan field.', 'everest-forms' ), |
| 343 | 'evf_install_and_active_nonce' => wp_create_nonce( 'install_and_active_nonce' ), |
| 344 | 'upgrade_plan_title' => esc_html__( 'is a Premium Addon', 'everest-forms' ), |
| 345 | 'upgrade_plan_message' => esc_html__( 'This addon requires premium plan. Please upgrade to the Premium plan to unlock all these awesome field.', 'everest-forms' ), |
| 346 | 'upgrade_plan_button' => esc_html__( 'Upgrade Plan', 'everest-forms' ), |
| 347 | 'admin_url' => admin_url(), |
| 348 | 'vedio_links' => array( |
| 349 | 'dropdown' => 'kDYAKElqNtM', |
| 350 | ), |
| 351 | 'evf_one_time_draggable_title' => esc_html__( 'File upload', 'everest-forms' ), |
| 352 | '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' ), |
| 353 | 'evf_one_time_payment_gateway_title' => esc_html__( 'Payment Gateway', 'everest-forms' ), |
| 354 | 'evf_one_time_payment_gateway_message' => esc_html__( 'Only one Payment Gateway field is allowed per form.', 'everest-forms' ), |
| 355 | 'evf_payment_method_dependency_title' => esc_html__( 'Payment Gateway Field', 'everest-forms' ), |
| 356 | 'evf_payment_method_dependency_message' => esc_html__( 'Remove Payment Gateway field to use this field.', 'everest-forms' ), |
| 357 | 'evf_legacy_payment_blocks_gateway_title' => esc_html__( 'Payment Gateway field unavailable', 'everest-forms' ), |
| 358 | 'evf_legacy_payment_blocks_gateway_message' => esc_html__( 'To add a Payment Gateway field, first disable %s in the Payments tab.', 'everest-forms' ), |
| 359 | 'evf_credit_card_blocks_gateway_message' => esc_html__( 'To add a Payment Gateway field, first remove the Credit Card field.', 'everest-forms' ), |
| 360 | 'evf_legacy_payment_label_credit_card' => esc_html__( 'Stripe', 'everest-forms' ), |
| 361 | 'evf_legacy_payment_label_paypal' => esc_html__( 'PayPal', 'everest-forms' ), |
| 362 | 'evf_legacy_payment_label_authorize_net' => esc_html__( 'Authorize.Net', 'everest-forms' ), |
| 363 | 'evf_legacy_payment_label_square' => esc_html__( 'Square', 'everest-forms' ), |
| 364 | 'evf_legacy_payment_label_razorpay' => esc_html__( 'Razorpay', 'everest-forms' ), |
| 365 | 'evf_legacy_payment_label_mollie' => esc_html__( 'Mollie', 'everest-forms' ), |
| 366 | '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' ), |
| 367 | |
| 368 | ) |
| 369 | ); |
| 370 | |
| 371 | // EverestForms admin pages. |
| 372 | if ( in_array( $screen_id, evf_get_screen_ids(), true ) ) { |
| 373 | wp_enqueue_script( 'everest-forms-admin' ); |
| 374 | wp_enqueue_script( 'everest-forms-email-admin' ); |
| 375 | wp_enqueue_script( 'evf-enhanced-select' ); |
| 376 | wp_enqueue_script( 'jquery-ui-sortable' ); |
| 377 | wp_enqueue_script( 'jquery-ui-autocomplete' ); |
| 378 | wp_enqueue_script( 'evf-upgrade' ); |
| 379 | |
| 380 | // upgrade.js references evf_data in modal buttons; builder localizes the full object. |
| 381 | if ( 'everest-forms_page_evf-settings' === $screen_id && ! wp_script_is( 'evf-form-builder', 'enqueued' ) ) { |
| 382 | wp_localize_script( |
| 383 | 'evf-upgrade', |
| 384 | 'evf_data', |
| 385 | array( |
| 386 | 'i18n_ok' => esc_html__( 'OK', 'everest-forms' ), |
| 387 | 'i18n_close' => esc_html__( 'Close', 'everest-forms' ), |
| 388 | 'is_pro' => defined( 'EFP_PLUGIN_FILE' ), |
| 389 | ) |
| 390 | ); |
| 391 | } |
| 392 | |
| 393 | wp_localize_script( |
| 394 | 'everest-forms-email-admin', |
| 395 | 'evf_email_params', |
| 396 | array( |
| 397 | 'i18n_email_connection' => esc_html__( 'Enter a Email nickname', 'everest-forms' ), |
| 398 | 'i18n_email_placeholder' => esc_html__( 'Eg: Support Email', 'everest-forms' ), |
| 399 | 'i18n_email_error_name' => esc_html__( 'You must provide a Email nickname', 'everest-forms' ), |
| 400 | 'i18n_email_ok' => esc_html__( 'OK', 'everest-forms' ), |
| 401 | 'ajax_email_nonce' => wp_create_nonce( 'process-ajax-nonce' ), |
| 402 | 'ajax_url' => admin_url( 'admin-ajax.php', 'relative' ), |
| 403 | 'i18n_email_cancel' => esc_html__( 'Cancel', 'everest-forms' ), |
| 404 | 'i18n_default_address' => get_option( 'admin_email' ), |
| 405 | 'from_name' => get_bloginfo( 'name', 'display' ), |
| 406 | 'email_subject' => esc_html__( 'New Form Entry', 'everest-forms' ), |
| 407 | ) |
| 408 | ); |
| 409 | |
| 410 | wp_localize_script( |
| 411 | 'everest-forms-admin', |
| 412 | 'everest_forms_admin', |
| 413 | array( |
| 414 | 'ajax_import_nonce' => wp_create_nonce( 'process-import-ajax-nonce' ), |
| 415 | 'evf_search_addons' => wp_create_nonce( 'everest_forms_search_addons' ), |
| 416 | 'ajax_url' => admin_url( 'admin-ajax.php', 'relative' ), |
| 417 | 'i18n_field_meta_key_error' => esc_html__( 'Please enter in meta key with alphanumeric characters, dashes and underscores.', 'everest-forms' ), |
| 418 | 'i18n_field_min_value_greater' => esc_html__( 'Minimum value is greater than Maximum value.', 'everest-forms' ), |
| 419 | 'i18n_field_max_value_smaller' => esc_html__( 'Maximum value is smaller than Minimum value.', 'everest-forms' ), |
| 420 | 'i18n_field_def_value_greater' => esc_html__( 'Default value is greater than Maximum value.', 'everest-forms' ), |
| 421 | 'i18n_field_def_value_smaller' => esc_html__( 'Default value is smaller than Minimum value.', 'everest-forms' ), |
| 422 | 'i18n_form_export_action_error' => esc_html__( 'Please select a form which you want to export.', 'everest-forms' ), |
| 423 | 'i18n_log_copied' => esc_html__( 'Copied!', 'everest-forms' ), |
| 424 | 'smart_smtp_install_and_activate_nonce' => wp_create_nonce( 'everest-forms-smart-smtp-installation-nonce' ), |
| 425 | ) |
| 426 | ); |
| 427 | |
| 428 | wp_localize_script( |
| 429 | 'everest-forms-admin', |
| 430 | 'evf_admin_manage_tags', |
| 431 | array( |
| 432 | 'ajax_manage_tags_nonce' => wp_create_nonce( 'ajax_manage_tags_nonce' ), |
| 433 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 434 | 'manage_tags_title' => __( 'Are you sure want to delete selected tags?', 'everest-forms' ), |
| 435 | 'manage_tags_desc' => __( |
| 436 | 'Delete tags that you\'re no longer using. Deleting a tag will remove it from a form, but will not delete the form itself.', |
| 437 | 'everest-forms' |
| 438 | ), |
| 439 | ) |
| 440 | ); |
| 441 | |
| 442 | wp_localize_script( |
| 443 | 'evf-import-entries-form-csv', |
| 444 | 'evf_import_entries_obj', |
| 445 | array( |
| 446 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 447 | 'nonce' => wp_create_nonce( 'evf-import-entries' ), |
| 448 | ) |
| 449 | ); |
| 450 | |
| 451 | wp_localize_script( |
| 452 | 'evf-tool-roles-and-permission', |
| 453 | 'evf_roles_and_permission', |
| 454 | array( |
| 455 | 'security' => wp_create_nonce( 'wp_rest' ), |
| 456 | 'restURL' => rest_url(), |
| 457 | 'not_found_image' => evf()->plugin_url() . '/assets/images/not-found-image.png', |
| 458 | ) |
| 459 | ); |
| 460 | |
| 461 | wp_localize_script( |
| 462 | 'everest-forms-admin', |
| 463 | 'everest_forms_admin_locate', |
| 464 | array( |
| 465 | 'ajax_locate_nonce' => wp_create_nonce( 'process-locate-ajax-nonce' ), |
| 466 | 'ajax_url' => admin_url( 'admin-ajax.php', 'relative' ), |
| 467 | 'form_found_error' => esc_html__( 'Form not found in content', 'everest-forms' ), |
| 468 | 'form_found' => esc_html__( 'Form found in page:', 'everest-forms' ), |
| 469 | ) |
| 470 | ); |
| 471 | |
| 472 | wp_localize_script( |
| 473 | 'everest-forms-admin', |
| 474 | 'everest_forms_admin_generate_restapi_key', |
| 475 | array( |
| 476 | 'ajax_restapi_key_nonce' => wp_create_nonce( 'process-restapi-api-ajax-nonce' ), |
| 477 | 'ajax_url' => admin_url( 'admin-ajax.php', 'relative' ), |
| 478 | ) |
| 479 | ); |
| 480 | |
| 481 | wp_localize_script( |
| 482 | 'everest-forms-admin', |
| 483 | 'everest_forms_admin_form_migrator', |
| 484 | array( |
| 485 | 'evf_fm_dismiss_notice_nonce' => wp_create_nonce( 'evf_fm_dismiss_notice_nonce' ), |
| 486 | 'ajax_url' => admin_url( 'admin-ajax.php', 'relative' ), |
| 487 | ) |
| 488 | ); |
| 489 | } |
| 490 | |
| 491 | // AI chat assistant — only on the form editor (form_id present), not on the template selection screen. |
| 492 | if ( in_array( $screen_id, array( 'everest-forms_page_evf-builder' ), true ) && isset( $_GET['form_id'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification |
| 493 | wp_enqueue_script( |
| 494 | 'evf-builder-ai', |
| 495 | evf()->plugin_url() . '/dist/builderAI.min.js', |
| 496 | array( 'wp-element', 'react', 'react-dom' ), |
| 497 | EVF_VERSION, |
| 498 | true |
| 499 | ); |
| 500 | |
| 501 | $evf_ai_form_id = absint( $_GET['form_id'] ); // phpcs:ignore WordPress.Security.NonceVerification |
| 502 | wp_localize_script( |
| 503 | 'evf-builder-ai', |
| 504 | 'evfBuilderAI', |
| 505 | array( |
| 506 | 'ajaxUrl' => admin_url( 'admin-ajax.php' ), |
| 507 | 'nonce' => wp_create_nonce( 'evf_ai_nonce' ), |
| 508 | 'formId' => $evf_ai_form_id, |
| 509 | 'formTitle' => get_the_title( $evf_ai_form_id ), |
| 510 | // On local / development sites the AI gateway is unavailable: the |
| 511 | // assistant is shown but disabled rather than hidden. |
| 512 | 'aiDisabled' => class_exists( 'EVF_AI_Registration' ) && EVF_AI_Registration::is_local_site(), |
| 513 | ) |
| 514 | ); |
| 515 | } |
| 516 | |
| 517 | // EverestForms builder pages. |
| 518 | if ( in_array( $screen_id, array( 'everest-forms_page_evf-builder' ), true ) ) { |
| 519 | wp_enqueue_media(); |
| 520 | wp_enqueue_script( 'evf-upgrade' ); |
| 521 | wp_enqueue_script( 'evf-form-builder' ); |
| 522 | |
| 523 | wp_enqueue_script( 'wp-codemirror' ); |
| 524 | // Enqueue additional scripts for hints if not included by default. |
| 525 | // wp_enqueue_script( 'codemirror-hint', evf()->plugin_url() . '/assets/js/code-mirror/show-hint' . $suffix . '.js', array( 'wp-codemirror' ), EVF_VERSION, true ); |
| 526 | |
| 527 | // De-register scripts. |
| 528 | wp_dequeue_script( 'colorpick' ); |
| 529 | |
| 530 | // EverestForms builder setup page. |
| 531 | if ( isset( $_GET['create-form'] ) || isset( $_GET['form_id'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification |
| 532 | 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 ); |
| 533 | wp_enqueue_script( 'evf-setup' ); |
| 534 | wp_localize_script( |
| 535 | 'evf-setup', |
| 536 | 'evf_setup_params', |
| 537 | array( |
| 538 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 539 | 'create_form_nonce' => wp_create_nonce( 'everest_forms_create_form' ), |
| 540 | 'evf_active_nonce' => wp_create_nonce( 'evf_active_nonce' ), |
| 541 | 'template_licence_check_nonce' => wp_create_nonce( 'everest_forms_template_licence_check' ), |
| 542 | 'i18n_form_name' => esc_html__( 'Give it a name.', 'everest-forms' ), |
| 543 | 'i18n_form_error_name' => esc_html__( 'You must provide a Form name', 'everest-forms' ), |
| 544 | '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' ), |
| 545 | 'upgrade_button' => esc_html__( 'Upgrade Plan', 'everest-forms' ), |
| 546 | 'upgrade_message' => esc_html__( 'This template requires premium addons. Please upgrade to the Premium plan to unlock all these awesome Templates.', 'everest-forms' ), |
| 547 | 'upgrade_title' => esc_html__( 'is a Premium Template', 'everest-forms' ), |
| 548 | 'i18n_form_ok' => esc_html__( 'Continue', 'everest-forms' ), |
| 549 | 'i18n_form_placeholder' => esc_html__( 'Untitled Form', 'everest-forms' ), |
| 550 | 'i18n_form_title' => esc_html__( 'Uplift your form experience to the next level.', 'everest-forms' ), |
| 551 | 'i18n_installing' => esc_html__( 'installing', 'everest-forms' ), |
| 552 | 'save_changes_text' => esc_html__( 'Save and Reload', 'everest-forms' ), |
| 553 | 'reload_text' => esc_html__( 'Just Reload', 'everest-forms' ), |
| 554 | 'active_confirmation_title' => esc_html__( 'Activation Successful.', 'everest-forms' ), |
| 555 | 'install_confirmation_title' => esc_html__( 'Installation Successful.', 'everest-forms' ), |
| 556 | 'install_confirmation_message' => esc_html__( 'Addons have been installed and Activated. You have to reload the page', 'everest-forms' ), |
| 557 | 'active_confirmation_message' => esc_html__( 'Addons have been Activated. You have to reload the page', 'everest-forms' ), |
| 558 | 'download_failed' => esc_html__( 'Download Failed', 'everest-forms' ), |
| 559 | 'installing_title' => esc_html__( 'Installing...', 'everest-forms' ), |
| 560 | 'activate_title' => esc_html__( 'Activating...', 'everest-forms' ), |
| 561 | 'installing_message' => esc_html__( 'Please wait while the addon is being installed.', 'everest-forms' ), |
| 562 | 'activate_message' => esc_html__( 'Please wait while the addon is being activated.', 'everest-forms' ), |
| 563 | ) |
| 564 | ); |
| 565 | } |
| 566 | } |
| 567 | |
| 568 | if ( in_array( $screen_id, evf_get_screen_ids(), true ) ) { |
| 569 | wp_enqueue_style( 'everest-forms-survey-polls-quiz-admin' ); |
| 570 | wp_enqueue_script( 'everest-forms-survey-polls-quiz-builder' ); |
| 571 | wp_enqueue_script( 'random-color' ); |
| 572 | // wp_enqueue_script( 'chart' ); //for future use. |
| 573 | if ( isset( $_GET['page'], $_GET['tab'] ) && $_GET['page'] === 'evf-tools' && $_GET['tab'] === 'roles_and_permission' ) { |
| 574 | wp_enqueue_script( 'evf-tool-roles-and-permission' ); |
| 575 | } |
| 576 | |
| 577 | wp_enqueue_script( 'progress_bar' ); |
| 578 | wp_enqueue_script( 'evf-import-entries-form-csv' ); |
| 579 | wp_enqueue_script( 'print_this' ); |
| 580 | wp_localize_script( |
| 581 | 'everest-forms-survey-polls-quiz-builder', |
| 582 | 'everest_forms_survey_polls_quiz_builder', |
| 583 | array( |
| 584 | 'ajax_url' => admin_url( 'admin-ajax.php', 'relative' ), |
| 585 | 'admin_url' => admin_url(), |
| 586 | 'ajax_nonce' => wp_create_nonce( 'process-ajax-nonce' ), |
| 587 | 'i18n_field_less_than_highest_point_error' => esc_html__( 'Please enter in a value less than the highest rating point.', 'everest-forms' ), |
| 588 | 'i18n_field_greater_than_lowest_point_error' => esc_html__( 'Please enter in a value greater than the lowest rating point.', 'everest-forms' ), |
| 589 | 'i18n_field_lowest_rating_lower_than_min_value_error' => esc_html__( 'Please enter in a value greater or equal to 0.', 'everest-forms' ), |
| 590 | 'i18n_field_highest_rating_greater_than_max_value_error' => esc_html__( 'Please enter in a value less than 100.', 'everest-forms' ), |
| 591 | 'i18n_field_from_score_greater_than_to_score' => esc_html__( 'Please enter in a value greater than From Score.', 'everest-forms' ), |
| 592 | 'i18n_field_to_score_is_empty_error' => esc_html__( 'Please enter in a value to add more feedback.', 'everest-forms' ), |
| 593 | ) |
| 594 | ); |
| 595 | } |
| 596 | |
| 597 | // Tools page. |
| 598 | if ( 'everest-forms_page_evf-tools' === $screen_id ) { |
| 599 | wp_register_script( 'evf-admin-tools', evf()->plugin_url() . '/assets/js/admin/tools' . $suffix . '.js', array( 'jquery' ), EVF_VERSION, true ); |
| 600 | wp_enqueue_script( 'evf-admin-tools' ); |
| 601 | wp_localize_script( |
| 602 | 'evf-admin-tools', |
| 603 | 'everest_forms_admin_tools', |
| 604 | array( |
| 605 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 606 | 'delete_log_confirmation' => esc_js( esc_html__( 'Are you sure you want to delete this log?', 'everest-forms' ) ), |
| 607 | 'delete_all_log_confirmation' => esc_js( esc_html__( 'Are you sure you want to delete all logs?', 'everest-forms' ) ), |
| 608 | ) |
| 609 | ); |
| 610 | wp_localize_script( |
| 611 | 'evf-admin-tools', |
| 612 | 'everest_forms_form_migrator', |
| 613 | array( |
| 614 | 'ajax_url' => admin_url( 'admin-ajax.php' ), |
| 615 | 'evf_form_migrator_forms_list_nonce' => wp_create_nonce( 'evf_form_migrator_forms_list_nonce' ), |
| 616 | 'evf_form_migrator_nonce' => wp_create_nonce( 'evf_form_migrator_nonce' ), |
| 617 | 'evf_form_entry_migrator_nonce' => wp_create_nonce( 'evf_form_entry_migrator_nonce' ), |
| 618 | ) |
| 619 | ); |
| 620 | } |
| 621 | |
| 622 | // Add-ons/extensions page. |
| 623 | if ( 'everest-forms_page_evf-addons' === $screen_id ) { |
| 624 | wp_enqueue_script( 'everest-forms-extensions' ); |
| 625 | } |
| 626 | } |
| 627 | |
| 628 | /** |
| 629 | * Enqueue dashboard scripts (React). |
| 630 | * |
| 631 | * ADD THIS ENTIRE METHOD AFTER __construct() AND BEFORE admin_styles() |
| 632 | */ |
| 633 | /** |
| 634 | * Enqueue dashboard scripts (React). |
| 635 | */ |
| 636 | public function enqueue_dashboard_scripts() { |
| 637 | $screen_id = get_current_screen()->id; |
| 638 | if ( ! in_array( $screen_id, evf_get_screen_ids(), true ) ) { |
| 639 | return; |
| 640 | } |
| 641 | |
| 642 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 643 | $current_page = isset( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; |
| 644 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 645 | $current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( wp_unslash( $_GET['tab'] ) ) : 'general'; |
| 646 | |
| 647 | wp_enqueue_script( |
| 648 | 'evf-dashboard-header', |
| 649 | evf()->plugin_url() . '/dist/dashboardHeader.min.js', |
| 650 | array( 'wp-element', 'wp-i18n' ), |
| 651 | EVF_VERSION, |
| 652 | true |
| 653 | ); |
| 654 | |
| 655 | $script_handle = 'evf-dashboard-header'; |
| 656 | |
| 657 | // Enqueue dashboard app on free analytics page so FreeAnalyticsContent mounts on #evf-analytics-root. |
| 658 | if ( 'evf-analytics' === $current_page && ! defined( 'EFP_PLUGIN_FILE' ) ) { |
| 659 | wp_enqueue_style( |
| 660 | 'evf-dashboard-style', |
| 661 | evf()->plugin_url() . '/dist/dashboard.css', |
| 662 | array(), |
| 663 | EVF_VERSION |
| 664 | ); |
| 665 | wp_enqueue_script( |
| 666 | 'evf-dashboard-script', |
| 667 | evf()->plugin_url() . '/dist/dashboard.min.js', |
| 668 | array( 'wp-element', 'wp-hooks', 'react', 'react-dom' ), |
| 669 | EVF_VERSION, |
| 670 | true |
| 671 | ); |
| 672 | } |
| 673 | |
| 674 | if ( 'evf-entries' === $current_page ) { |
| 675 | $page_type = 'entries'; |
| 676 | } elseif ( 'evf-settings' === $current_page ) { |
| 677 | $page_type = 'settings'; |
| 678 | } elseif ( 'everest-forms-analytics' === $current_page || 'evf-analytics' === $current_page ) { |
| 679 | $page_type = 'analytics'; |
| 680 | } else { |
| 681 | $page_type = $current_page; |
| 682 | } |
| 683 | |
| 684 | wp_localize_script( |
| 685 | $script_handle, |
| 686 | '_EVF_DASHBOARD_', |
| 687 | array( |
| 688 | 'version' => EVF_VERSION, |
| 689 | 'isPro' => defined( 'EFP_PLUGIN_FILE' ), |
| 690 | 'showAnalyticsTab' => is_plugin_active( 'everest-forms-form-analytics/everest-forms-form-analytics.php' ), |
| 691 | 'upgradeURL' => 'https://everestforms.net/pricing/?', |
| 692 | 'adminURL' => admin_url( 'admin.php' ), |
| 693 | 'ajaxURL' => admin_url( 'admin-ajax.php' ), |
| 694 | 'evfRestApiNonce' => wp_create_nonce( 'wp_rest' ), |
| 695 | 'restURL' => rest_url(), |
| 696 | 'nonce' => wp_create_nonce( 'evf_admin' ), |
| 697 | 'pageType' => $page_type, |
| 698 | 'currentPage' => $current_page, |
| 699 | 'currentTab' => $current_tab, |
| 700 | 'allStepsCompleted' => ( |
| 701 | EVF_Admin_Dashboard::is_spam_protection_completed() |
| 702 | && (bool) get_option( 'everest_forms_test_email_sent', false ) |
| 703 | ) ? '1' : '0', |
| 704 | ) |
| 705 | ); |
| 706 | } |
| 707 | } |
| 708 | |
| 709 | return new EVF_Admin_Assets(); |
| 710 |