Plugin Directory

Changeset 3042570


Ignore:
Timestamp:
02/28/2024 12:46:43 PM (2 years ago)
Author:
glotpress
Message:

Update to version 4.0.0-beta.3 from GitHub

Location:
glotpress
Files:
42 edited
1 copied

Legend:

Unmodified
Added
Removed
  • glotpress/tags/4.0.0-beta.3/CHANGELOG.md

    r3027320 r3042570  
    11All notable changes to this project will be documented in this file.
    22This project adheres to [Semantic Versioning](http://semver.org/).
     3
     4## [4.0.0-beta.3] (February 28, 2024)
     5
     6**Features**
     7* Add a 'gp_before_translation_table' hook ([#1792])
     8
     9**Bugfixes**
     10
     11* Add trailing slash to current_url to fix matching URLs without trailing slash ([#1785])
     12* Breadcrumbs: Improve consistency across all content types ([#1789])
     13* Glossary: Match single word entries of parts of speech that have no suffix rules. ([#1791])
     14* Fix redirecting URL with query args ([#1797])
     15* Add the breadcrumbs for the "New project" actions ([#1800])
     16* Make the glossary regex more deterministic ([#1801])
    317
    418## [4.0.0-beta.2] (January 26, 2024)
     
    629643
    630644[Unreleased]: https://github.com/GlotPress/GlotPress/compare/3.0.0...HEAD
     645[4.0.0-beta.3]: https://github.com/GlotPress/GlotPress/compare/4.0.0-beta.2...4.0.0-beta.3
    631646[4.0.0-beta.2]: https://github.com/GlotPress/GlotPress/compare/4.0.0-beta.1...4.0.0-beta.2
    632647[4.0.0-beta.1]: https://github.com/GlotPress/GlotPress/compare/4.0.0-alpha.11...4.0.0-beta.1
     
    793808[#1779]: https://github.com/GlotPress/GlotPress/pull/1779
    794809[#1745]: https://github.com/GlotPress/GlotPress/pull/1745
     810[#1801]: https://github.com/GlotPress/GlotPress/pull/1801
     811[#1798]: https://github.com/GlotPress/GlotPress/pull/1798
     812[#1800]: https://github.com/GlotPress/GlotPress/pull/1800
     813[#1797]: https://github.com/GlotPress/GlotPress/pull/1797
     814[#1785]: https://github.com/GlotPress/GlotPress/pull/1785
     815[#1791]: https://github.com/GlotPress/GlotPress/pull/1791
     816[#1789]: https://github.com/GlotPress/GlotPress/pull/1789
     817[#1796]: https://github.com/GlotPress/GlotPress/pull/1796
     818[#1786]: https://github.com/GlotPress/GlotPress/pull/1786
     819[#1792]: https://github.com/GlotPress/GlotPress/pull/1792
  • glotpress/tags/4.0.0-beta.3/glotpress.php

    r3027320 r3042570  
    44 * Plugin URI: https://wordpress.org/plugins/glotpress/
    55 * Description: GlotPress is a tool to help translators collaborate.
    6  * Version: 4.0.0-beta.2
     6 * Version: 4.0.0-beta.3
    77 * Requires at least: 4.6
    88 * Tested up to: 6.4
     
    3030 */
    3131
    32 define( 'GP_VERSION', '4.0.0-beta.2' );
     32define( 'GP_VERSION', '4.0.0-beta.3' );
    3333define( 'GP_DB_VERSION', '980' );
    3434define( 'GP_CACHE_VERSION', '3.0' );
  • glotpress/tags/4.0.0-beta.3/gp-includes/route.php

    r2296035 r3042570  
    2828    public function __construct() {
    2929
     30        // Make sure that the current URL has a trailing slash.
     31        add_action( 'gp_before_request', array( $this, 'check_uri_trailing_slash' ) );
    3032    }
    3133
     
    358360        return status_header( $status );
    359361    }
     362
     363    /**
     364     * Check if the current URL has trailing slash. If not, redirect to trailed slash URL.
     365     *
     366     * @since 4.0.0
     367     */
     368    public function check_uri_trailing_slash() {
     369
     370        // Current URL.
     371        $current_uri = wp_parse_url( gp_url_current() );
     372
     373        // URL path.
     374        $current_path = $current_uri['path'];
     375
     376        // If the current path has no trailing slash, redirect to path with trailing slash.
     377        if ( trailingslashit( $current_path ) !== $current_path ) {
     378
     379            // Add trailing slash to redirect URL.
     380            $redirect_url = trailingslashit( $current_path );
     381
     382            // Include any existing query.
     383            if ( isset( $current_uri['query'] ) ) {
     384                $redirect_url .= '?' . $current_uri['query'];
     385            }
     386
     387            // Redirect to URL with trailing slash.
     388            $this->redirect( $redirect_url );
     389        }
     390    }
    360391}
  • glotpress/tags/4.0.0-beta.3/gp-includes/template.php

    r2785382 r3042570  
    254254    $links[]        = empty( $path_from_root ) ? __( 'Projects', 'glotpress' ) : gp_link_get( gp_url( '/projects' ), __( 'Projects', 'glotpress' ) );
    255255    foreach ( $path_from_root as $project ) {
    256         $links[] = gp_link_project_get( $project, esc_html( $project->name ) );
     256        if ( ! is_null( $project->id ) ) {
     257            $links[] = gp_link_project_get( $project, esc_html( $project->name ) );
     258        }
    257259    }
    258260    return $links;
    259261}
    260262
    261 function gp_breadcrumb_project( $project ) {
    262     return gp_breadcrumb( gp_project_links_from_root( $project ) );
     263/**
     264 * Get project breadcrumb.
     265 *
     266 * @since 4.0.0   New $extra_items array to append items like Translation Set, Project Glossary or the current action. The last item has no link.
     267 *                If project ID is '0', set base locales link to breadcrumb.
     268 *
     269 * @param GP_Project $project       GlotPress Project object.
     270 * @param array      $extra_items   Array of additional items to add to the breadcrumb.
     271 *
     272 * @return string   HTML of the breadcrumb.
     273 */
     274function gp_breadcrumb_project( $project, $extra_items = array() ) {
     275
     276    // If is a translation project, get the links. If is a virtual project with ID '0' for glossary, return base Locale for breadcrumb.
     277    $breadcrumb = 0 !== $project->id ? gp_project_links_from_root( $project ) : array( gp_link_get( gp_url( '/languages' ), __( 'Locales', 'glotpress' ) ) );
     278
     279    // If no extra items, the last breadcrumb item is the project name with no link.
     280    if ( empty( $extra_items ) ) {
     281        end( $breadcrumb );
     282        $last_key = key( $breadcrumb );
     283
     284        $breadcrumb[ $last_key ] = $project->name;
     285    }
     286
     287    // Add extra items.
     288    $breadcrumb = array_merge( $breadcrumb, $extra_items );
     289    return gp_breadcrumb( $breadcrumb );
    263290}
    264291
  • glotpress/tags/4.0.0-beta.3/gp-templates/glossary-delete.php

    r2699206 r3042570  
    99
    1010gp_title( __( 'Delete glossary < GlotPress', 'glotpress' ) );
    11 gp_breadcrumb(
     11gp_breadcrumb_project(
     12    $project,
    1213    array(
    13         gp_project_links_from_root( $project ),
    1414        gp_link_get( gp_url_project_locale( $project->path, $locale->slug, $translation_set->slug ), $translation_set->name ),
    15         gp_link_get( gp_url_join( gp_url_project_locale( $project->path, $locale->slug, $translation_set->slug ), '/glossary' ), __( 'Glossary', 'glotpress' ) ),
     15        // Check if is Global or Project Glossary.
     16        gp_link_get( gp_url_project_locale( $project->path, $locale->slug, $translation_set->slug ) . 'glossary', 0 === $project->id ? __( 'Locale Glossary', 'glotpress' ) : __( 'Project Glossary', 'glotpress' ), ),
    1617        __( 'Delete', 'glotpress' ),
    1718    )
  • glotpress/tags/4.0.0-beta.3/gp-templates/glossary-edit.php

    r2699206 r3042570  
    11<?php
    2 gp_title( __( 'Edit Glossary &lt; GlotPress', 'glotpress' ) );
    3 gp_breadcrumb(
     2gp_title( __( 'Edit glossary &lt; GlotPress', 'glotpress' ) );
     3gp_breadcrumb_project(
     4    $project,
    45    array(
    5         gp_project_links_from_root( $project ),
    66        gp_link_get( gp_url_project_locale( $project->path, $locale->slug, $translation_set->slug ), $translation_set->name ),
    7         gp_link_get( gp_url_project_locale( $project->path, $locale->slug, $translation_set->slug ) . '/glossary', __( 'Glossary', 'glotpress' ) ),
     7        // Check if is Global or Project Glossary.
     8        gp_link_get( gp_url_project_locale( $project->path, $locale->slug, $translation_set->slug ) . 'glossary', 0 === $project->id ? __( 'Locale Glossary', 'glotpress' ) : __( 'Project Glossary', 'glotpress' ), ),
    89        __( 'Edit', 'glotpress' ),
    910    )
     
    1213?>
    1314
    14 <h2><?php _e( 'Edit Glossary', 'glotpress' ); ?></h2>
     15<h2><?php _e( 'Edit glossary', 'glotpress' ); ?></h2>
    1516
    1617<form action="" method="post">
  • glotpress/tags/4.0.0-beta.3/gp-templates/glossary-import.php

    r2785382 r3042570  
    11<?php
    22gp_title( __( 'Import into Glossary &lt; GlotPress', 'glotpress' ) );
    3 gp_breadcrumb(
     3gp_breadcrumb_project(
     4    $project,
    45    array(
    5         gp_project_links_from_root( $project ),
    66        gp_link_get( gp_url_project_locale( $project->path, $locale->slug, $translation_set->slug ), $translation_set->name ),
    7         gp_link_get( gp_url_project_locale( $project->path, $locale->slug, $translation_set->slug ) . '/glossary', __( 'Glossary', 'glotpress' ) ),
     7        // Check if is Global or Project Glossary.
     8        gp_link_get( gp_url_project_locale( $project->path, $locale->slug, $translation_set->slug ) . 'glossary', 0 === $project->id ? __( 'Locale Glossary', 'glotpress' ) : __( 'Project Glossary', 'glotpress' ), ),
    89        __( 'Import', 'glotpress' ),
    910    )
  • glotpress/tags/4.0.0-beta.3/gp-templates/glossary-new.php

    r2699206 r3042570  
    11<?php
    22gp_title( __( 'Create New Glossary &lt; GlotPress', 'glotpress' ) );
    3 gp_breadcrumb(
     3gp_breadcrumb_project(
     4    $project,
    45    array(
    5         gp_project_links_from_root( $project ),
    66        gp_link_get( gp_url_project_locale( $project->path, $locale->slug, $translation_set->slug ), $translation_set->name ),
    7         __( 'Create Glossary', 'glotpress' ),
     7        __( 'Create New Glossary', 'glotpress' ),
    88    )
    99);
  • glotpress/tags/4.0.0-beta.3/gp-templates/glossary-view.php

    r2979634 r3042570  
    11<?php
    22gp_title( __( 'View Glossary &lt; GlotPress', 'glotpress' ) );
    3 gp_breadcrumb(
     3gp_breadcrumb_project(
     4    $project,
    45    array(
    56        // Show Projects if is projects path, show Locales if is locales path.
    6         gp_project_links_from_root( $project ) ? gp_project_links_from_root( $project ) : gp_link_get( gp_url( '/languages' ), __( 'Locales', 'glotpress' ) ),
    77        gp_link_get( gp_url_project_locale( $project->path, $locale->slug, $translation_set->slug ), $translation_set->name ),
    88        0 === $project->id ? __( 'Locale Glossary', 'glotpress' ) : __( 'Project Glossary', 'glotpress' ),
  • glotpress/tags/4.0.0-beta.3/gp-templates/helper-functions.php

    r3027320 r3042570  
    409409        $suffixes = array_filter( $suffixes, fn( $value ) => ! empty( $value ) );
    410410
     411        // Add suffixes for part_of_speech with rules.
    411412        if ( ! empty( $suffixes[ $type ] ) ) {
    412413            // Loop through rules.
     
    463464                }
    464465            }
     466        } else {
     467            // Add match for part_of_speech without any suffix rules.
     468            $glossary_entries_suffixes[ $term ] = array();
    465469        }
    466470    }
     
    545549            }
    546550        }
     551        // Make the regex more deterministic.
     552        ksort( $regex_group );
    547553
    548554        // Build the regular expression.
  • glotpress/tags/4.0.0-beta.3/gp-templates/project-branch.php

    r2699206 r3042570  
    77    )
    88);
    9 gp_breadcrumb_project( $project );
     9gp_breadcrumb_project(
     10    $project,
     11    array(
     12        __( 'Branch', 'glotpress' ),
     13    )
     14);
    1015gp_tmpl_header();
    1116?>
  • glotpress/tags/4.0.0-beta.3/gp-templates/project-delete.php

    r2699206 r3042570  
    1515    )
    1616);
    17 gp_breadcrumb_project( $project );
     17gp_breadcrumb_project(
     18    $project,
     19    array(
     20        __( 'Delete', 'glotpress' ),
     21    )
     22);
    1823gp_tmpl_header();
    1924?>
  • glotpress/tags/4.0.0-beta.3/gp-templates/project-edit.php

    r2699206 r3042570  
    77    )
    88);
    9 gp_breadcrumb_project( $project );
     9gp_breadcrumb_project(
     10    $project,
     11    array(
     12        __( 'Edit', 'glotpress' ),
     13    )
     14);
    1015gp_tmpl_header();
    1116?>
  • glotpress/tags/4.0.0-beta.3/gp-templates/project-import.php

    r3026779 r3042570  
    77    );
    88    $return_link = gp_url_project( $project );
    9     gp_breadcrumb_project( $project );
     9    gp_breadcrumb_project(
     10        $project,
     11        array(
     12            __( 'Import Originals', 'glotpress' ),
     13        )
     14    );
    1015} else {
    1116    $gp_title = sprintf(
     
    1520    );
    1621    $return_link = gp_url_project_locale( $project, $locale->slug, $translation_set->slug );
    17     gp_breadcrumb(
     22    gp_breadcrumb_project(
     23        $project,
    1824        array(
    19             gp_project_links_from_root( $project ),
    2025            gp_link_get( $return_link, $translation_set->name ),
     26            __( 'Import Translations', 'glotpress' ),
    2127        )
    2228    );
  • glotpress/tags/4.0.0-beta.3/gp-templates/project-mass-create-sets.php

    r2699206 r3042570  
    77    )
    88);
    9 gp_breadcrumb_project( $project );
     9gp_breadcrumb_project(
     10    $project,
     11    array(
     12        __( 'Mass-create Translation Sets', 'glotpress' ),
     13    )
     14);
    1015gp_enqueue_scripts( 'gp-mass-create-sets-page' );
    1116wp_localize_script(
  • glotpress/tags/4.0.0-beta.3/gp-templates/project-new.php

    r2699206 r3042570  
    11<?php
    22gp_title( __( 'Create New Project &lt; GlotPress', 'glotpress' ) );
    3 gp_breadcrumb(
     3gp_breadcrumb_project(
     4    $project,
    45    array(
    56        __( 'Create New Project', 'glotpress' ),
  • glotpress/tags/4.0.0-beta.3/gp-templates/project-permissions.php

    r2699206 r3042570  
    77    )
    88);
    9 gp_breadcrumb_project( $project );
     9gp_breadcrumb_project(
     10    $project,
     11    array(
     12        __( 'Permissions', 'glotpress' ),
     13    )
     14);
    1015gp_tmpl_header();
    1116?>
  • glotpress/tags/4.0.0-beta.3/gp-templates/translation-set-delete.php

    r2699206 r3042570  
    1616    )
    1717);
    18 gp_breadcrumb(
     18gp_breadcrumb_project(
     19    $project,
    1920    array(
    20         gp_project_links_from_root( $project ),
    21         gp_link_get( $url, $locale->english_name . ( 'default' !== $set->slug ? ' ' . $set->name : '' ) ),
     21        gp_link_get( $url, $locale->english_name . 'default' !== $set->slug ? ' ' . $set->name : '' ),
     22        __( 'Delete', 'glotpress' ),
    2223    )
    2324);
  • glotpress/tags/4.0.0-beta.3/gp-templates/translation-set-edit.php

    r2699206 r3042570  
    88    )
    99);
    10 gp_breadcrumb(
     10gp_breadcrumb_project(
     11    $project,
    1112    array(
    12         gp_project_links_from_root( $project ),
    1313        gp_link_get( $url, $locale->english_name . 'default' !== $set->slug ? ' ' . $set->name : '' ),
     14        __( 'Edit', 'glotpress' ),
    1415    )
    1516);
  • glotpress/tags/4.0.0-beta.3/gp-templates/translation-set-new.php

    r2699206 r3042570  
    11<?php
    22gp_title( __( 'Create New Translation Set &lt; GlotPress', 'glotpress' ) );
    3 $project ? gp_breadcrumb_project( $project ) : gp_breadcrumb( array( __( 'New Translation Set', 'glotpress' ) ) );
     3if ( $project ) {
     4    gp_breadcrumb_project(
     5        $project,
     6        array(
     7            __( 'Create New Translation Set', 'glotpress' ),
     8        )
     9    );
     10} else {
     11    gp_breadcrumb(
     12        array(
     13            __( 'Create New Translation Set', 'glotpress' ),
     14        )
     15    );
     16}
    417
    518// jQuery is required for the 'translation-set-form' template.
  • glotpress/tags/4.0.0-beta.3/gp-templates/translations.php

    r3026779 r3042570  
    2121    $inactive_bubble = ' <span class="inactive bubble">' . __( 'Inactive', 'glotpress' ) . '</span>';
    2222}
    23 
    24 gp_breadcrumb(
     23gp_breadcrumb_project(
     24    $project,
    2525    array(
    26         gp_project_links_from_root( $project ),
    27         gp_link_get( $url, $translation_set->name ) . $inactive_bubble,
     26        $translation_set->name . $inactive_bubble,
    2827    )
    2928);
     
    430429
    431430<?php $class_rtl = 'rtl' === $locale->text_direction ? ' translation-sets-rtl' : ''; ?>
     431<?php
     432/**
     433 * Fires before the translation table has been displayed.
     434 *
     435 * @since 4.0.0
     436 *
     437 * @param array $def_vars Variables defined in the template.
     438 */
     439do_action( 'gp_before_translation_table', get_defined_vars() );
     440?>
    432441<table id="translations" class="<?php echo esc_attr( apply_filters( 'gp_translation_table_classes', 'gp-table translations ' . $class_rtl, get_defined_vars() ) ); ?>">
    433442    <thead>
  • glotpress/trunk/CHANGELOG.md

    r3027320 r3042570  
    11All notable changes to this project will be documented in this file.
    22This project adheres to [Semantic Versioning](http://semver.org/).
     3
     4## [4.0.0-beta.3] (February 28, 2024)
     5
     6**Features**
     7* Add a 'gp_before_translation_table' hook ([#1792])
     8
     9**Bugfixes**
     10
     11* Add trailing slash to current_url to fix matching URLs without trailing slash ([#1785])
     12* Breadcrumbs: Improve consistency across all content types ([#1789])
     13* Glossary: Match single word entries of parts of speech that have no suffix rules. ([#1791])
     14* Fix redirecting URL with query args ([#1797])
     15* Add the breadcrumbs for the "New project" actions ([#1800])
     16* Make the glossary regex more deterministic ([#1801])
    317
    418## [4.0.0-beta.2] (January 26, 2024)
     
    629643
    630644[Unreleased]: https://github.com/GlotPress/GlotPress/compare/3.0.0...HEAD
     645[4.0.0-beta.3]: https://github.com/GlotPress/GlotPress/compare/4.0.0-beta.2...4.0.0-beta.3
    631646[4.0.0-beta.2]: https://github.com/GlotPress/GlotPress/compare/4.0.0-beta.1...4.0.0-beta.2
    632647[4.0.0-beta.1]: https://github.com/GlotPress/GlotPress/compare/4.0.0-alpha.11...4.0.0-beta.1
     
    793808[#1779]: https://github.com/GlotPress/GlotPress/pull/1779
    794809[#1745]: https://github.com/GlotPress/GlotPress/pull/1745
     810[#1801]: https://github.com/GlotPress/GlotPress/pull/1801
     811[#1798]: https://github.com/GlotPress/GlotPress/pull/1798
     812[#1800]: https://github.com/GlotPress/GlotPress/pull/1800
     813[#1797]: https://github.com/GlotPress/GlotPress/pull/1797
     814[#1785]: https://github.com/GlotPress/GlotPress/pull/1785
     815[#1791]: https://github.com/GlotPress/GlotPress/pull/1791
     816[#1789]: https://github.com/GlotPress/GlotPress/pull/1789
     817[#1796]: https://github.com/GlotPress/GlotPress/pull/1796
     818[#1786]: https://github.com/GlotPress/GlotPress/pull/1786
     819[#1792]: https://github.com/GlotPress/GlotPress/pull/1792
  • glotpress/trunk/glotpress.php

    r3027320 r3042570  
    44 * Plugin URI: https://wordpress.org/plugins/glotpress/
    55 * Description: GlotPress is a tool to help translators collaborate.
    6  * Version: 4.0.0-beta.2
     6 * Version: 4.0.0-beta.3
    77 * Requires at least: 4.6
    88 * Tested up to: 6.4
     
    3030 */
    3131
    32 define( 'GP_VERSION', '4.0.0-beta.2' );
     32define( 'GP_VERSION', '4.0.0-beta.3' );
    3333define( 'GP_DB_VERSION', '980' );
    3434define( 'GP_CACHE_VERSION', '3.0' );
  • glotpress/trunk/gp-includes/route.php

    r2296035 r3042570  
    2828    public function __construct() {
    2929
     30        // Make sure that the current URL has a trailing slash.
     31        add_action( 'gp_before_request', array( $this, 'check_uri_trailing_slash' ) );
    3032    }
    3133
     
    358360        return status_header( $status );
    359361    }
     362
     363    /**
     364     * Check if the current URL has trailing slash. If not, redirect to trailed slash URL.
     365     *
     366     * @since 4.0.0
     367     */
     368    public function check_uri_trailing_slash() {
     369
     370        // Current URL.
     371        $current_uri = wp_parse_url( gp_url_current() );
     372
     373        // URL path.
     374        $current_path = $current_uri['path'];
     375
     376        // If the current path has no trailing slash, redirect to path with trailing slash.
     377        if ( trailingslashit( $current_path ) !== $current_path ) {
     378
     379            // Add trailing slash to redirect URL.
     380            $redirect_url = trailingslashit( $current_path );
     381
     382            // Include any existing query.
     383            if ( isset( $current_uri['query'] ) ) {
     384                $redirect_url .= '?' . $current_uri['query'];
     385            }
     386
     387            // Redirect to URL with trailing slash.
     388            $this->redirect( $redirect_url );
     389        }
     390    }
    360391}
  • glotpress/trunk/gp-includes/template.php

    r2785382 r3042570  
    254254    $links[]        = empty( $path_from_root ) ? __( 'Projects', 'glotpress' ) : gp_link_get( gp_url( '/projects' ), __( 'Projects', 'glotpress' ) );
    255255    foreach ( $path_from_root as $project ) {
    256         $links[] = gp_link_project_get( $project, esc_html( $project->name ) );
     256        if ( ! is_null( $project->id ) ) {
     257            $links[] = gp_link_project_get( $project, esc_html( $project->name ) );
     258        }
    257259    }
    258260    return $links;
    259261}
    260262
    261 function gp_breadcrumb_project( $project ) {
    262     return gp_breadcrumb( gp_project_links_from_root( $project ) );
     263/**
     264 * Get project breadcrumb.
     265 *
     266 * @since 4.0.0   New $extra_items array to append items like Translation Set, Project Glossary or the current action. The last item has no link.
     267 *                If project ID is '0', set base locales link to breadcrumb.
     268 *
     269 * @param GP_Project $project       GlotPress Project object.
     270 * @param array      $extra_items   Array of additional items to add to the breadcrumb.
     271 *
     272 * @return string   HTML of the breadcrumb.
     273 */
     274function gp_breadcrumb_project( $project, $extra_items = array() ) {
     275
     276    // If is a translation project, get the links. If is a virtual project with ID '0' for glossary, return base Locale for breadcrumb.
     277    $breadcrumb = 0 !== $project->id ? gp_project_links_from_root( $project ) : array( gp_link_get( gp_url( '/languages' ), __( 'Locales', 'glotpress' ) ) );
     278
     279    // If no extra items, the last breadcrumb item is the project name with no link.
     280    if ( empty( $extra_items ) ) {
     281        end( $breadcrumb );
     282        $last_key = key( $breadcrumb );
     283
     284        $breadcrumb[ $last_key ] = $project->name;
     285    }
     286
     287    // Add extra items.
     288    $breadcrumb = array_merge( $breadcrumb, $extra_items );
     289    return gp_breadcrumb( $breadcrumb );
    263290}
    264291
  • glotpress/trunk/gp-templates/glossary-delete.php

    r2699206 r3042570  
    99
    1010gp_title( __( 'Delete glossary &lt; GlotPress', 'glotpress' ) );
    11 gp_breadcrumb(
     11gp_breadcrumb_project(
     12    $project,
    1213    array(
    13         gp_project_links_from_root( $project ),
    1414        gp_link_get( gp_url_project_locale( $project->path, $locale->slug, $translation_set->slug ), $translation_set->name ),
    15         gp_link_get( gp_url_join( gp_url_project_locale( $project->path, $locale->slug, $translation_set->slug ), '/glossary' ), __( 'Glossary', 'glotpress' ) ),
     15        // Check if is Global or Project Glossary.
     16        gp_link_get( gp_url_project_locale( $project->path, $locale->slug, $translation_set->slug ) . 'glossary', 0 === $project->id ? __( 'Locale Glossary', 'glotpress' ) : __( 'Project Glossary', 'glotpress' ), ),
    1617        __( 'Delete', 'glotpress' ),
    1718    )
  • glotpress/trunk/gp-templates/glossary-edit.php

    r2699206 r3042570  
    11<?php
    2 gp_title( __( 'Edit Glossary &lt; GlotPress', 'glotpress' ) );
    3 gp_breadcrumb(
     2gp_title( __( 'Edit glossary &lt; GlotPress', 'glotpress' ) );
     3gp_breadcrumb_project(
     4    $project,
    45    array(
    5         gp_project_links_from_root( $project ),
    66        gp_link_get( gp_url_project_locale( $project->path, $locale->slug, $translation_set->slug ), $translation_set->name ),
    7         gp_link_get( gp_url_project_locale( $project->path, $locale->slug, $translation_set->slug ) . '/glossary', __( 'Glossary', 'glotpress' ) ),
     7        // Check if is Global or Project Glossary.
     8        gp_link_get( gp_url_project_locale( $project->path, $locale->slug, $translation_set->slug ) . 'glossary', 0 === $project->id ? __( 'Locale Glossary', 'glotpress' ) : __( 'Project Glossary', 'glotpress' ), ),
    89        __( 'Edit', 'glotpress' ),
    910    )
     
    1213?>
    1314
    14 <h2><?php _e( 'Edit Glossary', 'glotpress' ); ?></h2>
     15<h2><?php _e( 'Edit glossary', 'glotpress' ); ?></h2>
    1516
    1617<form action="" method="post">
  • glotpress/trunk/gp-templates/glossary-import.php

    r2785382 r3042570  
    11<?php
    22gp_title( __( 'Import into Glossary &lt; GlotPress', 'glotpress' ) );
    3 gp_breadcrumb(
     3gp_breadcrumb_project(
     4    $project,
    45    array(
    5         gp_project_links_from_root( $project ),
    66        gp_link_get( gp_url_project_locale( $project->path, $locale->slug, $translation_set->slug ), $translation_set->name ),
    7         gp_link_get( gp_url_project_locale( $project->path, $locale->slug, $translation_set->slug ) . '/glossary', __( 'Glossary', 'glotpress' ) ),
     7        // Check if is Global or Project Glossary.
     8        gp_link_get( gp_url_project_locale( $project->path, $locale->slug, $translation_set->slug ) . 'glossary', 0 === $project->id ? __( 'Locale Glossary', 'glotpress' ) : __( 'Project Glossary', 'glotpress' ), ),
    89        __( 'Import', 'glotpress' ),
    910    )
  • glotpress/trunk/gp-templates/glossary-new.php

    r2699206 r3042570  
    11<?php
    22gp_title( __( 'Create New Glossary &lt; GlotPress', 'glotpress' ) );
    3 gp_breadcrumb(
     3gp_breadcrumb_project(
     4    $project,
    45    array(
    5         gp_project_links_from_root( $project ),
    66        gp_link_get( gp_url_project_locale( $project->path, $locale->slug, $translation_set->slug ), $translation_set->name ),
    7         __( 'Create Glossary', 'glotpress' ),
     7        __( 'Create New Glossary', 'glotpress' ),
    88    )
    99);
  • glotpress/trunk/gp-templates/glossary-view.php

    r2979634 r3042570  
    11<?php
    22gp_title( __( 'View Glossary &lt; GlotPress', 'glotpress' ) );
    3 gp_breadcrumb(
     3gp_breadcrumb_project(
     4    $project,
    45    array(
    56        // Show Projects if is projects path, show Locales if is locales path.
    6         gp_project_links_from_root( $project ) ? gp_project_links_from_root( $project ) : gp_link_get( gp_url( '/languages' ), __( 'Locales', 'glotpress' ) ),
    77        gp_link_get( gp_url_project_locale( $project->path, $locale->slug, $translation_set->slug ), $translation_set->name ),
    88        0 === $project->id ? __( 'Locale Glossary', 'glotpress' ) : __( 'Project Glossary', 'glotpress' ),
  • glotpress/trunk/gp-templates/helper-functions.php

    r3027320 r3042570  
    409409        $suffixes = array_filter( $suffixes, fn( $value ) => ! empty( $value ) );
    410410
     411        // Add suffixes for part_of_speech with rules.
    411412        if ( ! empty( $suffixes[ $type ] ) ) {
    412413            // Loop through rules.
     
    463464                }
    464465            }
     466        } else {
     467            // Add match for part_of_speech without any suffix rules.
     468            $glossary_entries_suffixes[ $term ] = array();
    465469        }
    466470    }
     
    545549            }
    546550        }
     551        // Make the regex more deterministic.
     552        ksort( $regex_group );
    547553
    548554        // Build the regular expression.
  • glotpress/trunk/gp-templates/project-branch.php

    r2699206 r3042570  
    77    )
    88);
    9 gp_breadcrumb_project( $project );
     9gp_breadcrumb_project(
     10    $project,
     11    array(
     12        __( 'Branch', 'glotpress' ),
     13    )
     14);
    1015gp_tmpl_header();
    1116?>
  • glotpress/trunk/gp-templates/project-delete.php

    r2699206 r3042570  
    1515    )
    1616);
    17 gp_breadcrumb_project( $project );
     17gp_breadcrumb_project(
     18    $project,
     19    array(
     20        __( 'Delete', 'glotpress' ),
     21    )
     22);
    1823gp_tmpl_header();
    1924?>
  • glotpress/trunk/gp-templates/project-edit.php

    r2699206 r3042570  
    77    )
    88);
    9 gp_breadcrumb_project( $project );
     9gp_breadcrumb_project(
     10    $project,
     11    array(
     12        __( 'Edit', 'glotpress' ),
     13    )
     14);
    1015gp_tmpl_header();
    1116?>
  • glotpress/trunk/gp-templates/project-import.php

    r3026779 r3042570  
    77    );
    88    $return_link = gp_url_project( $project );
    9     gp_breadcrumb_project( $project );
     9    gp_breadcrumb_project(
     10        $project,
     11        array(
     12            __( 'Import Originals', 'glotpress' ),
     13        )
     14    );
    1015} else {
    1116    $gp_title = sprintf(
     
    1520    );
    1621    $return_link = gp_url_project_locale( $project, $locale->slug, $translation_set->slug );
    17     gp_breadcrumb(
     22    gp_breadcrumb_project(
     23        $project,
    1824        array(
    19             gp_project_links_from_root( $project ),
    2025            gp_link_get( $return_link, $translation_set->name ),
     26            __( 'Import Translations', 'glotpress' ),
    2127        )
    2228    );
  • glotpress/trunk/gp-templates/project-mass-create-sets.php

    r2699206 r3042570  
    77    )
    88);
    9 gp_breadcrumb_project( $project );
     9gp_breadcrumb_project(
     10    $project,
     11    array(
     12        __( 'Mass-create Translation Sets', 'glotpress' ),
     13    )
     14);
    1015gp_enqueue_scripts( 'gp-mass-create-sets-page' );
    1116wp_localize_script(
  • glotpress/trunk/gp-templates/project-new.php

    r2699206 r3042570  
    11<?php
    22gp_title( __( 'Create New Project &lt; GlotPress', 'glotpress' ) );
    3 gp_breadcrumb(
     3gp_breadcrumb_project(
     4    $project,
    45    array(
    56        __( 'Create New Project', 'glotpress' ),
  • glotpress/trunk/gp-templates/project-permissions.php

    r2699206 r3042570  
    77    )
    88);
    9 gp_breadcrumb_project( $project );
     9gp_breadcrumb_project(
     10    $project,
     11    array(
     12        __( 'Permissions', 'glotpress' ),
     13    )
     14);
    1015gp_tmpl_header();
    1116?>
  • glotpress/trunk/gp-templates/translation-set-delete.php

    r2699206 r3042570  
    1616    )
    1717);
    18 gp_breadcrumb(
     18gp_breadcrumb_project(
     19    $project,
    1920    array(
    20         gp_project_links_from_root( $project ),
    21         gp_link_get( $url, $locale->english_name . ( 'default' !== $set->slug ? ' ' . $set->name : '' ) ),
     21        gp_link_get( $url, $locale->english_name . 'default' !== $set->slug ? ' ' . $set->name : '' ),
     22        __( 'Delete', 'glotpress' ),
    2223    )
    2324);
  • glotpress/trunk/gp-templates/translation-set-edit.php

    r2699206 r3042570  
    88    )
    99);
    10 gp_breadcrumb(
     10gp_breadcrumb_project(
     11    $project,
    1112    array(
    12         gp_project_links_from_root( $project ),
    1313        gp_link_get( $url, $locale->english_name . 'default' !== $set->slug ? ' ' . $set->name : '' ),
     14        __( 'Edit', 'glotpress' ),
    1415    )
    1516);
  • glotpress/trunk/gp-templates/translation-set-new.php

    r2699206 r3042570  
    11<?php
    22gp_title( __( 'Create New Translation Set &lt; GlotPress', 'glotpress' ) );
    3 $project ? gp_breadcrumb_project( $project ) : gp_breadcrumb( array( __( 'New Translation Set', 'glotpress' ) ) );
     3if ( $project ) {
     4    gp_breadcrumb_project(
     5        $project,
     6        array(
     7            __( 'Create New Translation Set', 'glotpress' ),
     8        )
     9    );
     10} else {
     11    gp_breadcrumb(
     12        array(
     13            __( 'Create New Translation Set', 'glotpress' ),
     14        )
     15    );
     16}
    417
    518// jQuery is required for the 'translation-set-form' template.
  • glotpress/trunk/gp-templates/translations.php

    r3026779 r3042570  
    2121    $inactive_bubble = ' <span class="inactive bubble">' . __( 'Inactive', 'glotpress' ) . '</span>';
    2222}
    23 
    24 gp_breadcrumb(
     23gp_breadcrumb_project(
     24    $project,
    2525    array(
    26         gp_project_links_from_root( $project ),
    27         gp_link_get( $url, $translation_set->name ) . $inactive_bubble,
     26        $translation_set->name . $inactive_bubble,
    2827    )
    2928);
     
    430429
    431430<?php $class_rtl = 'rtl' === $locale->text_direction ? ' translation-sets-rtl' : ''; ?>
     431<?php
     432/**
     433 * Fires before the translation table has been displayed.
     434 *
     435 * @since 4.0.0
     436 *
     437 * @param array $def_vars Variables defined in the template.
     438 */
     439do_action( 'gp_before_translation_table', get_defined_vars() );
     440?>
    432441<table id="translations" class="<?php echo esc_attr( apply_filters( 'gp_translation_table_classes', 'gp-table translations ' . $class_rtl, get_defined_vars() ) ); ?>">
    433442    <thead>
Note: See TracChangeset for help on using the changeset viewer.