Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 66 additions & 10 deletions classes/controllers/FrmFormsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,22 @@ private static function create_submit_button_field( $form ) {
);
}

/**
* @return void
*/
public static function edit( $values = false ) {
FrmAppHelper::permission_check( 'frm_edit_forms' );

$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );

return self::get_edit_vars( $id );
self::get_edit_vars( $id );
}

/**
* @param mixed $id
* @param string $message
* @return void
*/
public static function settings( $id = false, $message = '' ) {
FrmAppHelper::permission_check( 'frm_edit_forms' );

Expand All @@ -181,7 +189,7 @@ public static function settings( $id = false, $message = '' ) {

FrmOnSubmitHelper::maybe_migrate_submit_settings_to_action( $id );

return self::get_settings_vars( $id, array(), $message );
self::get_settings_vars( $id, array(), $message );
}

public static function update_settings() {
Expand All @@ -205,7 +213,8 @@ public static function update_settings() {
$warnings = FrmFormsHelper::check_for_warnings( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing

if ( count( $errors ) > 0 ) {
return self::get_settings_vars( $id, $errors, compact( 'warnings' ) );
self::get_settings_vars( $id, $errors, compact( 'warnings' ) );
return;
}

do_action( 'frm_before_update_form_settings', $id );
Expand All @@ -221,7 +230,7 @@ public static function update_settings() {

$message = __( 'Settings Successfully Updated', 'formidable' );

return self::get_settings_vars( $id, array(), compact( 'message', 'warnings' ) );
self::get_settings_vars( $id, array(), compact( 'message', 'warnings' ) );
}

/**
Expand All @@ -233,6 +242,9 @@ private static function antispam_was_on( $form_id ) {
return ! empty( $form->options['antispam'] );
}

/**
* @return void
*/
public static function update( $values = array() ) {
if ( empty( $values ) ) {
$values = $_POST; // phpcs:ignore WordPress.Security.NonceVerification.Missing
Expand All @@ -252,7 +264,8 @@ public static function update( $values = array() ) {
$id = isset( $values['id'] ) ? absint( $values['id'] ) : FrmAppHelper::get_param( 'id', '', 'get', 'absint' );

if ( count( $errors ) > 0 ) {
return self::get_edit_vars( $id, $errors );
self::get_edit_vars( $id, $errors );
return;
}

self::maybe_remove_draft_option_from_fields( $id );
Expand All @@ -273,7 +286,7 @@ public static function update( $values = array() ) {
wp_die( FrmAppHelper::kses( $message, array( 'a' ) ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}

return self::get_edit_vars( $id, array(), $message );
self::get_edit_vars( $id, array(), $message );
}

/**
Expand Down Expand Up @@ -447,6 +460,8 @@ private static function set_post_global( $page ) {

/**
* @since 3.0
*
Comment thread
Crabcyborg marked this conversation as resolved.
* @return void
*/
private static function load_theme_preview() {
add_filter( 'wp_title', 'FrmFormsController::preview_title', 9999 );
Expand Down Expand Up @@ -480,6 +495,8 @@ public static function preview_block_theme_body_classnames( $classes ) {
/**
* Not every theme supports get_template_part( 'page' ).
* When this is not supported, false is returned, and we can handle a fallback.
*
* @return void
Comment thread
Crabcyborg marked this conversation as resolved.
*/
private static function fallback_when_page_template_part_is_not_supported_by_theme() {
if ( have_posts() ) {
Expand Down Expand Up @@ -551,9 +568,12 @@ public static function preview_page_title( $title ) {
}

/**
* Set the page title for the theme preview page
* Set the page title for the theme preview page.
*
* @since 3.0
*
* @param string $title
* @return string
*/
public static function preview_title( $title ) {
return __( 'Form Preview', 'formidable' );
Expand Down Expand Up @@ -716,6 +736,10 @@ public static function change_form_status( $status ) {
self::display_forms_list( $params, $message );
}

/**
* @param array $ids
* @return string
*/
public static function bulk_trash( $ids ) {
FrmAppHelper::permission_check( 'frm_delete_forms' );

Expand Down Expand Up @@ -762,6 +786,10 @@ public static function destroy() {
self::display_forms_list( $params, $message );
}

/**
* @param array $ids
* @return string
*/
public static function bulk_destroy( $ids ) {
FrmAppHelper::permission_check( 'frm_delete_forms' );

Expand Down Expand Up @@ -851,6 +879,8 @@ public static function build_new_form() {
* Before creating a new form, get the name and description from the modal.
*
* @since 4.0
*
* @return array<string,string>
*/
public static function get_modal_values() {
$name = FrmAppHelper::get_param( 'name', '', 'post', 'sanitize_text_field' );
Expand All @@ -867,6 +897,8 @@ public static function get_modal_values() {
* Hook exists since 2.5.0
*
* @since 2.0.15
*
* @return void
*/
public static function insert_form_button() {
if ( current_user_can( 'frm_view_forms' ) ) {
Expand Down Expand Up @@ -1035,6 +1067,9 @@ public static function get_columns( $columns ) {
return $columns;
}

/**
* @return array<string,string>
*/
public static function get_sortable_columns() {
return array(
'id' => 'id',
Expand Down Expand Up @@ -1077,6 +1112,13 @@ public static function save_per_page( $save, $option, $value ) {
return $save;
}

/**
* @param int|string $id
* @param array $errors
* @param string $message
* @param bool $create_link
* @return void
*/
private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) {
global $frm_vars;

Expand Down Expand Up @@ -1162,6 +1204,10 @@ private static function get_edit_vars( $id, $errors = array(), $message = '', $c
require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/edit.php';
}

/**
* @param array $fields
* @return array
*/
public static function update_form_builder_fields( $fields, $form ) {
foreach ( $fields as $field ) {
$field->do_not_include_icons = true;
Expand All @@ -1175,6 +1221,12 @@ public static function maybe_update_form_builder_message( &$message ) {
}
}

/**
* @param int|string $id
* @param array $errors
* @param array|string $args
* @return void
*/
public static function get_settings_vars( $id, $errors = array(), $args = array() ) {
FrmAppHelper::permission_check( 'frm_edit_forms' );

Expand Down Expand Up @@ -1464,7 +1516,7 @@ private static function advanced_helpers( $atts ) {
);

$user_fields = self::user_shortcodes();
if ( ! empty( $user_fields ) ) {
if ( $user_fields ) {
$user_helpers = array();
foreach ( $user_fields as $uk => $uf ) {
$user_helpers[ '|user_id| show="' . $uk . '"' ] = $uf;
Expand Down Expand Up @@ -1691,6 +1743,10 @@ public static function replace_content_shortcodes( $content, $entry, $shortcodes
return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
}

/**
* @param array $errors
* @return array
*/
public static function process_bulk_form_actions( $errors ) {
if ( ! $_REQUEST ) {
return $errors;
Expand Down Expand Up @@ -1758,7 +1814,7 @@ public static function route() {
if ( empty( $json_vars ) ) {
// json decoding failed so we should return an error message.
$action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
if ( 'edit' == $action ) {
if ( 'edit' === $action ) {
$action = 'update';
}

Expand Down Expand Up @@ -1991,7 +2047,7 @@ private static function add_forms_to_admin_bar( $actions ) {
*/
public static function get_form_shortcode( $atts ) {
global $frm_vars;
if ( isset( $frm_vars['skip_shortcode'] ) && $frm_vars['skip_shortcode'] ) {
if ( ! empty( $frm_vars['skip_shortcode'] ) ) {
$sc = '[formidable';
$sc .= FrmAppHelper::array_to_html_params( $atts );
return $sc . ']';
Expand Down