[ Index ]

PHP Cross Reference of GlotPress

title

Body

[close]

/gp-templates/ -> translations.php (source)

   1  <?php
   2  /**
   3   * Template for the translations table.
   4   *
   5   * @package    GlotPress
   6   * @subpackage Templates
   7   */
   8  
   9  /** @var GP_Translation_Set $translation_set */
  10  
  11  gp_title(
  12      sprintf(
  13          /* translators: 1: Translation set name. 2: Project name. */
  14          __( 'Translations &lt; %1$s &lt; %2$s &lt; GlotPress', 'glotpress' ),
  15          $translation_set->name,
  16          $project->name
  17      )
  18  );
  19  gp_breadcrumb(
  20      array(
  21          gp_project_links_from_root( $project ),
  22          gp_link_get( $url, $translation_set->name ),
  23      )
  24  );
  25  gp_enqueue_scripts( array( 'gp-editor', 'gp-translations-page' ) );
  26  wp_localize_script(
  27      'gp-translations-page',
  28      '$gp_translations_options',
  29      array(
  30          'sort'   => __( 'Sort', 'glotpress' ),
  31          'filter' => __( 'Filter', 'glotpress' ),
  32      )
  33  );
  34  
  35  // localizer adds var in front of the variable name, so we can't use $gp.editor.options
  36  $editor_options = compact( 'can_approve', 'can_write', 'url', 'discard_warning_url', 'set_priority_url', 'set_status_url' );
  37  
  38  wp_localize_script( 'gp-editor', '$gp_editor_options', $editor_options );
  39  
  40  gp_tmpl_header();
  41  $i = 0;
  42  ?>
  43  
  44  <div class="gp-heading">
  45      <h2>
  46          <?php
  47          printf(
  48              /* translators: 1: Project name. 2: Translation set name. */
  49              __( 'Translation of %1$s: %2$s', 'glotpress' ),
  50              esc_html( $project->name ),
  51              esc_html( $translation_set->name )
  52          );
  53          ?>
  54      </h2>
  55      <?php gp_link_set_edit( $translation_set, $project, _x( '(edit)', 'translation set', 'glotpress' ) ); ?>
  56      <?php gp_link_set_delete( $translation_set, $project, _x( '(delete)', 'translation set', 'glotpress' ) ); ?>
  57      <div class="glossary-links">
  58          <?php
  59          $can_create_locale_glossary      = GP::$permission->current_user_can( 'admin' );
  60          $locale_glossary_translation_set = GP::$translation_set->by_project_id_slug_and_locale( 0, $translation_set->slug, $translation_set->locale );
  61          $locale_glossary                 = GP::$glossary->by_set_id( $locale_glossary_translation_set->id );
  62  
  63          // Locale Glossary link.
  64          if ( $locale_glossary ) {
  65              ?>
  66              <a href="<?php echo esc_url( gp_url_join( gp_url( '/languages' ), $locale->slug, $translation_set->slug, 'glossary' ) ); ?>" class="glossary-link"><?php _e( 'Locale Glossary', 'glotpress' ); ?></a>
  67              <?php
  68          } elseif ( $can_create_locale_glossary ) {
  69              ?>
  70              <a href="<?php echo esc_url( gp_url_join( gp_url( '/languages' ), $locale->slug, $translation_set->slug, 'glossary' ) ); ?>" class="glossary-link"><?php _e( 'Create Locale Glossary', 'glotpress' ); ?></a>
  71              <?php
  72          }
  73  
  74          // Show separator if both links are shown.
  75          if ( ( $locale_glossary || $can_create_locale_glossary ) && ( ( $glossary && $glossary->translation_set_id === $translation_set->id ) || $can_approve ) ) {
  76              ?>
  77              <strong class="separator">•</strong>
  78              <?php
  79          }
  80  
  81          // Project Glossary link.
  82          if ( $glossary && $glossary->translation_set_id === $translation_set->id ) {
  83              echo gp_link( $glossary->path(), __( 'Project Glossary', 'glotpress' ), array( 'class' => 'glossary-link' ) );
  84          } elseif ( $can_approve ) {
  85              echo gp_link_get( gp_url( '/glossaries/-new', array( 'translation_set_id' => $translation_set->id ) ), __( 'Create Project Glossary', 'glotpress' ), array( 'class' => 'glossary-link' ) );
  86          }
  87          ?>
  88      </div>
  89  </div>
  90  
  91  <div class="filter-toolbar">
  92      <form id="upper-filters-toolbar" class="filters-toolbar" action="" method="get" accept-charset="utf-8">
  93          <div>
  94          <a href="#" class="revealing filter"><?php _e( 'Filter &darr;', 'glotpress' ); ?></a> <span class="separator">&bull;</span>
  95          <a href="#" class="revealing sort"><?php _e( 'Sort &darr;', 'glotpress' ); ?></a> <strong class="separator">&bull;</strong>
  96          <?php
  97          $current_filter = '';
  98          $filter_links   = array();
  99  
 100          // Use array_filter() to remove empty values, store them for use later if a custom filter has been applied.
 101          $filters_values_only = array_filter( $filters );
 102          $sort_values_only    = array_filter( $sort );
 103          $filters_and_sort    = array_merge( $filters_values_only, $sort_values_only );
 104  
 105          /**
 106           * Check to see if a term or user login has been added to the filter or one of the other filter options, if so,
 107           * we don't want to match the standard filter links.
 108           *
 109           * Note: Don't check for the warnings filter here otherwise we won't be able to use this value during the check
 110           * to see if the warnings filter link entry is the currently selected filter.
 111           */
 112          $additional_filters = array_key_exists( 'term', $filters_and_sort ) ||
 113                                  array_key_exists( 'user_login', $filters_and_sort ) ||
 114                                  array_key_exists( 'with_comment', $filters_and_sort ) ||
 115                                  array_key_exists( 'case_sensitive', $filters_and_sort ) ||
 116                                  array_key_exists( 'with_plural', $filters_and_sort ) ||
 117                                  array_key_exists( 'with_context', $filters_and_sort );
 118  
 119          // Because 'warnings' is not a translation status we need to know if we're filtering on it before we check
 120          // for what filter links to add.
 121          $warnings_filter = array_key_exists( 'warnings', $filters_and_sort );
 122  
 123          $all_filters = array(
 124              'status' => 'current_or_waiting_or_fuzzy_or_untranslated',
 125          );
 126  
 127          $current_filter_class = array(
 128              'class' => 'filter-current',
 129          );
 130  
 131          $is_current_filter = ( array() === array_diff( $all_filters, $filters_and_sort ) || array() === $filters_and_sort ) && ! $additional_filters && ! $warnings_filter;
 132          $current_filter    = $is_current_filter ? 'all' : $current_filter;
 133  
 134          $filter_links[] = gp_link_get(
 135              $url,
 136              // Translators: %s is the total strings count for the current translation set.
 137              sprintf( __( 'All&nbsp;(%s)', 'glotpress' ), number_format_i18n( $translation_set->all_count() ) ),
 138              $is_current_filter ? $current_filter_class : array()
 139          );
 140  
 141          $translated_filters = array(
 142              'filters[status]' => 'current',
 143          );
 144  
 145          $is_current_filter = array() === array_diff( $translated_filters, $filters_and_sort ) && false === $additional_filters && ! $warnings_filter;
 146          $current_filter    = $is_current_filter ? 'translated' : $current_filter;
 147  
 148          $filter_links[] = gp_link_get(
 149              add_query_arg( $translated_filters, $url ),
 150              // Translators: %s is the translated strings count for the current translation set.
 151              sprintf( __( 'Translated&nbsp;(%s)', 'glotpress' ), number_format_i18n( $translation_set->current_count() ) ),
 152              $is_current_filter ? $current_filter_class : array()
 153          );
 154  
 155          $untranslated_filters = array(
 156              'filters[status]' => 'untranslated',
 157          );
 158  
 159          $is_current_filter = array() === array_diff( $untranslated_filters, $filters_and_sort ) && false === $additional_filters && ! $warnings_filter;
 160          $current_filter    = $is_current_filter ? 'untranslated' : $current_filter;
 161  
 162          $filter_links[] = gp_link_get(
 163              add_query_arg( $untranslated_filters, $url ),
 164              // Translators: %s is the untranslated strings count for the current translation set.
 165              sprintf( __( 'Untranslated&nbsp;(%s)', 'glotpress' ), number_format_i18n( $translation_set->untranslated_count() ) ),
 166              $is_current_filter ? $current_filter_class : array()
 167          );
 168  
 169          $waiting_filters = array(
 170              'filters[status]' => 'waiting',
 171          );
 172  
 173          $is_current_filter = array() === array_diff( $waiting_filters, $filters_and_sort ) && ! $additional_filters && ! $warnings_filter;
 174          $current_filter    = $is_current_filter ? 'waiting' : $current_filter;
 175  
 176          $filter_links[] = gp_link_get(
 177              add_query_arg( $waiting_filters, $url ),
 178              // Translators: %s is the waiting strings count for the current translation set.
 179              sprintf( __( 'Waiting&nbsp;(%s)', 'glotpress' ), number_format_i18n( $translation_set->waiting_count() ) ),
 180              $is_current_filter ? $current_filter_class : array()
 181          );
 182  
 183          $fuzzy_filters = array(
 184              'filters[status]' => 'fuzzy',
 185          );
 186  
 187          $is_current_filter = array() === array_diff( $fuzzy_filters, $filters_and_sort ) && ! $additional_filters && ! $warnings_filter;
 188          $current_filter    = $is_current_filter ? 'fuzzy' : $current_filter;
 189  
 190          $filter_links[] = gp_link_get(
 191              add_query_arg( $fuzzy_filters, $url ),
 192              // Translators: %s is the fuzzy strings count for the current translation set.
 193              sprintf( __( 'Fuzzy&nbsp;(%s)', 'glotpress' ), number_format_i18n( $translation_set->fuzzy_count() ) ),
 194              $is_current_filter ? $current_filter_class : array()
 195          );
 196  
 197          $warning_filters = array(
 198              'filters[warnings]' => 'yes',
 199          );
 200  
 201          $is_current_filter = array() === array_diff( $warning_filters, $filters_and_sort ) && ! $additional_filters && ! array_key_exists( 'status', $filters_and_sort );
 202          $current_filter    = $is_current_filter ? 'warning' : $current_filter;
 203  
 204          $filter_links[] = gp_link_get(
 205              add_query_arg( $warning_filters, $url ),
 206              // Translators: %s is the strings with warnings count for the current translation set.
 207              sprintf( __( 'Warnings&nbsp;(%s)', 'glotpress' ), number_format_i18n( $translation_set->warnings_count() ) ),
 208              $is_current_filter ? $current_filter_class : array()
 209          );
 210  
 211          // If no filter has been selected yet, then add the current filter count to the end of the filter links array.
 212          if ( '' === $current_filter ) {
 213              // Build an array or query args to add to the link using the current sort/filter options.
 214              $custom_filter = array();
 215  
 216              foreach ( $filters_values_only as $key => $value ) {
 217                  $custom_filter[ 'filters[' . $key . ']' ] = $value;
 218              }
 219  
 220              foreach ( $sort_values_only as $key => $value ) {
 221                  $custom_filter[ 'sort[' . $key . ']' ] = $value;
 222              }
 223  
 224              $filter_links[] = gp_link_get(
 225                  add_query_arg( $custom_filter, $url ),
 226                  // Translators: %s is the strings with the current filter count for the current translation set.
 227                  sprintf( __( 'Current&nbsp;Filter&nbsp;(%s)', 'glotpress' ), number_format_i18n( $total_translations_count ) ),
 228                  $current_filter_class
 229              );
 230          }
 231  
 232          // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
 233          echo implode( ' <span class="separator">&bull;</span> ', $filter_links );
 234          ?>
 235          </div>
 236          <div class="filters-expanded filters hidden">
 237              <div class="filters-expanded-section">
 238                  <fieldset>
 239                      <legend class="screen-reader-text"><?php _e( 'Search:', 'glotpress' ); ?></legend>
 240                      <label for="filters[term]" class="filter-title"><?php _e( 'Search Term:', 'glotpress' ); ?></label><br />
 241                      <input type="text" value="<?php echo gp_esc_attr_with_entities( gp_array_get( $filters, 'term' ) ); ?>" name="filters[term]" id="filters[term]" /><br />
 242                      <input type="checkbox" name="filters[case_sensitive]" value="yes" id="filters[case_sensitive][yes]" <?php gp_checked( 'yes' === gp_array_get( $filters, 'case_sensitive' ) ); ?>>&nbsp;<label for='filters[case_sensitive][yes]'><?php _e( 'Case-sensitive search', 'glotpress' ); ?></label>
 243                  </fieldset>
 244  
 245                  <fieldset>
 246                      <legend class="filter-title"><?php _e( 'Term Scope:', 'glotpress' ); ?></legend>
 247                      <?php
 248                      echo gp_radio_buttons(
 249                          'filters[term_scope]',
 250                          array(
 251                              'scope_originals'    => __( 'Originals only', 'glotpress' ),
 252                              'scope_translations' => __( 'Translations only', 'glotpress' ),
 253                              'scope_context'      => __( 'Context only', 'glotpress' ),
 254                              'scope_references'   => __( 'References only', 'glotpress' ),
 255                              'scope_both'         => __( 'Both Originals and Translations', 'glotpress' ),
 256                              'scope_any'          => __( 'Any', 'glotpress' ),
 257                          ),
 258                          gp_array_get( $filters, 'term_scope', 'scope_any' )
 259                      );
 260                      ?>
 261                  </fieldset>
 262              </div>
 263  
 264              <div class="filters-expanded-section">
 265                  <fieldset id="filter-status-fields">
 266                      <legend class="filter-title"><?php _e( 'Status:', 'glotpress' ); ?></legend>
 267                      <?php
 268                      $selected_status      = gp_array_get( $filters, 'status', 'current_or_waiting_or_fuzzy_or_untranslated' );
 269                      $selected_status_list = explode( '_or_', $selected_status );
 270                      ?>
 271                      <label for="filters[status][current]">
 272                          <input type="checkbox" value="current" id="filters[status][current]" <?php gp_checked( 'either' === $selected_status || in_array( 'current', $selected_status_list, true ) ); ?>>
 273                          <?php _e( 'Current', 'glotpress' ); ?>
 274                      </label><br />
 275                      <label for="filters[status][waiting]">
 276                          <input type="checkbox" value="waiting" id="filters[status][waiting]" <?php gp_checked( 'either' === $selected_status || in_array( 'waiting', $selected_status_list, true ) ); ?>>
 277                          <?php _e( 'Waiting', 'glotpress' ); ?>
 278                      </label><br />
 279                      <label for="filters[status][fuzzy]">
 280                          <input type="checkbox" value="fuzzy" id="filters[status][fuzzy]" <?php gp_checked( 'either' === $selected_status || in_array( 'fuzzy', $selected_status_list, true ) ); ?>>
 281                          <?php _e( 'Fuzzy', 'glotpress' ); ?>
 282                      </label><br />
 283                      <label for="filters[status][untranslated]">
 284                          <input type="checkbox" value="untranslated" id="filters[status][untranslated]" <?php gp_checked( in_array( 'untranslated', $selected_status_list, true ) ); ?>>
 285                          <?php _e( 'Untranslated', 'glotpress' ); ?>
 286                      </label><br />
 287                      <label for="filters[status][rejected]">
 288                          <input type="checkbox" value="rejected" id="filters[status][rejected]" <?php gp_checked( 'either' === $selected_status || in_array( 'rejected', $selected_status_list, true ) ); ?>>
 289                          <?php _e( 'Rejected', 'glotpress' ); ?>
 290                      </label><br />
 291                      <label for="filters[status][old]">
 292                          <input type="checkbox" value="old" id="filters[status][old]" <?php gp_checked( 'either' === $selected_status || in_array( 'old', $selected_status_list, true ) ); ?>>
 293                          <?php _e( 'Old', 'glotpress' ); ?>
 294                      </label><br />
 295                      <button type="button" id="filter-status-select-all" class="button is-link"><?php _e( 'Select all', 'glotpress' ); ?></button>
 296                      <input type="hidden" id="filter-status-selected" name="filters[status]" value="<?php echo esc_attr( $selected_status ); ?>" />
 297                  </fieldset>
 298              </div>
 299  
 300              <div class="filters-expanded-section">
 301                  <fieldset>
 302                      <legend class="filter-title"><?php _e( 'Options:', 'glotpress' ); ?></legend>
 303                      <input type="checkbox" name="filters[with_comment]" value="yes" id="filters[with_comment][yes]" <?php gp_checked( 'yes' === gp_array_get( $filters, 'with_comment' ) ); ?>>&nbsp;<label for='filters[with_comment][yes]'><?php _e( 'With comment', 'glotpress' ); ?></label><br />
 304                      <input type="checkbox" name="filters[with_context]" value="yes" id="filters[with_context][yes]" <?php gp_checked( 'yes' === gp_array_get( $filters, 'with_context' ) ); ?>>&nbsp;<label for='filters[with_context][yes]'><?php _e( 'With context', 'glotpress' ); ?></label><br />
 305                      <input type="checkbox" name="filters[warnings]" value="yes" id="filters[warnings][yes]" <?php gp_checked( 'yes' === gp_array_get( $filters, 'warnings' ) ); ?>>&nbsp;<label for='filters[warnings][yes]'><?php _e( 'With warnings', 'glotpress' ); ?></label><br />
 306                      <input type="checkbox" name="filters[with_plural]" value="yes" id="filters[with_plural][yes]" <?php gp_checked( 'yes' === gp_array_get( $filters, 'with_plural' ) ); ?>>&nbsp;<label for='filters[with_plural][yes]'><?php _e( 'With plural', 'glotpress' ); ?></label>
 307                  </fieldset>
 308              </div>
 309  
 310              <div class="filters-expanded-section">
 311                  <label for="filters[user_login]" class="filter-title"><?php _e( 'User:', 'glotpress' ); ?></label><br />
 312                  <input type="text" value="<?php echo gp_esc_attr_with_entities( gp_array_get( $filters, 'user_login' ) ); ?>" name="filters[user_login]" id="filters[user_login]" /><br />
 313              </div>
 314  
 315              <?php
 316              /**
 317               * Fires after the translation set filters options.
 318               *
 319               * This action is inside a DL element.
 320               *
 321               * @since 2.1.0
 322               */
 323              do_action( 'gp_translation_set_filters_form' );
 324              ?>
 325  
 326              <div class="filters-expanded-actions">
 327                  <input type="submit" class="button is-primary" value="<?php esc_attr_e( 'Apply Filters', 'glotpress' ); ?>" name="filter" />
 328              </div>
 329          </div>
 330          <div class="filters-expanded sort hidden">
 331              <div class="filters-expanded-section">
 332                  <fieldset>
 333                      <legend class="filter-title"><?php _ex( 'By:', 'sort by', 'glotpress' ); ?></legend>
 334                      <?php
 335                      $default_sort = get_user_option( 'gp_default_sort' );
 336                      if ( ! is_array( $default_sort ) ) {
 337                          $default_sort = array(
 338                              'by'  => 'priority',
 339                              'how' => 'desc',
 340                          );
 341                      }
 342  
 343                      $sort_bys = wp_list_pluck( gp_get_sort_by_fields(), 'title' );
 344                      echo gp_radio_buttons( 'sort[by]', $sort_bys, gp_array_get( $sort, 'by', $default_sort['by'] ) );
 345                      ?>
 346                  </fieldset>
 347              </div>
 348  
 349              <div class="filters-expanded-section">
 350                  <fieldset>
 351                      <legend class="filter-title"><?php _e( 'Order:', 'glotpress' ); ?></legend>
 352                      <?php
 353                      echo gp_radio_buttons(
 354                          'sort[how]',
 355                          array(
 356                              'asc'  => __( 'Ascending', 'glotpress' ),
 357                              'desc' => __( 'Descending', 'glotpress' ),
 358                          ),
 359                          gp_array_get( $sort, 'how', $default_sort['how'] )
 360                      );
 361                      ?>
 362                  </fieldset>
 363              </div>
 364  
 365              <?php
 366              /**
 367               * Fires after the translation set sort options.
 368               *
 369               * This action is inside a DL element.
 370               *
 371               * @deprecated 2.1.0 Call gp_translation_set_sort_form instead
 372               * @since 1.0.0
 373               */
 374              do_action( 'gp_translation_set_filters' );
 375  
 376              /**
 377               * Fires after the translation set sort options.
 378               *
 379               * This action is inside a DL element.
 380               *
 381               * @since 2.1.0
 382               */
 383              do_action( 'gp_translation_set_sort_form' );
 384              ?>
 385  
 386              <div class="filters-expanded-actions">
 387                  <input type="submit" class="button is-primary" value="<?php esc_attr_e( 'Apply Sorting', 'glotpress' ); ?>" name="sorts" />
 388              </div>
 389          </div>
 390      </form>
 391  </div>
 392  
 393  <div class="gp-table-actions top">
 394      <?php
 395      if ( $can_approve ) {
 396          gp_translations_bulk_actions_toolbar( $bulk_action, $can_write, $translation_set, 'top' );
 397      }
 398  
 399      echo gp_pagination( $page, $per_page, $total_translations_count );
 400      ?>
 401  </div>
 402  
 403  <?php $class_rtl = 'rtl' === $locale->text_direction ? ' translation-sets-rtl' : ''; ?>
 404  <table id="translations" class="gp-table translations <?php echo esc_attr( $class_rtl ); ?>">
 405      <thead>
 406      <tr>
 407          <?php
 408          if ( $can_approve ) :
 409              ?>
 410              <th class="gp-column-checkbox checkbox" scope="row"><input type="checkbox" /></th>
 411              <?php
 412          endif;
 413          ?>
 414          <th class="gp-column-priority"><?php /* Translators: Priority */ _e( 'Prio', 'glotpress' ); ?></th>
 415          <th class="gp-column-original"><?php _e( 'Original string', 'glotpress' ); ?></th>
 416          <th class="gp-column-translation"><?php _e( 'Translation', 'glotpress' ); ?></th>
 417          <th class="gp-column-actions">&mdash;</th>
 418      </tr>
 419      </thead>
 420  <?php
 421      foreach ( $translations as $translation ) {
 422          if ( ! $translation->translation_set_id ) {
 423              $translation->translation_set_id = $translation_set->id;
 424          }
 425  
 426      $can_approve_translation = GP::$permission->current_user_can( 'approve', 'translation', $translation->id, array( 'translation' => $translation ) );
 427      gp_tmpl_load( 'translation-row', get_defined_vars() );
 428  }
 429  ?>
 430  <?php
 431      if ( ! $translations ) :
 432  ?>
 433      <tr><td colspan="<?php echo $can_approve ? 5 : 4; ?>"><?php _e( 'No translations were found!', 'glotpress' ); ?></td></tr>
 434  <?php
 435      endif;
 436  ?>
 437  </table>
 438  
 439  <div class="gp-table-actions bottom">
 440      <?php
 441      if ( $can_approve ) {
 442          gp_translations_bulk_actions_toolbar( $bulk_action, $can_write, $translation_set, 'bottom' );
 443      }
 444      ?>
 445      <div id="legend">
 446          <div><strong><?php _e( 'Legend:', 'glotpress' ); ?></strong></div>
 447          <?php
 448          foreach ( GP::$translation->get_static( 'statuses' ) as $legend_status ) :
 449              ?>
 450              <div class="box status-<?php echo esc_attr( $legend_status ); ?>"></div>
 451              <div>
 452                  <?php
 453                  switch ( $legend_status ) {
 454                      case 'current':
 455                          _e( 'Current', 'glotpress' );
 456                          break;
 457                      case 'waiting':
 458                          _e( 'Waiting', 'glotpress' );
 459                          break;
 460                      case 'fuzzy':
 461                          _e( 'Fuzzy', 'glotpress' );
 462                          break;
 463                      case 'old':
 464                          _e( 'Old', 'glotpress' );
 465                          break;
 466                      case 'rejected':
 467                          _e( 'Rejected', 'glotpress' );
 468                          break;
 469                      default:
 470                          echo esc_html( $legend_status );
 471                  }
 472                  ?>
 473              </div>
 474              <?php
 475          endforeach;
 476          ?>
 477          <div class="box has-warnings"></div>
 478          <div><?php _e( 'With warnings', 'glotpress' ); ?></div>
 479      </div>
 480      <?php echo gp_pagination( $page, $per_page, $total_translations_count ); ?>
 481  </div>
 482  
 483  <p class="actionlist">
 484      <?php
 485      $footer_links = array();
 486      if ( ( isset( $can_import_current ) && $can_import_current ) || ( isset( $can_import_waiting ) && $can_import_waiting ) ) {
 487          $footer_links[] = gp_link_get( gp_url_project( $project, array( $locale->slug, $translation_set->slug, 'import-translations' ) ), __( 'Import Translations', 'glotpress' ) );
 488      }
 489  
 490      /**
 491       * The 'default' filter is 'Current/waiting/fuzzy + untranslated (All)', however that is not
 492       * the default action when exporting so make sure to set it on the export link if no filter
 493       * has been activated by the user.
 494       */
 495      if ( ! array_key_exists( 'status', $filters ) ) {
 496          $filters['status'] = 'current_or_waiting_or_fuzzy_or_untranslated';
 497      }
 498  
 499      $export_url     = gp_url_project( $project, array( $locale->slug, $translation_set->slug, 'export-translations' ) );
 500      $export_link    = gp_link_get(
 501          $export_url,
 502          __( 'Export', 'glotpress' ),
 503          array(
 504              'id'      => 'export',
 505              'filters' => add_query_arg( array( 'filters' => $filters ), $export_url ),
 506          )
 507      );
 508      $format_options = array();
 509      foreach ( GP::$formats as $slug => $format ) {
 510          $format_options[ $slug ] = $format->name;
 511      }
 512      $what_dropdown   = gp_select(
 513          'what-to-export',
 514          array(
 515              'all'      => _x( 'all current', 'export choice', 'glotpress' ),
 516              'filtered' => _x( 'only matching the filter', 'export choice', 'glotpress' ),
 517          ),
 518          'all'
 519      );
 520      $format_dropdown = gp_select( 'export-format', $format_options, 'po' );
 521      /* translators: 1: export 2: what to export dropdown (all/filtered) 3: export format */
 522      $footer_links[] = sprintf( __( '%1$s %2$s as %3$s', 'glotpress' ), $export_link, $what_dropdown, $format_dropdown );
 523  
 524      /**
 525       * Filter footer links in translations.
 526       *
 527       * @since 1.0.0
 528       *
 529       * @param array              $footer_links    Default links.
 530       * @param GP_Project         $project         The current project.
 531       * @param GP_Locale          $locale          The current locale.
 532       * @param GP_Translation_Set $translation_set The current translation set.
 533       */
 534      $footer_links = apply_filters( 'gp_translations_footer_links', $footer_links, $project, $locale, $translation_set );
 535  
 536      // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
 537      echo implode( ' &bull; ', $footer_links );
 538      ?>
 539  </p>
 540  <?php
 541  gp_tmpl_footer();


Generated: Sat Apr 27 01:01:04 2024 Cross-referenced by PHPXref 0.7.1