@@ -37,6 +37,9 @@ |
||
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | + /** |
|
| 41 | + * @param string $root |
|
| 42 | + */ |
|
| 40 | 43 | public function scan_dir( $root, $exclude = array() ) { |
| 41 | 44 | $filter = function ( $file, $key, $iterator ) use ( $exclude ) { |
| 42 | 45 | if ( $iterator->hasChildren() && ! in_array( $file->getFilename(), $exclude ) ) { |
@@ -9,6 +9,9 @@ |
||
| 9 | 9 | private $invocations; |
| 10 | 10 | private $file_path; |
| 11 | 11 | |
| 12 | + /** |
|
| 13 | + * @param $invocations |
|
| 14 | + */ |
|
| 12 | 15 | public function __construct( $file_path, $invocations ) { |
| 13 | 16 | $this->file_path = $file_path; |
| 14 | 17 | $this->invocations = $invocations; |
@@ -31,6 +31,7 @@ |
||
| 31 | 31 | |
| 32 | 32 | /** |
| 33 | 33 | * Saves the items to a file and returns the file contents |
| 34 | + * @param string $file_path |
|
| 34 | 35 | */ |
| 35 | 36 | public function save( $file_path, $allow_empty = true ) { |
| 36 | 37 | |
@@ -11,6 +11,9 @@ |
||
| 11 | 11 | private $declarations; |
| 12 | 12 | private $current_relative_path; |
| 13 | 13 | |
| 14 | + /** |
|
| 15 | + * @param $declarations |
|
| 16 | + */ |
|
| 14 | 17 | public function __construct( $current_relative_path, $declarations ) { |
| 15 | 18 | $this->current_relative_path = $current_relative_path; |
| 16 | 19 | $this->declarations = $declarations; |
@@ -36,6 +36,9 @@ |
||
| 36 | 36 | add_action( 'init', array( &$this, 'action_init' ) ); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | + /** |
|
| 40 | + * @param string $file |
|
| 41 | + */ |
|
| 39 | 42 | function wpcom_static_url($file) { |
| 40 | 43 | $i = hexdec( substr( md5( $file ), -1 ) ) % 2; |
| 41 | 44 | return 'https://s' . $i . '.wp.com' . $file; |
@@ -33,6 +33,9 @@ discard block |
||
| 33 | 33 | public $extra_headers = array(); |
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | + * @param string $method |
|
| 37 | + * @param string $url |
|
| 38 | + * @param string $post_body |
|
| 36 | 39 | * @return WPCOM_JSON_API instance |
| 37 | 40 | */ |
| 38 | 41 | static function init( $method = null, $url = null, $post_body = null ) { |
@@ -347,6 +350,9 @@ discard block |
||
| 347 | 350 | return call_user_func_array( array( $endpoint, 'callback' ), $path_pieces ); |
| 348 | 351 | } |
| 349 | 352 | |
| 353 | + /** |
|
| 354 | + * @param integer $status_code |
|
| 355 | + */ |
|
| 350 | 356 | function output_early( $status_code, $response = null, $content_type = 'application/json' ) { |
| 351 | 357 | $exit = $this->exit; |
| 352 | 358 | $this->exit = false; |
@@ -563,11 +569,18 @@ discard block |
||
| 563 | 569 | return wp_json_encode( $data ); |
| 564 | 570 | } |
| 565 | 571 | |
| 572 | + /** |
|
| 573 | + * @param string $needle |
|
| 574 | + */ |
|
| 566 | 575 | function ends_with( $haystack, $needle ) { |
| 567 | 576 | return $needle === substr( $haystack, -strlen( $needle ) ); |
| 568 | 577 | } |
| 569 | 578 | |
| 570 | 579 | // Returns the site's blog_id in the WP.com ecosystem |
| 580 | + |
|
| 581 | + /** |
|
| 582 | + * @return integer |
|
| 583 | + */ |
|
| 571 | 584 | function get_blog_id_for_output() { |
| 572 | 585 | return $this->token_details['blog_id']; |
| 573 | 586 | } |
@@ -590,6 +603,10 @@ discard block |
||
| 590 | 603 | } |
| 591 | 604 | |
| 592 | 605 | // Returns true if the specified blog ID is a restricted blog |
| 606 | + |
|
| 607 | + /** |
|
| 608 | + * @param integer $blog_id |
|
| 609 | + */ |
|
| 593 | 610 | function is_restricted_blog( $blog_id ) { |
| 594 | 611 | /** |
| 595 | 612 | * Filters all REST API access and return a 403 unauthorized response for all Restricted blog IDs. |
@@ -639,7 +656,7 @@ discard block |
||
| 639 | 656 | /** |
| 640 | 657 | * Counts the number of comments on a site, excluding certain comment types. |
| 641 | 658 | * |
| 642 | - * @param $post_id int Post ID. |
|
| 659 | + * @param integer $post_id int Post ID. |
|
| 643 | 660 | * @return array Array of counts, matching the output of https://developer.wordpress.org/reference/functions/get_comment_count/. |
| 644 | 661 | */ |
| 645 | 662 | public function wp_count_comments( $post_id ) { |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | /** |
| 85 | 85 | * Return an array of allowed mime_type items used to upload a media file. |
| 86 | 86 | * |
| 87 | - * @return array mime_type array |
|
| 87 | + * @return string[] mime_type array |
|
| 88 | 88 | */ |
| 89 | 89 | static function get_allowed_mime_types( $default_mime_types ) { |
| 90 | 90 | return array_unique( array_merge( $default_mime_types, array( |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | * @param object $media_item - media post object |
| 253 | 253 | * @param file $file - file recently added |
| 254 | 254 | * @param bool $has_original_media - condition is the original media has been already added |
| 255 | - * @return bool `true` if the item has been added. Otherwise `false`. |
|
| 255 | + * @return false|null `true` if the item has been added. Otherwise `false`. |
|
| 256 | 256 | */ |
| 257 | 257 | public static function register_revision( $media_item, $file, $has_original_media ) { |
| 258 | 258 | if ( is_wp_error( $file ) || ! $has_original_media ) { |
@@ -280,6 +280,9 @@ discard block |
||
| 280 | 280 | return $original; |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | + /** |
|
| 284 | + * @param string $pathname |
|
| 285 | + */ |
|
| 283 | 286 | public static function delete_file( $pathname ) { |
| 284 | 287 | if ( ! file_exists( $pathname ) || ! is_file( $pathname ) ) { |
| 285 | 288 | // let's touch a fake file to try to `really` remove the media file |
@@ -295,7 +298,7 @@ discard block |
||
| 295 | 298 | * |
| 296 | 299 | * @param number $media_id - media post ID |
| 297 | 300 | * @param string $filename - basename of the file ( name-of-file.ext ) |
| 298 | - * @return bool `true` is the file has been removed, `false` if not. |
|
| 301 | + * @return boolean|null `true` is the file has been removed, `false` if not. |
|
| 299 | 302 | */ |
| 300 | 303 | private static function delete_media_history_file( $media_id, $filename ) { |
| 301 | 304 | $attached_path = get_attached_file( $media_id ); |
@@ -365,6 +368,7 @@ discard block |
||
| 365 | 368 | * |
| 366 | 369 | * @param number $media_id - media post ID |
| 367 | 370 | * @param number [$limit] - maximun amount of items. 20 as default. |
| 371 | + * @param integer $limit |
|
| 368 | 372 | * @return array items removed from `revision_history` |
| 369 | 373 | */ |
| 370 | 374 | public static function limit_revision_history( $media_id, $limit = null) { |
@@ -166,6 +166,7 @@ discard block |
||
| 166 | 166 | /** |
| 167 | 167 | * Get attachment images for a specified post and return them. Also make sure |
| 168 | 168 | * their dimensions are at or above a required minimum. |
| 169 | + * @param integer $post_id |
|
| 169 | 170 | */ |
| 170 | 171 | static function from_attachment( $post_id, $width = 200, $height = 200 ) { |
| 171 | 172 | $images = array(); |
@@ -232,7 +233,7 @@ discard block |
||
| 232 | 233 | * format to the other images?_from_*() methods. |
| 233 | 234 | * |
| 234 | 235 | * @param int $post_id The post ID to check |
| 235 | - * @return Array containing details of the Featured Image, or empty array if none. |
|
| 236 | + * @return integer|null containing details of the Featured Image, or empty array if none. |
|
| 236 | 237 | */ |
| 237 | 238 | static function from_thumbnail( $post_id, $width = 200, $height = 200 ) { |
| 238 | 239 | $images = array(); |
@@ -687,7 +688,6 @@ discard block |
||
| 687 | 688 | * resized and cropped image. |
| 688 | 689 | * |
| 689 | 690 | * @param string $src |
| 690 | - * @param int $dimension |
|
| 691 | 691 | * @return string Transformed image URL |
| 692 | 692 | */ |
| 693 | 693 | static function fit_image_url( $src, $width, $height ) { |
@@ -1534,6 +1534,7 @@ discard block |
||
| 1534 | 1534 | * timezone set in the options table for the blog or the GMT offset. |
| 1535 | 1535 | * |
| 1536 | 1536 | * @param datetime string $date_string Date to parse. |
| 1537 | + * @param string $date_string |
|
| 1537 | 1538 | * |
| 1538 | 1539 | * @return array( $local_time_string, $gmt_time_string ) |
| 1539 | 1540 | */ |
@@ -1643,6 +1644,10 @@ discard block |
||
| 1643 | 1644 | do_action( 'restapi_theme_init' ); |
| 1644 | 1645 | } |
| 1645 | 1646 | |
| 1647 | + /** |
|
| 1648 | + * @param string $from_hook |
|
| 1649 | + * @param string $to_hook |
|
| 1650 | + */ |
|
| 1646 | 1651 | function copy_hooks( $from_hook, $to_hook, $base_paths ) { |
| 1647 | 1652 | global $wp_filter; |
| 1648 | 1653 | foreach ( $wp_filter as $hook => $actions ) { |