Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1644735
Add: QoL #2
shervElmi Jan 12, 2025
6c5d269
Complete QoL #3
shervElmi Jan 14, 2025
bbfcf88
Merge remote-tracking branch 'origin/master' into qol-release
shervElmi Jan 15, 2025
36b4bdb
Complete QoL #4
shervElmi Jan 15, 2025
fd271f9
Refactor: Add `$display_smart_values_icon`
shervElmi Jan 15, 2025
7a6e38b
Complete QoL #7
shervElmi Jan 16, 2025
2f2f6ab
Complete QoL # 8
shervElmi Jan 17, 2025
457e53d
Fix search button hover style
shervElmi Jan 17, 2025
c69615d
Merge branch 'master' into qol-release
shervElmi Jan 17, 2025
ad76f97
Complete QoL #10
shervElmi Jan 17, 2025
fc2ff49
Init: QoL #1
shervElmi Jan 21, 2025
5c9727f
Complete QoL #1
shervElmi Jan 22, 2025
6d1db55
Merge remote-tracking branch 'origin/master' into qol-release
shervElmi Feb 3, 2025
8126f76
Consolidate hooks into handle_current_screen
shervElmi Feb 7, 2025
9d0bad2
Refactor to early return for reduced indentation
shervElmi Feb 7, 2025
e914ed0
Remove unnecessary visibility checks
shervElmi Feb 7, 2025
406f4af
Add column_views
shervElmi Feb 10, 2025
109f03f
Merge branch 'master' into qol-release
shervElmi Feb 17, 2025
e85e954
Refactor remember_custom_sort
shervElmi Feb 17, 2025
7e9de8b
Load saved sorting preferences for the forms list
shervElmi Feb 17, 2025
5ab72b0
Add apply_saved_sort_preference method
shervElmi Feb 17, 2025
50c6a0f
Apply saved sort preferences to Forms and History lists
shervElmi Feb 17, 2025
03129e2
Add PHPDoc for `frm_field_options_after_description` action
shervElmi Feb 19, 2025
be4b9b3
Refactor: Use FrmAppHelper::array_to_html_params for confirm bulk del…
shervElmi Feb 19, 2025
508794a
Revert filter_admin_notices visibility
shervElmi Feb 19, 2025
b3e0ce8
Add is_admin_list_page
shervElmi Feb 19, 2025
62667c1
Execute remember_custom_sort only on admin list pages
shervElmi Feb 19, 2025
d05e62f
Fix the issue where the sorted column icon was not active
shervElmi Feb 19, 2025
353a814
Merge remote-tracking branch 'origin/HEAD' into qol-release
shervElmi Feb 26, 2025
1e6af9a
Revert default-value-setting.php changes
shervElmi Feb 26, 2025
1a5ca03
Prevent redundant DB updates on sort refresh
shervElmi Feb 26, 2025
9bb18f5
Adjust utility classes order
shervElmi Mar 3, 2025
3960636
Merge branch 'master' into qol-release
shervElmi Mar 4, 2025
004c3de
Add 'show_nav=1' to 'View Form" url
shervElmi Mar 5, 2025
4c0f9f6
Move $confirm_delete_attributes inside the $verify condition check
shervElmi Mar 5, 2025
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
91 changes: 89 additions & 2 deletions classes/controllers/FrmAppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1329,15 +1329,27 @@ private static function in_our_pages() {
}

