PK!@]3class-twenty-twenty-one-customize-color-control.phpnu[get( 'Version' ), false ); } /** * Refresh the parameters passed to the JavaScript via JSON. * * @since Twenty Twenty-One 1.0 * * @uses WP_Customize_Control::to_json() * * @return void */ public function to_json() { parent::to_json(); $this->json['palette'] = $this->palette; } } PK!eaqq%class-twenty-twenty-one-svg-icons.phpnu[ source on its own array key, without adding either * the `width` or `height` attributes, since these are added dynamically, * before rendering the SVG code. * * All icons are assumed to have equal width and height, hence the option * to only specify a `$size` parameter in the svg methods. * * @since Twenty Twenty-One 1.0 */ class Twenty_Twenty_One_SVG_Icons { /** * User Interface icons – svg sources. * * @since Twenty Twenty-One 1.0 * * @var array */ protected static $icons = array( 'arrow_right' => '', 'arrow_left' => '', 'close' => '', 'menu' => '', 'plus' => '', 'minus' => '', ); /** * Social Icons – svg sources. * * @since Twenty Twenty-One 1.0 * * @var array */ protected static $social_icons = array( '500px' => '', 'amazon' => '', 'bandcamp' => '', 'behance' => '', 'codepen' => '', 'deviantart' => '', 'dribbble' => '', 'dropbox' => '', 'etsy' => '', 'facebook' => '', 'feed' => '', 'flickr' => '', 'foursquare' => '', 'goodreads' => '', 'google' => '', 'github' => '', 'instagram' => '', 'lastfm' => '', 'linkedin' => '', 'mail' => '', 'mastodon' => '', 'medium' => '', 'meetup' => '', 'pinterest' => '', 'pocket' => '', 'reddit' => '', 'skype' => '', 'snapchat' => '', 'soundcloud' => '', 'spotify' => '', 'tumblr' => '', 'twitch' => '', 'twitter' => '', 'vimeo' => '', 'vk' => '', 'wordpress' => '', 'yelp' => '', 'youtube' => '', ); /** * Social Icons – domain mappings. * * By default, each Icon ID is matched against a .com TLD. To override this behavior, * specify all the domains it covers (including the .com TLD too, if applicable). * * @since Twenty Twenty-One 1.0 * * @var array */ protected static $social_icons_map = array( 'amazon' => array( 'amazon.com', 'amazon.cn', 'amazon.in', 'amazon.fr', 'amazon.de', 'amazon.it', 'amazon.nl', 'amazon.es', 'amazon.co', 'amazon.ca', ), 'behance' => array( 'behance.net', ), 'codepen' => array( 'codepen.io', ), 'facebook' => array( 'facebook.com', 'fb.me', ), 'feed' => array( 'feed', ), 'lastfm' => array( 'last.fm', ), 'mail' => array( 'mailto:', ), 'pocket' => array( 'getpocket.com', ), 'twitch' => array( 'twitch.tv', ), 'wordpress' => array( 'wordpress.com', 'wordpress.org', ), ); /** * Gets the SVG code for a given icon. * * @static * * @since Twenty Twenty-One 1.0 * * @param string $group The icon group. * @param string $icon The icon. * @param int $size The icon-size in pixels. * @return string */ public static function get_svg( $group, $icon, $size ) { if ( 'ui' === $group ) { $arr = self::$icons; } elseif ( 'social' === $group ) { $arr = self::$social_icons; } else { $arr = array(); } /** * Filters Twenty Twenty-Ones's array of icons. * * The dynamic portion of the hook name, `$group`, refers to * the name of the group of icons, either "ui" or "social". * * @since Twenty Twenty-One 1.0 * * @param array $arr Array of icons. */ $arr = apply_filters( "twenty_twenty_one_svg_icons_{$group}", $arr ); $svg = ''; if ( array_key_exists( $icon, $arr ) ) { $repl = sprintf( ''; } } return null; } } PK!D//%class-twenty-twenty-one-dark-mode.phpnu[ in the dashboard. add_filter( 'admin_body_class', array( $this, 'admin_body_classes' ) ); // Add the switch on the frontend & customizer. add_action( 'wp_footer', array( $this, 'the_switch' ) ); // Add the privacy policy content. add_action( 'admin_init', array( $this, 'add_privacy_policy_content' ) ); } /** * Editor custom color variables & scripts. * * @since Twenty Twenty-One 1.0 * * @return void */ public function editor_custom_color_variables() { if ( ! $this->switch_should_render() ) { return; } $background_color = get_theme_mod( 'background_color', 'D1E4DD' ); $should_respect_color_scheme = get_theme_mod( 'respect_user_color_preference', false ); if ( $should_respect_color_scheme && Twenty_Twenty_One_Custom_Colors::get_relative_luminance_from_hex( $background_color ) > 127 ) { // Add Dark Mode variable overrides. wp_add_inline_style( 'twenty-twenty-one-custom-color-overrides', '.is-dark-theme.is-dark-theme .editor-styles-wrapper { --global--color-background: var(--global--color-dark-gray); --global--color-primary: var(--global--color-light-gray); --global--color-secondary: var(--global--color-light-gray); --button--color-text: var(--global--color-background); --button--color-text-hover: var(--global--color-secondary); --button--color-text-active: var(--global--color-secondary); --button--color-background: var(--global--color-secondary); --button--color-background-active: var(--global--color-background); --global--color-border: #9ea1a7; --table--stripes-border-color: rgba(240, 240, 240, 0.15); --table--stripes-background-color: rgba(240, 240, 240, 0.15); }' ); } wp_enqueue_script( 'twentytwentyone-dark-mode-support-toggle', get_template_directory_uri() . '/assets/js/dark-mode-toggler.js', array(), '1.0.0', true ); wp_enqueue_script( 'twentytwentyone-editor-dark-mode-support', get_template_directory_uri() . '/assets/js/editor-dark-mode-support.js', array( 'twentytwentyone-dark-mode-support-toggle' ), '1.0.0', true ); } /** * Enqueue scripts and styles. * * @since Twenty Twenty-One 1.0 * * @return void */ public function enqueue_scripts() { if ( ! $this->switch_should_render() ) { return; } $url = get_template_directory_uri() . '/assets/css/style-dark-mode.css'; if ( is_rtl() ) { $url = get_template_directory_uri() . '/assets/css/style-dark-mode-rtl.css'; } wp_enqueue_style( 'tt1-dark-mode', $url, array( 'twenty-twenty-one-style' ), wp_get_theme()->get( 'Version' ) ); // @phpstan-ignore-line. Version is always a string. } /** * Enqueue scripts for the customizer. * * @since Twenty Twenty-One 1.0 * * @return void */ public function customize_controls_enqueue_scripts() { if ( ! $this->switch_should_render() ) { return; } wp_enqueue_script( 'twentytwentyone-customize-controls', get_template_directory_uri() . '/assets/js/customize.js', array( 'customize-base', 'customize-controls', 'underscore', 'jquery', 'twentytwentyone-customize-helpers' ), '1.0.0', true ); } /** * Register customizer options. * * @since Twenty Twenty-One 1.0 * * @param WP_Customize_Manager $wp_customize Theme Customizer object. * @return void */ public function customizer_controls( $wp_customize ) { $colors_section = $wp_customize->get_section( 'colors' ); if ( is_object( $colors_section ) ) { $colors_section->title = __( 'Colors & Dark Mode', 'twentytwentyone' ); } // Custom notice control. include_once get_theme_file_path( 'classes/class-twenty-twenty-one-customize-notice-control.php' ); // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound $wp_customize->add_setting( 'respect_user_color_preference_notice', array( 'capability' => 'edit_theme_options', 'default' => '', 'sanitize_callback' => '__return_empty_string', ) ); $wp_customize->add_control( new Twenty_Twenty_One_Customize_Notice_Control( $wp_customize, 'respect_user_color_preference_notice', array( 'section' => 'colors', 'priority' => 100, 'active_callback' => static function() { return 127 >= Twenty_Twenty_One_Custom_Colors::get_relative_luminance_from_hex( get_theme_mod( 'background_color', 'D1E4DD' ) ); }, ) ) ); $wp_customize->add_setting( 'respect_user_color_preference', array( 'capability' => 'edit_theme_options', 'default' => false, 'sanitize_callback' => static function( $value ) { return (bool) $value; }, ) ); $description = '

'; $description .= sprintf( /* translators: %s: Twenty Twenty-One support article URL. */ __( 'Dark Mode is a device setting. If a visitor to your site requests it, your site will be shown with a dark background and light text. Learn more about Dark Mode.', 'twentytwentyone' ), esc_url( __( 'https://wordpress.org/support/article/twenty-twenty-one/#dark-mode-support', 'twentytwentyone' ) ) ); $description .= '

'; $description .= '

' . __( 'Dark Mode can also be turned on and off with a button that you can find in the bottom corner of the page.', 'twentytwentyone' ) . '

'; $wp_customize->add_control( 'respect_user_color_preference', array( 'type' => 'checkbox', 'section' => 'colors', 'label' => esc_html__( 'Dark Mode support', 'twentytwentyone' ), 'priority' => 110, 'description' => $description, 'active_callback' => static function( $value ) { return 127 < Twenty_Twenty_One_Custom_Colors::get_relative_luminance_from_hex( get_theme_mod( 'background_color', 'D1E4DD' ) ); }, ) ); // Add partial for background_color. $wp_customize->selective_refresh->add_partial( 'background_color', array( 'selector' => '#dark-mode-toggler', 'container_inclusive' => true, 'render_callback' => function() { $attrs = ( $this->switch_should_render() ) ? array() : array( 'style' => 'display:none;' ); $this->the_html( $attrs ); }, ) ); } /** * Calculate classes for the main element. * * @since Twenty Twenty-One 1.0 * * @param string $classes The classes for element. * @return string */ public function html_classes( $classes ) { if ( ! $this->switch_should_render() ) { return $classes; } $background_color = get_theme_mod( 'background_color', 'D1E4DD' ); $should_respect_color_scheme = get_theme_mod( 'respect_user_color_preference', false ); if ( $should_respect_color_scheme && 127 <= Twenty_Twenty_One_Custom_Colors::get_relative_luminance_from_hex( $background_color ) ) { return ( $classes ) ? ' respect-color-scheme-preference' : 'respect-color-scheme-preference'; } return $classes; } /** * Adds a class to the element in the editor to accommodate dark-mode. * * @since Twenty Twenty-One 1.0 * * @param string $classes The admin body-classes. * @return string */ public function admin_body_classes( $classes ) { if ( ! $this->switch_should_render() ) { return $classes; } global $current_screen; if ( empty( $current_screen ) ) { set_current_screen(); } if ( $current_screen->is_block_editor() ) { $should_respect_color_scheme = get_theme_mod( 'respect_user_color_preference', false ); $background_color = get_theme_mod( 'background_color', 'D1E4DD' ); if ( $should_respect_color_scheme && Twenty_Twenty_One_Custom_Colors::get_relative_luminance_from_hex( $background_color ) > 127 ) { $classes .= ' twentytwentyone-supports-dark-theme'; } } return $classes; } /** * Determine if we want to print the dark-mode switch or not. * * @since Twenty Twenty-One 1.0 * * @return bool */ public function switch_should_render() { global $is_IE; return ( get_theme_mod( 'respect_user_color_preference', false ) && ! $is_IE && 127 <= Twenty_Twenty_One_Custom_Colors::get_relative_luminance_from_hex( get_theme_mod( 'background_color', 'D1E4DD' ) ) ); } /** * Add night/day switch. * * @since Twenty Twenty-One 1.0 * * @return void */ public function the_switch() { if ( ! $this->switch_should_render() ) { return; } $this->the_html(); $this->the_script(); } /** * Print the dark-mode switch HTML. * * Inspired from https://codepen.io/aaroniker/pen/KGpXZo (MIT-licensed) * * @since Twenty Twenty-One 1.0 * * @param array $attrs The attributes to add to our '; ?> '; include get_template_directory() . '/assets/js/dark-mode-toggler.js'; // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude echo ''; } /** * Adds information to the privacy policy. * * @since Twenty Twenty-One 1.0 * * @return void */ public function add_privacy_policy_content() { if ( ! function_exists( 'wp_add_privacy_policy_content' ) ) { return; } $content = '

' . __( 'Twenty Twenty-One uses LocalStorage when Dark Mode support is enabled.', 'twentytwentyone' ) . '

' . '' . __( 'Suggested text:', 'twentytwentyone' ) . ' ' . __( 'This website uses LocalStorage to save the setting when Dark Mode support is turned on or off.
LocalStorage is necessary for the setting to work and is only used when a user clicks on the Dark Mode button.
No data is saved in the database or transferred.', 'twentytwentyone' ); wp_add_privacy_policy_content( 'Twenty Twenty-One', wp_kses_post( wpautop( $content, false ) ) ); } } PK!; $QQ%class-twenty-twenty-one-customize.phpnu[get_setting( 'blogname' )->transport = 'postMessage'; // @phpstan-ignore-line. Assume that this setting exists. $wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage'; // @phpstan-ignore-line. Assume that this setting exists. // Add partial for blogname. $wp_customize->selective_refresh->add_partial( 'blogname', array( 'selector' => '.site-title', 'render_callback' => array( $this, 'partial_blogname' ), ) ); // Add partial for blogdescription. $wp_customize->selective_refresh->add_partial( 'blogdescription', array( 'selector' => '.site-description', 'render_callback' => array( $this, 'partial_blogdescription' ), ) ); // Add "display_title_and_tagline" setting for displaying the site-title & tagline. $wp_customize->add_setting( 'display_title_and_tagline', array( 'capability' => 'edit_theme_options', 'default' => true, 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ), ) ); // Add control for the "display_title_and_tagline" setting. $wp_customize->add_control( 'display_title_and_tagline', array( 'type' => 'checkbox', 'section' => 'title_tagline', 'label' => esc_html__( 'Display Site Title & Tagline', 'twentytwentyone' ), ) ); /** * Add excerpt or full text selector to customizer */ $wp_customize->add_section( 'excerpt_settings', array( 'title' => esc_html__( 'Excerpt Settings', 'twentytwentyone' ), 'priority' => 120, ) ); $wp_customize->add_setting( 'display_excerpt_or_full_post', array( 'capability' => 'edit_theme_options', 'default' => 'excerpt', 'sanitize_callback' => static function( $value ) { return 'excerpt' === $value || 'full' === $value ? $value : 'excerpt'; }, ) ); $wp_customize->add_control( 'display_excerpt_or_full_post', array( 'type' => 'radio', 'section' => 'excerpt_settings', 'label' => esc_html__( 'On Archive Pages, posts show:', 'twentytwentyone' ), 'choices' => array( 'excerpt' => esc_html__( 'Summary', 'twentytwentyone' ), 'full' => esc_html__( 'Full text', 'twentytwentyone' ), ), ) ); // Background color. // Include the custom control class. include_once get_theme_file_path( 'classes/class-twenty-twenty-one-customize-color-control.php' ); // phpcs:ignore WPThemeReview.CoreFunctionality.FileInclude.FileIncludeFound // Register the custom control. $wp_customize->register_control_type( 'Twenty_Twenty_One_Customize_Color_Control' ); // Get the palette from theme-supports. $palette = get_theme_support( 'editor-color-palette' ); // Build the colors array from theme-support. $colors = array(); if ( isset( $palette[0] ) && is_array( $palette[0] ) ) { foreach ( $palette[0] as $palette_color ) { $colors[] = $palette_color['color']; } } // Add the control. Overrides the default background-color control. $wp_customize->add_control( new Twenty_Twenty_One_Customize_Color_Control( $wp_customize, 'background_color', array( 'label' => esc_html_x( 'Background color', 'Customizer control', 'twentytwentyone' ), 'section' => 'colors', 'palette' => $colors, ) ) ); } /** * Sanitize boolean for checkbox. * * @since Twenty Twenty-One 1.0 * * @param bool $checked Whether or not a box is checked. * @return bool */ public static function sanitize_checkbox( $checked = null ) { return (bool) isset( $checked ) && true === $checked; } /** * Render the site title for the selective refresh partial. * * @since Twenty Twenty-One 1.0 * * @return void */ public function partial_blogname() { bloginfo( 'name' ); } /** * Render the site tagline for the selective refresh partial. * * @since Twenty Twenty-One 1.0 * * @return void */ public function partial_blogdescription() { bloginfo( 'description' ); } } } PK!^MM4class-twenty-twenty-one-customize-notice-control.phpnu[

custom_get_readable_color( $background_color ) . ';'; $theme_css .= '--global--color-secondary: ' . $this->custom_get_readable_color( $background_color ) . ';'; $theme_css .= '--button--color-background: ' . $this->custom_get_readable_color( $background_color ) . ';'; $theme_css .= '--button--color-text-hover: ' . $this->custom_get_readable_color( $background_color ) . ';'; if ( '#fff' === $this->custom_get_readable_color( $background_color ) ) { $theme_css .= '--table--stripes-border-color: rgba(240, 240, 240, 0.15);'; $theme_css .= '--table--stripes-background-color: rgba(240, 240, 240, 0.15);'; } } $theme_css .= '}'; return $theme_css; } /** * Customizer & frontend custom color variables. * * @since Twenty Twenty-One 1.0 * * @return void */ public function custom_color_variables() { if ( 'd1e4dd' !== strtolower( get_theme_mod( 'background_color', 'D1E4DD' ) ) ) { wp_add_inline_style( 'twenty-twenty-one-style', $this->generate_custom_color_variables() ); } } /** * Editor custom color variables. * * @since Twenty Twenty-One 1.0 * * @return void */ public function editor_custom_color_variables() { wp_enqueue_style( 'twenty-twenty-one-custom-color-overrides', get_theme_file_uri( 'assets/css/custom-color-overrides.css' ), array(), wp_get_theme()->get( 'Version' ) ); $background_color = get_theme_mod( 'background_color', 'D1E4DD' ); if ( 'd1e4dd' !== strtolower( $background_color ) ) { wp_add_inline_style( 'twenty-twenty-one-custom-color-overrides', $this->generate_custom_color_variables( 'editor' ) ); } } /** * Get luminance from a HEX color. * * @static * * @since Twenty Twenty-One 1.0 * * @param string $hex The HEX color. * @return int Returns a number (0-255). */ public static function get_relative_luminance_from_hex( $hex ) { // Remove the "#" symbol from the beginning of the color. $hex = ltrim( $hex, '#' ); // Make sure there are 6 digits for the below calculations. if ( 3 === strlen( $hex ) ) { $hex = substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) . substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) . substr( $hex, 2, 1 ) . substr( $hex, 2, 1 ); } // Get red, green, blue. $red = hexdec( substr( $hex, 0, 2 ) ); $green = hexdec( substr( $hex, 2, 2 ) ); $blue = hexdec( substr( $hex, 4, 2 ) ); // Calculate the luminance. $lum = ( 0.2126 * $red ) + ( 0.7152 * $green ) + ( 0.0722 * $blue ); return (int) round( $lum ); } /** * Adds a class to if the background-color is dark. * * @since Twenty Twenty-One 1.0 * * @param array $classes The existing body classes. * @return array */ public function body_class( $classes ) { $background_color = get_theme_mod( 'background_color', 'D1E4DD' ); $luminance = self::get_relative_luminance_from_hex( $background_color ); if ( 127 > $luminance ) { $classes[] = 'is-dark-theme'; } else { $classes[] = 'is-light-theme'; } if ( 225 <= $luminance ) { $classes[] = 'has-background-white'; } return $classes; } } PK!:j,IIclass-reports-page.phpnu[process_request(); } /** * Process request * * @since 1.0 */ public function process_request() { $action = Forminator_Core::sanitize_text_field( 'forminator_action' ); if ( ! $action ) { return; } $page = Forminator_Core::sanitize_text_field( 'page' ); // Check if the page is not the relevant. if ( 'forminator-reports' !== $page ) { return; } $id = filter_input( INPUT_POST, 'id', FILTER_VALIDATE_INT ); // Verify nonce. $nonce = Forminator_Core::sanitize_text_field( 'forminatorNonce' ); if ( ! $nonce || ! wp_verify_nonce( $nonce, 'forminator-report-action' ) ) { return; } $ids = Forminator_Core::sanitize_text_field( 'ids' ); $report_ids = ! empty( $ids ) ? explode( ',', $ids ) : array(); $form_report = Forminator_Form_Reports_Model::get_instance(); switch ( $action ) { case 'delete-report': if ( ! empty( $id ) ) { $form_report->report_delete( $id ); } break; case 'bulk-delete': if ( ! empty( $report_ids ) ) { foreach ( $report_ids as $report_id ) { $form_report->report_delete( $report_id ); } } break; case 'bulk-active': if ( ! empty( $report_ids ) ) { foreach ( $report_ids as $report_id ) { $form_report->report_update_status( $report_id, 'active' ); } } break; case 'bulk-inactive': if ( ! empty( $report_ids ) ) { foreach ( $report_ids as $report_id ) { $form_report->report_update_status( $report_id, 'inactive' ); } } break; default: break; } } /** * Get Reports data * * @param int $form_id Form Id. * @param string $form_type Form type. * @param string $start_date Start date. * @param string $end_date End date. * @param string $range_type Range type. * * @return array */ public function forminator_report_data( $form_id, $form_type, $start_date = '', $end_date = '', $range_type = '' ) { $reports = array(); $form_view = Forminator_Form_Views_Model::get_instance(); if ( ! empty( $form_id ) ) { $start_date = ! empty( $start_date ) ? $start_date : date_i18n( 'Y-m-01' ); $end_date = ! empty( $end_date ) ? $end_date : date_i18n( 'Y-m-t' ); $module_slug = $this->get_module_slug( $form_type ); $module_time = get_the_date( 'Y-m-d H:i:s', $form_id ); $previous_time = ! empty( $range_type ) ? $range_type : 'This Month'; $previous_start_date = $this->forminator_previous_time( $previous_time, $start_date, $end_date ); $previous_end_date = gmdate( 'Y-m-d', strtotime( '-1 day', strtotime( $start_date ) ) ); $reports = array( 'start_date' => $start_date, 'end_date' => $end_date, 'previous_start' => $previous_start_date, 'previous_end' => $previous_end_date, 'last_entry_time' => forminator_get_latest_entry_time_by_form_id( $form_id ), 'average_month' => self::forminator_montly_average( $module_time ), 'previous_entries' => Forminator_Form_Entry_Model::count_report_entries( $form_id, $previous_start_date, $previous_end_date ), 'selected_entries' => Forminator_Form_Entry_Model::count_report_entries( $form_id, $start_date, $end_date ), 'total_entries' => Forminator_Form_Entry_Model::count_report_entries( $form_id ), 'previous_views' => $form_view->count_views( $form_id, $previous_start_date, $previous_end_date ), 'selected_views' => $form_view->count_views( $form_id, $start_date, $end_date ), 'total_views' => $form_view->count_views( $form_id ), 'previous_payment' => 0, 'selected_payment' => 0, 'stripe_payment' => 0, 'paypal_payment' => 0, 'integration' => array(), ); if ( 'quiz' === $module_slug ) { $has_lead = false; $model = Forminator_Base_Form_Model::get_model( $form_id ); if ( is_object( $model ) && isset( $model->settings['hasLeads'] ) && $model->settings['hasLeads'] ) { $has_lead = $model->settings['hasLeads']; $reports['total_leads'] = Forminator_Form_Entry_Model::count_leads( $form_id ); $reports['selected_leads'] = Forminator_Form_Entry_Model::count_leads( $form_id, $start_date, $end_date ); $reports['previous_leads'] = Forminator_Form_Entry_Model::count_leads( $form_id, $previous_start_date, $previous_end_date ); } $reports['has_leads'] = $has_lead; } if ( self::has_live_payments( $form_id ) ) { $payment_report = $this->forminator_payment_report_data( $form_id, $start_date, $end_date, $previous_start_date, $previous_end_date ); $reports = array_merge( $reports, $payment_report ); } $connected_addons = forminator_get_addons_instance_connected_with_module( $form_id, $module_slug ); if ( ! empty( $connected_addons ) ) { $reports['integration'] = $connected_addons; } forminator_maybe_log( __METHOD__, $start_date, $end_date ); } return apply_filters( 'forminator_reports_data', $reports ); } /** * Get monthly average * * @param string $start_date Start date. * * @return mixed|void */ public static function forminator_montly_average( $start_date ) { $total_month = 0; if ( ! empty( $start_date ) ) { $start_date = strtotime( trim( $start_date ) ); $end_date = strtotime( gmdate( 'Y/m/d' ) ); $start_year = gmdate( 'Y', $start_date ); $end_year = gmdate( 'Y', $end_date ); $start_month = gmdate( 'm', $start_date ); $end_month = gmdate( 'm', $end_date ); $total_month = ( ( $end_year - $start_year ) * 12 ) + ( $end_month - $start_month ); } return apply_filters( 'forminator_reports_average_month', $total_month ); } /** * Check payment * * @param int $form_id Form Id. * * @return bool */ public static function has_live_payments( $form_id ) { $model = Forminator_Form_Entry_Model::has_live_payment( $form_id ); return $model; } /** * Check payment * * @param int $form_id Form Id. * * @return bool */ public static function has_payments( $form_id ) { $model = Forminator_Base_Form_Model::get_model( $form_id ); if ( is_object( $model ) && $model->has_stripe_or_paypal() ) { return true; } return false; } /** * Get module slug * * @param string $form_type Form type. * * @return string */ public function get_module_slug( $form_type ) { switch ( $form_type ) { case 'forminator_forms': $slug = 'form'; break; case 'forminator_polls': $slug = 'poll'; break; case 'forminator_quizzes': $slug = 'quiz'; break; default: $slug = ''; break; } return $slug; } /** * Report array * * @param array $reports Reports. * @param int $form_id Form Id. * * @return array[] */ public function forminator_report_array( $reports, $form_id ) { $report_data = array(); if ( ! empty( $reports ) ) { $selected_conversion = 0 < $reports['selected_views'] ? number_format( ( $reports['selected_entries'] * 100 ) / $reports['selected_views'], 1 ) : 0; $previous_conversion = 0 < $reports['previous_views'] ? number_format( ( $reports['previous_entries'] * 100 ) / $reports['previous_views'], 1 ) : 0; $report_data = array( 'views' => array( 'selected' => intval( $reports['selected_views'] ), 'previous' => intval( $reports['previous_views'] ), 'increment' => $this->forminator_difference_calculate( $reports['selected_views'], $reports['previous_views'] ), 'average' => 0 < $reports['average_month'] ? round( intval( $reports['total_views'] ) / intval( $reports['average_month'] ) ) : '', 'difference' => $reports['selected_views'] > $reports['previous_views'] ? 'high' : 'low', ), 'conversion' => array( 'selected' => 0 < $selected_conversion ? floatval( $selected_conversion ) . '%' : 0, 'previous' => 0 < $previous_conversion ? floatval( $previous_conversion ) . '%' : 0, 'increment' => $this->forminator_difference_calculate( $selected_conversion, $previous_conversion ), 'average' => 0 < $reports['average_month'] ? number_format( floatval( $selected_conversion ) / intval( $reports['average_month'] ), 1 ) . '%' : 0, 'difference' => $selected_conversion > $previous_conversion ? 'high' : 'low', ), 'payment' => array( 'selected' => 0 < $reports['selected_payment'] ? '$' . number_format( $reports['selected_payment'], 2 ) : 0, 'previous' => 0 < $reports['previous_payment'] ? '$' . number_format( $reports['previous_payment'], 2 ) : 0, 'stripe' => 0 < $reports['stripe_payment'] ? '$' . number_format( $reports['stripe_payment'], 2 ) : 0, 'paypal' => 0 < $reports['paypal_payment'] ? '$' . number_format( $reports['paypal_payment'], 2 ) : 0, 'increment' => 0 < $reports['selected_payment'] ? round( intval( $reports['previous_payment'] ) ) * 100 / intval( $reports['selected_payment'] ) . '%' : '', 'difference' => $reports['selected_payment'] > $reports['previous_payment'] ? 'high' : 'low', ), 'entries' => array( 'selected' => intval( $reports['selected_entries'] ), 'previous' => intval( $reports['previous_entries'] ), 'increment' => $this->forminator_difference_calculate( $reports['selected_entries'], $reports['previous_entries'] ), 'average' => 0 < $reports['average_month'] ? round( intval( $reports['total_entries'] ) / intval( $reports['average_month'] ) ) : '', 'difference' => $reports['selected_entries'] > $reports['previous_entries'] ? 'high' : 'low', ), ); if ( isset( $reports['has_leads'] ) && $reports['has_leads'] ) { $report_data['leads'] = array( 'selected' => intval( $reports['selected_leads'] ), 'previous' => intval( $reports['previous_leads'] ), 'increment' => $this->forminator_difference_calculate( $reports['selected_leads'], $reports['previous_leads'] ), 'average' => 0 < $reports['average_month'] ? round( intval( $reports['total_leads'] ) / intval( $reports['average_month'] ) ) : '', 'difference' => $reports['selected_leads'] > $reports['previous_leads'] ? 'high' : 'low', ); } if ( ! empty( $reports['integration'] ) ) { $integration_data = array(); foreach ( $reports['integration'] as $integration ) { $addon_data = $integration->to_array(); $slug = $addon_data['slug']; if ( ! empty( $integration->multi_id ) ) { $multi_id = $integration->multi_id; } elseif ( ! empty( $integration->multi_global_id ) ) { $multi_id = $integration->multi_global_id; } else { $multi_id = ''; } if ( ! empty( $multi_id ) ) { $meta_key = 'forminator_addon_' . $slug . '_status-' . $multi_id; $previous_send = Forminator_Form_Entry_Model::addons_data( $form_id, $meta_key, $reports['previous_start'], $reports['previous_end'] ); $selected_sent = Forminator_Form_Entry_Model::addons_data( $form_id, $meta_key, $reports['start_date'], $reports['end_date'] ); $integration_data[ $slug ] = array( 'title' => $addon_data['title'], 'short_title' => $addon_data['short_title'], 'image' => $addon_data['image'], 'selected' => $selected_sent, 'previous' => $previous_send, 'increment' => $this->forminator_difference_calculate( $selected_sent, $previous_send ), 'difference' => $selected_sent >= $previous_send ? 'high' : 'low', ); } } $report_data['integration'] = $integration_data; } } return $report_data; } /** * Get payment report data * * @param int $form_id Form Id. * @param string $start_date Start date. * @param string $end_date End date. * @param string $previous_start Previous start date. * @param string $previous_end Previous end date. * * @return array */ public function forminator_payment_report_data( $form_id, $start_date, $end_date, $previous_start, $previous_end ) { $payments = array( 'selected_payment' => 0, 'previous_payment' => 0, 'stripe_payment' => 0, 'paypal_payment' => 0, ); $end_date = $end_date . ' 23:59:00'; $payment_data = Forminator_Form_Entry_Model::payment_amount( $form_id, $previous_start, $end_date ); if ( ! empty( $payment_data ) ) { foreach ( $payment_data as $data ) { $meta_value = maybe_unserialize( $data->meta_value ); if ( $data->date_created >= $start_date && $data->date_created <= $end_date ) { $payments['selected_payment'] += $meta_value['amount']; if ( 'stripe-1' === $data->meta_key || 'stripe-ocs-1' === $data->meta_key ) { $payments['stripe_payment'] += $meta_value['amount']; } if ( 'paypal-1' === $data->meta_key ) { $payments['paypal_payment'] += $meta_value['amount']; } } if ( $data->date_created >= $previous_start && $data->date_created <= $previous_end ) { $payments['previous_payment'] += $meta_value['amount']; } } } return $payments; } /** * Chart data * * @param int $form_id Form Id. * @param string $start_date Start date. * @param string $end_date End date. * * @return array */ public function forminator_report_chart_data( $form_id, $start_date = '', $end_date = '' ) { $days_array = array(); $default_array = array(); if ( empty( $start_date ) ) { $start_date = gmdate( 'Y-m-01' ); } if ( empty( $end_date ) ) { $end_date = gmdate( 'Y-m-t' ); } $sdate = strtotime( $start_date ); $edate = strtotime( $end_date ); while ( $sdate <= $edate ) { $default_date = gmdate( 'Y-m-d', $sdate ); $days_array[] = gmdate( 'M j, Y', $sdate ); $default_array[ $default_date ] = 0; $sdate = strtotime( '+1 day', $sdate ); } $report_entries = Forminator_Form_Entry_Model::count_report_entries( $form_id, $start_date, $end_date ); if ( 0 === $report_entries ) { $submissions_data = $default_array; } else { $submissions = Forminator_Form_Entry_Model::get_form_latest_entries_count_grouped_by_day( $form_id, $start_date, $end_date ); $submissions_array = wp_list_pluck( $submissions, 'entries_amount', 'date_created' ); $submissions_data = array_merge( $default_array, array_intersect_key( $submissions_array, $default_array ) ); } $canvas_spacing = max( $submissions_data ) + 8; return array( 'monthDays' => $days_array, 'submissions' => $submissions_data, 'canvas_spacing' => intval( $canvas_spacing ), ); } /** * Previous Time * * @param string $time Time. * @param string $start_date Start date. * @param string $end_date End date. * * @return false|string */ public function forminator_previous_time( $time, $start_date, $end_date ) { switch ( $time ) { case 'Today': $previous_start_date = gmdate( 'Y-m-d', strtotime( '-1 day', strtotime( $start_date ) ) ); break; case 'Last 7 Days': $previous_start_date = gmdate( 'Y-m-d', strtotime( '-7 day', strtotime( $start_date ) ) ); break; case 'This Month': $previous_start_date = gmdate( 'Y-m-d', strtotime( 'first day of last month', strtotime( $start_date ) ) ); break; case 'Last 30 Days': $previous_start_date = gmdate( 'Y-m-d', strtotime( '-30 day', strtotime( $start_date ) ) ); break; case 'This Year': $previous_start_date = gmdate( 'Y-m-d', strtotime( 'last year January 1st', strtotime( $start_date ) ) ); break; case 'Custom': $datediff = strtotime( $end_date ) - strtotime( $start_date ); $total_days = round( $datediff / ( 60 * 60 * 24 ) ) + 1; $previous_days = '-' . $total_days . 'day'; $previous_start_date = gmdate( 'Y-m-d', strtotime( $previous_days, strtotime( $start_date ) ) ); break; default: $previous_start_date = ''; } return $previous_start_date; } /** * Difference_calculate * * @param int $selected Selected. * @param int $previous Previous. * * @return float|int */ public function forminator_difference_calculate( $selected, $previous ) { $percent = 0; if ( 0 < $previous && 0 < $selected ) { if ( $previous < $selected ) { // Increase percent. $percent_from = $selected - $previous; } else { // Decrease percent. $percent_from = $previous - $selected; } $percent_value = ( $percent_from * 100 ) / $previous; $percent = 0 < $percent_value ? round( $percent_from / $previous * 100 ) . '%' : 0; } return $percent; } /** * Get app link * * @param int $module_id Module Id. * @param string $module_type Module type. * * @return string|void */ public function get_app_link_module_id( $module_id, $module_type ) { switch ( $module_type ) { case 'forminator_quizzes': $quiz_model = Forminator_Base_Form_Model::get_model( $module_id ); $quiz_type = isset( $quiz_model->quiz_type ) ? $quiz_model->quiz_type : ''; $wizard_slug = 'forminator-' . $quiz_type . '-wizard'; break; case 'forminator_polls': $wizard_slug = 'forminator-poll-wizard'; break; default: $wizard_slug = 'forminator-cform-wizard'; break; } $wizard_link = admin_url( 'admin.php?page=' . $wizard_slug . '&id=' . $module_id ); return $wizard_link; } /** * Fetch Reports * * @return array|object|stdClass[]|null */ public function fetch_reports() { $form_reports = Forminator_Form_Reports_Model::get_instance(); return $form_reports->fetch_all_report(); } /** * Get total forms * * @param string $module Module type. * * @return int */ public function get_total_forms( $module ) { switch ( $module ) { case 'forms': $total = forminator_cforms_total( 'publish' ); break; case 'quizzes': $total = forminator_quizzes_total( 'publish' ); break; case 'polls': $total = forminator_polls_total( 'publish' ); break; default: $total = 0; break; } return $total; } } PK!zccclass-admin.phpnu[includes(); // Init admin pages. add_action( 'admin_menu', array( $this, 'add_dashboard_page' ) ); if ( current_user_can( 'manage_options' ) ) { add_action( 'admin_notices', array( $this, 'show_stripe_restricted_api_key_notice' ) ); add_action( 'admin_notices', array( $this, 'show_stripe_updated_notice' ) ); add_action( 'admin_notices', array( $this, 'show_rating_notice' ) ); add_action( 'admin_notices', array( $this, 'show_pro_available_notice' ) ); // Show Promote free plan notice only for Free version, for admins and if WPMU DEV Dashboard is not activated. if ( ! FORMINATOR_PRO && ! class_exists( 'WPMUDEV_Dashboard' ) // The notice was already dismissed. && ! self::was_notification_dismissed( 'forminator_promote_free_plan' ) // Remind me later was clicked. && ! self::maybe_remind_later() ) { add_action( 'admin_notices', array( $this, 'promote_free_plan' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'promote_free_plan_scripts' ) ); } add_action( 'admin_notices', array( $this, 'check_stripe_addon_version' ) ); add_action( 'admin_notices', array( $this, 'show_cf7_importer_notice' ) ); add_action( 'admin_notices', array( $this, 'show_addons_update_notice' ) ); add_action( 'admin_notices', array( $this, 'set_encryption_key_notice' ) ); } // Add plugin action links. add_filter( 'plugin_action_links_' . FORMINATOR_PLUGIN_BASENAME, array( $this, 'add_plugin_action_links' ) ); if ( forminator_is_networkwide() ) { add_filter( 'network_admin_plugin_action_links_' . FORMINATOR_PLUGIN_BASENAME, array( $this, 'add_plugin_action_links', ) ); } // Add links next to plugin details. add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 3 ); // Update permissions when user profile is updated. add_action( 'profile_update', array( $this, 'maybe_update_permissions' ), 10, 1 ); // Clear pages cache. add_action( 'save_post', array( $this, 'clear_pages_cache' ) ); add_action( 'delete_post', array( $this, 'clear_pages_cache' ) ); add_action( 'trash_post', array( $this, 'clear_pages_cache' ) ); add_action( 'untrash_post', array( $this, 'clear_pages_cache' ) ); // Init Admin AJAX class. new Forminator_Admin_AJAX(); /** * Triggered when Admin is loaded */ do_action( 'forminator_admin_loaded' ); } // ** // * Setup WPMUDEV Dashboard notifications. // * // * @return void // */ // public function init_notices() { // if ( FORMINATOR_PRO ) { // return; // } // // $install_date = get_site_option( 'forminator_free_install_date', false ); // if ( ! $install_date ) { // $install_date = time(); // } // // Notice module file. // include_once forminator_plugin_dir() . 'library/lib/free-notices/module.php'; // // Register plugin for notice. // do_action( // 'wpmudev_register_notices', // 'forminator', // array( // 'basename' => plugin_basename( FORMINATOR_PLUGIN_BASENAME ), // 'title' => 'Forminator', // 'wp_slug' => 'forminator', // 'installed_on' => $install_date, // 'screens' => array( // 'toplevel_page_forminator', // 'forminator_page_forminator-cform', // 'forminator_page_forminator-poll', // 'forminator_page_forminator-quiz', // 'forminator_page_forminator-entries', // 'forminator_page_forminator-integrations', // 'forminator_page_forminator-settings', // ), // ) // ); // } /** * Include required files * * @since 1.0 */ private function includes() { // Admin pages. include_once forminator_plugin_dir() . 'admin/pages/dashboard-page.php'; include_once forminator_plugin_dir() . 'admin/pages/entries-page.php'; include_once forminator_plugin_dir() . 'admin/pages/integrations-page.php'; include_once forminator_plugin_dir() . 'admin/pages/settings-page.php'; include_once forminator_plugin_dir() . 'admin/pages/addons-page.php'; include_once forminator_plugin_dir() . 'admin/pages/reports-page.php'; include_once forminator_plugin_dir() . 'admin/pages/templates-page.php'; // Admin AJAX. include_once forminator_plugin_dir() . 'admin/classes/class-admin-ajax.php'; // Admin Data. include_once forminator_plugin_dir() . 'admin/classes/class-admin-data.php'; // Admin l10n. include_once forminator_plugin_dir() . 'admin/classes/class-admin-l10n.php'; if ( forminator_is_import_plugin_enabled( 'cf7' ) ) { // CF7 Import. include_once forminator_plugin_dir() . 'admin/classes/thirdparty-importers/class-importer-cf7.php'; } if ( forminator_is_import_plugin_enabled( 'ninjaforms' ) ) { // Ninjaforms Import. include_once forminator_plugin_dir() . 'admin/classes/thirdparty-importers/class-importer-ninja.php'; } if ( forminator_is_import_plugin_enabled( 'gravityforms' ) ) { // Gravityforms CF7 Import. include_once forminator_plugin_dir() . 'admin/classes/thirdparty-importers/class-importer-gravity.php'; } // Admin Addons page. include_once forminator_plugin_dir() . 'admin/classes/class-addons-page.php'; // Admin report page. include_once forminator_plugin_dir() . 'admin/classes/class-reports-page.php'; } /** * Initialize Dashboard page * * @since 1.0 */ public function add_dashboard_page() { $title = esc_html__( 'Forminator', 'forminator' ); if ( FORMINATOR_PRO ) { $title = esc_html__( 'Forminator Pro', 'forminator' ); } $this->pages['forminator'] = new Forminator_Dashboard_Page( 'forminator', 'dashboard', $title, $title, false, false ); $this->pages['forminator-dashboard'] = new Forminator_Dashboard_Page( 'forminator', 'dashboard', esc_html__( 'Forminator Dashboard', 'forminator' ), esc_html__( 'Dashboard', 'forminator' ), 'forminator' ); } /** * Add Integrations page * * @since 1.1 */ public function add_integrations_page() { add_action( 'admin_menu', array( $this, 'init_integrations_page' ) ); } /** * Initialize Integrations page * * @since 1.1 */ public function init_integrations_page() { $this->pages['forminator-integrations'] = new Forminator_Integrations_Page( 'forminator-integrations', 'integrations', esc_html__( 'Integrations', 'forminator' ), esc_html__( 'Integrations', 'forminator' ), 'forminator' ); // TODO: remove this after converted to JS. $addons = Forminator_Integration_Loader::get_instance()->get_addons()->to_array(); foreach ( $addons as $slug => $addon_array ) { $addon_class = forminator_get_addon( $slug ); if ( $addon_class && is_callable( array( $addon_class, 'admin_hook_html_version' ) ) ) { call_user_func( array( $addon_class, 'admin_hook_html_version' ) ); } } } /** * Add Settings page * * @since 1.0 */ public function add_settings_page() { add_action( 'admin_menu', array( $this, 'init_settings_page' ) ); } /** * Initialize Settings page * * @since 1.0 */ public function init_settings_page() { $this->pages['forminator-settings'] = new Forminator_Settings_Page( 'forminator-settings', 'settings', esc_html__( 'Global Settings', 'forminator' ), esc_html__( 'Settings', 'forminator' ), 'forminator' ); } /** * Add Templates page * * @since 1.0 */ public function add_templates_page() { add_action( 'admin_menu', array( $this, 'init_templates_page' ) ); } /** * Initialize templates page * * @since 1.0 */ public function init_templates_page() { $section_name = esc_html__( 'Templates', 'forminator' ) . ' ' . esc_html__( 'New', 'forminator' ) . ''; $this->pages['forminator-templates'] = new Forminator_Templates_Page( 'forminator-templates', 'templates', $section_name, $section_name, 'forminator' ); } /** * Add Entries page * * @since 1.0.5 */ public function add_entries_page() { add_action( 'admin_menu', array( $this, 'init_entries_page' ) ); } /** * Initialize Entries page * * @since 1.0.5 */ public function init_entries_page() { $this->pages['forminator-entries'] = new Forminator_Entries_Page( 'forminator-entries', 'common/entries', esc_html__( 'Forminator Submissions', 'forminator' ), esc_html__( 'Submissions', 'forminator' ), 'forminator' ); } /** * Add Forminator Pro page * * @since 1.0 */ public function add_upgrade_page() { add_action( 'admin_menu', array( $this, 'init_upgrade_page' ) ); } /** * Initialize Settings page * * @since 1.0 */ public function init_upgrade_page() { add_submenu_page( 'forminator', esc_html__( 'Upgrade for 80% Off!', 'forminator' ), esc_html__( 'Upgrade for 80% Off!', 'forminator' ), forminator_get_permission( 'forminator-upgrade' ), 'https://wpmudev.com/project/forminator-pro/?utm_source=forminator&utm_medium=plugin&utm_campaign=forminator_submenu_upsell' ); } /** * Add Add-ons page * * @since 1.15 */ public function add_addons_page() { add_action( 'admin_menu', array( $this, 'init_addons_page' ) ); } /** * Initialize Add-ons page * * @since 1.15 */ public function init_addons_page() { $this->pages['forminator-addons'] = new Forminator_Addons_Page( 'forminator-addons', 'addons', esc_html__( 'Forminator Add-ons', 'forminator' ), esc_html__( 'Add-ons', 'forminator' ), 'forminator' ); } /** * Add Reports page * * @since 1.18.0 */ public function add_reports_page() { add_action( 'admin_menu', array( $this, 'init_reports_page' ) ); } /** * Initialize Reports page * * @since 1.18.0 */ public function init_reports_page() { $this->pages['forminator-reports'] = new Forminator_Reports_Page( 'forminator-reports', 'common/reports', esc_html__( 'Reports', 'forminator' ), esc_html__( 'Reports', 'forminator' ), 'forminator' ); } /** * Check if we have any old Stripe form * * @return bool * @since 1.9 */ public function has_old_stripe_forms() { $forms = Forminator_Form_Model::model()->get_models_by_field_and_version( 'stripe-1', '1.9-alpha.1' ); if ( count( $forms ) > 0 ) { return true; } return false; } /** * Displays an admin notice when the user is an active member and doesn't have Forminator Pro installed * Shown in forminator pages. Per user notification. */ public function show_pro_available_notice() { if ( ( isset( $_GET['page'] ) && 'forminator' !== substr( sanitize_text_field( wp_unslash( $_GET['page'] ) ), 0, 10 ) ) || FORMINATOR_PRO ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended return; } // The notice was already dismissed. if ( self::was_notification_dismissed( 'forminator_pro_is_available' ) ) { return; } // Show the notice only to users who can do something about this and who are members. if ( ! self::user_can_update_plugins() || ! forminator_can_install_pro() ) { return; } $url = add_query_arg( array( 'page' => 'wpmudev-plugins' ), network_admin_url( 'admin.php' ) ) . '#pid=2097296'; $link = '' . esc_html__( 'Upgrade', 'forminator' ) . ''; $username = forminator_get_current_username(); $name = ! empty( $username ) ? $username : esc_html__( 'Hey', 'forminator' ); $message = '

'; /* translators: user's name */ $message .= sprintf( esc_html__( '%s, it appears you have an active WPMU DEV membership but haven\'t upgraded Forminator to the pro version. You won\'t lose any settings upgrading, go for it!', 'forminator' ), $name ); $message .= '

'; $message .= '

' . $link . '

'; echo '
'; echo wp_kses_post( $message ); echo '
'; } /** * Enqueue scripts for Promote Free Plan notice */ public function promote_free_plan_scripts() { // Show the notice only on WP Dashboard page. $screen = get_current_screen(); if ( 'dashboard' !== $screen->id ) { return; } $dashboard_object = $this->pages['forminator-dashboard']; $dashboard_object->enqueue_scripts( '' ); } /** * Displays Promote Free Plan notice */ public function promote_free_plan() { // Show the notice only on WP Dashboard page. $screen = get_current_screen(); if ( 'dashboard' !== $screen->id ) { return; } $button_1 = '' . esc_html__( 'Connect to Unlock Cloud Templates', 'forminator' ) . ''; $remind = '' . esc_html__( 'Remind me later', 'forminator' ) . ''; $message = '

'; $message .= esc_html__( 'Free Cloud Templates—Build Forms Across All Your Sites in 1 Click!', 'forminator' ); $message .= '

'; $message .= '

'; $message .= sprintf( /* translators: %1$s - opening tag, %2$s - closing tag */ esc_html__( 'Say goodbye to manual exports! Now, %1$sForminator Hub%2$s users get FREE access to %1$sCloud Templates%2$s—instantly reuse your custom forms on any connected WordPress site.', 'forminator' ), '', '' ); $message .= '

'; $message .= '

'; $message .= esc_html__( 'Plus, unlock WPMU DEV’s full suite of tools trusted by 50K+ developers.', 'forminator' ); $message .= ' ' . esc_html__( 'Completely free.', 'forminator' ) . ''; $message .= '

'; $message .= '

' . $button_1 . ' ' . $remind . '

'; echo '
'; echo wp_kses_post( $message ); echo '
'; $dashboard_object = $this->pages['forminator-dashboard']; echo '
'; echo '
'; $dashboard_object->template( 'dashboard/promote-free-plan' ); echo '
'; echo '
'; } /** * Displays an admin notice when Forminator version is 1.16.0 or higher and Stripe Addon version is less than 1.0.4 * Shown in forminator pages. Per user notification. */ public function check_stripe_addon_version() { $min_stripe_addon_version = '1.3.0'; // Show the notice only if Stripe Addon is active and its version is less than 1.0.4. if ( ! defined( 'FORMINATOR_STRIPE_ADDON' ) || ! class_exists( 'Forminator_Stripe_Addon' ) || version_compare( FORMINATOR_STRIPE_ADDON, $min_stripe_addon_version, '>=' ) ) { return; } // Show the notice only for administrators. if ( ! current_user_can( 'manage_options' ) ) { return; } $message = '

'; /* translators: 1. Forminator version. 2. Min Stripe addon version. */ $message .= sprintf( esc_html__( 'We\'ve noticed you have updated to Forminator Pro version %1$s. Please ensure you also update your Forminator Stripe Subscriptions Add-on to version %2$s or higher to ensure compatibility with the new submissions processes.', 'forminator' ), FORMINATOR_VERSION, $min_stripe_addon_version ); $message .= '

