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

Register settings to correct sub section #6

Merged
merged 1 commit into from
Nov 7, 2024
Merged
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
12 changes: 7 additions & 5 deletions getdave-responsive-navigation-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ function enqueue_block_assets() {
wp_add_inline_style( GDRNB_PLUGIN_SLUG . '-style', $css );
}


function add_settings_page() {
add_options_page(
__( 'Responsive Navigation Block Settings', 'getdave-responsive-navigation-block' ), // Page title
Expand All @@ -151,7 +152,7 @@ function settings_page_callback() {
<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
<form action="options.php" method="post">
<?php
settings_fields( 'reading' );
settings_fields( GDRNB_PLUGIN_SLUG . '_responsive_nav' ); // Use your custom settings group
do_settings_sections( GDRNB_PLUGIN_SLUG . '_responsive_nav' );
submit_button( __( 'Save Settings', 'getdave-responsive-navigation-block' ) );
?>
Expand All @@ -162,22 +163,22 @@ function settings_page_callback() {

function register_settings() {
register_setting(
'reading',
GDRNB_PLUGIN_SLUG . '_responsive_nav', // Custom settings group
GDRNB_PLUGIN_SLUG . '_responsive_nav_breakpoint',
array(
'type' => 'integer',
'description' => __( 'The breakpoint at which the navigation will switch to mobile view', 'getdave-responsive-navigation-block' ),
'description' => __( 'The breakpoint value at which the navigation will switch.', 'getdave-responsive-navigation-block' ),
'sanitize_callback' => 'absint',
'default' => GDRNB_DEFAULT_BREAKPOINT,
)
);

register_setting(
'reading',
GDRNB_PLUGIN_SLUG . '_responsive_nav', // Custom settings group
GDRNB_PLUGIN_SLUG . '_responsive_nav_unit',
array(
'type' => 'string',
'description' => __( 'The unit of the navigation breakpoint', 'getdave-responsive-navigation-block' ),
'description' => __( 'The unit used for the breakpoint.', 'getdave-responsive-navigation-block' ),
'sanitize_callback' => 'sanitize_text_field',
'default' => GDRNB_DEFAULT_UNIT,
)
Expand Down Expand Up @@ -207,6 +208,7 @@ function register_settings() {
);
}


function settings_section_callback() {
echo '<p>' . esc_html__( 'Set the breakpoint and unit at which the special Navigation block variations "Desktop Navigation" and "Mobile Navigation" will switch.', 'getdave-responsive-navigation-block' ) . '</p>';
echo '<p>' . esc_html__( '⚠️ Please note: setting this value will have no effect on the standard Navigation block.', 'getdave-responsive-navigation-block' ) . '</p>';
Expand Down
Loading