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-dashboard.php
193 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Dashboard page. |
| 4 | * |
| 5 | * @package EverestForms/Admin/Dashboard |
| 6 | * @since 2.0.8.1 |
| 7 | */ |
| 8 | |
| 9 | defined( 'ABSPATH' ) || exit; |
| 10 | |
| 11 | /** |
| 12 | * EVF_Admin_Dashboard Class. |
| 13 | */ |
| 14 | class EVF_Admin_Dashboard { |
| 15 | |
| 16 | /** |
| 17 | * Check if spam protection (reCAPTCHA) is configured. |
| 18 | * Requires BOTH site key AND secret key to be filled. |
| 19 | * |
| 20 | * @return bool True if any captcha type has BOTH keys configured, false otherwise. |
| 21 | */ |
| 22 | public static function is_spam_protection_configured() { |
| 23 | $captcha_configs = array( |
| 24 | array( |
| 25 | 'site_key' => get_option( 'everest_forms_recaptcha_v2_site_key', '' ), |
| 26 | 'secret_key' => get_option( 'everest_forms_recaptcha_v2_secret_key', '' ), |
| 27 | ), |
| 28 | array( |
| 29 | 'site_key' => get_option( 'everest_forms_recaptcha_v2_invisible_site_key', '' ), |
| 30 | 'secret_key' => get_option( 'everest_forms_recaptcha_v2_invisible_secret_key', '' ), |
| 31 | ), |
| 32 | array( |
| 33 | 'site_key' => get_option( 'everest_forms_recaptcha_v3_site_key', '' ), |
| 34 | 'secret_key' => get_option( 'everest_forms_recaptcha_v3_secret_key', '' ), |
| 35 | ), |
| 36 | array( |
| 37 | 'site_key' => get_option( 'everest_forms_recaptcha_hcaptcha_site_key', '' ), |
| 38 | 'secret_key' => get_option( 'everest_forms_recaptcha_hcaptcha_secret_key', '' ), |
| 39 | ), |
| 40 | array( |
| 41 | 'site_key' => get_option( 'everest_forms_recaptcha_turnstile_site_key', '' ), |
| 42 | 'secret_key' => get_option( 'everest_forms_recaptcha_turnstile_secret_key', '' ), |
| 43 | ), |
| 44 | ); |
| 45 | |
| 46 | foreach ( $captcha_configs as $config ) { |
| 47 | if ( ! empty( $config['site_key'] ) && ! empty( $config['secret_key'] ) ) { |
| 48 | return true; |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | return false; |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Check if spam protection step is completed. |
| 57 | * Returns true if EITHER manually skipped OR configured with both keys. |
| 58 | * |
| 59 | * @return bool True if spam protection is completed, false otherwise. |
| 60 | */ |
| 61 | public static function is_spam_protection_completed() { |
| 62 | $manually_skipped = (bool) get_option( 'everest_forms_spam_protection_skipped', false ); |
| 63 | $is_configured = self::is_spam_protection_configured(); |
| 64 | |
| 65 | return $manually_skipped || $is_configured; |
| 66 | } |
| 67 | |
| 68 | |
| 69 | /** |
| 70 | * Handles output of the reports page in admin. |
| 71 | */ |
| 72 | public static function page_output() { |
| 73 | if ( ! is_admin_bar_showing() || ! current_user_can( 'manage_everest_forms' ) ) { |
| 74 | return; |
| 75 | } |
| 76 | if ( ! empty( $_GET['page'] ) && 'evf-dashboard' === $_GET['page'] ) { //phpcs:ignore WordPress.Security.NonceVerification |
| 77 | wp_enqueue_script( 'evf-dashboard-script', EVF()->plugin_url() . '/dist/dashboard.min.js', array( 'wp-element', 'wp-hooks', 'react', 'react-dom' ), EVF()->version, true ); |
| 78 | if ( ! function_exists( 'get_plugins' ) ) { |
| 79 | require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 80 | } |
| 81 | if ( ! function_exists( 'wp_get_themes' ) ) { |
| 82 | require_once ABSPATH . 'wp-admin/includes/theme.php'; |
| 83 | } |
| 84 | $installed_plugin_slugs = array_keys( get_plugins() ); |
| 85 | $allowed_plugin_slugs = array( |
| 86 | 'user-registration/user-registration.php', |
| 87 | 'blockart-blocks/blockart.php', |
| 88 | 'learning-management-system/lms.php', |
| 89 | 'magazine-blocks/magazine-blocks.php', |
| 90 | ); |
| 91 | |
| 92 | $installed_theme_slugs = array_keys( wp_get_themes() ); |
| 93 | $current_theme = get_stylesheet(); |
| 94 | |
| 95 | wp_localize_script( |
| 96 | 'evf-dashboard-script', |
| 97 | '_EVF_DASHBOARD_', |
| 98 | array( |
| 99 | 'adminURL' => esc_url( admin_url() ), |
| 100 | 'adminEmail' => get_option( 'admin_email' ), |
| 101 | 'settingsURL' => esc_url( admin_url( '/admin.php?page=evf-settings' ) ), |
| 102 | 'siteURL' => esc_url( home_url( '/' ) ), |
| 103 | 'liveDemoURL' => esc_url_raw( 'https://everestforms.demoswp.net/' ), |
| 104 | 'assetsURL' => esc_url( EVF()->plugin_url() . '/assets/' ), |
| 105 | 'evfRestApiNonce' => wp_create_nonce( 'wp_rest' ), |
| 106 | 'ajaxURL' => esc_url( admin_url( 'admin-ajax.php' ) ), |
| 107 | 'smartSmtpNonce' => wp_create_nonce( 'everest-forms-smart-smtp-installation-nonce' ), |
| 108 | 'newFormURL' => esc_url( admin_url( '/admin.php?page=evf-builder&create-form=1' ) ), |
| 109 | 'allFormsURL' => esc_url( admin_url( '/admin.php?page=evf-builder' ) ), |
| 110 | 'restURL' => rest_url(), |
| 111 | 'version' => EVF()->version, |
| 112 | 'isPro' => is_plugin_active( 'everest-forms-pro/everest-forms-pro.php' ), |
| 113 | 'showAnalyticsTab' => is_plugin_active( 'everest-forms-form-analytics/everest-forms-form-analytics.php' ), |
| 114 | 'licensePlan' => evf_get_license_plan(), |
| 115 | 'licenseActivationURL' => esc_url_raw( admin_url( 'plugins.php' ) ), |
| 116 | 'utmCampaign' => EVF()->utm_campaign, |
| 117 | 'upgradeURL' => esc_url_raw( 'https://everestforms.net/upgrade/?' ), |
| 118 | 'allStepsCompleted' => ( |
| 119 | (bool) get_option( 'everest_forms_create_form_skipped', false ) |
| 120 | && self::is_spam_protection_completed() |
| 121 | && (bool) get_option( 'everest_forms_test_email_sent', false ) |
| 122 | ) ? '1' : '0', |
| 123 | 'plugins' => array_reduce( |
| 124 | $allowed_plugin_slugs, |
| 125 | function ( $acc, $curr ) use ( $installed_plugin_slugs ) { |
| 126 | if ( in_array( $curr, $installed_plugin_slugs, true ) ) { |
| 127 | |
| 128 | if ( is_plugin_active( $curr ) ) { |
| 129 | $acc[ $curr ] = 'active'; |
| 130 | } else { |
| 131 | $acc[ $curr ] = 'inactive'; |
| 132 | } |
| 133 | } else { |
| 134 | $acc[ $curr ] = 'not-installed'; |
| 135 | } |
| 136 | return $acc; |
| 137 | }, |
| 138 | array() |
| 139 | ), |
| 140 | 'themes' => array( |
| 141 | 'zakra' => strpos( $current_theme, 'zakra' ) !== false ? 'active' : ( |
| 142 | in_array( 'zakra', $installed_theme_slugs, true ) ? 'inactive' : 'not-installed' |
| 143 | ), |
| 144 | 'colormag' => strpos( $current_theme, 'colormag' ) !== false || strpos( $current_theme, 'colormag-pro' ) !== false ? 'active' : ( |
| 145 | in_array( 'colormag', $installed_theme_slugs, true ) || in_array( 'colormag-pro', $installed_theme_slugs, true ) ? 'inactive' : 'not-installed' |
| 146 | ), |
| 147 | ), |
| 148 | 'alert_icon' => plugins_url( 'assets/images/icons/alert-icon.png', EVF_PLUGIN_FILE ), |
| 149 | ) |
| 150 | ); |
| 151 | |
| 152 | ob_start(); |
| 153 | self::dashboard_page_body(); |
| 154 | self::dashboard_page_footer(); |
| 155 | exit; |
| 156 | } |
| 157 | } |
| 158 | /** |
| 159 | * Dashboard Page body content. |
| 160 | * |
| 161 | * @since 1.0.0 |
| 162 | */ |
| 163 | public static function dashboard_page_body() { |
| 164 | ?> |
| 165 | |
| 166 | <body class="everest-forms-dashboard notranslate" translate="no"> |
| 167 | <div id="everest-forms-dashboard"></div> |
| 168 | </body> |
| 169 | <?php |
| 170 | } |
| 171 | |
| 172 | /** |
| 173 | * Dashboard Page footer content. |
| 174 | * |
| 175 | * @since 1.0.0 |
| 176 | */ |
| 177 | public static function dashboard_page_footer() { |
| 178 | if ( function_exists( 'wp_print_media_templates' ) ) { |
| 179 | wp_print_media_templates(); |
| 180 | } |
| 181 | wp_print_footer_scripts(); |
| 182 | |
| 183 | // Action hook for pro/addons to print scripts BEFORE the dashboard script. |
| 184 | do_action( 'everest_forms_dashboard_scripts' ); |
| 185 | |
| 186 | wp_print_scripts( 'evf-dashboard-script' ); |
| 187 | ?> |
| 188 | |
| 189 | </html> |
| 190 | <?php |
| 191 | } |
| 192 | } |
| 193 |