| 1 |
<?php |
| 2 |
|
| 3 |
namespace Yoast\WP\SEO\Integrations; |
| 4 |
|
| 5 |
use Yoast\WP\SEO\Conditionals\Admin\Estimated_Reading_Time_Conditional; |
| 6 |
|
| 7 |
/** |
| 8 |
* Estimated reading time class. |
| 9 |
*/ |
| 10 |
class Estimated_Reading_Time implements Integration_Interface { |
| 11 |
|
| 12 |
/** |
| 13 |
* Returns the conditionals based in which this loadable should be active. |
| 14 |
* |
| 15 |
* @return array |
| 16 |
*/ |
| 17 |
public static function get_conditionals() { |
| 18 |
return [ Estimated_Reading_Time_Conditional::class ]; |
| 19 |
} |
| 20 |
|
| 21 |
/** |
| 22 |
* Initializes the integration. |
| 23 |
* |
| 24 |
* This is the place to register hooks and filters. |
| 25 |
* |
| 26 |
* @return void |
| 27 |
*/ |
| 28 |
public function register_hooks() { |
| 29 |
\add_filter( 'wpseo_metabox_entries_general', [ $this, 'add_estimated_reading_time_hidden_fields' ] ); |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* Adds an estimated-reading-time hidden field. |
| 34 |
* |
| 35 |
* @param array $field_defs The $fields_defs. |
| 36 |
* |
| 37 |
* @return array |
| 38 |
*/ |
| 39 |
public function add_estimated_reading_time_hidden_fields( $field_defs ) { |
| 40 |
if ( \is_array( $field_defs ) ) { |
| 41 |
$field_defs['estimated-reading-time-minutes'] = [ |
| 42 |
'type' => 'hidden', |
| 43 |
'title' => 'estimated-reading-time-minutes', |
| 44 |
]; |
| 45 |
} |
| 46 |
|
| 47 |
return $field_defs; |
| 48 |
} |
| 49 |
} |
| 50 |
|