@@ -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 | } |
@@ -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 | } |
@@ -15,32 +15,32 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | interface Wordlift_Batch_Operation_Interface { |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * Process the batch operation starting from the specified offset. |
|
| 20 | - * |
|
| 21 | - * @since 3.20.0 |
|
| 22 | - * |
|
| 23 | - * @param int $offset Start from the specified offset (or 0 if not specified). |
|
| 24 | - * @param int $limit Process the specified amount of items per call (or 10 if not specified). |
|
| 25 | - * |
|
| 26 | - * @return array { |
|
| 27 | - * The operation result. |
|
| 28 | - * |
|
| 29 | - * @type int $next The next offset. |
|
| 30 | - * @type int $limit The amount of items to process per call. |
|
| 31 | - * @type int $remaining The remaining number of elements to process. |
|
| 32 | - * @type bool $complete Whether the operation completed. |
|
| 33 | - * } |
|
| 34 | - */ |
|
| 35 | - public function process( $offset = 0, $limit = 10 ); |
|
| 18 | + /** |
|
| 19 | + * Process the batch operation starting from the specified offset. |
|
| 20 | + * |
|
| 21 | + * @since 3.20.0 |
|
| 22 | + * |
|
| 23 | + * @param int $offset Start from the specified offset (or 0 if not specified). |
|
| 24 | + * @param int $limit Process the specified amount of items per call (or 10 if not specified). |
|
| 25 | + * |
|
| 26 | + * @return array { |
|
| 27 | + * The operation result. |
|
| 28 | + * |
|
| 29 | + * @type int $next The next offset. |
|
| 30 | + * @type int $limit The amount of items to process per call. |
|
| 31 | + * @type int $remaining The remaining number of elements to process. |
|
| 32 | + * @type bool $complete Whether the operation completed. |
|
| 33 | + * } |
|
| 34 | + */ |
|
| 35 | + public function process( $offset = 0, $limit = 10 ); |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * Count the number of elements that would be affected by the operation. |
|
| 39 | - * |
|
| 40 | - * @since 3.20.0 |
|
| 41 | - * |
|
| 42 | - * @return int The number of elements that would be affected. |
|
| 43 | - */ |
|
| 44 | - public function count(); |
|
| 37 | + /** |
|
| 38 | + * Count the number of elements that would be affected by the operation. |
|
| 39 | + * |
|
| 40 | + * @since 3.20.0 |
|
| 41 | + * |
|
| 42 | + * @return int The number of elements that would be affected. |
|
| 43 | + */ |
|
| 44 | + public function count(); |
|
| 45 | 45 | |
| 46 | 46 | } |
@@ -12,15 +12,15 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class Wordlift_Install_3_27_1 extends Wordlift_Install { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * {@inheritdoc} |
|
| 17 | - */ |
|
| 18 | - protected static $version = '3.27.1'; |
|
| 15 | + /** |
|
| 16 | + * {@inheritdoc} |
|
| 17 | + */ |
|
| 18 | + protected static $version = '3.27.1'; |
|
| 19 | 19 | |
| 20 | - public function install() { |
|
| 21 | - $procedure = new Recipe_Maker_Entity_Type_Procedure(); |
|
| 22 | - $procedure->run_procedure(); |
|
| 23 | - } |
|
| 20 | + public function install() { |
|
| 21 | + $procedure = new Recipe_Maker_Entity_Type_Procedure(); |
|
| 22 | + $procedure->run_procedure(); |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | 25 | |
| 26 | 26 | } |
@@ -12,170 +12,170 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | abstract class Wordlift_Plugin_WP_Async_Request { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Prefix |
|
| 17 | - * |
|
| 18 | - * (default value: 'wp') |
|
| 19 | - * |
|
| 20 | - * @var string |
|
| 21 | - * @access protected |
|
| 22 | - */ |
|
| 23 | - protected $prefix = 'wp'; |
|
| 24 | - |
|
| 25 | - /** |
|
| 26 | - * Action |
|
| 27 | - * |
|
| 28 | - * (default value: 'async_request') |
|
| 29 | - * |
|
| 30 | - * @var string |
|
| 31 | - * @access protected |
|
| 32 | - */ |
|
| 33 | - protected $action = 'async_request'; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * Identifier |
|
| 37 | - * |
|
| 38 | - * @var mixed |
|
| 39 | - * @access protected |
|
| 40 | - */ |
|
| 41 | - protected $identifier; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * Data |
|
| 45 | - * |
|
| 46 | - * (default value: array()) |
|
| 47 | - * |
|
| 48 | - * @var array |
|
| 49 | - * @access protected |
|
| 50 | - */ |
|
| 51 | - protected $data = array(); |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * Initiate new async request |
|
| 55 | - */ |
|
| 56 | - public function __construct() { |
|
| 57 | - $this->identifier = $this->prefix . '_' . $this->action; |
|
| 58 | - |
|
| 59 | - add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) ); |
|
| 60 | - add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) ); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * Set data used during the request |
|
| 65 | - * |
|
| 66 | - * @param array $data Data. |
|
| 67 | - * |
|
| 68 | - * @return $this |
|
| 69 | - */ |
|
| 70 | - public function data( $data ) { |
|
| 71 | - $this->data = $data; |
|
| 72 | - |
|
| 73 | - return $this; |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * Dispatch the async request |
|
| 78 | - * |
|
| 79 | - * @return array|WP_Error |
|
| 80 | - */ |
|
| 81 | - public function dispatch() { |
|
| 82 | - $url = add_query_arg( $this->get_query_args(), $this->get_query_url() ); |
|
| 83 | - $args = $this->get_post_args(); |
|
| 84 | - |
|
| 85 | - return wp_remote_post( esc_url_raw( $url ), $args ); |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * Get query args |
|
| 90 | - * |
|
| 91 | - * @return array |
|
| 92 | - */ |
|
| 93 | - protected function get_query_args() { |
|
| 94 | - if ( property_exists( $this, 'query_args' ) ) { |
|
| 95 | - return $this->query_args; |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - $args = array( |
|
| 99 | - 'action' => $this->identifier, |
|
| 100 | - 'nonce' => wp_create_nonce( $this->identifier ), |
|
| 101 | - ); |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * Filters the post arguments used during an async request. |
|
| 105 | - * |
|
| 106 | - * @param array $url |
|
| 107 | - */ |
|
| 108 | - return apply_filters( $this->identifier . '_query_args', $args ); |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - /** |
|
| 112 | - * Get query URL |
|
| 113 | - * |
|
| 114 | - * @return string |
|
| 115 | - */ |
|
| 116 | - protected function get_query_url() { |
|
| 117 | - if ( property_exists( $this, 'query_url' ) ) { |
|
| 118 | - return $this->query_url; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - $url = admin_url( 'admin-ajax.php' ); |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * Filters the post arguments used during an async request. |
|
| 125 | - * |
|
| 126 | - * @param string $url |
|
| 127 | - */ |
|
| 128 | - return apply_filters( $this->identifier . '_query_url', $url ); |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * Get post args |
|
| 133 | - * |
|
| 134 | - * @return array |
|
| 135 | - */ |
|
| 136 | - protected function get_post_args() { |
|
| 137 | - if ( property_exists( $this, 'post_args' ) ) { |
|
| 138 | - return $this->post_args; |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - $args = array( |
|
| 142 | - 'timeout' => 0.01, |
|
| 143 | - 'blocking' => false, |
|
| 144 | - 'body' => $this->data, |
|
| 145 | - 'cookies' => $_COOKIE, |
|
| 146 | - 'sslverify' => apply_filters( 'https_local_ssl_verify', false ), |
|
| 147 | - ); |
|
| 148 | - |
|
| 149 | - /** |
|
| 150 | - * Filters the post arguments used during an async request. |
|
| 151 | - * |
|
| 152 | - * @param array $args |
|
| 153 | - */ |
|
| 154 | - return apply_filters( $this->identifier . '_post_args', $args ); |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - /** |
|
| 158 | - * Maybe handle |
|
| 159 | - * |
|
| 160 | - * Check for correct nonce and pass to handler. |
|
| 161 | - */ |
|
| 162 | - public function maybe_handle() { |
|
| 163 | - // Don't lock up other requests while processing |
|
| 164 | - session_write_close(); |
|
| 165 | - |
|
| 166 | - check_ajax_referer( $this->identifier, 'nonce' ); |
|
| 167 | - |
|
| 168 | - $this->handle(); |
|
| 169 | - |
|
| 170 | - wp_die(); |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - /** |
|
| 174 | - * Handle |
|
| 175 | - * |
|
| 176 | - * Override this method to perform any actions required |
|
| 177 | - * during the async request. |
|
| 178 | - */ |
|
| 179 | - abstract protected function handle(); |
|
| 15 | + /** |
|
| 16 | + * Prefix |
|
| 17 | + * |
|
| 18 | + * (default value: 'wp') |
|
| 19 | + * |
|
| 20 | + * @var string |
|
| 21 | + * @access protected |
|
| 22 | + */ |
|
| 23 | + protected $prefix = 'wp'; |
|
| 24 | + |
|
| 25 | + /** |
|
| 26 | + * Action |
|
| 27 | + * |
|
| 28 | + * (default value: 'async_request') |
|
| 29 | + * |
|
| 30 | + * @var string |
|
| 31 | + * @access protected |
|
| 32 | + */ |
|
| 33 | + protected $action = 'async_request'; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * Identifier |
|
| 37 | + * |
|
| 38 | + * @var mixed |
|
| 39 | + * @access protected |
|
| 40 | + */ |
|
| 41 | + protected $identifier; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * Data |
|
| 45 | + * |
|
| 46 | + * (default value: array()) |
|
| 47 | + * |
|
| 48 | + * @var array |
|
| 49 | + * @access protected |
|
| 50 | + */ |
|
| 51 | + protected $data = array(); |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * Initiate new async request |
|
| 55 | + */ |
|
| 56 | + public function __construct() { |
|
| 57 | + $this->identifier = $this->prefix . '_' . $this->action; |
|
| 58 | + |
|
| 59 | + add_action( 'wp_ajax_' . $this->identifier, array( $this, 'maybe_handle' ) ); |
|
| 60 | + add_action( 'wp_ajax_nopriv_' . $this->identifier, array( $this, 'maybe_handle' ) ); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * Set data used during the request |
|
| 65 | + * |
|
| 66 | + * @param array $data Data. |
|
| 67 | + * |
|
| 68 | + * @return $this |
|
| 69 | + */ |
|
| 70 | + public function data( $data ) { |
|
| 71 | + $this->data = $data; |
|
| 72 | + |
|
| 73 | + return $this; |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * Dispatch the async request |
|
| 78 | + * |
|
| 79 | + * @return array|WP_Error |
|
| 80 | + */ |
|
| 81 | + public function dispatch() { |
|
| 82 | + $url = add_query_arg( $this->get_query_args(), $this->get_query_url() ); |
|
| 83 | + $args = $this->get_post_args(); |
|
| 84 | + |
|
| 85 | + return wp_remote_post( esc_url_raw( $url ), $args ); |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * Get query args |
|
| 90 | + * |
|
| 91 | + * @return array |
|
| 92 | + */ |
|
| 93 | + protected function get_query_args() { |
|
| 94 | + if ( property_exists( $this, 'query_args' ) ) { |
|
| 95 | + return $this->query_args; |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + $args = array( |
|
| 99 | + 'action' => $this->identifier, |
|
| 100 | + 'nonce' => wp_create_nonce( $this->identifier ), |
|
| 101 | + ); |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * Filters the post arguments used during an async request. |
|
| 105 | + * |
|
| 106 | + * @param array $url |
|
| 107 | + */ |
|
| 108 | + return apply_filters( $this->identifier . '_query_args', $args ); |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + /** |
|
| 112 | + * Get query URL |
|
| 113 | + * |
|
| 114 | + * @return string |
|
| 115 | + */ |
|
| 116 | + protected function get_query_url() { |
|
| 117 | + if ( property_exists( $this, 'query_url' ) ) { |
|
| 118 | + return $this->query_url; |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + $url = admin_url( 'admin-ajax.php' ); |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * Filters the post arguments used during an async request. |
|
| 125 | + * |
|
| 126 | + * @param string $url |
|
| 127 | + */ |
|
| 128 | + return apply_filters( $this->identifier . '_query_url', $url ); |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * Get post args |
|
| 133 | + * |
|
| 134 | + * @return array |
|
| 135 | + */ |
|
| 136 | + protected function get_post_args() { |
|
| 137 | + if ( property_exists( $this, 'post_args' ) ) { |
|
| 138 | + return $this->post_args; |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + $args = array( |
|
| 142 | + 'timeout' => 0.01, |
|
| 143 | + 'blocking' => false, |
|
| 144 | + 'body' => $this->data, |
|
| 145 | + 'cookies' => $_COOKIE, |
|
| 146 | + 'sslverify' => apply_filters( 'https_local_ssl_verify', false ), |
|
| 147 | + ); |
|
| 148 | + |
|
| 149 | + /** |
|
| 150 | + * Filters the post arguments used during an async request. |
|
| 151 | + * |
|
| 152 | + * @param array $args |
|
| 153 | + */ |
|
| 154 | + return apply_filters( $this->identifier . '_post_args', $args ); |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + /** |
|
| 158 | + * Maybe handle |
|
| 159 | + * |
|
| 160 | + * Check for correct nonce and pass to handler. |
|
| 161 | + */ |
|
| 162 | + public function maybe_handle() { |
|
| 163 | + // Don't lock up other requests while processing |
|
| 164 | + session_write_close(); |
|
| 165 | + |
|
| 166 | + check_ajax_referer( $this->identifier, 'nonce' ); |
|
| 167 | + |
|
| 168 | + $this->handle(); |
|
| 169 | + |
|
| 170 | + wp_die(); |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + /** |
|
| 174 | + * Handle |
|
| 175 | + * |
|
| 176 | + * Override this method to perform any actions required |
|
| 177 | + * during the async request. |
|
| 178 | + */ |
|
| 179 | + abstract protected function handle(); |
|
| 180 | 180 | |
| 181 | 181 | } |
@@ -8,8 +8,8 @@ |
||
| 8 | 8 | ?> |
| 9 | 9 | <form method="post" action="options.php"> |
| 10 | 10 | <?php |
| 11 | - settings_fields( 'wl_settings__webhooks' ); |
|
| 12 | - do_settings_sections( 'wl_settings__webhooks' ); |
|
| 13 | - submit_button( 'Save Settings' ); |
|
| 14 | - ?> |
|
| 11 | + settings_fields( 'wl_settings__webhooks' ); |
|
| 12 | + do_settings_sections( 'wl_settings__webhooks' ); |
|
| 13 | + submit_button( 'Save Settings' ); |
|
| 14 | + ?> |
|
| 15 | 15 | </form> |