diff --git a/includes/admin/class-pr-core-settings.php b/includes/admin/class-pr-core-settings.php new file mode 100644 index 0000000..23a1e91 --- /dev/null +++ b/includes/admin/class-pr-core-settings.php @@ -0,0 +1,176 @@ + 'boolean', + 'default' => true, + 'sanitize_callback' => 'rest_sanitize_boolean', + ] + ); + + register_setting( + 'pr_core_settings', + self::LIMIT_OPTION, + [ + 'type' => 'integer', + 'default' => 3, + 'sanitize_callback' => [ $this, 'sanitize_limit' ], + ] + ); + + add_settings_section( + 'pr_core_related_articles', + __( 'Related Articles', 'peptide-repo-core' ), + [ $this, 'render_section' ], + 'pr_core_settings' + ); + + add_settings_field( + self::ENABLED_OPTION, + __( 'Enable Related Articles', 'peptide-repo-core' ), + [ $this, 'render_enabled_field' ], + 'pr_core_settings', + 'pr_core_related_articles' + ); + + add_settings_field( + self::LIMIT_OPTION, + __( 'Number of Articles to Display', 'peptide-repo-core' ), + [ $this, 'render_limit_field' ], + 'pr_core_settings', + 'pr_core_related_articles' + ); + } + + /** + * Render the settings page. + * + * @return void + */ + public function render_page(): void { + ?> +
+

+
+ +
+
+ ' . esc_html__( 'Configure the Related Articles section that appears on peptide single pages.', 'peptide-repo-core' ) . '

'; + } + + /** + * Render enabled toggle field. + * + * @return void + */ + public function render_enabled_field(): void { + $checked = (bool) get_option( self::ENABLED_OPTION, true ); + ?> + + /> + + + +

+ +

+