From ca6f9a1474c015289f9deda0a42676d3b5dea514 Mon Sep 17 00:00:00 2001 From: ntsekouras Date: Tue, 14 Jan 2025 08:06:41 +0200 Subject: [PATCH] Action Bar: Add `Action Bar visibility` general setting --- .../add-action-bar-visibility-general-setting | 4 +++ .../wpcom-admin-interface.php | 26 +++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 projects/packages/jetpack-mu-wpcom/changelog/add-action-bar-visibility-general-setting diff --git a/projects/packages/jetpack-mu-wpcom/changelog/add-action-bar-visibility-general-setting b/projects/packages/jetpack-mu-wpcom/changelog/add-action-bar-visibility-general-setting new file mode 100644 index 0000000000000..3ac3387965b4a --- /dev/null +++ b/projects/packages/jetpack-mu-wpcom/changelog/add-action-bar-visibility-general-setting @@ -0,0 +1,4 @@ +Significance: patch +Type: added + +Add `Action Bar visibility` general setting diff --git a/projects/packages/jetpack-mu-wpcom/src/features/wpcom-admin-interface/wpcom-admin-interface.php b/projects/packages/jetpack-mu-wpcom/src/features/wpcom-admin-interface/wpcom-admin-interface.php index e3d2d404765a2..c877e1b6d7e68 100644 --- a/projects/packages/jetpack-mu-wpcom/src/features/wpcom-admin-interface/wpcom-admin-interface.php +++ b/projects/packages/jetpack-mu-wpcom/src/features/wpcom-admin-interface/wpcom-admin-interface.php @@ -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() { + add_settings_field( 'wpcom_show_action_bar', '', 'wpcom_show_action_bar_display', 'general', 'default' ); + + 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 '' . esc_html__( 'Action Bar visibility', 'jetpack-mu-wpcom' ) . ''; + echo ''; + echo '

' . esc_html__( 'Learn more about Action Bar.', 'jetpack-mu-wpcom' ) . '

'; +} +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.