/** * @covers ::gravityview_strip_whitespace() */ public function test_gravityview_strip_whitespace() { // Pure whitespace gets stripped $this->assertEquals('', gravityview_strip_whitespace(' ')); $this->assertEquals('', gravityview_strip_whitespace(' ')); $this->assertEquals('', gravityview_strip_whitespace("\t")); $this->assertEquals('', gravityview_strip_whitespace("\t\t")); $this->assertEquals('', gravityview_strip_whitespace("\n")); $this->assertEquals('', gravityview_strip_whitespace("\n\n")); $this->assertEquals('', gravityview_strip_whitespace("\r")); $this->assertEquals('', gravityview_strip_whitespace("\r\r")); $this->assertEquals('', gravityview_strip_whitespace("\r\n\t ")); $this->assertEquals('Word', gravityview_strip_whitespace("\nWord\n")); $this->assertEquals('Word Word', gravityview_strip_whitespace("Word\nWord\n")); $this->assertEquals('Word Word Word', gravityview_strip_whitespace("Word\nWord\nWord\n")); $this->assertEquals('Word Word Word', gravityview_strip_whitespace("Word Word Word ")); $this->assertEquals('Word Word Word Word', gravityview_strip_whitespace("Word\n\tWord\n\tWord\n\tWord")); }
/** * Display the Edit Entry form * * @return [type] [description] */ public function edit_entry_form() { $back_link = esc_url(remove_query_arg(array('page', 'view', 'edit'))); ?> <div class="gv-edit-entry-wrapper"><?php $javascript = gravityview_ob_include(GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this); /** * Fixes weird wpautop() issue * @see https://github.com/katzwebservices/GravityView/issues/451 */ echo gravityview_strip_whitespace($javascript); ?> <h2 class="gv-edit-entry-title"> <span><?php /** * @filter `gravityview_edit_entry_title` Modify the edit entry title * @param string $edit_entry_title Modify the "Edit Entry" title * @param GravityView_Edit_Entry_Render $this This object */ $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this); echo esc_attr($edit_entry_title); ?> </span> </h2> <?php // Display the success message if (rgpost('action') === 'update') { if (!$this->is_valid) { // Keeping this compatible with Gravity Forms. $validation_message = "<div class='validation_error'>" . __('There was a problem with your submission.', 'gravityview') . " " . __('Errors have been highlighted below.', 'gravityview') . "</div>"; $message = apply_filters("gform_validation_message_{$this->form['id']}", apply_filters("gform_validation_message", $validation_message, $this->form), $this->form); echo GVCommon::generate_notice($message, 'gv-error'); } else { $entry_updated_message = sprintf(esc_attr__('Entry Updated. %sReturn to Entry%s', 'gravityview'), '<a href="' . $back_link . '">', '</a>'); /** * @filter `gravityview/edit_entry/success` Modify the edit entry success message (including the anchor link) * @since 1.5.4 * @param string $entry_updated_message Existing message * @param int $view_id View ID * @param array $entry Gravity Forms entry array * @param string $back_link URL to return to the original entry. @since 1.6 */ $message = apply_filters('gravityview/edit_entry/success', $entry_updated_message, $this->view_id, $this->entry, $back_link); echo GVCommon::generate_notice($message); } } ?> <?php // The ID of the form needs to be `gform_{form_id}` for the pluploader ?> <form method="post" id="gform_<?php echo $this->form_id; ?> " enctype="multipart/form-data"> <?php wp_nonce_field(self::$nonce_key, self::$nonce_key); wp_nonce_field(self::$nonce_field, self::$nonce_field, false); // Most of this is needed for GFFormDisplay::validate(), but `gform_unique_id` is needed for file cleanup. ?> <?php /** * By default, the lead_detail_edit method uses the `RGFormsModel::get_lead_field_value()` method, which doesn't fill in $_POST values when there is a validation error, because it was designed to work in the admin. We want to use the `RGFormsModel::get_field_value()` If the form has been submitted, use the values for the fields. */ //add_filter( 'gform_get_field_value', array( $this, 'get_field_value' ), 10, 3 ); // Print the actual form HTML $this->render_edit_form(); //echo $this->render_form_buttons(); ?> </form> </div> <?php }
/** * Given a View id, calculates the assigned form, and returns the form fields (only the sortable ones ) * AJAX callback * * * @access public * @return void */ function get_sortable_fields() { $this->check_ajax_nonce(); $form = ''; // if form id is set, use it, else, get form from preset if (!empty($_POST['form_id'])) { $form = (int) $_POST['form_id']; } elseif (!empty($_POST['template_id'])) { $form = GravityView_Ajax::pre_get_form_fields($_POST['template_id']); } $response = gravityview_get_sortable_fields($form); $response = gravityview_strip_whitespace($response); exit($response); }
/** * Display the Edit Entry form * * @return [type] [description] */ public function edit_entry_form() { ?> <div class="gv-edit-entry-wrapper"><?php $javascript = gravityview_ob_include(GravityView_Edit_Entry::$file . '/partials/inline-javascript.php', $this); /** * Fixes weird wpautop() issue * @see https://github.com/katzwebservices/GravityView/issues/451 */ echo gravityview_strip_whitespace($javascript); ?> <h2 class="gv-edit-entry-title"> <span><?php /** * @filter `gravityview_edit_entry_title` Modify the edit entry title * @param string $edit_entry_title Modify the "Edit Entry" title * @param GravityView_Edit_Entry_Render $this This object */ $edit_entry_title = apply_filters('gravityview_edit_entry_title', __('Edit Entry', 'gravityview'), $this); echo esc_attr($edit_entry_title); ?> </span> </h2> <?php $this->maybe_print_message(); ?> <?php // The ID of the form needs to be `gform_{form_id}` for the pluploader ?> <form method="post" id="gform_<?php echo $this->form_id; ?> " enctype="multipart/form-data"> <?php wp_nonce_field(self::$nonce_key, self::$nonce_key); wp_nonce_field(self::$nonce_field, self::$nonce_field, false); // Print the actual form HTML $this->render_edit_form(); ?> </form> </div> <?php }