/**
* Hide all third-parties admin notices only in our admin pages.
* Handles actions related to the current screen.
*
* @since x.x
*
* @return void
*/
public static function filter_admin_notices() {
public static function handle_current_screen() {
if ( ! self::in_our_pages() ) {
return;
}

self::filter_admin_notices();
self::remember_custom_sort();
}

/**
* Hide all third-parties admin notices only in our admin pages.
*
* @return void
*/
public static function filter_admin_notices() {
$actions = array(
'admin_notices',
'network_admin_notices',
Expand All @@ -1362,6 +1374,81 @@ public static function filter_admin_notices() {
}
}

/**
* Remembers and applies user-specific sorting preferences.
*
* @return void
*/
private static function remember_custom_sort() {
$screen = get_current_screen();
if ( ! $screen ) {
return;
}

if ( ! FrmAppHelper::is_admin_list_page() && ! FrmAppHelper::is_admin_list_page( 'formidable-entries' ) ) {
return;
}

$orderby = FrmAppHelper::get_param( 'orderby' );

if ( ! $orderby ) {
return;
}

$user_id = get_current_user_id();
$meta_key = 'frm_preferred_list_sort_' . $screen->id;
$order = FrmAppHelper::get_param( 'order' );

$new_sort = array(
'orderby' => $orderby,
'order' => $order,
);

$current_sort = get_user_meta( $user_id, $meta_key, true );

if ( $new_sort !== $current_sort ) {
update_user_meta(
$user_id,
$meta_key,
array(
'orderby' => $orderby,
'order' => $order,
)
);
}
}
Comment thread
shervElmi marked this conversation as resolved.

/**
* Retrieve and apply any saved sorting preferences for the current screen.
*
* @since x.x
*
* @param string &$orderby Reference to the current 'orderby' parameter.
* @param string &$order Reference to the current 'order' parameter.
* @return void
*/
public static function apply_saved_sort_preference( &$orderby, &$order ) {
if ( ! function_exists( 'get_current_screen' ) ) {
return;
}

$screen = get_current_screen();
if ( ! $screen ) {
return;
}

$user_id = get_current_user_id();
$preferred_list_sort = get_user_meta( $user_id, 'frm_preferred_list_sort_' . $screen->id, true );

if ( is_array( $preferred_list_sort ) && ! empty( $preferred_list_sort['orderby'] ) ) {
$orderby = $preferred_list_sort['orderby'];

if ( ! empty( $preferred_list_sort['order'] ) ) {
$order = $preferred_list_sort['order'];
}
}
}
Comment thread
shervElmi marked this conversation as resolved.

/**
* Validate that the callback name is ours not from third-party.
*
Expand Down
2 changes: 1 addition & 1 deletion classes/controllers/FrmHooksController.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public static function load_admin_hooks() {
add_filter( 'plugin_action_links_' . FrmAppHelper::plugin_folder() . '/formidable.php', 'FrmAppController::settings_link' );
add_filter( 'admin_footer_text', 'FrmAppController::set_footer_text' );
add_action( 'admin_footer', 'FrmAppController::add_admin_footer_links' );
add_action( 'current_screen', 'FrmAppController::filter_admin_notices' );
add_action( 'current_screen', 'FrmAppController::handle_current_screen' );

// Entries Controller.
add_action( 'admin_menu', 'FrmEntriesController::menu', 12 );
Expand Down
13 changes: 1 addition & 12 deletions classes/controllers/FrmUsageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,7 @@ public static function load_scripts() {
* @return bool
*/
private static function is_forms_list_page() {
if ( ! FrmAppHelper::is_admin_page() ) {
return false;
}

// Check Trash page.
$form_type = FrmAppHelper::simple_get( 'form_type' );
if ( $form_type && 'published' !== $form_type ) {
return false;
}

// Check edit or settings page.
return ! FrmAppHelper::simple_get( 'frm_action' );
return FrmAppHelper::is_admin_list_page();
}

/**
Expand Down
23 changes: 23 additions & 0 deletions classes/helpers/FrmAppHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,29 @@ public static function is_formidable_admin() {
return $is_formidable;
}

/**
* Checks if is a list page.
*
* @since x.x
*
* @param string $page The name of the page to check.
* @return bool
*/
public static function is_admin_list_page( $page = 'formidable' ) {
if ( ! self::is_admin_page( $page ) ) {
return false;
}

// Check Trash page.
$form_type = self::simple_get( 'form_type' );
if ( $form_type && 'published' !== $form_type ) {
return false;
}

// Check edit or settings page.
return ! self::simple_get( 'frm_action' );
}

/**
* Check for certain page in Formidable settings
*
Expand Down
2 changes: 2 additions & 0 deletions classes/helpers/FrmEntriesListHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ protected function get_order_by() {
)
);

FrmAppController::apply_saved_sort_preference( $orderby, $order );

return FrmDb::esc_order( $orderby . ' ' . $order );
}

Expand Down
24 changes: 24 additions & 0 deletions classes/helpers/FrmFormsListHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public function prepare_items() {
'default' => 'ASC',
)
);

FrmAppController::apply_saved_sort_preference( $orderby, $order );

$start = self::get_param(
array(
'param' => 'start',
Expand Down Expand Up @@ -335,6 +338,7 @@ public function single_row( $item, $style = '' ) {
protected function column_shortcode( $form ) {
$val = '<a href="#" class="frm-embed-form" role="button" aria-label="' . esc_attr__( 'Embed Form', 'formidable' ) . '">' . FrmAppHelper::icon_by_class( 'frmfont frm_code_icon', array( 'echo' => false ) ) . '</a>';
$val .= $this->column_style( $form );
$val .= $this->column_views( $form );
$val = apply_filters( 'frm_form_list_actions', $val, array( 'form' => $form ) );
// Remove the space hard coded in Landing pages.
$val = str_replace( '&nbsp;', '', $val );
Expand Down Expand Up @@ -370,6 +374,26 @@ protected function column_style( $form ) {
return '<a href="' . esc_url( $href ) . '" title="' . esc_attr( $style->post_title ) . '">' . FrmAppHelper::icon_by_class( 'frmfont frm_pallet_icon', array( 'echo' => false ) ) . '</a>';
}

/**
* Generate the HTML for the form Views page.
*
* @since x.x
*
* @param stdClass $form Form object.
* @return string
*/
protected function column_views( $form ) {
$attributes = array(
'href' => admin_url( 'admin.php?page=formidable-views&form=' . absint( $form->id ) . '&show_nav=1' ),
'title' => __( 'View Form', 'formidable' ),
'target' => '_blank',
);

return '<a ' . FrmAppHelper::array_to_html_params( $attributes ) . '>
' . FrmAppHelper::icon_by_class( 'frmfont frm_eye_icon', array( 'echo' => false ) ) .
'</a>';
}

/**
* @param array $actions
* @param object $item
Expand Down
16 changes: 15 additions & 1 deletion classes/helpers/FrmListHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,19 @@ protected function bulk_actions( $which = '' ) {
$verify = $this->confirm_bulk_delete();

if ( $verify ) {
echo "<a id='confirm-bulk-delete-" . esc_attr( $which ) . "' class='frm-hidden' href='confirm-bulk-delete' data-loaded-from='" . esc_attr( $this->loaded_from() ) . "' data-frmverify='" . esc_attr( $verify ) . "' data-frmverify-btn='frm-button-red'></a>";
$confirm_delete_attributes = array(
'id' => 'confirm-bulk-delete-' . $which,
'class' => 'frm-hidden',
'tabindex' => '-1',
'aria-hidden' => 'true',
'href' => 'confirm-bulk-delete',
'data-loaded-from' => $this->loaded_from(),
'data-frmverify' => $verify,
'data-frmverify-btn' => 'frm-button-red',
);

// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo '<a ' . FrmAppHelper::array_to_html_params( $confirm_delete_attributes ) . '></a>';
}
}

Expand Down Expand Up @@ -895,6 +907,8 @@ public function print_column_headers( $with_id = true ) {
$current_order = 'asc';
}

FrmAppController::apply_saved_sort_preference( $current_orderby, $current_order );

if ( ! empty( $columns['cb'] ) ) {
static $cb_counter = 1;
$columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All', 'formidable' ) . '</label>';
Expand Down
15 changes: 15 additions & 0 deletions classes/views/frm-fields/back-end/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,21 @@
include FrmAppHelper::plugin_path() . '/classes/views/frm-fields/back-end/field-description.php';
}

/**
* Fires after displaying the field description in a form settings.
*
* @since x.x
*
* @param array $args {
* Array containing the field data.
*
* @type array $field The field settings.
* @type array $display The display settings for the field.
* @type array $values The values associated with the field.
* }
*/
do_action( 'frm_field_options_after_description', compact( 'field', 'display', 'values' ) );
Comment thread
shervElmi marked this conversation as resolved.

// Field Size
if ( $display['size'] && ! in_array( $field['type'], array( 'select', 'data', 'time' ), true ) ) {
$display_max = $display['max'];
Expand Down
40 changes: 33 additions & 7 deletions css/frm_admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -1546,7 +1546,8 @@ body.frm-hidden-overflow {
.wp-core-ui.frm-white-body .button-secondary:hover,
.wp-core-ui.frm-white-body .button-secondary:focus,
.wp-core-ui.frm-white-body .tablenav .button:hover,
.frm_wrap .preview > .button:hover {
.frm_wrap .preview > .button:hover,
.frm-white-body #search-submit:hover {
border-color: var(--grey-300) !important;
color: var(--grey-800);
background: var(--grey-50) !important;
Expand Down Expand Up @@ -1745,14 +1746,14 @@ input.frm_insert_in_template {
margin-bottom: var(--gap-2xs) !important;
}

.frm-mb-xs {
margin-bottom: var(--gap-xs) !important;
}

.frm-mb-sm {
margin-bottom: var(--gap-sm) !important;
}

.frm-mb-xs {
margin-bottom: var(--gap-xs) !important;
}

.frm-mb-md {
margin-bottom: var(--gap-md) !important;
}
Expand All @@ -1777,6 +1778,10 @@ input.frm_insert_in_template {
margin-right: auto;
}

.frm-mr-2xs {
margin-right: var(--gap-2xs) !important;
}

.frm-mx-0 {
margin-left: 0 !important;
margin-right: 0 !important;
Expand Down Expand Up @@ -1847,6 +1852,10 @@ input.frm_insert_in_template {
padding-top: var(--gap-sm) !important;
}

.frm-pt-md {
padding-top: var(--gap-md) !important;
}

.frm-pt-xl {
padding-top: var(--gap-xl) !important;
}
Expand All @@ -1857,6 +1866,12 @@ input.frm_insert_in_template {
.frm-pb-sm {
padding-bottom: var(--gap-sm) !important;
}

.frm-px-sm {
padding-right: var(--gap-sm) !important;
padding-left: var(--gap-sm) !important;
}

.frm-px-md {
padding-right: var(--gap-md) !important;
padding-left: var(--gap-md) !important;
Expand Down Expand Up @@ -1922,6 +1937,10 @@ input.frm_insert_in_template {
width: 100% !important;
}

.frm-w-half {
width: 50% !important;
}

.frm_block, /* deprecated */
.frm-block {
display: block;
Expand Down Expand Up @@ -1954,7 +1973,6 @@ input.frm_insert_in_template {
gap: var(--gap-sm);
}


.frm-flex-col {
display: flex;
flex-direction: column;
Expand Down Expand Up @@ -2059,6 +2077,10 @@ input.frm_insert_in_template {
cursor: pointer;
}

.frm-align-baseline {
vertical-align: baseline !important;
}

/* End Generic Classes, Start Forced Generic Classes */

.frm-fields p > label.frm_hidden,
Expand Down Expand Up @@ -6820,10 +6842,13 @@ tr.frm_options_heading td {
font-size: var(--text-md);
box-sizing: border-box;
border: 1px dashed var(--grey-300);
outline: 2px solid transparent;
}

.frm-over-droppable + .frm_no_fields {
border-style: solid;
border-color: var(--primary-500);
outline-color: var(--primary-500);
}

.frm_no_section_fields {
Expand All @@ -6850,7 +6875,8 @@ tr.frm_options_heading td {
visibility: hidden;
}

.frm-has-fields .frm_no_fields {
.frm-has-fields .frm_no_fields,
#frm_form_editor_container:not(.frm-has-fields) #frm_drag_placeholder {
display: none;
}

Expand Down
Loading