/home/techb158/l2hypotheques.com/wp-content/plugins/wpforms-lite/src/Admin/Tools/Views
NameSizeModeActions
ActionScheduler.php14010644editdlrm
ActionSchedulerList.php24510644editdlrm
CodeSnippets.php28450644editdlrm
EntryAutomation.php21070644editdlrm
Export.php96350644editdlrm
Import.php116220644editdlrm
Importer.php99010644editdlrm
Logs.php83940644editdlrm
System.php140210644editdlrm
View.php17440644editdlrm
Edit: /home/techb158/l2hypotheques.com/wp-content/plugins/wpforms-lite/src/Admin/Tools/Views/Import.php (11622B)
check_unfiltered_html_capability() ) { $this->error_unfiltered_html_import_message(); return; } $this->hooks(); $this->importers = ( new Importers() )->get_importers(); } /** * Register hooks. * * @since 1.7.9 */ private function hooks() { add_action( 'wpforms_tools_init', [ $this, 'import_process' ] ); } /** * Get view label. * * @since 1.6.6 * * @return string */ public function get_label() { return esc_html__( 'Import', 'wpforms-lite' ); } /** * Import process. * * @since 1.6.6 */ public function import_process() { // phpcs:disable WordPress.Security.NonceVerification.Missing if ( empty( $_POST['action'] ) || $_POST['action'] !== 'import_form' || empty( $_FILES['file']['tmp_name'] ) || ! isset( $_POST['submit-import'] ) || ! $this->verify_nonce() ) { return; } // phpcs:enable WordPress.Security.NonceVerification.Missing $this->process(); } /** * Import view content. * * @since 1.6.6 */ public function display() { // Bail early, in case the current user lacks the `unfiltered_html` capability. if ( ! $this->check_unfiltered_html_capability() ) { return; } $this->success_import_message(); $this->wpforms_block(); $this->other_forms_block(); } /** * Success import message. * * @since 1.6.6 */ private function success_import_message() { // phpcs:ignore WordPress.Security.NonceVerification.Recommended if ( isset( $_GET['wpforms_notice'] ) && $_GET['wpforms_notice'] === 'forms-imported' ) { ?>

check your forms.', 'wpforms-lite' ), [ 'a' => [ 'href' => [] ] ] ), esc_url( admin_url( 'admin.php?page=wpforms-overview' ) ) ); } ?>

reach out to our support team.', 'wpforms-lite' ), [ 'a' => [ 'href' => [], 'target' => [], 'rel' => [], ], ] ), 'https://wpforms.com/contact/' ) ); } /** * WPForms section. * * @since 1.6.6 */ private function wpforms_block() { ?>

nonce_field(); ?>

importers ) ) { ?>

400, ] ); } // The wp_unslash() function breaks upload on Windows. // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash, WordPress.Security.NonceVerification.Missing $filename = isset( $_FILES['file']['tmp_name'] ) ? sanitize_text_field( $_FILES['file']['tmp_name'] ) : ''; // phpcs:enable WordPress.Security.NonceVerification.Missing $result = self::import_forms( $filename ); if ( $result !== null ) { wp_die( esc_html( $result->get_error_message() ), esc_html__( 'Error', 'wpforms-lite' ), [ 'response' => 400, ] ); } wp_safe_redirect( add_query_arg( [ 'wpforms_notice' => 'forms-imported' ] ) ); exit; } /** * Import forms from file. * Should be static for external use. * * @since 1.8.6 * * @param string $filename File containing forms to be imported. * * @return null|WP_Error */ public static function import_forms( string $filename ) { if ( ! current_user_can( 'unfiltered_html' ) ) { return new WP_Error( 'no_permission', __( 'The unfiltered HTML permissions are required to import form.', 'wpforms-lite' ) ); } // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents $forms = json_decode( File::remove_utf8_bom( file_get_contents( $filename ) ), true ); if ( empty( $forms ) || ! is_array( $forms ) ) { return new WP_Error( 'bad_json', __( 'Please upload a valid .json form export file.', 'wpforms-lite' ) ); } if ( ! self::save_forms( $forms ) ) { return new WP_Error( 'no_permission', __( 'There was an error saving your form. Please check your file and try again.', 'wpforms-lite' ) ); } return null; } /** * Save forms. * * @since 1.8.6 * * @param array $forms Forms. * * @return bool */ private static function save_forms( array $forms ): bool { foreach ( $forms as $form ) { $title = ! empty( $form['settings']['form_title'] ) ? $form['settings']['form_title'] : ''; $desc = ! empty( $form['settings']['form_desc'] ) ? $form['settings']['form_desc'] : ''; $new_id = wp_insert_post( [ 'post_title' => wp_slash( $title ), 'post_status' => 'publish', 'post_type' => 'wpforms', 'post_excerpt' => wp_slash( $desc ), ] ); // When we cannot insert one form into the DB, or update it, // we will have a similar issue with the following form in the JSON file. // So, it is better to bail out and inform the user that we cannot proceed. if ( ! $new_id ) { return false; } $form['id'] = $new_id; if ( ! self::update_form( $form ) ) { return false; } } return true; } /** * Update form. * * @since 1.8.6 * * @param array $form Form. * * @return bool */ private static function update_form( array $form ): bool { if ( wpforms_is_form_data_slashing_enabled() ) { $form = wp_slash( $form ); } $result = wp_update_post( [ 'ID' => $form['id'], 'post_content' => wpforms_encode( $form ), ] ); if ( ! $result ) { return false; } if ( empty( $form['settings']['form_tags'] ) ) { return true; } $result = wp_set_post_terms( $form['id'], implode( ',', (array) $form['settings']['form_tags'] ), WPForms_Form_Handler::TAGS_TAXONOMY ); if ( ! $result ) { return false; } return true; } }