forked from beezwax/WP-Publish-to-Apple-News
-
Notifications
You must be signed in to change notification settings - Fork 71
/
class-component-text-styles.php
71 lines (64 loc) · 1.52 KB
/
class-component-text-styles.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
/**
* Publish to Apple News: \Apple_Exporter\Builders\Component_Text_Styles class
*
* @package Apple_News
* @subpackage Apple_Exporter\Builders
*/
namespace Apple_Exporter\Builders;
/**
* Exporter and components can register styles. This class manages the styles
* the final JSON will contain.
*
* @since 0.4.0
*/
class Component_Text_Styles extends Builder {
/**
* All styles.
*
* @var array
* @access private
*/
private $styles;
/**
* Constructor.
*
* @param \Apple_Exporter\Exporter_Content $content The content object to load.
* @param \Apple_Exporter\Exporter_Content_Settings $settings The settings object to load.
* @access public
*/
public function __construct( $content, $settings ) {
parent::__construct( $content, $settings );
$this->styles = [];
}
/**
* Register a style into the exporter.
*
* @since 0.4.0
* @param string $name The name of the style to register.
* @param array $spec The spec for the style.
* @access public
*/
public function register_style( $name, $spec ) {
// Only register once, styles have unique names.
if ( array_key_exists( $name, $this->styles ) ) {
return;
}
$this->styles[ $name ] = $spec;
}
/**
* Returns all styles defined so far.
*
* @since 0.4.0
* @return array
* @access protected
*/
protected function build() {
/**
* Modifies available component text styles.
*
* @param array $styles Component text styles.
*/
return apply_filters( 'apple_news_component_text_styles', $this->styles );
}
}