'; echo '
'; echo wp_kses_post( $message ); echo '
'; } /** * Check if the given notification was dismissed. * * @param string $notification_name Notification slug. * * @return bool */ public static function was_notification_dismissed( $notification_name ) { $dismissed = get_user_meta( get_current_user_id(), 'frmt_dismissed_messages', true ); return ( is_array( $dismissed ) && in_array( $notification_name, $dismissed, true ) ); } /** * Return true if Remind me later was clicked * * @return bool */ private static function maybe_remind_later() { $option = get_transient( 'forminator_free_plan_remind_later_' . get_current_user_id() ); return (bool) $option; } /** * Check if the current user is able to update plugins * * @return bool */ public static function user_can_update_plugins() { $cap = is_multisite() ? 'manage_network_plugins' : 'update_plugins'; return current_user_can( $cap ); } /** * Show CF7 importer notice * * @since 1.11 */ public function show_cf7_importer_notice() { $notice_dismissed = get_option( 'forminator_cf7_notice_dismissed', false ); if ( $notice_dismissed ) { return; } if ( ! forminator_is_import_plugin_enabled( 'cf7' ) ) { return; } ?>

has_old_stripe_forms() ) { return; } ?>

tag with link to stripe SCA Compliant, 2. closing tag. */ esc_html__( 'To make Forminator\'s Stripe field %1$sSCA Compliant%2$s, we have replaced the Stripe Checkout modal with Stripe Elements which adds an inline field to collect your customer\'s credit or debit card details. Your existing forms with Stripe field are automatically updated, but we recommend checking them to ensure everything works fine.', 'forminator' ), '', '' ); ?>

tag, 2. closing tag, 3. Opening tag with link to payments settings section, 4. closing tag, 5. Opening tag with link Stripe API key, 6. closing tag. */ esc_html__( '%1$sStripe API Notice:%2$s You are currently using the deprecated Stripe Secret key in your %3$sForminator Stripe integration%4$s. We recommend switching to the Restricted API key (RAK) instead. %5$sLearn More%6$s.', 'forminator' ), '', '', '', '', '', '' ); ?>

tag with link to documentation, 2. Closing tag. */ esc_html__( 'For more information, %1$ssee our documentation%2$s.', 'forminator' ), '', '' ); ?>

tag. 2. Closing ', '', 'FORMINATOR_ENCRYPTION_KEY', 'wp-config.php' ); ?>

FORMINATOR_ENCRYPTION_KEY', 'wp-config.php' ); ?>

define( \'FORMINATOR_ENCRYPTION_KEY\', \'' . esc_html( Forminator_Encryption::generate_encryption_key() ) . '\' );' ); ?>

