File manager - Edit - /home/theblueo/tv/fb4e3b/Lite.tar
Back
Admin/Connect.php 0000666 00000017322 15214133076 0007711 0 ustar 00 <?php namespace WPForms\Lite\Admin; use WP_Error; use WPForms\Helpers\PluginSilentUpgrader; /** * WPForms Connect. * * WPForms Connect is our service that makes it easy for non-techy users to * upgrade to WPForms Pro without having to manually install WPForms Pro plugin. * * @since 1.5.5 */ class Connect { /** * Constructor. * * @since 1.5.5 */ public function __construct() { $this->hooks(); } /** * Hooks. * * @since 1.5.5 */ public function hooks() { \add_action( 'wpforms_settings_enqueue', array( $this, 'settings_enqueues' ) ); \add_action( 'wp_ajax_wpforms_connect_url', array( $this, 'generate_url' ) ); \add_action( 'wp_ajax_nopriv_wpforms_connect_process', array( $this, 'process' ) ); } /** * Settings page enqueues. * * @since 1.5.5 */ public function settings_enqueues() { $min = \wpforms_get_min_suffix(); \wp_enqueue_script( 'wpforms-connect', \WPFORMS_PLUGIN_URL . "lite/assets/js/admin/connect{$min}.js", array( 'jquery' ), \WPFORMS_VERSION, true ); } /** * Generate and return WPForms Connect URL. * * @since 1.5.5 */ public function generate_url() { $this->init_error_handler(); try { // Run a security check. \check_ajax_referer( 'wpforms-admin', 'nonce' ); // Check for permissions. if ( ! \current_user_can( 'install_plugins' ) ) { \wp_send_json_error( array( 'message' => \esc_html__( 'Sorry, you do not have permission to install plugins.', 'wpforms-lite' ) ) ); } $key = ! empty( $_POST['key'] ) ? \sanitize_text_field( \wp_unslash( $_POST['key'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification if ( empty( $key ) ) { \wp_send_json_error( array( 'message' => \esc_html__( 'Please enter your license key to connect.', 'wpforms-lite' ) ) ); } if ( wpforms()->pro ) { \wp_send_json_error( array( 'message' => \esc_html__( 'Only the Lite version can upgrade.', 'wpforms-lite' ) ) ); } // Verify pro version is not installed. $active = \activate_plugin( 'wpforms/wpforms.php', false, false, true ); if ( ! \is_wp_error( $active ) ) { // Deactivate Lite. \deactivate_plugins( \plugin_basename( WPFORMS_PLUGIN_FILE ) ); \wp_send_json_success( array( 'message' => \esc_html__( 'WPForms Pro was already installed and has not been activated.', 'wpforms-lite' ), 'reload' => true, ) ); } // Generate URL. $oth = hash( 'sha512', \wp_rand() ); \update_option( 'wpforms_connect_token', $oth ); \update_option( 'wpforms_connect', $key ); $version = WPFORMS_VERSION; $endpoint = \admin_url( 'admin-ajax.php' ); $redirect = \admin_url( 'admin.php?page=wpforms-settings' ); $url = \add_query_arg( array( 'key' => $key, 'oth' => $oth, 'endpoint' => $endpoint, 'version' => $version, 'siteurl' => \admin_url(), 'homeurl' => \home_url(), 'redirect' => rawurldecode( base64_encode( $redirect ) ), // phpcs:ignore 'v' => 2, ), 'https://upgrade.wpforms.com' ); \wp_send_json_success( array( 'url' => $url, 'back_url' => \add_query_arg( array( 'action' => 'wpforms_connect', 'oth' => $oth, ), $endpoint ), ) ); } catch ( \Exception $e ) { \wp_send_json_error( array( 'error' => $e->getMessage() . ' in file ' . $e->getFile() . ', line ' . $e->getLine() ) ); } } /** * Process WPForms Connect. * * @since 1.5.5 */ public function process() { $this->init_error_handler(); try { $error = esc_html__( 'Could not install upgrade. Please download from wpforms.com and install manually.', 'wpforms-lite' ); // Verify params present (oth & download link). $post_oth = ! empty( $_REQUEST['oth'] ) ? \sanitize_text_field( \wp_unslash( $_REQUEST['oth'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification $post_url = ! empty( $_REQUEST['file'] ) ? \esc_url_raw( \wp_unslash( $_REQUEST['file'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification if ( empty( $post_oth ) || empty( $post_url ) ) { \wp_send_json_error( $error ); } // Verify oth. $oth = \get_option( 'wpforms_connect_token' ); if ( empty( $oth ) || ! hash_equals( $oth, $post_oth ) ) { \wp_send_json_error( $error ); } // Delete so cannot replay. \delete_option( 'wpforms_connect_token' ); // Set the current screen to avoid undefined notices. \set_current_screen( 'wpforms_page_wpforms-settings' ); // Prepare variables. $url = \esc_url_raw( \add_query_arg( array( 'page' => 'wpforms-settings', ), \admin_url( 'admin.php' ) ) ); // Verify pro not activated. if ( wpforms()->pro ) { \wp_send_json_success( \esc_html__( 'Plugin installed & activated.', 'wpforms-lite' ) ); } // Verify pro not installed. $active = \activate_plugin( 'wpforms/wpforms.php', $url, false, true ); if ( ! \is_wp_error( $active ) ) { \deactivate_plugins( plugin_basename( WPFORMS_PLUGIN_FILE ) ); \wp_send_json_success( esc_html__( 'Plugin installed & activated.', 'wpforms-lite' ) ); } $creds = \request_filesystem_credentials( $url, '', false, false, null ); // Check for file system permissions. $perm_error = \esc_html__( 'Could not install upgrade. Please check for file system permissions and try again. Also you can download plugin from wpforms.com and install manually.', 'wpforms-lite' ); if ( false === $creds || ! \WP_Filesystem( $creds ) ) { \wp_send_json_error( $perm_error ); } /* * We do not need any extra credentials if we have gotten this far, so let's install the plugin. */ // Do not allow WordPress to search/download translations, as this will break JS output. \remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 ); // Create the plugin upgrader with our custom skin. $installer = new PluginSilentUpgrader( new ConnectSkin() ); // Error check. if ( ! method_exists( $installer, 'install' ) ) { \wp_send_json_error( $error ); } // Check license key. $key = \get_option( 'wpforms_connect', false ); if ( empty( $key ) ) { \wp_send_json_error( new WP_Error( '403', \esc_html__( 'No key provided.', 'wpforms-lite' ) ) ); } $installer->install( $post_url ); // phpcs:ignore // Flush the cache and return the newly installed plugin basename. \wp_cache_flush(); $plugin_basename = $installer->plugin_info(); if ( $plugin_basename ) { // Deactivate the lite version first. \deactivate_plugins( \plugin_basename( WPFORMS_PLUGIN_FILE ) ); // Activate the plugin silently. $activated = \activate_plugin( $plugin_basename, '', false, true ); if ( ! \is_wp_error( $activated ) ) { \add_option( 'wpforms_install', 1 ); \wp_send_json_success( \esc_html__( 'Plugin installed & activated.', 'wpforms-lite' ) ); } else { // Reactivate the lite plugin if pro activation failed. \activate_plugin( \plugin_basename( WPFORMS_PLUGIN_FILE ), '', false, true ); \wp_send_json_error( \esc_html__( 'Pro version installed but needs to be activated from the Plugins page inside your WordPress admin.', 'wpforms-lite' ) ); } } \wp_send_json_error( $error ); } catch ( \Exception $e ) { \wp_send_json_error( array( 'error' => $e->getMessage() . ' in file ' . $e->getFile() . ', line ' . $e->getLine() ) ); } } /** * Converting errors to exceptions. * * @since 1.5.5 */ public function init_error_handler() { set_error_handler( // phpcs:ignore function ( $errno, $errstr, $errfile, $errline, array $errcontex ) { throw new \Exception( $errstr ); } ); } } Admin/ConnectSkin.php 0000666 00000001576 15214133076 0010542 0 ustar 00 <?php namespace WPForms\Lite\Admin; use WPForms\Helpers\PluginSilentUpgraderSkin; /** * WPForms Connect Skin. * * WPForms Connect is our service that makes it easy for non-techy users to * upgrade to WPForms Pro without having to manually install WPForms Pro plugin. * * @since 1.5.5 * @since 1.5.6.1 Extend PluginSilentUpgraderSkin and clean up the class. */ class ConnectSkin extends PluginSilentUpgraderSkin { /** * Instead of outputting HTML for errors, json_encode the errors and send them * back to the Ajax script for processing. * * @since 1.5.5 * * @param array $errors Array of errors with the install process. */ public function error( $errors ) { if ( ! empty( $errors ) ) { echo \wp_json_encode( array( 'error' => \esc_html__( 'There was an error installing WPForms Pro. Please try again.', 'wpforms-lite' ), ) ); die; } } } Admin/DashboardWidget.php 0000666 00000032767 15214133076 0011365 0 ustar 00 <?php namespace WPForms\Lite\Admin; /** * Dashboard Widget shows a chart and the form entries stats in WP Dashboard. * * @since 1.5.0 */ class DashboardWidget { /** * Widget settings. * * @since 1.5.0 * * @var array */ public $settings; /** * Constructor. * * @since 1.5.0 */ public function __construct() { add_action( 'admin_init', array( $this, 'init' ) ); } /** * Init class. * * @since 1.5.5 */ public function init() { // This widget should be displayed for certain high-level users only. if ( ! wpforms_current_user_can() ) { return; } if ( ! apply_filters( 'wpforms_admin_dashboardwidget', true ) ) { return; } $this->settings(); $this->hooks(); } /** * Filterable widget settings. * * @since 1.5.0 */ public function settings() { $this->settings = array( // Number of forms to display in the forms list before "Show More" button appears. 'forms_list_number_to_display' => \apply_filters( 'wpforms_dash_widget_forms_list_number_to_display', 5 ), // Allow results caching to reduce DB load. 'allow_data_caching' => \apply_filters( 'wpforms_dash_widget_allow_data_caching', true ), // Transient lifetime in seconds. Defaults to the end of a current day. 'transient_lifetime' => \apply_filters( 'wpforms_dash_widget_transient_lifetime', \strtotime( 'tomorrow' ) - \time() ), // Determine if the forms with no entries should appear in a forms list. Once switched, the effect applies after cache expiration. 'display_forms_list_empty_entries' => \apply_filters( 'wpforms_dash_widget_display_forms_list_empty_entries', true ), ); } /** * Widget hooks. * * @since 1.5.0 */ public function hooks() { \add_action( 'admin_enqueue_scripts', array( $this, 'widget_scripts' ) ); \add_action( 'wp_dashboard_setup', array( $this, 'widget_register' ) ); \add_action( 'admin_init', array( $this, 'hide_widget' ) ); \add_action( 'wpforms_create_form', __CLASS__ . '::clear_widget_cache' ); \add_action( 'wpforms_save_form', __CLASS__ . '::clear_widget_cache' ); \add_action( 'wpforms_delete_form', __CLASS__ . '::clear_widget_cache' ); } /** * Load widget-specific scripts. * * @since 1.5.0 */ public function widget_scripts() { $screen = \get_current_screen(); if ( ! isset( $screen->id ) || 'dashboard' !== $screen->id ) { return; } $min = \wpforms_get_min_suffix(); \wp_enqueue_style( 'wpforms-dashboard-widget', \WPFORMS_PLUGIN_URL . "assets/css/dashboard-widget{$min}.css", array(), \WPFORMS_VERSION ); \wp_enqueue_script( 'wpforms-moment', \WPFORMS_PLUGIN_URL . 'assets/js/moment.min.js', array(), '2.22.2', true ); \wp_enqueue_script( 'wpforms-chart', \WPFORMS_PLUGIN_URL . 'assets/js/chart.min.js', array( 'wpforms-moment' ), '2.7.2', true ); \wp_enqueue_script( 'wpforms-dashboard-widget', \WPFORMS_PLUGIN_URL . "lite/assets/js/admin/dashboard-widget{$min}.js", array( 'jquery', 'wpforms-chart' ), \WPFORMS_VERSION, true ); \wp_localize_script( 'wpforms-dashboard-widget', 'wpforms_dashboard_widget', array( 'show_more_html' => \esc_html__( 'Show More', 'wpforms-lite' ) . '<span class="dashicons dashicons-arrow-down"></span>', 'show_less_html' => \esc_html__( 'Show Less', 'wpforms-lite' ) . '<span class="dashicons dashicons-arrow-up"></span>', 'i18n' => array( 'entries' => \esc_html__( 'Entries', 'wpforms-lite' ), ), ) ); } /** * Register the widget. * * @since 1.5.0 */ public function widget_register() { global $wp_meta_boxes; $widget_key = 'wpforms_reports_widget_lite'; \wp_add_dashboard_widget( $widget_key, \esc_html__( 'WPForms', 'wpforms-lite' ), array( $this, 'widget_content' ) ); // Attempt to place the widget at the top. $normal_dashboard = $wp_meta_boxes['dashboard']['normal']['core']; $widget_instance = array( $widget_key => $normal_dashboard[ $widget_key ] ); unset( $normal_dashboard[ $widget_key ] ); $sorted_dashboard = \array_merge( $widget_instance, $normal_dashboard ); $wp_meta_boxes['dashboard']['normal']['core'] = $sorted_dashboard; } /** * Load widget content. * * @since 1.5.0 */ public function widget_content() { $forms = \wpforms()->form->get( '', array( 'fields' => 'ids' ) ); echo '<div class="wpforms-dash-widget wpforms-lite">'; if ( empty( $forms ) ) { $this->widget_content_no_forms_html(); } else { $this->widget_content_html(); } $plugins = \get_plugins(); if ( ! \array_key_exists( 'google-analytics-for-wordpress/googleanalytics.php', $plugins ) && ! \array_key_exists( 'google-analytics-premium/googleanalytics-premium.php', $plugins ) && ! empty( $forms ) ) { $this->recommended_plugin_block_html(); } echo '</div><!-- .wpforms-dash-widget -->'; } /** * Widget content HTML if a user has no forms. * * @since 1.5.0 */ public function widget_content_no_forms_html() { $create_form_url = \add_query_arg( 'page', 'wpforms-builder', \admin_url( 'admin.php' ) ); $learn_more_url = 'https://wpforms.com/docs/creating-first-form/?utm_source=WordPress&utm_medium=link&utm_campaign=liteplugin&utm_content=dashboardwidget'; ?> <div class="wpforms-dash-widget-block wpforms-dash-widget-block-no-forms"> <img class="wpforms-dash-widget-block-sullie-logo" src="<?php echo \esc_url( WPFORMS_PLUGIN_URL . 'assets/images/sullie.png' ); ?>" alt="<?php \esc_attr_e( 'Sullie the WPForms mascot', 'wpforms-lite' ); ?>"> <h2><?php \esc_html_e( 'Create Your First Form to Start Collecting Leads', 'wpforms-lite' ); ?></h2> <p><?php \esc_html_e( 'You can use WPForms to build contact forms, surveys, payment forms, and more with just a few clicks.', 'wpforms-lite' ); ?></p> <a href="<?php echo \esc_url( $create_form_url ); ?>" class="button button-primary"> <?php \esc_html_e( 'Create Your Form', 'wpforms-lite' ); ?> </a> <a href="<?php echo \esc_url( $learn_more_url ); ?>" class="button" target="_blank" rel="noopener noreferrer"> <?php \esc_html_e( 'Learn More', 'wpforms-lite' ); ?> </a> </div> <?php } /** * Widget content HTML. * * @since 1.5.0 */ public function widget_content_html() { ?> <div class="wpforms-dash-widget-chart-block-container"> <div class="wpforms-dash-widget-block"> <h3 id="wpforms-dash-widget-chart-title"> <?php \esc_html_e( 'Total Entries', 'wpforms-lite' ); ?> </h3> <select class="wpforms-dash-widget-select-timespan" style="display: none;"> <option><?php \esc_html_e( 'Last 7 days', 'wpforms-lite' ); ?></option> </select> </div> <div class="wpforms-dash-widget-block wpforms-dash-widget-chart-block"> <canvas id="wpforms-dash-widget-chart" width="400" height="300"></canvas> </div> <div class="wpforms-dash-widget-block-upgrade"> <div class="wpforms-dash-widget-modal"> <h2><?php \esc_html_e( 'View all Form Entries inside WordPress Dashboard', 'wpforms-lite' ); ?></h2> <p><?php \esc_html_e( 'Form entries reports are not available.', 'wpforms-lite' ); ?></p> <p><?php \esc_html_e( 'Form entries are not stored in Lite.', 'wpforms-lite' ); ?></p> <p><?php \esc_html_e( 'Upgrade to Pro and get access to the reports.', 'wpforms-lite' ); ?></p> <p> <a href="<?php echo \esc_url( wpforms_admin_upgrade_link( 'dashboard-widget' ) ); ?>" class="wpforms-dash-widget-upgrade-btn" target="_blank" rel="noopener noreferrer"> <?php \esc_html_e( 'Upgrade to WPForms Pro', 'wpforms-lite' ); ?> </a> </p> <!-- <p> <a href="https://wpforms.com" class="wpforms-dash-widget-site-link"> <?php \esc_html_e( 'Go to WPForms.com', 'wpforms-lite' ); ?> </a> </p> --> </div> </div> </div> <div class="wpforms-dash-widget-block"> <h3><?php \esc_html_e( 'Total Entries by Form', 'wpforms-lite' ); ?></h3> </div> <div id="wpforms-dash-widget-forms-list-block" class="wpforms-dash-widget-block wpforms-dash-widget-forms-list-block"> <?php $this->forms_list_block(); ?> </div> <?php } /** * Forms list block. * * @since 1.5.0 */ public function forms_list_block() { $forms = $this->get_entries_count_by_form(); if ( empty( $forms ) ) { $this->forms_list_block_empty_html(); } else { $this->forms_list_block_html( $forms ); } } /** * Empty forms list block HTML. * * @since 1.5.0 */ public function forms_list_block_empty_html() { ?> <p class="wpforms-error wpforms-error-no-data-forms-list"> <?php \esc_html_e( 'No entries were submitted yet.', 'wpforms-lite' ); ?> </p> <?php } /** * Forms list block HTML. * * @since 1.5.0 * * @param array $forms Forms to display in the list. */ public function forms_list_block_html( $forms ) { // Number of forms to display in the forms list before "Show More" button appears. $show_forms = $this->settings['forms_list_number_to_display']; ?> <table id="wpforms-dash-widget-forms-list-table" cellspacing="0"> <?php foreach ( \array_values( $forms ) as $key => $form ) : ?> <tr <?php echo $key >= $show_forms ? 'class="wpforms-dash-widget-forms-list-hidden-el"' : ''; ?> data-form-id="<?php echo \absint( $form['form_id'] ); ?>"> <td><span class="wpforms-dash-widget-form-title"><?php echo \esc_html( $form['title'] ); ?></span></td> <td><?php echo \absint( $form['count'] ); ?></td> </tr> <?php endforeach; ?> </table> <?php if ( \count( $forms ) > $show_forms ) : ?> <button type="button" id="wpforms-dash-widget-forms-more" class="wpforms-dash-widget-forms-more" title="<?php \esc_html_e( 'Show all forms', 'wpforms-lite' ); ?>"> <?php \esc_html_e( 'Show More', 'wpforms-lite' ); ?> <span class="dashicons dashicons-arrow-down"></span> </button> <?php endif; ?> <?php } /** * Recommended plugin block HTML. * * @since 1.5.0 */ public function recommended_plugin_block_html() { $install_mi_url = \wp_nonce_url( \self_admin_url( 'update.php?action=install-plugin&plugin=google-analytics-for-wordpress' ), 'install-plugin_google-analytics-for-wordpress' ); ?> <div class="wpforms-dash-widget-recommended-plugin-block"> <p><?php \esc_html_e( 'Recommended Plugin:', 'wpforms-lite' ); ?> <b><?php \esc_html_e( 'MonsterInsights', 'wpforms-lite' ); ?></b> - <a href="<?php echo \esc_url( $install_mi_url ); ?>"><?php \esc_html_e( 'Install', 'wpforms-lite' ); ?></a> | <a href="https://www.monsterinsights.com/?utm_source=wpformsplugin&utm_medium=link&utm_campaign=wpformsdashboardwidget"><?php \esc_html_e( 'Learn More', 'wpforms-lite' ); ?></a></p> </div> <?php } /** * Get entries count grouped by form. * Main point of entry to fetch form entry count data from DB. * Cache the result. * * @since 1.5.0 * * @return array */ public function get_entries_count_by_form() { // Allow results caching to reduce DB load. $allow_caching = $this->settings['allow_data_caching']; if ( $allow_caching ) { $transient_name = 'wpforms_dash_widget_lite_entries_by_form'; $cache = \get_transient( $transient_name ); // Filter the cache to clear or alter its data. $cache = \apply_filters( 'wpforms_dash_widget_lite_cached_data', $cache ); } // is_array() detects cached empty searches. if ( $allow_caching && \is_array( $cache ) ) { return $cache; } $forms = \wpforms()->form->get( '', array( 'fields' => 'ids' ) ); if ( empty( $forms ) || ! \is_array( $forms ) ) { return array(); } $result = array(); foreach ( $forms as $form_id ) { $count = \absint( \get_post_meta( $form_id, 'wpforms_entries_count', true ) ); if ( empty( $count ) && empty( $this->settings['display_forms_list_empty_entries'] ) ) { continue; } $result[ $form_id ] = array( 'form_id' => $form_id, 'count' => $count, 'title' => \get_the_title( $form_id ), ); } if ( ! empty( $result ) ) { // Sort forms by entries count (desc). \uasort( $result, function ( $a, $b ) { return ( $a['count'] > $b['count'] ) ? - 1 : 1; } ); } if ( $allow_caching ) { // Transient lifetime in seconds. Defaults to the end of a current day. $transient_lifetime = $this->settings['transient_lifetime']; \set_transient( $transient_name, $result, $transient_lifetime ); } return $result; } /** * Hide dashboard widget. * Use dashboard screen options to make it visible again. * * @since 1.5.0 */ public function hide_widget() { if ( ! \is_admin() || ! \is_user_logged_in() ) { return; } if ( ! isset( $_GET['wpforms-nonce'] ) || ! \wp_verify_nonce( \sanitize_key( \wp_unslash( $_GET['wpforms-nonce'] ) ), 'wpforms_hide_dash_widget' ) ) { return; } if ( ! isset( $_GET['wpforms-widget'] ) || 'hide' !== $_GET['wpforms-widget'] ) { return; } $user_id = \get_current_user_id(); $metaboxhidden = \get_user_meta( $user_id, 'metaboxhidden_dashboard', true ); if ( ! \is_array( $metaboxhidden ) ) { \update_user_meta( $user_id, 'metaboxhidden_dashboard', array( 'wpforms_reports_widget_lite' ) ); } if ( \is_array( $metaboxhidden ) && ! \in_array( 'wpforms_reports_widget_lite', $metaboxhidden, true ) ) { $metaboxhidden[] = 'wpforms_reports_widget_lite'; \update_user_meta( $user_id, 'metaboxhidden_dashboard', $metaboxhidden ); } $redirect_url = \remove_query_arg( array( 'wpforms-widget', 'wpforms-nonce' ) ); \wp_safe_redirect( $redirect_url ); exit(); } /** * Clear dashboard widget cached data. * * @since 1.5.2 */ public static function clear_widget_cache() { delete_transient( 'wpforms_dash_widget_lite_entries_by_form' ); } } Admin/Education.php 0000666 00000006267 15214133076 0010241 0 ustar 00 <?php namespace WPForms\Lite\Admin; /** * WPForms admin pages changes and enhancements to educate Lite users on what is available in WPForms Pro. * * @since 1.5.7 */ class Education { /** * WPForms admin page slug. * * @since 1.5.7 * * @var string */ public $page; /** * Constructor. * * @since 1.5.7 */ public function __construct() { $this->hooks(); } /** * Hooks. * * @since 1.5.7 */ public function hooks() { if ( ! \wpforms_is_admin_page() && ! \wp_doing_ajax() ) { return; } if ( ! \apply_filters( 'wpforms_lite_admin_education', true ) ) { return; } // Admin page slug. $this->page = str_replace( 'wpforms-', '', filter_input( INPUT_GET, 'page', FILTER_SANITIZE_STRING ) ); \add_action( 'admin_init', array( $this, 'notice_bar_init' ) ); } /** * Notice bar init. * * @since 1.5.7 */ public function notice_bar_init() { \add_action( 'admin_enqueue_scripts', array( $this, 'enqueues' ) ); \add_action( 'wpforms_admin_header_before', array( $this, 'notice_bar_display' ) ); \add_action( 'wp_ajax_wpforms_notice_bar_dismiss', array( $this, 'notice_bar_ajax_dismiss' ) ); } /** * Notice bar display message. * * @since 1.5.7 */ public function notice_bar_display() { $current_user = \wp_get_current_user(); $dismissed = \get_user_meta( $current_user->ID, 'wpforms_dismissed', true ); if ( ! empty( $dismissed['lite-notice-bar'] ) ) { return; } $msg = sprintf( /* translators: %s - WPForms.com Upgrade page URL. */ __( 'You’re using WPForms Lite. To unlock more features consider <a href="%s" target="_blank" rel="noopener noreferrer">upgrading to Pro</a>.', 'wpforms-lite' ), \wpforms_admin_upgrade_link( 'notice-bar' ) ); printf( '<div id="wpforms-notice-bar"> <span class="wpforms-notice-bar-message">%s</span> <button type="button" class="dismiss" title="%s" data-page="%s" /> </div>', \wp_kses( $msg, array( 'a' => array( 'href' => array(), 'rel' => array(), 'target' => array(), ), ) ), \esc_attr__( 'Dismiss this message.', 'wpforms-lite' ), \esc_attr( $this->page ) ); } /** * Ajax handler for dismissing DYK notices. * * @since 1.5.7 */ public function notice_bar_ajax_dismiss() { // Run a security check. \check_ajax_referer( 'wpforms-admin', 'nonce' ); // Check for permissions. if ( ! \wpforms_current_user_can() ) { \wp_send_json_error( array( 'error' => \esc_html__( 'You do not have permission to perform this action.', 'wpforms-lite' ), ) ); } $current_user = \wp_get_current_user(); $dismissed = \get_user_meta( $current_user->ID, 'wpforms_dismissed', true ); if ( empty( $dismissed ) ) { $dismissed = array(); } $dismissed['lite-notice-bar'] = time(); \update_user_meta( $current_user->ID, 'wpforms_dismissed', $dismissed ); \wp_send_json_success(); } /** * Load enqueues. * * @since 1.5.7 */ public function enqueues() { $min = \wpforms_get_min_suffix(); \wp_enqueue_script( 'wpforms-lite-admin-education', \WPFORMS_PLUGIN_URL . "lite/assets/js/admin/education{$min}.js", array( 'jquery' ), \WPFORMS_VERSION, false ); } } Admin/Builder/Education.php 0000666 00000054461 15214133076 0011626 0 ustar 00 <?php namespace WPForms\Lite\Admin\Builder; /** * Form Builder changes and enhancements to educate Lite users on what is available in WPForms Pro. * * @since 1.5.1 */ class Education { /** * Constructor. * * @since 1.5.1 */ public function __construct() { $this->hooks(); } /** * Hooks. * * @since 1.5.1 */ public function hooks() { if ( wp_doing_ajax() ) { add_action( 'wp_ajax_wpforms_dyk_dismiss', array( $this, 'dyk_ajax_dismiss' ) ); add_action( 'wp_ajax_wpforms_update_field_recaptcha', array( $this, 'recaptcha_field_callback' ) ); } // Only proceed for the form builder. if ( ! wpforms_is_admin_page( 'builder' ) ) { return; } add_action( 'wpforms_field_options_after_advanced-options', array( $this, 'field_conditional_logic' ), 10, 2 ); add_filter( 'wpforms_lite_builder_strings', array( $this, 'js_strings' ) ); add_action( 'wpforms_builder_enqueues_before', array( $this, 'enqueues' ) ); add_action( 'wpforms_setup_panel_after', array( $this, 'templates' ) ); add_filter( 'wpforms_builder_fields_buttons', array( $this, 'fields' ), 50 ); add_action( 'wpforms_builder_after_panel_sidebar', array( $this, 'settings' ), 100, 2 ); add_action( 'wpforms_providers_panel_sidebar', array( $this, 'providers' ), 50 ); add_action( 'wpforms_payments_panel_sidebar', array( $this, 'payments' ), 50 ); add_action( 'wpforms_builder_settings_notifications_after', array( $this, 'dyk_notifications' ) ); add_action( 'wpforms_builder_settings_confirmations_after', array( $this, 'dyk_confirmations' ) ); } /** * Localize needed strings. * * @since 1.5.1 * * @param array $strings JS strings. * * @return array */ public function js_strings( $strings ) { $strings['upgrade'] = [ 'pro' => [ 'title' => esc_html__( 'is a PRO Feature', 'wpforms-lite' ), 'message' => '<p>' . esc_html__( 'We\'re sorry, the %name% is not available on your plan. Please upgrade to the PRO plan to unlock all these awesome features.', 'wpforms-lite' ) . '</p>', 'bonus' => '<p>' . wp_kses( __( '<strong>Bonus:</strong> WPForms Lite users get <span>50% off</span> regular price, automatically applied at checkout.', 'wpforms-lite' ), [ 'strong' => [], 'span' => [], ] ) . '</p>', 'doc' => '<a href="https://wpforms.com/docs/upgrade-wpforms-lite-paid-license/?utm_source=WordPress&utm_medium=link&utm_campaign=liteplugin&utm_content=upgrade-pro" target="_blank" rel="noopener noreferrer" class="already-purchased">' . esc_html__( 'Already purchased?', 'wpforms-lite' ) . '</a>', 'button' => esc_html__( 'Upgrade to PRO', 'wpforms-lite' ), 'url' => wpforms_admin_upgrade_link( 'builder-modal', 'upgrade-pro' ), 'modal' => wpforms_get_upgrade_modal_text( 'pro' ), ], 'elite' => [ 'title' => esc_html__( 'is an Elite Feature', 'wpforms-lite' ), 'message' => '<p>' . esc_html__( 'We\'re sorry, the %name% is not available on your plan. Please upgrade to the Elite plan to unlock all these awesome features.', 'wpforms-lite' ) . '</p>', 'bonus' => '<p>' . wp_kses( __( '<strong>Bonus:</strong> WPForms Lite users get <span>50% off</span> regular price, automatically applied at checkout.', 'wpforms-lite' ), [ 'strong' => [], 'span' => [], ] ) . '</p>', 'doc' => '<a href="https://wpforms.com/docs/upgrade-wpforms-lite-paid-license/?utm_source=WordPress&utm_medium=link&utm_campaign=liteplugin&utm_content=upgrade-elite" target="_blank" rel="noopener noreferrer" class="already-purchased">' . esc_html__( 'Already purchased?', 'wpforms-lite' ) . '</a>', 'button' => esc_html__( 'Upgrade to Elite', 'wpforms-lite' ), 'url' => wpforms_admin_upgrade_link( 'builder-modal', 'upgrade-elite' ), 'modal' => wpforms_get_upgrade_modal_text( 'elite' ), ], ]; return $strings; } /** * Load enqueues. * * @since 1.5.1 */ public function enqueues() { $min = wpforms_get_min_suffix(); wp_enqueue_script( 'wpforms-builder-education', WPFORMS_PLUGIN_URL . "lite/assets/js/admin/builder-education{$min}.js", array( 'jquery', 'jquery-confirm' ), WPFORMS_VERSION, false ); } /** * Display templates. * * @since 1.5.1 */ public function templates() { $templates = array( array( 'name' => esc_html__( 'Request A Quote Form', 'wpforms-lite' ), 'slug' => 'request-quote', 'description' => esc_html__( 'Start collecting leads with this pre-made Request a quote form. You can add and remove fields as needed.', 'wpforms-lite' ), ), array( 'name' => esc_html__( 'Donation Form', 'wpforms-lite' ), 'slug' => 'donation', 'description' => esc_html__( 'Start collecting donation payments on your website with this ready-made Donation form. You can add and remove fields as needed.', 'wpforms-lite' ), ), array( 'name' => esc_html__( 'Billing / Order Form', 'wpforms-lite' ), 'slug' => 'order', 'description' => esc_html__( 'Collect payments for product and service orders with this ready-made form template. You can add and remove fields as needed.', 'wpforms-lite' ), ), ); ?> <div class="wpforms-setup-title"> <?php esc_html_e( 'Unlock Pre-Made Form Templates', 'wpforms-lite' ); ?> <a href="<?php echo esc_url( wpforms_admin_upgrade_link( 'builder-templates' ) ); ?>" target="_blank" rel="noopener noreferrer" class="btn-green wpforms-upgrade-link wpforms-upgrade-modal" style="text-transform: uppercase;font-size: 13px;font-weight: 700;padding: 5px 10px;vertical-align: text-bottom;"> <?php esc_html_e( 'Upgrade', 'wpforms-lite' ); ?> </a> </div> <p class="wpforms-setup-desc"> <?php esc_html_e( 'While WPForms Lite allows you to create any type of form, you can speed up the process by unlocking our other pre-built form templates among other features, so you never have to start from scratch again...', 'wpforms-lite' ); ?> </p> <div class="wpforms-setup-templates wpforms-clear" style="opacity:0.5;"> <?php $x = 0; foreach ( $templates as $template ) { $class = 0 === $x % 3 ? 'first ' : ''; ?> <div class="wpforms-template upgrade-modal <?php echo sanitize_html_class( $class ); ?>" id="wpforms-template-<?php echo sanitize_html_class( $template['slug'] ); ?>"> <div class="wpforms-template-name wpforms-clear"> <?php echo esc_html( $template['name'] ); ?> </div> <div class="wpforms-template-details"> <p class="desc"><?php echo esc_html( $template['description'] ); ?></p> </div> </div> <?php $x ++; } ?> </div> <?php } /** * Display fields. * * @since 1.5.1 * * @param array $fields Form fields. * * @return array */ public function fields( $fields ) { // Add reCAPTCHA field to Standard group. $fields['standard']['fields'][] = array( 'icon' => 'fa-google', 'name' => esc_html__( 'reCAPTCHA', 'wpforms-lite' ), 'type' => 'recaptcha', 'order' => 180, 'class' => 'not-draggable', ); $fields['fancy']['fields'] = array( array( 'icon' => 'fa-phone', 'name' => esc_html__( 'Phone', 'wpforms-lite' ), 'type' => 'phone', 'order' => '1', 'class' => 'upgrade-modal', ), array( 'icon' => 'fa-map-marker', 'name' => esc_html__( 'Address', 'wpforms-lite' ), 'type' => 'address', 'order' => '2', 'class' => 'upgrade-modal', ), array( 'icon' => 'fa-calendar-o', 'name' => esc_html__( 'Date / Time', 'wpforms-lite' ), 'type' => 'date-time', 'order' => '3', 'class' => 'upgrade-modal', ), array( 'icon' => 'fa-link', 'name' => esc_html__( 'Website / URL', 'wpforms-lite' ), 'type' => 'url', 'order' => '4', 'class' => 'upgrade-modal', ), array( 'icon' => 'fa-upload', 'name' => esc_html__( 'File Upload', 'wpforms-lite' ), 'type' => 'file-upload', 'order' => '5', 'class' => 'upgrade-modal', ), array( 'icon' => 'fa-lock', 'name' => esc_html__( 'Password', 'wpforms-lite' ), 'type' => 'password', 'order' => '6', 'class' => 'upgrade-modal', ), array( 'icon' => 'fa-files-o', 'name' => esc_html__( 'Page Break', 'wpforms-lite' ), 'type' => 'pagebreak', 'order' => '7', 'class' => 'upgrade-modal', ), array( 'icon' => 'fa-arrows-h', 'name' => esc_html__( 'Section Divider', 'wpforms-lite' ), 'type' => 'divider', 'order' => '8', 'class' => 'upgrade-modal', ), array( 'icon' => 'fa-eye-slash', 'name' => esc_html__( 'Hidden Field', 'wpforms-lite' ), 'type' => 'hidden', 'order' => '9', 'class' => 'upgrade-modal', ), array( 'icon' => 'fa-code', 'name' => esc_html__( 'HTML', 'wpforms-lite' ), 'type' => 'html', 'order' => '10', 'class' => 'upgrade-modal', ), array( 'icon' => 'fa-star', 'name' => esc_html__( 'Rating', 'wpforms-lite' ), 'type' => 'rating', 'order' => '11', 'class' => 'upgrade-modal', ), array( 'icon' => 'fa-question-circle', 'name' => esc_html__( 'Captcha', 'wpforms-lite' ), 'type' => 'captcha', 'order' => '12', 'class' => 'upgrade-modal', ), array( 'icon' => 'fa-pencil', 'name' => esc_html__( 'Signature', 'wpforms-lite' ), 'type' => 'signature', 'order' => '13', 'class' => 'upgrade-modal', ), array( 'icon' => 'fa-ellipsis-h', 'name' => esc_html__( 'Likert Scale', 'wpforms-lite' ), 'type' => 'likert_scale', 'order' => '14', 'class' => 'upgrade-modal', ), array( 'icon' => 'fa-tachometer', 'name' => esc_html__( 'Net Promoter Score', 'wpforms-lite' ), 'type' => 'net_promoter_score', 'order' => '15', 'class' => 'upgrade-modal', ), ); $fields['payment']['fields'] = array( array( 'icon' => 'fa-file-o', 'name' => esc_html__( 'Single Item', 'wpforms-lite' ), 'type' => 'payment-single', 'order' => '1', 'class' => 'upgrade-modal', ), array( 'icon' => 'fa-list-ul', 'name' => esc_html__( 'Multiple Items', 'wpforms-lite' ), 'type' => 'payment-multiple', 'order' => '2', 'class' => 'upgrade-modal', ), array( 'icon' => 'fa-check-square-o', 'name' => esc_html__( 'Checkbox Items', 'wpforms-lite' ), 'type' => 'payment-checkbox', 'order' => '3', 'class' => 'upgrade-modal', ), array( 'icon' => 'fa-caret-square-o-down', 'name' => esc_html__( 'Dropdown Items', 'wpforms-lite' ), 'type' => 'payment-select', 'order' => '4', 'class' => 'upgrade-modal', ), array( 'icon' => 'fa-money', 'name' => esc_html__( 'Total', 'wpforms-lite' ), 'type' => 'payment-total', 'order' => '5', 'class' => 'upgrade-modal', ), ); return $fields; } /** * Display conditional logic settings section for fields inside the form builder. * * @since 1.5.5 * * @param array $field Field data. * @param object $instance Builder instance. */ public function field_conditional_logic( $field, $instance ) { // Certain fields don't support conditional logic. if ( in_array( $field['type'], array( 'pagebreak', 'divider', 'hidden' ), true ) ) { return; } ?> <div class="wpforms-field-option-group"> <a href="#" class="wpforms-field-option-group-toggle upgrade-modal" data-name="<?php esc_attr_e( 'Conditional Logic', 'wpforms-lite' ); ?>"> <?php esc_html_e( 'Conditionals', 'wpforms-lite' ); ?> <i class="fa fa-angle-right"></i> </a> </div> <?php } /** * Display settings panels. * * @since 1.5.1 * * @param object $form Current form. * @param string $slug Panel slug. */ public function settings( $form, $slug ) { if ( 'settings' !== $slug ) { return; } $settings = array( array( 'name' => esc_html__( 'Conversational Forms', 'wpforms-lite' ), 'slug' => 'conversational-forms', 'plugin' => 'wpforms-conversational-forms/wpforms-conversational-forms.php', 'plugin_slug' => 'wpforms-conversational-forms', 'license' => 'pro', ), array( 'name' => esc_html__( 'Surveys and Polls', 'wpforms-lite' ), 'slug' => 'surveys-polls', 'plugin' => 'wpforms-surveys-polls/wpforms-surveys-polls.php', 'plugin_slug' => 'wpforms-surveys-polls', 'license' => 'pro', ), array( 'name' => esc_html__( 'Form Pages', 'wpforms-lite' ), 'slug' => 'form-pages', 'plugin' => 'wpforms-form-pages/wpforms-form-pages.php', 'plugin_slug' => 'wpforms-form-pages', 'license' => 'pro', ), array( 'name' => esc_html__( 'Form Locker', 'wpforms-lite' ), 'slug' => 'form-locker', 'plugin' => 'wpforms-form-locker/wpforms-form-locker.php', 'plugin_slug' => 'wpforms-form-locker', 'license' => 'pro', ), array( 'name' => esc_html__( 'Form Abandonment', 'wpforms-lite' ), 'slug' => 'form-abandonment', 'plugin' => 'wpforms-form-abandonment/wpforms-form-abandonment.php', 'plugin_slug' => 'wpforms-form-abandonment', 'license' => 'pro', ), array( 'name' => esc_html__( 'Post Submissions', 'wpforms-lite' ), 'slug' => 'post-submissions', 'plugin' => 'wpforms-post-submissions/wpforms-post-submissions.php', 'plugin_slug' => 'wpforms-post-submissions', 'license' => 'pro', ), ); foreach ( $settings as $setting ) { /* translators: %s - addon name. */ $modal_name = sprintf( esc_html__( '%s addon', 'wpforms' ), $setting['name'] ); printf( '<a href="#" class="wpforms-panel-sidebar-section wpforms-panel-sidebar-section-%s upgrade-modal" data-name="%s" data-license="%s">', esc_attr( $setting['slug'] ), esc_attr( $modal_name ), esc_attr( $setting['license'] ) ); echo esc_html( $setting['name'] ); echo '<i class="fa fa-angle-right wpforms-toggle-arrow"></i>'; echo '</a>'; } } /** * Display providers. * * @since 1.5.1 */ public function providers() { $providers = wpforms_get_providers_all(); foreach ( $providers as $provider ) { $this->display_single_addon_btn( $provider ); } } /** * Display payments. * * @since 1.5.1 */ public function payments() { $payments = array( array( 'name' => esc_html__( 'PayPal Standard', 'wpforms-lite' ), 'slug' => 'paypal_standard', 'img' => 'addon-icon-paypal.png', 'license' => 'pro', ), array( 'name' => esc_html__( 'Stripe', 'wpforms-lite' ), 'slug' => 'stripe', 'img' => 'addon-icon-stripe.png', 'license' => 'pro', ), ); foreach ( $payments as $payment ) { $this->display_single_addon_btn( $payment ); } } /** * Display a single addon button in a builder. * * @since 1.5.7 * * @param array $addon Required keys: name, slug, img. */ protected function display_single_addon_btn( $addon ) { if ( ! isset( $addon['name'], $addon['slug'], $addon['img'], $addon['license'] ) ) { return; } /* translators: %s - addon name. */ $modal_name = sprintf( esc_html__( '%s addon', 'wpforms-lite' ), $addon['name'] ); ?> <a href="#" class="wpforms-panel-sidebar-section icon wpforms-panel-sidebar-section-<?php echo esc_attr( $addon['slug'] ); ?> upgrade-modal" data-name="<?php echo esc_attr( $modal_name ); ?>" data-license="<?php echo esc_attr( $addon['license'] ); ?>"> <img src="<?php echo esc_attr( WPFORMS_PLUGIN_URL . 'assets/images/' . $addon['img'] ); ?>" alt=""> <?php echo esc_html( $addon['name'] ); ?> <i class="fa fa-angle-right wpforms-toggle-arrow"></i> </a> <?php } /** * Targeting on `reCAPTCHA` field button in the builder. * * TODO: Lite and Pro Education duplicate this code. * * @since 1.5.7 */ public function recaptcha_field_callback() { // Run a security check. check_ajax_referer( 'wpforms-builder', 'nonce' ); // Check for permissions. if ( ! wpforms_current_user_can() ) { die( esc_html__( 'You do not have permission.', 'wpforms-lite' ) ); } // Check for form ID. if ( ! isset( $_POST['id'] ) || empty( $_POST['id'] ) ) { die( esc_html__( 'No form ID found.', 'wpforms-lite' ) ); } // Get an actual form data. $form_id = absint( $_POST['id'] ); $form_data = wpforms()->form->get( $form_id, array( 'content_only' => true ) ); if ( empty( $form_data ) ) { wp_send_json_error( esc_html__( 'Something wrong. Please, try again later.', 'wpforms-lite' ) ); } // Check that recaptcha is configured in the settings. $site_key = wpforms_setting( 'recaptcha-site-key' ); $secret_key = wpforms_setting( 'recaptcha-secret-key' ); $recaptcha_name = $this->get_recaptcha_name(); if ( empty( $recaptcha_name ) ) { wp_send_json_error( esc_html__( 'Something wrong. Please, try again later.', 'wpforms-lite' ) ); } // Prepare a result array. $data = array( 'current' => false, 'cases' => array( 'not_configured' => array( 'title' => esc_html__( 'Heads up!', 'wpforms-lite' ), 'content' => sprintf( wp_kses( /* translators: %1$s - reCaptcha settings page URL; %2$s - WPForms.com doc URL. */ __( 'Google reCAPTCHA isn\'t configured yet. Please complete the setup in your <a href="%1$s" target="_blank">WPForms Settings</a>, and check out our <a href="%2$s" target="_blank" rel="noopener noreferrer">step by step tutorial</a> for full details.', 'wpforms-lite' ), array( 'a' => array( 'href' => true, 'rel' => true, 'target' => true, ), ) ), esc_url( admin_url( 'admin.php?page=wpforms-settings&view=recaptcha' ) ), 'https://wpforms.com/docs/setup-captcha-wpforms/' ), ), 'configured_not_enabled' => array( 'title' => false, /* translators: %s - reCAPTCHA type. */ 'content' => sprintf( esc_html__( '%s has been enabled for this form. Don\'t forget to save your form!', 'wpforms-lite' ), $recaptcha_name ), ), 'configured_enabled' => array( 'title' => false, 'content' => esc_html__( 'Are you sure you want to disable Google reCAPTCHA for this form?', 'wpforms-lite' ), 'cancel' => true, ), ), ); if ( ! $site_key || ! $secret_key ) { // If reCAPTCHA is not configured in the WPForms plugin settings. $data['current'] = 'not_configured'; } elseif ( ! isset( $form_data['settings']['recaptcha'] ) || '1' !== $form_data['settings']['recaptcha'] ) { // If reCAPTCHA is configured in WPForms plugin settings, but wasn't set in form settings. $data['current'] = 'configured_not_enabled'; } else { // If reCAPTCHA is configured in WPForms plugin and form settings. $data['current'] = 'configured_enabled'; } wp_send_json_success( $data ); } /** * Retrive a reCAPTCHA type name. * * @since 1.5.8 * * @return string */ public function get_recaptcha_name() { $recaptcha_type = wpforms_setting( 'recaptcha-type', 'v2' ); // Get a recaptcha name. switch ( $recaptcha_type ) { case 'v2': $recaptcha_name = esc_html__( 'Google Checkbox v2 reCAPTCHA', 'wpforms-lite' ); break; case 'invisible': $recaptcha_name = esc_html__( 'Google Invisible v2 reCAPTCHA', 'wpforms-lite' ); break; case 'v3': $recaptcha_name = esc_html__( 'Google v3 reCAPTCHA', 'wpforms-lite' ); break; default: $recaptcha_name = ''; break; } return $recaptcha_name; } /** * "Did You Know?" Notifications. * * @since 1.5.8 */ public function dyk_notifications() { $this->dyk_display( 'notifications', array( 'desc' => esc_html__( 'You can have multiple notifications with conditional logic.', 'wpforms-lite' ), ) ); } /** * "Did You Know?" Notifications. * * @since 1.5.8 */ public function dyk_confirmations() { $this->dyk_display( 'confirmations', array( 'desc' => esc_html__( 'You can have multiple confirmations with conditional logic.', 'wpforms-lite' ), ) ); } /** * "Did You Know?" display message. * * @since 1.5.8 * * @param string $section Form builder section/area (slug). * @param array $settings Notice settings array. */ public function dyk_display( $section, $settings ) { $current_user = wp_get_current_user(); $dismissed = get_user_meta( $current_user->ID, 'wpforms_dismissed', true ); // Check if not dismissed. if ( ! empty( $dismissed[ 'dyk-builder-' . $section ] ) ) { return; } $translations = array( 'upgrade_to_pro' => __( 'Upgrade to Pro.', 'wpforms' ), 'dismiss_title' => __( 'Dismiss this message.', 'wpforms' ), 'did_you_know' => __( 'Did You Know?', 'wpforms' ), 'learn_more' => __( 'Learn More', 'wpforms' ), ); $learn_more = ( ! empty( $settings['more'] ) ) ? '<a href="' . esc_url( $settings['more'] ) . '" class="learn-more">' . esc_html( $translations['learn_more'] ) . '</a>' : ''; printf( '<section class="wpforms-dyk"> <div class="wpforms-dyk-fbox"> <div class="wpforms-dyk-message"><b>%s</b><br>%s</div> <div class="wpforms-dyk-buttons"> %s <a href="%s" target="_blank" rel="noopener noreferrer" class="wpforms-btn wpforms-btn-md wpforms-btn-light-grey">%s</a> <button type="button" class="dismiss" title="%s" data-section="%s"/> </div> </div> </section>', esc_html( $translations['did_you_know'] ), esc_html( $settings['desc'] ), $learn_more, // phpcs:ignore esc_url( wpforms_admin_upgrade_link( 'Form Builder DYK', ucfirst( $section ) ) ), esc_html( $translations['upgrade_to_pro'] ), esc_attr( $translations['dismiss_title'] ), esc_attr( $section ) ); } /** * Ajax handler for dismissing DYK notices. * * @since 1.5.8 */ public function dyk_ajax_dismiss() { // Run a security check. check_ajax_referer( 'wpforms-builder', 'nonce' ); // Check for permissions. if ( ! wpforms_current_user_can() ) { wp_send_json_error( array( 'error' => esc_html__( 'You do not have permission to perform this action.', 'wpforms-lite' ), ) ); } $current_user = wp_get_current_user(); $dismissed = get_user_meta( $current_user->ID, 'wpforms_dismissed', true ); if ( empty( $dismissed ) ) { $dismissed = array(); } $section = ! empty( $_GET['section'] ) ? sanitize_key( wp_unslash( $_GET['section'] ) ) : ''; $dismissed[ 'dyk-builder-' . $section ] = time(); update_user_meta( $current_user->ID, 'wpforms_dismissed', $dismissed ); wp_send_json_success(); } } Admin/Settings/Education.php 0000666 00000011327 15214133076 0012032 0 ustar 00 <?php namespace WPForms\Lite\Admin\Settings; /** * Settings changes and enhancements to educate Lite users on what is * available in WPForms Pro. * * @since 1.5.5 */ class Education { /** * Constructor. * * @since 1.5.1 */ public function __construct() { $this->hooks(); } /** * Hooks. * * @since 1.5.1 */ public function hooks() { // Only proceed for the Settings > Integrations tab. if ( ! \wpforms_is_admin_page( 'settings' ) ) { return; } // Integrations related hooks. if ( \wpforms_is_admin_page( 'settings', 'integrations' ) ) { \add_filter( 'wpforms_admin_strings', array( $this, 'js_strings' ) ); \add_action( 'admin_enqueue_scripts', array( $this, 'enqueues' ) ); \add_action( 'wpforms_settings_providers', array( $this, 'providers' ), 10000, 1 ); } } /** * Localize needed strings. * * @since 1.5.5 * * @param array $strings JS strings. * * @return array */ public function js_strings( $strings ) { $strings['upgrade'] = [ 'pro' => [ 'title' => esc_html__( 'is a PRO Feature', 'wpforms-lite' ), 'message' => '<p>' . esc_html__( 'We\'re sorry, the %name% is not available on your plan. Please upgrade to the PRO plan to unlock all these awesome features.', 'wpforms-lite' ) . '</p>', 'bonus' => '<p>' . wp_kses( __( '<strong>Bonus:</strong> WPForms Lite users get <span>50% off</span> regular price, automatically applied at checkout.', 'wpforms-lite' ), [ 'strong' => [], 'span' => [], ] ) . '</p>', 'doc' => '<a href="https://wpforms.com/docs/upgrade-wpforms-lite-paid-license/?utm_source=WordPress&utm_medium=link&utm_campaign=liteplugin&utm_content=upgrade-pro" target="_blank" rel="noopener noreferrer" class="already-purchased">' . esc_html__( 'Already purchased?', 'wpforms-lite' ) . '</a>', 'button' => esc_html__( 'Upgrade to PRO', 'wpforms-lite' ), 'url' => wpforms_admin_upgrade_link( 'settings-modal', 'upgrade-pro' ), 'modal' => wpforms_get_upgrade_modal_text( 'pro' ), ], 'elite' => [ 'title' => esc_html__( 'is an Elite Feature', 'wpforms-lite' ), 'message' => '<p>' . esc_html__( 'We\'re sorry, the %name% is not available on your plan. Please upgrade to the Elite plan to unlock all these awesome features.', 'wpforms-lite' ) . '</p>', 'bonus' => '<p>' . wp_kses( __( '<strong>Bonus:</strong> WPForms Lite users get <span>50% off</span> regular price, automatically applied at checkout.', 'wpforms-lite' ), [ 'strong' => [], 'span' => [], ] ) . '</p>', 'doc' => '<a href="https://wpforms.com/docs/upgrade-wpforms-lite-paid-license/?utm_source=WordPress&utm_medium=link&utm_campaign=liteplugin&utm_content=upgrade-elite" target="_blank" rel="noopener noreferrer" class="already-purchased">' . esc_html__( 'Already purchased?', 'wpforms-lite' ) . '</a>', 'button' => esc_html__( 'Upgrade to Elite', 'wpforms-lite' ), 'url' => wpforms_admin_upgrade_link( 'settings-modal', 'upgrade-elite' ), 'modal' => wpforms_get_upgrade_modal_text( 'elite' ), ], ]; return $strings; } /** * Load enqueues. * * @since 1.5.5 */ public function enqueues() { $min = \wpforms_get_min_suffix(); \wp_enqueue_script( 'wpforms-settings-education', \WPFORMS_PLUGIN_URL . "lite/assets/js/admin/settings-education{$min}.js", array( 'jquery', 'jquery-confirm' ), \WPFORMS_VERSION, false ); } /** * Display providers. * * @since 1.5.5 */ public function providers() { $providers = wpforms_get_providers_all(); foreach ( $providers as $provider ) { /* translators: %s - addon name*/ $modal_name = sprintf( \__( '%s addon', 'wpforms' ), $provider['name'] ); /* translators: %s - addon name*/ $descr = sprintf( \__( 'Integrate %s with WPForms', 'wpforms' ), $provider['name'] ); printf( '<div id="wpforms-integration-%1$s" class="wpforms-settings-provider wpforms-clear focus-out education-modal" data-name="%2$s" data-action="upgrade" data-url="%3$s" data-license="%4$s"> <div class="wpforms-settings-provider-header wpforms-clear"> <div class="wpforms-settings-provider-logo "> <i class="fa fa-chevron-right"></i> %5$s </div> <div class="wpforms-settings-provider-info"> <h3>%6$s</h3> <p>%7$s</p> </div> </div> </div>', \esc_attr( $provider['slug'] ), \esc_attr( $modal_name ), isset( $provider['url'] ) ? \esc_attr( $provider['url'] ) : '', \esc_attr( $provider['license'] ), '<img src="' . \esc_attr( WPFORMS_PLUGIN_URL ) . 'assets/images/' . \esc_attr( $provider['img'] ) . '">', \esc_html( $provider['name'] ), \esc_html( $descr ) ); } } } Admin/Settings/Access.php 0000666 00000014242 15214133076 0011317 0 ustar 00 <?php namespace WPForms\Lite\Admin\Settings; /** * Settings Access tab. * * @since 1.5.8 */ class Access { /** * View slug. * * @since 1.5.8 * * @var string */ const SLUG = 'access'; /** * Constructor. * * @since 1.5.8 */ public function __construct() { $this->hooks(); } /** * Hooks. * * @since 1.5.8 */ public function hooks() { add_action( 'admin_enqueue_scripts', array( $this, 'enqueues' ) ); add_filter( 'wpforms_settings_tabs', array( $this, 'add_tab' ) ); add_filter( 'wpforms_settings_defaults', array( $this, 'add_section' ) ); } /** * Enqueues. * * @since 1.5.8 */ public function enqueues() { if ( ! wpforms_is_admin_page( 'settings', self::SLUG ) ) { return; } // Lity. wp_enqueue_style( 'wpforms-lity', WPFORMS_PLUGIN_URL . 'assets/css/lity.min.css', null, '3.0.0' ); wp_enqueue_script( 'wpforms-lity', WPFORMS_PLUGIN_URL . 'assets/js/lity.min.js', array( 'jquery' ), '3.0.0', true ); } /** * Add Access tab. * * @since 1.5.8 * * @param array $tabs Array of tabs. * * @return array Array of tabs. */ public function add_tab( $tabs ) { $tab = array( self::SLUG => array( 'name' => esc_html__( 'Access', 'wpforms-lite' ), 'form' => false, 'submit' => false, ), ); return wpforms_list_insert_after( $tabs, 'integrations', $tab ); } /** * Add Access settings section. * * @since 1.5.8 * * @param array $settings Settings sections. * * @return array */ public function add_section( $settings ) { $section_rows = array( 'heading', 'screenshots', 'caps', 'upgrade_to_pro', ); foreach ( $section_rows as $section_row ) { $settings[ self::SLUG ][ self::SLUG . '-' . $section_row ] = array( 'id' => self::SLUG . '-' . $section_row, 'content' => method_exists( $this, 'output_section_row_' . $section_row ) ? $this->{ 'output_section_row_' . $section_row }() : '', 'type' => 'content', 'no_label' => true, 'class' => array( $section_row ), ); } return $settings; } /** * Generate and output section "Heading" row HTML. * * @since 1.5.8 */ public function output_section_row_heading() { return sprintf( '<h4>%1$s<img src="%2$s" alt="%3$s"></h4><p>%4$s</p><p>%5$s</p>', esc_html__( 'Access Controls', 'wpforms-lite' ), esc_url( WPFORMS_PLUGIN_URL . 'assets/images/lite-settings-access/pro-plus.svg' ), esc_attr__( 'Pro+', 'wpforms-lite' ), esc_html__( 'Access controls allows you to manage and customize access to WPForms functionality.', 'wpforms-lite' ), esc_html__( 'You can easily grant or restrict access using the simple built-in controls, or use our official integrations with Members and User Role Editor plugins.', 'wpforms-lite' ) ); } /** * Generate and output section "Screenshots" row HTML. * * @since 1.5.8 */ public function output_section_row_screenshots() { $format = '<div class="cont"> <img src="%1$s" srcset="%2$s 2x" alt="%6$s"/> <a href="%3$s" class="hover" data-lity data-lity-srcset="%4$s 2x" data-lity-desc="%6$s"></a> <span>%5$s</span> </div>'; $images_url = WPFORMS_PLUGIN_URL . 'assets/images/lite-settings-access/'; $content = sprintf( $format, esc_url( $images_url . 'thumbnail-access-controls.png' ), esc_url( $images_url . 'thumbnail-access-controls@2x.png' ), esc_url( $images_url . 'screenshot-access-controls.png' ), esc_url( $images_url . 'screenshot-access-controls@2x.png' ), esc_html__( 'Simple Built-in Controls', 'wpforms-lite' ), esc_attr( esc_html__( 'Simple Built-in Controls', 'wpforms-lite' ) ) ); $content .= sprintf( $format, esc_url( $images_url . 'thumbnail-members.png' ), esc_url( $images_url . 'thumbnail-members@2x.png' ), esc_url( $images_url . 'screenshot-members.png' ), esc_url( $images_url . 'screenshot-members@2x.png' ), esc_html__( 'Members Integration', 'wpforms-lite' ), esc_attr( esc_html__( 'Members Integration', 'wpforms-lite' ) ) ); $content .= sprintf( $format, esc_url( $images_url . 'thumbnail-user-role-editor.png' ), esc_url( $images_url . 'thumbnail-user-role-editor@2x.png' ), esc_url( $images_url . 'screenshot-user-role-editor.png' ), esc_url( $images_url . 'screenshot-user-role-editor@2x.png' ), esc_html__( 'User Role Editor Integration', 'wpforms-lite' ), esc_attr( esc_html__( 'User Role Editor Integration', 'wpforms-lite' ) ) ); return $content; } /** * Generate and output section "Capabilities" row HTML. * * @since 1.5.8 */ public function output_section_row_caps() { $caps = array( array( esc_html__( 'Create Forms', 'wpforms-lite' ), esc_html__( 'Edit Forms', 'wpforms-lite' ), esc_html__( 'Edit Others Forms', 'wpforms-lite' ), esc_html__( 'View Forms', 'wpforms-lite' ), esc_html__( 'View Others Forms', 'wpforms-lite' ), ), array( esc_html__( 'Delete Forms', 'wpforms-lite' ), esc_html__( 'Delete Others Forms', 'wpforms-lite' ), esc_html__( 'View Forms Entries', 'wpforms-lite' ), esc_html__( 'View Others Forms Entries', 'wpforms-lite' ), ), array( esc_html__( 'Edit Forms Entries', 'wpforms-lite' ), esc_html__( 'Edit Others Forms Entries', 'wpforms-lite' ), esc_html__( 'Delete Forms Entries', 'wpforms-lite' ), esc_html__( 'Delete Others Forms Entries', 'wpforms-lite' ), ), ); $content = '<p>' . esc_html__( 'Custom access to the following capabilities…', 'wpforms-lite' ) . '</p>'; foreach ( $caps as $column ) { $content .= '<ul>'; foreach ( $column as $cap ) { $content .= '<li>' . $cap . '</li>'; } $content .= '</ul>'; } return $content; } /** * Generate and output section "Upgrade to Pro" row HTML. * * @since 1.5.8 */ public function output_section_row_upgrade_to_pro() { $content = sprintf( '<a href="%1$s" target="_blank" rel="noopener noreferrer" class="wpforms-upgrade-modal wpforms-btn wpforms-btn-lg wpforms-btn-orange">%2$s</a>', esc_url( 'https://wpforms.com/lite-upgrade/?discount=LITEUPGRADE&utm_source=WordPress&utm_medium=settings-license&utm_campaign=liteplugin' ), esc_html__( 'Upgrade to WPForms Now', 'wpforms-lite' ) ); return $content; } } Reports/EntriesCount.php 0000666 00000002124 15214133076 0011342 0 ustar 00 <?php namespace WPForms\Lite\Reports; /** * Generate form submissions reports. * * @since 1.5.4 */ class EntriesCount { /** * Constructor. * * @since 1.5.4 */ public function __construct() {} /** * Get entries count grouped by form. * Main point of entry to fetch form entry count data from DB. * Cache the result. * * @since 1.5.4 * * @return array */ public function get_by_form() { $forms = \wpforms()->form->get( '', array( 'fields' => 'ids' ) ); if ( empty( $forms ) || ! \is_array( $forms ) ) { return array(); } $result = array(); foreach ( $forms as $form_id ) { $count = \absint( \get_post_meta( $form_id, 'wpforms_entries_count', true ) ); if ( empty( $count ) ) { continue; } $result[ $form_id ] = array( 'form_id' => $form_id, 'count' => $count, 'title' => \get_the_title( $form_id ), ); } if ( ! empty( $result ) ) { // Sort forms by entries count (desc). \uasort( $result, function ( $a, $b ) { return ( $a['count'] > $b['count'] ) ? -1 : 1; } ); } return $result; } }
| ver. 1.4 |
Github
|
.
| PHP 7.0.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings