Making WordPress.org


Ignore:
Timestamp:
07/17/2024 11:19:52 AM (23 months ago)
Author:
psrpinto
Message:

Translate: Sync "Translation Events" from GitHub

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-translation-events/includes/templates.php

    r13800 r13906  
    33namespace Wporg\TranslationEvents;
    44
     5/**
     6 * Legacy (non-theme) templates.
     7 */
    58class Templates {
    6     private static bool $use_new_design = false;
    7 
    8     public static function use_new_design( bool $also_in_production = false ): void {
    9         if ( $also_in_production ) {
    10             // If it's enabled for production, it's also enabled for development, so it's always enabled.
    11             self::$use_new_design = true;
    12         } else {
    13             // Only enable if new design has been explicitly enabled.
    14             self::$use_new_design = defined( 'TRANSLATION_EVENTS_NEW_DESIGN' ) && TRANSLATION_EVENTS_NEW_DESIGN;
    15         }
    16 
    17         if ( self::$use_new_design ) {
    18             wp_register_style(
    19                 'translation-events-new-design-css',
    20                 plugins_url( 'assets/css/new-design.css', __DIR__ ),
    21                 array( 'dashicons' ),
    22                 filemtime( __DIR__ . '/../assets/css/new-design.css' )
    23             );
    24             gp_enqueue_styles( 'translation-events-new-design-css' );
    25         }
    26     }
    27 
    28     public static function render( string $template, array $data = array() ) {
    29         $template_path = __DIR__ . '/../templates/';
    30         if ( self::$use_new_design ) {
    31             $template_path = $template_path . 'new-design/';
    32         }
    33 
    34         gp_tmpl_load( $template, $data, $template_path );
    35     }
     9    private const LEGACY_TEMPLATE_DIRECTORY = __DIR__ . '/../templates/';
    3610
    3711    public static function header( array $data = array() ) {
     
    4317    }
    4418
    45     public static function part( string $template, array $data ) {
     19    public static function part( string $template, array $data = array() ) {
    4620        self::render( "parts/$template", $data );
    4721    }
     22
     23    public static function render( string $template, array $data = array() ) {
     24        gp_tmpl_load( $template, $data, self::LEGACY_TEMPLATE_DIRECTORY );
     25    }
    4826}
Note: See TracChangeset for help on using the changeset viewer.