Commit 150f49f8 authored by Mike Little's avatar Mike Little

Add bebug mode flag.

Output it for JS to use.
parent 98d5aba8
Pipeline #85 canceled with stage
......@@ -89,6 +89,14 @@ class Advent_Calendar_Settings_Page {
'cac_settings_name_section'
);
add_settings_field(
'cac-debug_mode',
__( 'debug mode?', 'codeup-advent-calendar' ),
[ $this, 'render_cac_debug_mode_checkbox_field' ],
'cac_settings_name',
'cac_settings_name_section'
);
add_settings_field(
'cac-create_days_checkbox',
__( 'Create default days?', 'codeup-advent-calendar' ),
......@@ -172,6 +180,19 @@ class Advent_Calendar_Settings_Page {
echo '<p class="description">' . __( 'Checking the second box will DELETE any existing days', 'codeup-advent-calendar' ) . '</p>';
}
/**
* Render the debug mode check box.
*/
function render_cac_debug_mode_checkbox_field() {
// Get current value.
$options = get_option( 'cac_settings_name' );
$current_value = isset( $options['cac-debug_mode'] ) ? $options['cac-debug_mode'] : '';
echo '<input type="checkbox" name="cac_settings_name[cac-debug_mode]" class="cac-debug_mode_checkbox_field" value="1" ' . checked($current_value, true, false ) . '" > ' .
__( 'debug on', 'codeup-advent-calendar' ) . '<br>';
echo '<p class="description">' . __( 'Checking this will allow you to click all days on the calendar', 'codeup-advent-calendar' ) . '</p>';
}
/**
* Validate input and convert to comma separated list.
*
......
......@@ -27,6 +27,7 @@ wp_enqueue_style(
/* get our calendar options */
$options = get_option( 'cac_settings_name' );
$page_title = isset( $options['cac-calendar_title'] ) ? $options['cac-calendar_title'] : '';
$cac_debug_mode = isset( $options['cac-debug_mode'] ) ? $options['cac-debug_mode'] : '';
$image_id = isset( $options['cac-calendar_background_id'] ) ? intval( $options['cac-calendar_background_id'] ) : 0;
$background_image = wp_get_attachment_image_src( $image_id, 'full' );
......@@ -60,7 +61,7 @@ wp_enqueue_script(
wp_localize_script( 'advent-calendar', 'advent_calendar_data',
[
'foo' => 'bar',
'debug_mode' => $cac_debug_mode ?? '0',
]
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment