D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
everqlsh
/
www
/
wp-admin
/
user
/
577040
/
Filename :
abstracts.zip
back
Copy
PK nG}\_ß* * class-admin-import-mediator.phpnu �[��� <?php /** * Forminator Admin Import Mediator * * @package Forminator */ if ( ! defined( 'ABSPATH' ) ) { die(); } /** * Class Forminator_Admin_Module * * @since 1.7 */ abstract class Forminator_Import_Mediator { /** * Stored form data. * * @since 1.7 * @access public * @var array */ public $data = array(); /** * Insert form data * Override by child classes * * @param int $id Id. * * @since 1.7 * @return array Parsed form data */ public function import_form( $id ) { return array(); } /** * Replaces invalid tags with forminator tags * * @param string $mayhavetags Tag to replace. * @param array $tags Tags. * * @since 1.7 * @return string returns string with valid field tag format */ public function replace_invalid_tags( $mayhavetags, $tags = array() ) { if ( ! empty( $tags ) ) { $tags = array_merge( $tags, array( '{all_fields_table}' => '{all_fields}', '{referer}' => '{referer_url}', ) ); } $mayhavetags = strtr( $mayhavetags, $tags ); return $mayhavetags; } /** * Replace default tag * * @param string $tags Tag. * * @return string */ public function replace_default_tags( $tags ) { $value = ''; if ( ! empty( $tags ) ) { switch ( $tags ) { case 'user_login': $value = 'wp_user.login'; break; case 'user_email': $value = 'wp_user.email'; break; case 'user_first_name': $value = 'wp_user.first_name'; break; case 'user_last_name': $value = 'wp_user.last_name'; break; case 'user_display_name': $value = 'wp_user.display_name'; break; default: break; } } return $value; } /** * Default form fields * * @since 1.7 * * @return array */ public static function default_fields() { // todo: check if defaults are available. $fields = array( 'name', 'email', 'phone', 'address', 'url', 'website', 'checkbox', 'number', 'slider', 'textarea', 'text', 'select', 'radio', 'calculation', 'date', 'time', 'upload', 'section', 'hidden', 'html', 'postdata', 'pagination', 'stripe', 'stripe-ocs', 'currency', 'consent', 'gdprcheckbox', 'honeypot', 'captcha', 'rating', 'submit', ); return apply_filters( 'forminator_default_fields', $fields ); } /** * Return random number * * @since 1.7 * @return int random number */ public function random_wrapper_int() { // get all forms. $int = intval( (float) wp_rand() / (float) getrandmax() * 9999 ); return absint( $int ); } /** * Replaces cf7 tags with forminator tags * * @param string $type Field type. * * @since 1.7 * @return string returns string with valid field tag format */ public function get_thirdparty_field_type( $type ) { switch ( trim( $type ) ) { case 'firstname': case 'lastname': $type = 'name'; break; case 'textbox': case 'dynamichidden': $type = 'text'; break; case 'acceptance': $type = 'consent'; break; case 'honeypot': $type = 'honeypot'; break; case 'listradio': $type = 'radio'; break; case 'listselect': case 'listmultiselect': case 'multiselect': case 'multiple': case 'liststate': $type = 'select'; break; case 'listcheckbox': $type = 'checkbox'; break; case 'city': case 'listcountry': case 'zip': $type = 'address'; break; case 'textarea': case 'description': $type = 'textarea'; break; case 'tel': $type = 'phone'; break; case 'url': $type = 'url'; break; case 'page': $type = 'pagination'; break; case 'file': case 'fileupload': $type = 'upload'; break; case 'recaptcha': $type = 'captcha'; break; default: break; } if ( ! in_array( $type, self::default_fields(), true ) ) { $type = ''; } return $type; } /** * Tries the form import * * @param mixed $import_data Import data. * * @return array * @throws Exception Throws Exception. */ public function try_form_import( $import_data ) { try { if ( empty( $import_data ) || ! is_array( $import_data ) ) { throw new Exception( esc_html__( 'Oops, looks like we found an issue. Import text can not include whitespace or special characters.', 'forminator' ) ); } if ( ! isset( $import_data['type'] ) || 'form' !== $import_data['type'] ) { throw new Exception( esc_html__( 'Oops, wrong module type. You can only import a module of the same type that you\'re currently viewing.', 'forminator' ) ); } $import_data = $this->parse_import_data( $import_data ); $model = Forminator_Form_Model::create_from_import_data( $import_data ); if ( is_wp_error( $model ) ) { throw new Exception( $model->get_error_message() ); } if ( ! $model instanceof Forminator_Form_Model ) { throw new Exception( esc_html__( 'Failed to import form, please make sure import text is valid, and try again.', 'forminator' ) ); } $return_url = admin_url( 'admin.php?page=forminator-cform' ); return array( 'id' => $model->id, 'url' => $return_url, 'type' => 'success', ); } catch ( Exception $e ) { return array( 'message' => $e->getMessage(), 'type' => 'fail', ); } } /** * Parses form data structure * * @param array $data Form data. * * @since 1.7 * @return array Parsed form data */ public function parse_import_data( $data ) { $fields = array(); $form_data = array(); if ( empty( $data ) || ! is_array( $data ) || ! isset( $data['data']['fields'] ) ) { return; } foreach ( $data['data']['fields'] as $key => $value ) { $value['id'] = $value['element_id']; $fields[] = $value; } $form_data['data']['fields'] = $fields; $form_data['data']['settings'] = $data['data']['settings']; $form_data['name'] = $data['data']['settings']['formName']; $form_data['type'] = $data['type']; $form_data['status'] = $data['status']; $form_data['version'] = FORMINATOR_VERSION; return $form_data; } } PK nG}\�`<��7 �7 class-admin-view-page.phpnu �[��� <?php /** * Forminator Admin View Page * * @package Forminator */ if ( ! defined( 'ABSPATH' ) ) { die(); } /** * Class Forminator_View_Page * * @since 1.0 */ abstract class Forminator_Admin_View_Page extends Forminator_Admin_Page { /** * Current model * * @var object|bool */ protected $model = false; /** * Current form id * * @var int */ protected $form_id = 0; /** * Fields * * @var array */ protected $fields = array(); /** * Visible Fields * * @var array */ protected $visible_fields = array(); /** * Number of checked fields * * @var int */ protected $checked_fields = 0; /** * Number of total fields * * @var int */ protected $total_fields = 0; /** * Error message if avail * * @var string */ protected $error_message = ''; /** * Total Entries * * @var int */ protected $total_entries = 0; /** * Per page * * @var int */ protected $per_page = 10; /** * Page number * * @var int */ protected $page_number = 1; /** * Page num * * @var int */ protected $pagenum = 1; /** * Filters to be used * * [key=>value] * ['search'=>'search term'] * * @since 1.5.4 * @var array */ public $filters = array(); /** * Order to be used * * [key=>order] * ['entry_date' => 'ASC'] * * @since 1.5.4 * @var array */ public $order = array(); /** * Entries * * @var array */ protected $entries = array(); /** * Total filtered Entries * * @since 1.5.4 * @var int */ protected $filtered_total_entries = 0; /** * Flag fields is currently filtered * * @since 1.5.4 * @var bool */ public $fields_is_filtered = false; /** * Connected addons * * @var Forminator_Integration[] */ protected static $connected_addons = null; /** * Registered addons * * @var Forminator_Integration[] */ protected static $registered_addons = null; /** * Construct entries * * @noinspection PhpMissingParentConstructorInspection * * Construct Entries Renderer * * @since 1.0.5 * * @param string $folder Folder. */ protected function entries_construct( $folder ) { $this->folder = $folder; $this->before_render(); $this->trigger_before_render_action(); $this->add_page_hooks(); } /** * Get fields * * @since 1.0 * @return array */ public function get_fields() { return $this->fields; } /** * Visible fields * * @since 1.0 * @return array */ public function get_visible_fields() { return $this->visible_fields; } /** * Checked field option * * @since 1.0 * * @param string $slug - the field slug. * * @return string */ public function checked_field( $slug ) { if ( ! empty( $this->visible_fields ) && is_array( $this->visible_fields ) ) { if ( in_array( $slug, $this->visible_fields, true ) ) { return checked( $slug, $slug ); } else { return ''; } } return checked( $slug, $slug ); } /** * Get model name * * @since 1.0 * @return string */ public function get_model_name() { if ( $this->model ) { return $this->model->name; } return ''; } /** * Fields header * * @since 1.0 */ public function fields_header() { printf( /* Translators: 1. checked field, 2. total field. */ esc_html__( 'Showing %$1s of %$2s fields', 'forminator' ), esc_html( $this->checked_fields ), esc_html( $this->total_fields ) ); } /** * The total entries * * @since 1.0 * @return int */ public function total_entries() { return $this->total_entries; } /** * The total filtered entries * * @since 1.5.4 * @return int */ public function filtered_total_entries() { return $this->filtered_total_entries; } /** * Get Entries * * @since 1.0 * @return array */ public function get_entries() { return $this->entries; } /** * Get Page Number * * @since 1.0 * @return int */ public function get_page_number() { return $this->page_number; } /** * Get Per Page * * @since 1.0 * @return int */ public function get_per_page() { return $this->per_page; } /** * Pagination * * @since 1.0 */ public function paginate() { $count = $this->filtered_total_entries; echo '<span class="sui-pagination-results">' . /* translators: %s is count. */ esc_html( sprintf( _n( '%s result', '%s results', $count, 'forminator' ), $count ) ) . '</span>'; forminator_list_pagination( $count, 'entries' ); } /** * Bulk actions * * @since 1.0 * * @param string $position Position. * @param bool $is_registration For registration?. */ public function bulk_actions( $position = 'top', $is_registration = false ) { ?> <select name="<?php echo ( 'top' === $position ) ? 'entries-action' : 'entries-action-bottom'; ?>" class="sui-select sui-select-sm sui-select-inline" data-width="200px" data-placeholder="<?php esc_html_e( 'Bulk Actions', 'forminator' ); ?>" aria-label="<?php esc_attr_e( 'Bulk Actions', 'forminator' ); ?>" > <option></option> <?php if ( $is_registration ) { ?> <option value="approve-users"><?php esc_html_e( 'Approve Users', 'forminator' ); ?></option> <?php } ?> <option value="delete-all"><?php esc_html_e( 'Delete Entries', 'forminator' ); ?></option> </select> <button class="sui-button"><?php esc_html_e( 'Apply', 'forminator' ); ?></button> <?php } /** * Prepare results * * @since 1.0 */ public function prepare_results() { if ( is_object( $this->model ) ) { $paged = $this->page_number; $per_page = $this->per_page; $offset = ( $paged - 1 ) * $per_page; $this->total_entries = Forminator_Form_Entry_Model::count_entries( $this->model->id, false, true ); $args = array( 'form_id' => $this->model->id, 'is_spam' => 0, 'per_page' => $per_page, 'offset' => $offset, 'order_by' => 'entries.date_created', 'order' => 'DESC', ); $args = wp_parse_args( $this->filters, $args ); $args = wp_parse_args( $this->order, $args ); $result = Forminator_Form_Entry_Model::query_entries( $args, true ); $this->entries = ! empty( $result['data'] ) ? $result['data'] : array(); $this->filtered_total_entries = ! empty( $result['count'] ) ? $result['count'] : 0; } } /** * Called when page is loaded and content not rendered yet * * @since 1.0 */ public function before_render() { $this->model = Forminator_Base_Form_Model::get_model( $this->form_id ); if ( is_object( $this->model ) ) { $this->fields = $this->model->get_fields(); if ( is_null( $this->fields ) ) { $this->fields = array(); } } else { $this->model = false; } $this->pagenum = absint( Forminator_Core::sanitize_text_field( 'paged' ) ); $this->parse_filters(); $this->parse_order(); $this->per_page = forminator_form_view_per_page( 'entries' ); $this->page_number = max( 1, $this->pagenum ); $this->total_fields = count( $this->fields ); $this->checked_fields = $this->total_fields; } /** * Parsing filters * * @since 1.5.4 */ protected function parse_filters() { $data_range = Forminator_Core::sanitize_text_field( 'date_range' ); $user_status = Forminator_Core::sanitize_text_field( 'user_status' ); $search = Forminator_Core::sanitize_text_field( 'search' ); $min_id = Forminator_Core::sanitize_text_field( 'min_id' ); $max_id = Forminator_Core::sanitize_text_field( 'max_id' ); $entry_status = Forminator_Core::sanitize_text_field( 'entry_status' ); $filters = array(); if ( ! empty( $data_range ) ) { $date_ranges = explode( ' - ', $data_range ); if ( is_array( $date_ranges ) && isset( $date_ranges[0] ) && isset( $date_ranges[1] ) ) { $date_ranges[0] = gmdate( 'Y-m-d', strtotime( $date_ranges[0] ) ); $date_ranges[1] = gmdate( 'Y-m-d', strtotime( $date_ranges[1] ) ); forminator_maybe_log( __METHOD__, $date_ranges ); $filters['date_created'] = array( $date_ranges[0], $date_ranges[1] ); } } if ( ! empty( $search ) ) { $filters['search'] = $search; } if ( $user_status ) { $filters['user_status'] = $user_status; } if ( ! empty( $min_id ) ) { $min_id = intval( $min_id ); if ( $min_id > 0 ) { $filters['min_id'] = $min_id; } } if ( ! empty( $max_id ) ) { $max_id = intval( $max_id ); if ( $max_id > 0 ) { $filters['max_id'] = $max_id; } } if ( $entry_status ) { $filters['entry_status'] = $entry_status; } $this->filters = $filters; } /** * Parsing order * * @since 1.5.4 */ protected function parse_order() { $valid_order_bys = array( 'entries.date_created', 'entries.entry_id', ); $valid_orders = array( 'DESC', 'ASC', ); $order_by = Forminator_Core::sanitize_text_field( 'order_by' ); if ( ! in_array( $order_by, $valid_order_bys, true ) ) { $order_by = 'entries.date_created'; } $this->order['order_by'] = $order_by; $order = strtoupper( Forminator_Core::sanitize_text_field( 'order' ) ); if ( ! in_array( $order, $valid_orders, true ) ) { $order = 'DESC'; } $this->order['order'] = $order; } /** * Executor of adding additional items on entry page * * @see self::on_render_entry() * @since 1.1 * * @param Forminator_Form_Entry_Model $entry_model Form entry model. * * @return array */ protected function attach_addon_on_render_entry( Forminator_Form_Entry_Model $entry_model ) { $additional_items = array(); // find all registered addons, so history can be shown even for deactivated addons. $registered_addons = $this->get_registered_addons(); foreach ( $registered_addons as $registered_addon ) { try { $hooks = $registered_addon->get_addon_hooks( $this->form_id, static::$module_slug ); $meta_data = forminator_find_addon_meta_data_from_entry_model( $registered_addon, $entry_model ); $addon_additional_items = $hooks->on_render_entry( $entry_model, $meta_data );// run and forget. $addon_additional_items = static::format_addon_additional_items( $addon_additional_items ); $additional_items = array_merge( $additional_items, $addon_additional_items ); } catch ( Exception $e ) { forminator_addon_maybe_log( $registered_addon->get_slug(), 'failed to on_render_entry', $e->getMessage() ); } } return $additional_items; } /** * Flag whether box filter opened or nope * * @since 1.5.4 * @return bool */ protected function is_filter_box_enabled() { $order = Forminator_Core::sanitize_text_field( 'order' ); $order_by = Forminator_Core::sanitize_text_field( 'order_by' ); return ( ! empty( $this->filters ) || ( ! empty( $order ) && ! empty( $order_by ) ) ); } /** * Get current error message * * @return string * * @since 1.5.2 */ public function error_message() { return $this->error_message; } /** * Get Globally registered Addons, avoid overhead for checking registered addons many times * * @return array|Forminator_Integration[] */ public function get_registered_addons() { if ( empty( self::$registered_addons ) ) { self::$registered_addons = array(); $registered_addons = forminator_get_registered_addons(); $class_name = 'Forminator_Integration_' . static::$module_slug . '_Hooks'; foreach ( $registered_addons as $registered_addon ) { try { $hooks = $registered_addon->get_addon_hooks( $this->form_id, static::$module_slug ); if ( $hooks instanceof $class_name ) { self::$registered_addons[] = $registered_addon; } } catch ( Exception $e ) { forminator_addon_maybe_log( $registered_addon->get_slug(), 'failed to get_addon_hooks', $e->getMessage() ); } } } return self::$registered_addons; } /** * Process request * * @since 1.0 */ public function process_request() { if ( isset( $_GET['err_msg'] ) ) { $this->error_message = wp_kses_post( wp_unslash( $_GET['err_msg'] ) ); } // it should be before nonce check cus we use filter on Submissions page without nonce :facepalm:. if ( isset( $_GET['field'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput -- Sanitized in Forminator_Core::sanitize_array. $this->visible_fields = Forminator_Core::sanitize_array( $_GET['field'] ); $this->checked_fields = count( $this->visible_fields ); $this->fields_is_filtered = true; } $action = Forminator_Core::sanitize_text_field( 'entries-action' ); if ( ! $action ) { $action = Forminator_Core::sanitize_text_field( 'entries-action-bottom' ); } $nonce = Forminator_Core::sanitize_text_field( 'forminatorEntryNonce' ); /** * Start modifying data */ if ( ! $nonce || ! wp_verify_nonce( $nonce, 'forminator' . forminator_get_prefix( static::$module_slug, '', true ) . 'Entries' ) ) { return; } switch ( $action ) { case 'approve-users': $this->approve_users(); break; case 'delete-all': $this->delete_all_action(); break; default: break; } $forminator_action = Forminator_Core::sanitize_text_field( 'forminator_action' ); switch ( $forminator_action ) { case 'delete': $id = filter_input( INPUT_POST, 'id', FILTER_VALIDATE_INT ); if ( $id ) { $this->delete_action( $id ); $this->maybe_redirect_to_referer(); exit; } break; default: break; } } /** * Action delete * * @param int $id ID. */ public function delete_action( $id ) { Forminator_Form_Entry_Model::delete_by_entrys( $this->model->id, $id ); } /** * This view is unused from 1.5.4 on, using "forminator-entries" instead. */ protected function maybe_redirect() { if ( 'forminator-' . forminator_get_prefix( static::$module_slug, 'c' ) . '-view' === $this->page_slug ) { $form_type = forminator_get_prefix( static::$module_slug, 'post_type' ); $url = '?page=forminator-entries&form_type=' . $form_type; $form_id = (int) Forminator_Core::sanitize_text_field( 'form_id' ); if ( $form_id ) { $url .= '&form_id=' . $form_id; } if ( wp_safe_redirect( $url ) ) { exit; } } } } PK nG}\l���- �- class-admin-module.phpnu �[��� <?php /** * Forminator Admin Module * * @package Forminator */ if ( ! defined( 'ABSPATH' ) ) { die(); } /** * Class Forminator_Admin_Module * * @since 1.0 */ abstract class Forminator_Admin_Module { /** * Pages * * @var array */ public $pages = array(); /** * Page * * @var string */ public $page = ''; /** * Edit page * * @var string */ public $page_edit = ''; /** * Page entries * * @var string */ public $page_entries = ''; /** * Directory * * @var string */ public $dir = ''; /** * Forminator_Admin_Module constructor. * * @since 1.0 */ public function __construct() { $this->init(); $this->includes(); add_action( 'admin_menu', array( $this, 'add_menu_pages' ) ); add_action( 'admin_head', array( $this, 'hide_menu_pages' ) ); add_action( 'wp_loaded', array( $this, 'create_module' ) ); // admin-menu-editor compat. add_action( 'admin_menu_editor-menu_replaced', array( $this, 'hide_menu_pages' ) ); add_filter( 'forminator_data', array( $this, 'add_js_defaults' ) ); add_filter( 'forminator_l10n', array( $this, 'add_l10n_strings' ) ); add_filter( 'submenu_file', array( $this, 'admin_submenu_file' ), 10, 2 ); } /** * Init * * @since 1.0 */ public function init() { // Call init instead of __construct in modules. } /** * Attach admin pages * * @since 1.0 */ public function add_menu_pages() {} /** * Create module * * @since 1.0 */ public function create_module() {} /** * Hide pages from menu * * @since 1.0 */ public function hide_menu_pages() { remove_submenu_page( 'forminator', $this->page_edit ); remove_submenu_page( 'forminator', $this->page_entries ); echo '<style> #toplevel_page_forminator ul.wp-submenu li a[href="admin.php?page=forminator-addons"] { color: #1ABC9C !important; } #toplevel_page_forminator ul.wp-submenu li a[href="admin.php?page=forminator-templates"] { display: flex; justify-content: space-between; align-items: center; } #toplevel_page_forminator ul.wp-submenu li a[href="admin.php?page=forminator-templates"] .menu-new-tag { font-size: 8px; line-height: 8px; padding: 2px 6px; background: #1ABC9C; border-radius: 9px; text-transform: uppercase; color: #fff; font-weight: 900; height: 100%; letter-spacing: -0.25px; } </style>'; if ( ! FORMINATOR_PRO ) { echo '<style>#toplevel_page_forminator ul.wp-submenu li:last-child a[href^="https://wpmudev.com"] { background-color: #8d00b1 !important; color: #fff !important; font-weight: 500 !important; letter-spacing: -0.2px; }</style>'; echo '<script>jQuery(function() {jQuery(\'#toplevel_page_forminator ul.wp-submenu li:last-child a[href^="https://wpmudev.com"]\').attr("target", "_blank");});</script>'; } } /** * Used to include files * * @since 1.0 */ public function includes() { include_once $this->dir . '/admin-page-new.php'; include_once $this->dir . '/admin-page-view.php'; include_once $this->dir . '/admin-page-entries.php'; include_once $this->dir . '/admin-renderer-entries.php'; } /** * Inject module options to JS * * @since 1.0 * @param mixed $data Data. * @return mixed */ public function add_js_defaults( $data ) { return $data; } /** * Inject l10n strings to JS * * @param mixed $strings Strings. * @since 1.0 * @return mixed */ public function add_l10n_strings( $strings ) { return $strings; } /** * Is the admin page being viewed in edit mode * * @since 1.0 * @return mixed */ public static function is_edit() { return filter_input( INPUT_GET, 'id', FILTER_VALIDATE_INT ) || filter_input( INPUT_POST, 'id', FILTER_VALIDATE_INT ); } /** * Is the module admin dashboard page * * @since 1.0 * @return bool */ public function is_admin_home() { global $plugin_page; return $this->page === $plugin_page; } /** * Is the module admin new/edit page * * @since 1.0 * @return bool */ public function is_admin_wizard() { global $plugin_page; // $plugin_page may not be set if we call the function too early, retrieve the page slug from GET. $page = Forminator_Core::sanitize_text_field( 'page' ); if ( empty( $plugin_page ) ) { return $this->page_edit === $page; } return $this->page_edit === $plugin_page; } /** * Highlight parent page in sidebar * * @deprecated 1.1 No longer used because this function override prohibited WordPress global of $plugin_page * @since 1.0 * * @param mixed $file File. * * @return mixed */ public function highlight_admin_parent( $file ) { _deprecated_function( __METHOD__, '1.1', null ); return $file; } /** * Prepare settings * * @param array $original_settings Sent settings. * @return array */ protected static function validate_settings( $original_settings ) { // Sanitize settings. $settings = forminator_sanitize_array_field( $original_settings ); // Sanitize custom css. if ( isset( $original_settings['custom_css'] ) ) { $settings['custom_css'] = sanitize_textarea_field( $original_settings['custom_css'] ); } // Sanitize admin email message. if ( isset( $original_settings['admin-email-editor'] ) ) { $settings['admin-email-editor'] = wp_kses_post( $original_settings['admin-email-editor'] ); } // Sanitize quiz description. if ( isset( $original_settings['quiz_description'] ) ) { $settings['quiz_description'] = wp_kses_post( $original_settings['quiz_description'] ); } if ( isset( $original_settings['social-share-message'] ) ) { $settings['social-share-message'] = forminator_sanitize_textarea( $original_settings['social-share-message'] ); } if ( isset( $original_settings['msg_count'] ) ) { // Backup, we allow html here. $settings['msg_count'] = wp_kses_post( $original_settings['msg_count'] ); } $settings = apply_filters( 'forminator_builder_data_settings_before_saving', $settings, $original_settings ); return $settings; } /** * Highlight submenu on admin page * * @since 1.1 * * @param string $submenu_file Submenu file. * @param string $parent_file Parent file. * * @return string */ public function admin_submenu_file( $submenu_file, $parent_file ) { global $plugin_page; if ( 'forminator' !== $parent_file ) { return $submenu_file; } if ( $this->page_edit === $plugin_page || $this->page_entries === $plugin_page ) { $submenu_file = $this->page; } return $submenu_file; } /** * Import Form * * @param string $json JSON data to import. * @param string $name Module name. * @param string $slug Module type. * @param bool $change_recipients Change recipients. * @param bool $draft Draft status. * @param array $extra_args extra arguments. * * @throws Exception When import failed. */ public static function import_json( string $json, string $name, string $slug, bool $change_recipients, bool $draft = false, array $extra_args = array() ) { $import_data = json_decode( $json, true ); if ( $import_data ) { array_walk_recursive( $import_data, function ( &$item ) { if ( isset( $item ) ) { $item = html_entity_decode( $item, ENT_QUOTES | ENT_HTML5, 'UTF-8' ); } } ); } $import_data = Forminator_Core::sanitize_array( $import_data ); if ( $change_recipients ) { $import_data = self::change_recipients( $import_data ); } // hook custom data here. $import_data = apply_filters( 'forminator_' . $slug . '_import_data', $import_data ); if ( empty( $import_data ) || ! is_array( $import_data ) ) { throw new Exception( esc_html__( 'Oops, looks like we found an issue. Import text can not include whitespace or special characters.', 'forminator' ) ); } if ( ! isset( $import_data['type'] ) || $slug !== $import_data['type'] ) { throw new Exception( esc_html__( 'Oops, wrong module type. You can only import a module of the same type that you\'re currently viewing.', 'forminator' ) ); } $class = 'Forminator_' . forminator_get_prefix( $slug, '', true ) . '_Model'; if ( $draft ) { $import_data['status'] = $class::STATUS_DRAFT; } if ( ! empty( $extra_args ) && isset( $import_data['data']['settings'] ) ) { $import_data['data']['settings'] = array_merge( $import_data['data']['settings'], $extra_args ); } if ( ! empty( $import_data['data']['settings'] ) ) { $validate = forminator_validate_registration_form_settings( $import_data['data']['settings'] ); if ( is_wp_error( $validate ) ) { // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped -- Exception message is already escaped. throw new Exception( $validate->get_error_message() ); } } $model = $class::create_from_import_data( $import_data, $name ); if ( is_wp_error( $model ) ) { throw new Exception( esc_html( $model->get_error_message() ) ); } if ( ! $model instanceof Forminator_Base_Form_Model ) { throw new Exception( esc_html__( 'Failed to import module, please make sure import text is valid, and try again.', 'forminator' ) ); } return $model; } /** * Change the recipients * * @since 1.18.0 * * @param mixed $data imported module data. * * @return array $data */ private static function change_recipients( $data ) { if ( ! empty( $data ) ) { $current_user_email = wp_get_current_user()->user_email; if ( 'poll' === $data['type'] ) { if ( ! empty( $data['data']['settings']['admin-email-recipients'] ) ) { $data['data']['settings']['admin-email-recipients'] = self::apply_user_email( $data['data']['settings']['admin-email-recipients'], $current_user_email ); } if ( ! empty( $data['data']['settings']['admin-email-cc-address'] ) ) { $data['data']['settings']['admin-email-cc-address'] = self::apply_user_email( $data['data']['settings']['admin-email-cc-address'], $current_user_email ); } if ( ! empty( $data['data']['settings']['admin-email-bcc-address'] ) ) { $data['data']['settings']['admin-email-bcc-address'] = self::apply_user_email( $data['data']['settings']['admin-email-bcc-address'], $current_user_email ); } } elseif ( ! empty( $data['data']['notifications'] ) ) { $email_fields_to_update = array( 'recipients', 'bcc-email', 'cc-email', ); foreach ( $data['data']['notifications'] as $notif_key => $notif ) { foreach ( $email_fields_to_update as $key ) { if ( ! empty( $notif[ $key ] ) ) { $data['data']['notifications'][ $notif_key ][ $key ] = self::apply_user_email( $notif[ $key ], $current_user_email ); } } // Modify the routing recipients. if ( ! empty( $notif['routing'] ) ) { foreach ( $notif['routing'] as $routing_key => $route ) { if ( ! empty( $route['email'] ) ) { $route_emails = self::apply_user_email( $route['email'], $current_user_email ); $data['data']['notifications'][ $notif_key ]['routing'][ $routing_key ]['email'] = $route_emails; } } } } } } return $data; } /** * Apply user emails * * @since 1.18.0 * * @param string $data Email recipients. * @param string $current_user_email User email. * * @return array */ private static function apply_user_email( $data, $current_user_email ) { $recipients = ! is_array( $data ) ? explode( ',', $data ) : $data; foreach ( $recipients as $key => $recipient ) { $recipient = trim( $recipient ); // Will not change recipients that use field tags like {email-1}. if ( false === strpos( $recipient, '{' ) ) { $recipients[ $key ] = $current_user_email; } } $recipients = array_unique( $recipients ); return ! is_array( $data ) ? implode( ',', $recipients ) : $recipients; } } PK nG}\:t�8ţ ţ class-admin-module-edit-page.phpnu �[��� <?php /** * Forminator Admin Module Edit Page * * @package Forminator */ if ( ! defined( 'ABSPATH' ) ) { die(); } /** * Class Forminator_Admin_Module_Edit_Page * * @since 1.14.10 */ abstract class Forminator_Admin_Module_Edit_Page extends Forminator_Admin_Page { /** * Page number * * @var int */ protected static $page_number = 1; /** * Initialize * * @since 1.0 */ public function init() { $pagenum = absint( Forminator_Core::sanitize_text_field( 'paged' ) ); self::$page_number = max( 1, $pagenum ); $this->processRequest(); } /** * Trigger before render */ public function before_render() { wp_enqueue_script( 'forminator-chart', forminator_plugin_url() . 'assets/js/library/Chart.bundle.min.js', array( 'jquery' ), '2.9.4', false ); } /** * Count modules * * @param string $status Modules status. * @since 1.0 * @return int */ public function countModules( $status = '' ) { $class_name = 'Forminator_' . forminator_get_prefix( static::$module_slug, '', true ) . '_Model'; return $class_name::model()->count_all( $status ); } /** * Get modules * * @since 1.0 * @return array */ public function getModules() { $modules = array(); $limit = null; $const = 'FORMINATOR_' . strtoupper( static::$module_slug ) . '_LIST_LIMIT'; if ( defined( $const ) && constant( $const ) ) { $limit = constant( $const ); } $data = self::get_models( $limit ); $form_view = Forminator_Form_Views_Model::get_instance(); // Fallback. if ( ! isset( $data['models'] ) || empty( $data['models'] ) ) { return $modules; } foreach ( $data['models'] as $model ) { $form_name = $model->name; if ( isset( $model->settings['formName'] ) && ! empty( $model->settings['formName'] ) ) { $form_name = $model->settings['formName']; } $modules[] = static::module_array( $model->id, $form_name, $form_view->count_views( $model->id ), gmdate( get_option( 'date_format' ), strtotime( $model->raw->post_date ) ), $model->status, $model ); } return $modules; } /** * Get modules for search * * @param null|string $search_keyword Search Keyword. * * @since 1.14.12 * @return array */ public static function get_searched_modules( $search_keyword = null ) { $modules = array(); $data = self::get_models( -1 ); // Fallback. if ( ! isset( $data['models'] ) || empty( $data['models'] ) ) { return $modules; } // Search. if ( ! is_null( $search_keyword ) ) { $search_keyword = explode( ' ', $search_keyword ); $form_view = Forminator_Form_Views_Model::get_instance(); $module_slug = self::get_slug_ajax( true ); $class_name = 'Forminator_' . $module_slug . '_Page'; foreach ( $data['models'] as $model ) { foreach ( $search_keyword as $keyword ) { // If found. if ( false !== stripos( $model->settings['formName'], $keyword ) ) { $modules[] = $class_name::module_array( $model->id, $model->settings['formName'], $form_view->count_views( $model->id ), gmdate( get_option( 'date_format' ), strtotime( $model->raw->post_date ) ), $model->status, $model ); // prevent duplicates. break; } } } } return $modules; } /** * Get slug for ajax search * * @param string|bool $slug Module slug. * * @since 1.14.12 * @return array */ public static function get_slug_ajax( $slug = false ) { $page = Forminator_Core::sanitize_text_field( 'page' ); if ( ! $page ) { return ''; } switch ( $page ) { case 'forminator-poll': $module_slug = $slug ? 'Poll' : 'poll'; break; case 'forminator-quiz': $module_slug = $slug ? 'Quiz' : 'quiz'; break; default: $module_slug = $slug ? 'CForm' : 'form'; break; } return $module_slug; } /** * Has error on payment field * * @param mixed $module Module. * @param bool $is_stripe_connected Is stripe connected. * @return bool */ public static function has_payment_field_error( $module, $is_stripe_connected ) { if ( ! empty( $module['model'] ) && method_exists( $module['model'], 'has_stripe_field' ) ) { $stripe_field = $module['model']->has_stripe_field(); if ( ! empty( $stripe_field ) ) { if ( false === $is_stripe_connected ) { return true; } $stripe_field->mode; $plan_id_key = 'live' === $stripe_field->mode ? 'live_plan_id' : 'test_plan_id'; foreach ( $stripe_field->payments as $plan ) { if ( 'subscription' === $plan['payment_method'] && empty( $plan[ $plan_id_key ] ) ) { return true; } } } } if ( ! empty( $module['model'] ) && method_exists( $module['model'], 'has_paypal_field' ) ) { $paypal_field = $module['model']->has_paypal_field(); if ( ! empty( $paypal_field ) ) { if ( false === forminator_has_paypal_settings() ) { return true; } } } return false; } /** * Show the modules * * @param array $modules Modules. * @param string $module_slug Module slug. * @param string $preview_dialog Preview dialog. * @param string $preview_title Preview title. * @param string $export_dialog Export dialog. * @param string $post_type Post type. * @param string $soon Soon. * @param string $sql_month_start_date Start date. * @param string $wizard_page Wizard page. * @param string $search_keyword Search Keyword. * * @since 1.14.12 * @return mixed */ public static function show_modules( $modules, $module_slug, $preview_dialog, $preview_title, $export_dialog, $post_type, $soon, $sql_month_start_date, $wizard_page, $search_keyword = null ) { if ( empty( $modules ) ) { $is_search = true; require_once forminator_plugin_dir() . 'admin/views/common/list/empty_content.php'; } $is_stripe_connected = false; $page = $module_slug; if ( 'form' === $page ) { $page = 'cform'; $is_stripe_connected = forminator_has_stripe_connected(); } foreach ( $modules as $module ) { $module_entries_from_last_month = 0 !== $module['entries'] ? count( Forminator_Form_Entry_Model::get_newer_entry_ids_of_form_id( $module['id'], $sql_month_start_date ) ) : 0; $opened_class = ''; $opened_chart = ''; $has_leads = isset( $module['has_leads'] ) ? $module['has_leads'] : false; $leads_id = isset( $module['leads_id'] ) ? $module['leads_id'] : 0; if ( ! is_null( $wizard_page ) && ! isset( $module['type'] ) ) { $edit_url = admin_url( 'admin.php?page=' . $wizard_page . '&id=' . $module['id'] ); } else { // For quizzes. $edit_url = admin_url( 'admin.php?page=forminator-' . ( 'nowrong' === $module['type'] ? $module['type'] : 'knowledge' ) . '-wizard&id=' . $module['id'] ); } $view_stats = filter_input( INPUT_GET, 'view-stats', FILTER_VALIDATE_INT ); if ( $view_stats && intval( $module['id'] ) === $view_stats ) { $opened_class = ' sui-accordion-item--open forminator-scroll-to'; $opened_chart = ' sui-chartjs-loaded'; } $display_warning_icon = self::has_payment_field_error( $module, $is_stripe_connected ); if ( true === $display_warning_icon ) { $opened_class .= ' forminator-notice-yellow'; } ?> <div class="sui-accordion-item<?php echo esc_attr( $opened_class ); ?>"> <div class="sui-accordion-item-header"> <div class="sui-accordion-item-title sui-trim-title"> <label for="wpf-module-<?php echo esc_attr( $module['id'] ); ?>" class="sui-checkbox sui-accordion-item-action"> <input type="checkbox" id="wpf-module-<?php echo esc_attr( $module['id'] ); ?>" value="<?php echo esc_html( $module['id'] ); ?>"> <span aria-hidden="true"></span> <span class="sui-screen-reader-text"><?php esc_html_e( 'Select this module', 'forminator' ); ?></span> </label> <?php if ( true === $display_warning_icon ) { ?> <span class="sui-notice-icon sui-icon-info forminator-accordion-notice-icon" aria-hidden="true"></span> <?php } ?> <span class="sui-trim-text"><?php echo esc_html( htmlspecialchars( forminator_get_form_name( $module['id'] ) ) ); ?></span> <?php if ( 'publish' === $module['status'] ) { echo '<span class="sui-tag sui-tag-blue">' . esc_html__( 'Published', 'forminator' ) . '</span>'; } ?> <?php if ( 'draft' === $module['status'] ) { echo '<span class="sui-tag">' . esc_html__( 'Draft', 'forminator' ) . '</span>'; } ?> </div> <div class="sui-accordion-item-date"><strong><?php esc_html_e( 'Last Submission', 'forminator' ); ?></strong> <?php echo esc_html( $module['last_entry_time'] ); ?></div> <div class="sui-accordion-col-auto"> <a href="<?php echo esc_url( $edit_url ); ?>" class="sui-button sui-button-ghost sui-accordion-item-action sui-desktop-visible"> <i class="sui-icon-pencil" aria-hidden="true"></i> <?php esc_html_e( 'Edit', 'forminator' ); ?> </a> <a href="<?php echo esc_url( $edit_url ); ?>" class="sui-button-icon sui-accordion-item-action sui-mobile-visible"> <i class="sui-icon-pencil" aria-hidden="true"></i> <span class="sui-screen-reader-text"><?php esc_html_e( 'Edit', 'forminator' ); ?></span> </a> <div class="sui-dropdown sui-accordion-item-action<?php echo $soon ? ' fui-dropdown-soon' : ''; ?>"> <button class="sui-button-icon sui-dropdown-anchor"> <i class="sui-icon-widget-settings-config" aria-hidden="true"></i> <span class="sui-screen-reader-text"><?php esc_html_e( 'Open list settings', 'forminator' ); ?></span> </button> <ul class="module-actions"> <li><a href="#" class="wpmudev-open-modal" data-modal="<?php echo esc_attr( $preview_dialog ); ?>" data-modal-title="<?php /* translators: 1. Review title, 2. Form name. */ printf( esc_attr__( '%1$s - %2$s', 'forminator' ), esc_html( $preview_title ), esc_attr( htmlspecialchars( forminator_get_form_name( $module['id'] ) ) ) ); ?>" data-form-id="<?php echo esc_attr( $module['id'] ); ?>" data-has-leads="<?php echo esc_attr( $has_leads ); ?>" data-leads-id="<?php echo esc_attr( $leads_id ); ?>" data-nonce-preview="<?php echo esc_attr( wp_create_nonce( 'forminator_load_module' ) ); ?>" data-nonce="<?php echo esc_attr( wp_create_nonce( 'forminator_popup_' . $preview_dialog ) ); ?>"> <i class="sui-icon-eye" aria-hidden="true"></i> <?php esc_html_e( 'Preview', 'forminator' ); ?> </a></li> <li> <button class="copy-clipboard" data-shortcode='[forminator_<?php echo esc_attr( $module_slug ); ?> id="<?php echo esc_attr( $module['id'] ); ?>"]'><i class="sui-icon-code" aria-hidden="true"></i> <?php esc_html_e( 'Copy Shortcode', 'forminator' ); ?></button> </li> <li> <form method="post"> <input type="hidden" name="forminator_action" value="update-status"> <input type="hidden" name="id" value="<?php echo esc_attr( $module['id'] ); ?>"/> <input type="hidden" name="msearch" value="" /> <?php if ( 'publish' === $module['status'] ) : ?> <input type="hidden" name="status" value="draft"/> <?php elseif ( 'draft' === $module['status'] ) : ?> <input type="hidden" name="status" value="publish"/> <?php endif; ?> <?php $update_status_nonce = esc_attr( 'forminator-nonce-update-status-' . $module['id'] ); wp_nonce_field( $update_status_nonce, $update_status_nonce, false ); ?> <input type="hidden" name="_wp_http_referer" value="<?php echo esc_url( admin_url( 'admin.php?page=forminator-' . $page ) ); ?>"> <button type="submit"> <?php if ( 'publish' === $module['status'] ) : ?> <i class="sui-icon-unpublish" aria-hidden="true"></i> <?php esc_html_e( 'Unpublish', 'forminator' ); ?> <?php elseif ( 'draft' === $module['status'] ) : ?> <i class="sui-icon-upload-cloud" aria-hidden="true"></i> <?php esc_html_e( 'Publish', 'forminator' ); ?> <?php endif; ?> </button> </form> </li> <li><a href="<?php echo esc_url( admin_url( 'admin.php?page=forminator-entries&form_type=' . $post_type . '&form_id=' . $module['id'] ) ); ?>"> <i class="sui-icon-community-people" aria-hidden="true"></i> <?php esc_html_e( 'View Submissions', 'forminator' ); ?> </a></li> <li <?php echo ( $has_leads ) ? 'aria-hidden="true"' : ''; ?>><form method="post"> <input type="hidden" name="forminator_action" value="clone"> <input type="hidden" name="id" value="<?php echo esc_attr( $module['id'] ); ?>"/> <input type="hidden" name="msearch" value="" /> <?php $clone_nonce = esc_attr( 'forminator-nonce-clone-' . $module['id'] ); wp_nonce_field( $clone_nonce, 'forminatorNonce' ); ?> <?php if ( $has_leads ) : ?> <button type="submit" disabled="disabled" class="fui-button-with-tag sui-tooltip sui-tooltip-left sui-constrained" data-tooltip="<?php esc_html_e( 'Duplicate isn\'t supported at the moment for the quizzes with lead capturing enabled.', 'forminator' ); ?>"> <span class="sui-icon-page-multiple" aria-hidden="true"></span> <span class="fui-button-label"><?php esc_html_e( 'Duplicate', 'forminator' ); ?></span> <span class="sui-tag sui-tag-blue sui-tag-sm"><?php echo esc_html__( 'Coming soon', 'forminator' ); ?></span> </button> <?php else : ?> <button type="submit"> <i class="sui-icon-page-multiple" aria-hidden="true"></i> <?php esc_html_e( 'Duplicate', 'forminator' ); ?> </button> <?php endif; ?> </form></li> <li> <button class="wpmudev-open-modal" data-modal="delete-module" data-modal-title="<?php esc_attr_e( 'Reset Tracking Data', 'forminator' ); ?>" data-modal-content="<?php /* translators: %s is the Module slug. */ printf( esc_attr__( 'This action will reset the views and conversions data for this %s. Are you sure you want to proceed?', 'forminator' ), esc_html__( $module_slug, 'forminator' ) ); /* phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText -- I18n is required. */ ?>" data-button-text="<?php esc_attr_e( 'Reset', 'forminator' ); ?>" data-form-id="<?php echo esc_attr( $module['id'] ); ?>" data-action="reset-views" data-nonce="<?php echo esc_attr( wp_create_nonce( 'forminator-nonce-reset-views-' . $module['id'] ) ); ?>" > <i class="sui-icon-update" aria-hidden="true"></i> <?php esc_html_e( 'Reset Tracking data', 'forminator' ); ?> </button> </li> <?php if ( 'form' === $module_slug ) { ?> <li> <button class="wpmudev-open-modal" data-modal="apply_preset" data-form-id="<?php echo esc_attr( $module['id'] ); ?>" > <i class="sui-icon-brush" aria-hidden="true"></i> <?php esc_html_e( 'Apply Preset', 'forminator' ); ?> </button> </li> <?php } ?> <?php if ( Forminator::is_import_export_feature_enabled() ) : ?> <?php if ( $has_leads ) : ?> <li aria-hidden="true"><a href="#" class="fui-button-with-tag sui-tooltip sui-tooltip-left" data-tooltip="<?php esc_html_e( 'Export isn\'t supported at the moment for the quizzes with lead capturing enabled.', 'forminator' ); ?>"> <span class="sui-icon-cloud-migration" aria-hidden="true"></span> <span class="fui-button-label"><?php esc_html_e( 'Export', 'forminator' ); ?></span> <span class="sui-tag sui-tag-blue sui-tag-sm"><?php echo esc_html__( 'Coming soon', 'forminator' ); ?></span> </a></li> <?php else : ?> <li><a href="#" class="wpmudev-open-modal" data-modal="<?php echo esc_attr( $export_dialog ); ?>" data-modal-title="" data-form-id="<?php echo esc_attr( $module['id'] ); ?>" data-nonce="<?php echo esc_attr( wp_create_nonce( 'forminator_popup_export_' . $module_slug ) ); ?>"> <i class="sui-icon-cloud-migration" aria-hidden="true"></i> <?php esc_html_e( 'Export', 'forminator' ); ?> </a></li> <?php endif; ?> <?php endif; ?> <li> <button class="sui-option-red wpmudev-open-modal" data-modal="delete-module" data-modal-title="<?php /* translators: %s: Module slug. */ printf( esc_attr__( 'Delete %s', 'forminator' ), esc_html( forminator_get_prefix( $module_slug, '', true ) ) ); ?>" data-modal-content="<?php /* translators: %s: Module slug. */ printf( esc_attr__( 'Are you sure you wish to permanently delete this %s?', 'forminator' ), esc_html( $module_slug ) ); ?>" data-form-id="<?php echo esc_attr( $module['id'] ); ?>" data-nonce="<?php echo esc_attr( wp_create_nonce( 'forminator_' . $module_slug . '_request' ) ); ?>" > <i class="sui-icon-trash" aria-hidden="true"></i> <?php esc_html_e( 'Delete', 'forminator' ); ?> </button> </li> </ul> </div> <button class="sui-button-icon sui-accordion-open-indicator" aria-label="<?php esc_html_e( 'Open item', 'forminator' ); ?>"><i class="sui-icon-chevron-down" aria-hidden="true"></i></button> </div> </div> <div class="sui-accordion-item-body"> <ul class="sui-accordion-item-data"> <li data-col="large"> <strong><?php esc_html_e( 'Last Submission', 'forminator' ); ?></strong> <span><?php echo esc_html( $module['last_entry_time'] ); ?></span> </li> <?php if ( forminator_global_tracking() ) { ?> <li data-col="small"> <strong><?php esc_html_e( 'Views', 'forminator' ); ?></strong> <span><?php echo esc_html( $module['views'] ); ?></span> </li> <?php } ?> <li> <?php if ( $has_leads ) : ?> <strong class="forminator-leads-leads" style="display:none;"><?php esc_html_e( 'Leads Collected', 'forminator' ); ?></strong> <a href="<?php echo esc_url( admin_url( 'admin.php?page=forminator-quiz-view&form_id=' . $module['id'] ) ); ?>" class="forminator-leads-leads" style="display:none;"><?php echo esc_html( $module['leads'] ); ?></a> <?php endif; ?> <strong class="forminator-leads-submissions"><?php esc_html_e( 'Submissions', 'forminator' ); ?></strong> <a href="<?php echo esc_url( admin_url( 'admin.php?page=forminator-entries&form_type=' . $post_type . '&form_id=' . $module['id'] ) ); ?>" class="forminator-leads-submissions"><?php echo esc_html( $module['entries'] ); ?></a> </li> <?php if ( forminator_global_tracking() ) { ?> <li> <strong><?php esc_html_e( 'Conversion Rate', 'forminator' ); ?></strong> <span class="forminator-submission-rate"><?php echo esc_html( self::getRate( $module ) ); ?>%</span> <?php if ( $has_leads ) : ?> <span class="forminator-leads-rate" style="display:none;"><?php echo esc_html( Forminator_Quiz_Page::getLeadsRate( $module ) ); ?>%</span> <?php endif; ?> </li> <?php } ?> <?php if ( $has_leads ) : ?> <li class="fui-conversion-select" data-col="selector"> <label class="fui-selector-label"><?php esc_html_e( 'View data for', 'forminator' ); ?></label> <select class="sui-select sui-select-sm fui-selector-button fui-select-listing-data"> <option value="submissions"><?php esc_html_e( 'Submissions', 'forminator' ); ?></option> <option value="leads"><?php esc_html_e( 'Leads Form', 'forminator' ); ?></option> </select> </li> <?php endif; ?> <?php if ( forminator_global_tracking() ) { ?> <li> <a href="<?php echo esc_url( admin_url( 'admin.php?page=forminator-reports&form_type=' . $post_type . '&form_id=' . $module['id'] ) ); ?>" class="sui-button sui-button-ghost"> <i class="sui-icon-page" aria-hidden="true"></i> <?php esc_html_e( 'view full report', 'forminator' ); ?> </a> </li> <?php } ?> </ul> <div class="sui-chartjs <?php echo esc_attr( $opened_chart ); ?> forminator-stats-chart" data-chart-id="<?php echo esc_attr( $module['id'] ); ?>"> <?php unset( $message ); if ( 0 === $module['entries'] ) { /* translators: %s: Module slug */ $message = sprintf( esc_html__( 'Your %s doesn\'t have any submission yet. Try again in a moment.', 'forminator' ), esc_html__( $module_slug, 'forminator' ) ); /* phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText -- I18n is required. */ } elseif ( 'draft' === $module['status'] ) { /* translators: %s: Module slug */ $message = sprintf( esc_html__( 'This %s is in draft state, so we\'ve paused collecting data until you publish it live.', 'forminator' ), esc_html__( $module_slug, 'forminator' ) ); /* phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText -- I18n is required. */ } elseif ( 0 === $module_entries_from_last_month ) { /* translators: %s: Module slug */ $message = sprintf( esc_html__( 'Your %s didn\'t collect submissions the past 30 days.', 'forminator' ), esc_html__( $module_slug, 'forminator' ) ); /* phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText -- I18n is required. */ } ?> <?php if ( ! empty( $message ) ) { ?> <div class="sui-chartjs-message sui-chartjs-message--empty"> <p><i class="sui-icon-info" aria-hidden="true"></i> <?php echo esc_html( $message ); ?></p> </div> <?php } ?> <div class="sui-chartjs-canvas"> <?php if ( ( 0 !== $module['entries'] ) || ( 0 !== $module_entries_from_last_month ) ) { ?> <canvas id="forminator-module-<?php echo esc_attr( $module['id'] ); ?>-stats"></canvas> <?php } ?> </div> </div> <?php if ( $has_leads ) { ?> <div class="sui-chartjs <?php echo esc_attr( $opened_chart ); ?> forminator-leads-chart" style="display: none;" data-chart-id="<?php echo esc_attr( $leads_id ); ?>"> <?php if ( ! empty( $message ) ) { ?> <div class="sui-chartjs-message sui-chartjs-message--empty"> <p><i class="sui-icon-info" aria-hidden="true"></i> <?php echo esc_html( $message ); ?></p> </div> <?php } ?> <div class="sui-chartjs-canvas"> <?php if ( ( 0 !== $module['entries'] ) || ( 0 !== $module_entries_from_last_month ) ) { ?> <canvas id="forminator-module-<?php echo esc_attr( $leads_id ); ?>-stats"></canvas> <?php } ?> </div> </div> <?php } ?> </div> </div> <?php } } /** * Calculate rate * * @since 1.0 * * @param array $module Module. * * @return float|int */ public static function getRate( $module ) { if ( $module['views'] > 0 ) { $rate = round( ( $module['entries'] * 100 ) / $module['views'], 1 ); } else { $rate = 0; } return $rate; } /** * Pagination * * @param bool $is_search Is search. * @param int $count Count. * * @since 1.0 */ public function pagination( $is_search, $count ) { echo '<span class="sui-pagination-results">' /* translators: %s: Pagination Count */ . esc_html( sprintf( _n( '%s result', '%s results', $count, 'forminator' ), $count ) ) . '</span>'; if ( $is_search ) { return; } forminator_list_pagination( $count ); } /** * Get models * * @since 1.0 * @since 1.6 add $limit * @param int $limit Limit. * * @return array */ public static function get_models( $limit = null ) { if ( ! isset( static::$module_slug ) ) { $module_slug = self::get_slug_for_search(); } else { $module_slug = static::$module_slug; } $class_name = 'Forminator_' . forminator_get_prefix( $module_slug, '', true ) . '_Model'; $data = $class_name::model()->get_all_paged( self::$page_number, $limit ); return $data; } /** * Get slug when in search * * @since 1.14.12 * * @return string */ public static function get_slug_for_search() { $page = Forminator_Core::sanitize_text_field( 'page' ); switch ( $page ) { case 'forminator-poll': $module_slug = 'poll'; break; case 'forminator-quiz': $module_slug = 'quiz'; break; default: $module_slug = 'form'; break; } return $module_slug; } /** * Clone Module * * @since 1.6 * * @param int $id Module Id. */ public function clone_module( $id ) { // check if this id is valid and the record is exists. $model = Forminator_Base_Form_Model::get_model( $id ); if ( is_object( $model ) ) { // create one. // reset id. $model->id = null; // update title. if ( isset( $model->settings['formName'] ) ) { $model->settings['formName'] = /* translators: %s: Form name */ sprintf( esc_html__( 'Copy of %s', 'forminator' ), esc_html( $model->settings['formName'] ) ); } // save it to create new record. $new_id = $model->save( true ); if ( is_wp_error( $new_id ) ) { return $new_id; } /** * Action called after module cloned * * @since 1.11 * * @param int $new_id - module id. * @param object $model - module model. * * @since 1.39 * @param int $id - Old module id. */ do_action( 'forminator_' . static::$module_slug . '_action_clone', $new_id, $model, $id ); $function = 'forminator_clone_' . static::$module_slug . '_submissions_retention'; if ( function_exists( $function ) ) { $function( $id, $new_id ); } // Purge count forms cache. $cache_prefix = 'forminator_' . static::$module_slug . '_total_entries'; wp_cache_delete( $cache_prefix, $cache_prefix ); wp_cache_delete( $cache_prefix . '_publish', $cache_prefix . '_publish' ); wp_cache_delete( $cache_prefix . '_draft', $cache_prefix . '_draft' ); // Call do action after create duplicate module. Forminator_Base_Form_Model::module_update_do_action( static::$module_slug, $new_id, $model ); } } /** * Delete module * * @since 1.6 * * @param int $id Module Id. */ public static function delete_module( $id ) { // check if this id is valid and the record is exists. $model = Forminator_Base_Form_Model::get_model( $id ); if ( is_object( $model ) ) { $validate = forminator_validate_registration_form_settings( $model->settings ); if ( is_wp_error( $validate ) ) { return $validate; } // For Quizzes with Leads. if ( isset( $model->settings['hasLeads'] ) && isset( $model->settings['leadsId'] ) && $model->settings['hasLeads'] ) { $leads_id = $model->settings['leadsId']; $leads_model = Forminator_Base_Form_Model::get_model( $leads_id ); if ( is_object( $leads_model ) ) { wp_delete_post( $leads_id ); self::delete_css( $leads_id ); } } Forminator_Form_Entry_Model::delete_by_form( $id ); $form_view = Forminator_Form_Views_Model::get_instance(); $form_view->delete_by_form( $id ); $post_status = get_post_status( $id ); if ( 'pdf_form' === $post_status ) { $model::$module_slug = 'pdf'; } $function = 'forminator_update_' . $model::$module_slug . '_submissions_retention'; if ( function_exists( $function ) ) { $function( $id, null, null ); } wp_delete_post( $id ); self::delete_css( $id ); // Purge count forms cache. $cache_prefix = 'forminator_' . $model::$module_slug . '_total_entries'; wp_cache_delete( $cache_prefix, $cache_prefix ); wp_cache_delete( $cache_prefix . '_publish', $cache_prefix . '_publish' ); wp_cache_delete( $cache_prefix . '_draft', $cache_prefix . '_draft' ); /** * Action called after module deleted * * @since 1.11 * * @param int $id - module id. */ do_action( 'forminator_' . $model::$module_slug . '_action_delete', $id ); } } /** * Delete module CSS file * * @param int $id Module ID. */ private static function delete_css( $id ) { $css_file = Forminator_Assets_Enqueue::get_css_upload( $id, 'dir' ); if ( file_exists( $css_file ) ) { // delete CSS file. wp_delete_file( $css_file ); } $css_dir = dirname( $css_file ); $index_file = $css_dir . DIRECTORY_SEPARATOR . 'index.php'; if ( file_exists( $index_file ) ) { // Delete index.php file inside `css` folder. wp_delete_file( $index_file ); } // Ensure the WP_Filesystem is initialized. if ( ! function_exists( 'wp_filesystem' ) ) { require_once ABSPATH . 'wp-admin/includes/file.php'; } WP_Filesystem(); // Global $wp_filesystem should be available now. global $wp_filesystem; // remove `css` folder. if ( $wp_filesystem->is_dir( $css_dir ) ) { $wp_filesystem->rmdir( $css_dir ); } $module_dir = dirname( $css_dir ); $files = array_diff( scandir( $module_dir ), array( '.', '..', 'index.php' ) ); // Completely remove module folder if there are no other files. if ( ! $files ) { $index_file = $module_dir . DIRECTORY_SEPARATOR . 'index.php'; if ( file_exists( $index_file ) ) { // Delete index.php file inside module folder. wp_delete_file( $index_file ); } // remove module folder. if ( $wp_filesystem->is_dir( $module_dir ) ) { $wp_filesystem->rmdir( $module_dir ); } } } /** * Delete module entries * * @since 1.6 * * @param int $id Module Id. */ public function delete_module_entries( $id ) { // check if this id is valid and the record is exists. $model = Forminator_Base_Form_Model::get_model( $id ); if ( is_object( $model ) ) { Forminator_Form_Entry_Model::delete_by_form( $id ); } } /** * Export module * * @since 1.6 * * @param int $id Module Id. */ public function export_module( $id ) { $exportable = array(); $model_name = ''; $model = Forminator_Base_Form_Model::get_model( $id ); if ( $model instanceof Forminator_Base_Form_Model ) { $model_name = $model->name; $exportable = $model->to_exportable_data(); } $encoded = wp_json_encode( $exportable ); $fp = fopen( 'php://memory', 'w' ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fopen fwrite( $fp, $encoded ); // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_fwrite fseek( $fp, 0 ); $filename = esc_html__( 'forminator', 'forminator' ) . '-' . sanitize_title( $model_name ) . '-' . static::$module_slug . '-export.txt'; header( 'Content-Description: File Transfer' ); header( 'Content-Type: text/plain' ); header( 'Content-Disposition: attachment; filename="' . basename( $filename ) . '"' ); header( 'Cache-Control: must-revalidate' ); header( 'Content-Length: ' . strlen( $encoded ) ); // make php send the generated csv lines to the browser. ob_clean(); fpassthru( $fp ); } /** * Override scripts to be loaded * * @since 1.11 * * @param string $hook Hook name. */ public function enqueue_scripts( $hook ) { parent::enqueue_scripts( $hook ); forminator_print_front_styles(); forminator_print_front_scripts(); } /** * Process request * * @since 1.0 */ public function processRequest() { $action = Forminator_Core::sanitize_text_field( 'forminator_action' ); if ( ! $action ) { return; } if ( 'pdf-preview' === $action ) { $this->process_pdf_actions( $action ); return; } $page = Forminator_Core::sanitize_text_field( 'page' ); // Check if the page is not the relevant module type page and not forminator dashboard page. if ( 'forminator-' . forminator_get_prefix( static::$module_slug, 'c' ) !== $page && 'forminator' !== $page ) { return; } $form_type = Forminator_Core::sanitize_text_field( 'form_type' ); // In forminator dashboard, check if form type is not the relevant module type. if ( 'forminator' === $page && $form_type && forminator_get_prefix( static::$module_slug, 'custom-' ) !== $form_type ) { return; } $id = filter_input( INPUT_POST, 'id', FILTER_VALIDATE_INT ); // Set nonce names first for verification. switch ( $action ) { case 'clone': $nonce_name = 'forminatorNonce'; $nonce_action = 'forminator-nonce-clone-' . $id; break; case 'reset-views': $nonce_name = 'forminatorNonce'; $nonce_action = 'forminator-nonce-reset-views-' . $id; break; case 'update-status': $nonce_name = 'forminator-nonce-update-status-' . $id; $nonce_action = $nonce_name; break; default: $nonce_name = 'forminatorNonce'; $nonce_action = 'forminator_' . static::$module_slug . '_request'; break; } // Verify nonce. $nonce = Forminator_Core::sanitize_text_field( $nonce_name ); if ( ! $nonce || ! wp_verify_nonce( $nonce, $nonce_action ) ) { return; } $plural_slug = forminator_get_prefix( static::$module_slug, '', false, true ); $is_redirect = true; $ids = Forminator_Core::sanitize_text_field( 'ids' ); $module_ids = ! empty( $ids ) ? explode( ',', $ids ) : array(); $has_access_error = 0; switch ( $action ) { case 'delete': if ( ! empty( $id ) ) { $result = static::delete_module( $id ); if ( is_wp_error( $result ) ) { $error_message = $result->get_error_message(); } else { $notice = static::$module_slug . '_deleted'; } } break; case 'clone': if ( ! empty( $id ) ) { $result = $this->clone_module( $id ); if ( is_wp_error( $result ) ) { $error_message = $result->get_error_message(); } else { $notice = static::$module_slug . '_duplicated'; } } break; case 'reset-views': if ( ! empty( $id ) ) { self::reset_module_views( $id ); $notice = static::$module_slug . '_reset'; } break; case 'delete-votes': case 'delete-entries': if ( ! empty( $id ) ) { $this->delete_module_entries( $id ); } break; case 'export': if ( ! empty( $id ) ) { $this->export_module( $id ); } $is_redirect = false; break; case 'delete-' . $plural_slug: foreach ( $module_ids as $id ) { $result = static::delete_module( $id ); if ( is_wp_error( $result ) && ( in_array( $result->get_error_code(), array( 'invalid_access', 'invalid_user_role' ), true ) ) ) { ++$has_access_error; } } if ( $has_access_error ) { $text_message = __( 'The selected form(s) have been deleted. Note: This action cannot be performed on forms without sufficient permissions.', 'forminator' ); } break; case 'delete-votes-polls': case 'delete-entries-' . $plural_slug: foreach ( $module_ids as $id ) { $this->delete_module_entries( $id ); } break; case 'clone-' . $plural_slug: foreach ( $module_ids as $id ) { $result = $this->clone_module( $id ); if ( is_wp_error( $result ) && ( in_array( $result->get_error_code(), array( 'invalid_access', 'invalid_user_role' ), true ) ) ) { ++$has_access_error; } } if ( $has_access_error ) { $text_message = esc_html__( 'The selected form(s) have been duplicated. Note: This action cannot be performed on forms without sufficient permissions.', 'forminator' ); } break; case 'reset-views-' . $plural_slug: foreach ( $module_ids as $id ) { self::reset_module_views( $id ); } break; case 'update-status': $status = Forminator_Core::sanitize_text_field( 'status' ); if ( ! empty( $id ) && ! empty( $status ) ) { // only publish and draft status avail. if ( in_array( $status, array( 'publish', 'draft' ), true ) ) { $model = Forminator_Base_Form_Model::get_model( $id ); if ( $model instanceof Forminator_Base_Form_Model ) { $model->status = $status; $result = $model->save(); if ( is_wp_error( $result ) ) { $error_message = $result->get_error_message(); } else { // Call module update do action on status update. Forminator_Base_Form_Model::module_update_do_action( static::$module_slug, $id, $model ); } } } } break; case 'update-statuses': $status = Forminator_Core::sanitize_text_field( 'status' ); // only publish and draft status avail. if ( ! empty( $status ) && in_array( $status, array( 'publish', 'draft' ), true ) ) { foreach ( $module_ids as $id ) { $model = Forminator_Base_Form_Model::get_model( $id ); if ( $model instanceof Forminator_Base_Form_Model ) { $model->status = $status; $result = $model->save(); if ( is_wp_error( $result ) && ( in_array( $result->get_error_code(), array( 'invalid_access', 'invalid_user_role' ), true ) ) ) { ++$has_access_error; } else { // Call module update do action on status update. Forminator_Base_Form_Model::module_update_do_action( static::$module_slug, $id, $model ); } } } if ( $has_access_error ) { $text_message = esc_html__( 'The selected form(s) have been updated. Note: This action cannot be performed on forms without sufficient permissions.', 'forminator' ); } } break; case 'draft-' . $plural_slug: foreach ( $module_ids as $form_id ) { $result = $this->update_module_status( $form_id, 'draft' ); if ( is_wp_error( $result ) && ( in_array( $result->get_error_code(), array( 'invalid_access', 'invalid_user_role' ), true ) ) ) { ++$has_access_error; } } if ( $has_access_error ) { $text_message = esc_html__( 'The selected form(s) have been updated. Note: This action cannot be performed on forms without sufficient permissions.', 'forminator' ); } break; case 'publish-' . $plural_slug: foreach ( $module_ids as $form_id ) { $result = $this->update_module_status( $form_id, 'publish' ); if ( is_wp_error( $result ) && ( in_array( $result->get_error_code(), array( 'invalid_access', 'invalid_user_role' ), true ) ) ) { ++$has_access_error; } } if ( $has_access_error ) { $text_message = esc_html__( 'The selected form(s) have been updated. Note: This action cannot be performed on forms without sufficient permissions.', 'forminator' ); } break; default: break; } if ( $is_redirect ) { $to_referer = true; if ( isset( $_POST['forminatorRedirect'] ) && 'false' === $_POST['forminatorRedirect'] ) { $to_referer = false; } $args = array( 'page' => $this->get_admin_page(), ); $search = Forminator_Core::sanitize_text_field( 'msearch' ); if ( $search ) { $args['module-search'] = $search; $to_referer = false; } if ( ! empty( $notice ) ) { $args['forminator_notice'] = $notice; $to_referer = false; } if ( ! empty( $error_message ) ) { $args['forminator_error_notice'] = $error_message; $to_referer = false; } if ( ! empty( $text_message ) ) { $args['forminator_text_notice'] = $text_message; $to_referer = false; } $fallback_redirect = add_query_arg( $args, admin_url( 'admin.php' ) ); $this->maybe_redirect_to_referer( $fallback_redirect, $to_referer ); } exit; } /** * Process PDF actions * * @param string $action PDF action. * * @since 1.25 */ public function process_pdf_actions( $action ) { $page = Forminator_Core::sanitize_text_field( 'page' ); $form_type = Forminator_Core::sanitize_text_field( 'form_type' ); if ( 'forminator-cform-wizard' !== $page && 'pdf-form' !== $form_type ) { return; } $nonce = Forminator_Core::sanitize_text_field( 'preview_nonce' ); if ( ! $nonce || ! wp_verify_nonce( $nonce, 'forminator_load_module' ) ) { return; } if ( ! current_user_can( forminator_get_permission( 'forminator-cform' ) ) ) { return; } $pdf_id = Forminator_Core::sanitize_text_field( 'pdf_id' ); if ( empty( $pdf_id ) ) { $pdf_id = Forminator_Core::sanitize_text_field( 'id' ); } if ( ! is_numeric( $pdf_id ) ) { return; } if ( class_exists( 'Forminator_PDF_Form_Actions' ) ) { $pdf_action = new Forminator_PDF_Form_Actions(); $pdf = Forminator_API::get_module( $pdf_id ); if ( 'pdf-preview' === $action ) { $pdf_action->process_pdf_download( $pdf, 'preview', esc_html( $pdf->name . '_' . wp_date( 'M-j-y' ) . '.pdf' ), 'I' ); exit; // Do not remove. } } } /** * Update Module Status * * @since 1.6 * * @param int $id Module Id. * @param string $status Module status. */ public function update_module_status( $id, $status ) { // only publish and draft status avail. if ( in_array( $status, array( 'publish', 'draft' ), true ) ) { $model = Forminator_Base_Form_Model::get_model( $id ); if ( $model instanceof Forminator_Base_Form_Model ) { $model->status = $status; $result = $model->save(); if ( is_wp_error( $result ) ) { return $result; } else { // Call module update do action on status update. Forminator_Base_Form_Model::module_update_do_action( static::$module_slug, $id, $model ); } } } } /** * Reset views data * * @since 1.6 * * @param int $id Module ID. */ public static function reset_module_views( $id ) { $form_types = forminator_form_types(); $module = get_post( $id ); if ( ! empty( $module->post_type ) && in_array( $module->post_type, $form_types, true ) ) { $form_view = Forminator_Form_Views_Model::get_instance(); $form_view->delete_by_form( $id ); } } } PK nG}\�FH$zX zX class-admin-page.phpnu �[��� <?php /** * Forminator Admin Page * * @package Forminator */ if ( ! defined( 'ABSPATH' ) ) { die(); } /** * Class Forminator_Admin_Page * * @since 1.0 */ abstract class Forminator_Admin_Page { /** * Current page ID * * @var number */ public $page_id = null; /** * Current page slug * * @var string */ protected $page_slug = ''; /** * Path to view folder * * @var string */ protected $folder = ''; /** * Forminator_Admin_Page Constructor * * @since 1.0 * * @param string $page_slug Page slug. * @param string $folder Folder. * @param string $page_title Page title. * @param string $menu_title Menu title. * @param bool $parent_page Parent or not. * @param bool $render Render the page. */ public function __construct( $page_slug, $folder, $page_title, $menu_title, $parent_page = false, $render = true ) { $this->page_slug = $page_slug; $this->folder = $folder; if ( ! $parent_page ) { $this->page_id = add_menu_page( $page_title, $menu_title, forminator_get_permission( $page_slug ), $page_slug, $render ? array( $this, 'render' ) : null, $this->get_menu_icon() ); } else { $this->page_id = add_submenu_page( $parent_page, $page_title, $menu_title, forminator_get_permission( $page_slug ), $page_slug, $render ? array( $this, 'render' ) : null ); } if ( $render ) { $this->render_page_hooks(); } $this->init(); add_filter( 'removable_query_args', array( $this, 'remove_notice_params' ) ); } /** * Use that method instead of __construct * * @todo : deperecate this, since its not correct way to execute action on page, * instead this function will executed everywhere on all pages, * unless you are really wanna do that?! * * @since 1.0 */ public function init() { } /** * Hooks before content render * * @since 1.0 */ public function render_page_hooks() { add_action( 'load-' . $this->page_id, array( $this, 'before_render' ) ); add_action( 'load-' . $this->page_id, array( $this, 'trigger_before_render_action' ) ); add_filter( 'load-' . $this->page_id, array( $this, 'add_page_hooks' ) ); } /** * Return page slug * * @since 1.0 * @return string */ public function get_the_slug() { return $this->page_slug; } /** * Called when page is loaded and content not rendered yet * * @since 1.0 */ public function before_render() { } /** * Trigger an action before this screen is rendered * * @since 1.0 */ public function trigger_before_render_action() { do_action( 'forminator_loaded_admin_page_' . $this->get_the_slug() ); } /** * Add page screen hooks * * @since 1.0 */ public function add_page_hooks() { $page_action = filter_input( INPUT_GET, 'page_action' ); if ( ! forminator_cloud_templates_disabled() && 'hub_connection' === $page_action && ! Forminator_Hub_Connector::hub_connector_connected() ) { return; } add_filter( 'user_can_richedit', '__return_true' ); // Confirms wp editor script is loaded on Forminator admin pages. add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); add_filter( 'admin_body_class', array( $this, 'admin_body_classes' ) ); add_action( 'init', array( $this, 'init_scripts' ) ); } /** * Remove Get parameters for Forminator notices * * @param string[] $vars An array of query variables to remove from a URL. * @return array */ public function remove_notice_params( $vars ) { $vars[] = 'forminator_notice'; $vars[] = 'forminator_text_notice'; $vars[] = 'forminator_error_notice'; if ( Forminator_Hub_Connector::hub_connector_connected() ) { $vars[] = 'page_action'; } return $vars; } /** * Add page screen hooks * * @since 1.0 * * @param string $hook Hook name. */ public function enqueue_scripts( $hook ) { // Load admin scripts. wp_register_script( 'forminator-admin', forminator_plugin_url() . 'requirejs/main.js', array( 'backbone', 'underscore', 'jquery', 'wp-color-picker', ), FORMINATOR_VERSION, true ); forminator_common_admin_enqueue_scripts(); } /** * Init Admin scripts * * @since 1.0 * * @param string $hook Hook name. */ public function init_scripts( $hook ) { // Init jquery ui. forminator_admin_jquery_ui_init(); } /** * Render page header * * @since 1.0 */ protected function render_header() { $this->show_css_warning(); $this->show_stripe_migration_notice(); if ( $this->template_exists( $this->folder . '/header' ) ) { $this->template( $this->folder . '/header' ); } else { ?> <header class="sui-header"> <h1 class="sui-header-title"><?php echo esc_html( get_admin_page_title() ); ?></h1> </header> <?php } } /** * Render page footer * * @since 1.0 */ protected function render_footer() { $hide_footer = false; $footer_text = sprintf( /* translators: %s: SUI Icon . */ esc_html__( 'Made with %s by WPMU DEV', 'forminator' ), ' <i class="sui-icon-heart"></i>' ); $hide_footer = apply_filters( 'wpmudev_branding_change_footer', $hide_footer ); $footer_text = apply_filters( 'wpmudev_branding_footer_text', $footer_text ); if ( $this->template_exists( $this->folder . '/footer' ) ) { $this->template( $this->folder . '/footer' ); } ?> <div class="sui-footer"><?php echo wp_kses_post( $footer_text ); ?></div> <?php if ( FORMINATOR_PRO ) { ?> <?php if ( ! $hide_footer ) : ?> <ul class="sui-footer-nav"> <li><a href="https://wpmudev.com/hub2/" target="_blank"><?php esc_html_e( 'The Hub', 'forminator' ); ?></a></li> <li><a href="https://wpmudev.com/projects/category/plugins/" target="_blank"><?php esc_html_e( 'Plugins', 'forminator' ); ?></a></li> <li><a href="https://wpmudev.com/roadmap/" target="_blank"><?php esc_html_e( 'Roadmap', 'forminator' ); ?></a></li> <li><a href="https://wpmudev.com/hub2/support/" target="_blank"><?php esc_html_e( 'Support', 'forminator' ); ?></a></li> <li><a href="https://wpmudev.com/docs/" target="_blank"><?php esc_html_e( 'Docs', 'forminator' ); ?></a></li> <li><a href="https://wpmudev.com/hub2/community/" target="_blank"><?php esc_html_e( 'Community', 'forminator' ); ?></a></li> <li><a href="https://wpmudev.com/terms-of-service/" target="_blank"><?php esc_html_e( 'Terms of Service', 'forminator' ); ?></a></li> <li><a href="https://incsub.com/privacy-policy/" target="_blank"><?php esc_html_e( 'Privacy Policy', 'forminator' ); ?></a></li> </ul> <?php endif; ?> <?php } else { ?> <ul class="sui-footer-nav"> <li><a href="https://profiles.wordpress.org/wpmudev#content-plugins" target="_blank"><?php esc_html_e( 'Free Plugins', 'forminator' ); ?></a></li> <li><a href="https://wpmudev.com/features/" target="_blank"><?php esc_html_e( 'Membership', 'forminator' ); ?></a></li> <li><a href="https://wpmudev.com/roadmap/" target="_blank"><?php esc_html_e( 'Roadmap', 'forminator' ); ?></a></li> <li><a href="https://wordpress.org/support/plugin/forminator" target="_blank"><?php esc_html_e( 'Support', 'forminator' ); ?></a></li> <li><a href="https://wpmudev.com/docs/" target="_blank"><?php esc_html_e( 'Docs', 'forminator' ); ?></a></li> <li><a href="https://wpmudev.com/hub-welcome/" target="_blank"><?php esc_html_e( 'The Hub', 'forminator' ); ?></a></li> <li><a href="https://wpmudev.com/terms-of-service/" target="_blank"><?php esc_html_e( 'Terms of Service', 'forminator' ); ?></a></li> <li><a href="https://incsub.com/privacy-policy/" target="_blank"><?php esc_html_e( 'Privacy Policy', 'forminator' ); ?></a></li> </ul> <?php } ?> <?php if ( ! $hide_footer ) : ?> <ul class="sui-footer-social"> <li><a href="https://www.facebook.com/wpmudev" target="_blank"> <i class="sui-icon-social-facebook" aria-hidden="true"></i> <span class="sui-screen-reader-text"><?php esc_html_e( 'Facebook', 'forminator' ); ?></span> </a></li> <li><a href="https://twitter.com/wpmudev" target="_blank"> <i class="sui-icon-social-twitter" aria-hidden="true"></i> <span class="sui-screen-reader-text"><?php esc_html_e( 'X', 'forminator' ); ?></span> </a></li> <li><a href="https://www.instagram.com/wpmu_dev/" target="_blank"> <i class="sui-icon-instagram" aria-hidden="true"></i> <span class="sui-screen-reader-text"><?php esc_html_e( 'Instagram', 'forminator' ); ?></span> </a></li> </ul> <?php endif; ?> <?php } /** * Render page container * * @since 1.0 */ public function render() { $accessibility_enabled = get_option( 'forminator_enable_accessibility', false ); ?> <main class="sui-wrap <?php echo $accessibility_enabled ? 'sui-color-accessible' : ''; ?> <?php echo esc_attr( 'wpmudev-forminator-' . $this->page_slug ); ?>"> <?php $page_action = filter_input( INPUT_GET, 'page_action' ); $hub_connecting = ! forminator_cloud_templates_disabled() && 'hub_connection' === $page_action; if ( $hub_connecting && ! Forminator_Hub_Connector::hub_connector_connected() ) { do_action( 'wpmudev_hub_connector_ui', 'forminator' ); } else { $this->render_header(); $this->render_page_content(); $this->render_footer(); if ( $hub_connecting && Forminator_Hub_Connector::hub_connector_connected() ) { self::hub_connected_successfully_modal(); } } ?> </main> <?php } /** * Show modal when hub connected successfully */ public static function hub_connected_successfully_modal() { ?> <div class="sui-modal sui-modal-sm"> <div role="dialog" id="forminator-hub-connected-successfully-modal" class="sui-modal-content" aria-modal="true" aria-labelledby="forminator-hub-connected-successfully-modal-title" aria-describedby="forminator-hub-connected-successfully-modal-description" data-esc-close="true" > <div class="sui-box"> <div class="sui-box-header sui-flatten sui-content-center sui-spacing-top--60"> <span class="sui-icon-check-tick sui-success sui-xl" aria-hidden="true"></span> <h3 id="forminator-hub-connected-successfully-modal-title" class="sui-box-title sui-lg"> <?php esc_html_e( 'Site connected successfully!', 'forminator' ); ?> </h3> <p id="forminator-hub-connected-successfully-modal-description" class="sui-description"> <b><?php esc_html_e( 'Congratulations!', 'forminator' ); ?></b> <?php esc_html_e( 'Your site is connected to the Hub. You can now save your forms to the Hub cloud.', 'forminator' ); ?> </p> </div> <div class="sui-box-footer sui-flatten sui-content-center"> <button class="sui-button sui-button-blue" data-modal-close> <?php esc_html_e( 'Close', 'forminator' ); ?> </button> </div> </div> </div> </div> <?php } /** * Render actual page template * * @since 1.0 */ protected function render_page_content() { $this->template( $this->folder . '/content' ); } /** * Load an admin template * * @since 1.0 * * @param string $path Template path. * @param array $args Arguments. * @param bool $echo_content Echo. * * @return string */ public function template( $path, $args = array(), $echo_content = true ) { $file = forminator_plugin_dir() . "admin/views/$path.php"; $content = ''; if ( is_file( $file ) ) { ob_start(); if ( isset( $args['id'] ) ) { $template_class = $args['class']; $template_id = $args['id']; $title = $args['title']; $header_callback = $args['header_callback']; $main_callback = $args['main_callback']; $footer_callback = $args['footer_callback']; } include $file; $content = ob_get_clean(); } if ( $echo_content ) { echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped } return $content; } /** * Check if template exist * * @since 1.0 * * @param string $path Template path. * * @return bool */ protected function template_exists( $path ) { $file = forminator_plugin_dir() . "admin/views/$path.php"; return is_file( $file ); } /** * Generates the admin body class required for WPMU DEV Shared UI * * @since 1.0.2 * @return string $sui_body_class */ public function get_sui_body_class() { $sanitize_version = str_replace( '.', '-', FORMINATOR_SUI_VERSION ); $sui_body_class = "sui-$sanitize_version"; return $sui_body_class; } /** * Add admin body classes * * @since 1.0.2 * * @param string $classes Classes. * * @return string $classes */ public function admin_body_classes( $classes ) { $screen = get_current_screen(); // Do nothing if not a forminator page. if ( strpos( $screen->base, '_page_forminator' ) === false ) { return $classes; } $classes = $this->get_sui_body_class(); // if accessibility enabled add sui select accessible class. if ( get_option( 'forminator_enable_accessibility', false ) ) { $classes .= ' sui-elements-accessible'; } return $classes; } /** * Get admin page param * * @since 1.5.4 * @return string */ protected function get_admin_page() { return Forminator_Core::sanitize_text_field( 'page' ); } /** * Redirect to referer if available * * @since 1.6 * * @param string $fallback_redirect url if referer not found. * @param bool $to_referer Referer. */ protected function maybe_redirect_to_referer( $fallback_redirect = '', $to_referer = true ) { $referer = wp_get_referer(); $referer = ! empty( $referer ) ? $referer : wp_get_raw_referer(); $referer = remove_query_arg( array( 'export', 'delete', 'forminator_notice', 'forminator_text_notice', 'forminator_error_notice' ), $referer ); if ( $referer && $to_referer ) { wp_safe_redirect( $referer ); } elseif ( $fallback_redirect ) { wp_safe_redirect( $fallback_redirect ); } else { $admin_url = admin_url( 'admin.php' ); $admin_url = add_query_arg( array( 'page' => $this->get_admin_page(), ), $admin_url ); wp_safe_redirect( $admin_url ); } exit(); } /** * Get css class used for box summary on admin page * * @since 1.6 * @return string */ public function get_box_summary_classes() { $classes = ''; if ( Forminator::is_wpmudev_member() ) { $hide_branding = false; $hide_branding = apply_filters( 'wpmudev_branding_hide_branding', $hide_branding ); $custom_branding_image = ''; $custom_branding_image = apply_filters( 'wpmudev_branding_hero_image', $custom_branding_image ); if ( $hide_branding && ! empty( $custom_branding_image ) ) { $classes .= ' sui-rebranded'; } elseif ( $hide_branding && empty( $custom_branding_image ) ) { $classes .= ' sui-unbranded'; } } return $classes; } /** * Get image url for summary box * * @since 1.6 * @return string */ public function get_box_summary_image_url() { $image_url = ''; if ( Forminator::is_wpmudev_member() ) { $image_url = apply_filters( 'wpmudev_branding_hero_image', $image_url ); } return $image_url; } /** * Get inline style for box summary-image div * * @since 1.6 * @return string */ public function get_box_summary_image_style() { $image_url = $this->get_box_summary_image_url(); if ( ! empty( $image_url ) ) { return 'background-image:url(' . esc_url( $image_url ) . ')'; } return ''; } /** * Show migration notice for stripe * * @return void */ public function show_stripe_migration_notice() { $active_forms = Forminator_Form_Model::model()->get_models_with_old_stripe(); if ( ! $active_forms ) { return; } ?> <div role="alert" class="sui-notice sui-notice-yellow sui-active" style="display: block; text-align: left;" aria-live="assertive" > <div class="sui-notice-content"> <div class="sui-notice-message"> <span class="sui-notice-icon sui-icon-info" aria-hidden="true"></span> <p> <b><?php esc_html_e( 'Migrate to new Forminator Stripe field', 'forminator' ); ?></b> </p> <p> <?php $stripe_link = 'https://wpmudev.com/docs/wpmu-dev-plugins/forminator/#stripe-field'; printf( /* Translators: 1. Opening <a> tag with link 2. closing <a> tag. */ esc_html__( 'You are using the Stripe simple card payment element, which is being deprecated by Stripe. %1$sLearn more%2$s. To ensure seamless transactions, update the Stripe field in the form(s) below to the new Stripe payment element.', 'forminator' ), '<a href="' . esc_url( $stripe_link ) . '" target="_blank">', '</a>' ); ?> </p> <?php foreach ( $active_forms as $form ) : ?> <li> <a href="<?php echo esc_url( admin_url( 'admin.php?page=forminator-cform-wizard&id=' . intval( $form['id'] ) ) ); ?>" class=""> <?php echo esc_html( $form['title'] ); ?> <i class="sui-icon-pencil" aria-hidden="true"></i> </a> </li> <?php endforeach; ?> </div> </div> </div> <?php } /** * Show warning if frontend is loaded in https but the WordPress address url setting uses http only * * @since 1.15.1 */ public function show_css_warning() { $home_url = wp_parse_url( home_url() ); $site_url_option = wp_parse_url( get_option( 'siteurl' ) ); // WordPress Address (URL). if ( ( 'https' === $home_url['scheme'] && 'https' === $site_url_option['scheme'] ) || ( 'http' === $home_url['scheme'] && 'http' === $site_url_option['scheme'] ) ) { return; } ?> <div role="alert" class="sui-notice sui-notice-yellow sui-active" style="display: block; text-align: left;" aria-live="assertive" > <div class="sui-notice-content"> <div class="sui-notice-message"> <span class="sui-notice-icon sui-icon-info" aria-hidden="true"></span> <p><?php esc_html_e( 'Forminator\'s CSS style cannot be loaded because your website\'s address is configured in WordPress to use HTTP instead of HTTPS. This may cause some web content, including Forminator forms, to display incorrectly.', 'forminator' ); ?></p> </div> </div> </div> <?php } /** * Forminator icon svg image. * * @return string */ private function get_menu_icon() { ob_start(); ?> <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg"> <path fill-rule="evenodd" clip-rule="evenodd" d="M12.5067 1.79874H16.2222C16.6937 1.79874 17.1459 1.99053 17.4793 2.33187C17.8127 2.67321 18 3.13614 18 3.61887V18.1799C18 18.6626 17.8127 19.1255 17.4793 19.4669C17.1459 19.8082 16.6937 20 16.2222 20H3.77778C3.30628 20 2.85412 19.8082 2.52072 19.4669C2.18733 19.1255 2 18.6626 2 18.1799V3.61887C2 3.13614 2.18733 2.67321 2.52072 2.33187C2.85412 1.99053 3.30628 1.79874 3.77778 1.79874H7.49333C7.68017 1.27168 8.02098 0.816284 8.46946 0.494469C8.91793 0.172654 9.45234 0 10 0C10.5477 0 11.0821 0.172654 11.5305 0.494469C11.979 0.816284 12.3198 1.27168 12.5067 1.79874ZM10.4938 1.9521C10.3476 1.8521 10.1758 1.79874 10 1.79874C9.76425 1.79874 9.53817 1.89464 9.37147 2.0653C9.20477 2.23597 9.11111 2.46744 9.11111 2.7088C9.11111 2.8888 9.16323 3.06472 9.2609 3.21438C9.35858 3.36404 9.49741 3.48072 9.65983 3.5496C9.82225 3.61848 10.001 3.63648 10.1734 3.60137C10.3458 3.56625 10.5042 3.47958 10.6285 3.3523C10.7528 3.22503 10.8375 3.06286 10.8718 2.88633C10.9061 2.70979 10.8885 2.52682 10.8212 2.36053C10.754 2.19424 10.64 2.0521 10.4938 1.9521ZM3.77778 3.61887V18.1799H16.2222V3.61887H13.5556V5.43899H6.44444V3.61887H3.77778ZM6.44442 10.8987H13.5555C13.7913 10.8987 14.0174 10.9946 14.1841 11.1653C14.3508 11.3359 14.4444 11.5674 14.4444 11.8087C14.4444 12.0501 14.3508 12.2816 14.1841 12.4522C14.0174 12.6229 13.7913 12.7188 13.5555 12.7188H6.44442C6.20867 12.7188 5.98259 12.6229 5.8159 12.4522C5.6492 12.2816 5.55553 12.0501 5.55553 11.8087C5.55553 11.5674 5.6492 11.3359 5.8159 11.1653C5.98259 10.9946 6.20867 10.8987 6.44442 10.8987ZM13.5555 8.16849H6.44442C6.20867 8.16849 5.98259 8.26438 5.8159 8.43505C5.6492 8.60572 5.55553 8.83719 5.55553 9.07855C5.55553 9.31992 5.6492 9.55138 5.8159 9.72205C5.98259 9.89272 6.20867 9.98862 6.44442 9.98862H13.5555C13.7913 9.98862 14.0174 9.89272 14.1841 9.72205C14.3508 9.55138 14.4444 9.31992 14.4444 9.07855C14.4444 8.83719 14.3508 8.60572 14.1841 8.43505C14.0174 8.26438 13.7913 8.16849 13.5555 8.16849ZM10 13.6289H13.5556C13.7913 13.6289 14.0174 13.7248 14.1841 13.8954C14.3508 14.0661 14.4444 14.2976 14.4444 14.5389C14.4444 14.7803 14.3508 15.0118 14.1841 15.1824C14.0174 15.3531 13.7913 15.449 13.5556 15.449H10C9.76425 15.449 9.53817 15.3531 9.37148 15.1824C9.20478 15.0118 9.11111 14.7803 9.11111 14.5389C9.11111 14.2976 9.20478 14.0661 9.37148 13.8954C9.53817 13.7248 9.76425 13.6289 10 13.6289Z" fill="#F0F6FC"/> </svg> <?php $svg = ob_get_clean(); return 'data:image/svg+xml;base64,' . base64_encode( $svg ); //phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.obfuscation_base64_encode -- Base64 encode the img content. } /** * Forminator modules */ public function populate_modules() { $modules[] = array( 'name' => esc_html__( 'Forms', 'forminator' ), 'model' => Forminator_Form_Model::model(), 'slug' => 'form', ); $modules[] = array( 'name' => esc_html__( 'Polls', 'forminator' ), 'model' => Forminator_Poll_Model::model(), 'slug' => 'poll', ); $modules[] = array( 'name' => esc_html__( 'Quizzes', 'forminator' ), 'model' => Forminator_Quiz_Model::model(), 'slug' => 'quiz', ); return $modules; } /** * Modules form type * * @return array */ public function modules_form_type() { $form_types = array(); $modules = $this->populate_modules(); foreach ( $modules as $module ) { /** * Forminator_Base_Form_Model * * @var Forminator_Base_Form_Model $model */ $model = $module['model']; $name = $module['name']; $form_types[ $model->get_post_type() ] = $name; } return $form_types; } /** * Get Form Model if current requested form_id available and matched form_type * * @return bool|Forminator_Base_Form_Model|null */ public function get_form_model() { if ( $this->get_current_form_id() ) { $form_model = forminator_get_model_from_id( $this->get_current_form_id() ); if ( ! $form_model instanceof Forminator_Base_Form_Model ) { return null; } if ( $form_model->get_post_type() !== $this->get_current_form_type() ) { return null; } return $form_model; } return null; } } PK nG}\_ß* * class-admin-import-mediator.phpnu �[��� PK nG}\�`<��7 �7 y class-admin-view-page.phpnu �[��� PK nG}\l���- �- UP class-admin-module.phpnu �[��� PK nG}\:t�8ţ ţ p~ class-admin-module-edit-page.phpnu �[��� PK nG}\�FH$zX zX �" class-admin-page.phpnu �[��� PK � C{