Making WordPress.org

Changeset 6451


Ignore:
Timestamp:
01/28/2018 04:27:38 PM (7 years ago)
Author:
ocean90
Message:

Translate: Extend translation editor with a link to view the original in the consistency tool.

Fixes #2915.

File:
1 edited

Legend:

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

    r5601 r6451  
    4343        add_action( 'after_setup_theme', array( $this, 'after_setup_theme' ) );
    4444        add_filter( 'body_class', array( $this, 'wporg_add_make_site_body_class' ) );
     45        add_filter( 'gp_translation_row_template_more_links', array( $this, 'add_consistency_tool_link' ), 10, 5 );
    4546
    4647        // Toolbar.
     
    5859            $this->register_cli_commands();
    5960        }
     61    }
     62
     63    /**
     64     * Adds a link to view originals in consistency tool.
     65     *
     66     * @param array              $more_links      The links to be output.
     67     * @param GP_Project         $project         Project object.
     68     * @param GP_Locale          $locale          Locale object.
     69     * @param GP_Translation_Set $translation_set Translation Set object.
     70     * @param GP_Translation     $translation     Translation object.
     71     */
     72    public function add_consistency_tool_link( $more_links, $project, $locale, $translation_set, $translation ) {
     73        $consistency_tool_url = add_query_arg(
     74            [
     75                'search' => urlencode( $translation->singular ),
     76                'set'    => urlencode( $locale->slug . '/' . $translation_set->slug ),
     77            ],
     78            home_url( '/consistency' )
     79        );
     80
     81        $more_links['consistency-tool'] = '<a href="' . esc_url( $consistency_tool_url ) . '">View original in consistency tool</a>';
     82
     83        return $more_links;
    6084    }
    6185
Note: See TracChangeset for help on using the changeset viewer.