= $published_modules ) && ! $publish_later ) || ( 10 < $published_modules && ! $publish_later_dismiss ) ) { $milestone = ( 10 >= $published_modules ) ? 5 : 10; ?>

strtotime( '+7 days', $install_date ) && ! $publish_later && ! $publish_later_dismiss && ! $days_later_dismiss ) { ?>

' . esc_html__( 'Dashboard', 'forminator' ) . ''; } // Documentation link. $action_links['docs'] = '' . esc_html__( 'Docs', 'forminator' ) . ''; // Check if the current logged-in member has access Forminator Pro. $can_install_pro = forminator_can_install_pro(); $membership_type = forminator_get_wpmudev_membership(); // Upgrade or Renew links. if ( ! FORMINATOR_PRO ) { if ( $can_install_pro ) { $action_links['upgrade'] = '' . esc_html__( 'Upgrade', 'forminator' ) . ''; } else { $action_links['renew'] = '' . esc_html__( 'Upgrade For 80% Off!', 'forminator' ) . ''; } } elseif ( in_array( $membership_type, array( 'expired', 'free', 'paused', '' ), true ) && ! $can_install_pro ) { $action_links['renew'] = '' . esc_html__( 'Renew Membership', 'forminator' ) . ''; } return array_merge( $action_links, $links ); } /** * Show row meta on the plugin screen. * * @param mixed $links Plugin Row Meta. * @param mixed $file Plugin Base file. * @param array $plugin_data Plugin data. * * @return array * @since 1.13 */ public function plugin_row_meta( $links, $file, $plugin_data ) { if ( FORMINATOR_PLUGIN_BASENAME === $file ) { // Show network meta links only when activated network wide. if ( is_network_admin() && ! forminator_is_networkwide() ) { return $links; } // Change AuthorURI link. if ( isset( $links[1] ) ) { $author_uri = FORMINATOR_PRO ? 'https://wpmudev.com/' : 'https://profiles.wordpress.org/wpmudev/'; $author_uri = sprintf( '%s', $author_uri, esc_html__( 'WPMU DEV', 'forminator' ) ); $links[1] = /* translators: %s: Authorise url. */ sprintf( esc_html__( 'By %s', 'forminator' ), $author_uri ); } if ( ! FORMINATOR_PRO ) { // Change AuthorURI link. if ( isset( $links[2] ) && false === strpos( $links[2], 'target="_blank"' ) ) { if ( ! isset( $plugin_data['slug'] ) && $plugin_data['Name'] ) { $links[2] = sprintf( '%s', esc_url( network_admin_url( 'plugin-install.php?tab=plugin-information&plugin=forminator' . '&TB_iframe=true&width=600&height=550' ) ), /* translators: %s: Plugin name. */ sprintf( esc_html__( 'More information about %s', 'forminator' ), $plugin_data['Name'] ), esc_attr( $plugin_data['Name'] ), esc_html__( 'View details', 'forminator' ) ); } else { $links[2] = str_replace( 'href=', 'target="_blank" href=', $links[2] ); } } $row_meta['rate'] = '' . esc_html__( 'Rate Forminator', 'forminator' ) . ''; $row_meta['support'] = '' . esc_html__( 'Support', 'forminator' ) . ''; } else { // Change 'Visit plugins' link to 'View details'. if ( isset( $links[2] ) && false !== strpos( $links[2], 'project/forminator' ) ) { $links[2] = sprintf( '%s', esc_url( forminator_get_link( 'pro_link', '', 'project/forminator-pro/' ) ), esc_html__( 'View details', 'forminator' ) ); } $row_meta['support'] = '' . esc_html__( 'Premium Support', 'forminator' ) . ''; } $row_meta['roadmap'] = '' . esc_html__( 'Roadmap', 'forminator' ) . ''; return array_merge( $links, $row_meta ); } return $links; } /** * Show addons update notice */ public function show_addons_update_notice() { if ( ! FORMINATOR_PRO || 'forminator-addons' === filter_input( INPUT_GET, 'page' ) ) { return; } $version = ''; $addons = $this->pages['forminator-addons']->get_addons_by_action(); if ( empty( $addons['update'] ) ) { return; } foreach ( $addons['update'] as $update ) { $version .= $update->version_latest . '_'; } $notice_dismissed = get_option( 'forminator_addons_update_' . $version . 'dismiss', false ); if ( $notice_dismissed ) { return; } $notice_later = get_option( 'forminator_addons_update_' . $version . 'later', false ); if ( $notice_later && current_time( 'timestamp' ) < strtotime( '+7 days', $notice_later ) ) { // phpcs:ignore WordPress.DateTime.CurrentTimeTimestamp.Requested -- We are using the current timestamp based on the site's timezone. return; } ?>

$permission ) { /** * For specific users. * - Add caps to the users * - Check each permission for get_avatar then retrieve it. */ if ( 'specific' === $permission['permission_type'] ) { foreach ( $permission['specific_user'] as $user_index => $user_id ) { $user = get_user_by( 'ID', $user_id ); if ( false !== $user ) { // Set user info. $permissions[ $key ]['user_info'][ $user_id ]['name'] = $user->display_name; $permissions[ $key ]['user_info'][ $user_id ]['email'] = $user->user_email; // We only need avatar for first user. if ( 0 === $user_index ) { $permissions[ $key ]['avatar'] = get_avatar_url( $user->user_email, array( 'size' => 30 ) ); } } } /** * For roles. * - Add caps to users under these roles. */ } else { if ( empty( $permission['exclude_users'] ) ) { continue; } // Set user info for excluded users. foreach ( $permission['exclude_users'] as $user_id ) { $user = get_user_by( 'ID', $user_id ); if ( false !== $user ) { $permissions[ $key ]['user_info'][ $user_id ]['name'] = $user->display_name; $permissions[ $key ]['user_info'][ $user_id ]['email'] = $user->user_email; } } } } update_option( 'forminator_permissions', $permissions ); } /** * Get error notice * * @param string $error Error message. It should be already escaped. * @return string */ public static function get_red_notice( string $error ): string { return static::get_notice( 'error', $error ); } /** * Get success notice * * @param string $message Success message. It should be already escaped. * @return string */ public static function get_green_notice( string $message ): string { return static::get_notice( 'green', $message ); } /** * Get SUI notice * * @param string $type Notice type. * @param string $message Message. It should be already escaped. * @return string */ public static function get_notice( string $type, string $message ): string { $notice_class = 'green' === $type ? 'sui-notice-green' : 'sui-notice-red'; $icon_class = 'green' === $type ? 'sui-icon-check-tick' : 'sui-icon-info'; return ''; } /** * Clear pages cache * * @param int|null $post_id Post ID. */ public static function clear_pages_cache( int $post_id = null ) { if ( ! is_null( $post_id ) && 'page' === get_post_type( $post_id ) ) { wp_cache_delete( 'forminator_cached_pages', 'forminator-cache' ); } } } PK!r>>class-admin-ajax.phpnu[get_post_data(); $quiz_data = array(); // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Verified in forminator_validate_ajax. if ( ! empty( $_POST['data'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput -- Sanitized in Forminator_Core::sanitize_array. $quiz_data = Forminator_Core::sanitize_array( json_decode( wp_unslash( $_POST['data'] ), true ) ); } $id = isset( $submitted_data['form_id'] ) ? intval( $submitted_data['form_id'] ) : 0; $settings = isset( $quiz_data['settings'] ) ? $quiz_data['settings'] : array(); $title = isset( $submitted_data['quiz_title'] ) ? $submitted_data['quiz_title'] : $submitted_data['formName']; $status = isset( $submitted_data['status'] ) ? $submitted_data['status'] : ''; $version = isset( $submitted_data['version'] ) ? $submitted_data['version'] : '1.0'; $template = new stdClass(); $template->type = isset( $submitted_data['action'] ) ? $submitted_data['action'] : ''; // Check if results exist. if ( isset( $quiz_data['results'] ) && is_array( $quiz_data['results'] ) ) { $template->results = $quiz_data['results']; } // Check if answers exist. if ( isset( $quiz_data['questions'] ) ) { $template->questions = $quiz_data['questions']; } if ( isset( $quiz_data['settings'] ) ) { $settings = $quiz_data['settings']; } $settings['version'] = $version; $template->settings = $settings; if ( isset( $quiz_data['notifications'] ) ) { $template->notifications = $quiz_data['notifications']; } $id = Forminator_Quiz_Admin::update( $id, $title, $status, $template ); if ( is_wp_error( $id ) ) { wp_send_json_error( $id->get_error_message() ); } else { wp_send_json_success( $id ); } } /** * Save poll * * @since 1.0 * @since 1.1 change superglobal POST to `get_post_data` */ public function save_poll_form() { if ( ! forminator_is_user_allowed( 'forminator-poll' ) ) { wp_send_json_error( esc_html__( 'Invalid request, you are not allowed to do that action.', 'forminator' ) ); } forminator_validate_ajax( 'forminator_save_poll', false, 'forminator-poll' ); $submitted_data = $this->get_post_data(); $poll_data = array(); // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Verified in forminator_validate_ajax. if ( ! empty( $_POST['data'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput -- Sanitized in Forminator_Core::sanitize_array. $poll_data = Forminator_Core::sanitize_array( json_decode( wp_unslash( $_POST['data'] ), true ) ); } $settings = isset( $poll_data['settings'] ) ? $poll_data['settings'] : array(); $id = isset( $submitted_data['form_id'] ) ? intval( $submitted_data['form_id'] ) : 0; $title = $submitted_data['formName']; $status = isset( $submitted_data['status'] ) ? $submitted_data['status'] : ''; $version = isset( $submitted_data['version'] ) ? $submitted_data['version'] : '1.0'; $template = new stdClass(); if ( isset( $poll_data['answers'] ) ) { $template->answers = $poll_data['answers']; } $settings['version'] = $version; $template->settings = $settings; $id = Forminator_Poll_Admin::update( $id, $title, $status, $template ); if ( is_wp_error( $id ) ) { wp_send_json_error( $id->get_error_message() ); } else { wp_send_json_success( $id ); } } /** * Save custom form fields * * @since 1.2 */ public function save_builder() { if ( ! forminator_is_user_allowed( 'forminator-cform' ) ) { wp_send_json_error( esc_html__( 'Invalid request, you are not allowed to do that action.', 'forminator' ) ); } forminator_validate_ajax( 'forminator_save_builder_fields', false, 'forminator-cform' ); $submitted_data = $this->get_post_data(); $form_data = array(); $fields = array(); $id = isset( $submitted_data['form_id'] ) ? intval( $submitted_data['form_id'] ) : 0; $title = $submitted_data['formName']; $status = isset( $submitted_data['status'] ) ? $submitted_data['status'] : ''; $version = isset( $submitted_data['version'] ) ? $submitted_data['version'] : '1.0'; $template = new stdClass(); $action = ''; // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Verified in forminator_validate_ajax. if ( ! empty( $_POST['data'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput -- Sanitized in Forminator_Core::sanitize_array. $form_data = Forminator_Core::sanitize_array( json_decode( wp_unslash( $_POST['data'] ), true ) ); } if ( is_null( $id ) || $id <= 0 ) { $form_model = new Forminator_Form_Model(); $action = 'create'; if ( empty( $status ) ) { $status = Forminator_Form_Model::STATUS_PUBLISH; } } else { $form_model = Forminator_Base_Form_Model::get_model( $id ); $action = 'update'; if ( ! is_object( $form_model ) ) { wp_send_json_error( esc_html__( 'Form model doesn\'t exist', 'forminator' ) ); } if ( empty( $status ) ) { $status = $form_model->status; } // we need to empty fields cause we will send new data. $form_model->clear_fields(); } // Build the fields. if ( isset( $form_data ) ) { $fields = $form_data['wrappers']; unset( $form_data['wrappers'] ); } $template->fields = $fields; if ( isset( $form_data['integrationConditions'] ) ) { $template->integration_conditions = $form_data['integrationConditions']; } if ( isset( $form_data['behaviorArray'] ) ) { $template->behaviors = $form_data['behaviorArray']; } if ( isset( $form_data['notifications'] ) ) { $template->notifications = $form_data['notifications']; } // Sanitize settings. $settings = $form_data['settings']; $activation_method = ! empty( $settings['activation-method'] ) ? $settings['activation-method'] : ''; if ( 'manual' === $activation_method ) { $settings['automatic-login'] = ''; } if ( isset( $settings['fields-style'] ) && 'custom' === $settings['fields-style'] ) { $settings['spacing'] = ! empty( $settings['spacing'] ) ? $settings['spacing'] : 0; } $settings['version'] = $version; $template->settings = $settings; $id = Forminator_Custom_Form_Admin::update( $id, $title, $status, $template ); if ( is_wp_error( $id ) ) { wp_send_json_error( $id ); } else { wp_send_json_success( $id ); } } /** * Save PDF * * @since 2.0 * @throws Exception When failed to create PDF. */ public function save_pdf() { if ( ! forminator_is_user_allowed( 'forminator-cform' ) ) { wp_send_json_error( esc_html__( 'Invalid request, you are not allowed to do that action.', 'forminator' ) ); } forminator_validate_ajax( 'forminator_save_builder_fields', false, 'forminator-cform' ); try { $submitted_data = $this->get_post_data(); if ( ! class_exists( 'Forminator_PDF_Form_Actions' ) ) { throw new Exception( esc_html__( 'PDF add-on is not installed.', 'forminator' ) ); } $pdf_data['pdf_id'] = Forminator_PDF_Form_Actions::create_new_pdf_form( $submitted_data ); if ( empty( $pdf_data['pdf_id'] ) || ! is_numeric( $pdf_data['pdf_id'] ) ) { throw new Exception( esc_html__( 'Failed to create PDF. Please try again.', 'forminator' ) ); } wp_send_json_success( $pdf_data ); } catch ( Exception $e ) { wp_send_json_error( $e->getMessage() ); } } /** * Deleta a PDF * * @since 2.0 * @throws Exception When failed to delete PDF. */ public function delete_pdf() { if ( ! forminator_is_user_allowed( 'forminator-cform' ) ) { wp_send_json_error( esc_html__( 'Invalid request, you are not allowed to do that action.', 'forminator' ) ); } forminator_validate_ajax( 'forminator_save_builder_fields', false, 'forminator-cform' ); try { $pdf_data = $this->get_post_data(); if ( ! isset( $pdf_data['pdfId'] ) || empty( $pdf_data['pdfId'] ) ) { throw new Exception( esc_html__( 'PDF not found.', 'forminator' ) ); } Forminator_API::delete_form( $pdf_data['pdfId'] ); wp_send_json_success( $pdf_data['pdfId'] ); } catch ( Exception $e ) { wp_send_json_error( $e->getMessage() ); } } /** * Fetch PDF files * * @since 2.0 * @throws Exception When failed to fetch PDF. */ public function fetch_pdfs() { if ( ! forminator_is_user_allowed( 'forminator-cform' ) ) { wp_send_json_error( esc_html__( 'Invalid request, you are not allowed to do that action.', 'forminator' ) ); } forminator_validate_ajax( 'forminator_save_builder_fields', false, 'forminator-cform' ); try { $submitted_data = $this->get_post_data(); $pdfs = Forminator_API::get_forms( null, 1, 999, 'pdf_form', $submitted_data['parent_form_id'] ); if ( is_wp_error( $pdfs ) || ! is_array( $pdfs ) ) { throw new Exception( esc_html__( 'Forminator encountered an error while fetching the PDF files.', 'forminator' ) ); } wp_send_json_success( $pdfs ); } catch ( Exception $e ) { wp_send_json_error( $e->getMessage() ); } } /** * Save custom form settings * * @since 1.2 */ public function save_builder_settings() { _deprecated_function( 'save_builder_settings', '1.6', 'save_builder' ); if ( ! current_user_can( forminator_get_permission( 'forminator-cform' ) ) ) { return; } forminator_validate_ajax( 'forminator_save_builder_fields', false, 'forminator-cform' ); $submitted_data = $this->get_post_data(); $id = isset( $submitted_data['form_id'] ) ? intval( $submitted_data['form_id'] ) : 0; $title = $submitted_data['formName']; $status = isset( $submitted_data['status'] ) ? $submitted_data['status'] : ''; $version = isset( $submitted_data['version'] ) ? $submitted_data['version'] : '1.0'; if ( is_null( $id ) || $id <= 0 ) { $form_model = new Forminator_Form_Model(); if ( empty( $status ) ) { $status = Forminator_Form_Model::STATUS_PUBLISH; } } else { $form_model = Forminator_Base_Form_Model::get_model( $id ); if ( ! is_object( $form_model ) ) { wp_send_json_error( esc_html__( "Form model doesn't exist", 'forminator' ) ); } if ( empty( $status ) ) { $status = $form_model->status; } } $form_model->set_var_in_array( 'name', 'formName', $submitted_data, 'forminator_sanitize_field' ); $settings = $submitted_data['data']; $settings['formName'] = $title; $settings['version'] = $version; $form_model->settings = $settings; // status. $form_model->status = $status; // Save data. $id = $form_model->save(); if ( is_wp_error( $id ) ) { wp_send_json_error( $id->get_error_message() ); } // add privacy settings to global option. $override_privacy = false; if ( isset( $settings['enable-submissions-retention'] ) ) { $override_privacy = filter_var( $settings['enable-submissions-retention'], FILTER_VALIDATE_BOOLEAN ); } $retention_number = null; $retention_unit = null; if ( $override_privacy ) { $retention_number = 0; $retention_unit = 'days'; if ( isset( $settings['submissions-retention-number'] ) ) { $retention_number = (int) $settings['submissions-retention-number']; } if ( isset( $settings['submissions-retention-unit'] ) ) { $retention_unit = $settings['submissions-retention-unit']; } } forminator_update_form_submissions_retention( $id, $retention_number, $retention_unit ); wp_send_json_success( $id ); } /** * Apply Appearance Preset ajax. */ public function apply_appearance_preset() { forminator_validate_ajax( 'forminator_apply_preset', false, 'forminator-cform' ); $preset_id = Forminator_Core::sanitize_text_field( 'preset_id' ); $ids = filter_input( INPUT_POST, 'ids', FILTER_VALIDATE_INT, FILTER_REQUIRE_ARRAY ); $edit_form = filter_input( INPUT_POST, 'edit_form', FILTER_VALIDATE_BOOLEAN ); $count = 0; $new_settings = Forminator_Settings_Page::get_preset( $preset_id ); if ( $ids ) { foreach ( $ids as $form_id ) { $form_model = Forminator_Base_Form_Model::get_model( $form_id ); if ( ! $form_model ) { continue; } $form_model->settings = self::merge_appearance_settings( $form_model->settings, $new_settings ); if ( $edit_form ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput -- Sanitized in Forminator_Core::sanitize_array. $settings = isset( $_POST['settings'] ) ? Forminator_Core::sanitize_array( $_POST['settings'] ) : array(); $old_settings = json_decode( wp_unslash( $settings ), true ); if ( $old_settings ) { $form_model->settings = self::merge_appearance_settings( $old_settings, $new_settings ); } wp_send_json_success( $form_model->settings ); } // Save data. $result = $form_model->save(); if ( ! is_wp_error( $result ) ) { // Regenerare module css file. Forminator_Render_Form::regenerate_css_file( $form_id ); ++$count; } } } if ( $edit_form ) { wp_send_json_error( esc_html__( 'Something went wrong.', 'forminator' ) ); } /* translators: %s: Form count */ $success = sprintf( esc_html__( 'Preset successfully applied to %d form(s).', 'forminator' ), $count ); wp_send_json_success( $success ); } /** * Merge Appearance settings * * @param array $settings Current Settings. * @param array $new_settings New Appearance settings. * * @return array */ private function merge_appearance_settings( $settings, $new_settings ) { $appearance_settings = Forminator_Settings_Page::only_appearance_settings( $settings ); $rest_settings = array(); foreach ( $settings as $key => $val ) { if ( ! array_key_exists( $key, $appearance_settings ) ) { $rest_settings[ $key ] = $val; } } $new_settings = array_merge( $rest_settings, $new_settings ); return $new_settings; } /** * Create Appearance Preset ajax. */ public function create_appearance_preset() { forminator_validate_ajax( 'forminator_create_preset', false, 'forminator-settings' ); $id = uniqid(); $settings = array(); $form_id = filter_input( INPUT_POST, 'form_id', FILTER_VALIDATE_INT ); $name = Forminator_Core::sanitize_text_field( 'name' ); if ( empty( $name ) ) { wp_send_json_error( esc_html__( 'Preset Name is empty.', 'forminator' ) ); } if ( ! empty( $form_id ) ) { $form = Forminator_Base_Form_Model::get_model( $form_id ); $settings = $form->settings; } // Update preset list. Forminator_Settings_Page::save_preset_list( $id, $name ); // Save preset. self::save_preset( $id, $settings ); wp_send_json_success( $id ); } /** * Delete Appearance Preset ajax. */ public function delete_appearance_preset() { forminator_validate_ajax( 'forminator_appearance_preset', false, 'forminator-settings' ); $id = Forminator_Core::sanitize_text_field( 'preset_id' ); if ( empty( $id ) ) { wp_send_json_error( esc_html__( 'Preset ID is empty.', 'forminator' ) ); } if ( 'default' === $id ) { wp_send_json_error( esc_html__( 'Preset ID is incorrect.', 'forminator' ) ); } // Delete preset from list. $key = 'forminator_appearance_presets'; $preset_names = get_option( $key, array() ); unset( $preset_names[ $id ] ); update_option( $key, $preset_names ); // Delete preset. delete_option( 'forminator_appearance_preset_' . $id ); wp_send_json_success(); } /** * Save Appearance Preset ajax. */ public function save_appearance_preset() { forminator_validate_ajax( 'forminator_appearance_preset', false, 'forminator-settings' ); $id = Forminator_Core::sanitize_text_field( 'presetId' ); if ( ! $id ) { wp_send_json_error( esc_html__( 'Appearance preset id doesn\'t exist', 'forminator' ) ); } $settings = array(); // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Verified in forminator_validate_ajax. if ( ! empty( $_POST['settings'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput -- Sanitized in Forminator_Core::sanitize_array. $settings = Forminator_Core::sanitize_array( json_decode( wp_unslash( $_POST['settings'] ), true ) ); } self::save_preset( $id, $settings ); wp_send_json_success( esc_html__( 'The preset has been successfully updated.', 'forminator' ) ); } /** * Save Appearance Preset * * @param string $id ID. * @param array $settings Settings. */ private static function save_preset( $id, $settings ) { update_option( 'forminator_appearance_preset_' . $id, $settings ); } /** * Dismiss welcome message * * @since 1.0 */ public function dismiss_welcome() { forminator_validate_ajax( 'forminator_dismiss_welcome' ); update_option( 'forminator_welcome_dismissed', true ); wp_send_json_success(); } /** * Set encryption key */ public function set_encryption_key() { forminator_validate_ajax( 'forminator_set_encryption_key' ); try { $config_content = self::prepare_new_wp_config(); $config_file = self::get_wp_config_file_path(); global $wp_filesystem; // Write the modified content back to wp-config.php. return $wp_filesystem->put_contents( $config_file, $config_content, FS_CHMOD_FILE ); } catch ( Exception $e ) { wp_send_json_error( $e->getMessage() ); } wp_send_json_success(); } /** * Get full path to wp-config.php file. * * @return string */ public static function get_wp_config_file_path(): string { $path = ABSPATH . 'wp-config.php'; if ( ! file_exists( ABSPATH . 'wp-config.php' ) && file_exists( dirname( ABSPATH ) . '/wp-config.php' ) && ! file_exists( dirname( ABSPATH ) . '/wp-settings.php' ) ) { $path = dirname( ABSPATH ) . '/wp-config.php'; } return apply_filters( 'forminator_wp_config_file_path', $path ); } /** * Prepare new wp-config.php content * * @return string * @throws Exception Throws exception if failed to prepare new wp-config.php content. */ public static function prepare_new_wp_config() { // Check if current user can write to files. if ( ! current_user_can( 'manage_options' ) ) { throw new Exception( esc_html__( 'You do not have permission to write to the wp-config.php file.', 'forminator' ) ); } global $wp_filesystem; // Ensure we have the WP_Filesystem initialized. if ( is_null( $wp_filesystem ) && ! function_exists( 'WP_Filesystem' ) ) { require_once ABSPATH . 'wp-admin/includes/file.php'; } WP_Filesystem(); if ( ! $wp_filesystem instanceof WP_Filesystem_Base ) { throw new Exception( esc_html__( 'Unable to initialize WP_Filesystem.', 'forminator' ) ); } // Get the path to wp-config.php. $config_file = self::get_wp_config_file_path(); // Check if the file exists. if ( ! $wp_filesystem->exists( $config_file ) ) { throw new Exception( esc_html__( 'wp-config.php file not found.', 'forminator' ) ); } // Read the wp-config.php content. $config_content = $wp_filesystem->get_contents( $config_file ); if ( ! $config_content ) { throw new Exception( esc_html__( 'Unable to read wp-config.php file content.', 'forminator' ) ); } // Check if the constant already exists. if ( strpos( $config_content, 'FORMINATOR_ENCRYPTION_KEY' ) !== false ) { throw new Exception( esc_html__( 'FORMINATOR_ENCRYPTION_KEY constant already exists.', 'forminator' ) ); } $secret = Forminator_Encryption::generate_encryption_key(); $new_constant = sprintf( "define( 'FORMINATOR_ENCRYPTION_KEY', '%s' );%s", $secret, PHP_EOL ); // Append the new constant before the line that says "That's all, stop editing!". $wp_comment = "/* That's all, stop editing! Happy blogging. */"; $new_content = str_replace( $wp_comment, $new_constant . "\n\n$wp_comment", $config_content ); if ( $new_content === $config_content ) { $wp_comment = "/* That's all, stop editing! Happy publishing. */"; $new_content = str_replace( $wp_comment, $new_constant . "\n\n$wp_comment", $config_content ); if ( $new_content === $config_content ) { throw new Exception( esc_html__( 'WP config file does not have the expected content.', 'forminator' ) ); } } return $new_content; } /** * Check if we can write to wp-config.php file * * @return bool */ public static function can_write_to_wp_config(): bool { try { self::prepare_new_wp_config(); } catch ( Exception $e ) { return false; } return true; } /** * Load google fonts * * @since 1.0.5 */ public function load_google_fonts() { forminator_validate_ajax( 'forminator_load_google_fonts', false, 'forminator' ); // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Verified in forminator_validate_ajax. $is_object = isset( $_POST['data']['isObject'] ) ? sanitize_text_field( wp_unslash( $_POST['data']['isObject'] ) ) : false; $fonts = forminator_get_font_families( $is_object ); wp_send_json_success( $fonts ); } /** * Load reCaptcha settings * * @since 1.0 */ public function load_captcha() { // Validate nonce. forminator_validate_ajax( 'forminator_popup_captcha', false, 'forminator-settings' ); $html = forminator_template( 'settings/popup/edit-captcha-content' ); wp_send_json_success( $html ); } /** * Save reCaptcha popup data * * @since 1.0 */ public function save_captcha() { // Validate nonce. forminator_validate_ajax( 'forminator_save_popup_captcha', false, 'forminator-settings' ); update_option( 'forminator_captcha_key', Forminator_Core::sanitize_text_field( 'v2_captcha_key' ) ); update_option( 'forminator_captcha_secret', Forminator_Core::sanitize_text_field( 'v2_captcha_secret' ) ); update_option( 'forminator_v2_invisible_captcha_key', Forminator_Core::sanitize_text_field( 'v2_invisible_captcha_key' ) ); update_option( 'forminator_v2_invisible_captcha_secret', Forminator_Core::sanitize_text_field( 'v2_invisible_captcha_secret' ) ); update_option( 'forminator_v3_captcha_key', Forminator_Core::sanitize_text_field( 'v3_captcha_key' ) ); update_option( 'forminator_v3_captcha_secret', Forminator_Core::sanitize_text_field( 'v3_captcha_secret' ) ); $hcaptcha_key = ''; if ( isset( $_POST['hcaptcha_key'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Verified in forminator_validate_ajax. // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Verified in forminator_validate_ajax. $hcaptcha_key = sanitize_text_field( wp_unslash( $_POST['hcaptcha_key'] ) ); } $hcaptcha_secret = ''; if ( isset( $_POST['hcaptcha_secret'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Verified in forminator_validate_ajax. // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Verified in forminator_validate_ajax. $hcaptcha_secret = sanitize_text_field( wp_unslash( $_POST['hcaptcha_secret'] ) ); } $captcha_tab_saved = ''; if ( isset( $_POST['captcha_tab_saved'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Verified in forminator_validate_ajax. // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Verified in forminator_validate_ajax. $captcha_tab_saved = sanitize_text_field( wp_unslash( $_POST['captcha_tab_saved'] ) ); } update_option( 'forminator_hcaptcha_key', $hcaptcha_key ); update_option( 'forminator_hcaptcha_secret', $hcaptcha_secret ); update_option( 'forminator_captcha_tab_saved', $captcha_tab_saved ); update_option( 'forminator_captcha_language', Forminator_Core::sanitize_text_field( 'captcha_language' ) ); wp_send_json_success(); } /** * Load currency modal * * @since 1.0 */ public function load_currency() { forminator_validate_ajax( 'forminator_popup_currency', false, 'forminator-settings' ); $html = forminator_template( 'settings/popup/edit-currency-content' ); wp_send_json_success( $html ); } /** * Save reCaptcha popup data * * @since 1.0 */ public function save_currency() { // Validate nonce. forminator_validate_ajax( 'forminator_save_popup_currency', false, 'forminator-settings' ); update_option( 'forminator_currency', Forminator_Core::sanitize_text_field( 'currency' ) ); wp_send_json_success(); } /** * Load entries pagination modal * * @since 1.0.2 */ public function load_pagination_entries() { // Validate nonce. forminator_validate_ajax( 'forminator_popup_pagination_entries', false, 'forminator-settings' ); $html = forminator_template( 'settings/popup/edit-pagination-entries-content' ); wp_send_json_success( $html ); } /** * Load reCaptcha preview * * @since 1.5.4 */ public function load_recaptcha_preview() { forminator_validate_ajax( 'forminator_load_captcha_settings', false, 'forminator-settings' ); $site_language = get_locale(); $language = get_option( 'forminator_captcha_language', '' ); $language = ! empty( $language ) ? $language : $site_language; $captcha = Forminator_Core::sanitize_text_field( 'captcha' ); if ( 'v2-invisible' === $captcha ) { $captcha_key = get_option( 'forminator_v2_invisible_captcha_key', '' ); $captcha_size = 'invisible'; $onload = 'forminator_render_admin_captcha_v2_invisible'; } elseif ( 'v3' === $captcha ) { $captcha_key = get_option( 'forminator_v3_captcha_key', '' ); $captcha_size = 'invisible'; $onload = 'forminator_render_admin_captcha_v3'; } else { $captcha_key = get_option( 'forminator_captcha_key', '' ); $captcha_size = 'normal'; $onload = 'forminator_render_admin_captcha_v2'; } $html = ''; if ( ! empty( $captcha_key ) ) { // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript $html .= ''; $html .= '
'; } else { $html .= ''; } wp_send_json_success( $html ); } /** * Load hCaptcha preview * * @since 1.15.? */ public function load_hcaptcha_preview() { forminator_validate_ajax( 'forminator_load_captcha_settings', false, 'forminator-settings' ); $site_language = get_locale(); $language = get_option( 'forminator_captcha_language', '' ); $language = ! empty( $language ) ? $language : $site_language; $hcaptcha_key = get_option( 'forminator_hcaptcha_key', '' ); $hcaptcha_secret = get_option( 'forminator_hcaptcha_secret', '' ); $onload = 'forminator_render_admin_hcaptcha'; if ( ! empty( $hcaptcha_key ) && ! empty( $hcaptcha_secret ) ) { // recaptchacompat=off seems to fix problems with hcaptcha container loading recaptcha instead of hcaptcha in the admin. // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript $html = ''; $html .= '
'; } else { $html = '

' . esc_html__( 'Save your API keys to load the hCAPTCHA preview.', 'forminator' ) . '

'; } wp_send_json_success( $html ); } /** * Load listings pagination modal * * @since 1.0.2 */ public function load_pagination_listings() { // Validate nonce. forminator_validate_ajax( 'forminator_popup_pagination_listings', false, 'forminator-settings' ); $html = forminator_template( 'settings/popup/edit-pagination-listings-content' ); wp_send_json_success( $html ); } /** * Save listings pagination popup data * * @since 1.0.2 */ public function save_pagination_listings() { // Validate nonce. forminator_validate_ajax( 'forminator_save_popup_pagination_listings', false, 'forminator-settings' ); $pagination = filter_input( INPUT_POST, 'pagination_listings', FILTER_VALIDATE_INT ); if ( 0 < $pagination ) { update_option( 'forminator_pagination_listings', $pagination ); wp_send_json_success(); } else { wp_send_json_error( esc_html__( 'Limit per page can not be less than one.', 'forminator' ) ); } } /** * Load the email settings form * * @since 1.1 */ public function load_email_form() { // Validate nonce. forminator_validate_ajax( 'forminator_load_popup_email_settings', false, 'forminator-settings' ); $html = forminator_template( 'settings/popup/edit-email-content' ); wp_send_json_success( $html ); } /** * Load the uninstall form * * @since 1.0.2 */ public function load_uninstall_form() { // Validate nonce. forminator_validate_ajax( 'forminator_popup_uninstall_form', false, 'forminator-settings' ); $html = forminator_template( 'settings/popup/edit-uninstall-content' ); wp_send_json_success( $html ); } /** * Save listings pagination popup data * * @since 1.0.2 */ public function save_uninstall_form() { // Validate nonce. forminator_validate_ajax( 'forminator_save_popup_uninstall_settings', false, 'forminator-settings' ); $delete_uninstall = Forminator_Core::sanitize_text_field( 'delete_uninstall', false ); $delete_uninstall = filter_var( $delete_uninstall, FILTER_VALIDATE_BOOLEAN ); $custom_upload = Forminator_Core::sanitize_text_field( 'custom_upload', false ); $custom_upload = filter_var( $custom_upload, FILTER_VALIDATE_BOOLEAN ); $custom_upload_root = Forminator_Core::sanitize_text_field( 'custom_upload_root' ); $custom_upload_root = ! empty( $custom_upload_root ) ? $custom_upload_root : 'forminator'; update_option( 'forminator_uninstall_clear_data', $delete_uninstall ); // Custom upload. update_option( 'forminator_custom_upload', $custom_upload ); update_option( 'forminator_custom_upload_root', $custom_upload_root ); wp_send_json_success(); } /** * Preview module * * @since 1.0 */ public function preview_module() { $current_action = current_action(); $slug = str_replace( array( 'wp_ajax_forminator_load_preview_', '_popup' ), '', $current_action ); if ( 'cforms' === $slug ) { $slug = 'form'; } elseif ( 'polls' === $slug ) { $slug = 'poll'; } elseif ( 'quizzes' === $slug ) { $slug = 'quiz'; } // Validate nonce. forminator_validate_ajax( 'forminator_popup_preview_' . $slug, false, 'forminator' ); $preview_data = false; // force -1 for preview. $form_id = filter_input( INPUT_POST, 'id', FILTER_VALIDATE_INT ); $form_id = $form_id ? $form_id : - 1; // Check if preview data set. if ( ! empty( $_POST['data'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Verified in forminator_validate_ajax. // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput -- Sanitized in Forminator_Core::sanitize_array. $data = Forminator_Core::sanitize_array( $_POST['data'], 'data' ); if ( ! is_array( $data ) ) { $data = json_decode( $data, true ); } $function = 'forminator_data_to_model_' . $slug; $preview_data = $function( $data ); } $html = forminator_preview( $form_id, $slug, true, $preview_data ); wp_send_json_success( $html ); } /** * Load list of exports * * @since 1.0 */ public function load_exports() { // Validate nonce. forminator_validate_ajax( 'forminator_load_exports', false, 'forminator-settings' ); $form_id = filter_input( INPUT_POST, 'id', FILTER_VALIDATE_INT ); if ( $form_id ) { $args = array( 'form_id' => $form_id, ); $html = forminator_template( 'settings/popup/exports-content', $args ); wp_send_json_success( $html ); } else { wp_send_json_error( esc_html__( 'Not valid module ID provided.', 'forminator' ) ); } } /** * Clear list of exports * * @since 1.0 */ public function clear_exports() { // Validate nonce. forminator_validate_ajax( 'forminator_clear_exports', false, 'forminator-settings' ); $form_id = filter_input( INPUT_POST, 'id', FILTER_VALIDATE_INT ); if ( ! $form_id ) { wp_send_json_error( esc_html__( 'No ID was provided.', 'forminator' ) ); } $was_cleared = delete_export_logs( $form_id ); if ( $was_cleared ) { wp_send_json_success( esc_html__( 'Exports cleared.', 'forminator' ) ); } else { wp_send_json_error( esc_html__( 'Exports couldn\'t be cleared.', 'forminator' ) ); } } /** * Search Emails * * @since 1.0.3 * @since 1.1 change superglobal POST to `get_post_data` */ public function search_emails() { $submitted_data = $this->get_post_data(); $property = isset( $submitted_data['property'] ) ? $submitted_data['property'] : ''; $permission_slug = isset( $submitted_data['permission'] ) ? $submitted_data['permission'] : ''; forminator_validate_ajax( 'forminator_search_emails', false, $permission_slug ); // TODO : add ajax validate here and js admin too. $admin_email = ! empty( $submitted_data['admin_email'] ) ? true : false; $search_email = ! empty( $submitted_data['q'] ) ? $submitted_data['q'] : false; $exclude_admins = ! empty( $submitted_data['exclude_admins'] ) ? $submitted_data['exclude_admins'] : false; $is_permission = ! empty( $submitted_data['is_permission'] ) ? $submitted_data['is_permission'] : false; // return admin_email when requested. if ( $admin_email ) { wp_send_json_success( get_option( 'admin_email' ) ); } if ( ! $search_email ) { wp_send_json_success( array() ); } $args = array( 'search' => '*' . $search_email . '*', 'number' => 10, 'orderby' => 'user_login', 'order' => 'ASC', ); if ( $exclude_admins ) { $args['role__not_in'] = 'Administrator'; } $role = isset( $submitted_data['role'] ) ? $submitted_data['role'] : array(); if ( ! empty( $role ) ) { $args['role__in'] = $role; } /** * Filter args to be passed on to get_users * * @param array $args * @param string $search_email string to search. * * @see get_users() * * @since 1.2 */ $args = apply_filters( 'forminator_builder_search_emails_args', $args, $search_email ); // Create a single array of users in permissions. if ( 'specific_user' === $property ) { $permitted_users = array(); $permissions = get_option( 'forminator_permissions', array() ); $pid = isset( $submitted_data['pid'] ) ? $submitted_data['pid'] : ''; foreach ( $permissions as $permission ) { if ( (string) $pid !== (string) $permission['pid'] && isset( $permission['specific_user'] ) ) { $permitted_users = array_merge( $permitted_users, $permission['specific_user'] ); } } } $users = get_users( $args ); $data = array(); if ( ! empty( $users ) ) { foreach ( $users as $user ) { // Check if user has already been added to other permissions. if ( 'specific_user' === $property ) { if ( in_array( $user->ID, $permitted_users ) ) { // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict -- Possible of 0 or '0'. continue; } } if ( $is_permission ) { $data[] = array( 'id' => $user->ID, 'text' => $user->user_email, 'display_name' => $user->display_name, ); } else { $data[] = array( 'id' => $user->user_email, 'text' => $user->user_email, 'display_name' => $user->display_name, ); } } } /** * Filter returned data when builder search emails * * @param array $data * @param array $users search result of get_users. * @param array $args current query args passed to get_users. * @param string $search_email string to search. * * @since 1.2 */ $data = apply_filters( 'forminator_builder_search_emails_data', $data, $users, $args, $search_email ); wp_send_json_success( $data ); } /** * Get superglobal POST data * * @param string $nonce_action action to validate. * @param array $sanitize_callbacks { * custom sanitize options, its assoc array * 'field_name_1' => 'function_to_call_1' function will called with `call_user_func_array`, * 'field_name_2' => 'function_to_call_2', * }. * @param string $permission_slug The slug that will be used to get the capability for checking. * * @return array * @since 1.1 */ protected function get_post_data( $nonce_action = '', $sanitize_callbacks = array(), $permission_slug = '' ) { // do nonce / caps check when requested. if ( ! empty( $nonce_action ) ) { // it will wp_send_json_error. forminator_validate_ajax( $nonce_action, false, $permission_slug ); } // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Verified in forminator_validate_ajax. $post_data = Forminator_Core::sanitize_array( $_POST ); // do some additional sanitize. foreach ( $sanitize_callbacks as $field => $sanitize_func ) { if ( isset( $post_data[ $field ] ) ) { if ( is_callable( $sanitize_func ) ) { $post_data[ $field ] = call_user_func_array( array( $sanitize_func ), array( $post_data[ $field ] ) ); } } } // do some validation. return $post_data; } /** * Load Privacy Settings * * @since 1.0.6 */ public function load_privacy_settings() { // Validate nonce. forminator_validate_ajax( 'forminator_popup_privacy_settings', false, 'forminator-settings' ); $html = forminator_template( 'settings/popup/edit-privacy-settings' ); wp_send_json_success( $html ); } /** * Save Privacy Settings * * @since 1.0.6 */ public function save_privacy_settings() { // Validate nonce. forminator_validate_ajax( 'forminator_save_privacy_settings', false, 'forminator-settings' ); // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Verified in forminator_validate_ajax. $post_data = Forminator_Core::sanitize_array( $_POST ); /** * CUSTOM FORMS */ // Account Erasure Requests. if ( isset( $post_data['erase_form_submissions'] ) ) { $enable_erasure_request_erase_form_submissions = filter_var( $post_data['erase_form_submissions'], FILTER_VALIDATE_BOOLEAN ); update_option( 'forminator_enable_erasure_request_erase_form_submissions', $enable_erasure_request_erase_form_submissions ); } // Account Erasure Requests. // Submissions Retention. $cform_retain_forever = filter_var( $post_data['form_retain_submission_forever'], FILTER_VALIDATE_BOOLEAN ); update_option( 'retain_submission_forever', (string) $cform_retain_forever ); if ( $cform_retain_forever ) { $post_data['form_retain_submission_number'] = 0; } if ( isset( $post_data['form_retain_submission_number'] ) ) { $submissions_retention_number = intval( $post_data['form_retain_submission_number'] ); if ( $submissions_retention_number < 0 ) { $submissions_retention_number = 0; } update_option( 'forminator_retain_submissions_interval_number', $submissions_retention_number ); } update_option( 'forminator_retain_submissions_interval_unit', $post_data['form_retain_submission_unit'] ); // Submissions Retention. // IP Retention. $cform_retain_ip_forever = filter_var( $post_data['form_retain_ip_forever'], FILTER_VALIDATE_BOOLEAN ); update_option( 'retain_ip_forever', (string) $cform_retain_ip_forever ); if ( $cform_retain_ip_forever ) { $post_data['form_retain_ip_number'] = 0; } if ( isset( $post_data['form_retain_ip_number'] ) ) { $cform_ip_retention_number = intval( $post_data['form_retain_ip_number'] ); if ( $cform_ip_retention_number < 0 ) { $cform_ip_retention_number = 0; } update_option( 'forminator_retain_ip_interval_number', $cform_ip_retention_number ); } update_option( 'forminator_retain_ip_interval_unit', $post_data['form_retain_ip_unit'] ); // IP Retention. // Geolocation Retention. $cform_retain_geolocation_forever = filter_var( $post_data['form_retain_geolocation_forever'], FILTER_VALIDATE_BOOLEAN ); update_option( 'retain_geolocation_forever', (string) $cform_retain_geolocation_forever ); if ( $cform_retain_geolocation_forever ) { $post_data['form_retain_geolocation_number'] = 0; } if ( isset( $post_data['form_retain_geolocation_number'] ) ) { $cform_geolocation_retention_number = intval( $post_data['form_retain_geolocation_number'] ); if ( $cform_geolocation_retention_number < 0 ) { $cform_geolocation_retention_number = 0; } update_option( 'forminator_retain_geolocation_interval_number', $cform_geolocation_retention_number ); } update_option( 'forminator_retain_geolocation_interval_unit', $post_data['form_retain_geolocation_unit'] ); /** * POLLS */ // Submissions Retention. $poll_retain_submissions_forever = filter_var( $post_data['poll_retain_submission_forever'], FILTER_VALIDATE_BOOLEAN ); update_option( 'poll_retain_submission_forever', (string) $poll_retain_submissions_forever ); if ( $poll_retain_submissions_forever ) { $post_data['poll_retain_submission_number'] = 0; } // Polls. if ( isset( $post_data['poll_retain_submission_number'] ) ) { $poll_submissions_retention_number = intval( $post_data['poll_retain_submission_number'] ); if ( $poll_submissions_retention_number < 0 ) { $poll_submissions_retention_number = 0; } update_option( 'forminator_retain_poll_submissions_interval_number', $poll_submissions_retention_number ); } update_option( 'forminator_retain_poll_submissions_interval_unit', $post_data['poll_retain_submission_unit'] ); // Submissions Retention. // IP Retention. $poll_retain_ip_forever = filter_var( $post_data['poll_retain_ip_forever'], FILTER_VALIDATE_BOOLEAN ); update_option( 'retain_poll_forever', (string) $poll_retain_ip_forever ); if ( $poll_retain_ip_forever ) { $post_data['poll_retain_ip_number'] = 0; } if ( isset( $post_data['poll_retain_ip_number'] ) ) { $votes_retention_number = intval( $post_data['poll_retain_ip_number'] ); if ( $votes_retention_number < 0 ) { $votes_retention_number = 0; } update_option( 'forminator_retain_votes_interval_number', $votes_retention_number ); } update_option( 'forminator_retain_votes_interval_unit', $post_data['poll_retain_ip_unit'] ); // IP Retention. /** * QUIZ */ // Submissions Retention. $quiz_retain_submissions_forever = filter_var( $post_data['quiz_retain_submission_forever'], FILTER_VALIDATE_BOOLEAN ); update_option( 'quiz_retain_submission_forever', (string) $quiz_retain_submissions_forever ); if ( $quiz_retain_submissions_forever ) { $post_data['quiz_retain_submission_number'] = 0; } if ( isset( $post_data['quiz_retain_submission_number'] ) ) { $quiz_submissions_retention_number = intval( $post_data['quiz_retain_submission_number'] ); if ( $quiz_submissions_retention_number < 0 ) { $quiz_submissions_retention_number = 0; } update_option( 'forminator_retain_quiz_submissions_interval_number', $quiz_submissions_retention_number ); } update_option( 'forminator_retain_quiz_submissions_interval_unit', $post_data['quiz_retain_submission_unit'] ); // Submissions Retention. wp_send_json_success(); } /** * AJAX Reset tracking data */ public function reset_tracking_data() { // Validate nonce. forminator_validate_ajax( 'forminator_reset_tracking_data', false, 'forminator' ); $id = filter_input( INPUT_POST, 'id', FILTER_VALIDATE_INT ); if ( ! $id ) { wp_send_json_error( esc_html__( 'Required id parameter is not set.', 'forminator' ) ); } Forminator_Admin_Module_Edit_Page::reset_module_views( $id ); wp_send_json_success( esc_html__( 'Tracking Data has been reset successfully.', 'forminator' ) ); } /** * Execute Import Form * * @since 1.5 */ public function save_import() { if ( ! Forminator::is_import_export_feature_enabled() ) { wp_send_json_error( esc_html__( 'Import Export Feature disabled.', 'forminator' ) ); } if ( empty( $_POST['importable'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing wp_send_json_error( esc_html__( 'Import text can not be empty.', 'forminator' ) ); } $current_action = current_action(); $slug = str_replace( array( 'wp_ajax_forminator_save_import_', '_popup' ), '', $current_action ); // Validate nonce. forminator_validate_ajax( 'forminator_save_import_' . $slug, false, 'forminator-settings' ); // Modify recipients if replace all recipients checkbox has been checked. $change_recipients = 'checked' === Forminator_Core::sanitize_text_field( 'change_recipients' ); // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput $json = wp_unslash( $_POST['importable'] ); $model = $this->import_json( $json, $slug, $change_recipients ); $return_url = admin_url( 'admin.php?page=forminator-' . forminator_get_prefix( $slug, 'c' ) ); /** * Fires after form import * * @since 1.27.0 * * @param string $slug Module type. */ do_action( 'forminator_after_form_import', $slug ); wp_send_json_success( array( 'id' => $model->id, 'url' => $return_url, ) ); } /** * Create module from template * * @throws Exception When failed to create form template. */ public function create_module_from_template() { // Validate nonce. forminator_validate_ajax( 'forminator_create_form_from_template', false, 'forminator-cform' ); forminator_validate_ajax( 'forminator_create_form_from_template', false, 'forminator-templates' ); $template_id = filter_input( INPUT_POST, 'id' ); if ( empty( $template_id ) ) { wp_send_json_error( esc_html__( 'Template ID is missing.', 'forminator' ) ); } $form_admin = new Forminator_Custom_Form_Admin(); try { $id = $form_admin->create_module_from_template( $template_id, '', 'template' ); if ( is_wp_error( $id ) ) { throw new Exception( $id->get_error_message() ); } } catch ( Exception $e ) { wp_send_json_error( $e->getMessage() ); } $return_url = admin_url( 'admin.php?page=forminator-cform-wizard&id=' . $id ); wp_send_json_success( array( 'id' => $id, 'url' => $return_url, ) ); } /** * Import Form * * @param string $json JSON data to import. * @param string $slug Module type. * @param bool $change_recipients Change recipients. * @param bool $draft Draft status. * * @throws Exception When import failed. */ public function import_json( string $json, string $slug, bool $change_recipients, bool $draft = false ) { try { $model = Forminator_Admin_Module::import_json( $json, '', $slug, $change_recipients, $draft ); return $model; } catch ( Exception $e ) { wp_send_json_error( $e->getMessage() ); } } /** * Get instance of thirdparty importer class * * @param string $type Import from. * * @since 1.5 */ public function importers( $type ) { $class = ''; switch ( $type ) { case 'cf7': if ( class_exists( 'Forminator_Admin_Import_CF7' ) ) { $class = new Forminator_Admin_Import_CF7(); } break; case 'ninja': if ( class_exists( 'Forminator_Admin_Import_Ninja' ) ) { $class = new Forminator_Admin_Import_Ninja(); } break; case 'gravity': if ( class_exists( 'Forminator_Admin_Import_Gravity' ) ) { return new Forminator_Admin_Import_Gravity(); } break; default: break; } return $class; } /** * Load Import Custom Form Popup * * @since 1.5 */ public function load_import_form_cf7() { if ( ! Forminator::is_import_export_feature_enabled() || ! forminator_is_import_plugin_enabled( 'cf7' ) ) { wp_send_json_success( '' ); } // Validate nonce. forminator_validate_ajax( 'forminator_popup_import_form_cf7', false, 'forminator-settings' ); $html = forminator_template( 'custom-form/popup/import-cf7' ); wp_send_json_success( $html ); } /** * Execute Contact Form 7 Import Form * * @since 1.5 */ public function save_import_form_cf7() { if ( ! Forminator::is_import_export_feature_enabled() || ! forminator_is_import_plugin_enabled( 'cf7' ) ) { wp_send_json_error( esc_html__( 'Import Export Feature disabled.', 'forminator' ) ); } // Validate nonce. forminator_validate_ajax( 'forminator_save_import_form_cf7', false, 'forminator-settings' ); $post_data = $this->get_post_data(); $importable = ( isset( $post_data['cf7_forms'] ) ? $post_data['cf7_forms'] : '' ); $importer = $this->importers( 'cf7' ); if ( ! empty( $importer ) ) : if ( ! empty( $importable ) ) { if ( 'specific' === $importable ) { $forms = isset( $post_data['cf7-form-id'] ) ? $post_data['cf7-form-id'] : array(); } else { $forms = forminator_list_thirdparty_contact_forms( 'cf7' ); } if ( ! empty( $forms ) ) { foreach ( $forms as $key => $value ) { $values = 'specific' === $importable ? intval( $value ) : $value->ID; $imported = $importer->import_form( $values, $post_data ); if ( 'fail' === $imported['type'] ) { $error = $imported['message']; } } if ( ! empty( $error ) ) { wp_send_json_error( $error ); } wp_send_json_success( $imported ); } } else { wp_send_json_error( esc_html__( 'Can\'t find form to import', 'forminator' ) ); } endif; wp_send_json_error( esc_html__( 'Could not import the forms. Check if the selected form plugin is active', 'forminator' ) ); } /** * Load Import Custom Form Popup * * @since 1.5 */ public function load_import_form_ninja() { if ( ! Forminator::is_import_export_feature_enabled() || ! forminator_is_import_plugin_enabled( 'ninjaforms' ) ) { wp_send_json_success( '' ); } // Validate nonce. forminator_validate_ajax( 'forminator_popup_import_form_ninjaforms', false, 'forminator-settings' ); $html = forminator_template( 'custom-form/popup/import-ninjaforms' ); wp_send_json_success( $html ); } /** * Execute Ninjaforms Import Form Save * * @since 1.5 */ public function save_import_form_ninja() { if ( ! Forminator::is_import_export_feature_enabled() || ! forminator_is_import_plugin_enabled( 'ninjaforms' ) ) { wp_send_json_error( esc_html__( 'Import Export Feature disabled.', 'forminator' ) ); } // Validate nonce. forminator_validate_ajax( 'forminator_save_import_form_ninja', false, 'forminator-settings' ); $importable = Forminator_Core::sanitize_text_field( 'ninjaforms' ); $importer = ( ! empty( $this->importers( 'ninja' ) ) ? $this->importers( 'ninja' ) : '' ); if ( ! empty( $importer ) ) : if ( 'all' !== $importable && '' !== $importable ) { $importable = absint( $importable ); $imported = $importer->import_form( $importable ); if ( 'fail' === $imported['type'] ) { wp_send_json_error( $imported['message'] ); } wp_send_json_success( $imported ); } elseif ( '' !== $importable ) { $forms = forminator_list_thirdparty_contact_forms( 'ninjaforms' ); foreach ( $forms as $key => $value ) { $imported = $importer->import_form( $value->get_id() ); if ( 'fail' === $imported['type'] ) { $error = $imported['message']; } } if ( ! empty( $error ) ) { wp_send_json_error( $error ); } wp_send_json_success( $imported ); } endif; wp_send_json_error( esc_html__( 'Could not import the forms. Check if the selected form plugin is active', 'forminator' ) ); } /** * Load Import Custom Form Popup * * @since 1.5 */ public function load_import_form_gravity() { if ( ! Forminator::is_import_export_feature_enabled() || ! forminator_is_import_plugin_enabled( 'gravityforms' ) ) { wp_send_json_success( '' ); } // Validate nonce. forminator_validate_ajax( 'forminator_popup_import_form_gravityforms', false, 'forminator-settings' ); $html = forminator_template( 'custom-form/popup/import-gravityforms' ); wp_send_json_success( $html ); } /** * Execute Ninjaforms Import Form Save * * @since 1.5 */ public function save_import_form_gravity() { if ( ! Forminator::is_import_export_feature_enabled() || ! forminator_is_import_plugin_enabled( 'gravityforms' ) ) { wp_send_json_error( esc_html__( 'Import Export Feature disabled.', 'forminator' ) ); } // Validate nonce. forminator_validate_ajax( 'forminator_save_import_form_gravity', false, 'forminator-settings' ); $importable = Forminator_Core::sanitize_text_field( 'gravityforms' ); $importer = ( ! empty( $this->importers( 'gravity' ) ) ? $this->importers( 'gravity' ) : '' ); if ( ! empty( $importer ) ) : if ( 'all' !== $importable && '' !== $importable ) { $importable = absint( $importable ); $imported = $importer->import_form( $importable ); if ( 'fail' === $imported['type'] ) { wp_send_json_error( $imported['message'] ); } wp_send_json_success( $imported ); } elseif ( '' !== $importable ) { $forms = forminator_list_thirdparty_contact_forms( 'gravityforms' ); foreach ( $forms as $key => $value ) { $imported = $importer->import_form( $value['id'] ); if ( 'fail' === $imported['type'] ) { $error = $imported['message']; } } if ( ! empty( $error ) ) { wp_send_json_error( $error ); } wp_send_json_success( $imported ); } endif; } /** * Load Export Module Popup * * @since 1.5 */ public function load_export() { if ( ! Forminator::is_import_export_feature_enabled() ) { wp_send_json_success( '' ); } $current_action = current_action(); $slug = str_replace( array( 'wp_ajax_forminator_load_export_', '_popup' ), '', $current_action ); // Validate nonce. forminator_validate_ajax( 'forminator_popup_export_' . $slug, false, 'forminator' ); $html = forminator_template( 'common/popup/export', array( 'slug' => $slug ) ); /** * Fires after form export * * @since 1.27.0 * * @param int $slug Module type. */ do_action( 'forminator_after_form_export', $slug ); wp_send_json_success( $html ); } /** * Load Import Popup * * @since 1.5 */ public function load_import() { if ( ! Forminator::is_import_export_feature_enabled() ) { wp_send_json_success( '' ); } $current_action = current_action(); $slug = str_replace( array( 'wp_ajax_forminator_load_import_', '_popup' ), '', $current_action ); // Validate nonce. forminator_validate_ajax( 'forminator_popup_import_' . $slug, false, 'forminator' ); $html = forminator_template( 'common/popup/import', array( 'slug' => $slug ) ); wp_send_json_success( $html ); } /** * Save pagination data * * @since 1.6 */ public function save_pagination() { // Validate nonce. forminator_validate_ajax( 'forminator_save_popup_pagination', false, 'forminator' ); $pagination = filter_input( INPUT_POST, 'pagination_entries', FILTER_VALIDATE_INT ); $pagination_listing = filter_input( INPUT_POST, 'pagination_listings', FILTER_VALIDATE_INT ); if ( 1 > $pagination || 1 > $pagination_listing ) { wp_send_json_error( esc_html__( 'Limit per page can not be less than one.', 'forminator' ) ); } update_option( 'forminator_pagination_entries', $pagination ); update_option( 'forminator_pagination_listings', $pagination_listing ); wp_send_json_success(); } /** * Save accessibility_settings * * @since 1.6.1 */ public function save_accessibility_settings() { // Validate nonce. forminator_validate_ajax( 'forminator_save_accessibility_settings', false, 'forminator-settings' ); $enable_accessibility = filter_input( INPUT_POST, 'enable_accessibility', FILTER_VALIDATE_BOOLEAN ); update_option( 'forminator_enable_accessibility', $enable_accessibility ); wp_send_json_success(); } /** * Save dashboard * * @since 1.6.3 */ public function save_dashboard_settings() { // Validate nonce. forminator_validate_ajax( 'forminator_save_dashboard_settings', false, 'forminator-settings' ); $dashboard_settings = forminator_get_dashboard_settings(); $widgets = array( 'forms', 'polls', 'quizzes' ); $num_recents = filter_input( INPUT_POST, 'num_recent', FILTER_VALIDATE_INT, FILTER_REQUIRE_ARRAY ); $num_recents = is_array( $num_recents ) ? $num_recents : array(); $publisheds = filter_input( INPUT_POST, 'published', FILTER_VALIDATE_BOOLEAN, FILTER_REQUIRE_ARRAY ); $publisheds = is_array( $publisheds ) ? $publisheds : array(); $drafts = filter_input( INPUT_POST, 'draft', FILTER_VALIDATE_BOOLEAN, FILTER_REQUIRE_ARRAY ); $drafts = is_array( $drafts ) ? $drafts : array(); // value based settings. foreach ( $num_recents as $widget => $value ) { if ( ! isset( $dashboard_settings[ $widget ] ) ) { $dashboard_settings[ $widget ] = array(); } // at least 0. if ( $value >= 0 ) { $dashboard_settings[ $widget ]['num_recent'] = $value; } } // bool based settings aka checkboxes. foreach ( $widgets as $widget ) { if ( ! isset( $dashboard_settings[ $widget ] ) ) { $dashboard_settings[ $widget ] = array(); } // default enabled, handle when not exist = false. if ( ! isset( $publisheds[ $widget ] ) ) { $dashboard_settings[ $widget ]['published'] = false; } if ( ! isset( $drafts[ $widget ] ) ) { $dashboard_settings[ $widget ]['draft'] = false; } } update_option( 'forminator_dashboard_settings', $dashboard_settings ); $sender_email = filter_input( INPUT_POST, 'sender_email', FILTER_SANITIZE_EMAIL ); if ( $sender_email ) { update_option( 'forminator_sender_email_address', $sender_email ); } $sender_name = Forminator_Core::sanitize_text_field( 'sender_name' ); if ( $sender_name ) { update_option( 'forminator_sender_name', $sender_name ); } $pagination = filter_input( INPUT_POST, 'pagination_entries', FILTER_VALIDATE_INT ); $pagination_listing = filter_input( INPUT_POST, 'pagination_listings', FILTER_VALIDATE_INT ); if ( 1 > $pagination || 1 > $pagination_listing ) { wp_send_json_error( esc_html__( 'Limit per page can not be less than one.', 'forminator' ) ); } update_option( 'forminator_pagination_entries', $pagination ); update_option( 'forminator_pagination_listings', $pagination_listing ); $editor_settings = Forminator_Core::sanitize_text_field( 'editor_settings', false ); update_option( 'forminator_editor_settings', $editor_settings ); $old_usage_tracking = get_option( 'forminator_usage_tracking' ); $usage_tracking = filter_input( INPUT_POST, 'usage_tracking', FILTER_VALIDATE_BOOLEAN ); if ( ! $old_usage_tracking && $usage_tracking ) { Forminator_Core::init_mixpanel( true ); do_action( 'forminator_enable_usage_tracking', 'Settings' ); } elseif ( $old_usage_tracking && ! $usage_tracking ) { do_action( 'forminator_disable_usage_tracking', 'Settings' ); } update_option( 'forminator_usage_tracking', $usage_tracking ); /** * Triggered after save dashboard settings * * @since 1.27.0 */ do_action( 'forminator_after_dashboard_settings' ); wp_send_json_success(); } /** * Disconnect stripe * * @since 1.7 */ public function stripe_disconnect() { // Validate nonce. forminator_validate_ajax( 'forminatorSettingsRequest', false, 'forminator-settings' ); if ( class_exists( 'Forminator_Gateway_Stripe' ) ) { Forminator_Gateway_Stripe::store_settings( array() ); } $data['notification'] = array( 'type' => 'success', 'text' => esc_html__( 'Stripe account disconnected successfully.', 'forminator' ), 'duration' => '4000', ); $file = forminator_plugin_dir() . 'admin/views/settings/payments/section-stripe.php'; ob_start(); /* @noinspection PhpIncludeInspection */ include $file; $data['html'] = ob_get_clean(); wp_send_json_success( $data ); } /** * Disconnect PayPal * * @since 1.7 */ public function paypal_disconnect() { // Validate nonce. forminator_validate_ajax( 'forminatorSettingsRequest', false, 'forminator-settings' ); if ( class_exists( 'Forminator_PayPal_Express' ) ) { Forminator_PayPal_Express::store_settings( array() ); } $data['notification'] = array( 'type' => 'success', 'text' => esc_html__( 'PayPal account disconnected successfully.', 'forminator' ), 'duration' => '4000', ); $file = forminator_plugin_dir() . 'admin/views/settings/payments/section-paypal.php'; ob_start(); /* @noinspection PhpIncludeInspection */ include $file; $data['html'] = ob_get_clean(); wp_send_json_success( $data ); } /** * Handle stripe settings * * @since 1.7 */ public function stripe_update_page() { // Validate nonce. forminator_validate_ajax( 'forminator_stripe_settings_modal', false, 'forminator-settings' ); $file = forminator_plugin_dir() . 'admin/views/settings/payments/section-stripe.php'; ob_start(); /* @noinspection PhpIncludeInspection */ include $file; $html = ob_get_clean(); wp_send_json_success( $html ); } /** * Handle PayPal settings * * @since 1.7 */ public function paypal_update_page() { // Validate nonce. forminator_validate_ajax( 'forminator_paypal_settings_modal', false, 'forminator-settings' ); $file = forminator_plugin_dir() . 'admin/views/settings/payments/section-paypal.php'; ob_start(); /* @noinspection PhpIncludeInspection */ include $file; $html = ob_get_clean(); wp_send_json_success( $html ); } /** * Handle stripe settings * * @since 1.7 * @throws Forminator_Gateway_Exception When connection fails. */ public function stripe_settings_modal() { if ( ! class_exists( 'Forminator_Gateway_Stripe' ) ) { return false; } // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Verified in forminator_validate_ajax. $post_data = Forminator_Core::sanitize_array( $_POST ); // Validate nonce. forminator_validate_ajax( 'forminator_stripe_settings_modal', false, $post_data['page_slug'] ); $data = array(); $is_connect_request = isset( $post_data['connect'] ) ? $post_data['connect'] : false; $template_vars = array(); try { $stripe = new Forminator_Gateway_Stripe(); $test_key = isset( $post_data['test_key'] ) ? $post_data['test_key'] : $stripe->get_test_key(); $test_secret = isset( $post_data['test_secret'] ) ? $post_data['test_secret'] : $stripe->get_test_secret(); $live_key = isset( $post_data['live_key'] ) ? $post_data['live_key'] : $stripe->get_live_key(); $live_secret = isset( $post_data['live_secret'] ) ? $post_data['live_secret'] : $stripe->get_live_secret(); $page_slug = isset( $post_data['page_slug'] ) ? $post_data['page_slug'] : ''; $default_currency = $stripe->get_default_currency(); $template_vars['test_key'] = $test_key; $template_vars['test_secret'] = $test_secret; $template_vars['live_key'] = $live_key; $template_vars['live_secret'] = $live_secret; if ( ( ! empty( $test_secret ) && 'sk_' === substr( $test_secret, 0, 3 ) ) || ( ! empty( $live_secret ) && 'sk_' === substr( $live_secret, 0, 3 ) ) ) { $template_vars['has_deprecated_secret_key'] = true; } if ( ! empty( $is_connect_request ) ) { if ( empty( $test_key ) ) { throw new Forminator_Gateway_Exception( '', Forminator_Gateway_Stripe::EMPTY_TEST_KEY_EXCEPTION ); } if ( empty( $test_secret ) ) { throw new Forminator_Gateway_Exception( '', Forminator_Gateway_Stripe::EMPTY_TEST_SECRET_EXCEPTION ); } Forminator_Gateway_Stripe::validate_keys( $test_key, $test_secret, Forminator_Gateway_Stripe::INVALID_TEST_SECRET_EXCEPTION ); if ( empty( $live_key ) ) { throw new Forminator_Gateway_Exception( '', Forminator_Gateway_Stripe::EMPTY_LIVE_KEY_EXCEPTION ); } if ( empty( $live_secret ) ) { throw new Forminator_Gateway_Exception( '', Forminator_Gateway_Stripe::EMPTY_LIVE_SECRET_EXCEPTION ); } Forminator_Gateway_Stripe::validate_keys( $live_key, $live_secret, Forminator_Gateway_Stripe::INVALID_LIVE_SECRET_EXCEPTION ); /** * Fires before stripe connected * * @since 1.35.0 * * @param string $test_key Test key. * @param string $test_secret Test secret. * @param string $live_key Live key. * @param string $live_secret Live secret. * @param string $page_slug Page slug. */ do_action( 'forminator_before_stripe_connected', $test_key, $test_secret, $live_key, $live_secret, $page_slug ); Forminator_Gateway_Stripe::store_settings( array( 'test_key' => $test_key, 'test_secret' => $test_secret, 'live_key' => $live_key, 'live_secret' => $live_secret, 'default_currency' => $default_currency, ) ); $data['notification'] = array( 'type' => 'success', 'text' => esc_html__( 'Stripe account connected successfully. You can now add the Stripe field to your forms and start collecting payments.', 'forminator' ), 'duration' => '4000', ); } } catch ( Forminator_Gateway_Exception $e ) { forminator_maybe_log( __METHOD__, $e->getMessage(), $e->getTrace() ); $template_vars['error_message'] = $e->getMessage(); if ( Forminator_Gateway_Stripe::EMPTY_TEST_KEY_EXCEPTION === $e->getCode() ) { $template_vars['test_key_error'] = esc_html__( 'Please input test publishable key', 'forminator' ); } if ( Forminator_Gateway_Stripe::EMPTY_TEST_SECRET_EXCEPTION === $e->getCode() ) { $template_vars['test_secret_error'] = esc_html__( 'Please input test secret key', 'forminator' ); } if ( Forminator_Gateway_Stripe::EMPTY_LIVE_KEY_EXCEPTION === $e->getCode() ) { $template_vars['live_key_error'] = esc_html__( 'Please input live publishable key', 'forminator' ); } if ( Forminator_Gateway_Stripe::EMPTY_LIVE_SECRET_EXCEPTION === $e->getCode() ) { $template_vars['live_secret_error'] = esc_html__( 'Please input live secret key', 'forminator' ); } if ( Forminator_Gateway_Stripe::INVALID_TEST_SECRET_EXCEPTION === $e->getCode() ) { if ( ! empty( $test_secret ) && 'sk_' === substr( $test_secret, 0, 3 ) ) { $template_vars['test_secret_error'] = esc_html__( 'You\'ve entered an invalid test secret key', 'forminator' ); } else { $template_vars['test_secret_error'] = esc_html__( 'You\'ve entered an invalid test restricted key', 'forminator' ); } } if ( Forminator_Gateway_Stripe::INVALID_LIVE_SECRET_EXCEPTION === $e->getCode() ) { if ( ! empty( $live_secret ) && 'sk_' === substr( $live_secret, 0, 3 ) ) { $template_vars['live_secret_error'] = esc_html__( 'You\'ve entered an invalid live secret key', 'forminator' ); } else { $template_vars['live_secret_error'] = esc_html__( 'You\'ve entered an invalid live restricted key', 'forminator' ); } } if ( Forminator_Gateway_Stripe::INVALID_TEST_KEY_EXCEPTION === $e->getCode() ) { $template_vars['test_key_error'] = esc_html__( 'You\'ve entered an invalid test publishable key', 'forminator' ); } if ( Forminator_Gateway_Stripe::INVALID_LIVE_KEY_EXCEPTION === $e->getCode() ) { $template_vars['live_key_error'] = esc_html__( 'You\'ve entered an invalid live publishable key', 'forminator' ); } } ob_start(); /* @noinspection PhpIncludeInspection */ include forminator_plugin_dir() . 'admin/views/settings/payments/stripe.php'; $html = ob_get_clean(); $data['html'] = $html; $data['buttons'] = array(); $data['buttons']['connect']['markup'] = '
' . '' . '
'; wp_send_json_success( $data ); } /** * Handle PayPal settings * * @since 1.7.1 * @throws Forminator_Gateway_Exception When failed to connect. */ public function paypal_settings_modal() { // Validate nonce. forminator_validate_ajax( 'forminator_paypal_settings_modal', false, 'forminator-settings' ); $data = array(); // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Verified in forminator_validate_ajax. $post_data = Forminator_Core::sanitize_array( $_POST ); $is_connect_request = isset( $post_data['connect'] ) ? $post_data['connect'] : false; $template_vars = array(); try { $paypal = new Forminator_PayPal_Express(); $sandbox_id = isset( $post_data['sandbox_id'] ) ? $post_data['sandbox_id'] : $paypal->get_sandbox_id(); $sandbox_secret = isset( $post_data['sandbox_secret'] ) ? $post_data['sandbox_secret'] : $paypal->get_sandbox_secret(); $live_id = isset( $post_data['live_id'] ) ? $post_data['live_id'] : $paypal->get_live_id(); $live_secret = isset( $post_data['live_secret'] ) ? $post_data['live_secret'] : $paypal->get_live_secret(); $default_currency = $paypal->get_default_currency(); $template_vars['sandbox_id'] = $sandbox_id; $template_vars['sandbox_secret'] = $sandbox_secret; $template_vars['live_id'] = $live_id; $template_vars['live_secret'] = $live_secret; if ( ! empty( $is_connect_request ) ) { if ( empty( $sandbox_id ) ) { throw new Forminator_Gateway_Exception( '', Forminator_PayPal_Express::EMPTY_SANDBOX_ID_EXCEPTION ); } if ( empty( $sandbox_secret ) ) { throw new Forminator_Gateway_Exception( '', Forminator_PayPal_Express::EMPTY_SANDBOX_SECRET_EXCEPTION ); } $paypal->validate_id( 'sandbox', $sandbox_id, $sandbox_secret, Forminator_PayPal_Express::INVALID_SANDBOX_SECRET_EXCEPTION ); if ( empty( $live_id ) ) { throw new Forminator_Gateway_Exception( '', Forminator_PayPal_Express::EMPTY_LIVE_ID_EXCEPTION ); } if ( empty( $live_secret ) ) { throw new Forminator_Gateway_Exception( '', Forminator_PayPal_Express::EMPTY_LIVE_SECRET_EXCEPTION ); } $paypal->validate_id( 'live', $live_id, $live_secret, Forminator_PayPal_Express::INVALID_LIVE_SECRET_EXCEPTION ); Forminator_PayPal_Express::store_settings( array( 'sandbox_id' => $sandbox_id, 'sandbox_secret' => $sandbox_secret, 'live_id' => $live_id, 'live_secret' => $live_secret, 'currency' => $default_currency, ) ); $data['notification'] = array( 'type' => 'success', 'text' => esc_html__( 'PayPal account connected successfully. You can now add the PayPal field to your forms and start collecting payments.', 'forminator' ), 'duration' => '4000', ); } } catch ( Forminator_Gateway_Exception $e ) { forminator_maybe_log( __METHOD__, $e->getMessage(), $e->getTrace() ); $template_vars['error_message'] = $e->getMessage(); if ( Forminator_PayPal_Express::EMPTY_SANDBOX_ID_EXCEPTION === $e->getCode() ) { $template_vars['sandbox_id_error'] = esc_html__( 'Please input sandbox client id', 'forminator' ); } if ( Forminator_PayPal_Express::EMPTY_SANDBOX_SECRET_EXCEPTION === $e->getCode() ) { $template_vars['sandbox_secret_error'] = esc_html__( 'Please input sandbox secret key', 'forminator' ); } if ( Forminator_PayPal_Express::EMPTY_LIVE_ID_EXCEPTION === $e->getCode() ) { $template_vars['live_id_error'] = esc_html__( 'Please input live client id', 'forminator' ); } if ( Forminator_PayPal_Express::EMPTY_LIVE_SECRET_EXCEPTION === $e->getCode() ) { $template_vars['live_secret_error'] = esc_html__( 'Please input live secret key', 'forminator' ); } if ( Forminator_PayPal_Express::INVALID_SANDBOX_SECRET_EXCEPTION === $e->getCode() ) { $template_vars['sandbox_secret_error'] = esc_html__( 'You\'ve entered an invalid sandbox secret key', 'forminator' ); } if ( Forminator_PayPal_Express::INVALID_LIVE_SECRET_EXCEPTION === $e->getCode() ) { $template_vars['live_secret_error'] = esc_html__( 'You\'ve entered an invalid live secret key', 'forminator' ); } if ( Forminator_PayPal_Express::INVALID_SANDBOX_ID_EXCEPTION === $e->getCode() ) { $template_vars['sandbox_id_error'] = esc_html__( 'You\'ve entered an invalid sandbox client id', 'forminator' ); } if ( Forminator_PayPal_Express::INVALID_LIVE_ID_EXCEPTION === $e->getCode() ) { $template_vars['live_id_error'] = esc_html__( 'You\'ve entered an invalid live client id', 'forminator' ); } } ob_start(); /* @noinspection PhpIncludeInspection */ include forminator_plugin_dir() . 'admin/views/settings/payments/paypal.php'; $html = ob_get_clean(); $data['html'] = $html; $data['buttons'] = array(); $data['buttons']['connect']['markup'] = '
' . '' . '
'; wp_send_json_success( $data ); } /** * Dismiss notice. Use dismiss_admin_notice method instead * * @since 1.9 */ public function dismiss_notice() { forminator_validate_ajax( 'forminator_dismiss_notification' ); $notification_name = Forminator_Core::sanitize_text_field( 'prop' ); $input_value = Forminator_Core::sanitize_text_field( 'value' ); $allowed_options = array( 'forminator_skip_pro_notice', 'forminator_cf7_notice_dismissed', 'forminator_stripe_rak_notice_dismissed', 'forminator_stripe_notice_dismissed', 'forminator_rating_success', 'forminator_rating_dismissed', 'forminator_publish_rating_later', 'forminator_publish_rating_later_dismiss', 'forminator_days_rating_later_dismiss', 'forminator_submission_rating_later', 'forminator_submission_rating_later_dismiss', 'forminator_hosting_banner_dismiss', 'forminator_hosting_banner_later', ); if ( ! in_array( $notification_name, $allowed_options, true ) && 0 !== strpos( $notification_name, 'forminator_addons_update_' ) && 0 !== strpos( $notification_name, 'forminator_dismiss_feature_' ) ) { wp_send_json_error( esc_html__( 'Invalid option name', 'forminator' ) ); } if ( ! empty( $input_value ) ) { update_option( $notification_name, $input_value ); } else { update_option( $notification_name, true ); } $version_upgraded = get_option( 'forminator_version_upgraded', false ); if ( $version_upgraded ) { update_option( 'forminator_version_upgraded', false ); } wp_send_json_success(); } /** * Toggle usage tracking * * @return void */ public function toggle_usage_tracking() { forminator_validate_ajax( 'forminator_usage_tracking' ); $usage_value = filter_input( INPUT_POST, 'enabled', FILTER_VALIDATE_BOOLEAN ); $source = 'Upgrade Modal'; update_option( 'forminator_usage_tracking', $usage_value ); Forminator_Core::init_mixpanel( true ); if ( $usage_value ) { /** * Triggered after enabling Feature model Usage settings on New-feature popup * * @param string $source Source of the action. */ do_action( 'forminator_enable_usage_tracking', $source ); } else { /** * Triggered after disabling Feature model Usage settings on New-feature popup * * @param string $source Source of the action. */ do_action( 'forminator_disable_usage_tracking', $source ); } wp_send_json_success( esc_html__( 'Settings saved successfully!', 'forminator' ) ); } /** * Dismiss admin notice. */ public function dismiss_admin_notice() { forminator_validate_ajax( 'forminator_dismiss_notice' ); $slug = Forminator_Core::sanitize_text_field( 'slug' ); $user_id = get_current_user_id(); $dismissed = get_user_meta( $user_id, 'frmt_dismissed_messages', true ); if ( ! $dismissed || ! is_array( $dismissed ) ) { $dismissed = array(); } $dismissed[] = $slug; update_user_meta( $user_id, 'frmt_dismissed_messages', $dismissed ); wp_send_json_success(); } /** * Dismiss notice * * @since 1.9 */ public function later_notice() { forminator_validate_ajax( 'forminator_dismiss_notification' ); $notification_name = Forminator_Core::sanitize_text_field( 'prop' ); $form_id = filter_input( INPUT_POST, 'form_id', FILTER_VALIDATE_INT ); $allowed_keys = array( 'forminator_publish_rating_later', 'forminator_publish_rating_later_dismiss', 'forminator_days_rating_later_dismiss', 'forminator_submission_rating_later', 'forminator_submission_rating_later_dismiss', ); if ( ! in_array( $notification_name, $allowed_keys, true ) ) { wp_send_json_error( esc_html__( 'Invalid notification name', 'forminator' ) ); } update_post_meta( $form_id, $notification_name, true ); wp_send_json_success(); } /** * Promote free plan - Remind me later */ public function promote_remind_later() { forminator_validate_ajax( 'forminator_promote_remind_later' ); set_transient( 'forminator_free_plan_remind_later_' . get_current_user_id(), true, WEEK_IN_SECONDS ); wp_send_json_success(); } /** * Save general payments settings * * @since 1.7 */ public function save_payments() { forminator_validate_ajax( 'forminator_save_payments_settings', false, 'forminator-settings' ); // stripe. $default_currency = Forminator_Core::sanitize_text_field( 'stripe-default-currency' ); if ( $default_currency ) { try { Forminator_Gateway_Stripe::store_default_currency( $default_currency ); } catch ( Forminator_Gateway_Exception $e ) { wp_send_json_error( $e->getMessage() ); } } // paypal. $pp_default_currency = Forminator_Core::sanitize_text_field( 'paypal-default-currency' ); if ( $pp_default_currency ) { $default_currency = $pp_default_currency; try { Forminator_PayPal_Express::store_default_currency( $default_currency ); } catch ( Forminator_Gateway_Exception $e ) { wp_send_json_error( $e->getMessage() ); } } wp_send_json_success(); } /** * Delete all poll submission * * @since 1.7.2 */ public function delete_poll_submissions() { forminator_validate_ajax( 'forminatorPollEntries', false, 'forminator-entries' ); $form_id = filter_input( INPUT_POST, 'id', FILTER_VALIDATE_INT ); if ( $form_id ) { Forminator_Form_Entry_Model::delete_by_form( $form_id ); $file = forminator_plugin_dir() . 'admin/views/common/entries/content-none.php'; ob_start(); /* @noinspection PhpIncludeInspection */ include $file; $html = ob_get_clean(); $data['html'] = $html; $data['notification'] = array( 'type' => 'success', 'text' => esc_html__( 'All the submissions deleted successfully.', 'forminator' ), 'duration' => '4000', ); wp_send_json_success( $data ); } else { $data['notification'] = array( 'type' => 'error', 'text' => esc_html__( 'Submission delete failed.', 'forminator' ), 'duration' => '4000', ); wp_send_json_error( $data ); } } /** * Module search for all types * * @since 1.14.12 */ public function module_search() { forminator_validate_ajax( 'forminator-nonce-search-module', false, 'forminator' ); $html = ''; $keyword = Forminator_Core::sanitize_text_field( 'search_keyword' ); $modules = Forminator_Admin_Module_Edit_Page::get_searched_modules( $keyword ); ob_start(); Forminator_Admin_Module_Edit_Page::show_modules( $modules, Forminator_Core::sanitize_text_field( 'module_slug' ), Forminator_Core::sanitize_text_field( 'preview_dialog' ), Forminator_Core::sanitize_text_field( 'preview_title' ), Forminator_Core::sanitize_text_field( 'export_dialog' ), Forminator_Core::sanitize_text_field( 'post_type' ), Forminator_Core::sanitize_text_field( 'soon' ), Forminator_Core::sanitize_text_field( 'sql_month_start_date' ), Forminator_Core::sanitize_text_field( 'wizard_page' ), $keyword ); $html = ob_get_clean(); wp_send_json_success( $html ); } /** * Addons page action * * @return void */ public function addons_page_actions() { // Validate nonce. forminator_validate_ajax( 'forminator_popup_addons_actions', false, 'forminator-addons' ); $action = Forminator_Core::sanitize_text_field( 'action' ); if ( ! $action ) { wp_send_json_error( array( 'message' => esc_html__( 'Required field missing', 'forminator' ) ) ); } $action = str_replace( 'forminator_', '', $action ); Forminator_Admin_Addons_Page::get_instance()->addons_action_ajax( $action ); // When the addons_action_ajax function did not send a response assume error. wp_send_json_error( array( 'message' => esc_html__( 'Unexpected action, we could not handle it.', 'forminator' ) ) ); } /** * Filter report data * * @return void */ public function filter_report_data() { // Validate nonce. forminator_validate_ajax( 'forminator_filter_report_data', false, 'forminator-reports' ); $form_id = filter_input( INPUT_POST, 'form_id', FILTER_VALIDATE_INT ); $form_type = Forminator_Core::sanitize_text_field( 'form_type' ); $start_date = Forminator_Core::sanitize_text_field( 'start_date' ); $end_date = Forminator_Core::sanitize_text_field( 'end_date' ); $range_time = Forminator_Core::sanitize_text_field( 'range_time' ); $range_text = ! empty( $range_time ) ? $range_time : 'Custom'; if ( ! empty( $form_id ) && ! empty( $start_date ) && ! empty( $end_date ) ) { $admin_report_instance = Forminator_Admin_Report_Page::get_instance(); $reports = $admin_report_instance->forminator_report_data( $form_id, $form_type, $start_date, $end_date, $range_text ); $report_data = $admin_report_instance->forminator_report_array( $reports, $form_id ); $chart_data = $admin_report_instance->forminator_report_chart_data( $form_id, $start_date, $end_date ); if ( isset( $chart_data['submissions'] ) ) { $chart_data['submissions'] = array_values( $chart_data['submissions'] ); } if ( ! empty( $report_data ) ) { $response = array( 'reports' => $report_data, 'chart_data' => $chart_data, ); $response = apply_filters( 'forminator_report_data', $response, $form_id, $form_type, $start_date, $end_date ); wp_send_json_success( $response ); } } wp_send_json_error( array( 'message' => esc_html__( 'Required field missing', 'forminator' ) ) ); } /** * Search users from the add recipients modal. * * @since 1.20.0 */ public function search_users() { forminator_validate_ajax( 'forminator-fetch', 'nonce', 'forminator-reports' ); $query = Forminator_Core::sanitize_text_field( 'query' ); $query = "*$query*"; $exclude = filter_input( INPUT_POST, 'exclude', FILTER_VALIDATE_INT, FILTER_REQUIRE_ARRAY ); $users = forminator_get_users_by_query( $query, $exclude ); wp_send_json_success( $users ); } /** * Get avatar for the recipients modal. * * @since 1.20.0 */ public function get_avatar() { forminator_validate_ajax( 'forminator-fetch', 'nonce', 'forminator-reports' ); if ( ! current_user_can( forminator_get_permission( 'forminator-reports' ) ) ) { wp_send_json_error( array( 'message' => esc_html__( 'Current user cannot add recipient.', 'forminator' ), ) ); } $email = filter_input( INPUT_POST, 'email', FILTER_VALIDATE_EMAIL ); if ( false === $email ) { wp_send_json_error( array( 'message' => esc_html__( 'Invalid email.', 'forminator' ), ) ); } wp_send_json_success( get_avatar_url( $email ) ); } /** * Fetch reports by id * * @since 1.20.0 */ public function fetch_report() { forminator_validate_ajax( 'forminator-fetch', 'nonce', 'forminator-reports' ); $report_id = Forminator_Core::sanitize_text_field( 'report_id' ); $report_value = array(); if ( empty( $report_id ) ) { wp_send_json_error( array( 'message' => esc_html__( 'Something went wrong.', 'forminator' ), ) ); } $report_data = Forminator_Form_Reports_Model::get_instance()->fetch_report_by_id( $report_id ); if ( ! empty( $report_data ) ) { $report_value = ! empty( $report_data->report_value ) ? Forminator_Core::sanitize_html_array( maybe_unserialize( $report_data->report_value ) ) : array(); if ( isset( $report_data->status ) ) { $report_value['report_status'] = esc_html( $report_data->status ); } $report_value['report_id'] = intval( $report_data->report_id ); } wp_send_json_success( $report_value ); } /** * Save Report. * * @since 1.20.0 */ public function save_report() { forminator_validate_ajax( 'forminator-save', 'nonce', 'forminator-reports' ); // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Verified in forminator_validate_ajax. if ( empty( $_POST['reports'] ) ) { wp_send_json_error( array( 'message' => esc_html__( 'Something went wrong.', 'forminator' ), ) ); } $report_id = Forminator_Core::sanitize_text_field( 'report_id' ); $status = Forminator_Core::sanitize_text_field( 'status' ); $reports_data = Forminator_Core::sanitize_array( $_POST['reports'] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput $reports_data['report_status'] = $status; if ( 0 !== (int) $report_id ) { $result = Forminator_Form_Reports_Model::get_instance()->report_update( $report_id, $reports_data, $status ); } else { $result = Forminator_Form_Reports_Model::get_instance()->report_save( $reports_data, $status ); $reports_data['report_id'] = $result; } if ( is_wp_error( $result ) ) { wp_send_json_error(); } /** * Fires after report save * * @since 1.27.0 * * @param array $reports_data Report data. */ do_action( 'forminator_after_notification_update', $reports_data ); wp_send_json_success( $result ); } /** * Update report status */ public function update_report_status() { forminator_validate_ajax( 'forminator-save', 'nonce', 'forminator-reports' ); $report_id = Forminator_Core::sanitize_text_field( 'report_id' ); $status = Forminator_Core::sanitize_text_field( 'status' ); if ( empty( $status ) ) { wp_send_json_error( array( 'message' => esc_html__( 'Something went wrong.', 'forminator' ), ) ); } $result = Forminator_Form_Reports_Model::get_instance()->report_update_status( $report_id, $status ); if ( is_wp_error( $result ) ) { wp_send_json_error(); } wp_send_json_success( $result ); } /** * Save permission. */ public function save_permissions() { forminator_validate_ajax( 'forminator_permission_nonce' ); $old_permissions = get_option( 'forminator_permissions', array() ); $post_data = Forminator_Core::sanitize_array( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Verified in forminator_validate_ajax. $permissions = json_decode( wp_unslash( $post_data['permissions'] ), true ); $caps = forminator_get_capabilities(); // Perform changes during save mode. if ( 'new' === $post_data['mode'] ) { foreach ( $permissions as $key => $permission ) { /** * For specific users. * - Add caps to the users * - Check each permission for get_avatar then retrieve it. */ if ( 'specific' === $permission['permission_type'] ) { foreach ( $permission['specific_user'] as $user_index => $user_id ) { $user = get_user_by( 'ID', $user_id ); if ( false !== $user ) { // Add caps to the user. forminator_apply_capabilities( $user, $permission ); // Set user info. $permissions[ $key ]['user_info'][ $user_id ]['name'] = $user->display_name; $permissions[ $key ]['user_info'][ $user_id ]['email'] = $user->user_email; // We only need avatar for first user. if ( 0 === $user_index ) { $permissions[ $key ]['avatar'] = get_avatar_url( $user->user_email, array( 'size' => 30 ) ); } } } /** * For roles. * - Add caps to users under these roles. */ } else { $role = get_role( $permission['user_role'] ); // Add caps to the role. forminator_apply_capabilities( $role, $permission ); if ( empty( $permission['exclude_users'] ) ) { continue; } // Set user info for excluded users. foreach ( $permission['exclude_users'] as $user_id ) { $user = get_user_by( 'ID', $user_id ); if ( false !== $user ) { $permissions[ $key ]['user_info'][ $user_id ]['name'] = $user->display_name; $permissions[ $key ]['user_info'][ $user_id ]['email'] = $user->user_email; } } } } /** * EDIT mode. * * If specific users, get the missing users from new permission state then revoke their caps. * Add new caps if new ones are added. * * If role, add or remove caps as per new state. */ } else { $pid = $post_data['pid']; // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict -- Possible for 0 or "0" $old_permission = $old_permissions[ array_search( $pid, array_column( $old_permissions, 'pid' ) ) ]; if ( 'edit' === $post_data['mode'] ) { foreach ( $permissions as $key => $permission ) { if ( $old_permission['pid'] === $permission['pid'] ) { // If specific user. if ( 'specific' === $permission['permission_type'] ) { // Remove caps from deleted users. $deleted_users = array_diff( $old_permission['specific_user'], $permission['specific_user'] ); foreach ( $deleted_users as $user_id ) { $graduate = get_user_by( 'ID', $user_id ); if ( false !== $graduate ) { foreach ( $caps as $cap ) { $graduate->remove_cap( $cap ); } } } // Add/remove caps to the current users. foreach ( $permission['specific_user'] as $user_index => $user_id ) { $user = get_user_by( 'ID', $user_id ); forminator_apply_capabilities( $user, $permission ); // Set user info. $permissions[ $key ]['user_info'][ $user_id ]['name'] = $user->display_name; $permissions[ $key ]['user_info'][ $user_id ]['email'] = $user->user_email; // We only need avatar for first user. if ( 0 === $user_index ) { $permissions[ $key ]['avatar'] = get_avatar_url( $user->user_email, array( 'size' => 30 ) ); } } // If role. } else { $role = get_role( $permission['user_role'] ); // Add/remove caps to the role. forminator_apply_capabilities( $role, $permission ); if ( empty( $permission['exclude_users'] ) ) { continue; } // Set user info for excluded users. foreach ( $permission['exclude_users'] as $user_id ) { $user = get_user_by( 'ID', $user_id ); if ( false !== $user ) { $permissions[ $key ]['user_info'][ $user_id ]['name'] = $user->display_name; $permissions[ $key ]['user_info'][ $user_id ]['email'] = $user->user_email; } } } } } /** * Delete mode. * * If specific users, get the missing users from new permission state then revoke their caps. * Add new caps if new ones are added. * * If role, add or remove caps as per new state. */ } elseif ( 'delete' === $post_data['mode'] ) { // If specific user. if ( 'specific' === $old_permission['permission_type'] ) { // Remove caps from users. foreach ( $old_permission['specific_user'] as $user_id ) { $graduate = get_user_by( 'ID', $user_id ); if ( false !== $graduate ) { foreach ( $caps as $cap ) { $graduate->remove_cap( $cap ); } } } // If role. } else { $role = get_role( $old_permission['user_role'] ); // Remove caps from the role. if ( ! is_null( $role ) ) { foreach ( $caps as $cap ) { $role->remove_cap( $cap ); } } } } } if ( update_option( 'forminator_permissions', $permissions ) ) { wp_send_json_success( $permissions ); } else { wp_send_json_error(); } } } PK!w|0-0-class-admin-data.phpnu[core = Forminator::get_instance(); } /** * Combine Data and pass to JS * * @return array * @since 1.0 */ public function get_options_data() { $data = $this->admin_js_defaults(); $data = apply_filters( 'forminator_data', $data ); $data['fields'] = forminator_get_fields_sorted( 'position', SORT_ASC ); $data['fieldsPro'] = forminator_get_pro_fields(); return $data; } /** * Generate nonce * * @since 1.2 */ public function generate_nonce() { $this->_nonce = wp_create_nonce( 'forminator_load_google_fonts' ); } /** * Get current generated nonce * * @return string * @since 1.2 */ public function get_nonce() { return $this->_nonce; } /** * Return published pages * * @return array */ public static function get_pages() { $cached_pages = wp_cache_get( 'forminator_cached_pages', 'forminator-cache' ); if ( false !== $cached_pages ) { return $cached_pages; } global $wpdb; $sql = "SELECT ID, post_title FROM {$wpdb->posts} WHERE post_type = 'page' AND post_status = 'publish' ORDER BY post_title ASC"; $pages = $wpdb->get_results( $sql ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery // Cache the result. wp_cache_set( 'forminator_cached_pages', $pages, 'forminator-cache' ); return $pages; } /** * Default Admin properties * * @return array * @since 1.0 */ public function admin_js_defaults() { // Generate addon nonce. Forminator_Integration_Admin_Ajax::get_instance()->generate_nonce(); $id = filter_input( INPUT_GET, 'id', FILTER_VALIDATE_INT ); $user = wp_get_current_user(); $dashboard = class_exists( 'WPMUDEV_Dashboard' ); return array( 'ajaxUrl' => forminator_ajax_url(), 'adminUrl' => admin_url(), 'siteUrl' => site_url(), 'akismetEnabled' => is_plugin_active( 'akismet/akismet.php' ), 'application' => '', 'is_touch' => wp_is_mobile(), 'dashboardUrl' => menu_page_url( 'forminator', false ), 'formEditUrl' => menu_page_url( 'forminator-cform-wizard', false ), 'noWrongEditUrl' => menu_page_url( 'forminator-nowrong-wizard', false ), 'knowledgeEditUrl' => menu_page_url( 'forminator-knowledge-wizard', false ), 'pollEditUrl' => menu_page_url( 'forminator-poll-wizard', false ), 'settingsUrl' => menu_page_url( 'forminator-settings', false ), 'integrationsUrl' => menu_page_url( 'forminator-integrations', false ), 'addonsUrl' => menu_page_url( 'forminator-addons', false ), 'hasCaptcha' => forminator_has_captcha_settings(), 'hasV2Captcha' => forminator_has_v2_captcha_settings(), 'hasV2InvisibleCaptcha' => forminator_has_v2_invisible_captcha_settings(), 'hasV3Captcha' => forminator_has_v3_captcha_settings(), 'hasHCaptcha' => forminator_has_hcaptcha_settings(), 'loadCaptcha' => wp_create_nonce( 'forminator_load_captcha_settings' ), 'hasStripe' => forminator_has_stripe_connected(), 'formNonce' => $this->get_nonce(), 'resetTrackingDataNonce' => wp_create_nonce( 'forminator_reset_tracking_data' ), 'createNonce' => wp_create_nonce( 'forminator_create_module' ), 'previewNonce' => wp_create_nonce( 'forminator_load_module' ), 'searchNonce' => wp_create_nonce( 'forminator_search_emails' ), 'gFontNonce' => wp_create_nonce( 'forminator_load_google_fonts' ), 'dismissNonce' => wp_create_nonce( 'forminator_dismiss_notification' ), 'formProcessNonce' => wp_create_nonce( 'forminator_form_request' ), 'formExportNonce' => wp_create_nonce( 'forminator_popup_export_form' ), 'pollProcessNonce' => wp_create_nonce( 'forminator_poll_request' ), 'pollExportNonce' => wp_create_nonce( 'forminator_popup_export_poll' ), 'quizProcessNonce' => wp_create_nonce( 'forminator_quiz_request' ), 'quizExportNonce' => wp_create_nonce( 'forminator_popup_export_quiz' ), 'cloneNonce' => wp_create_nonce( 'forminator-nonce-clone-' . $id ), 'load_cloud_templates' => wp_create_nonce( 'forminator_load_cloud_templates' ), 'save_cloud_templates' => wp_create_nonce( 'forminator_save_cloud_templates' ), 'create_form_nonce' => wp_create_nonce( 'forminator_create_form_from_template' ), 'disconnect_hub_nonce' => wp_create_nonce( 'forminator_disconnect_from_hub' ), 'templates_per_page' => apply_filters( 'forminator_templates_per_page', 100 ), 'addons_enabled' => Forminator::is_addons_feature_enabled(), 'pluginUrl' => forminator_plugin_url(), 'imagesUrl' => forminator_plugin_url() . 'assets/images', 'addonNonce' => Forminator_Integration_Admin_Ajax::get_instance()->get_nonce(), 'countries' => forminator_get_countries_list(), 'userList' => forminator_list_users(), 'variables' => forminator_get_vars(), 'variablesForHiddenField' => forminator_get_vars( true ), 'payment_variables' => forminator_get_payment_vars(), 'stripe_subscription_variables' => forminator_get_stripe_subscription_vars(), 'maxUpload' => forminator_get_max_upload(), 'captchaLangs' => forminator_get_captcha_languages(), 'erasure' => get_option( 'forminator_enable_erasure_request_erase_form_submissions', false ), 'retain_number' => get_option( 'forminator_retain_submissions_interval_number', 0 ), 'retain_unit' => get_option( 'forminator_retain_submissions_interval_unit', 'days' ), 'poll_ip_retain_number' => get_option( 'forminator_retain_votes_interval_number', 0 ), 'poll_ip_retain_unit' => get_option( 'forminator_retain_votes_interval_unit', 'days' ), 'submissions_ip_retain_number' => get_option( 'forminator_retain_poll_submissions_interval_number', 0 ), 'submissions_ip_retain_unit' => get_option( 'forminator_retain_poll_submissions_interval_unit', 'days' ), 'submissions_quiz_retain_number' => get_option( 'forminator_retain_quiz_submissions_interval_number', 0 ), 'submissions_quiz_retain_unit' => get_option( 'forminator_retain_quiz_submissions_interval_unit', 'days' ), 'skip_pro_notice' => get_option( 'forminator_skip_pro_notice', false ), 'fileExts' => forminator_get_ext_types(), 'version' => FORMINATOR_VERSION, 'showDocLink' => forminator_is_show_documentation_link(), 'showBranding' => forminator_is_show_branding(), 'currencies' => forminator_currency_list(), 'ppCurrencies' => forminator_pp_currency_list(), 'postTypeList' => forminator_post_type_list(), 'postCategories' => forminator_post_categories(), 'isPro' => FORMINATOR_PRO, 'isHubConnected' => false, 'dashboardPlugin' => $dashboard, 'isWPMUDEVloggedIn' => $dashboard && WPMUDEV_Dashboard::$api->get_key(), 'expiredMembership' => $dashboard && forminator_get_wpmudev_membership() === 'expired', 'userRoles' => forminator_get_accessible_user_roles(), 'pages' => self::get_pages(), 'hasPayPal' => forminator_has_paypal_settings(), 'pollAnswerColors' => forminator_get_poll_chart_colors(), 'isMainSite' => forminator_is_main_site(), 'isSubdomainNetwork' => forminator_is_subdomain_network(), 'showFieldSettings' => get_option( 'forminator_editor_settings', 'true' ), 'hasStripePro' => defined( 'FORMINATOR_STRIPE_ADDON' ) && class_exists( 'Forminator_Stripe_Addon' ), 'stripeForms' => $this->get_forms_by_field_type( 'stripe' ), 'paypalForms' => $this->get_forms_by_field_type( 'paypal' ), 'form_modules' => $this->get_modules( 'get_forms' ), 'quiz_modules' => $this->get_modules( 'get_quizzes' ), 'poll_modules' => $this->get_modules( 'get_polls' ), 'pdfAddonActive' => class_exists( 'Forminator_PDF_Addon' ), 'wpmudevMembership' => forminator_get_wpmudev_membership(), // 'free' 'pdfExtensionsEnabled' => $this->pdf_extensions_enabled(), 'userPermissions' => $user->get_role_caps(), 'manage_forminator_templates' => forminator_is_user_allowed( 'forminator-templates' ), 'cloudDisabled' => forminator_cloud_templates_disabled(), 'globalTracking' => forminator_global_tracking(), ); } /** * Get form by field * * @param string $type Field type. * * @return array */ public function get_forms_by_field_type( $type ) { $field_forms = array(); $forms = Forminator_Form_Model::model()->get_models( 99 ); if ( ! empty( $forms ) ) { foreach ( $forms as $form ) { if ( ! empty( $form->fields ) ) { foreach ( $form->fields as $f => $field ) { $field_array = $field->to_formatted_array(); $field_type = isset( $field_array['type'] ) ? $field_array['type'] : ''; if ( $type === $field_type || ( 'stripe' === $type && 'stripe-ocs' === $field_type ) ) { $field_forms[ $form->id ] = isset( $form->settings['formName'] ) ? $form->settings['formName'] : ''; } } } } } return $field_forms; } /** * Print forms select * * @param string $method Method time. * * @return array * @since 1.0 */ public function get_modules( $method ) { $modules = array(); $modules_data = Forminator_API::$method( null, 1, 999, 'publish' ); if ( ! empty( $modules_data ) ) { foreach ( $modules_data as $m => $module ) { $module = (array) $module; $title = forminator_get_form_name( $module['id'] ); if ( mb_strlen( $title ) > 25 ) { $title = mb_substr( $title, 0, 25 ) . '...'; } $modules[ $m ]['id'] = $module['id']; $modules[ $m ]['name'] = $title; } } return $modules; } /** * Check MPDF extensions. * * @since 1.25 * * @return bool */ public function pdf_extensions_enabled() { if ( function_exists( 'forminator_pdf_extensions_enabled' ) ) { return forminator_pdf_extensions_enabled(); } return false; } } PK!)thirdparty-importers/.htaccessnu6$ Order allow,deny Deny from all PK!x&/thirdparty-importers/class-importer-gravity.phpnu[ $field ) { $type = $this->get_thirdparty_field_type( $field['type'] ); if ( '' === $type ) { continue; } if ( isset( $count[ $type ] ) && $count[ $type ] > 0 ) { $count[ $type ] = $count[ $type ] + 1; } else { $count[ $type ] = 1; } $options = $field['choices']; $field_options = array(); $wrapper = 'wrapper-' . $this->random_wrapper_int() . '-' . $this->random_wrapper_int(); if ( ! empty( $options ) ) { foreach ( $options as $key => $option ) { $field_options[] = array( 'label' => esc_html( $option['text'] ), 'value' => esc_html( $option['value'] ), 'limit' => '', ); } } $new_fields[ $mkey ] = array( 'field_label' => esc_html( $field['label'] ), 'type' => esc_html( $type ), 'element_id' => esc_html( $type . '-' . $count[ $type ] ), 'cols' => 12, 'wrapper_id' => $wrapper, 'options' => $field_options, 'required' => filter_var( $field['isRequired'], FILTER_VALIDATE_BOOLEAN ), 'custom-class' => $field['cssClass'], 'description' => $field['description'], 'placeholder' => esc_html( $field['placeholder'] ), ); if ( 'address' === $type ) { foreach ( $field['inputs'] as $key => $input ) { if ( '4.1' === $input['id'] ) { $new_fields[ $mkey ]['street_address'] = ! isset( $input['isHidden'] ); } elseif ( '4.2' === $input['id'] ) { $new_fields[ $mkey ]['address_line'] = ! isset( $input['isHidden'] ); } elseif ( '4.3' === $input['id'] ) { $new_fields[ $mkey ]['address_city'] = ! isset( $input['isHidden'] ); } elseif ( '4.4' === $input['id'] ) { $new_fields[ $mkey ]['address_state'] = ! isset( $input['isHidden'] ); } elseif ( '4.5' === $input['id'] ) { $new_fields[ $mkey ]['address_zip'] = ! isset( $input['isHidden'] ); } elseif ( '4.6' === $input['id'] ) { $new_fields[ $mkey ]['address_country'] = ! isset( $input['isHidden'] ); } } } if ( 'multiselect' === $field['type'] ) { $new_fields[ $mkey ]['value_type'] = 'multiselect'; } if ( 'page' === $field['type'] ) { $new_fields[ $mkey ]['btn_left'] = $field['previousButton']['text']; $new_fields[ $mkey ]['btn_right'] = $field['nextButton']['text']; } $tag_key = $field['label'] . ':' . $field['id']; $tags[ "{$tag_key}" ] = $new_fields[ $mkey ]['element_id']; }//endforeach fields import $settings['use-admin-email'] = false; $settings['use-user-email'] = false; // form actions. if ( ! empty( $notifications ) ) { foreach ( $notifications as $key => $action ) { if ( 'email' === $action['toType'] ) { if ( isset( $action['to'] ) && '{admin_email}' === $action['to'] && false === $settings['use-admin-email'] ) { $settings['use-admin-email'] = true; $settings['admin-email-title'] = ( isset( $action['subject'] ) ? $this->replace_invalid_tags( $action['subject'], $tags ) : '' ); $settings['admin-email-editor'] = ( isset( $action['message'] ) ? $this->replace_invalid_tags( $action['message'], $tags ) : '' ); $settings['admin-email-from-name'] = ( isset( $action['fromName'] ) ? $this->replace_invalid_tags( $action['fromName'], $tags ) : '' ); $settings['admin-email-recipients'] = get_bloginfo( 'admin_email' ); $settings['admin-email-bcc-address'] = ( isset( $action['bcc'] ) ? $this->replace_invalid_tags( $action['bcc'], $tags ) : '' ); $settings['admin-email-cc-address'] = ( isset( $action['cc'] ) ? $this->replace_invalid_tags( $action['cc'], $tags ) : '' ); $settings['admin-email-reply-to-address'] = ( isset( $action['replyTo'] ) ? $this->replace_invalid_tags( $action['replyTo'], $tags ) : '' ); } elseif ( isset( $action['to'] ) && '{admin_email}' !== $action['to'] && false === $settings['use-user-email'] ) { $settings['use-user-email'] = true; $settings['user-email-title'] = ( isset( $action['subject'] ) ? $this->replace_invalid_tags( $action['subject'], $tags ) : '' ); $settings['user-email-editor'] = ( isset( $action['message'] ) ? $this->replace_invalid_tags( $action['message'], $tags ) : '' ); $settings['user-email-from-name'] = ( isset( $action['fromName'] ) ? $this->replace_invalid_tags( $action['fromName'], $tags ) : '' ); $settings['user-email-recipients'] = ( isset( $action['to'] ) ? $this->replace_invalid_tags( $action['to'], $tags ) : '' ); $settings['user-email-bcc-address'] = ( isset( $action['bcc'] ) ? $this->replace_invalid_tags( $action['bcc'], $tags ) : '' ); $settings['user-email-cc-address'] = ( isset( $action['cc'] ) ? $this->replace_invalid_tags( $action['cc'], $tags ) : '' ); $settings['user-email-reply-to-address'] = ( isset( $action['replyTo'] ) ? $this->replace_invalid_tags( $action['replyTo'], $tags ) : '' ); } } } }//end settings loop $action = ( ! empty( $confirmations ) ? current( $confirmations ) : '' ); if ( ! empty( $action ) && isset( $action['type'] ) ) { switch ( $action['type'] ) { case 'page': case 'redirect': $settings['submission-behaviour'] = 'behaviour-redirect'; $url = ( isset( $action['pageid'] ) ? get_permalink( $action['pageid'] ) : $action['url'] ); $settings['redirect-url'] = esc_url( $url ); break; case 'message': $settings['submission-behaviour'] = 'behaviour-thankyou'; $settings['thankyou-message'] = $action['message']; break; default: break; } } // final settings. $settings['formName'] = esc_html( $form['title'] ); $settings['custom-submit-text'] = esc_html( $form['button']['text'] ); // form data. $data['status'] = 'publish'; $data['version'] = FORMINATOR_VERSION; $data['type'] = 'form'; $data['data']['fields'] = $new_fields; $data['data']['settings'] = $settings; $data = apply_filters( 'forminator_gravity_form_import_data', $data ); $import = $this->try_form_import( $data ); return $import; } } PK!Y;l&66-thirdparty-importers/class-importer-ninja.phpnu[ 'value') or array('value') $position : the position where the new array will be inserted into. Please mind that arrays start at 0 */ return array_slice( $data, 0, $position, true ) + $insert + array_slice( $data, $position, null, true ); } /** * Insert form data * * @param int $id Form id. * * @since 1.7 * @return array Form import message */ public function import_form( $id ) { $form = Ninja_Forms()->form( $id ); $form_fields = $form->get_fields(); $actions = $form->get_actions(); $pagination = ( ! empty( $form->get()->get_setting( 'formContentData' ) ) ? $form->get()->get_setting( 'formContentData' ) : array() ); $data = array(); $new_fields = array(); $settings = array(); $tags = array(); $count = array(); $page_total = 0; $mkey = 0; // multipart. if ( $this->ninja_multipart() && isset( $pagination[0]['formContentData'] ) ) { $page_total = count( $pagination ); foreach ( $pagination as $key => $value ) { $page_key = call_user_func( 'end', array_values( $value['formContentData'] ) ); $page[ "{$page_key}" ] = $value['order'] + 1; } } // fields import. foreach ( $form_fields as $key => $field ) { $type = $this->get_thirdparty_field_type( $field->get_setting( 'type' ) ); if ( '' === $type ) { continue; } if ( 'submit' === $type ) { $submit_label = esc_html( $field->get_setting( 'label' ) ); } else { if ( isset( $count[ $type ] ) && $count[ $type ] > 0 ) { $count[ $type ] = $count[ $type ] + 1; } else { $count[ $type ] = 1; } $options = $field->get_setting( 'options' ); $field_options = array(); $wrapper = 'wrapper-' . $this->random_wrapper_int() . '-' . $this->random_wrapper_int(); if ( ! empty( $options ) ) { foreach ( $options as $key => $option ) { $field_options[] = array( 'label' => esc_html( $option['label'] ), 'value' => esc_html( $option['value'] ), 'limit' => '', ); } } $new_fields[ $mkey ] = array( 'field_label' => esc_html( $field->get_setting( 'label' ) ), 'type' => esc_html( $type ), 'element_id' => esc_html( $type . '-' . $count[ $type ] ), 'cols' => 12, 'wrapper_id' => $wrapper, 'options' => $field_options, 'required' => filter_var( $field->get_setting( 'required' ), FILTER_VALIDATE_BOOLEAN ), 'custom-class' => $field->get_setting( 'element_class' ), 'description' => ( ! empty( $field->get_setting( 'desc_text' ) ) ? $field->get_setting( 'desc_text' ) : '' ), 'placeholder' => $field->get_setting( 'placeholder' ), ); if ( 'address' === $type ) { if ( 'address' === $field->get_setting( 'type' ) ) { $new_fields[ $mkey ]['street_address'] = true; $new_fields[ $mkey ]['address_city'] = true; $new_fields[ $mkey ]['address_state'] = true; $new_fields[ $mkey ]['address_zip'] = true; $new_fields[ $mkey ]['address_country'] = true; $new_fields[ $mkey ]['address_line'] = true; } elseif ( 'city' === $field->get_setting( 'type' ) ) { $new_fields[ $mkey ]['address_city'] = true; } elseif ( 'zip' === $field->get_setting( 'type' ) ) { $new_fields[ $mkey ]['address_zip'] = true; } elseif ( 'country' === $field->get_setting( 'type' ) ) { $new_fields[ $mkey ]['address_country'] = true; } } if ( 'multiselect' === $type ) { $new_fields[ $mkey ]['value_type'] = 'multiselect'; } } $tag_key = $field->get_setting( 'key' ); $tags[ "{$tag_key}" ] = "{$new_fields[$mkey]['element_id']}"; if ( isset( $page[ "{$tag_key}" ] ) && $page[ "{$tag_key}" ] < $page_total ) { ++$mkey; $element_key = $page[ "{$tag_key}" ]; $new_fields[ $mkey ] = array( 'type' => 'pagination', 'element_id' => esc_html( 'pagination-' . $element_key ), 'cols' => 12, 'wrapper_id' => 'wrapper-' . $this->random_wrapper_int() . '-' . $this->random_wrapper_int(), ); } ++$mkey; }//endforeach fields import $settings['use-admin-email'] = false; $settings['use-user-email'] = false; // form actions. foreach ( $actions as $key => $action ) { $action = $action->get_settings(); $active = filter_var( $action['active'], FILTER_VALIDATE_BOOLEAN ); if ( false === $active ) { continue; } if ( 'email' === $action['type'] ) { // admin email detection. if ( isset( $action['to'] ) && '{system:admin_email}' === $action['to'] && false === $settings['use-admin-email'] ) { $settings['use-admin-email'] = true; $settings['admin-email-title'] = $this->replace_invalid_tags( $action['email_subject'], $tags ); $settings['admin-email-editor'] = $this->replace_invalid_tags( $action['email_message'], $tags ); $settings['admin-email-from-name'] = $this->replace_invalid_tags( $action['reply_to'], $tags ); $settings['admin-email-recipients'] = get_bloginfo( 'admin_email' ); } // get the first user notification action. if ( isset( $action['to'] ) && '{system:admin_email}' !== $action['to'] && false === $settings['use-user-email'] ) { $settings['use-user-email'] = true; $settings['user-email-title'] = $this->replace_invalid_tags( $action['email_subject'], $tags ); $settings['user-email-editor'] = $this->replace_invalid_tags( $action['email_message'], $tags ); $settings['user-email-from-name'] = $this->replace_invalid_tags( $action['reply_to'], $tags ); $settings['user-email-recipients'] = $this->replace_invalid_tags( $action['to'], $tags ); } } elseif ( 'redirect' === $action['type'] ) { $settings['submission-behaviour'] = 'behaviour-redirect'; $settings['redirect-url'] = $action['redirect_url']; } elseif ( 'successmessage' === $action['type'] && ! isset( $settings['submission-behaviour'] ) ) { $settings['submission-behaviour'] = 'behaviour-thankyou'; $settings['thankyou-message'] = $action['message']; } elseif ( 'save' === $action['type'] ) { $settings['store_submissions'] = $action['active']; } }//endforeach form actions // final settings. $settings['formName'] = esc_html( $form->get()->get_setting( 'title' ) ); $settings['custom-submit-text'] = isset( $submit_label ) ? $submit_label : ''; // form data. $data['status'] = 'publish'; $data['version'] = FORMINATOR_VERSION; $data['type'] = 'form'; $data['data']['fields'] = $new_fields; $data['data']['settings'] = $settings; $data = apply_filters( 'forminator_ninja_form_import_data', $data ); $import = $this->try_form_import( $data ); return $import; } } PK!ڕڕ+thirdparty-importers/class-importer-cf7.phpnu[' ) ); } else { $label_html = trim( strip_tags( $matches[2], '' ) ); } $form = preg_replace( $regex, '', $form ); $is_tag = strpos( $label_html, '[' ); // get label from form html. if ( isset( $label_html ) && ! empty( $label_html ) && false === $is_tag ) { return trim( rtrim( $label_html ) ); } } return ''; } /** * Insert form data * * @param int $id Form Id. * @param array $post_data Post Data. * * @return array|object */ public function import_form( $id, $post_data = array() ) { $form = wpcf7_contact_form( intval( $id ) ); $form_fields = $form->scan_form_tags(); $form_html = $form->prop( 'form' ); $mail = $form->prop( 'mail' ); $mail_2 = $form->prop( 'mail_2' ); $messages = $form->prop( 'messages' ); $data = array(); $count = array(); $new_fields = array(); $settings = array( 'form-type' => 'default', 'pagination-header' => 'nav', 'form-border-style' => 'solid', 'basic-form-border-style' => 'solid', 'form-padding' => '', 'basic-form-padding' => '', 'form-border' => '', 'basic-form-border' => '', 'fields-style' => 'open', 'basic-fields-style' => 'open', 'validation' => 'on_submit', 'form-style' => 'default', 'form-substyle' => 'default', 'enable-ajax' => 'true', 'autoclose' => 'true', 'submission-indicator' => 'show', 'indicator-label' => esc_html__( 'Submitting...', 'forminator' ), 'paginationData' => array( 'pagination-header-design' => 'show', 'pagination-header' => 'nav', ), ); $tags = array(); $entry_meta = array(); $cf7_addons = ! empty( $post_data['cf7-addons'] ) ? $post_data['cf7-addons'] : array(); $honeypot = false; $global = array(); $field_data = $this->get_fields_data( $form_fields ); $entry = new Forminator_Form_Entry_Model(); $entry->entry_type = 'custom-forms'; $wpcf7cf_entries = array(); $submit_label = ''; $submit_class = ''; $autofill = array(); // fields import. if ( is_plugin_active( 'cf7-conditional-fields/contact-form-7-conditional-fields.php' ) && in_array( 'conditional', $cf7_addons, true ) ) { $wpcf7cf_entries = CF7CF::getConditions( $id ); } foreach ( $form_fields as $mkey => $field ) { $custom_class = ''; $form_placeholder = ''; $default_value = ''; $options = array(); $condition = array(); $blank_options = array(); $type = $this->get_thirdparty_field_type( $field->basetype ); if ( 'honeypot' === $type && in_array( 'honeypot', $cf7_addons, true ) ) { $honeypot = true; } if ( 'honeypot' === $type || empty( $type ) ) { continue; } $wrapper = 'wrapper-' . $this->random_wrapper_int() . '-' . $this->random_wrapper_int(); if ( 'submit' === $field['type'] ) { $submit_label = $field->labels[0]; if ( isset( $field['options'] ) ) { $classes = preg_grep( '/^class:/', $field['options'] ); if ( ! empty( $classes ) ) { foreach ( $classes as $class_value ) { $exploded = explode( ':', $class_value ); if ( isset( $exploded[1] ) ) { $submit_class .= $exploded[1] . ' '; } } } } } else { if ( isset( $count[ $type ] ) && $count[ $type ] > 0 ) { $count[ $type ] = $count[ $type ] + 1; } else { $count[ $type ] = 1; } if ( ! empty( $field->labels ) && ( 'select' === $type || 'radio' === $type || 'checkbox' === $type ) ) { $checked = array(); $after_pipes = array(); if ( isset( $field['options'] ) ) { $has_blank = preg_grep( '/^include_blank/', $field['options'] ); $has_values = preg_grep( '/^default:/', $field['options'] ); if ( ! empty( $has_values ) ) { $keys = array_keys( $has_values ); $explode_default = explode( ':', $has_values[ $keys[0] ] ); if ( isset( $explode_default[1] ) ) { $checked = explode( '_', $explode_default[1] ); } } } if ( $field->pipes instanceof WPCF7_Pipes ) { $after_pipes = $field->pipes->collect_afters(); } if ( ! empty( $has_blank ) ) { $blank_options[] = array( 'label' => '---', 'value' => '', 'limit' => '', 'default' => '', ); } foreach ( $field->labels as $key => $label ) { $options[] = array( 'label' => esc_html( $label ), 'value' => isset( $after_pipes[ $key ] ) ? esc_html( $after_pipes[ $key ] ) : esc_html( $field->values[ $key ] ), 'limit' => '', 'default' => in_array( $key + 1, $checked ), // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict -- Possible for 1 or '1' ); } $options = array_merge( $blank_options, $options ); } if ( 'acceptance' === $field['type'] ) { $gdpr = true; } if ( isset( $field['options'] ) ) { $classes = preg_grep( '/^class:/', $field['options'] ); if ( ! empty( $classes ) ) { foreach ( $classes as $class_value ) { $exploded = explode( ':', $class_value ); if ( isset( $exploded[1] ) ) { $custom_class .= $exploded[1] . ' '; } } } } if ( isset( $field['options'] ) ) { $placeholder = preg_grep( '/^placeholder/', $field['options'] ); $field_value = ( isset( $field['values'] ) && isset( $field['values'][0] ) ) ? $field['values'][0] : ''; if ( ! empty( $placeholder ) ) { $form_placeholder = $field_value; } else { $default_value = $field_value; } } $entry_meta[ $field['name'] ] = $type . '-' . $count[ $type ]; if ( in_array( 'cfdb7', $cf7_addons, true ) && 'upload' === $type ) { $entry_meta[ $field['name'] . 'cfdb7_file' ] = $type . '-' . $count[ $type ]; } $condition = $this->import_conditional_field( $wpcf7cf_entries, $form_html, $field, $field_data ); if ( 'captcha' === $type ) { $global['captchaV2'] = true; $condition = array(); $field_name = esc_html__( 'reCaptcha', 'forminator' ); } else { $field_name = esc_html( $this->get_label_cf7( $field->name, $form_html ) ); } $new_fields[ $mkey ] = array( 'element_id' => esc_html( $type . '-' . $count[ $type ] ), 'placeholder' => esc_html( $form_placeholder ), 'type' => esc_html( $type ), 'wrapper_id' => $wrapper, 'form_id' => $wrapper, 'cols' => 12, 'required' => substr( $field['type'], - 1, 1 ) === '*' ? true : false, 'field_label' => $field_name, 'options' => $options, 'default' => esc_html( $default_value ), 'default_value' => esc_html( $default_value ), 'custom-class' => trim( $custom_class ), 'conditions' => $condition, ); // Handle specific field options. switch ( $field['basetype'] ) { case 'select': $new_fields[ $mkey ] = $this->handle_select_field( $field, $new_fields[ $mkey ], $messages ); break; case 'text': $new_fields[ $mkey ] = $this->handle_text_field( $field, $new_fields[ $mkey ], $messages ); break; case 'textarea': $new_fields[ $mkey ] = $this->handle_text_field( $field, $new_fields[ $mkey ], $messages ); break; case 'number': $new_fields[ $mkey ] = $this->handle_number_field( $field, $new_fields[ $mkey ], $messages ); break; case 'file': $new_fields[ $mkey ] = $this->handle_upload_field( $field, $new_fields[ $mkey ], $messages ); break; case 'acceptance': $new_fields[ $mkey ] = $this->handle_acceptance_field( $field, $new_fields[ $mkey ], $messages ); break; case 'date': $new_fields[ $mkey ] = $this->handle_date_field( $field, $new_fields[ $mkey ], $messages ); break; case 'url': $new_fields[ $mkey ] = $this->handle_url_field( $field, $new_fields[ $mkey ], $messages ); break; case 'tel': $new_fields[ $mkey ] = $this->handle_phone_field( $field, $new_fields[ $mkey ], $messages ); break; case 'email': $new_fields[ $mkey ] = $this->handle_email_field( $field, $new_fields[ $mkey ], $messages ); break; case 'captcha': $new_fields[ $mkey ] = $this->handle_captcha_field( $field, $new_fields[ $mkey ], $messages ); break; case 'checkbox': $new_fields[ $mkey ] = $this->handle_checkbox_field( $field, $new_fields[ $mkey ], $messages ); break; default: break; } $tag_key = $field['name']; $tags[ "[$tag_key]" ] = '{' . $new_fields[ $mkey ]['element_id'] . '}'; if ( isset( $field['options'] ) ) { $has_default_values = preg_grep( '/^default:/', $field['options'] ); if ( ! empty( $has_default_values ) ) { $has_default_values = array_values( $has_default_values ); $explode_default_value = explode( ':', $has_default_values[0] ); if ( isset( $explode_default_value[1] ) ) { $default_tag = $this->replace_default_tags( $explode_default_value[1] ); $default_field = esc_html( $type . '-' . $count[ $type ] ); if ( ! empty( $default_tag ) ) { $autofill[ $mkey ]['element_id'] = $default_field; $autofill[ $mkey ]['provider'] = $default_tag; $autofill[ $mkey ]['is_editable'] = 'yes'; } } } } } }//endforeach fields // admin mail import. $settings['use-admin-email'] = false; if ( isset( $mail['active'] ) && true === $mail['active'] ) { $settings['use-admin-email'] = true; $settings['admin-email-title'] = $this->replace_invalid_tags( $mail['subject'], $tags ); $settings['admin-email-editor'] = $this->replace_invalid_tags( $mail['body'], $tags ); $admin_email_from = $this->replace_invalid_tags( $mail['sender'], $tags ); if ( preg_match( '/^([^\<]*)(?:\<([^\>]*)\>)?$/u', $admin_email_from, $matches ) ) { $settings['admin-email-from-name'] = isset( $matches[1] ) ? $matches[1] : ''; $settings['admin-email-from-address'] = isset( $matches[2] ) ? $matches[2] : ''; } $header_pattern = '/(reply-to|bcc|cc):(.+?)(?= reply-to:| bcc:| cc:|$)/i'; $additional_headers = trim( preg_replace( '/\s+/', ' ', $mail['additional_headers'] ) ); if ( preg_match_all( $header_pattern, $additional_headers, $header_matches ) ) { $regex_header = array_change_key_case( array_combine( $header_matches[1], $header_matches[2] ), CASE_LOWER ); if ( ! empty( $regex_header['reply-to'] ) ) { $reply_tag = $this->replace_invalid_tags( $regex_header['reply-to'], $tags ); $settings['admin-email-reply-to-address'] = trim( $reply_tag ); } if ( ! empty( $regex_header['bcc'] ) ) { $bcc_tag = $this->replace_invalid_tags( $regex_header['bcc'], $tags ); $settings['admin-email-bcc-address'] = explode( ',', trim( $bcc_tag ) ); } if ( ! empty( $regex_header['cc'] ) ) { $cc_tag = $this->replace_invalid_tags( $regex_header['cc'], $tags ); $settings['admin-email-cc-address'] = explode( ',', trim( $cc_tag ) ); } } $settings['admin-email-recipients'] = explode( ' ', $this->replace_invalid_tags( $mail['recipient'], $tags ) ); } // autoresponder import. $settings['use-user-email'] = false; if ( isset( $mail_2['active'] ) && true === $mail_2['active'] ) { $settings['use-user-email'] = true; $settings['user-email-title'] = $this->replace_invalid_tags( $mail_2['subject'], $tags ); $settings['user-email-editor'] = $this->replace_invalid_tags( $mail_2['body'], $tags ); $user_email_from = $this->replace_invalid_tags( $mail_2['sender'], $tags ); if ( preg_match( '/^([^\<]*)(?:\<([^\>]*)\>)?$/u', $user_email_from, $matches ) ) { $settings['user-email-from-name'] = isset( $matches[1] ) ? $matches[1] : ''; $settings['user-email-from-address'] = isset( $matches[2] ) ? $matches[2] : ''; } $user_header_pattern = '/(reply-to|bcc|cc):(.+?)(?= reply-to:| bcc:| cc:|$)/i'; $user_additional_headers = trim( preg_replace( '/\s+/', ' ', $mail_2['additional_headers'] ) ); if ( preg_match_all( $user_header_pattern, $user_additional_headers, $user_header_matches ) ) { $user_regex_header = array_change_key_case( array_combine( $user_header_matches[1], $user_header_matches[2] ), CASE_LOWER ); if ( ! empty( $user_regex_header['reply-to'] ) ) { $user_reply_tag = $this->replace_invalid_tags( $user_regex_header['reply-to'], $tags ); $settings['user-email-reply-to-address'] = trim( $user_reply_tag ); } if ( ! empty( $user_regex_header['bcc'] ) ) { $user_bcc_tag = $this->replace_invalid_tags( $user_regex_header['bcc'], $tags ); $settings['user-email-bcc-address'] = explode( ',', trim( $user_bcc_tag ) ); } if ( ! empty( $user_regex_header['cc'] ) ) { $user_cc_tag = $this->replace_invalid_tags( $user_regex_header['cc'], $tags ); $settings['user-email-cc-address'] = explode( ',', trim( $user_cc_tag ) ); } } $settings['user-email-recipients'] = explode( ' ', $this->replace_invalid_tags( $mail_2['recipient'], $tags ) ); } // form settings basic import. $settings['formName'] = esc_html( get_the_title( $id ) ); $settings['thankyou-message'] = $messages['mail_sent_ok']; $settings['custom-invalid-form-message'] = $messages['validation_error']; $settings['honeypot'] = $honeypot; $settings['enable-ajax'] = 'true'; $settings['validation-inline'] = true; $settings['validation'] = 'on_submit'; if ( ! empty( $autofill ) ) { $settings['use-autofill'] = true; $settings['fields-autofill'] = array_values( $autofill ); } // form submit data settings. $settings['submitData']['custom-submit-text'] = $submit_label; $settings['submitData']['custom-class'] = $submit_class; if ( is_plugin_active( 'wpcf7-redirect/wpcf7-redirect.php' ) && in_array( 'redirection', $cf7_addons, true ) ) { $redirect = new WPCF7_Redirect(); if ( method_exists( $redirect, 'get_fields_values' ) ) { // For old wpcf7-redirect plugin. $redirect_meta = $redirect->get_fields_values( $id ); } else { // For new wpcf7-redirect plugin after their update. $redirect = new WPCF7R_Form( $id ); $redirect_meta = $redirect->get_cf7_redirection_settings(); } if ( ! empty( $redirect_meta['page_id'] ) || ! empty( $redirect_meta['external_url'] ) ) { if ( $redirect_meta['external_url'] && 'on' === $redirect_meta['use_external_url'] ) { $redirect_url = $redirect_meta['external_url']; } else { $redirect_url = get_permalink( $redirect_meta['page_id'] ); } $settings['submission-behaviour'] = 'behaviour-redirect'; $settings['redirect-url'] = $redirect_url; $settings['newtab'] = 'on' === $redirect_meta['open_in_new_tab'] ? 'newtab_thankyou' : 'sametab'; } } // for basics generation. $data['status'] = get_post_status( $id ); $data['version'] = FORMINATOR_VERSION; $data['type'] = 'form'; $data['data']['fields'] = $new_fields; $data['data']['settings'] = $settings; $data = apply_filters( 'forminator_cf7_form_import_data', $data ); $import = $this->try_form_import( $data ); $this->import_global_settings( $global ); if ( is_plugin_active( 'flamingo/flamingo.php' ) && in_array( 'flamingo', $cf7_addons, true ) ) { $this->import_flamingo( $id, $entry, $import, $entry_meta ); } if ( is_plugin_active( 'contact-form-cfdb7/contact-form-cfdb-7.php' ) && in_array( 'cfdb7', $cf7_addons, true ) ) { $this->import_cfdb7( $id, $entry, $import, $entry_meta ); } if ( is_plugin_active( 'contact-form-submissions/contact-form-submissions.php' ) && in_array( 'submissions', $cf7_addons, true ) ) { $this->import_submissions( $id, $entry, $import, $entry_meta ); } if ( is_plugin_active( 'advanced-cf7-db/advanced-cf7-db.php' ) && in_array( 'advanced_cf7', $cf7_addons, true ) ) { $this->import_advanced_cf7( $id, $entry, $import, $entry_meta ); } return $import; } /** * Handle select field specific options * * @since 1.11 * * @param array $field Field. * @param array $options Options. * @param array $messages Messages. * * @return mixed */ public function handle_select_field( $field, $options, $messages ) { // Check if select field has any options. $options['value_type'] = 'single'; if ( isset( $field['options'] ) ) { // Check if multiple option enabled. if ( in_array( 'multiple', $field['options'], true ) ) { $options['value_type'] = 'multiselect'; } } if ( ! empty( $messages['invalid_required'] ) ) { $options['required_message'] = $messages['invalid_required']; } return $options; } /** * Handle checkbox field specific options * * @since 1.11 * * @param array $field Field. * @param array $options Options. * @param array $messages Messages. * * @return mixed */ public function handle_checkbox_field( $field, $options, $messages ) { if ( ! empty( $messages['invalid_required'] ) ) { $options['required_message'] = $messages['invalid_required']; } return $options; } /** * Handle text field specific options * * @since 1.11 * * @param array $field Field. * @param array $options Options. * @param array $messages Messages. * * @return mixed */ public function handle_text_field( $field, $options, $messages ) { if ( isset( $field['options'] ) ) { $max_length = preg_grep( '/^maxlength:/', $field['options'] ); if ( ! empty( $max_length ) ) { foreach ( $max_length as $length ) { $exploded = explode( ':', $length ); if ( isset( $exploded[1] ) ) { $options['limit'] = $exploded[1]; $options['limit_type'] = 'characters'; } } } if ( ! empty( $messages['invalid_required'] ) ) { $options['required_message'] = $messages['invalid_required']; } } return $options; } /** * Handle number field specific options * * @since 1.11 * * @param array $field Field. * @param array $options Options. * @param array $messages Messages. * * @return mixed */ public function handle_number_field( $field, $options, $messages ) { if ( isset( $field['options'] ) ) { $min = preg_grep( '/^min:/', $field['options'] ); $max = preg_grep( '/^max:/', $field['options'] ); if ( ! empty( $min ) ) { foreach ( $min as $length ) { $exploded = explode( ':', $length ); if ( isset( $exploded[1] ) ) { $options['limit_min'] = $exploded[1]; } } } if ( ! empty( $max ) ) { foreach ( $max as $length ) { $exploded = explode( ':', $length ); if ( isset( $exploded[1] ) ) { $options['limit_max'] = $exploded[1]; } } } } if ( ! empty( $messages['invalid_required'] ) ) { $options['required_message'] = $messages['invalid_required']; } return $options; } /** * Handle GDPR field specific options * * @since 1.11 * * @param array $field Field. * @param array $options Options. * @param array $messages Messages. * * @return mixed */ public function handle_acceptance_field( $field, $options, $messages ) { // Check if content exists. if ( isset( $field['content'] ) ) { $options['gdpr_description'] = $field['content']; } if ( ! empty( $messages['accept_terms'] ) ) { $options['required_message'] = $messages['accept_terms']; } return $options; } /** * Handle Date field specific options * * @since 1.11 * * @param array $field Field. * @param array $options Options. * @param array $messages Messages. * * @return mixed */ public function handle_date_field( $field, $options, $messages ) { $field_value = ( isset( $field['values'] ) && isset( $field['values'][0] ) ) ? $field['values'][0] : ''; if ( isset( $field['options'] ) ) { $min = preg_grep( '/^min:/', $field['options'] ); $max = preg_grep( '/^max:/', $field['options'] ); if ( ! empty( $min ) ) { foreach ( $min as $length ) { $exploded = explode( ':', $length ); if ( isset( $exploded[1] ) ) { $options['min_year'] = gmdate( 'Y', strtotime( $exploded[1] ) ); } } } if ( ! empty( $max ) ) { foreach ( $max as $length ) { $exploded = explode( ':', $length ); if ( isset( $exploded[1] ) ) { $options['max_year'] = gmdate( 'Y', strtotime( $exploded[1] ) ); } } } } if ( ! empty( $field_value ) ) { $options['default_date'] = 'custom'; $options['date'] = $field_value; } if ( ! empty( $messages['invalid_required'] ) ) { $options['required_message'] = $messages['invalid_required']; } $options['field_type'] = 'picker'; $options['date_format'] = 'dd/mm/yy'; return $options; } /** * Handle Phone field specific options * * @since 1.11 * * @param array $field Field. * @param array $options Options. * @param array $messages Messages. * * @return mixed */ public function handle_phone_field( $field, $options, $messages ) { if ( ! empty( $messages['invalid_required'] ) ) { $options['required_message'] = $messages['invalid_required']; } if ( ! empty( $messages['invalid_tel'] ) ) { $options['validation_message'] = $messages['invalid_tel']; } return $options; } /** * Handle email field specific options * * @since 1.11 * * @param array $field Field. * @param array $options Options. * @param array $messages Messages. * * @return mixed */ public function handle_email_field( $field, $options, $messages ) { if ( ! empty( $messages['invalid_required'] ) ) { $options['required_message'] = $messages['invalid_required']; } if ( ! empty( $messages['invalid_email'] ) ) { $options['validation_message'] = $messages['invalid_email']; } return $options; } /** * Handle Captcha field specific options * * @since 1.11 * * @param array $field Field. * @param array $options Options. * @param array $messages Messages. * * @return mixed */ public function handle_captcha_field( $field, $options, $messages ) { if ( ! empty( $messages['captcha_not_match'] ) ) { $options['recaptcha_error_message'] = $messages['captcha_not_match']; } return $options; } /** * Handle URL field specific options * * @since 1.11 * * @param array $field Field. * @param array $options Options. * @param array $messages Messages. * * @return mixed */ public function handle_url_field( $field, $options, $messages ) { if ( ! empty( $messages['invalid_required'] ) ) { $options['required_message'] = $messages['invalid_required']; } if ( ! empty( $messages['invalid_url'] ) ) { $options['validation_message'] = $messages['invalid_url']; } return $options; } /** * Handle upload field specific options * * @since 1.11 * * @param array $field Field. * @param array $options Options. * @param array $messages Messages. * * @return mixed */ public function handle_upload_field( $field, $options, $messages ) { if ( isset( $field['options'] ) ) { $limit_value = preg_grep( '/^limit:/', $field['options'] ); $types_value = preg_grep( '/^filetypes:/', $field['options'] ); // Handle size limit options. if ( ! empty( $limit_value ) ) { foreach ( $limit_value as $limit ) { $exploded = explode( ':', $limit ); if ( isset( $exploded[1] ) ) { $options['upload-limit'] = $this->convert_limit_to_mb( $exploded[1] ); } } } // Handle file types. if ( ! empty( $types_value ) ) { foreach ( $types_value as $types_values ) { $exploded = explode( ':', $types_values ); if ( isset( $exploded[1] ) ) { $types = explode( '|', $exploded[1] ); $filtered = array(); foreach ( $types as $type ) { $filtered[] = $this->filter_filetypes( $type ); } $options['filetypes'] = $filtered; $options['custom-files'] = true; } } } } return $options; } /** * Convert limit to MB * * @since 1.11 * * @param int $limit Limit. * * @return float|string */ public function convert_limit_to_mb( $limit ) { if ( stripos( $limit, 'mb' ) !== false ) { // Limit is already in MB, return value. return mb_substr( $limit, 0, - 2 ); } if ( stripos( $limit, 'kb' ) !== false ) { $limit = mb_substr( $limit, 0, - 2 ); // Limit is in KB, we need to convert to MB. return round( $limit / 1024, 2 ); } return round( $limit / 1024 / 1024, 2 ); } /** * Filter file types to WP mime types * * @since 1.11 * * @param string $file File type. * * @return string */ public function filter_filetypes( $file ) { switch ( $file ) { case 'jpg': $file = 'jpg|jpeg|jpe'; break; case 'jpeg': $file = 'jpg|jpeg|jpe'; break; case 'mp3': $file = 'mp3|m4a|m4b'; break; case '3gp': $file = '3gp|3gpp'; break; case 'mp4': $file = 'mp4|m4v'; break; case 'mpeg': $file = 'mpeg|mpg|mpe'; break; case 'mpg': $file = 'mpeg|mpg|mpe'; break; case 'mov': $file = 'mov|qt'; break; case 'tiff': $file = 'tiff|tif'; break; case 'tif': $file = 'tiff|tif'; break; default: break; } return $file; } /** * Import flamingo * * @param int $id Post Id. * @param Forminator_Form_Entry_Model $entry Form entry model. * @param array $import Import. * @param array $meta Meta. */ public function import_flamingo( $id, Forminator_Form_Entry_Model $entry, $import, $meta ) { $field_data_array = array(); if ( ! empty( $import ) && 'success' === $import['type'] ) { $entry->form_id = $import['id']; $slug = get_post_field( 'post_name', $id ); $flamingo_data = Flamingo_Inbound_Message::find( array( 'posts_per_page' => - 1, 'channel' => $slug, ) ); if ( ! empty( $flamingo_data ) ) { foreach ( $flamingo_data as $flamingo ) { $created_date = date_i18n( 'Y-m-d H:i:s', strtotime( str_replace( ' @', '', $flamingo->date ) ) ); if ( $entry->save( $created_date ) ) { if ( ! empty( $flamingo->fields ) ) { foreach ( $flamingo->fields as $key => $value ) { if ( isset( $meta[ $key ] ) ) { if ( strpos( $meta[ $key ], 'upload' ) !== false ) { $value = array( 'file' => array( 'success' => true, 'file_url' => $value, 'file_path' => '', ), ); } $field_data_array[] = array( 'name' => $meta[ $key ], 'value' => $value, ); } } if ( ! empty( $flamingo->meta['remote_ip'] ) ) { $field_data_array[] = array( 'name' => '_forminator_user_ip', 'value' => $flamingo->meta['remote_ip'], ); } $entry->set_fields( $field_data_array, $created_date ); } } } } } } /** * Import cfdb7 * * @param int $id Form Id. * @param Forminator_Form_Entry_Model $entry Form entry model. * @param array $import Import. * @param array $meta Meta. */ public function import_cfdb7( $id, Forminator_Form_Entry_Model $entry, $import, $meta ) { global $wpdb; $field_data_array = array(); if ( ! empty( $import ) && 'success' === $import['type'] ) { $entry->form_id = $import['id']; $table_name = $wpdb->prefix . 'db7_forms'; // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $form_data = $wpdb->get_results( $wpdb->prepare( 'SELECT `form_value`,`form_date` FROM ' . esc_sql( $table_name ) . ' WHERE `form_post_id` = %d', $id ) ); if ( ! empty( $form_data ) ) { foreach ( $form_data as $form_value ) { $data_value = maybe_unserialize( $form_value->form_value ); $data_date = date_i18n( 'Y-m-d H:i:s', strtotime( $form_value->form_date ) ); if ( $entry->save( $data_date ) && ! empty( $data_value ) ) { foreach ( $data_value as $key => $value ) { if ( isset( $meta[ $key ] ) ) { if ( strpos( $meta[ $key ], 'upload' ) !== false ) { $upload_dir = wp_upload_dir(); $cfdb7_dir_url = $upload_dir['baseurl'] . '/cfdb7_uploads'; $file_url = ! empty( $value ) ? $cfdb7_dir_url . '/' . $value : ''; $value = array( 'file' => array( 'success' => true, 'file_url' => $file_url, 'file_path' => '', ), ); } $field_data_array[] = array( 'name' => $meta[ $key ], 'value' => $value, ); } } $entry->set_fields( $field_data_array, $data_date ); } } } } } /** * Import submission * * @param int $id Form Id. * @param Forminator_Form_Entry_Model $entry Form entry model. * @param array $import Import. * @param array $meta Meta. */ public function import_submissions( $id, Forminator_Form_Entry_Model $entry, $import, $meta ) { $field_data_array = array(); if ( ! empty( $import ) && 'success' === $import['type'] ) { $entry->form_id = $import['id']; $submissions_data = get_posts( array( 'posts_per_page' => - 1, 'post_type' => 'wpcf7s', 'meta_key' => 'form_id', // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key 'meta_value' => (int) $id, // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_value ) ); if ( ! empty( $submissions_data ) ) { foreach ( $submissions_data as $submissions ) { $data_date = date_i18n( 'Y-m-d H:i:s', strtotime( $submissions->post_date ) ); if ( $entry->save( $data_date ) ) { if ( ! empty( $meta ) ) { foreach ( $meta as $key => $value ) { if ( $value ) { $meta_key = 'wpcf7s_posted-' . $key; $meta_value = get_post_meta( $submissions->ID, $meta_key, true ); $data_value = $meta_value; if ( strpos( $meta[ $key ], 'upload' ) !== false ) { $meta_value = get_post_meta( $submissions->ID, 'wpcf7s_file-' . $key, true ); $contact_form_submissions = new WPCF7Submissions(); $wpcf7s_url = $contact_form_submissions->get_wpcf7s_url(); $file_url = ! empty( $meta_value ) ? $wpcf7s_url . '/' . $submissions->ID . '/' . $meta_value : ''; $data_value = array( 'file' => array( 'success' => true, 'file_url' => $file_url, 'file_path' => '', ), ); } $field_data_array[] = array( 'name' => $value, 'value' => $data_value, ); } } $entry->set_fields( $field_data_array, $data_date ); } } } } } } /** * Field data * * @param array $form_fields Form fields. * * @return array */ public function get_fields_data( $form_fields ) { $data = array(); $count = array(); if ( ! empty( $form_fields ) ) { foreach ( $form_fields as $field ) { $type = $this->get_thirdparty_field_type( $field->basetype ); if ( isset( $count[ $type ] ) && $count[ $type ] > 0 ) { $count[ $type ] = $count[ $type ] + 1; } else { $count[ $type ] = 1; } $data[ $field['name'] ] = $type . '-' . $count[ $type ]; } } return $data; } /** * Import global settings * * @param array $setting Global settings. */ public function import_global_settings( $setting ) { if ( ! empty( $setting ) ) { if ( isset( $setting['captchaV2'] ) ) { if ( class_exists( 'WPCF7_RECAPTCHA' ) ) { $cf7_captcha = WPCF7_RECAPTCHA::get_instance(); $cf7_captcha_key = $cf7_captcha->is_active() ? $cf7_captcha->get_sitekey() : ''; $cf7_captcha_secret = $cf7_captcha->is_active() ? $cf7_captcha->get_secret( $cf7_captcha_key ) : ''; if ( $cf7_captcha_key && $cf7_captcha_secret ) { update_option( 'forminator_captcha_key', $cf7_captcha_key ); update_option( 'forminator_captcha_secret', $cf7_captcha_secret ); } } } } } /** * Import Advanced CF7 * * @param int $id Form Id. * @param Forminator_Form_Entry_Model $entry Form entry model. * @param array $import Import. * @param array $meta Meta. */ public function import_advanced_cf7( $id, Forminator_Form_Entry_Model $entry, $import, $meta ) { global $wpdb; $field_data_array = array(); if ( ! empty( $import ) && 'success' === $import['type'] ) { $entry->form_id = $import['id']; $cf7d_entry_order_by = '`data_id` DESC'; $table_name = VSZ_CF7_DATA_ENTRY_TABLE_NAME; $query = "SELECT * FROM {$table_name} WHERE cf7_id = %d AND data_id IN( SELECT * FROM ( SELECT data_id FROM {$table_name} WHERE 1 = 1 AND cf7_id = %d GROUP BY `data_id` ORDER BY %s ) temp_table) ORDER BY %s"; // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared $data = $wpdb->get_results( $wpdb->prepare( $query, $id, $id, $cf7d_entry_order_by, $cf7d_entry_order_by ) ); $submissions_data = vsz_cf7_sortdata( $data ); if ( ! empty( $submissions_data ) ) { foreach ( $submissions_data as $submissions ) { $data_date = date_i18n( 'Y-m-d H:i:s', strtotime( $submissions['submit_time'] ) ); if ( $entry->save( $data_date ) ) { if ( ! empty( $meta ) ) { foreach ( $meta as $key => $value ) { if ( isset( $submissions[ $key ] ) ) { $data_value = $submissions[ $key ]; if ( strpos( $value, 'upload' ) !== false ) { $data_value = array( 'file' => array( 'success' => true, 'file_url' => $submissions[ $key ], 'file_path' => '', ), ); } if ( strpos( $value, 'checkbox' ) !== false || strpos( $value, 'select' ) !== false ) { $data_value = explode( '
', nl2br( $submissions[ $key ] ) ); $data_value = array_map( 'trim', $data_value ); } $field_data_array[] = array( 'name' => $value, 'value' => $data_value, ); } } $entry->set_fields( $field_data_array, $data_date ); } } } } } } /** * Import Condition * * @param array $wpcf7cf_entries Form entries. * @param string $form_html Form HTML. * @param array $field Field. * @param array $field_data Field data. * * @return array */ public function import_conditional_field( $wpcf7cf_entries, $form_html, $field, $field_data ) { $condition = array(); if ( ! empty( $wpcf7cf_entries ) ) { foreach ( $wpcf7cf_entries as $wpcf7cf ) { $then_field = $wpcf7cf['then_field']; $hide_pattern = '~
]*>(.*?)
~si'; if ( preg_match_all( $hide_pattern, $form_html, $matches ) ) { if ( ! empty( $matches ) && isset( $matches[1][0] ) ) { if ( preg_match( '/' . $field['name'] . '/', $matches[1][0], $matches ) ) { if ( ! empty( $wpcf7cf['and_rules'] ) ) { foreach ( $wpcf7cf['and_rules'] as $rule ) { $if_field = $field_data[ $rule['if_field'] ]; $is_rule = 'equals' === $rule['operator'] ? 'is' : 'is_not'; $condition[] = array( 'element_id' => $if_field, 'rule' => $is_rule, 'value' => $rule['if_value'], ); } } } } } $inline_pattern = '~]*>(.*?)~si'; if ( preg_match_all( $inline_pattern, $form_html, $matches ) ) { if ( ! empty( $matches ) && isset( $matches[1][0] ) ) { if ( preg_match( '/' . $field['name'] . '/', $matches[1][0], $matches ) ) { if ( ! empty( $wpcf7cf['and_rules'] ) ) { foreach ( $wpcf7cf['and_rules'] as $rule ) { $if_field = $field_data[ $rule['if_field'] ]; $is_rule = 'equals' === $rule['operator'] ? 'is' : 'is_not'; $condition[] = array( 'element_id' => $if_field, 'rule' => $is_rule, 'value' => $rule['if_value'], ); } } } } } } } return $condition; } } PK!Cq~<<class-addons-page.phpnu[user_can_install( $pid ) ) { $installed = WPMUDEV_Dashboard::$upgrader->is_project_installed( $pid ); if ( ! $installed ) { $success = WPMUDEV_Dashboard::$upgrader->install( $pid ); if ( $success ) { $html_addons = $this->addons_html( $pid ); wp_send_json_success( array( 'message' => /* translators: %s: Add-on name */ sprintf( esc_html__( '%s was successfully installed', 'forminator' ), $this->get_addon_value( $pid, 'name' ) ), 'html' => $html_addons, ) ); } } } } $err = WPMUDEV_Dashboard::$upgrader->get_error(); wp_send_json_error( array( 'error' => $err, ) ); break; case 'addons-activate': if ( $pid ) { $local = WPMUDEV_Dashboard::$site->get_cached_projects( $pid ); if ( empty( $local ) ) { $errors['error'] = array( 'message' => esc_html__( 'Not installed', 'forminator' ), ); wp_send_json_error( $errors ); } $result = activate_plugin( $local['filename'], '', $is_network ); if ( is_wp_error( $result ) ) { $errors['error'] = array( 'file' => $pid, 'code' => $result->get_error_code(), 'message' => $result->get_error_message(), ); wp_send_json_error( $errors ); } else { WPMUDEV_Dashboard::$site->schedule_shutdown_refresh(); $html_addons = $this->addons_html( $pid ); wp_send_json_success( array( 'message' => /* translators: %s: Add-on name */ sprintf( esc_html__( '%s was successfully activated', 'forminator' ), $this->get_addon_value( $pid, 'name' ) ), 'html' => $html_addons, ) ); } } break; case 'addons-deactivate': if ( $pid ) { $local = WPMUDEV_Dashboard::$site->get_cached_projects( $pid ); if ( empty( $local ) ) { $errors['error'] = array( 'message' => esc_html__( 'Not installed', 'forminator' ), ); wp_send_json_error( $errors ); } // Check that it's a valid plugin. $valid = validate_plugin( $local['filename'] ); if ( is_wp_error( $valid ) ) { $errors['error'] = array( 'file' => $pid, 'code' => $valid->get_error_code(), 'message' => $valid->get_error_message(), ); wp_send_json_error( $errors ); } deactivate_plugins( $local['filename'], false, $is_network ); // there is no return so we always call it a success. WPMUDEV_Dashboard::$site->schedule_shutdown_refresh(); $html_addons = $this->addons_html( $pid ); wp_send_json_success( array( 'message' => /* translators: %s: Add-on name */ sprintf( esc_html__( '%s was successfully deactivated', 'forminator' ), $this->get_addon_value( $pid, 'name' ) ), 'html' => $html_addons, ) ); } break; case 'addons-delete': if ( $pid ) { if ( WPMUDEV_Dashboard::$upgrader->delete_plugin( $pid ) ) { $html_addons = $this->addons_html( $pid ); wp_send_json_success( array( 'message' => /* translators: %s: Add-on name */ sprintf( esc_html__( '%s was successfully deleted', 'forminator' ), $this->get_addon_value( $pid, 'name' ) ), 'html' => $html_addons, ) ); } else { $err = WPMUDEV_Dashboard::$upgrader->get_error(); wp_send_json_error( $err ); } } break; case 'addons-update': if ( $pid ) { $success = WPMUDEV_Dashboard::$upgrader->upgrade( $pid ); if ( ! $success ) { $error = WPMUDEV_Dashboard::$upgrader->get_error(); $errors['error'] = array( 'message' => $error['message'], ); wp_send_json_error( $errors ); } $html_addons = $this->addons_html( $pid ); wp_send_json_success( array( 'message' => /* translators: %s: Add-on name */ sprintf( esc_html__( '%s was successfully updated', 'forminator' ), $this->get_addon_value( $pid, 'name' ) ), 'html' => $html_addons, ) ); } break; default: wp_send_json_error( array( 'message' => sprintf( /* translators: %s: Action */ esc_html__( 'Unknown action: %s', 'forminator' ), esc_html( $action ) ), ) ); break; } } /** * Render addons content * * @param string $name Name. * @param string $pid The Project ID. * @param array $addons Addons. */ public function addons_render( $name, $pid, $addons = array() ) { $file_name = $name . '.php'; $file_path = forminator_plugin_dir() . 'admin/views/addons/' . $file_name; $path = false; if ( file_exists( $file_path ) ) { $path = $file_path; } if ( $path ) { if ( empty( $addons ) ) { $addons = $this->get_addons( $pid ); } /** * Output some content before the template is loaded, or modify the * variables passed to the file. * * @var array $data The */ $new_data = apply_filters( 'forminator_before-' . $name, $addons ); if ( isset( $new_data ) && is_array( $new_data ) ) { $addons = $new_data; } require $path; /** * Output code or do stuff after the template was loaded. */ do_action( 'forminator_after-' . $name ); } else { printf( '

