#57596 closed enhancement (fixed)
Categories/Tags: Quick Edit contents should only be rendered if quick edit is in actions after filtering.
Reported by: | costdev | Owned by: | SergeyBiryukov |
---|---|---|---|
Milestone: | 6.4 | Priority: | normal |
Severity: | normal | Version: | 3.0.4 |
Component: | Quick/Bulk Edit | Keywords: | has-testing-info |
Focuses: | Cc: |
Description (last modified by )
This is a follow-up to #16502.
Overview
Despite Quick Edit being removed from the available actions, a class="inline_<id>"
div is still rendered on the Posts > Categories
and Posts > Tags
screens.
To prevent the div from rendering, this code (Ref 1) must be rendered only if the $actions
array includes the inline hide-if-no-js
key.
The Problem
The $actions
array is currently created in the ::handle_row_actions()
method of WP_Terms_List_Table
. This method returns an HTML string, not an array.
Possible Solution 1
We could check the return value of ::handle_row_actions()
to see if it includes a substring, such as editinline
, using str_contains()
. However, this isn't a particularly clean solution, and is easily prone to regressions.
Possible Solution 2
We could abstract this entire portion (Ref 2) of the ::handle_row_actions()
method to a new method that returns array $actions
.
This new method would be called in ::handle_row_actions()
to retain existing functionality, as well as in ::column_name
:
$actions = $this->get_row_actions();
if ( isset( $actions['inline hide-if-no-js'] ) ) {
// The code from (Ref 1)
}
I'm adding 2nd-opinion
to gather thoughts on these possible solutions, and to explore other solutions you may have.
Reproduction/Testing Instructions
Steps to Reproduce or Test
- Create a new file
wp-content/plugins/test-quick-edit-removal.php
with the following contents:<?php /** * Plugin Name: Test Quick Edit Removal * Description: Tests the removal of Quick Edit Contents. * Author: WordPress Core Contributors * Author URI: https://make.wordpress.org/core * License: GPLv2 or later * Version: 1.0.0 */ add_action( 'admin_bar_menu', 'test_qer_adminbar', 999 ); add_filter( 'tag_row_actions', 'test_qer_hide_quick_edit', 10, 1 ); function test_qer_adminbar( $wp_admin_bar ) { global $pagenow; $action = empty( $_GET['hide_quick_edit'] ) ? '1' : '0'; $url = add_query_arg( array_merge( $_GET, array( 'hide_quick_edit' => $action ) ), admin_url( $pagenow ) ); $wp_admin_bar->add_node( array( 'id' => 'test-qer', 'title' => $action ? 'Remove Quick Edit' : 'Add Quick Edit', 'href' => $url ) ); } function test_qer_hide_quick_edit( $actions ) { if ( isset( $_GET['hide_quick_edit'] ) && '1' === $_GET['hide_quick_edit'] ) unset( $actions['inline hide-if-no-js'] ); return $actions; }
- Navigate to
Plugins > Installed Plugins
and activate Test Quick Edit Removal. - Navigate to
Posts > Categories
. - Open DevTools and inspect a category's title.
- Below the category's title
<strong>
markup, there will be<div class="hidden" id="inline_XXXX">
element. - In the admin bar, click "Remove Quick Edit".
- 🐞 Repeat steps 4-5.
- Click "Add Quick Edit".
- Apply a patch.
- ✅ Repeat steps 3-7.
- Repeat steps 3-10 for
Posts > Tags
.
Expected Results
When reproducing a bug:
- ❌ The hidden "inline_XXXX" element should exist even though "Quick Edit" is removed.
When testing a patch to validate it works as expected:
- ✅ The element should no longer exist when "Quick Edit" is removed.
Change History (6)
This ticket was mentioned in Slack in #core by abhanonstopnews. View the logs.
2 years ago
#4
@
18 months ago
Note: An alternative approach with a new filter is suggested in comment:54:ticket:16502.
This ticket needs testing and alternative solutions/ views on solution proposed. Thanks to @costdev for separating this from the original ticket, and adding a solution and testing information.