PluginProbe
BeyondWords – AI audio for publishers / 6.3.0
BeyondWords – AI audio for publishers v6.3.0
7.1.0 trunk 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.1.0 4.1.1 4.1.2 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.3.0 4.4.0 4.5.0 4.5.1 4.6.0 4.6.1 4.6.2 4.7.0 All 43 releases
speechkit / src / Component / Settings / Fields / IncludeExcerpt / IncludeExcerpt.php

IncludeExcerpt.php in BeyondWords – AI audio for publishers 6.3.0, at src/Component/Settings/Fields/IncludeExcerpt/IncludeExcerpt.php

111 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 /**
6 * Setting: Include excerpt
7 *
8 * @package Beyondwords\Wordpress
9 * @author Stuart McAlpine <stu@beyondwords.io>
10 * @since 3.0.0
11 * @since 5.0.0 Rename labels from "Prepend excerpt" to "Include excerpt".
12 */
13
14 namespace Beyondwords\Wordpress\Component\Settings\Fields\IncludeExcerpt;
15
16 /**
17 * IncludeExcerpt
18 *
19 * @since 3.0.0
20 */
21 defined('ABSPATH') || exit;
22
23 class IncludeExcerpt
24 {
25 /**
26 * Default value.
27 *
28 * @var string
29 */
30 public const DEFAULT_VALUE = false;
31
32 /**
33 * Option name.
34 *
35 * @var string
36 */
37 public const OPTION_NAME = 'beyondwords_prepend_excerpt';
38
39 /**
40 * Init.
41 *
42 * @since 4.0.0
43 * @since 6.0.0 Make static.
44 */
45 public static function init()
46 {
47 add_action('admin_init', [self::class, 'addSetting']);
48 add_filter('option_' . self::OPTION_NAME, 'rest_sanitize_boolean');
49 }
50
51 /**
52 * Init setting.
53 *
54 * @since 3.0.0
55 * @since 5.0.0 Rename field.
56 * @since 6.0.0 Make static.
57 *
58 * @return void
59 */
60 public static function addSetting()
61 {
62 register_setting(
63 'beyondwords_content_settings',
64 self::OPTION_NAME,
65 [
66 'type' => 'boolean',
67 'sanitize_callback' => 'rest_sanitize_boolean',
68 'default' => self::DEFAULT_VALUE,
69 ]
70 );
71
72 add_settings_field(
73 'beyondwords-include-excerpt',
74 __('Excerpt', 'speechkit'),
75 [self::class, 'render'],
76 'beyondwords_content',
77 'content'
78 );
79 }
80
81 /**
82 * Render setting field.
83 *
84 * @since 3.0.0
85 * @since 4.0.0 Updated label and description
86 * @since 5.0.0 Updated label and description
87 * @since 6.0.0 Make static.
88 *
89 * @return void
90 **/
91 public static function render()
92 {
93 $value = get_option(self::OPTION_NAME);
94 ?>
95 <div>
96 <label>
97 <input type="hidden" name="<?php echo esc_attr(self::OPTION_NAME); ?>" value="" />
98 <input
99 type="checkbox"
100 id="<?php echo esc_attr(self::OPTION_NAME); ?>"
101 name="<?php echo esc_attr(self::OPTION_NAME); ?>"
102 value="1"
103 <?php checked($value); ?>
104 />
105 <?php esc_html_e('Include excerpts in audio', 'speechkit'); ?>
106 </label>
107 </div>
108 <?php
109 }
110 }
111