%s

', sprintf( /* translators: %s: name of the file */ esc_html__( 'Error: The file %s does not exist. Please re-install the plugin.', 'forminator' ), '"' . esc_html( $name ) . '"' ) ); } } /** * Get addon * * @param string $pid The Project ID. * * @return array|false|object */ public function get_addons( $pid ) { $addon = array(); if ( $pid ) { $addon = self::get_project_info_from_wpmudev_dashboard( $pid ); } return $addon; } /** * Get addon value * * @param string $pid The Project ID. * @param string $key Key. * * @return string */ public function get_addon_value( $pid, $key ) { $value = ''; $addon = $this->get_addons( $pid ); if ( ! empty( $addon ) ) { $value = isset( $addon->{$key} ) ? $addon->{$key} : ''; } return $value; } /** * Get addon slug based on PID. * * @param string $pid The Project ID. * * @return string */ public static function get_addon_slug( $pid ) { switch ( $pid ) { case 3953609: $addon_slug = 'stripe'; break; case 4262971: $addon_slug = 'pdf'; break; case self::GEOLOCATION_PID: $addon_slug = 'geolocation'; break; default: $addon_slug = ''; break; } return $addon_slug; } /** * Get addons html * * @param string $pid The Project ID. * * @return string */ public function addons_html( $pid ) { ob_start(); $this->addons_render( 'addons-list', $pid ); return ob_get_clean(); } /** * Renders a view file with static call. * * @since 1.0 * @since 4.2.0 Moved from Opt_In to this class. * * @param string $file Path to the view file. * @param array $params Array whose keys will be variable names when within the view file. * @param bool|false $return_value Whether to echo or return the contents. * @return string */ public function render_template( $file, $params = array(), $return_value = false ) { // Assign $file to a variable which is unlikely to be used by users of the method. extract( $params, EXTR_OVERWRITE ); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract if ( $return_value ) { ob_start(); } $file_name = $file . '.php'; $file_path = forminator_plugin_dir() . $file_name; if ( file_exists( $file_path ) ) { include $file_path; } if ( $return_value ) { return ob_get_clean(); } if ( ! empty( $params ) ) { foreach ( $params as $param ) { unset( $param ); } } } /** * Get addon by id * * @param string $pid The Project ID. * * @return false|object|stdClass */ public static function forminator_addon_by_pid( $pid ) { $res = array(); if ( class_exists( 'WPMUDEV_Dashboard' ) ) { $res = self::get_project_info_from_wpmudev_dashboard( $pid, true ); } else { $addons = self::forminator_get_static_addons(); foreach ( $addons as $addon ) { if ( $pid === $addon->pid ) { $res = $addon; } } } return $res; } /** * Replace the addon name, info, features from static addon. * To display the translated content. * * @since 1.31 * * @param mixed $project The addon object. * @return mixed */ private static function override_content_from_static_addons( $project ) { if ( ! empty( $project->pid ) ) { $addons = self::forminator_get_static_addons(); foreach ( $addons as $addon ) { if ( $project->pid === $addon->pid ) { $project->name = $addon->name; $project->info = $addon->info; $project->features = $addon->features; } } } return $project; } /** * Get project details from WPMUDEV dashboard. * * @since 1.31 * * @param int $pid The Project ID. * @param bool $fetch_full Optional. If true, then even potentially * time-consuming preparation is done. * e.g. load changelog via API. * * @return object Details about the project. */ public static function get_project_info_from_wpmudev_dashboard( $pid, $fetch_full = false ) { $res = array(); if ( class_exists( 'WPMUDEV_Dashboard' ) ) { $res = clone WPMUDEV_Dashboard::$site->get_project_info( $pid, $fetch_full ); // Override the content from plugin to load the translated content. $res = self::override_content_from_static_addons( $res ); } return $res; } /** * Get static addons * * @return stdClass[] */ public static function forminator_get_static_addons() { // Stripe Addon. $stripe_addon = new stdClass(); $stripe_addon->pid = 3953609; $stripe_addon->name = esc_html__( 'Forminator Stripe Subscriptions Add-on', 'forminator' ); $stripe_addon->info = esc_html__( 'The Stripe subscription add-on lets you collect recurring/subscription payments with Forminator Pro on your WordPress sites.', 'forminator' ); $stripe_addon->version_latest = '1.0'; $stripe_addon->version_installed = '1.0'; $stripe_addon->is_network_admin = is_network_admin(); $stripe_addon->is_hidden = false; $stripe_addon->is_installed = false; $stripe_addon->features = array( esc_html__( 'Create and manage one-time and recurring Stripe payments in Forminator Pro.', 'forminator' ), esc_html__( 'Set up products in Forminator within minutes.', 'forminator' ), esc_html__( 'Offer users a trial period for your product before they start paying.', 'forminator' ), esc_html__( 'Use conditional logic to process payments based on form input field values.', 'forminator' ), ); $stripe_addon->url = (object) array( 'thumbnail' => esc_url( forminator_plugin_url() . 'assets/images/forminator-stripe-logo.png' ), ); $stripe_addon->changelog = array( array( 'time' => '1628782583', 'version' => '1.0', 'log' => '

