首页 WordPress函数大全 plugins_api()

plugins_api()

2020-05-02 / 4090阅 / 悠然

如何你看完本文还不知道如何使用该函数,可以联系我定制视频教程,50元/个函数,学不会全额退款

plugins_api( string $action, array|object $args = array() )

从WordPress.org插件API检索插件安装程序页面。

描述

插件可以使用三个过滤器覆盖Plugin API结果。假设这是针对插件的,可以扩展>“ plugins_api_args”,针对args,并将操作作为第二个参数。“ plugins_api_args”的钩子必须确保返回对象。

第二个过滤器“ plugins_api”允许插件完全覆盖WordPress.org插件安装API。如果$ action是'query_plugins'或'plugin_information',则必须传递一个对象。如果$ action是'hot_tags'或'hot_categories',则必须传递一个数组。

最后,第三过滤器, 'plugins_api_result',使得能够过滤响应对象或阵列,这取决于> query_pluginsplugin_informationhot_tagshot_categories $ slugNoYesNoNo $ per_pageYesNoNoNo $ pageYesNoNoNo $ numberNoNoYesYes $ searchYesNoNoNo $ tagYesNoNoNo $ authorYesNoNoNo $ userYesNoNoNo $ browseYesNoNoNo $ localeYesYesNoNo $ installed_pluginsYesNoNoNo $ is_sslYesYesNoNo $ fieldsYesYesNoNo

参数

$action

(string)
(Required)
API action to perform: 'query_plugins', 'plugin_information', 'hot_tags' or 'hot_categories'.

$args

(array|object)
(Optional)
Array or object of arguments to serialize for the Plugin Info API.

  • 'slug'
    (string) The plugin slug.
  • 'per_page'
    (int) Number of plugins per page. Default 24.
  • 'page'
    (int) Number of current page. Default 1.
  • 'number'
    (int) Number of tags or categories to be queried.
  • 'search'
    (string) A search term.
  • 'tag'
    (string) Tag to filter plugins.
  • 'author'
    (string) Username of an plugin author to filter plugins.
  • 'user'
    (string) Username to query for their favorites.
  • 'browse'
    (string) Browse view: 'popular', 'new', 'beta', 'recommended'.
  • 'locale'
    (string) Locale to provide context-sensitive results. Default is the value of get_locale().
  • 'installed_plugins'
    (string) Installed plugins to provide context-sensitive results.
  • 'is_ssl'
    (bool) Whether links should be returned with https or not. Default false.
  • 'fields'
    (array) Array of fields which should or should not be returned.

    • 'short_description'
      (bool) Whether to return the plugin short description. Default true.
    • 'description'
      (bool) Whether to return the plugin full description. Default false.
    • 'sections'
      (bool) Whether to return the plugin readme sections: description, installation, FAQ, screenshots, other notes, and changelog. Default false.
    • 'tested'
      (bool) Whether to return the 'Compatible up to' value. Default true.
    • 'requires'
      (bool) Whether to return the required WordPress version. Default true.
    • 'requires_php'
      (bool) Whether to return the required PHP version. Default true.
    • 'rating'
      (bool) Whether to return the rating in percent and total number of ratings. Default true.
    • 'ratings'
      (bool) Whether to return the number of rating for each star (1-5). Default true.
    • 'downloaded'
      (bool) Whether to return the download count. Default true.
    • 'downloadlink'
      (bool) Whether to return the download link for the package. Default true.
    • 'last_updated'
      (bool) Whether to return the date of the last update. Default true.
    • 'added'
      (bool) Whether to return the date when the plugin was added to the wordpress.org repository. Default true.
    • 'tags'
      (bool) Whether to return the assigned tags. Default true.
    • 'compatibility'
      (bool) Whether to return the WordPress compatibility list. Default true.
    • 'homepage'
      (bool) Whether to return the plugin homepage link. Default true.
    • 'versions'
      (bool) Whether to return the list of all available versions. Default false.
    • 'donate_link'
      (bool) Whether to return the donation link. Default true.
    • 'reviews'
      (bool) Whether to return the plugin reviews. Default false.
    • 'banners'
      (bool) Whether to return the banner images links. Default false.
    • 'icons'
      (bool) Whether to return the icon links. Default false.
    • 'active_installs'
      (bool) Whether to return the number of active installations. Default false.
    • 'group'
      (bool) Whether to return the assigned group. Default false.
    • 'contributors'
      (bool) Whether to return the list of contributors. Default false.

Default value: array()

返回

(object|array|WP_Error) Response object or array>WP_Error> function reference article for more information on the make-up of possible return values depending on the value of $action.

大家谈论
    我的见解