18 * as the second parameter. The hook for {@see 'plugins_api_args'} must ensure that |
18 * as the second parameter. The hook for {@see 'plugins_api_args'} must ensure that |
19 * an object is returned. |
19 * an object is returned. |
20 * |
20 * |
21 * The second filter, {@see 'plugins_api'}, allows a plugin to override the WordPress.org |
21 * The second filter, {@see 'plugins_api'}, allows a plugin to override the WordPress.org |
22 * Plugin Installation API entirely. If `$action` is 'query_plugins' or 'plugin_information', |
22 * Plugin Installation API entirely. If `$action` is 'query_plugins' or 'plugin_information', |
23 * an object MUST be passed. If `$action` is 'hot_tags' or 'hot_categories', an array MUST |
23 * an object MUST be passed. If `$action` is 'hot_tags', an array MUST be passed. |
24 * be passed. |
|
25 * |
24 * |
26 * Finally, the third filter, {@see 'plugins_api_result'}, makes it possible to filter the |
25 * Finally, the third filter, {@see 'plugins_api_result'}, makes it possible to filter the |
27 * response object or array, depending on the `$action` type. |
26 * response object or array, depending on the `$action` type. |
28 * |
27 * |
29 * Supported arguments per action: |
28 * Supported arguments per action: |
30 * |
29 * |
31 * | Argument Name | query_plugins | plugin_information | hot_tags | hot_categories | |
30 * | Argument Name | query_plugins | plugin_information | hot_tags | |
32 * | -------------------- | :-----------: | :----------------: | :------: | :------------: | |
31 * | -------------------- | :-----------: | :----------------: | :------: | |
33 * | `$slug` | No | Yes | No | No | |
32 * | `$slug` | No | Yes | No | |
34 * | `$per_page` | Yes | No | No | No | |
33 * | `$per_page` | Yes | No | No | |
35 * | `$page` | Yes | No | No | No | |
34 * | `$page` | Yes | No | No | |
36 * | `$number` | No | No | Yes | Yes | |
35 * | `$number` | No | No | Yes | |
37 * | `$search` | Yes | No | No | No | |
36 * | `$search` | Yes | No | No | |
38 * | `$tag` | Yes | No | No | No | |
37 * | `$tag` | Yes | No | No | |
39 * | `$author` | Yes | No | No | No | |
38 * | `$author` | Yes | No | No | |
40 * | `$user` | Yes | No | No | No | |
39 * | `$user` | Yes | No | No | |
41 * | `$browse` | Yes | No | No | No | |
40 * | `$browse` | Yes | No | No | |
42 * | `$locale` | Yes | Yes | No | No | |
41 * | `$locale` | Yes | Yes | No | |
43 * | `$installed_plugins` | Yes | No | No | No | |
42 * | `$installed_plugins` | Yes | No | No | |
44 * | `$is_ssl` | Yes | Yes | No | No | |
43 * | `$is_ssl` | Yes | Yes | No | |
45 * | `$fields` | Yes | Yes | No | No | |
44 * | `$fields` | Yes | Yes | No | |
46 * |
45 * |
47 * @since 2.7.0 |
46 * @since 2.7.0 |
48 * |
47 * |
49 * @param string $action API action to perform: 'query_plugins', 'plugin_information', |
48 * @param string $action API action to perform: 'query_plugins', 'plugin_information', |
50 * 'hot_tags' or 'hot_categories'. |
49 * or 'hot_tags'. |
51 * @param array|object $args { |
50 * @param array|object $args { |
52 * Optional. Array or object of arguments to serialize for the Plugin Info API. |
51 * Optional. Array or object of arguments to serialize for the Plugin Info API. |
53 * |
52 * |
54 * @type string $slug The plugin slug. Default empty. |
53 * @type string $slug The plugin slug. Default empty. |
55 * @type int $per_page Number of plugins per page. Default 24. |
54 * @type int $per_page Number of plugins per page. Default 24. |
89 * @type bool $donate_link Whether to return the donation link. Default true. |
88 * @type bool $donate_link Whether to return the donation link. Default true. |
90 * @type bool $reviews Whether to return the plugin reviews. Default false. |
89 * @type bool $reviews Whether to return the plugin reviews. Default false. |
91 * @type bool $banners Whether to return the banner images links. Default false. |
90 * @type bool $banners Whether to return the banner images links. Default false. |
92 * @type bool $icons Whether to return the icon links. Default false. |
91 * @type bool $icons Whether to return the icon links. Default false. |
93 * @type bool $active_installs Whether to return the number of active installations. Default false. |
92 * @type bool $active_installs Whether to return the number of active installations. Default false. |
94 * @type bool $group Whether to return the assigned group. Default false. |
|
95 * @type bool $contributors Whether to return the list of contributors. Default false. |
93 * @type bool $contributors Whether to return the list of contributors. Default false. |
96 * } |
94 * } |
97 * } |
95 * } |
98 * @return object|array|WP_Error Response object or array on success, WP_Error on failure. See the |
96 * @return object|array|WP_Error Response object or array on success, WP_Error on failure. See the |
99 * {@link https://developer.wordpress.org/reference/functions/plugins_api/ function reference article} |
97 * {@link https://developer.wordpress.org/reference/functions/plugins_api/ function reference article} |
100 * for more information on the make-up of possible return values depending on the value of `$action`. |
98 * for more information on the make-up of possible return values depending on the value of `$action`. |
101 */ |
99 */ |
102 function plugins_api( $action, $args = array() ) { |
100 function plugins_api( $action, $args = array() ) { |
103 // Include an unmodified $wp_version. |
|
104 require ABSPATH . WPINC . '/version.php'; |
|
105 |
|
106 if ( is_array( $args ) ) { |
101 if ( is_array( $args ) ) { |
107 $args = (object) $args; |
102 $args = (object) $args; |
108 } |
103 } |
109 |
104 |
110 if ( 'query_plugins' === $action ) { |
105 if ( 'query_plugins' === $action ) { |
137 * Filters the response for the current WordPress.org Plugin Installation API request. |
132 * Filters the response for the current WordPress.org Plugin Installation API request. |
138 * |
133 * |
139 * Returning a non-false value will effectively short-circuit the WordPress.org API request. |
134 * Returning a non-false value will effectively short-circuit the WordPress.org API request. |
140 * |
135 * |
141 * If `$action` is 'query_plugins' or 'plugin_information', an object MUST be passed. |
136 * If `$action` is 'query_plugins' or 'plugin_information', an object MUST be passed. |
142 * If `$action` is 'hot_tags' or 'hot_categories', an array should be passed. |
137 * If `$action` is 'hot_tags', an array should be passed. |
143 * |
138 * |
144 * @since 2.7.0 |
139 * @since 2.7.0 |
145 * |
140 * |
146 * @param false|object|array $result The result object or array. Default false. |
141 * @param false|object|array $result The result object or array. Default false. |
147 * @param string $action The type of information being requested from the Plugin Installation API. |
142 * @param string $action The type of information being requested from the Plugin Installation API. |