- First public release

', ), ); $stripe_addon->pro_url = 'https://wpmudev.com/project/forminator-pro/?utm_source=forminator&utm_medium=plugin&utm_campaign=forminator_stripe-addon'; // PDF Addon. $pdf_addon = new stdClass(); $pdf_addon->pid = 4262971; $pdf_addon->name = esc_html__( 'PDF Generator Add-on', 'forminator' ); $pdf_addon->info = esc_html__( 'Generate and send PDF files (e.g. form entries, receipts, invoices, quotations) to users after form submission.', 'forminator' ); $pdf_addon->version_latest = '1.0'; $pdf_addon->version_installed = '1.0'; $pdf_addon->is_network_admin = is_network_admin(); $pdf_addon->is_hidden = false; $pdf_addon->is_installed = false; $pdf_addon->features = array( esc_html__( 'No limit on the number of PDFs you can generate for your forms.', 'forminator' ), esc_html__( 'Generate PDF files in seconds with our easy-to-use pre-designed templates.', 'forminator' ), esc_html__( 'Send customized email Notifications to admins and visitors with PDF attachments.', 'forminator' ), esc_html__( 'Download the PDFs of the form submissions on the Submissions page.', 'forminator' ), esc_html__( 'Generate payment receipts and invoices.', 'forminator' ), ); $pdf_addon->url = (object) array( 'thumbnail' => esc_url( forminator_plugin_url() . 'assets/images/pdf-logo@2x.png' ), ); $pdf_addon->changelog = array( array( 'time' => '1691653012', 'version' => '1.0', 'log' => '

