[ Index ]

PHP Cross Reference of GlotPress

title

Body

[close]

/gp-includes/ -> template.php (source)

   1  <?php
   2  function gp_tmpl_load( $template, $args = array(), $template_path = null ) {
   3      $args = gp_tmpl_filter_args( $args );
   4  
   5      /**
   6       * Fires before a template is loaded.
   7       *
   8       * @since 1.0.0
   9       *
  10       * @param string $template The template name.
  11       * @param array  $args     Arguments passed to the template. Passed by reference.
  12       */
  13      do_action_ref_array( 'gp_pre_tmpl_load', array( $template, &$args ) );
  14      require_once GP_TMPL_PATH . 'helper-functions.php';
  15      $locations = array( GP_TMPL_PATH );
  16      if ( ! is_null( $template_path ) ) {
  17          array_unshift( $locations, untrailingslashit( $template_path ) . '/' );
  18      }
  19  
  20      /**
  21       * Filter the locations to load template files from.
  22       *
  23       * @since 1.0.0
  24       *
  25       * @param array       $locations     File paths of template locations.
  26       * @param string      $template      The template name.
  27       * @param array       $args          Arguments passed to the template.
  28       * @param string|null $template_path Priority template location, if any.
  29       */
  30      $locations = apply_filters( 'gp_tmpl_load_locations', $locations, $template, $args, $template_path );
  31      if ( isset( $args['http_status'] ) ) {
  32          status_header( $args['http_status'] );
  33      }
  34      foreach ( $locations as $location ) {
  35          $file = $location . "$template.php";
  36          if ( is_readable( $file ) ) {
  37              extract( $args, EXTR_SKIP );
  38              include $file;
  39              break;
  40          }
  41      }
  42  
  43      /**
  44       * Fires after a template was loaded.
  45       *
  46       * @since 1.0.0
  47       *
  48       * @param string $template The template name.
  49       * @param array  $args     Arguments passed to the template. Passed by reference.
  50       */
  51      do_action_ref_array( 'gp_post_tmpl_load', array( $template, &$args ) );
  52  }
  53  
  54  /**
  55   * Retrieves content of a template via output buffering.
  56   *
  57   * @since 1.0.0
  58   *
  59   * @see gp_tmpl_load()
  60   *
  61   * @param mixed ...$args Arguments to be passed to gp_tmpl_load().
  62   * @return string|false
  63   */
  64  function gp_tmpl_get_output( ...$args ) {
  65      ob_start();
  66      gp_tmpl_load( ...$args );
  67      return ob_get_clean();
  68  }
  69  
  70  function gp_tmpl_header( $args = array() ) {
  71      gp_tmpl_load( 'header', $args );
  72  }
  73  
  74  function gp_tmpl_footer( $args = array() ) {
  75      gp_tmpl_load( 'footer', $args );
  76  }
  77  
  78  function gp_head() {
  79      /**
  80       * Fires inside the head element on the header template.
  81       *
  82       * @since 1.0.0
  83       */
  84      do_action( 'gp_head' );
  85  }
  86  
  87  function gp_footer() {
  88      /**
  89       * Fires at the end of the page, on the footer template.
  90       *
  91       * @since 1.0.0
  92       */
  93      do_action( 'gp_footer' );
  94  }
  95  
  96  function gp_nav_menu( $location = 'main' ) {
  97      $html  = '';
  98      $items = gp_nav_menu_items( $location );
  99  
 100      foreach ( $items as $link => $title ) {
 101          $html .= '<a href="' . $link . '">' . $title . '</a>';
 102      }
 103  
 104      return $html;
 105  }
 106  
 107  function gp_nav_menu_items( $location = 'main' ) {
 108      $items = array();
 109  
 110      if ( 'main' === $location ) {
 111          $items[ gp_url( '/projects' ) ]  = __( 'Projects', 'glotpress' );
 112          $items[ gp_url( '/languages' ) ] = __( 'Locales', 'glotpress' );
 113      } elseif ( 'side' === $location ) {
 114          if ( is_user_logged_in() ) {
 115              $user = wp_get_current_user();
 116              $items[ gp_url_profile( $user->user_nicename ) ]       = __( 'Profile', 'glotpress' );
 117              $items[ gp_url( '/settings' ) ]                        = __( 'Settings', 'glotpress' );
 118              $items[ esc_url( wp_logout_url( gp_url_current() ) ) ] = __( 'Log out', 'glotpress' );
 119          } else {
 120              $items[ esc_url( wp_login_url( gp_url_current() ) ) ] = __( 'Log in', 'glotpress' );
 121          }
 122      }
 123  
 124      /**
 125       * Filter the list of navigation menu items.
 126       *
 127       * @since 1.0.0
 128       *
 129       * @param array  $items    Menu items. URL as the key, menu label as the value.
 130       * @param string $location Location of the menu.
 131       */
 132      return apply_filters( 'gp_nav_menu_items', $items, $location );
 133  }
 134  
 135  function gp_tmpl_filter_args( $args ) {
 136      $clean_args = array();
 137      foreach ( $args as $k => $v ) {
 138          if ( '_' != $k[0] && 'GLOBALS' != $k && ! gp_startswith( $k, 'HTTP' ) && ! gp_startswith( $k, 'PHP' ) ) {
 139              $clean_args[ $k ] = $v;
 140          }
 141      }
 142      return $clean_args;
 143  }
 144  
 145  function gp_tmpl_404( $args = array() ) {
 146      gp_tmpl_load(
 147          '404',
 148          $args + array(
 149              'title'       => __( 'Not Found', 'glotpress' ),
 150              'http_status' => 404,
 151          )
 152      );
 153      exit();
 154  }
 155  
 156  function gp_title( $title = null ) {
 157      if ( ! is_null( $title ) ) {
 158          add_filter(
 159              'gp_title',
 160              function() use ( $title ) {
 161                  return $title;
 162              },
 163              5
 164          );
 165      } else {
 166  
 167          /**
 168           * Filter the title of a page.
 169           *
 170           * @since 1.0.0
 171           *
 172           * @param string $title The title of a page.
 173           */
 174          return apply_filters( 'gp_title', '' );
 175      }
 176  }
 177  
 178  function gp_breadcrumb( $breadcrumb = null, $args = array() ) {
 179      if ( $breadcrumb ) {
 180          $breadcrumb = gp_array_flatten( $breadcrumb );
 181  
 182          add_filter(
 183              'gp_breadcrumb_items',
 184              function( $breadcrumbs ) use ( $breadcrumb ) {
 185                  return array_merge( $breadcrumbs, $breadcrumb );
 186              },
 187              1
 188          );
 189      } else {
 190  
 191          /**
 192           * Filter the list of breadcrumb navigation items.
 193           *
 194           * @since 1.0.0
 195           *
 196           * @param array $breadcrumb_items Breadcrumb items as HTML string.
 197           */
 198          $breadcrumbs = apply_filters( 'gp_breadcrumb_items', array() );
 199  
 200          if ( $breadcrumbs ) {
 201              $defaults = array(
 202                  /* translators: separates links in the navigation breadcrumb */
 203                  'before'              => '<li>',
 204                  'after'               => '</li>',
 205                  'breadcrumb-template' => '<ul class="breadcrumb">{breadcrumb}</ul>',
 206              );
 207  
 208              $args = array_merge( $defaults, $args );
 209  
 210              $whole_breadcrumb = '';
 211  
 212              foreach ( $breadcrumbs as $breadcrumb ) {
 213                  $whole_breadcrumb .= $args['before'] . $breadcrumb . $args['after'];
 214              }
 215  
 216              $whole_breadcrumb = str_replace( '{breadcrumb}', $whole_breadcrumb, $args['breadcrumb-template'] );
 217  
 218              /**
 219               * Filter the breadcrumb HTML output.
 220               *
 221               * @since 1.0.0
 222               *
 223               * @param string $whole_breadcrumb Breadcrumb HTML.
 224               */
 225              return apply_filters( 'gp_breadcrumb', $whole_breadcrumb );
 226          }
 227      }
 228  }
 229  
 230  function gp_project_names_from_root( $leaf_project ) {
 231      $names          = array();
 232      $path_from_root = array_reverse( $leaf_project->path_to_root() );
 233  
 234      foreach ( $path_from_root as $project ) {
 235          $names[] = esc_html( $project->name );
 236      }
 237  
 238      $project_path = implode( ' | ', $names );
 239  
 240      return $project_path;
 241  }
 242  
 243  function gp_project_links_from_root( $leaf_project ) {
 244      if ( 0 === $leaf_project->id ) {
 245          return array();
 246      }
 247      $links          = array();
 248      $path_from_root = array_reverse( $leaf_project->path_to_root() );
 249      $links[]        = empty( $path_from_root ) ? __( 'Projects', 'glotpress' ) : gp_link_get( gp_url( '/projects' ), __( 'Projects', 'glotpress' ) );
 250      foreach ( $path_from_root as $project ) {
 251          $links[] = gp_link_project_get( $project, esc_html( $project->name ) );
 252      }
 253      return $links;
 254  }
 255  
 256  function gp_breadcrumb_project( $project ) {
 257      return gp_breadcrumb( gp_project_links_from_root( $project ) );
 258  }
 259  
 260  function gp_js_focus_on( $html_id ) {
 261      return '<script type="text/javascript">document.getElementById(\'' . esc_js( $html_id ) . '\').focus();</script>';
 262  }
 263  
 264  function gp_select( $name_and_id, $options, $selected_key, $attrs = array() ) {
 265      $attributes = gp_html_attributes( $attrs );
 266      $attributes = $attributes ? " $attributes" : '';
 267      $res        = "<select name='" . esc_attr( $name_and_id ) . "' id='" . esc_attr( $name_and_id ) . "' $attributes>\n";
 268      $labels     = array(
 269          'hidden' => _x( 'hidden', 'Priority', 'glotpress' ),
 270          'low'    => _x( 'low', 'Priority', 'glotpress' ),
 271          'normal' => _x( 'normal', 'Priority', 'glotpress' ),
 272          'high'   => _x( 'high', 'Priority', 'glotpress' ),
 273      );
 274      foreach ( $options as $value => $label ) {
 275          if ( isset( $labels[ $label ] ) ) {
 276              $label = $labels[ $label ];
 277          }
 278          $selected = selected( $value, $selected_key, false );
 279          $res     .= "\t<option value='" . esc_attr( $value ) . "'$selected>" . esc_html( $label ) . "</option>\n";
 280      }
 281      $res .= "</select>\n";
 282      return $res;
 283  }
 284  
 285  function gp_radio_buttons( $name, $radio_buttons, $checked_key ) {
 286      $res = '';
 287      foreach ( $radio_buttons as $value => $label ) {
 288          $checked = checked( $value, $checked_key, false );
 289          // TODO: something more flexible than <br />
 290          $res .= "\t<input type='radio' id='" . esc_attr( "{$name}[{$value}]" ) . "' name='" . esc_attr( $name ) . "' value='" . esc_attr( $value ) . "'$checked/>&nbsp;";
 291          $res .= "<label for='" . esc_attr( "{$name}[{$value}]" ) . "'>" . esc_html( $label ) . "</label><br />\n";
 292      }
 293      return $res;
 294  }
 295  
 296  function gp_pagination( $page, $per_page, $objects ) {
 297      $surrounding = 2;
 298      $first       = $prev_dots = $prev_pages = $next_pages = $next_dots = $last = '';
 299      $page        = intval( $page ) ? intval( $page ) : 1;
 300      $pages       = ceil( $objects / $per_page );
 301      if ( $page > $pages ) {
 302          return '';
 303      }
 304  
 305      if ( $page > 1 ) {
 306          $prev = gp_link_get( add_query_arg( array( 'page' => $page - 1 ) ), '&larr;', array( 'class' => 'previous' ) );
 307      } else {
 308          $prev = '<span class="previous disabled">&larr;</span>';
 309      }
 310  
 311      if ( $page < $pages ) {
 312          $next = gp_link_get( add_query_arg( array( 'page' => $page + 1 ) ), '&rarr;', array( 'class' => 'next' ) );
 313      } else {
 314          $next = '<span class="next disabled">&rarr;</span>';
 315      }
 316  
 317      $current = '<span class="current">' . $page . '</span>';
 318      if ( $page > 1 ) {
 319          $prev_pages = array();
 320          foreach ( range( max( 1, $page - $surrounding ), $page - 1 ) as $prev_page ) {
 321              $prev_pages[] = gp_link_get( add_query_arg( array( 'page' => $prev_page ) ), $prev_page );
 322          }
 323          $prev_pages = implode( ' ', $prev_pages );
 324          if ( $page - $surrounding > 1 ) {
 325              $prev_dots = '<span class="dots">&hellip;</span>';
 326          }
 327      }
 328      if ( $page < $pages ) {
 329          $next_pages = array();
 330          foreach ( range( $page + 1, min( $pages, $page + $surrounding ) ) as $next_page ) {
 331              $next_pages[] = gp_link_get( add_query_arg( array( 'page' => $next_page ) ), $next_page );
 332          }
 333          $next_pages = implode( ' ', $next_pages );
 334          if ( $page + $surrounding < $pages ) {
 335              $next_dots = '<span class="dots">&hellip;</span>';
 336          }
 337      }
 338      if ( $prev_dots ) {
 339          $first = gp_link_get( add_query_arg( array( 'page' => 1 ) ), 1 );
 340      }
 341      if ( $next_dots ) {
 342          $last = gp_link_get( add_query_arg( array( 'page' => $pages ) ), $pages );
 343      }
 344  
 345      $html = <<<HTML
 346      <div class="paging">
 347          $prev
 348          $first
 349          $prev_dots
 350          $prev_pages
 351          $current
 352          $next_pages
 353          $next_dots
 354          $last
 355          $next
 356      </div>
 357  HTML;
 358  
 359      /**
 360       * Filter the pagination HTML output.
 361       *
 362       * @since 1.0.0
 363       *
 364       * @param string $html     The pagination HTML.
 365       * @param int    $page     Current page number.
 366       * @param int    $per_page Objects per page.
 367       * @param int    $objects  Total number of objects to page.
 368       */
 369      return apply_filters( 'gp_pagination', $html, $page, $per_page, $objects );
 370  }
 371  
 372  function gp_html_attributes( $attrs ) {
 373      $attrs   = wp_parse_args( $attrs );
 374      $strings = array();
 375      foreach ( $attrs as $key => $value ) {
 376          $strings[] = $key . '="' . esc_attr( $value ) . '"';
 377      }
 378      return implode( ' ', $strings );
 379  }
 380  
 381  function gp_attrs_add_class( $attrs, $class_name ) {
 382      $attrs['class'] = isset( $attrs['class'] ) ? $attrs['class'] . ' ' . $class_name : $class_name;
 383      return $attrs;
 384  }
 385  
 386  /**
 387   * Returns HTML markup for a select element for all locales of a project.
 388   *
 389   * @since 1.0.0
 390   *
 391   * @param int    $project_id    ID of a project.
 392   * @param string $name_and_id   Name and ID of the select element.
 393   * @param string $selected_slug Slug of the current selected locale.
 394   * @param array  $attrs         Extra attributes.
 395   *
 396   * @return string HTML markup for a select element.
 397   */
 398  function gp_locales_by_project_dropdown( $project_id, $name_and_id, $selected_slug = null, $attrs = array() ) {
 399      $locales = GP_Locales::locales();
 400      if ( null != $project_id ) {
 401          $sets = GP::$translation_set->by_project_id( $project_id );
 402  
 403          $temp_locales = array();
 404  
 405          foreach ( $sets as $set ) {
 406              $temp_locales[ $set->locale ] = $locales[ $set->locale ];
 407          }
 408  
 409          if ( count( $temp_locales ) > 0 ) {
 410              $locales = $temp_locales;
 411          }
 412      }
 413      ksort( $locales );
 414  
 415      $options = array( '' => __( '&mdash; Locale &mdash;', 'glotpress' ) );
 416      foreach ( $locales as $key => $locale ) {
 417          $options[ $key ] = sprintf( '%s &mdash; %s', $locale->slug, $locale->english_name );
 418      }
 419  
 420      return gp_select( $name_and_id, $options, $selected_slug, $attrs );
 421  }
 422  
 423  /**
 424   * Returns HTML markup for a select element for all locales.
 425   *
 426   * @since 1.0.0
 427   *
 428   * @param string $name_and_id   Name and ID of the select element.
 429   * @param string $selected_slug Slug of the current selected locale.
 430   * @param array  $attrs         Extra attributes.
 431   *
 432   * @return string HTML markup for a select element.
 433   */
 434  function gp_locales_dropdown( $name_and_id, $selected_slug = null, $attrs = array() ) {
 435      return gp_locales_by_project_dropdown( null, $name_and_id, $selected_slug, $attrs );
 436  }
 437  
 438  /**
 439   * Returns HTML markup for a select element for projects.
 440   *
 441   * @since 1.0.0
 442   *
 443   * @param string $name_and_id         Name and ID of the select element.
 444   * @param string $selected_project_id The project id to mark as the currently selected.
 445   * @param array  $attrs               Extra attributes.
 446   * @param array  $exclude             An array of project IDs to exclude from the list.
 447   * @param array  $exclude_no_parent   Exclude the "No Parent" option from the list of projects.
 448   *
 449   * @return string HTML markup for a select element.
 450   */
 451  function gp_projects_dropdown( $name_and_id, $selected_project_id = null, $attrs = array(), $exclude = array(), $exclude_no_parent = false ) {
 452      if ( ! is_array( $exclude ) ) {
 453          $exclude = array( $exclude );
 454      }
 455  
 456      $projects = GP::$project->all();
 457      // TODO: mark which nodes are editable by the current user
 458      $tree = array();
 459      $top  = array();
 460      foreach ( $projects as $p ) {
 461          $tree[ $p->id ]['self'] = $p;
 462          if ( $p->parent_project_id ) {
 463              $tree[ $p->parent_project_id ]['children'][] = $p->id;
 464          } else {
 465              $top[] = $p->id;
 466          }
 467      }
 468  
 469      if ( ! $exclude_no_parent ) {
 470          $options = array( '' => __( '&mdash; No parent &mdash;', 'glotpress' ) );
 471      } else {
 472          $options = array();
 473      }
 474  
 475      foreach ( $top as $top_id ) {
 476          $stack = array( $top_id );
 477  
 478          while ( ! empty( $stack ) ) {
 479              $id = array_pop( $stack );
 480  
 481              if ( in_array( $id, $exclude, true ) ) {
 482                  continue;
 483              }
 484  
 485              $tree[ $id ]['level'] = gp_array_get( $tree[ $id ], 'level', 0 );
 486              $options[ $id ]       = str_repeat( '-', $tree[ $id ]['level'] ) . $tree[ $id ]['self']->name;
 487              foreach ( gp_array_get( $tree[ $id ], 'children', array() ) as $child_id ) {
 488                  $stack[]                    = $child_id;
 489                  $tree[ $child_id ]['level'] = $tree[ $id ]['level'] + 1;
 490              }
 491          }
 492      }
 493  
 494      return gp_select( $name_and_id, $options, $selected_project_id, $attrs );
 495  }
 496  
 497  function gp_array_of_things_to_json( $array ) {
 498      return wp_json_encode(
 499          array_map(
 500              function( $thing ) {
 501                  return $thing->fields();
 502              },
 503              $array
 504          )
 505      );
 506  }
 507  
 508  function gp_array_of_array_of_things_to_json( $array ) {
 509      $map_to_fields = function( $array ) {
 510          return array_map(
 511              function( $thing ) {
 512                  return $thing->fields();
 513              },
 514              $array
 515          );
 516      };
 517  
 518      return wp_json_encode( array_map( $map_to_fields, $array ) );
 519  }
 520  
 521  function things_to_fields( $data ) {
 522      if ( is_array( $data ) ) {
 523          foreach ( $data as $item_id => $item ) {
 524              $data[ $item_id ] = things_to_fields( $item );
 525          }
 526      } elseif ( $data instanceof GP_Thing ) {
 527          $data = $data->fields();
 528      }
 529  
 530      return $data;
 531  }
 532  
 533  function gp_preferred_sans_serif_style_tag( $locale ) {
 534      if ( ! $locale->preferred_sans_serif_font_family ) {
 535          return;
 536      }
 537  
 538      ?>
 539  <style type="text/css">
 540      .foreign-text {
 541          font-family: "<?php echo esc_attr( $locale->preferred_sans_serif_font_family ); ?>", inherit;
 542      }
 543  </style>
 544      <?php
 545  }
 546  
 547  function gp_html_excerpt( $str, $count, $ellipsis = '&hellip;' ) {
 548      $excerpt = trim( wp_html_excerpt( $str, $count ) );
 549      if ( $str != $excerpt ) {
 550          $excerpt .= $ellipsis;
 551      }
 552      return $excerpt;
 553  }
 554  
 555  function gp_checked( $checked ) {
 556      if ( $checked ) {
 557          echo 'checked="checked"';
 558      }
 559  }
 560  
 561  function gp_project_actions( $project, $translation_sets ) {
 562      $actions = array(
 563          gp_link_get( gp_url_project( $project, 'import-originals' ), __( 'Import Originals', 'glotpress' ) ),
 564          gp_link_get( gp_url_project( $project, array( '-permissions' ) ), __( 'Permissions', 'glotpress' ) ),
 565          gp_link_get( gp_url_project( '', '-new', array( 'parent_project_id' => $project->id ) ), __( 'New Sub-Project', 'glotpress' ) ),
 566          gp_link_get( gp_url( '/sets/-new', array( 'project_id' => $project->id ) ), __( 'New Translation Set', 'glotpress' ) ),
 567          gp_link_get( gp_url_project( $project, array( '-mass-create-sets' ) ), __( 'Mass-create Translation Sets', 'glotpress' ) ),
 568          gp_link_get( gp_url_project( $project, '-branch' ), __( 'Branch project', 'glotpress' ) ),
 569          gp_link_get( gp_url_project( $project, '-delete' ), __( 'Delete project', 'glotpress' ) ),
 570      );
 571  
 572      /**
 573       * Project action links.
 574       *
 575       * @since 1.0.0
 576       *
 577       * @param array      $actions Links as HTML strings.
 578       * @param GP_Project $project The project.
 579       */
 580      $actions = apply_filters( 'gp_project_actions', $actions, $project );
 581  
 582      echo '<ul>';
 583  
 584      foreach ( $actions as $action ) {
 585          // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
 586          echo '<li>' . $action . '</li>';
 587      }
 588  
 589      if ( $translation_sets ) {
 590          echo '<li>' . gp_project_options_form( $project ) . '</li>';
 591      }
 592  
 593      echo '</ul>';
 594  }
 595  
 596  function gp_project_options_form( $project ) {
 597      return '
 598              <a href="#" class="personal-options" id="personal-options-toggle"> ' . __( 'Personal project options', 'glotpress' ) . ' &darr;</a>
 599              <div class="personal-options">
 600                  <form action="' . gp_url_project( $project, '-personal' ) . '" method="post">
 601                  <dl>
 602                      <dt><label for="source-url-template">' . __( 'Source file URL', 'glotpress' ) . '</label></dt>
 603                      <dd>
 604                          <input type="text" value="' . esc_html( $project->source_url_template() ) . '" name="source-url-template" id="source-url-template" />
 605                          <small>' . sprintf(
 606                              /* translators: 1: %file%, 2: %line%, 3: https://trac.example.org/browser/%file%#L%line% */
 607                              __( 'URL to a source file in the project. You can use %1$s and %2$s. Ex. %3$s', 'glotpress' ),
 608                              '<code>%file%</code>',
 609                              '<code>%line%</code>',
 610                              '<code>https://trac.example.org/browser/%file%#L%line%</code>'
 611                          ) . '</small>
 612                      </dd>
 613                  </dl>
 614                  <p>
 615                      <input type="submit" name="submit" value="' . esc_attr__( 'Save &rarr;', 'glotpress' ) . '" id="save" />
 616                      <a class="ternary" href="#" onclick="jQuery(\'#personal-options-toggle\').click();return false;">' . __( 'Cancel', 'glotpress' ) . '</a>
 617                  </p>
 618                  ' . gp_route_nonce_field( 'set-personal-options_' . $project->id, false ) . '
 619                  </form>
 620              </div>';
 621  }
 622  
 623  function gp_entry_actions( $seperator = ' &bull; ' ) {
 624      $actions = array(
 625          '<button class="copy" tabindex="-1" title="' . __( 'Copy the original string to the translation area (overwrites existing text).', 'glotpress' ) . '">' . __( 'Copy from original', 'glotpress' ) . '</button> ' .
 626          '<button class="inserttab" tabindex="-1" title="' . __( 'Insert tab (\t) at the current cursor position.', 'glotpress' ) . '">' . __( 'Insert tab', 'glotpress' ) . '</button> ' .
 627          '<button class="insertnl" tabindex="-1" title="' . __( 'Insert newline (\n) at the current cursor position.', 'glotpress' ) . '">' . __( 'Insert newline', 'glotpress' ) . '</button>',
 628      );
 629  
 630      /**
 631       * Filters entry action links.
 632       *
 633       * @since 1.0.0
 634       *
 635       * @param array $actions Links as HTML strings.
 636       */
 637      $actions = apply_filters( 'gp_entry_actions', $actions );
 638  
 639      // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
 640      echo implode( $seperator, $actions );
 641  }
 642  
 643  /**
 644   * Generates a list of classes to be added to the translation row, based on translation entry properties.
 645   *
 646   * @since 2.2.0
 647   *
 648   * @param Translation_Entry $translation The translation entry object for the row.
 649   *
 650   * @return array
 651   */
 652  function gp_get_translation_row_classes( $translation ) {
 653      $classes   = array();
 654      $classes[] = $translation->translation_status ? 'status-' . $translation->translation_status : 'untranslated';
 655      $classes[] = 'priority-' . gp_array_get( GP::$original->get_static( 'priorities' ), $translation->priority );
 656      $classes[] = $translation->warnings ? 'has-warnings' : 'no-warnings';
 657      $classes[] = count( array_filter( $translation->translations, 'gp_is_not_null' ) ) > 0 ? 'has-translations' : 'no-translations';
 658  
 659      if ( property_exists( $translation, 'root_translation_set_id' ) ) {
 660          $classes[] = $translation->translation_set_id === $translation->root_translation_set_id ? 'root-translation' : '';
 661      }
 662  
 663      /**
 664       * Filters the list of CSS classes for a translation row
 665       *
 666       * @since 2.2.0
 667       *
 668       * @param array             $classes     An array of translation row classes.
 669       * @param Translation_Entry $translation The translation entry object.
 670       */
 671      $classes = apply_filters( 'gp_translation_row_classes', $classes, $translation );
 672  
 673      return $classes;
 674  }
 675  
 676  /**
 677   * Outputs space separated list of classes for the translation row, based on translation entry properties.
 678   *
 679   * @since 2.2.0
 680   *
 681   * @param Translation_Entry $translation The translation entry object for the row.
 682   *
 683   * @return void
 684   */
 685  function gp_translation_row_classes( $translation ) {
 686      $classes = gp_get_translation_row_classes( $translation );
 687      echo esc_attr( implode( ' ', $classes ) );
 688  }


Generated: Thu Sep 24 01:04:02 2020 Cross-referenced by PHPXref 0.7.1