Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Action Bar: Add Action Bar visibility general setting #41015

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: added

Add `Action Bar visibility` general setting
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,32 @@
use Automattic\Jetpack\Status;
use Automattic\Jetpack\Status\Host;

/**
* Add the Action Bar display setting on the General settings page.
* This setting allows users to hide the Action Bar on the front end of their site.
* The setting is stored in the `wpcom_show_action_bar` option.
* The setting is displayed only if the has the wp-admin interface selected.
*/
function wpcomsh_wpcom_show_action_bar_settings_field() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wpcom-admin-interface.php file was intended to contain logic involving the different admin interfaces (Default, Classic), so I'd move this part to somewhere else. Maybe you can add a new features/action-bar/action-bar.php file?

Also, this isn't a wpcomsh function, so I'd remove that prefix.

Suggested change
function wpcomsh_wpcom_show_action_bar_settings_field() {
function wpcom_show_action_bar_settings_field() {

add_settings_field( 'wpcom_show_action_bar', '', 'wpcom_show_action_bar_display', 'general', 'default' );
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized that atomic sites don't show the Action Bar and I'm wondering whether we should check about the type before adding this setting ( at least for now ). 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we should check if the site is Simple before running this.

Alternatively, if there are no plans to bring the action bar to Atomic sites, you could implement this logic directly in the wpcom repo, which only runs on Simple sites.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an issue asking for the action bar in atomic sites: Automattic/wp-calypso#36795

In order to do that, I think we should move the actionbar mu-plugin from wpcom repo to jetpack-wpcom-mu-plugin or something like that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to do that, I think we should move the actionbar mu-plugin from wpcom repo to jetpack-wpcom-mu-plugin or something like that.

Yes. @cbravobernal is something you're working on? My linked issue with yours are kind of co-dependent.

Copy link

@cbravobernal cbravobernal Jan 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not yet, I was checking how to do it while I found this task and decided to wait. Feel free to take it if you feel more comfortable tackling all together.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cbravobernal sounds good. I'll see what's decided about atomic and handle these two issues accordingly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if there are no plans to bring the action bar to Atomic sites, you could implement this logic directly in the wpcom repo, which only runs on Simple sites.

I would also recommend keeping things together in the dotcom codebase for now. It will make it easier to move things around when/if we eventually bring the action bar to WoA sites.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. I'll port these changes to dotcom.


register_setting( 'general', 'wpcom_show_action_bar', array( 'sanitize_callback' => 'esc_attr' ) );
}

/**
* Display the `wpcom_show_action_bar setting` on the General settings page.
*/
function wpcom_show_action_bar_display() {
$value = get_option( 'wpcom_show_action_bar', 1 );

echo '<tr valign="top"><th scope="row">' . esc_html__( 'Action Bar visibility', 'jetpack-mu-wpcom' ) . '</th>';
echo '<td><label for="wpcom_show_action_bar">';
echo '<input type="checkbox" id="wpcom_show_action_bar" name="wpcom_show_action_bar" value="1" ' . checked( $value, 1, false ) . ' />';
echo esc_html__( 'Show the Action Bar on the front end of the site.', 'jetpack-mu-wpcom' ) . '</label>';
echo '<p class="description"><a href="https://en.support.wordpress.com/action-bar/">' . esc_html__( 'Learn more about Action Bar.', 'jetpack-mu-wpcom' ) . '</a></p></td></tr>';
}
add_action( 'admin_init', 'wpcomsh_wpcom_show_action_bar_settings_field' );

/**
* Add the Admin Interface Style setting on the General settings page.
* This setting allows users to switch between the classic WP-Admin interface and the WordPress.com legacy dashboard.
Expand Down
Loading