| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
/** |
| 6 |
* Setting: Process excerpts |
| 7 |
* |
| 8 |
* @package Beyondwords\Wordpress |
| 9 |
* @author Stuart McAlpine <stu@beyondwords.io> |
| 10 |
* @since 3.0.0 |
| 11 |
*/ |
| 12 |
|
| 13 |
namespace Beyondwords\Wordpress\Component\Settings\PrependExcerpt; |
| 14 |
|
| 15 |
use Beyondwords\Wordpress\Component\Settings\SettingsUtils; |
| 16 |
|
| 17 |
/** |
| 18 |
* PrependExcerpt setup |
| 19 |
* |
| 20 |
* @since 3.0.0 |
| 21 |
*/ |
| 22 |
class PrependExcerpt |
| 23 |
{ |
| 24 |
/** |
| 25 |
* Constructor |
| 26 |
*/ |
| 27 |
public function __construct() |
| 28 |
{ |
| 29 |
add_action('admin_init', array($this, 'init')); |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* Init setting. |
| 34 |
* |
| 35 |
* @since 3.0.0 |
| 36 |
* |
| 37 |
* @return void |
| 38 |
*/ |
| 39 |
public function init() |
| 40 |
{ |
| 41 |
if (! SettingsUtils::hasApiSettings()) { |
| 42 |
return; |
| 43 |
} |
| 44 |
|
| 45 |
register_setting( |
| 46 |
'beyondwords', |
| 47 |
'beyondwords_prepend_excerpt', |
| 48 |
[ |
| 49 |
'default' => '', |
| 50 |
] |
| 51 |
); |
| 52 |
|
| 53 |
add_settings_field( |
| 54 |
'beyondwords-prepend-excerpt', |
| 55 |
__('Process excerpts', 'speechkit'), |
| 56 |
array($this, 'render'), |
| 57 |
'beyondwords', |
| 58 |
'content' |
| 59 |
); |
| 60 |
} |
| 61 |
|
| 62 |
/** |
| 63 |
* Render setting field. |
| 64 |
* |
| 65 |
* @since 3.0.0 |
| 66 |
* @since 4.0.0 Updated label and description |
| 67 |
* |
| 68 |
* @return void |
| 69 |
**/ |
| 70 |
public function render() |
| 71 |
{ |
| 72 |
$prependExcerpt = get_option('beyondwords_prepend_excerpt', ''); |
| 73 |
?> |
| 74 |
<div> |
| 75 |
<label> |
| 76 |
<input |
| 77 |
type="checkbox" |
| 78 |
name="beyondwords_prepend_excerpt" |
| 79 |
value="1" |
| 80 |
<?php checked($prependExcerpt, '1'); ?> |
| 81 |
/> |
| 82 |
<?php _e('Use excerpts for summaries', 'speechkit'); ?> |
| 83 |
</label> |
| 84 |
</div> |
| 85 |
<p class="description"> |
| 86 |
<?php |
| 87 |
_e( |
| 88 |
'Summaries are read aloud in-between titles and body content.', |
| 89 |
'speechkit' |
| 90 |
); |
| 91 |
?> |
| 92 |
</p> |
| 93 |
<?php |
| 94 |
} |
| 95 |
} |
| 96 |
|