Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions inc/packages/admin/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ function bootstrap() {
add_action( 'load-plugin-install.php', __NAMESPACE__ . '\\load_plugin_install' );
add_action( 'install_plugins_pre_plugin-information', __NAMESPACE__ . '\\maybe_hijack_plugin_info', 0 );
add_filter( 'plugins_api_result', __NAMESPACE__ . '\\alter_slugs', 10, 3 );
add_filter( 'plugins_api_result', __NAMESPACE__ . '\\sort_sections_in_api', 15, 1 );
add_filter( 'plugin_install_action_links', __NAMESPACE__ . '\\maybe_hijack_plugin_install_button', 10, 2 );
add_filter( 'plugin_install_description', __NAMESPACE__ . '\\maybe_add_data_to_description', 10, 2 );
add_action( 'wp_ajax_check_plugin_dependencies', __NAMESPACE__ . '\\set_slug_to_hashed' );
Expand Down Expand Up @@ -427,6 +428,32 @@ function alter_slugs( $res, $action, $args ) {
return $res;
}

/**
* Sort plugin modal tabs.
*
* Based on standard tab listing order.
*
* @param object|WP_Error $res Response object or WP_Error.
* @return object|WP_Error
*/
function sort_sections_in_api( $res ) {
$ordered_sections = [
'description',
'installation',
'faq',
'screenshots',
'changelog',
'upgrade_notice',
'other_notes',
];
if ( property_exists( $res, 'sections' ) ) {
$properly_ordered = array_merge( array_fill_keys( $ordered_sections, '' ), $res->sections );
$res->sections = array_filter( $properly_ordered );
}

return $res;
}

/**
* Override the install button, for bridged plugins.
*
Expand Down