* @since 3.0.0 * @since 5.0.0 Rename labels from "Prepend excerpt" to "Include excerpt". */ namespace Beyondwords\Wordpress\Component\Settings\Fields\IncludeExcerpt; /** * IncludeExcerpt * * @since 3.0.0 */ defined('ABSPATH') || exit; class IncludeExcerpt { /** * Default value. * * @var string */ public const DEFAULT_VALUE = false; /** * Option name. * * @var string */ public const OPTION_NAME = 'beyondwords_prepend_excerpt'; /** * Init. * * @since 4.0.0 * @since 6.0.0 Make static. */ public static function init() { add_action('admin_init', [self::class, 'addSetting']); add_filter('option_' . self::OPTION_NAME, 'rest_sanitize_boolean'); } /** * Init setting. * * @since 3.0.0 * @since 5.0.0 Rename field. * @since 6.0.0 Make static. * * @return void */ public static function addSetting() { register_setting( 'beyondwords_content_settings', self::OPTION_NAME, [ 'type' => 'boolean', 'sanitize_callback' => 'rest_sanitize_boolean', 'default' => self::DEFAULT_VALUE, ] ); add_settings_field( 'beyondwords-include-excerpt', __('Excerpt', 'speechkit'), [self::class, 'render'], 'beyondwords_content', 'content' ); } /** * Render setting field. * * @since 3.0.0 * @since 4.0.0 Updated label and description * @since 5.0.0 Updated label and description * @since 6.0.0 Make static. * * @return void **/ public static function render() { $value = get_option(self::OPTION_NAME); ?>