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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ _typos.toml export-ignore
/resources/ export-ignore
webpack.dev.js export-ignore
.browserslistrc export-ignore
/phpcs-sniffs/ export-ignore
5 changes: 5 additions & 0 deletions .github/workflows/phpcs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,10 @@ jobs:
- name: Install dependencies
run: composer install --dev --prefer-dist --no-progress

- name: Register custom PHPCS sniffs
run: |
CURRENT_PATHS=$(./vendor/bin/phpcs --config-show | grep 'installed_paths' | cut -d' ' -f2)
./vendor/bin/phpcs --config-set installed_paths "$CURRENT_PATHS,../../../phpcs-sniffs"

- name: PHPCS check
run: ./vendor/bin/phpcs --parallel=10 ./
1 change: 1 addition & 0 deletions bin/zip-plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ zip -r $zipname $destination \
-x "*/_typos.toml" \
-x "formidable-ai/resources/*" \
-x "*/webpack.dev.js"
-x "*/phpcs-sniffs/*"

if [ ! -z "$3" ]; then
rm -rf $destination
Expand Down
5 changes: 5 additions & 0 deletions classes/controllers/FrmAddonsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ public static function get_primary_license_info() {
if ( empty( $installed_addons ) || ! isset( $installed_addons['formidable_pro'] ) ) {
return false;
}

$installed_addons = array(
'formidable_pro' => $installed_addons['formidable_pro'],
);
Expand Down Expand Up @@ -786,6 +787,7 @@ protected static function prepare_addons( &$addons ) {
} else {
$base_file = 'formidable-' . $slug;
}

$file_name = $base_file . '/' . $base_file . '.php';
if ( ! isset( $addon['plugin'] ) ) {
$addon['plugin'] = $file_name;
Expand Down Expand Up @@ -849,6 +851,7 @@ private static function get_active_views_version() {
if ( ! is_callable( 'FrmViewsAppHelper::plugin_version' ) ) {
return false;
}

$plugin_version = FrmViewsAppHelper::plugin_version();
return version_compare( $plugin_version, '5.0', '>=' ) ? 'visual-views' : 'views';
}
Expand All @@ -865,6 +868,7 @@ protected static function prepare_addon_link( &$link ) {
if ( strpos( $link, 'http' ) !== 0 ) {
$link = $site_url . $link;
}

$link = FrmAppHelper::make_affiliate_url( $link );

$utm = array(
Expand Down Expand Up @@ -1272,6 +1276,7 @@ public static function connect_link() {
$auth = hash( 'sha512', wp_rand() );
update_option( 'frm_connect_token', $auth, 'no' );
}

$page = FrmAppHelper::simple_get( 'page', 'sanitize_title', 'formidable-settings' );
$link = 'https://formidableforms.com/api-connect/';
$args = array(
Expand Down
2 changes: 2 additions & 0 deletions classes/controllers/FrmAppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ public static function add_admin_class( $classes ) {
// Load the CSS for .is-fullscreen-mode.
wp_enqueue_style( 'wp-edit-post' );
}

$classes .= apply_filters( 'frm_admin_full_screen_class', $add_class );
}

Expand Down Expand Up @@ -787,6 +788,7 @@ public static function admin_js() {
if ( ! $post ) {
return;
}

$post_type = $post->post_type;
} else {
return;
Expand Down
1 change: 1 addition & 0 deletions classes/controllers/FrmEmailStylesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ private static function get_test_rich_text_email_content( $style_key, $table_row
a {color:' . esc_attr( $style_settings['link_color'] ) . ';}
</style>';
}

$wrapped_content .= '</head><body>' . $content . '</body></html>';

return $wrapped_content;
Expand Down
1 change: 1 addition & 0 deletions classes/controllers/FrmEntriesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ private static function maybe_format_field_name_for_column_title( $field, $inclu
if ( ! $include_column_for_sep_val || ! in_array( $field->type, array( 'select', 'radio', 'checkbox' ), true ) ) {
return $field_name;
}

$append_text = $is_value ? esc_html__( 'value', 'formidable' ) : esc_html__( 'label', 'formidable' );

return sprintf( '%s (%s)', $field_name, $append_text );
Expand Down
1 change: 1 addition & 0 deletions classes/controllers/FrmFormActionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,7 @@ public static function update_settings( $form_id ) {
if ( ! empty( $new_actions ) ) {
$new_actions = call_user_func_array( 'array_merge', $new_actions );
}

$old_actions = array_diff( $old_actions, $new_actions );

self::delete_missing_actions( $old_actions );
Expand Down
3 changes: 3 additions & 0 deletions classes/controllers/FrmFormsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ public static function list_form() {
$message = $errors['message'];
unset( $errors['message'] );
}

$errors = apply_filters( 'frm_admin_list_form_action', $errors );

self::display_forms_list( $params, $message, $errors );
Expand Down Expand Up @@ -1096,6 +1097,7 @@ private static function should_insert_form_popup() {
if ( FrmAppHelper::is_form_builder_page() ) {
return true;
}

$page = basename( FrmAppHelper::get_server_value( 'PHP_SELF' ) );
return in_array( $page, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php' ), true );
}
Expand Down Expand Up @@ -1132,6 +1134,7 @@ public static function get_shortcode_opts() {
),
);
}

$opts = apply_filters( 'frm_sc_popup_opts', $opts, $shortcode );

if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) {
Expand Down
5 changes: 5 additions & 0 deletions classes/controllers/FrmXMLController.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public static function install_template() {
} else {
$message = __( 'There was an error importing form', 'formidable' );
}

$response = array(
'message' => $message,
);
Expand Down Expand Up @@ -151,6 +152,7 @@ private static function get_posted_form() {
if ( empty( $form ) ) {
return $form;
}

$form = json_decode( $form, true );
return $form;
}
Expand Down Expand Up @@ -530,6 +532,7 @@ public static function generate_xml( $type, $args = array() ) {
}
unset( $form_id, $form_data );
}

$select = $table . '.ID';
$where['post_type'] = 'frm_styles';

Expand Down Expand Up @@ -640,6 +643,7 @@ private static function get_file_name( $args, $records ) {
if ( ! empty( $sitename ) ) {
$sitename .= '.';
}

$filename = $sitename . 'formidable.' . gmdate( 'Y-m-d' ) . '.xml';
}//end if

Expand Down Expand Up @@ -688,6 +692,7 @@ public static function csv( $form_id = false, $search = '', $fid = '' ) {
if ( function_exists( 'set_time_limit' ) ) {
set_time_limit( 0 );
}

$mem_limit = str_replace( 'M', '', ini_get( 'memory_limit' ) );
if ( (int) $mem_limit < 256 ) {
wp_raise_memory_limit();
Expand Down
2 changes: 2 additions & 0 deletions classes/helpers/FrmApiHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public static function is_for_user( $item ) {
if ( ! isset( $item['who'] ) || $item['who'] === 'all' ) {
return true;
}

$who = (array) $item['who'];
if ( self::is_for_everyone( $who ) ) {
return true;
Expand Down Expand Up @@ -99,6 +100,7 @@ private static function is_first_30() {
// because the user was active before this option was introduced.
return false;
}

$cutoff = strtotime( '-30 days' );
return $activation_timestamp > $cutoff;
}
Expand Down
6 changes: 6 additions & 0 deletions classes/helpers/FrmAppHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -1376,6 +1376,7 @@ public static function icon_by_class( $class, $atts = array() ) {
$icon = explode( ' ', $icon );
$icon = reset( $icon );
}

$icon = '<svg class="frmsvg' . esc_attr( $class ) . '"' . $html_atts . '><use xlink:href="#' . esc_attr( $icon ) . '" /></svg>';
}

Expand Down Expand Up @@ -2521,6 +2522,7 @@ public static function esc_textarea( $text, $is_rich_text = false ) {
if ( ! $is_rich_text ) {
$safe_text = htmlspecialchars( $safe_text, ENT_NOQUOTES );
}

$safe_text = str_replace( '&amp; ', '& ', $safe_text );

/**
Expand Down Expand Up @@ -2870,6 +2872,7 @@ private static function fill_field_defaults( $field, $record, array &$values, $a
if ( ! isset( $field->field_options['custom_field'] ) ) {
$field->field_options['custom_field'] = '';
}

$meta_value = FrmProEntryMetaHelper::get_post_value(
$record->post_id,
$field->field_options['post_field'],
Expand Down Expand Up @@ -3196,6 +3199,7 @@ public static function human_time_diff( $from, $to = '', $levels = 1 ) {
} else {
$now = new DateTime( '@' . $to );
}

$ago = new DateTime( '@' . $from );

// Get the time difference
Expand All @@ -3219,6 +3223,7 @@ public static function human_time_diff( $from, $to = '', $levels = 1 ) {
$levels => $time_strings[ $levels ],
);
}

$levels = 1;
}

Expand Down Expand Up @@ -3706,6 +3711,7 @@ public static function format_form_data( &$form ) {
if ( ! isset( $input['name'] ) ) {
continue;
}

$key = $input['name'];
if ( isset( $formatted[ $key ] ) ) {
if ( is_array( $formatted[ $key ] ) ) {
Expand Down
3 changes: 3 additions & 0 deletions classes/helpers/FrmCSVExportHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ private static function field_headings( $col ) {
} else {
$field_headings[ $col->id ] = strip_tags( $col->name );
}

$field_headings = apply_filters(
'frm_csv_field_columns',
$field_headings,
Expand Down Expand Up @@ -807,6 +808,7 @@ private static function print_csv_row( $rows ) {
} else {
fwrite( self::$fp, $sep . '"' . $val . '"' );
}

$sep = self::$column_separator;

unset( $k, $row );
Expand Down Expand Up @@ -870,6 +872,7 @@ public static function escape_csv( $value ) {
// escape the = to prevent vulnerability
$value = "'" . $value;
}

$value = str_replace( '"', '""', $value );

return $value;
Expand Down
1 change: 1 addition & 0 deletions classes/helpers/FrmEntriesHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ public static function prepare_display_value( $entry, $field, $atts ) {
if ( strpos( implode( ' ', $field_value ), '<img' ) !== false ) {
$sep = '<br/>';
}

$val = implode( $sep, $field_value );

return FrmAppHelper::kses( $val, 'all' );
Expand Down
2 changes: 2 additions & 0 deletions classes/helpers/FrmEntriesListHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ public function no_items() {
if ( $form_id ) {
$form = FrmForm::getOne( $form_id );
}

$has_form = ! empty( $form );

if ( ! $has_form ) {
Expand Down Expand Up @@ -386,6 +387,7 @@ public function single_row( $item, $style = '' ) {
} else {
$r .= $val;
}

$r .= '</td>';
}
unset( $val );
Expand Down
4 changes: 4 additions & 0 deletions classes/helpers/FrmFieldsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,7 @@ public static function run_wpautop( $atts, &$value ) {
if ( is_array( $value ) ) {
$value = implode( "\n", $value );
}

$value = wpautop( $value );
}
}
Expand Down Expand Up @@ -1125,6 +1126,7 @@ private static function trigger_shortcode_atts( $replace_with, $atts ) {
// Skip any option that uses 0 so sanitize_url=0 does not encode.
continue;
}

$function = 'atts_' . $included_att;
$replace_with = self::$function( $replace_with, $atts );
}
Expand Down Expand Up @@ -1850,6 +1852,7 @@ private static function switch_ids_except_strings( $replace, $replace_with, $exc
unset( $replace[ $index ] );
unset( $replace_with[ $index ] );
}

$value = str_replace( $replace, $replace_with, $value );
return $value;
}
Expand Down Expand Up @@ -2378,6 +2381,7 @@ public static function show_add_field_buttons( $args ) {
if ( isset( $upgrading['url'] ) ) {
$install_data = json_encode( $upgrading );
}

$requires = FrmFormsHelper::get_plan_required( $upgrading );
} elseif ( isset( $field_type['require'] ) ) {
$requires = $field_type['require'];
Expand Down
4 changes: 4 additions & 0 deletions classes/helpers/FrmFormsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ public static function form_switcher( $selected = false ) {
if ( $frm_action ) {
$query_args['frm_action'] = $frm_action;
}

$base = add_query_arg( $query_args, admin_url( 'admin.php' ) );
} elseif ( isset( $_GET['post'] ) ) {
$args['form'] = 0;
Expand Down Expand Up @@ -566,6 +567,7 @@ public static function get_custom_submit( $html, $form, $submit, $form_action, $
if ( FrmAppHelper::should_never_allow_unfiltered_html() ) {
$button = FrmAppHelper::kses_submit_button( $button );
}

$button_parts = explode( '[button_action]', $button );

$classes = apply_filters( 'frm_submit_button_class', array(), $form );
Expand Down Expand Up @@ -1677,6 +1679,7 @@ public static function plan_is_allowed( $args ) {
if ( $included || $plan === $license_type ) {
break;
}

$included = $plan === $plan_required;
}

Expand Down Expand Up @@ -1987,6 +1990,7 @@ public static function maybe_add_sanitize_url_attr( $url, $form_id ) {
if ( $options ) {
$new_shortcode .= ' ' . $options;
}

$new_shortcode .= ' sanitize_url=1]';

$query = str_replace( $shortcode, $new_shortcode, $query );
Expand Down
1 change: 1 addition & 0 deletions classes/helpers/FrmFormsListHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ private function get_form_name( $item, $actions, $edit_link, $mode = 'list' ) {
if ( is_null( $form_name ) || trim( $form_name ) === '' ) {
$form_name = FrmFormsHelper::get_no_title_text();
}

$form_name = FrmAppHelper::kses( $form_name );
if ( 'excerpt' != $mode ) {
$form_name = FrmAppHelper::truncate( $form_name, 50 );
Expand Down
3 changes: 3 additions & 0 deletions classes/helpers/FrmListHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,7 @@ protected function row_actions( $actions, $always_visible = false ) {
$sep = $i === $action_count ? '' : ' | ';
$out .= "<span class='$action'>$link$sep</span>";
}

$out .= '</div>';

$out .= '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details', 'formidable' ) . '</span></button>';
Expand Down Expand Up @@ -656,6 +657,7 @@ protected function pagination( $which ) {
strlen( $total_pages )
);
}

$html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );

/* translators: %1$s: Current page number, %2$s: Total pages */
Expand Down Expand Up @@ -683,6 +685,7 @@ protected function pagination( $which ) {
if ( ! empty( $infinite_scroll ) ) {
$pagination_links_class = ' hide-if-js';
}

$output .= "\n" . '<span class="' . esc_attr( $pagination_links_class ) . '">' . implode( "\n", $page_links ) . '</span>';

if ( $total_pages ) {
Expand Down
Loading