__( 'Interface', 'admin-help-docs' ),
'content_output' => __( 'Content & Output', 'admin-help-docs' ),
'access_control' => __( 'Access Control', 'admin-help-docs' ),
'advanced' => __( 'Advanced', 'admin-help-docs' ),
];
return apply_filters( 'helpdocs_settings_boxes', $boxes );
} // End setting_boxes()
/**
* Returns all settings fields.
*/
public static function setting_fields( $defaults_only = false ) : array {
$themes = [];
foreach ( Colors::themes() as $key => $theme ) {
$themes[ $key ] = $theme[ 'label' ];
}
$themes[ 'custom' ] = __( 'Custom (Use the color pickers below to customize)', 'admin-help-docs' );
$top_placements = [];
foreach ( self::top_placements() as $key => $label ) {
$top_placements[] = [
'value' => $key,
'label' => $label,
];
}
$legacy_cap = get_option( 'helpdocs_user_view_cap' );
$current_type = get_option( 'helpdocs_user_view_type' );
$view_default = ( false !== $legacy_cap && false === $current_type ) ? 'capability' : 'role';
$fields = [
// Interface
[
'name' => 'menu_title',
'label' => __( 'Menu Title', 'admin-help-docs' ),
'type' => 'text',
'sanitize' => 'sanitize_text_field',
'box' => 'interface',
'default' => 'Help Docs',
],
[
'name' => 'dashicon',
'label' => __( 'Menu Icon', 'admin-help-docs' ) . ' — View Dashicons ',
'type' => 'select',
'choices' => Helpers::get_dashicons(),
'sanitize' => 'sanitize_text_field',
'box' => 'interface',
'default' => 'editor-help',
],
[
'name' => 'menu_position',
'label' => __( 'Menu Position', 'admin-help-docs' ),
'desc' => __( '1 = Above Dashboard, 2 = Under Dashboard, 999 = Bottom, etc.', 'admin-help-docs' ),
'type' => 'number',
'sanitize' => 'absint',
'box' => 'interface',
'default' => Menu::$default_menu_position,
],
[
'name' => 'page_title',
'label' => __( 'Page Title', 'admin-help-docs' ),
'type' => 'text',
'sanitize' => 'sanitize_text_field',
'box' => 'interface',
'default' => Bootstrap::name(),
],
[
'name' => 'logo',
'label' => __( 'Page Logo', 'admin-help-docs' ),
'desc' => __( 'Preferred size: 100x100 pixels. Accepted formats: jpg | jpeg | png | webp', 'admin-help-docs' ),
'type' => 'text',
'sanitize' => 'sanitize_text_field',
'box' => 'interface',
'default' => Helpers::get_default_logo_url(),
],
[
'name' => 'doc_logo',
'label' => __( 'Help Doc Logo', 'admin-help-docs' ),
'desc' => __( 'You can also change the logo on all of the help docs, which may differ from the page logo if the background is contrasted. For example a light logo on dark background at the top of the page, and a dark logo on a light background on the help docs themselves. You can also disable the help doc logo from the Content & Output settings on the right. The preferred size of the image is 100x100 pixels. Accepted formats: jpg | jpeg | png | webp', 'admin-help-docs' ),
'type' => 'text',
'sanitize' => 'sanitize_text_field',
'box' => 'interface',
'default' => Helpers::get_default_logo_url(),
],
[
'name' => 'themes',
'label' => __( 'Color Theme', 'admin-help-docs' ),
'type' => 'select',
'choices' => $themes,
'sanitize' => 'sanitize_text_field',
'box' => 'interface',
'default' => 'custom',
],
[
'name' => 'contact_form',
'label' => __( 'Enable Support Contact Form', 'admin-help-docs' ),
'desc' => sprintf(
/* translators: %s is the current site admin email address. */
__( 'Adds a simple contact form within the Help Docs menu, allowing clients to reach out for support directly. Emails will be sent from %s. This feature utilizes wp_mail() for delivery. To ensure reliable inbox placement, using a dedicated provider like WP Mail SMTP (with Brevo) is advised, along with WP Mail Logging for tracking sent messages.', 'admin-help-docs' ),
'' . esc_html( get_option( 'admin_email' ) ) . ''
),
'type' => 'checkbox',
'sanitize' => 'sanitize_checkbox',
'box' => 'interface',
'default' => false,
'has_condition' => true,
],
[
'name' => 'contact_name',
'label' => __( 'Support Contact Name', 'admin-help-docs' ),
'desc' => __( 'Enter the name that clients can use to reach you. This will be displayed on the contact form page. Can be a business or personal name.', 'admin-help-docs' ),
'type' => 'text',
'sanitize' => 'sanitize_text_field',
'box' => 'interface',
'default' => '',
'condition' => [ 'contact_form' => true ],
],
[
'name' => 'contact_emails',
'label' => __( 'Support Contact Email(s)', 'admin-help-docs' ),
'desc' => __( 'Enter the email address(es) that will receive messages from the contact form. Separate multiple emails with commas.', 'admin-help-docs' ),
'type' => 'text',
'sanitize' => 'sanitize_text_field',
'box' => 'interface',
'default' => implode( ', ', Helpers::get_all_admin_emails() ),
'condition' => [ 'contact_form' => true ],
],
[
'name' => 'contact_phone',
'label' => __( 'Support Contact Phone Number', 'admin-help-docs' ),
'desc' => __( 'Enter a phone number that clients can use to reach you. This will be displayed on the contact form page.', 'admin-help-docs' ),
'type' => 'text',
'sanitize' => 'sanitize_text_field',
'box' => 'interface',
'default' => '',
'condition' => [ 'contact_form' => true ],
],
[
'name' => 'admin_bar',
'label' => __( 'Enable Admin Bar Menu for Backend', 'admin-help-docs' ),
'type' => 'checkbox',
'sanitize' => 'sanitize_checkbox',
'box' => 'interface',
'default' => false,
],
[
'name' => 'admin_bar_frontend',
'label' => __( 'Enable Admin Bar Menu for Frontend', 'admin-help-docs' ),
'type' => 'checkbox',
'sanitize' => 'sanitize_checkbox',
'box' => 'interface',
'default' => false,
],
[
'name' => 'replace_dashboard',
'label' => __( 'Replace WordPress Dashboard with a Help Doc', 'admin-help-docs' ),
'desc' => __( 'Replace the default WordPress dashboard with a custom help docs page. To add docs, set their locations to "WordPress Dashboard (Replaces Dashboard Entirely)". Warning: Replacing the WordPress dashboard entirely may affect other plugins and functionality. No other widgets or dashboard elements will be displayed.', 'admin-help-docs' ),
'type' => 'checkbox',
'sanitize' => 'sanitize_checkbox',
'box' => 'interface',
'default' => false,
],
[
'name' => 'dashboard_toc',
'label' => __( 'Enable Dashboard Table of Contents Widget', 'admin-help-docs' ),
'desc' => __( 'Adds a dashboard widget with a table of contents for the docs on the Main Documentation Page.', 'admin-help-docs' ),
'type' => 'checkbox',
'sanitize' => 'sanitize_checkbox',
'box' => 'interface',
'default' => false,
],
[
'name' => 'gutenberg_editor',
'label' => __( 'Use Gutenberg Editor', 'admin-help-docs' ),
'desc' => __( 'Adds support for the Gutenberg editor for the documentation. Default is the classic editor.', 'admin-help-docs' ),
'type' => 'checkbox',
'sanitize' => 'sanitize_checkbox',
'box' => 'interface',
'default' => false,
],
// Content & Output
[
'name' => 'admin_bar_include_content',
'label' => __( 'Include Doc Content in Admin Bar', 'admin-help-docs' ),
'desc' => __( 'Includes a snippet of the document content in the admin bar.', 'admin-help-docs' ),
'type' => 'checkbox',
'sanitize' => 'sanitize_checkbox',
'box' => 'content_output',
'default' => false,
],
[
'name' => 'default_doc',
'label' => __( 'Default Document on Main Docs Page', 'admin-help-docs' ),
'type' => 'select',
'choices' => Helpers::get_main_helpdoc_options(),
'sanitize' => 'sanitize_text_field',
'box' => 'content_output',
],
[
'name' => 'hide_doc_meta',
'label' => __( 'Hide Document Meta on Main Docs Page', 'admin-help-docs' ),
'desc' => __( 'Includes created and last modified dates and authors.', 'admin-help-docs' ),
'type' => 'checkbox',
'sanitize' => 'sanitize_checkbox',
'box' => 'content_output',
'default' => false,
],
[
'name' => 'auto_htoc',
'label' => __( 'Auto-Generate Table of Contents on Main Docs Page', 'admin-help-docs' ),
'desc' => __( 'Automatically generate a table of contents from headings (H2–H6) at the top of each documentation page.', 'admin-help-docs' ),
'type' => 'checkbox',
'sanitize' => 'sanitize_checkbox',
'box' => 'content_output',
'default' => false,
],
[
'name' => 'curly_quotes',
'label' => __( 'Disable Curly Quotes on Main Docs Page', 'admin-help-docs' ),
'desc' => __( 'WP automatically converts straight quotes (") to curly quotes (”), which makes sharing code difficult.', 'admin-help-docs' ),
'type' => 'checkbox',
'sanitize' => 'sanitize_checkbox',
'box' => 'content_output',
'default' => false,
],
[
'name' => 'enqueue_frontend_styles',
'label' => __( 'Use Frontend Stylesheets on Main Docs Page', 'admin-help-docs' ),
'desc' => __( 'Adds support for your frontend styles in the backend by enqueueing them while on the Main Docs Page.', 'admin-help-docs' ),
'type' => 'checkbox',
'sanitize' => 'sanitize_checkbox',
'box' => 'content_output',
'default' => false,
],
[
'name' => 'main_docs_css',
'label' => __( 'Main Docs Page CSS', 'admin-help-docs' ),
'desc' => __( 'Add CSS here to style the Main Documentation Page specifically. You must use CSS selectors.', 'admin-help-docs' ),
'type' => 'textarea',
'sanitize' => 'sanitize_custom_css',
'box' => 'content_output',
'default' => '',
],
[
'name' => 'include_logo_on_docs',
'label' => __( 'Include Logo on Help Docs', 'admin-help-docs' ),
'desc' => __( 'Includes the site logo on individual help docs that are not on the Main Docs Page.', 'admin-help-docs' ),
'type' => 'checkbox',
'sanitize' => 'sanitize_checkbox',
'box' => 'content_output',
'default' => true,
],
[
'name' => 'top_location_type',
'label' => __( 'Top Location Placement', 'admin-help-docs' ),
'type' => 'select',
'choices' => $top_placements,
'sanitize' => 'sanitize_key',
'box' => 'content_output',
'default' => 'admin_notices',
],
[
'name' => 'footer_left',
'label' => __( 'Left Footer Text', 'admin-help-docs' ),
'desc' => __( 'Supports HTML. Default: "Thank you for creating with WordPress."', 'admin-help-docs' ),
'type' => 'textarea',
'sanitize' => 'wp_kses_post',
'box' => 'content_output',
'default' => '',
],
[
'name' => 'footer_right',
'label' => __( 'Right Footer Text', 'admin-help-docs' ),
'desc' => __( 'Use {version} to display the current WordPress version', 'admin-help-docs' ),
'type' => 'textarea',
'sanitize' => 'wp_kses_post',
'box' => 'content_output',
'default' => 'Version {version}',
],
// Access & Permissions
[
'name' => 'api',
'label' => __( 'Allow Public by Default', 'admin-help-docs' ),
'type' => 'checkbox',
'sanitize' => 'sanitize_checkbox',
'box' => 'access_control',
'default' => false,
],
[
'name' => 'api_key',
'label' => __( 'Public Access API Key (Optional)', 'admin-help-docs' ),
'desc' => __( 'If you enable "Allow Public" above or on individual docs, you can optionally require an API key for access. This adds a layer of security by ensuring that only users with the key can import your documentation. To use, generate a key here and enter it into the import on your other site where you are importing the docs. Leave empty to allow public access without a key.', 'admin-help-docs' ),
'type' => 'api_key',
'sanitize' => 'sanitize_text_field',
'box' => 'access_control',
'default' => false,
],
[
'name' => 'user_view_type',
'label' => __( 'Requirement Type to View Docs', 'admin-help-docs' ),
'type' => 'select',
'choices' => [
'capability' => __( 'Capability', 'admin-help-docs' ),
'role' => __( 'Role', 'admin-help-docs' ),
],
'sanitize' => 'sanitize_text_field',
'box' => 'access_control',
'default' => $view_default,
'has_condition' => true,
],
[
'name' => 'user_view_cap',
'label' => __( 'Default Capability Required to View Docs', 'admin-help-docs' ) . ' — View a list of capabilities. ',
'desc' => __( 'Use manage_options for admins only. You can also override this setting on a per-document basis.', 'admin-help-docs' ),
'type' => 'text',
'sanitize' => 'sanitize_text_field',
'box' => 'access_control',
'default' => 'manage_options',
'condition' => [ 'user_view_type' => 'capability' ],
],
[
'name' => 'view_roles',
'label' => __( 'Additional Default Roles Required to View Docs', 'admin-help-docs' ),
'desc' => __( 'Admins can view all docs regardless of this setting. You can also override this setting on a per-document basis.', 'admin-help-docs' ),
'type' => 'checkboxes',
'choices' => Helpers::get_role_options(),
'sanitize' => 'sanitize_checkboxes',
'box' => 'access_control',
'condition' => [ 'user_view_type' => 'role' ],
],
[
'name' => 'user_edit_type',
'label' => __( 'Requirement Type to Edit Docs', 'admin-help-docs' ),
'type' => 'select',
'choices' => [
'capability' => __( 'Capability', 'admin-help-docs' ),
'role' => __( 'Role', 'admin-help-docs' ),
],
'sanitize' => 'sanitize_text_field',
'box' => 'access_control',
'default' => 'role',
'has_condition' => true,
],
[
'name' => 'user_edit_cap',
'label' => __( 'Capability Required to Edit Docs', 'admin-help-docs' ) . ' — View a list of capabilities. ',
'desc' => __( 'Use manage_options for admins only.', 'admin-help-docs' ),
'type' => 'text',
'sanitize' => 'sanitize_text_field',
'box' => 'access_control',
'default' => 'manage_options',
'condition' => [ 'user_edit_type' => 'capability' ],
],
[
'name' => 'edit_roles',
'label' => __( 'Additional Roles Required to Edit Docs', 'admin-help-docs' ),
'desc' => __( 'Admins can edit all docs regardless of this setting.', 'admin-help-docs' ),
'type' => 'checkboxes',
'choices' => Helpers::get_role_options(),
'sanitize' => 'sanitize_checkboxes',
'box' => 'access_control',
'condition' => [ 'user_edit_type' => 'role' ],
],
// Advanced
[
'name' => 'remove_on_uninstall',
'label' => __( 'Remove All Plugin Data on Uninstall', 'admin-help-docs' ),
'desc' => __( 'Deletes all plugin settings and documentation permanently when the plugin is deleted.', 'admin-help-docs' ),
'type' => 'checkbox',
'sanitize' => 'sanitize_checkbox',
'box' => 'advanced',
'default' => false,
],
[
'name' => 'flush_cache',
'label' => __( 'System Cache Management', 'admin-help-docs' ),
'type' => 'html',
'box' => 'advanced',
'content' => '',
],
[
'name' => 'upload_download_colors',
'label' => __( 'Upload/Download Colors', 'admin-help-docs' ),
'desc' => __( 'Export your current color settings as a JSON file for backup or transfer to another site. You can also import color settings from a JSON file exported from this plugin. Note: Importing settings will overwrite your current color settings.', 'admin-help-docs' ),
'type' => 'html',
'box' => 'advanced',
'content' => '