*/ public static function get_default_settings() { $defaults = array( 'automatic_processing' => false, 'enabled_post_types' => array( 'post', 'page' ), 'enable_diagrams' => true, 'diagram_mode' => 'compact', 'default_diagram_width' => 20, 'default_song_scale' => 1, 'chord_prompt_font_size' => 14, 'block_spacing' => 12, 'section_break_spacing' => 24, 'show_controls' => true, 'enable_print_button' => true, 'print_show_diagrams' => true, 'default_tuning' => 'gCEA', 'enharmonic_preference' => 'auto', 'print_footer_notice' => '', 'remove_on_uninstall' => false, ); return apply_filters( 'da_plectrum_default_settings', $defaults ); } /** * Register plugin settings. * * @return void */ public function register_settings() { register_setting( 'da_plectrum_settings_group', DA_PLECTRUM_OPTION_KEY, array( 'type' => 'array', 'sanitize_callback' => array( $this, 'sanitize_settings' ), 'default' => self::get_default_settings(), ) ); add_settings_section( 'da_plectrum_general', __( 'General', 'plectrum' ), '__return_empty_string', 'da-plectrum-settings' ); add_settings_field( 'automatic_processing', __( 'Enable automatic processing', 'plectrum' ), array( $this, 'render_checkbox_field' ), 'da-plectrum-settings', 'da_plectrum_general', array( 'key' => 'automatic_processing', 'description' => __( 'Automatically process chord-marked content on selected post types.', 'plectrum' ), ) ); add_settings_field( 'enabled_post_types', __( 'Enabled post types', 'plectrum' ), array( $this, 'render_post_types_field' ), 'da-plectrum-settings', 'da_plectrum_general', array( 'key' => 'enabled_post_types', 'description' => __( 'Choose which public post types should be processed automatically when enabled.', 'plectrum' ), ) ); add_settings_field( 'show_controls', __( 'Show controls by default', 'plectrum' ), array( $this, 'render_checkbox_field' ), 'da-plectrum-settings', 'da_plectrum_general', array( 'key' => 'show_controls', 'description' => __( 'Display transpose, size, and print controls when available.', 'plectrum' ), ) ); add_settings_field( 'enable_diagrams', __( 'Enable diagrams', 'plectrum' ), array( $this, 'render_checkbox_field' ), 'da-plectrum-settings', 'da_plectrum_general', array( 'key' => 'enable_diagrams', 'description' => __( 'Allow chord diagrams to be shown in rendered songs.', 'plectrum' ), ) ); add_settings_field( 'diagram_mode', __( 'Default diagram mode', 'plectrum' ), array( $this, 'render_select_field' ), 'da-plectrum-settings', 'da_plectrum_general', array( 'key' => 'diagram_mode', 'options' => array( 'compact' => __( 'Chord names with compact diagrams', 'plectrum' ), 'names' => __( 'Chord names only', 'plectrum' ), ), 'description' => __( 'Choose the initial display mode for chord diagrams.', 'plectrum' ), ) ); add_settings_field( 'default_diagram_width', __( 'Default diagram width', 'plectrum' ), array( $this, 'render_number_field' ), 'da-plectrum-settings', 'da_plectrum_general', array( 'key' => 'default_diagram_width', 'min' => 12, 'max' => 80, 'step' => 1, 'suffix' => __( 'px', 'plectrum' ), 'description' => __( 'Sets the default chord diagram width in pixels before any visitor adjustments.', 'plectrum' ), ) ); add_settings_field( 'default_song_scale', __( 'Default chord/lyric size', 'plectrum' ), array( $this, 'render_number_field' ), 'da-plectrum-settings', 'da_plectrum_general', array( 'key' => 'default_song_scale', 'min' => 0.75, 'max' => 1.75, 'step' => 0.05, 'description' => __( 'Sets the starting display scale for rendered chord sheets. Use 1 for the standard size.', 'plectrum' ), ) ); add_settings_field( 'chord_prompt_font_size', __( 'Chord prompt font size', 'plectrum' ), array( $this, 'render_number_field' ), 'da-plectrum-settings', 'da_plectrum_general', array( 'key' => 'chord_prompt_font_size', 'min' => 8, 'max' => 48, 'step' => 1, 'suffix' => __( 'px', 'plectrum' ), 'description' => __( 'Sets the font size for chord prompts such as G7, Am, F, and D7.', 'plectrum' ), ) ); add_settings_field( 'block_spacing', __( 'Content block spacing', 'plectrum' ), array( $this, 'render_number_field' ), 'da-plectrum-settings', 'da_plectrum_general', array( 'key' => 'block_spacing', 'min' => 0, 'max' => 80, 'step' => 1, 'suffix' => __( 'px', 'plectrum' ), 'description' => __( 'Sets the default top margin between adjacent content blocks.', 'plectrum' ), ) ); add_settings_field( 'section_break_spacing', __( 'Section break spacing', 'plectrum' ), array( $this, 'render_number_field' ), 'da-plectrum-settings', 'da_plectrum_general', array( 'key' => 'section_break_spacing', 'min' => 0, 'max' => 120, 'step' => 1, 'suffix' => __( 'px', 'plectrum' ), 'description' => __( 'Sets the larger top margin used after blank lines in the source content.', 'plectrum' ), ) ); add_settings_field( 'enharmonic_preference', __( 'Enharmonic preference', 'plectrum' ), array( $this, 'render_select_field' ), 'da-plectrum-settings', 'da_plectrum_general', array( 'key' => 'enharmonic_preference', 'options' => array( 'auto' => __( 'Automatic', 'plectrum' ), 'preserve-source' => __( 'Preserve source spelling', 'plectrum' ), 'sharps' => __( 'Prefer sharps', 'plectrum' ), 'flats' => __( 'Prefer flats', 'plectrum' ), ), 'description' => __( 'Choose how transposed chord names should prefer sharp or flat spellings.', 'plectrum' ), ) ); add_settings_field( 'enable_print_button', __( 'Enable print button', 'plectrum' ), array( $this, 'render_checkbox_field' ), 'da-plectrum-settings', 'da_plectrum_general', array( 'key' => 'enable_print_button', 'description' => __( 'Show a print button in the song controls.', 'plectrum' ), ) ); add_settings_field( 'print_show_diagrams', __( 'Show diagrams in print', 'plectrum' ), array( $this, 'render_checkbox_field' ), 'da-plectrum-settings', 'da_plectrum_general', array( 'key' => 'print_show_diagrams', 'description' => __( 'Include chord diagrams when printing song content.', 'plectrum' ), ) ); add_settings_field( 'print_footer_notice', __( 'Print footer notice', 'plectrum' ), array( $this, 'render_textarea_field' ), 'da-plectrum-settings', 'da_plectrum_general', array( 'key' => 'print_footer_notice', 'description' => __( 'Optional notice appended to printed output. Supports {year}, {site_name}, {post_title}, and {author}.', 'plectrum' ), ) ); add_settings_field( 'remove_on_uninstall', __( 'Remove settings on uninstall', 'plectrum' ), array( $this, 'render_checkbox_field' ), 'da-plectrum-settings', 'da_plectrum_general', array( 'key' => 'remove_on_uninstall', 'description' => __( 'Delete plugin settings when the plugin is uninstalled.', 'plectrum' ), ) ); } /** * Register settings page. * * @return void */ public function register_settings_page() { $this->page_hook = add_menu_page( __( 'Plectrum', 'plectrum' ), __( 'Plectrum', 'plectrum' ), 'manage_options', 'da-plectrum', array( $this, 'render_settings_page' ), 'dashicons-format-audio', 58 ); } /** * Render settings page. * * @return void */ public function render_settings_page() { if ( ! current_user_can( 'manage_options' ) ) { return; } $markup_example = implode( "\n", array( '[ukulele_chords]', 'A[Dm]las my love, you [C]do me wrong', 'To [Dm]cast me off dis[A]courteously;', 'And [Dm]I have loved you [C]oh so long,', 'De[Dm]lighting in [A7]your compa[D]ny,', '[/ukulele_chords]', ) ); ?>