[wp-trac] [WordPress Trac] #60783: plugins_api() and parameters

WordPress Trac noreply at wordpress.org
Fri Mar 15 13:57:13 UTC 2024


#60783: plugins_api() and parameters
--------------------------+-----------------------------
 Reporter:  juliobox      |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Plugins       |    Version:  trunk
 Severity:  normal        |   Keywords:  needs-patch
  Focuses:  docs          |
--------------------------+-----------------------------
 Hello there, (running WP6.5+, might be useless to say)
 By reading the doc for `plugins_api()` you can read that some fields are
 included or not in the response, the doc says ''"$fields: Array of fields
 which should or should not be returned."'' and then you have a list of
 fields, some true some false by default.
 Let's try it, this is my simple request on my plugin on repo:
 {{{#!php
 <?php
 require ABSPATH . 'wp-admin/includes/plugin-install.php';
 $api = plugins_api(
         'plugin_information',
         array(
                 'slug'   => 'secupress',
                 'fields' => []
         )
 );
 }}}
 Since the doc says ''"@type bool $contributors      Whether to return the
 list of contributors. **Default false**."'' I should not receive this
 field.
 Let see the response:
 {{{#!php
 <?php
 object(stdClass)#1010 (32) {
   ["name"]=>
   string(37) "SecuPress Free — WordPress Security"
   ["slug"]=>
   string(9) "secupress"
   ["version"]=>
   string(7) "2.2.5.1"
   ["author"]=>
   string(44) "SecuPress"
   ["author_profile"]=>
   string(41) "https://profiles.wordpress.org/secupress/"
   ["contributors"]=>
   array(4) {
 ...
 }}}
 There is. Same for those params that are "false" by default but still
 included:  "sections", "versions", "reviews", "banners", "active_installs"
 (I don't know for "group", can't get the thing).

 Also there is one param that is not affected by the arguments passed and
 always returned: "num_ratings".

 Finally there is some fields that are always returned where the doc can't
 help, I tried to use they array keys to cancel them, no chance, this is :
 "author', "author_profile" (those 2 may be forced, that's ok),
 "support_threads", "support_threads_resolved", "upgrade_notice", and
 "requires_plugin" (I know it's new, but don't forget it)

 The patch may have to be done on w.org since this is the site that add too
 much data and to not respect the passed parameters.

 Thanks for your time

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/60783>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list