@@ -16,26 +16,26 @@ |
||
16 | 16 | */ |
17 | 17 | abstract class Wordlift_Widget extends WP_Widget { |
18 | 18 | |
19 | - /** |
|
20 | - * @inheritdoc |
|
21 | - */ |
|
22 | - public function __construct( $id_base, $name, array $widget_options = array(), array $control_options = array() ) { |
|
23 | - parent::__construct( $id_base, $name, $widget_options, $control_options ); |
|
19 | + /** |
|
20 | + * @inheritdoc |
|
21 | + */ |
|
22 | + public function __construct( $id_base, $name, array $widget_options = array(), array $control_options = array() ) { |
|
23 | + parent::__construct( $id_base, $name, $widget_options, $control_options ); |
|
24 | 24 | |
25 | - // Initialize the Related Entities Cloud Widget. |
|
26 | - add_action( 'widgets_init', array( $this, 'widget_init' ) ); |
|
25 | + // Initialize the Related Entities Cloud Widget. |
|
26 | + add_action( 'widgets_init', array( $this, 'widget_init' ) ); |
|
27 | 27 | |
28 | - } |
|
28 | + } |
|
29 | 29 | |
30 | - /** |
|
31 | - * Register the related entities cloud widget |
|
32 | - * |
|
33 | - * @since 3.11.0 |
|
34 | - */ |
|
35 | - public function widget_init() { |
|
30 | + /** |
|
31 | + * Register the related entities cloud widget |
|
32 | + * |
|
33 | + * @since 3.11.0 |
|
34 | + */ |
|
35 | + public function widget_init() { |
|
36 | 36 | |
37 | - register_widget( get_class( $this ) ); |
|
37 | + register_widget( get_class( $this ) ); |
|
38 | 38 | |
39 | - } |
|
39 | + } |
|
40 | 40 | |
41 | 41 | } |
@@ -18,63 +18,63 @@ |
||
18 | 18 | */ |
19 | 19 | class Wordlift_Post_Author_Storage extends Wordlift_Post_Property_Storage { |
20 | 20 | |
21 | - /** |
|
22 | - * The {@link Wordlift_Entity_Service} instance. |
|
23 | - * |
|
24 | - * @since 3.15.0 |
|
25 | - * @access private |
|
26 | - * @var \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance. |
|
27 | - */ |
|
28 | - private $entity_service; |
|
21 | + /** |
|
22 | + * The {@link Wordlift_Entity_Service} instance. |
|
23 | + * |
|
24 | + * @since 3.15.0 |
|
25 | + * @access private |
|
26 | + * @var \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance. |
|
27 | + */ |
|
28 | + private $entity_service; |
|
29 | 29 | |
30 | - /** |
|
31 | - * The {@link Wordlift_User_Service} instance. |
|
32 | - * |
|
33 | - * @since 3.15.0 |
|
34 | - * @access private |
|
35 | - * @var \Wordlift_User_Service $user_service The {@link Wordlift_User_Service} instance. |
|
36 | - */ |
|
37 | - private $user_service; |
|
30 | + /** |
|
31 | + * The {@link Wordlift_User_Service} instance. |
|
32 | + * |
|
33 | + * @since 3.15.0 |
|
34 | + * @access private |
|
35 | + * @var \Wordlift_User_Service $user_service The {@link Wordlift_User_Service} instance. |
|
36 | + */ |
|
37 | + private $user_service; |
|
38 | 38 | |
39 | - /** |
|
40 | - * Create a {@link Wordlift_Post_Author_Storage} instance. |
|
41 | - * |
|
42 | - * @since 3.15.0 |
|
43 | - * |
|
44 | - * @param \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance. |
|
45 | - * @param \Wordlift_User_Service $user_service The {@link Wordlift_User_Service} instance. |
|
46 | - */ |
|
47 | - public function __construct( $entity_service, $user_service ) { |
|
48 | - parent::__construct( Wordlift_Post_Property_Storage::AUTHOR ); |
|
39 | + /** |
|
40 | + * Create a {@link Wordlift_Post_Author_Storage} instance. |
|
41 | + * |
|
42 | + * @since 3.15.0 |
|
43 | + * |
|
44 | + * @param \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance. |
|
45 | + * @param \Wordlift_User_Service $user_service The {@link Wordlift_User_Service} instance. |
|
46 | + */ |
|
47 | + public function __construct( $entity_service, $user_service ) { |
|
48 | + parent::__construct( Wordlift_Post_Property_Storage::AUTHOR ); |
|
49 | 49 | |
50 | - $this->entity_service = $entity_service; |
|
51 | - $this->user_service = $user_service; |
|
50 | + $this->entity_service = $entity_service; |
|
51 | + $this->user_service = $user_service; |
|
52 | 52 | |
53 | - } |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * Get the property value. |
|
57 | - * |
|
58 | - * @since 3.15.0 |
|
59 | - * |
|
60 | - * @param int $post_id The {@link WP_Post}'s id. |
|
61 | - * |
|
62 | - * @return array|string|null A single string, or an array of values or null |
|
63 | - * if the property isn't recognized. |
|
64 | - */ |
|
65 | - public function get( $post_id ) { |
|
66 | - $author_id = parent::get( $post_id ); |
|
55 | + /** |
|
56 | + * Get the property value. |
|
57 | + * |
|
58 | + * @since 3.15.0 |
|
59 | + * |
|
60 | + * @param int $post_id The {@link WP_Post}'s id. |
|
61 | + * |
|
62 | + * @return array|string|null A single string, or an array of values or null |
|
63 | + * if the property isn't recognized. |
|
64 | + */ |
|
65 | + public function get( $post_id ) { |
|
66 | + $author_id = parent::get( $post_id ); |
|
67 | 67 | |
68 | - // Get the entity bound to this user. |
|
69 | - $entity_id = $this->user_service->get_entity( $author_id ); |
|
68 | + // Get the entity bound to this user. |
|
69 | + $entity_id = $this->user_service->get_entity( $author_id ); |
|
70 | 70 | |
71 | - // If there's no entity bound return a simple author structure. |
|
72 | - if ( empty( $entity_id ) ) { |
|
73 | - return $this->user_service->get_uri( $author_id ); |
|
74 | - } |
|
71 | + // If there's no entity bound return a simple author structure. |
|
72 | + if ( empty( $entity_id ) ) { |
|
73 | + return $this->user_service->get_uri( $author_id ); |
|
74 | + } |
|
75 | 75 | |
76 | - // Return the entity URI. |
|
77 | - return $this->entity_service->get_uri( $entity_id ); |
|
78 | - } |
|
76 | + // Return the entity URI. |
|
77 | + return $this->entity_service->get_uri( $entity_id ); |
|
78 | + } |
|
79 | 79 | |
80 | 80 | } |
@@ -18,41 +18,41 @@ |
||
18 | 18 | */ |
19 | 19 | class Wordlift_Post_Meta_Storage extends Wordlift_Storage { |
20 | 20 | |
21 | - /** |
|
22 | - * The meta key to load data from. |
|
23 | - * |
|
24 | - * @since 3.15.0 |
|
25 | - * @access private |
|
26 | - * @var string $meta_key The meta key to load data from. |
|
27 | - */ |
|
28 | - private $meta_key; |
|
29 | - |
|
30 | - /** |
|
31 | - * Create a {@link Wordlift_Post_Meta_Storage} instance, by providing the |
|
32 | - * meta key the storage should read from. |
|
33 | - * |
|
34 | - * @since 3.15.0 |
|
35 | - * |
|
36 | - * @param string $meta_key The post meta key. |
|
37 | - */ |
|
38 | - public function __construct( $meta_key ) { |
|
39 | - |
|
40 | - $this->meta_key = $meta_key; |
|
41 | - |
|
42 | - } |
|
43 | - |
|
44 | - /** |
|
45 | - * Get the value for the specified meta key. |
|
46 | - * |
|
47 | - * @since 3.15.0 |
|
48 | - * |
|
49 | - * @param int $post_id The {@link WP_Post}'s id. |
|
50 | - * |
|
51 | - * @return array An array of values (or an empty array if nothing is set). |
|
52 | - */ |
|
53 | - public function get( $post_id ) { |
|
54 | - |
|
55 | - return get_post_meta( $post_id, $this->meta_key ); |
|
56 | - } |
|
21 | + /** |
|
22 | + * The meta key to load data from. |
|
23 | + * |
|
24 | + * @since 3.15.0 |
|
25 | + * @access private |
|
26 | + * @var string $meta_key The meta key to load data from. |
|
27 | + */ |
|
28 | + private $meta_key; |
|
29 | + |
|
30 | + /** |
|
31 | + * Create a {@link Wordlift_Post_Meta_Storage} instance, by providing the |
|
32 | + * meta key the storage should read from. |
|
33 | + * |
|
34 | + * @since 3.15.0 |
|
35 | + * |
|
36 | + * @param string $meta_key The post meta key. |
|
37 | + */ |
|
38 | + public function __construct( $meta_key ) { |
|
39 | + |
|
40 | + $this->meta_key = $meta_key; |
|
41 | + |
|
42 | + } |
|
43 | + |
|
44 | + /** |
|
45 | + * Get the value for the specified meta key. |
|
46 | + * |
|
47 | + * @since 3.15.0 |
|
48 | + * |
|
49 | + * @param int $post_id The {@link WP_Post}'s id. |
|
50 | + * |
|
51 | + * @return array An array of values (or an empty array if nothing is set). |
|
52 | + */ |
|
53 | + public function get( $post_id ) { |
|
54 | + |
|
55 | + return get_post_meta( $post_id, $this->meta_key ); |
|
56 | + } |
|
57 | 57 | |
58 | 58 | } |
@@ -16,35 +16,35 @@ |
||
16 | 16 | */ |
17 | 17 | abstract class Wordlift_Storage { |
18 | 18 | |
19 | - /** |
|
20 | - * Get the values for the property of the {@link WP_Post}. |
|
21 | - * |
|
22 | - * @since 3.15.0 |
|
23 | - * |
|
24 | - * @param int $post_id The {@link WP_Post}'s id. |
|
25 | - * |
|
26 | - * @return array |
|
27 | - */ |
|
28 | - abstract public function get( $post_id ); |
|
19 | + /** |
|
20 | + * Get the values for the property of the {@link WP_Post}. |
|
21 | + * |
|
22 | + * @since 3.15.0 |
|
23 | + * |
|
24 | + * @param int $post_id The {@link WP_Post}'s id. |
|
25 | + * |
|
26 | + * @return array |
|
27 | + */ |
|
28 | + abstract public function get( $post_id ); |
|
29 | 29 | |
30 | - /** |
|
31 | - * Get the first value for a property. |
|
32 | - * |
|
33 | - * @since 3.15.0 |
|
34 | - * |
|
35 | - * @param int $post_id The {@link WP_Post}'s id. |
|
36 | - * |
|
37 | - * @return string The first property value or an empty string. |
|
38 | - */ |
|
39 | - public function get_first( $post_id ) { |
|
30 | + /** |
|
31 | + * Get the first value for a property. |
|
32 | + * |
|
33 | + * @since 3.15.0 |
|
34 | + * |
|
35 | + * @param int $post_id The {@link WP_Post}'s id. |
|
36 | + * |
|
37 | + * @return string The first property value or an empty string. |
|
38 | + */ |
|
39 | + public function get_first( $post_id ) { |
|
40 | 40 | |
41 | - $values = $this->get( $post_id ); |
|
41 | + $values = $this->get( $post_id ); |
|
42 | 42 | |
43 | - if ( empty( $values ) ) { |
|
44 | - return ''; |
|
45 | - } |
|
43 | + if ( empty( $values ) ) { |
|
44 | + return ''; |
|
45 | + } |
|
46 | 46 | |
47 | - return $values[0]; |
|
48 | - } |
|
47 | + return $values[0]; |
|
48 | + } |
|
49 | 49 | |
50 | 50 | } |
@@ -21,18 +21,18 @@ |
||
21 | 21 | */ |
22 | 22 | class Wordlift_Deactivator { |
23 | 23 | |
24 | - /** |
|
25 | - * Short Description. (use period) |
|
26 | - * |
|
27 | - * Long Description. |
|
28 | - * |
|
29 | - * @since 1.0.0 |
|
30 | - */ |
|
31 | - public static function deactivate() { |
|
24 | + /** |
|
25 | + * Short Description. (use period) |
|
26 | + * |
|
27 | + * Long Description. |
|
28 | + * |
|
29 | + * @since 1.0.0 |
|
30 | + */ |
|
31 | + public static function deactivate() { |
|
32 | 32 | |
33 | - // Clear caches. |
|
34 | - Wordlift_File_Cache_Service::flush_all(); |
|
33 | + // Clear caches. |
|
34 | + Wordlift_File_Cache_Service::flush_all(); |
|
35 | 35 | |
36 | - } |
|
36 | + } |
|
37 | 37 | |
38 | 38 | } |
@@ -18,15 +18,15 @@ |
||
18 | 18 | */ |
19 | 19 | interface Wordlift_Admin_Element { |
20 | 20 | |
21 | - /** |
|
22 | - * Render the element. |
|
23 | - * |
|
24 | - * @since 3.11.0 |
|
25 | - * |
|
26 | - * @param array $args An array of parameters. |
|
27 | - * |
|
28 | - * @return \Wordlift_Admin_Element The element instance. |
|
29 | - */ |
|
30 | - public function render( $args ); |
|
21 | + /** |
|
22 | + * Render the element. |
|
23 | + * |
|
24 | + * @since 3.11.0 |
|
25 | + * |
|
26 | + * @param array $args An array of parameters. |
|
27 | + * |
|
28 | + * @return \Wordlift_Admin_Element The element instance. |
|
29 | + */ |
|
30 | + public function render( $args ); |
|
31 | 31 | |
32 | 32 | } |
@@ -15,41 +15,41 @@ |
||
15 | 15 | * @subpackage Wordlift/install |
16 | 16 | */ |
17 | 17 | class Wordlift_Install_3_10_0 extends Wordlift_Install { |
18 | - /** |
|
19 | - * @inheritdoc |
|
20 | - */ |
|
21 | - protected static $version = '3.10.0'; |
|
18 | + /** |
|
19 | + * @inheritdoc |
|
20 | + */ |
|
21 | + protected static $version = '3.10.0'; |
|
22 | 22 | |
23 | - /** |
|
24 | - * @inheritdoc |
|
25 | - */ |
|
26 | - public function install() { |
|
23 | + /** |
|
24 | + * @inheritdoc |
|
25 | + */ |
|
26 | + public function install() { |
|
27 | 27 | |
28 | - $term_slugs = array( |
|
29 | - 'thing', |
|
30 | - 'creative-work', |
|
31 | - 'event', |
|
32 | - 'organization', |
|
33 | - 'person', |
|
34 | - 'place', |
|
35 | - 'localbusiness', |
|
36 | - ); |
|
28 | + $term_slugs = array( |
|
29 | + 'thing', |
|
30 | + 'creative-work', |
|
31 | + 'event', |
|
32 | + 'organization', |
|
33 | + 'person', |
|
34 | + 'place', |
|
35 | + 'localbusiness', |
|
36 | + ); |
|
37 | 37 | |
38 | - foreach ( $term_slugs as $slug ) { |
|
38 | + foreach ( $term_slugs as $slug ) { |
|
39 | 39 | |
40 | - $term = get_term_by( 'slug', $slug, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
40 | + $term = get_term_by( 'slug', $slug, Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
41 | 41 | |
42 | - // Set the term's parent to 0. |
|
43 | - if ( $term ) { |
|
44 | - wp_update_term( |
|
45 | - $term->term_id, |
|
46 | - Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, |
|
47 | - array( |
|
48 | - 'parent' => 0, |
|
49 | - ) |
|
50 | - ); |
|
51 | - } |
|
52 | - } |
|
53 | - } |
|
42 | + // Set the term's parent to 0. |
|
43 | + if ( $term ) { |
|
44 | + wp_update_term( |
|
45 | + $term->term_id, |
|
46 | + Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, |
|
47 | + array( |
|
48 | + 'parent' => 0, |
|
49 | + ) |
|
50 | + ); |
|
51 | + } |
|
52 | + } |
|
53 | + } |
|
54 | 54 | |
55 | 55 | } |
@@ -18,210 +18,210 @@ |
||
18 | 18 | */ |
19 | 19 | class Wordlift_Storage_Factory { |
20 | 20 | |
21 | - /** |
|
22 | - * The {@link Wordlift_Entity_Service} instance. |
|
23 | - * |
|
24 | - * @since 3.15.0 |
|
25 | - * @access private |
|
26 | - * @var \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance. |
|
27 | - */ |
|
28 | - private $entity_service; |
|
29 | - |
|
30 | - /** |
|
31 | - * The {@link Wordlift_User_Service} instance. |
|
32 | - * |
|
33 | - * @since 3.15.0 |
|
34 | - * @access private |
|
35 | - * @var \Wordlift_User_Service $user_service The {@link Wordlift_User_Service} instance. |
|
36 | - */ |
|
37 | - private $user_service; |
|
38 | - |
|
39 | - /** |
|
40 | - * The {@link Wordlift_Property_Getter} instance. |
|
41 | - * |
|
42 | - * @since 3.15.0 |
|
43 | - * @access private |
|
44 | - * @var \Wordlift_Property_Getter The {@link Wordlift_Property_Getter} instance. |
|
45 | - */ |
|
46 | - private $property_getter; |
|
47 | - |
|
48 | - /** |
|
49 | - * The singleton instance. |
|
50 | - * |
|
51 | - * @since 3.15.0 |
|
52 | - * @access private |
|
53 | - * @var \Wordlift_Storage_Factory $instance The singleton instance. |
|
54 | - */ |
|
55 | - private static $instance; |
|
56 | - |
|
57 | - /** |
|
58 | - * Create a {@link Wordlift_Storage_Factory} instance. |
|
59 | - * |
|
60 | - * @since 3.15.0 |
|
61 | - * |
|
62 | - * @param \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance. |
|
63 | - * @param \Wordlift_User_Service $user_service The {@link Wordlift_User_Service} instance. |
|
64 | - * @param \Wordlift_Property_Getter $property_getter The {@link Wordlift_Property_Getter} instance. |
|
65 | - */ |
|
66 | - public function __construct( $entity_service, $user_service, $property_getter ) { |
|
67 | - |
|
68 | - $this->entity_service = $entity_service; |
|
69 | - $this->user_service = $user_service; |
|
70 | - $this->property_getter = $property_getter; |
|
71 | - |
|
72 | - self::$instance = $this; |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * Get the singleton instance. |
|
77 | - * |
|
78 | - * @since 3.15.0 |
|
79 | - * |
|
80 | - * @return \Wordlift_Storage_Factory The singleton instance. |
|
81 | - */ |
|
82 | - public static function get_instance() { |
|
83 | - |
|
84 | - return self::$instance; |
|
85 | - } |
|
86 | - |
|
87 | - /** |
|
88 | - * Get a {@link Wordlift_Post_Property_Storage} to read {@link WP_Post}s' |
|
89 | - * titles. |
|
90 | - * |
|
91 | - * @since 3.15.0 |
|
92 | - * |
|
93 | - * @return \Wordlift_Post_Property_Storage A {@link Wordlift_Post_Property_Storage} |
|
94 | - * instance. |
|
95 | - */ |
|
96 | - public function post_title() { |
|
97 | - |
|
98 | - return new Wordlift_Post_Property_Storage( Wordlift_Post_Property_Storage::TITLE ); |
|
99 | - } |
|
100 | - |
|
101 | - /** |
|
102 | - * Get a {@link Wordlift_Post_Property_Storage} to read {@link WP_Post}s' |
|
103 | - * descriptions stripped of tags and shortcodes. |
|
104 | - * |
|
105 | - * @since 3.15.0 |
|
106 | - * |
|
107 | - * @return \Wordlift_Post_Property_Storage A {@link Wordlift_Post_Property_Storage} |
|
108 | - * instance. |
|
109 | - */ |
|
110 | - public function post_description_no_tags_no_shortcodes() { |
|
111 | - |
|
112 | - return new Wordlift_Post_Property_Storage( Wordlift_Post_Property_Storage::DESCRIPTION_NO_TAGS_NO_SHORTCODES ); |
|
113 | - } |
|
114 | - |
|
115 | - /** |
|
116 | - * Get a {@link Wordlift_Post_Property_Storage} to read {@link WP_Post}s' |
|
117 | - * authors. |
|
118 | - * |
|
119 | - * @since 3.15.0 |
|
120 | - * |
|
121 | - * @return \Wordlift_Post_Property_Storage A {@link Wordlift_Post_Property_Storage} |
|
122 | - * instance. |
|
123 | - */ |
|
124 | - public function post_author() { |
|
125 | - |
|
126 | - return new Wordlift_Post_Property_Storage( Wordlift_Post_Property_Storage::AUTHOR ); |
|
127 | - } |
|
128 | - |
|
129 | - /** |
|
130 | - * Get a {@link Wordlift_Post_Property_Storage} to read {@link WP_Post}s' |
|
131 | - * metas. |
|
132 | - * |
|
133 | - * @since 3.15.0 |
|
134 | - * |
|
135 | - * @param string $meta_key The meta key to read. |
|
136 | - * |
|
137 | - * @return Wordlift_Post_Meta_Storage A {@link Wordlift_Post_Meta_Storage} |
|
138 | - * instance. |
|
139 | - */ |
|
140 | - public function post_meta( $meta_key ) { |
|
141 | - |
|
142 | - return new Wordlift_Post_Meta_Storage( $meta_key ); |
|
143 | - } |
|
144 | - |
|
145 | - /** |
|
146 | - * Get a {@link Wordlift_Post_Schema_Class_Storage} to read {@link WP_Post}s' |
|
147 | - * entity type class. |
|
148 | - * |
|
149 | - * @since 3.15.0 |
|
150 | - * |
|
151 | - * @return Wordlift_Post_Schema_Class_Storage A {@link Wordlift_Post_Schema_Class_Storage} |
|
152 | - * instance. |
|
153 | - */ |
|
154 | - public function schema_class() { |
|
155 | - |
|
156 | - return new Wordlift_Post_Schema_Class_Storage(); |
|
157 | - } |
|
158 | - |
|
159 | - /** |
|
160 | - * Get a {@link Wordlift_Post_Author_Storage} instance able to turn an author |
|
161 | - * id into a URI. |
|
162 | - * |
|
163 | - * @since 3.15.0 |
|
164 | - * |
|
165 | - * @return \Wordlift_Post_Author_Storage A {@link Wordlift_Post_Author_Storage} |
|
166 | - * instance. |
|
167 | - */ |
|
168 | - public function author_uri() { |
|
169 | - |
|
170 | - return new Wordlift_Post_Author_Storage( $this->entity_service, $this->user_service ); |
|
171 | - } |
|
172 | - |
|
173 | - /** |
|
174 | - * Get a {@link Wordlift_Post_Meta_Uri_Storage} instance which reads {@link WP_Post} |
|
175 | - * ids and maps them to URI. |
|
176 | - * |
|
177 | - * @param string $meta_key The {@link WP_Post}'s meta key. |
|
178 | - * |
|
179 | - * @return \Wordlift_Post_Meta_Uri_Storage A {@link Wordlift_Post_Meta_Uri_Storage} |
|
180 | - * instance. |
|
181 | - */ |
|
182 | - public function post_meta_to_uri( $meta_key ) { |
|
183 | - |
|
184 | - return new Wordlift_Post_Meta_Uri_Storage( $meta_key, $this->entity_service ); |
|
185 | - } |
|
186 | - |
|
187 | - /** |
|
188 | - * Get a list of {@link WP_Post}'s images URI. |
|
189 | - * |
|
190 | - * @since 3.15.0 |
|
191 | - * |
|
192 | - * @return \Wordlift_Post_Image_Storage A {@link Wordlift_Post_Image_Storage} |
|
193 | - * instance. |
|
194 | - */ |
|
195 | - public function post_images() { |
|
196 | - |
|
197 | - return new Wordlift_Post_Image_Storage(); |
|
198 | - } |
|
199 | - |
|
200 | - /** |
|
201 | - * Get a {@link Wordlift_Post_Related_Storage} instance to get related |
|
202 | - * {@link WP_Post}s. |
|
203 | - * |
|
204 | - * @since 3.15.0 |
|
205 | - * |
|
206 | - * @return \Wordlift_Post_Related_Storage A {@link Wordlift_Post_Related_Storage} |
|
207 | - * instance. |
|
208 | - */ |
|
209 | - public function relations() { |
|
210 | - |
|
211 | - return new Wordlift_Post_Related_Storage( $this->entity_service ); |
|
212 | - } |
|
213 | - |
|
214 | - /** |
|
215 | - * Get the {@link Wordlift_Url_Property_Storage} instance. |
|
216 | - * |
|
217 | - * @since 3.15.0 |
|
218 | - * |
|
219 | - * @return \Wordlift_Url_Property_Storage The {@link Wordlift_Url_Property_Storage} |
|
220 | - * instance. |
|
221 | - */ |
|
222 | - public function url_property() { |
|
223 | - |
|
224 | - return new Wordlift_Url_Property_Storage( $this->property_getter ); |
|
225 | - } |
|
21 | + /** |
|
22 | + * The {@link Wordlift_Entity_Service} instance. |
|
23 | + * |
|
24 | + * @since 3.15.0 |
|
25 | + * @access private |
|
26 | + * @var \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance. |
|
27 | + */ |
|
28 | + private $entity_service; |
|
29 | + |
|
30 | + /** |
|
31 | + * The {@link Wordlift_User_Service} instance. |
|
32 | + * |
|
33 | + * @since 3.15.0 |
|
34 | + * @access private |
|
35 | + * @var \Wordlift_User_Service $user_service The {@link Wordlift_User_Service} instance. |
|
36 | + */ |
|
37 | + private $user_service; |
|
38 | + |
|
39 | + /** |
|
40 | + * The {@link Wordlift_Property_Getter} instance. |
|
41 | + * |
|
42 | + * @since 3.15.0 |
|
43 | + * @access private |
|
44 | + * @var \Wordlift_Property_Getter The {@link Wordlift_Property_Getter} instance. |
|
45 | + */ |
|
46 | + private $property_getter; |
|
47 | + |
|
48 | + /** |
|
49 | + * The singleton instance. |
|
50 | + * |
|
51 | + * @since 3.15.0 |
|
52 | + * @access private |
|
53 | + * @var \Wordlift_Storage_Factory $instance The singleton instance. |
|
54 | + */ |
|
55 | + private static $instance; |
|
56 | + |
|
57 | + /** |
|
58 | + * Create a {@link Wordlift_Storage_Factory} instance. |
|
59 | + * |
|
60 | + * @since 3.15.0 |
|
61 | + * |
|
62 | + * @param \Wordlift_Entity_Service $entity_service The {@link Wordlift_Entity_Service} instance. |
|
63 | + * @param \Wordlift_User_Service $user_service The {@link Wordlift_User_Service} instance. |
|
64 | + * @param \Wordlift_Property_Getter $property_getter The {@link Wordlift_Property_Getter} instance. |
|
65 | + */ |
|
66 | + public function __construct( $entity_service, $user_service, $property_getter ) { |
|
67 | + |
|
68 | + $this->entity_service = $entity_service; |
|
69 | + $this->user_service = $user_service; |
|
70 | + $this->property_getter = $property_getter; |
|
71 | + |
|
72 | + self::$instance = $this; |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * Get the singleton instance. |
|
77 | + * |
|
78 | + * @since 3.15.0 |
|
79 | + * |
|
80 | + * @return \Wordlift_Storage_Factory The singleton instance. |
|
81 | + */ |
|
82 | + public static function get_instance() { |
|
83 | + |
|
84 | + return self::$instance; |
|
85 | + } |
|
86 | + |
|
87 | + /** |
|
88 | + * Get a {@link Wordlift_Post_Property_Storage} to read {@link WP_Post}s' |
|
89 | + * titles. |
|
90 | + * |
|
91 | + * @since 3.15.0 |
|
92 | + * |
|
93 | + * @return \Wordlift_Post_Property_Storage A {@link Wordlift_Post_Property_Storage} |
|
94 | + * instance. |
|
95 | + */ |
|
96 | + public function post_title() { |
|
97 | + |
|
98 | + return new Wordlift_Post_Property_Storage( Wordlift_Post_Property_Storage::TITLE ); |
|
99 | + } |
|
100 | + |
|
101 | + /** |
|
102 | + * Get a {@link Wordlift_Post_Property_Storage} to read {@link WP_Post}s' |
|
103 | + * descriptions stripped of tags and shortcodes. |
|
104 | + * |
|
105 | + * @since 3.15.0 |
|
106 | + * |
|
107 | + * @return \Wordlift_Post_Property_Storage A {@link Wordlift_Post_Property_Storage} |
|
108 | + * instance. |
|
109 | + */ |
|
110 | + public function post_description_no_tags_no_shortcodes() { |
|
111 | + |
|
112 | + return new Wordlift_Post_Property_Storage( Wordlift_Post_Property_Storage::DESCRIPTION_NO_TAGS_NO_SHORTCODES ); |
|
113 | + } |
|
114 | + |
|
115 | + /** |
|
116 | + * Get a {@link Wordlift_Post_Property_Storage} to read {@link WP_Post}s' |
|
117 | + * authors. |
|
118 | + * |
|
119 | + * @since 3.15.0 |
|
120 | + * |
|
121 | + * @return \Wordlift_Post_Property_Storage A {@link Wordlift_Post_Property_Storage} |
|
122 | + * instance. |
|
123 | + */ |
|
124 | + public function post_author() { |
|
125 | + |
|
126 | + return new Wordlift_Post_Property_Storage( Wordlift_Post_Property_Storage::AUTHOR ); |
|
127 | + } |
|
128 | + |
|
129 | + /** |
|
130 | + * Get a {@link Wordlift_Post_Property_Storage} to read {@link WP_Post}s' |
|
131 | + * metas. |
|
132 | + * |
|
133 | + * @since 3.15.0 |
|
134 | + * |
|
135 | + * @param string $meta_key The meta key to read. |
|
136 | + * |
|
137 | + * @return Wordlift_Post_Meta_Storage A {@link Wordlift_Post_Meta_Storage} |
|
138 | + * instance. |
|
139 | + */ |
|
140 | + public function post_meta( $meta_key ) { |
|
141 | + |
|
142 | + return new Wordlift_Post_Meta_Storage( $meta_key ); |
|
143 | + } |
|
144 | + |
|
145 | + /** |
|
146 | + * Get a {@link Wordlift_Post_Schema_Class_Storage} to read {@link WP_Post}s' |
|
147 | + * entity type class. |
|
148 | + * |
|
149 | + * @since 3.15.0 |
|
150 | + * |
|
151 | + * @return Wordlift_Post_Schema_Class_Storage A {@link Wordlift_Post_Schema_Class_Storage} |
|
152 | + * instance. |
|
153 | + */ |
|
154 | + public function schema_class() { |
|
155 | + |
|
156 | + return new Wordlift_Post_Schema_Class_Storage(); |
|
157 | + } |
|
158 | + |
|
159 | + /** |
|
160 | + * Get a {@link Wordlift_Post_Author_Storage} instance able to turn an author |
|
161 | + * id into a URI. |
|
162 | + * |
|
163 | + * @since 3.15.0 |
|
164 | + * |
|
165 | + * @return \Wordlift_Post_Author_Storage A {@link Wordlift_Post_Author_Storage} |
|
166 | + * instance. |
|
167 | + */ |
|
168 | + public function author_uri() { |
|
169 | + |
|
170 | + return new Wordlift_Post_Author_Storage( $this->entity_service, $this->user_service ); |
|
171 | + } |
|
172 | + |
|
173 | + /** |
|
174 | + * Get a {@link Wordlift_Post_Meta_Uri_Storage} instance which reads {@link WP_Post} |
|
175 | + * ids and maps them to URI. |
|
176 | + * |
|
177 | + * @param string $meta_key The {@link WP_Post}'s meta key. |
|
178 | + * |
|
179 | + * @return \Wordlift_Post_Meta_Uri_Storage A {@link Wordlift_Post_Meta_Uri_Storage} |
|
180 | + * instance. |
|
181 | + */ |
|
182 | + public function post_meta_to_uri( $meta_key ) { |
|
183 | + |
|
184 | + return new Wordlift_Post_Meta_Uri_Storage( $meta_key, $this->entity_service ); |
|
185 | + } |
|
186 | + |
|
187 | + /** |
|
188 | + * Get a list of {@link WP_Post}'s images URI. |
|
189 | + * |
|
190 | + * @since 3.15.0 |
|
191 | + * |
|
192 | + * @return \Wordlift_Post_Image_Storage A {@link Wordlift_Post_Image_Storage} |
|
193 | + * instance. |
|
194 | + */ |
|
195 | + public function post_images() { |
|
196 | + |
|
197 | + return new Wordlift_Post_Image_Storage(); |
|
198 | + } |
|
199 | + |
|
200 | + /** |
|
201 | + * Get a {@link Wordlift_Post_Related_Storage} instance to get related |
|
202 | + * {@link WP_Post}s. |
|
203 | + * |
|
204 | + * @since 3.15.0 |
|
205 | + * |
|
206 | + * @return \Wordlift_Post_Related_Storage A {@link Wordlift_Post_Related_Storage} |
|
207 | + * instance. |
|
208 | + */ |
|
209 | + public function relations() { |
|
210 | + |
|
211 | + return new Wordlift_Post_Related_Storage( $this->entity_service ); |
|
212 | + } |
|
213 | + |
|
214 | + /** |
|
215 | + * Get the {@link Wordlift_Url_Property_Storage} instance. |
|
216 | + * |
|
217 | + * @since 3.15.0 |
|
218 | + * |
|
219 | + * @return \Wordlift_Url_Property_Storage The {@link Wordlift_Url_Property_Storage} |
|
220 | + * instance. |
|
221 | + */ |
|
222 | + public function url_property() { |
|
223 | + |
|
224 | + return new Wordlift_Url_Property_Storage( $this->property_getter ); |
|
225 | + } |
|
226 | 226 | |
227 | 227 | } |
@@ -16,30 +16,30 @@ |
||
16 | 16 | */ |
17 | 17 | class Wordlift_Install_3_15_0 extends Wordlift_Install { |
18 | 18 | |
19 | - /** |
|
20 | - * @inheritdoc |
|
21 | - */ |
|
22 | - protected static $version = '3.15.0'; |
|
19 | + /** |
|
20 | + * @inheritdoc |
|
21 | + */ |
|
22 | + protected static $version = '3.15.0'; |
|
23 | 23 | |
24 | - /** |
|
25 | - * @inheritdoc |
|
26 | - */ |
|
27 | - public function install() { |
|
24 | + /** |
|
25 | + * @inheritdoc |
|
26 | + */ |
|
27 | + public function install() { |
|
28 | 28 | |
29 | - // Check whether the `article` term exists. |
|
30 | - $article = get_term_by( 'slug', 'article', Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
29 | + // Check whether the `article` term exists. |
|
30 | + $article = get_term_by( 'slug', 'article', Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME ); |
|
31 | 31 | |
32 | - // The `article` term doesn't exists, so create it. |
|
33 | - if ( empty( $article ) ) { |
|
34 | - wp_insert_term( |
|
35 | - 'Article', |
|
36 | - Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, |
|
37 | - array( |
|
38 | - 'slug' => 'article', |
|
39 | - 'description' => 'An Article.', |
|
40 | - ) |
|
41 | - ); |
|
42 | - } |
|
43 | - } |
|
32 | + // The `article` term doesn't exists, so create it. |
|
33 | + if ( empty( $article ) ) { |
|
34 | + wp_insert_term( |
|
35 | + 'Article', |
|
36 | + Wordlift_Entity_Type_Taxonomy_Service::TAXONOMY_NAME, |
|
37 | + array( |
|
38 | + 'slug' => 'article', |
|
39 | + 'description' => 'An Article.', |
|
40 | + ) |
|
41 | + ); |
|
42 | + } |
|
43 | + } |
|
44 | 44 | |
45 | 45 | } |