1 | <?php |
||
16 | class Post extends Abs\Type{ |
||
17 | |||
18 | /** |
||
19 | * metaboxes |
||
20 | * Easy access for the Metaboxes class. |
||
21 | * |
||
22 | * @var string |
||
23 | * @access private |
||
24 | */ |
||
25 | private $metaboxes; |
||
26 | |||
27 | /** |
||
28 | * type |
||
29 | * Defines type slug for use elsewhere in the plugin |
||
30 | * |
||
31 | * @var string |
||
32 | * @access protected |
||
33 | */ |
||
34 | protected $type = 'post'; |
||
35 | |||
36 | /** |
||
37 | * Constructor to load in the Metaboxes class. |
||
38 | * |
||
39 | * @see object |
||
40 | */ |
||
41 | public function __construct(){ |
||
46 | |||
47 | /** |
||
48 | * Create test data posts. |
||
49 | * |
||
50 | * This is where the magic begins. We accept a cpt id (slug) and potntially |
||
51 | * a number of posts to create. We then fetch the supports & metaboxes |
||
52 | * for that cpt and feed them into a function to create each post individually. |
||
53 | * |
||
54 | * @access private |
||
55 | * |
||
56 | * @see $this->get_cpt_supports, $this->get_metaboxes, $this->create_test_object |
||
57 | * |
||
58 | * @param string $slug a custom post type ID. |
||
59 | * @param boolean $connection Whether or not we're connected to the Internet. |
||
60 | * @param int $num Optional. Number of posts to create. |
||
61 | */ |
||
62 | public function create_objects( $slug, $connection, $num = '' ){ |
||
91 | |||
92 | |||
93 | /** |
||
94 | * Creates the individual test data post. |
||
95 | * |
||
96 | * Create individual posts for testing with. Gathers basic information such |
||
97 | * as title, content, thumbnail, etc. and inserts them with the post. Also |
||
98 | * adds metaboxes if applicable . |
||
99 | * |
||
100 | * @access private |
||
101 | * |
||
102 | * @see TestContent, wp_insert_post, add_post_meta, update_post_meta, $this->random_metabox_content |
||
103 | * |
||
104 | * @param string $slug a custom post type ID. |
||
105 | * @param array $supports Features that the post type supports. |
||
106 | * @param array $supports All CMB2 metaboxes attached to the post type. |
||
107 | */ |
||
108 | private function create_test_object( $slug, $supports, $metaboxes ){ |
||
179 | |||
180 | |||
181 | /** |
||
182 | * Assemble supports statements for a particular post type. |
||
183 | * |
||
184 | * @access private |
||
185 | * |
||
186 | * @see post_type_supports |
||
187 | * |
||
188 | * @param string $slug a custom post type ID. |
||
189 | * @return array Array of necessary supports booleans. |
||
190 | */ |
||
191 | private function get_cpt_supports( $slug ){ |
||
203 | |||
204 | |||
205 | /** |
||
206 | * Assigns taxonomies to the new post. |
||
207 | * |
||
208 | * Loop through every taxonomy type associated with a custom post type & |
||
209 | * assign the post to a random item out of each taxonomy. Taxonomies must |
||
210 | * have at least one term in them for this to work. |
||
211 | * |
||
212 | * @access private |
||
213 | * |
||
214 | * @param int $post_id a custom post type ID. |
||
215 | * @param array $taxonomies taxonomies assigned to this cpt. |
||
216 | * @return object WP Error if there is one. |
||
217 | */ |
||
218 | private function assign_terms( $post_id, $taxonomies ){ |
||
259 | |||
260 | |||
261 | /** |
||
262 | * Delete all test data, regardless of type, within posts. |
||
263 | * |
||
264 | * @see Delete |
||
265 | */ |
||
266 | public function delete_all(){ |
||
284 | |||
285 | |||
286 | /** |
||
287 | * Delete test data posts. |
||
288 | * |
||
289 | * This function will search for all posts of a particular post type ($slug) |
||
290 | * and delete them all using a particular cmb flag that we set when creating |
||
291 | * the posts. Validates the user first. |
||
292 | * |
||
293 | * @see WP_Query, wp_delete_post |
||
294 | * |
||
295 | * @param string $slug a custom post type ID. |
||
296 | */ |
||
297 | public function delete( $slug ){ |
||
359 | |||
360 | |||
361 | /** |
||
362 | * Find and delete attachments associated with a post ID. |
||
363 | * |
||
364 | * This function finds each attachment that is associated with a post ID |
||
365 | * and deletes it completely from the site. This is to prevent leftover |
||
366 | * random images from sitting on the site forever. |
||
367 | * |
||
368 | * @access private |
||
369 | * |
||
370 | * @see get_attached_media, wp_delete_attachment |
||
371 | * |
||
372 | * @param int $pid a custom post type ID. |
||
373 | */ |
||
374 | private function delete_associated_media( $pid ){ |
||
401 | |||
402 | |||
403 | } |
||
404 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..