Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 2 additions & 4 deletions classes/controllers/FrmAddonsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,7 @@ protected static function get_api_addons() {
* @return int Count of addons.
*/
public static function get_addons_count() {
$addons = self::get_api_addons();
return count( $addons );
return count( self::get_api_addons() );
}

/**
Expand Down Expand Up @@ -421,8 +420,7 @@ protected static function fallback_plugin_list() {
* @return string
*/
public static function get_pro_download_url() {
$license = self::get_pro_license();
$api = new FrmFormApi( $license );
$api = new FrmFormApi( self::get_pro_license() );
$downloads = $api->get_api_info();
$pro = self::get_pro_from_addons( $downloads );

Expand Down
8 changes: 3 additions & 5 deletions classes/controllers/FrmAppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,9 @@ public static function add_admin_class( $classes ) {
}

if ( FrmAppHelper::is_full_screen() ) {
$full_screen_on = self::get_full_screen_setting();
$add_class = '';
$add_class = '';

if ( $full_screen_on ) {
if ( self::get_full_screen_setting() ) {
$add_class = ' frm-full-screen is-fullscreen-mode';

// Load the CSS for .is-fullscreen-mode.
Expand Down Expand Up @@ -1583,8 +1582,7 @@ public static function apply_saved_sort_preference( &$orderby, &$order ) {
return;
}

$user_id = get_current_user_id();
$preferred_list_sort = get_user_meta( $user_id, $meta_key, true );
$preferred_list_sort = get_user_meta( get_current_user_id(), $meta_key, true );
$form_id = FrmAppHelper::simple_get( 'form', 'absint' );

if ( is_array( $preferred_list_sort ) && $form_id && is_int( $form_id ) && isset( $preferred_list_sort[ $form_id ] ) ) {
Expand Down
4 changes: 1 addition & 3 deletions classes/controllers/FrmCronController.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,7 @@ public static function schedule_events() {
* @return void
*/
public static function remove_crons() {
$events = self::get_events();

foreach ( $events as $event => $recurrence ) {
foreach ( self::get_events() as $event => $recurrence ) {
$timestamp = wp_next_scheduled( $event );

if ( false !== $timestamp ) {
Expand Down
13 changes: 5 additions & 8 deletions classes/controllers/FrmDashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,16 @@ public static function load_assets() {
* @return FrmDashboardHelper
*/
public static function get_dashboard_helper() {
$latest_available_form = FrmForm::get_latest_form();
$total_payments = self::view_args_payments();
$counters_value = array(
$total_payments = self::view_args_payments();
$counters_value = array(
'forms' => FrmForm::get_forms_count(),
'entries' => FrmEntry::get_entries_count(),
);

return new FrmDashboardHelper(
array(
'counters' => array(
'counters' => self::view_args_counters( $latest_available_form, $counters_value ),
'counters' => self::view_args_counters( FrmForm::get_latest_form(), $counters_value ),
),
'license' => array(),
'get_free_templates' => array(),
Expand Down Expand Up @@ -359,9 +358,8 @@ public static function entries_columns( $columns = array() ) {
* @return bool
*/
public static function welcome_banner_has_closed() {
$user_id = get_current_user_id();
$banner_closed_by_users = self::get_closed_welcome_banner_user_ids();
return $banner_closed_by_users && in_array( $user_id, $banner_closed_by_users, true );
return $banner_closed_by_users && in_array( get_current_user_id(), $banner_closed_by_users, true );
}

/**
Expand All @@ -381,8 +379,7 @@ public static function is_dashboard_page() {
* @return bool
*/
public static function email_is_subscribed( $email ) {
$subscribed_emails = self::get_subscribed_emails();
return in_array( $email, $subscribed_emails, true );
return in_array( $email, self::get_subscribed_emails(), true );
}

/**
Expand Down
4 changes: 1 addition & 3 deletions classes/controllers/FrmEmailStylesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,7 @@ public static function ajax_preview() {
die( esc_html( $not_exist_msg ) );
}

$styles = self::get_email_styles();

if ( ! isset( $styles[ $style_key ] ) ) {
if ( ! isset( self::get_email_styles()[ $style_key ] ) ) {
die( esc_html( $not_exist_msg ) );
}

Expand Down
4 changes: 1 addition & 3 deletions classes/controllers/FrmEntriesAJAXSubmitController.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ public static function ajax_create() {
wp_die();
}

$is_ajax_on = FrmForm::is_ajax_on( $form );

if ( ! $is_ajax_on ) {
if ( ! FrmForm::is_ajax_on( $form ) ) {
// This continues in the Pro version as it is required for other features including in-place edit.
// In Lite, if AJAX submit is not on, just exit early as this function is getting called incorrectly.
echo json_encode( $response );
Expand Down
3 changes: 1 addition & 2 deletions classes/controllers/FrmEntriesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,7 @@ public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $met
return;
}

$user_id = get_current_user_id();
update_user_option( $user_id, $this_page_name, $meta_value, true );
update_user_option( get_current_user_id(), $this_page_name, $meta_value, true );
}

/**
Expand Down
14 changes: 5 additions & 9 deletions classes/controllers/FrmFormsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ public static function update_settings() {

do_action( 'frm_before_update_form_settings', $id );

$antispam_was_on = self::antispam_was_on( $id );
$antispam_was_on = self::antispam_was_on( $id ); // phpcs:ignore Formidable.CodeAnalysis.InlineSingleUseVariable

FrmForm::update( $id, $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing

Expand Down Expand Up @@ -1073,9 +1073,8 @@ public static function insert_form_button() {
// In a form with 66 HTML fields, this saves 0.5 seconds on page load time, tested locally.
if ( ! isset( self::$formidable_tinymce_button ) ) {
FrmAppHelper::load_admin_wide_js();
$menu_name = FrmAppHelper::get_menu_name();
$icon = apply_filters( 'frm_media_icon', FrmAppHelper::svg_logo() );
self::$formidable_tinymce_button = '<a href="#TB_inline?width=50&height=50&inlineId=frm_insert_form" class="thickbox button add_media frm_insert_form" title="' . esc_attr__( 'Add forms and content', 'formidable' ) . '">' . FrmAppHelper::kses( $icon, 'all' ) . ' ' . esc_html( $menu_name ) . '</a>'; // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
self::$formidable_tinymce_button = '<a href="#TB_inline?width=50&height=50&inlineId=frm_insert_form" class="thickbox button add_media frm_insert_form" title="' . esc_attr__( 'Add forms and content', 'formidable' ) . '">' . FrmAppHelper::kses( $icon, 'all' ) . ' ' . esc_html( FrmAppHelper::get_menu_name() ) . '</a>'; // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
}
echo self::$formidable_tinymce_button; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
Expand Down Expand Up @@ -2298,9 +2297,7 @@ public static function admin_bar_css() {
* @since 4.05.02
*/
private static function move_menu_to_footer() {
$settings = FrmAppHelper::get_settings();

if ( empty( $settings->admin_bar ) ) {
if ( empty( FrmAppHelper::get_settings()->admin_bar ) ) {
remove_action( 'wp_body_open', 'wp_admin_bar_render', 0 );
}
}
Expand Down Expand Up @@ -3674,7 +3671,7 @@ public static function get_page_dropdown() {

check_ajax_referer( 'frm_ajax', 'nonce' );

$html = FrmAppHelper::clip(
$html = FrmAppHelper::clip(
function () {
FrmAppHelper::maybe_autocomplete_pages_options(
array(
Expand All @@ -3685,11 +3682,10 @@ function () {
);
}
);
$post_type_object = get_post_type_object( 'page' );
wp_send_json(
array(
'html' => $html,
'edit_page_url' => admin_url( sprintf( $post_type_object->_edit_link . '&action=edit', 0 ) ),
'edit_page_url' => admin_url( sprintf( get_post_type_object( 'page' )->_edit_link . '&action=edit', 0 ) ),
)
);
}
Expand Down
4 changes: 1 addition & 3 deletions classes/controllers/FrmInboxController.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ public static function dismiss_message() {
* @return void
*/
private static function add_tracking_request() {
$settings = FrmAppHelper::get_settings();

if ( $settings->tracking ) {
if ( FrmAppHelper::get_settings()->tracking ) {
return;
}

Expand Down
3 changes: 1 addition & 2 deletions classes/controllers/FrmSMTPController.php
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,8 @@ protected function is_smtp_configured() {
return false;
}

$phpmailer = $this->get_phpmailer();
$mailer = WPMailSMTP\Options::init()->get( 'mail', 'mailer' );
$is_mailer_complete = wp_mail_smtp()->get_providers()->get_mailer( $mailer, $phpmailer )->is_mailer_complete();
$is_mailer_complete = wp_mail_smtp()->get_providers()->get_mailer( $mailer, $this->get_phpmailer() )->is_mailer_complete();

return 'mail' !== $mailer && $is_mailer_complete;
}
Expand Down
16 changes: 6 additions & 10 deletions classes/controllers/FrmStylesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,7 @@ private static function get_url_to_custom_style( &$stylesheet_urls ) {
*/
public static function get_file_name() {
if ( is_multisite() ) {
$blog_id = get_current_blog_id();
return 'formidableforms' . absint( $blog_id ) . '.css';
return 'formidableforms' . absint( get_current_blog_id() ) . '.css';
}

return 'formidableforms.css';
Expand Down Expand Up @@ -368,9 +367,8 @@ public static function load_styler() {
return;
}

$frm_style = new FrmStyle( $style_id );
$active_style = $frm_style->get_one();
$default_style = self::get_default_style();
$frm_style = new FrmStyle( $style_id );
$active_style = $frm_style->get_one();

self::disable_admin_page_styling_on_submit_buttons();

Expand All @@ -381,7 +379,7 @@ public static function load_styler() {
*/
do_action( 'frm_before_render_style_page', compact( 'form' ) );

self::render_style_page( $active_style, $form, $default_style );
self::render_style_page( $active_style, $form, self::get_default_style() );
}

/**
Expand Down Expand Up @@ -526,9 +524,8 @@ private static function save_form_style() {
// If the default style is selected, use the "Always use default" legacy option instead of the default style.
// There's also a check here for conversational forms.
// Without the check it isn't possible to select "Default" because "Always use default" will convert to "Lines" dynamically.
$default_style = self::get_default_style();

if ( $style_id === $default_style->ID && empty( $form->options['chat'] ) ) {
if ( $style_id === self::get_default_style()->ID && empty( $form->options['chat'] ) ) {
$style_id = 1;
}

Expand Down Expand Up @@ -987,8 +984,7 @@ public static function reset_styling() {
// A style ID is not sent when resetting on the edit page.
// Instead of resetting the style, send the defaults back so the inputs can be updated with JavaScript.
$frm_style = new FrmStyle();
$defaults = $frm_style->get_defaults();
echo json_encode( $defaults );
echo json_encode( $frm_style->get_defaults() );
wp_die();
}

Expand Down
6 changes: 2 additions & 4 deletions classes/controllers/FrmWelcomeTourController.php
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,6 @@ private static function should_show_checklist() {
$page = FrmAppHelper::simple_get( 'page' );
$is_form_templates_page = FrmFormTemplatesController::PAGE_SLUG === $page;
$is_form_builder_page = FrmAppHelper::is_form_builder_page();
$is_style_editor_page = FrmAppHelper::is_style_editor_page();

switch ( $active_step ) {
case 'create-form':
Expand All @@ -370,7 +369,7 @@ private static function should_show_checklist() {
case 'style-form':
case 'embed-form':
case 'completed':
return $is_form_builder_page || $is_style_editor_page;
return $is_form_builder_page || FrmAppHelper::is_style_editor_page();
default:
return false;
}
Expand Down Expand Up @@ -622,9 +621,8 @@ public static function get_usage_data() {
}

$usage_data = array();
$steps = self::get_steps();

foreach ( $steps as $key => $step ) {
foreach ( self::get_steps() as $key => $step ) {
$usage_data[ 'completed_step_' . $key ] = empty( $option['completed_steps'][ $key ] ) ? 0 : 1;
}
Comment thread
Crabcyborg marked this conversation as resolved.

Expand Down
16 changes: 5 additions & 11 deletions classes/helpers/FrmAppHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,7 @@ public static function is_formidable_branding() {
return true;
}

$menu_icon = self::get_menu_icon_class();
return str_contains( $menu_icon, 'frm_logo_icon' );
return str_contains( self::get_menu_icon_class(), 'frm_logo_icon' );
}

/**
Expand Down Expand Up @@ -1051,8 +1050,7 @@ private static function decode_amp( &$string ) {
* @return string
*/
public static function kses( $value, $allowed = array() ) {
$allowed_html = self::allowed_html( $allowed );
return wp_kses( $value, $allowed_html );
return wp_kses( $value, self::allowed_html( $allowed ) );
}

/**
Expand Down Expand Up @@ -2341,8 +2339,7 @@ public static function maybe_add_permissions() {
return;
}

$user_id = get_current_user_id();
$user = new WP_User( $user_id );
$user = new WP_User( get_current_user_id() );
$frm_roles = self::frm_capabilities();

foreach ( $frm_roles as $frm_role => $frm_role_description ) {
Expand Down Expand Up @@ -3820,8 +3817,7 @@ public static function maybe_highlight_menu( $post_type ) {
* @return void
*/
public static function load_admin_wide_js( $load = true ) {
$version = self::plugin_version();
wp_register_script( 'formidable_admin_global', self::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), $version );
wp_register_script( 'formidable_admin_global', self::plugin_url() . '/js/formidable_admin_global.js', array( 'jquery' ), self::plugin_version() );

$global_strings = array(
'updating_msg' => __( 'Please wait while your site updates.', 'formidable' ),
Expand Down Expand Up @@ -4489,9 +4485,7 @@ public static function should_never_allow_unfiltered_html() {
* @return array
*/
public static function maybe_filter_array( $values, $keys ) {
$allow_unfiltered_html = self::allow_unfiltered_html();

if ( $allow_unfiltered_html ) {
if ( self::allow_unfiltered_html() ) {
return $values;
}

Expand Down
11 changes: 3 additions & 8 deletions classes/helpers/FrmEntriesHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -894,9 +894,7 @@ public static function maybe_render_captcha_score( $entry_id ) {
* @return int
*/
public static function get_entry_status( $status ) {
$statuses = self::get_entry_statuses();

if ( array_key_exists( $status, $statuses ) ) {
if ( array_key_exists( $status, self::get_entry_statuses() ) ) {
return $status;
}

Expand All @@ -919,8 +917,7 @@ public static function get_entry_status( $status ) {
* @return string
*/
public static function get_entry_status_label( $status ) {
$statuses = self::get_entry_statuses();
return $statuses[ self::get_entry_status( $status ) ];
return self::get_entry_statuses()[ self::get_entry_status( $status ) ];
}

/**
Expand Down Expand Up @@ -963,9 +960,7 @@ public static function get_entry_statuses() {
* @return int
*/
public static function get_visible_unread_inbox_count() {
$menu_name = FrmAppHelper::get_menu_name();

if ( ! in_array( $menu_name, array( 'Formidable', 'Forms' ), true ) ) {
if ( ! in_array( FrmAppHelper::get_menu_name(), array( 'Formidable', 'Forms' ), true ) ) {
return 0;
}

Expand Down
3 changes: 1 addition & 2 deletions classes/helpers/FrmEntriesListHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,9 @@ protected function set_per_page() {
protected function get_entry_items( &$s_query, &$join_form_in_query ) {
global $per_page;
$s_query = $this->get_search_query( $join_form_in_query );
$order = $this->get_order_by();
$limit = $this->get_limit( $per_page );

return FrmEntry::getAll( $s_query, $order, $limit, true, $join_form_in_query );
return FrmEntry::getAll( $s_query, $this->get_order_by(), $limit, true, $join_form_in_query );
}

/**
Expand Down
3 changes: 1 addition & 2 deletions classes/helpers/FrmFieldGdprHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ class FrmFieldGdprHelper {
* @return bool
*/
public static function hide_gdpr_field() {
$settings = FrmAppHelper::get_settings();
return ! $settings->enable_gdpr;
return ! FrmAppHelper::get_settings()->enable_gdpr;
}

/**
Expand Down
3 changes: 1 addition & 2 deletions classes/helpers/FrmFieldGridHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,8 @@ public function get_field_layout_class() {

$split = explode( ' ', $field['classes'] );
$this->is_frm_first = in_array( 'frm_first', $split, true );
$classes = self::get_grid_classes();

foreach ( $classes as $class ) {
foreach ( self::get_grid_classes() as $class ) {
if ( in_array( $class, $split, true ) ) {
return $class;
}
Expand Down
Loading
Loading