- First public release

', ), ); $pdf_addon->pro_url = 'https://wpmudev.com/project/forminator-pro/?utm_source=forminator&utm_medium=plugin&utm_campaign=forminator_pdf-addon'; // Geolocation Addon. $geo_addon = new stdClass(); $geo_addon->pid = self::GEOLOCATION_PID; $geo_addon->name = esc_html__( 'Geolocation Add-on', 'forminator' ); $geo_addon->info = esc_html__( 'Collect your form submitter’s location information and provide address auto-completion using Google Maps API.', 'forminator' ); $geo_addon->version_latest = '1.0'; $geo_addon->version_installed = '1.0'; $geo_addon->is_network_admin = is_network_admin(); $geo_addon->is_hidden = false; $geo_addon->is_installed = false; $geo_addon->features = array( esc_html__( 'Collect and store your users\' geolocation information.', 'forminator' ), esc_html__( 'Add address auto-completion to your forms\' address field(s).', 'forminator' ), esc_html__( 'See your users\' geolocation on Google Maps.', 'forminator' ), ); $geo_addon->url = (object) array( 'thumbnail' => esc_url( forminator_plugin_url() . 'assets/images/geolocation-logo@2x.png' ), ); $geo_addon->changelog = array( array( 'time' => '1688169600', 'version' => '1.0', 'log' => '

