WordPress.org

Making WordPress.org

Changeset 10275


Ignore:
Timestamp:
09/17/2020 01:22:41 AM (15 months ago)
Author:
dd32
Message:

Rosetta: Prevent custom_links menu items being upgraded to the 'Get WordPress' button when they appear in the menu before the download link.

This was causing the Pirate translation site to have a Downloads menu item and a downloads button that pointed to the Theme Directory.

Fixes #5433.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/rosetta/inc/class-plugin.php

    r7530 r10275  
    3434    private function __construct() {
    3535        add_action( 'plugins_loaded', [ $this, 'plugins_loaded' ], 1 );
    36         add_action( 'wp_nav_menu_objects', [ $this, 'download_button_menu_item' ], 11 );
     36        add_filter( 'wp_nav_menu_objects', [ $this, 'download_button_menu_item' ], 11 );
    3737
    3838        $this->sites = [
     
    7373    public function download_button_menu_item( $menu_items ) {
    7474        foreach ( $menu_items as $menu_item ) {
    75             if ( false !== stripos( $menu_item->url, 'download/' ) || 'page-download.php' === get_page_template_slug( $menu_item->object_id ) ) {
     75            if (
     76                false !== stripos( $menu_item->url, 'download/' ) ||
     77                (
     78                    $menu_item->object_id &&
     79                    'post_type' == $menu_item->type &&
     80                    'page-download.php' === get_page_template_slug( $menu_item->object_id )
     81                )
     82            ) {
     83                $menu_item->ID      = -1; // Prevents the title being overwritten by the page title.
    7684                $menu_item->classes = array_merge( $menu_item->classes, ['button', 'button-primary', 'download'] );
    7785                $menu_item->title   = _x( 'Get WordPress', 'Menu title', 'rosetta' );
Note: See TracChangeset for help on using the changeset viewer.