diff --git a/classes/controllers/FrmFormsController.php b/classes/controllers/FrmFormsController.php index b94f69b15b..49de781bdc 100644 --- a/classes/controllers/FrmFormsController.php +++ b/classes/controllers/FrmFormsController.php @@ -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' ); @@ -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() { @@ -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 ); @@ -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' ) ); } /** @@ -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 @@ -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 ); @@ -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 ); } /** @@ -447,6 +460,8 @@ private static function set_post_global( $page ) { /** * @since 3.0 + * + * @return void */ private static function load_theme_preview() { add_filter( 'wp_title', 'FrmFormsController::preview_title', 9999 ); @@ -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 */ private static function fallback_when_page_template_part_is_not_supported_by_theme() { if ( have_posts() ) { @@ -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' ); @@ -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' ); @@ -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' ); @@ -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 */ public static function get_modal_values() { $name = FrmAppHelper::get_param( 'name', '', 'post', 'sanitize_text_field' ); @@ -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' ) ) { @@ -1035,6 +1067,9 @@ public static function get_columns( $columns ) { return $columns; } + /** + * @return array + */ public static function get_sortable_columns() { return array( 'id' => 'id', @@ -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; @@ -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; @@ -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' ); @@ -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; @@ -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; @@ -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'; } @@ -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 . ']';