WordPress.org

Make WordPress Core

Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#38626 closed defect (bug) (invalid)

Audit the default args for load_themes_ajax()

Reported by: afercia Owned by:
Milestone: Priority: normal
Severity: normal Version: 4.7
Component: Customize Keywords: needs-patch
Focuses: Cc:

Description

Really not an expert about .org APIs but while testing #38365 noticed something that didn't look right to me. The default args for load_themes_ajax() introduced in [38813] are:

// Arguments for all queries.
$args = array(
	'per_page' => 100,
	'page' => absint( $_POST['page'] ),
	'fields' => array(
		'slug' => true,
		'screenshot' => true,
		'description' => true,
		'requires' => true,
		'rating' => true,
		'downloaded' => true,
		'downloadLink' => true,
		'last_updated' => true,
		'homepage' => true,
		'num_ratings' => true,
		'tags' => true,
	),
);

Was playing with screenshot setting it to false but nothing changed, so a quick check of the fields docs: https://codex.wordpress.org/WordPress.org_API#List_of_Themes revealed to me different key names:

description - false
sections - false
rating - true
ratings - false
downloaded - true
download_link - true
last_updated - true
homepage - true
tags - true
template - true
parent - false
versions - false
screenshot_url - true
active_installs - false

If i read it correctly, for example screenshot should be screenshot_url, in fact when I've changed it and set to false, the themes had no screenshot, as expected.

Other examples: downloadLink should be download_link, there's no slug or requires, etc. Some of the currently used fields seems the ones for plugins to me, for example num_ratings is used by the plugins API but there's no such a field in the Themes API doc, unless it's undocumented.

Change History (4)

#1 @ocean90
3 years ago

  • Keywords needs-patch added

@afercia If you're interested in the correct arguments you should take a look at the DocBlock of themes_api() or https://developer.wordpress.org/reference/functions/themes_api/.

#2 @afercia
3 years ago

Thanks @ocean90 yep I see now the old codex page is not updated (also, seems download_link is now downloadlink).

#3 @helen
3 years ago

  • Milestone 4.7 deleted
  • Resolution set to invalid
  • Status changed from new to closed

Closing as invalid since the feature isn't in core. Referenced back on #37661.

#4 @celloexpressions
3 years ago

It looks like that documentation is also somewhat inaccurate. This will need further investigation by the Meta team to determine what the correct fields are/should be, and the documentation needs to be updated accordingly. num_ratings is a themes field, for example, and including extended_author throws a 500 error.

For now, see https://github.com/xwp/wordpress-develop/pull/216/commits/27525bc312de4183cb711df28dbef25a858d057b.

Note: See TracTickets for help on using tickets.