- First public release

', ), ); $geo_addon->pro_url = 'https://wpmudev.com/project/forminator-pro/?utm_source=forminator&utm_medium=plugin&utm_campaign=forminator_geolocation-addon'; return array( $geo_addon, $pdf_addon, $stripe_addon, ); } } PK!v class-admin-l10n.phpnu[admin_l10n(); $admin_locale = require_once forminator_plugin_dir() . 'admin/locale.php'; $locale = array( '' => array( 'localeSlug' => 'default', ), ); $l10n['locale'] = array_merge( $locale, (array) $admin_locale ); return apply_filters( 'forminator_l10n', $l10n ); } /** * Default Admin properties * * @return array */ public function admin_l10n() { $current_user = wp_get_current_user(); $properties = array( 'popup' => array( 'form_name_label' => esc_html__( 'Name your form', 'forminator' ), 'form_name_placeholder' => esc_html__( 'E.g., Contact Form', 'forminator' ), 'name' => esc_html__( 'Name', 'forminator' ), 'fields' => esc_html__( 'Fields', 'forminator' ), 'date' => esc_html__( 'Date', 'forminator' ), 'clear_all' => esc_html__( 'Clear All', 'forminator' ), 'your_exports' => esc_html__( 'Your exports', 'forminator' ), 'edit_login_form' => esc_html__( 'Edit Login or Register form', 'forminator' ), 'edit_scheduled_export' => esc_html__( 'Edit Scheduled Export', 'forminator' ), 'frequency' => esc_html__( 'Frequency', 'forminator' ), 'daily' => esc_html__( 'Daily', 'forminator' ), 'weekly' => esc_html__( 'Weekly', 'forminator' ), 'monthly' => esc_html__( 'Monthly', 'forminator' ), 'week_day' => esc_html__( 'Day of the week', 'forminator' ), 'month_day' => esc_html__( 'Day of the month', 'forminator' ), 'month_year' => esc_html__( 'Month of the year', 'forminator' ), 'monday' => esc_html__( 'Monday', 'forminator' ), 'tuesday' => esc_html__( 'Tuesday', 'forminator' ), 'wednesday' => esc_html__( 'Wednesday', 'forminator' ), 'thursday' => esc_html__( 'Thursday', 'forminator' ), 'friday' => esc_html__( 'Friday', 'forminator' ), 'saturday' => esc_html__( 'Saturday', 'forminator' ), 'sunday' => esc_html__( 'Sunday', 'forminator' ), 'day_time' => esc_html__( 'Time of the day', 'forminator' ), 'email_to' => esc_html__( 'Email export data to', 'forminator' ), 'email_placeholder' => esc_html__( 'E.g., john@doe.com', 'forminator' ), 'schedule_help' => esc_html__( 'Leave blank if you don\'t want to receive exports via email.', 'forminator' ), 'congratulations' => esc_html__( 'Congratulations!', 'forminator' ), 'is_ready' => esc_html__( 'is ready!', 'forminator' ), 'new_form_desc' => esc_html__( 'Add it to any post / page by clicking Forminator button, or set it up as a Widget.', 'forminator' ), 'paypal_settings' => esc_html__( 'Edit PayPal credentials', 'forminator' ), 'preview_cforms' => esc_html__( 'Preview Custom Form', 'forminator' ), 'preview_polls' => esc_html__( 'Preview Poll', 'forminator' ), 'preview_quizzes' => esc_html__( 'Preview Quiz', 'forminator' ), 'captcha_settings' => esc_html__( 'Edit reCAPTCHA credentials', 'forminator' ), 'currency_settings' => esc_html__( 'Edit default currency', 'forminator' ), 'pagination_entries' => esc_html__( 'Submissions | Pagination Settings', 'forminator' ), 'pagination_listings' => esc_html__( 'Listings | Pagination Settings', 'forminator' ), 'email_settings' => esc_html__( 'Email Settings', 'forminator' ), 'uninstall_settings' => esc_html__( 'Uninstall Settings', 'forminator' ), 'privacy_settings' => esc_html__( 'Privacy Settings', 'forminator' ), 'validate_form_name' => esc_html__( 'Form name cannot be empty! Please pick a name for your form.', 'forminator' ), 'close' => esc_html__( 'Close', 'forminator' ), 'close_label' => esc_html__( 'Close this dialog window', 'forminator' ), 'go_back' => esc_html__( 'Go back', 'forminator' ), 'records' => esc_html__( 'Records', 'forminator' ), 'delete' => esc_html__( 'Delete', 'forminator' ), 'confirm' => esc_html__( 'Confirm', 'forminator' ), 'are_you_sure' => esc_html__( 'Are you sure?', 'forminator' ), 'cannot_be_reverted' => esc_html__( 'Have in mind this action cannot be reverted.', 'forminator' ), 'are_you_sure_form' => esc_html__( 'Are you sure you wish to permanently delete this form?', 'forminator' ), 'are_you_sure_poll' => esc_html__( 'Are you sure you wish to permanently delete this poll?', 'forminator' ), 'are_you_sure_quiz' => esc_html__( 'Are you sure you wish to permanently delete this quiz?', 'forminator' ), 'delete_form' => esc_html__( 'Delete Form', 'forminator' ), 'delete_poll' => esc_html__( 'Delete Poll', 'forminator' ), 'delete_quiz' => esc_html__( 'Delete Quiz', 'forminator' ), 'confirm_action' => esc_html__( 'Please confirm that you want to do this action.', 'forminator' ), 'confirm_title' => esc_html__( 'Confirm Action', 'forminator' ), 'confirm_field_delete' => esc_html__( 'Please confirm that you want to delete this field', 'forminator' ), 'cancel' => esc_html__( 'Cancel', 'forminator' ), 'save_alert' => esc_html__( 'The changes you made may be lost if you navigate away from this page.', 'forminator' ), 'save_changes' => esc_html__( 'Save Changes', 'forminator' ), 'save' => esc_html__( 'Save', 'forminator' ), 'export_form' => esc_html__( 'Export Form', 'forminator' ), 'export_poll' => esc_html__( 'Export Poll', 'forminator' ), 'export_quiz' => esc_html__( 'Export Quiz', 'forminator' ), 'import_form' => esc_html__( 'Import Form', 'forminator' ), 'import_form_cf7' => esc_html__( 'Import', 'forminator' ), 'import_form_ninja' => esc_html__( 'Import Ninja Forms', 'forminator' ), 'import_form_gravity' => esc_html__( 'Import Gravity Forms', 'forminator' ), 'import_poll' => esc_html__( 'Import Poll', 'forminator' ), 'import_quiz' => esc_html__( 'Import Quiz', 'forminator' ), 'enable_scheduled_export' => esc_html__( 'Enable scheduled exports', 'forminator' ), 'scheduled_export_if_new' => esc_html__( 'Send email only if there are new submissions', 'forminator' ), 'download_csv' => esc_html__( 'Download CSV', 'forminator' ), 'scheduled_exports' => esc_html__( 'Scheduled Exports', 'forminator' ), 'manual_exports' => esc_html__( 'Manual Exports', 'forminator' ), 'manual_description' => esc_html__( 'Download the submissions list in .csv format.', 'forminator' ), 'scheduled_description' => esc_html__( 'Enable scheduled exports to get the submissions list in your email.', 'forminator' ), 'disable' => esc_html__( 'Disable', 'forminator' ), 'enable' => esc_html__( 'Enable', 'forminator' ), 'enter_name' => esc_html__( 'Enter a name', 'forminator' ), 'new_form_desc2' => esc_html__( 'Name your new form, then let\'s start building!', 'forminator' ), 'new_poll_desc2' => esc_html__( 'Name your new poll, then let\'s start building!', 'forminator' ), 'new_quiz_desc2' => esc_html__( 'Choose whether you want to collect participants details (e.g. name, email, etc.) on your quiz.', 'forminator' ), 'learn_more' => esc_html__( 'Learn more', 'forminator' ), 'input_label' => esc_html__( 'Input Label', 'forminator' ), 'form_name_validation' => esc_html__( 'Form name cannot be empty.', 'forminator' ), 'poll_name_validation' => esc_html__( 'Poll name cannot be empty.', 'forminator' ), 'quiz_name_validation' => esc_html__( 'Quiz name cannot be empty.', 'forminator' ), 'new_form_placeholder' => esc_html__( 'E.g., Blank Form', 'forminator' ), 'new_poll_placeholder' => esc_html__( 'E.g., Blank Poll', 'forminator' ), 'new_quiz_placeholder' => esc_html__( 'E.g., My Awesome Quiz', 'forminator' ), 'create' => esc_html__( 'Create', 'forminator' ), 'reset' => esc_html__( 'RESET', 'forminator' ), 'disconnect' => esc_html__( 'Disconnect', 'forminator' ), 'apply_submission_filter' => esc_html__( 'Apply Submission Filters', 'forminator' ), 'registration_notice' => esc_html__( 'This template allows you to create your own registration form and insert it on a custom page. This doesn\'t modify the default registration form.', 'forminator' ), 'login_notice' => esc_html__( 'This template allows you to create your own login form and insert it on a custom page. This doesn\'t modify the default login form.', 'forminator' ), 'approve_user' => esc_html__( 'Approve', 'forminator' ), 'registration_name' => esc_html__( 'User Registration', 'forminator' ), 'login_name' => esc_html__( 'User Login', 'forminator' ), 'deactivate' => esc_html__( 'Deactivate', 'forminator' ), 'deactivateContent' => esc_html__( 'Are you sure you want to deactivate this Add-on?', 'forminator' ), 'deactivateAnyway' => esc_html__( 'Deactivate Anyway', 'forminator' ), 'forms' => esc_html__( 'Forms', 'forminator' ), 'quizzes' => esc_html__( 'Quizzes', 'forminator' ), 'polls' => esc_html__( 'Polls', 'forminator' ), 'back' => esc_html__( 'Back', 'forminator' ), 'settings_label' => esc_html__( 'Settings', 'forminator' ), 'settings_description' => esc_html__( 'Configure and customize the content of your report.', 'forminator' ), 'label_description' => esc_html__( 'The label is to help you identify this report notification.', 'forminator' ), 'module_description' => esc_html__( 'Choose a module for this report.', 'forminator' ), 'select_forms' => esc_html__( 'Select forms', 'forminator' ), 'select_forms_description' => esc_html__( 'Choose the forms you want to include in this report.', 'forminator' ), 'all_forms' => esc_html__( 'All Forms', 'forminator' ), 'selected_forms' => esc_html__( 'Selected Forms', 'forminator' ), 'selected_forms_description' => esc_html__( 'Select one or more forms to include in this report.', 'forminator' ), 'all_quizzes' => esc_html__( 'All Quizzes', 'forminator' ), 'select_quizzes' => esc_html__( 'Select quizzes', 'forminator' ), 'selected_quizzes' => esc_html__( 'Selected quizzes', 'forminator' ), 'select_quizzes_description' => esc_html__( 'Choose the quizzes you want to include in this report.', 'forminator' ), 'selected_quizzes_description' => esc_html__( 'Select one or more quizzes to include in this report.', 'forminator' ), 'all_polls' => esc_html__( 'All Polls', 'forminator' ), 'select_polls' => esc_html__( 'Select polls', 'forminator' ), 'selected_polls' => esc_html__( 'Selected polls', 'forminator' ), 'select_polls_description' => esc_html__( 'Choose the polls you want to include in this report.', 'forminator' ), 'selected_polls_description' => esc_html__( 'Select one or more polls to include in this report.', 'forminator' ), 'report_stats' => esc_html__( 'Report stats', 'forminator' ), 'all_stats' => esc_html__( 'All stats', 'forminator' ), 'stats' => esc_html__( 'Stats', 'forminator' ), 'stats_description' => esc_html__( 'Select the stats data to show in this reports.', 'forminator' ), 'views' => esc_html__( 'Views', 'forminator' ), 'bounce_rates' => esc_html__( 'Bounce rates', 'forminator' ), 'submissions' => esc_html__( 'Submissions', 'forminator' ), 'conversion_rates' => esc_html__( 'Conversion rates', 'forminator' ), 'payments' => esc_html__( 'Payments', 'forminator' ), 'leads' => esc_html__( 'Leads', 'forminator' ), 'schedule_label' => esc_html__( 'Schedule', 'forminator' ), 'schedule_description' => esc_html__( 'Choose how often you want to receive this report email.', 'forminator' ), 'frequency_description' => esc_html__( 'Choose the frequency of receiving the report email.', 'forminator' ), 'frequency_time' => self::get_timezone_string(), 'recipients_label' => esc_html__( 'Recipients', 'forminator' ), 'recipients_description' => esc_html__( 'Add the report email recipients below.', 'forminator' ), 'add_users' => esc_html__( 'Add users', 'forminator' ), 'add_by_email' => esc_html__( 'Add by email', 'forminator' ), 'search_user' => esc_html__( 'Search users', 'forminator' ), 'users' => esc_html__( 'Users', 'forminator' ), 'search_placeholder' => esc_html__( 'Type username', 'forminator' ), 'no_recipients' => esc_html__( 'You\'ve not added the users. In order to activate the notification you need to add users first.', 'forminator' ), 'no_recipient_disable' => esc_html__( 'You\'ve removed all recipients.', 'forminator' ), 'recipient_exists' => esc_html__( 'Recipient already exists.', 'forminator' ), 'add_user' => esc_html__( 'Add user', 'forminator' ), 'added_users' => esc_html__( 'Added users', 'forminator' ), 'remove_user' => esc_html__( 'Remove user', 'forminator' ), 'resend_invite' => esc_html__( 'Resend invite email', 'forminator' ), 'awaiting_confirmation' => esc_html__( 'Awaiting confirmation', 'forminator' ), 'invite_description' => esc_html__( 'Add recipient details.', 'forminator' ), 'first_name' => esc_html__( 'First name', 'forminator' ), 'email_address' => esc_html__( 'Email address', 'forminator' ), 'add_recipient' => esc_html__( 'Add recipient', 'forminator' ), 'adding_recipient' => esc_html__( 'Adding recipient', 'forminator' ), 'name_placeholder' => esc_html__( 'E.g. John', 'forminator' ), 'invite_no_recipient' => esc_html__( 'No recipients added. Please add one or more recipients above to finish scheduling the report.', 'forminator' ), 'status_label' => esc_html__( 'Activate report', 'forminator' ), 'configure' => esc_html__( 'Configure', 'forminator' ), 'deactivate_report' => esc_html__( 'Deactivate report', 'forminator' ), 'activate_report' => esc_html__( 'Activate report', 'forminator' ), 'form_reports' => esc_html__( 'Form reports', 'forminator' ), 'showing_report_from' => esc_html__( 'Showing report from', 'forminator' ), 'time_interval' => self::get_times(), 'week_days' => forminator_week_days(), 'month_days' => self::get_months(), 'fetch_nonce' => wp_create_nonce( 'forminator-fetch' ), 'save_nonce' => wp_create_nonce( 'forminator-save' ), ), 'quiz' => array( 'choose_quiz_title' => esc_html__( 'Create Quiz', 'forminator' ), 'choose_quiz_description' => esc_html__( 'Let\'s start by giving your quiz a name and choosing the appropriate quiz type based on your goal.', 'forminator' ), 'quiz_name' => esc_html__( 'Quiz Name', 'forminator' ), 'quiz_type' => esc_html__( 'Quiz Type', 'forminator' ), 'collect_leads' => esc_html__( 'Collect Leads', 'forminator' ), 'no_pagination' => esc_html__( 'No Pagination', 'forminator' ), 'paginate_quiz' => esc_html__( 'Paginated Quiz', 'forminator' ), 'presentation' => esc_html__( 'Presentation', 'forminator' ), 'quiz_pagination' => esc_html__( 'Quiz Presentation', 'forminator' ), 'quiz_pagination_descr' => esc_html__( 'How do you want the quiz questions to be presented to your users? You can break your quiz questions into pages, and display a number of questions at a time or show all questions at once.', 'forminator' ), 'quiz_pagination_descr2' => esc_html__( 'You can adjust this configuration at any time in the Behavior settings for your quiz.', 'forminator' ), 'knowledge_label' => esc_html__( 'Knowledge Quiz', 'forminator' ), 'knowledge_description' => esc_html__( 'Test the knowledge of your visitors on a subject and final score is calculated based on number of right answers. E.g., Test your music knowledge.', 'forminator' ), 'nowrong_label' => esc_html__( 'Personality Quiz', 'forminator' ), 'nowrong_description' => esc_html__( 'Show different outcomes depending on the visitor\'s answers. There are no wrong answers. E.g., Which superhero are you?', 'forminator' ), 'continue_button' => esc_html__( 'Continue', 'forminator' ), 'quiz_leads_toggle' => esc_html__( 'Collect leads on your quiz', 'forminator' ), 'create_quiz' => esc_html__( 'Create Quiz', 'forminator' ), 'quiz_leads_desc' => esc_html__( 'We will automatically create a default lead generation form for you. The lead generation form uses the Forms module, and some of the settings are shared between this quiz and the leads form.', 'forminator' ), ), 'form' => array( 'form_template_title' => esc_html__( 'Choose a template', 'forminator' ), 'form_template_description' => esc_html__( 'Customize one of our pre-made form templates, or start from scratch.', 'forminator' ), 'continue_button' => esc_html__( 'Continue', 'forminator' ), 'result' => esc_html__( 'result', 'forminator' ), 'results' => esc_html__( 'results', 'forminator' ), 'preset_templates' => esc_html__( 'Preset Templates', 'forminator' ), 'saved_templates' => esc_html__( 'Cloud Templates', 'forminator' ), 'categories' => esc_html__( 'Categories', 'forminator' ), 'preview' => esc_html__( 'Preview', 'forminator' ), 'useTemplate' => esc_html__( 'Use Template', 'forminator' ), 'create_blank_form' => esc_html__( 'Create Blank Form', 'forminator' ), 'pro' => esc_html__( 'PRO', 'forminator' ), ), 'sidebar' => array( 'label' => esc_html__( 'Label', 'forminator' ), 'value' => esc_html__( 'Value', 'forminator' ), 'add_option' => esc_html__( 'Add Option', 'forminator' ), 'delete' => esc_html__( 'Delete', 'forminator' ), 'pick_field' => esc_html__( 'Pick a field', 'forminator' ), 'field_will_be' => esc_html__( 'This field will be', 'forminator' ), 'if' => esc_html__( 'if', 'forminator' ), 'shown' => esc_html__( 'Shown', 'forminator' ), 'hidden' => esc_html__( 'Hidden', 'forminator' ), ), 'colors' => array( 'poll_shadow' => esc_html__( 'Poll shadow', 'forminator' ), 'title' => esc_html__( 'Title text', 'forminator' ), 'question' => esc_html__( 'Question text', 'forminator' ), 'answer' => esc_html__( 'Answer text', 'forminator' ), 'input_background' => esc_html__( 'Input field bg', 'forminator' ), 'input_border' => esc_html__( 'Input field border', 'forminator' ), 'input_placeholder' => esc_html__( 'Input field placeholder', 'forminator' ), 'input_text' => esc_html__( 'Input field text', 'forminator' ), 'btn_background' => esc_html__( 'Button background', 'forminator' ), 'btn_text' => esc_html__( 'Button text', 'forminator' ), 'link_res' => esc_html__( 'Results link', 'forminator' ), ), 'options' => array( 'browse' => esc_html__( 'Browse', 'forminator' ), 'clear' => esc_html__( 'Clear', 'forminator' ), 'no_results' => esc_html__( 'You don\'t have any results yet.', 'forminator' ), 'select_result' => esc_html__( 'Select result', 'forminator' ), 'no_answers' => esc_html__( 'You don\'t have any answer yet.', 'forminator' ), 'placeholder_image' => esc_html__( 'Click browse to add image...', 'forminator' ), 'placeholder_image_alt' => esc_html__( 'Click on browse to add an image', 'forminator' ), 'placeholder_answer' => esc_html__( 'Add an answer here', 'forminator' ), 'multiqs_empty' => esc_html__( 'You don\'t have any questions yet.', 'forminator' ), 'add_question' => esc_html__( 'Add Question', 'forminator' ), 'add_new_question' => esc_html__( 'Add New Question', 'forminator' ), 'question_title' => esc_html__( 'Question title', 'forminator' ), 'question_title_error' => esc_html__( 'Question title cannot be empty! Please, add some content to your question.', 'forminator' ), 'answers' => esc_html__( 'Answers', 'forminator' ), 'add_answer' => esc_html__( 'Add Answer', 'forminator' ), 'add_new_answer' => esc_html__( 'Add New Answer', 'forminator' ), 'add_result' => esc_html__( 'Add Result', 'forminator' ), 'delete_result' => esc_html__( 'Delete Result', 'forminator' ), 'title' => esc_html__( 'Title', 'forminator' ), 'image' => esc_html__( 'Image (optional)', 'forminator' ), 'description' => esc_html__( 'Description', 'forminator' ), 'trash_answer' => esc_html__( 'Delete this answer', 'forminator' ), 'correct' => esc_html__( 'Correct answer', 'forminator' ), 'no_options' => esc_html__( 'You don\'t have any options yet.', 'forminator' ), 'delete' => esc_html__( 'Delete', 'forminator' ), 'restricted_dates' => esc_html__( 'Restricted dates:', 'forminator' ), 'add' => esc_html__( 'Add', 'forminator' ), 'custom_date' => esc_html__( 'Pick custom date(s) to restrict:', 'forminator' ), 'form_data' => esc_html__( 'Form Data', 'forminator' ), 'required_form_fields' => esc_html__( 'Required Fields', 'forminator' ), 'optional_form_fields' => esc_html__( 'Optional Fields', 'forminator' ), 'all_fields' => esc_html__( 'All Submitted Fields', 'forminator' ), 'form_name' => esc_html__( 'Form Name', 'forminator' ), 'misc_data' => esc_html__( 'Misc Data', 'forminator' ), 'form_based_data' => esc_html__( 'Add form data', 'forminator' ), 'been_saved' => esc_html__( 'has been saved.', 'forminator' ), 'been_published' => esc_html__( 'has been published.', 'forminator' ), 'error_saving' => esc_html__( 'Error! Form cannot be saved.', 'forminator' ), 'default_value' => esc_html__( 'Default Value', 'forminator' ), 'admin_email' => get_option( 'admin_email' ), 'delete_question' => esc_html__( 'Delete this question', 'forminator' ), 'remove_image' => esc_html__( 'Remove image', 'forminator' ), 'answer_settings' => esc_html__( 'Show extra settings', 'forminator' ), 'add_new_result' => esc_html__( 'Add New Result', 'forminator' ), 'multiorder_validation' => esc_html__( 'You need to add at least one result for this quiz so you can re-order the results priority.', 'forminator' ), 'user_ip_address' => esc_html__( 'User IP Address', 'forminator' ), 'date' => esc_html__( 'Date', 'forminator' ), 'embed_id' => esc_html__( 'Embed Post/Page ID', 'forminator' ), 'embed_title' => esc_html__( 'Embed Post/Page Title', 'forminator' ), 'embed_url' => esc_html__( 'Embed URL', 'forminator' ), 'user_agent' => esc_html__( 'HTTP User Agent', 'forminator' ), 'refer_url' => esc_html__( 'HTTP Refer URL', 'forminator' ), 'display_name' => esc_html__( 'User Display Name', 'forminator' ), 'user_email' => esc_html__( 'User Email', 'forminator' ), 'user_login' => esc_html__( 'User Login', 'forminator' ), 'shortcode_copied' => esc_html__( 'Shortcode has been copied successfully.', 'forminator' ), 'uri_copied' => esc_html__( 'URI has been copied successfully.', 'forminator' ), ), 'commons' => array( 'color' => esc_html__( 'Color', 'forminator' ), 'colors' => esc_html__( 'Colors', 'forminator' ), 'border_color' => esc_html__( 'Border color', 'forminator' ), 'border_color_hover' => esc_html__( 'Border color (hover)', 'forminator' ), 'border_color_active' => esc_html__( 'Border color (active)', 'forminator' ), 'border_color_correct' => esc_html__( 'Border color (correct)', 'forminator' ), 'border_color_incorrect' => esc_html__( 'Border color (incorrect)', 'forminator' ), 'border_width' => esc_html__( 'Border width', 'forminator' ), 'border_style' => esc_html__( 'Border style', 'forminator' ), 'background' => esc_html__( 'Background', 'forminator' ), 'background_hover' => esc_html__( 'Background (hover)', 'forminator' ), 'background_active' => esc_html__( 'Background (active)', 'forminator' ), 'background_correct' => esc_html__( 'Background (correct)', 'forminator' ), 'background_incorrect' => esc_html__( 'Background (incorrect)', 'forminator' ), 'font_color' => esc_html__( 'Font color', 'forminator' ), 'font_color_hover' => esc_html__( 'Font color (hover)', 'forminator' ), 'font_color_active' => esc_html__( 'Font color (active)', 'forminator' ), 'font_color_correct' => esc_html__( 'Font color (correct)', 'forminator' ), 'font_color_incorrect' => esc_html__( 'Font color (incorrect)', 'forminator' ), 'font_background' => esc_html__( 'Font background (hover)', 'forminator' ), 'font_background_active' => esc_html__( 'Font background (active)', 'forminator' ), 'font_family' => esc_html__( 'Font family', 'forminator' ), 'font_family_custom' => esc_html__( 'Custom font family', 'forminator' ), 'font_family_placeholder' => esc_html__( 'E.g., \'Arial\', sans-serif', 'forminator' ), 'font_family_custom_description' => esc_html__( 'Here you can type the font family you want to use, as you would in CSS.', 'forminator' ), 'icon_size' => esc_html__( 'Icon size', 'forminator' ), 'enable' => esc_html__( 'Enable', 'forminator' ), 'dropdown' => esc_html__( 'Dropdown', 'forminator' ), 'appearance' => esc_html__( 'Appearance', 'forminator' ), 'expand' => esc_html__( 'Expand', 'forminator' ), 'placeholder' => esc_html__( 'Placeholder', 'forminator' ), 'preview' => esc_html__( 'Preview', 'forminator' ), 'icon_color' => esc_html__( 'Icon color', 'forminator' ), 'icon_color_hover' => esc_html__( 'Icon color (hover)', 'forminator' ), 'icon_color_active' => esc_html__( 'Icon color (active)', 'forminator' ), 'icon_color_correct' => esc_html__( 'Icon color (correct)', 'forminator' ), 'icon_color_incorrect' => esc_html__( 'Icon color (incorrect)', 'forminator' ), 'box_shadow' => esc_html__( 'Box shadow', 'forminator' ), 'enable_settings' => esc_html__( 'Enable settings', 'forminator' ), 'font_size' => esc_html__( 'Font size', 'forminator' ), 'font_weight' => esc_html__( 'Font weight', 'forminator' ), 'text_align' => esc_html__( 'Text align', 'forminator' ), 'regular' => esc_html__( 'Regular', 'forminator' ), 'medium' => esc_html__( 'Medium', 'forminator' ), 'large' => esc_html__( 'Large', 'forminator' ), 'light' => esc_html__( 'Light', 'forminator' ), 'normal' => esc_html__( 'Normal', 'forminator' ), 'bold' => esc_html__( 'Bold', 'forminator' ), 'typography' => esc_html__( 'Typography', 'forminator' ), 'padding_top' => esc_html__( 'Top padding', 'forminator' ), 'padding_right' => esc_html__( 'Right padding', 'forminator' ), 'padding_bottom' => esc_html__( 'Bottom padding', 'forminator' ), 'padding_left' => esc_html__( 'Left padding', 'forminator' ), 'border_radius' => esc_html__( 'Border radius', 'forminator' ), 'date_placeholder' => esc_html__( '20 April 2018', 'forminator' ), 'left' => esc_html__( 'Left', 'forminator' ), 'center' => esc_html__( 'Center', 'forminator' ), 'right' => esc_html__( 'Right', 'forminator' ), 'none' => esc_html__( 'None', 'forminator' ), 'solid' => esc_html__( 'Solid', 'forminator' ), 'dashed' => esc_html__( 'Dashed', 'forminator' ), 'dotted' => esc_html__( 'Dotted', 'forminator' ), 'delete_option' => esc_html__( 'Delete option', 'forminator' ), 'label' => esc_html__( 'Label', 'forminator' ), 'value' => esc_html__( 'Value', 'forminator' ), 'reorder_option' => esc_html__( 'Re-order this option', 'forminator' ), 'forminator_ui' => esc_html__( 'Forminator UI', 'forminator' ), 'forminator_bold' => esc_html__( 'Forminator Bold', 'forminator' ), 'forminator_flat' => esc_html__( 'Forminator Flat', 'forminator' ), 'material_design' => esc_html__( 'Material Design', 'forminator' ), 'no_file_chosen' => esc_html__( 'No file chosen', 'forminator' ), 'update_successfully' => esc_html__( 'saved successfully!', 'forminator' ), 'update_unsuccessfull' => esc_html__( 'Error! Settings were not saved.', 'forminator' ), 'approve_user_successfull' => esc_html__( 'User approved successfully.', 'forminator' ), 'error_message' => esc_html__( 'Something went wrong!', 'forminator' ), 'approve_user_unsuccessfull' => esc_html__( 'Error! User was not approved.', 'forminator' ), ), 'social' => array( 'facebook' => esc_html__( 'Facebook', 'forminator' ), 'twitter' => esc_html__( 'Twitter', 'forminator' ), 'google_plus' => esc_html__( 'Google+', 'forminator' ), 'linkedin' => esc_html__( 'LinkedIn', 'forminator' ), ), 'calendar' => array( 'day_names_min' => self::get_short_days_names(), 'month_names' => self::get_months_names(), ), 'exporter' => array( 'export_nonce' => wp_create_nonce( 'forminator_export' ), 'form_id' => forminator_get_form_id_helper(), 'form_type' => forminator_get_form_type_helper(), 'enabled' => filter_var( forminator_get_exporter_info( 'enabled', forminator_get_form_id_helper() . forminator_get_form_type_helper() ), FILTER_VALIDATE_BOOLEAN ), 'interval' => forminator_get_exporter_info( 'interval', forminator_get_form_id_helper() . forminator_get_form_type_helper() ), 'month_day' => forminator_get_exporter_info( 'month_day', forminator_get_form_id_helper() . forminator_get_form_type_helper() ), 'day' => forminator_get_exporter_info( 'day', forminator_get_form_id_helper() . forminator_get_form_type_helper() ), 'hour' => forminator_get_exporter_info( 'hour', forminator_get_form_id_helper() . forminator_get_form_type_helper() ), 'email' => forminator_get_exporter_info( 'email', forminator_get_form_id_helper() . forminator_get_form_type_helper() ), 'if_new' => forminator_get_exporter_info( 'if_new', forminator_get_form_id_helper() . forminator_get_form_type_helper() ), 'noResults' => esc_html__( 'No Result Found', 'forminator' ), 'searching' => esc_html__( 'Searching', 'forminator' ), ), 'exporter_logs' => forminator_get_export_logs( forminator_get_form_id_helper() ), 'geolocation' => array( 'configure_title' => esc_html__( 'Configure Geolocation', 'forminator' ), ), 'templates' => array( 'create_form' => esc_html__( 'Create Form', 'forminator' ), 'open_actions' => esc_html__( 'Open actions', 'forminator' ), 'alt_logo' => esc_html__( 'WPMU DEV Logo', 'forminator' ), 'login' => esc_html__( 'Log In to Your WPMU DEV Account', 'forminator' ), 'login_plugin' => esc_html__( 'Looks like your site is not connected to WPMU DEV. Log in to your WPMU DEV account to access cloud templates.', 'forminator' ), 'login_plugin2' => esc_html__( 'Looks like your site is not connected to WPMU DEV. Log in to your WPMU DEV account to unlock the complete list of preset templates.', 'forminator' ), 'login_button' => esc_html__( 'LOG IN TO WPMU DEV', 'forminator' ), 'login_dashboard' => esc_url( network_admin_url( 'admin.php?page=wpmudev' ) ), 'renew_button' => esc_html__( 'Renew Membership', 'forminator' ), 'expired' => esc_html__( 'WPMU DEV Membership Expired', 'forminator' ), 'renew_membership' => sprintf( /* translators: %s - current user display name */ esc_html__( 'Hey %s, your WPMU DEV membership has expired. You need an active membership to use the preset templates. Renew your membership to get instant access to our pre-designed form templates.', 'forminator' ), esc_html( $current_user->display_name ) ), 'renew_membership2' => sprintf( /* translators: %s - current user display name */ esc_html__( 'Hey %s, your WPMU DEV membership has expired. You need an active membership to access cloud templates. Renew your membership to get instant access to the cloud templates.', 'forminator' ), esc_html( $current_user->display_name ) ), 'install_dashboard' => esc_html__( 'You don\'t have the WPMU DEV Dashboard plugin, which you\'ll need to access Pro preset templates. Install and log in to the dashboard to unlock the complete list of preset templates.', 'forminator' ), 'install_button' => esc_html__( 'Install Plugin', 'forminator' ), 'no_templates' => esc_html__( 'No templates available', 'forminator' ), 'no_templates_desc' => sprintf( /* translators: %1$s - opening anchor tag, %2$s - closing anchor tag */ esc_html__( 'You have not saved any form templates yet. All your saved form templates will be displayed here. Click %1$shere%2$s to learn more on how to create form templates.', 'forminator' ), '', '' ), 'duplicate' => esc_html__( 'Duplicate', 'forminator' ), 'rename' => esc_html__( 'Rename', 'forminator' ), 'rename_template' => esc_html__( 'Rename Template', 'forminator' ), 'rename_descr' => esc_html__( 'Enter a new name for your template.', 'forminator' ), 'delete_template' => esc_html__( 'Delete Template', 'forminator' ), 'delete_nonce' => wp_create_nonce( 'forminator-delete-cloud-template' ), 'rename_nonce' => wp_create_nonce( 'forminator-rename-cloud-template' ), 'duplicate_nonce' => wp_create_nonce( 'forminator-duplicate-cloud-template' ), 'delete_confirm' => esc_html__( 'Are you sure you want to permanently delete the selected template from your Hub cloud account?', 'forminator' ), 'empty_search' => esc_html__( 'We couldn\'t find any template matching your search keyword. Please try again.', 'forminator' ), 'not_found' => esc_html__( 'No result found', 'forminator' ), 'search' => esc_html__( 'Search', 'forminator' ), 'no_results' => esc_html__( 'No result for “{search_text}”', 'forminator' ), 'loading_templates' => esc_html__( 'Loading templates...', 'forminator' ), 'load_categories' => esc_html__( 'Loading categories...', 'forminator' ), 'upgrade' => esc_html__( 'Upgrade', 'forminator' ), ), ); $properties = self::add_notice( $properties ); return $properties; } /** * Maybe add notices to properties * * @param array $properties Properties. * * @return array */ private static function add_notice( $properties ) { if ( isset( $_GET['forminator_notice'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended $notices = self::get_notices_list(); $key = (string) Forminator_Core::sanitize_text_field( 'forminator_notice' ); if ( ! empty( $notices[ $key ] ) ) { $properties['notices'][] = $notices[ $key ]; } } if ( isset( $_GET['forminator_text_notice'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended $properties['notices']['custom_notice'] = Forminator_Core::sanitize_text_field( 'forminator_text_notice' ); } if ( isset( $_GET['forminator_error_notice'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended $properties['notices']['error_notice'] = Forminator_Core::sanitize_text_field( 'forminator_error_notice' ); } return $properties; } /** * All possible notices that can be shown after refreshing page * * @return array */ private static function get_notices_list() { $list = array( 'settings_reset' => esc_html__( 'Data and settings have been reset successfully!', 'forminator' ), 'form_deleted' => esc_html__( 'Form successfully deleted.', 'forminator' ), 'poll_deleted' => esc_html__( 'Poll successfully deleted.', 'forminator' ), 'quiz_deleted' => esc_html__( 'Quiz successfully deleted.', 'forminator' ), 'form_duplicated' => esc_html__( 'Form successfully duplicated.', 'forminator' ), 'poll_duplicated' => esc_html__( 'Poll successfully duplicated.', 'forminator' ), 'quiz_duplicated' => esc_html__( 'Quiz successfully duplicated.', 'forminator' ), 'form_reset' => esc_html__( 'Form tracking data successfully reset.', 'forminator' ), 'poll_reset' => esc_html__( 'Poll tracking data successfully reset.', 'forminator' ), 'quiz_reset' => esc_html__( 'Quiz tracking data successfully reset.', 'forminator' ), 'preset_deleted' => esc_html__( 'The selected preset has been successfully deleted.', 'forminator' ), ); return $list; } /** * Get short days names html escaped and translated * * @return array * @since 1.5.4 */ public static function get_short_days_names() { return array( esc_html__( 'Su', 'forminator' ), esc_html__( 'Mo', 'forminator' ), esc_html__( 'Tu', 'forminator' ), esc_html__( 'We', 'forminator' ), esc_html__( 'Th', 'forminator' ), esc_html__( 'Fr', 'forminator' ), esc_html__( 'Sa', 'forminator' ), ); } /** * Get months names html escaped and translated * * @return array * @since 1.5.4 */ public static function get_months_names() { return array( esc_html__( 'January', 'forminator' ), esc_html__( 'February', 'forminator' ), esc_html__( 'March', 'forminator' ), esc_html__( 'April', 'forminator' ), esc_html__( 'May', 'forminator' ), esc_html__( 'June', 'forminator' ), esc_html__( 'July', 'forminator' ), esc_html__( 'August', 'forminator' ), esc_html__( 'September', 'forminator' ), esc_html__( 'October', 'forminator' ), esc_html__( 'November', 'forminator' ), esc_html__( 'December', 'forminator' ), ); } /** * Return times frame for select box * * @return mixed * @since 1.20.0 */ private static function get_times() { $data = array(); for ( $i = 0; $i < 24; $i++ ) { foreach ( apply_filters( 'forminator_get_times_interval', array( '00' ) ) as $min ) { $time_key = $i . ':' . $min; $time_value = date_format( date_create( $time_key ), 'h:i A' ); $data[] = apply_filters( 'forminator_get_times_hour_min', $time_value ); } } return apply_filters( 'forminator_get_times', $data ); } /** * Return time zone string. * * @return string * @since 3.1.1 */ private static function get_timezone_string() { $current_offset = get_option( 'gmt_offset' ); $tzstring = get_option( 'timezone_string' ); if ( empty( $tzstring ) ) { // Create a UTC+- zone if no timezone string exists. if ( 0 === $current_offset ) { $tzstring = 'UTC+0'; } elseif ( $current_offset < 0 ) { $tzstring = 'UTC' . $current_offset; } else { $tzstring = 'UTC+' . $current_offset; } } $timezone_string = sprintf( /* translators: %1$s - time zone, %2$s - current time, %3$s - WordPress setting link, %4$s - tag closing */ esc_html__( 'Your site\'s current time is %1$s %2$s based on your %3$sWordPress Settings%4$s', 'forminator' ), '' . esc_html( date_i18n( 'h:i a' ) ) . '', '' . esc_html( $tzstring ) . '', '', '' ); return $timezone_string; } /** * Return months frame for select box * * @return mixed * @since 1.20.0 */ private static function get_months() { $days_data = array(); $days = range( 1, 28 ); foreach ( $days as $day ) { $days_data[] = $day; } return apply_filters( 'forminator_get_months', $days_data ); } } PK!@]3class-twenty-twenty-one-customize-color-control.phpnu[PK!eaqq%class-twenty-twenty-one-svg-icons.phpnu[PK!D//%Eclass-twenty-twenty-one-dark-mode.phpnu[PK!; $QQ%+class-twenty-twenty-one-customize.phpnu[PK!^MM4class-twenty-twenty-one-customize-notice-control.phpnu[PK!G[д)class-twenty-twenty-one-custom-colors.phpnu[PK!:j,II-class-reports-page.phpnu[PK!zcctwclass-admin.phpnu[PK!r>>/class-admin-ajax.phpnu[PK!w|0-0-class-admin-data.phpnu[PK!) thirdparty-importers/.htaccessnu6$PK!x&/thirdparty-importers/class-importer-gravity.phpnu[PK!Y;l&66- thirdparty-importers/class-importer-ninja.phpnu[PK!ڕڕ+i*thirdparty-importers/class-importer-cf7.phpnu[PK!Cq~<<class-addons-page.phpnu[PK!v dclass-admin-l10n.phpnu[PK