[ Index ]

PHP Cross Reference of YOURLS

title

Body

[close]

/includes/ -> functions-html.php (source)

   1  <?php
   2  
   3  /**
   4   * Display <h1> header and logo
   5   *
   6   * @return void
   7   */
   8  function yourls_html_logo() {
   9      yourls_do_action( 'pre_html_logo' );
  10      ?>
  11      <header role="banner">
  12      <h1>
  13          <a href="<?php echo yourls_admin_url( 'index.php' ) ?>" title="YOURLS"><span>YOURLS</span>: <span>Y</span>our <span>O</span>wn <span>URL</span> <span>S</span>hortener<br/>
  14          <img src="<?php yourls_site_url(); ?>/images/yourls-logo.svg?v=<?php echo YOURLS_VERSION; ?>" id="yourls-logo" alt="YOURLS" title="YOURLS" /></a>
  15      </h1>
  16      </header>
  17      <?php
  18      yourls_do_action( 'html_logo' );
  19  }
  20  
  21  /**
  22   * Display HTML head and <body> tag
  23   *
  24   * @param string $context Context of the page (stats, index, infos, ...)
  25   * @param string $title HTML title of the page
  26   * @return void
  27   */
  28  function yourls_html_head( $context = 'index', $title = '' ) {
  29  
  30      yourls_do_action( 'pre_html_head', $context, $title );
  31  
  32      // All components to false, except when specified true
  33      $share = $insert = $tablesorter = $tabs = $cal = $charts = false;
  34  
  35      // Load components as needed
  36      switch ( $context ) {
  37          case 'infos':
  38              $share = $tabs = $charts = true;
  39              break;
  40  
  41          case 'bookmark':
  42              $share = $insert = $tablesorter = true;
  43              break;
  44  
  45          case 'index':
  46              $insert = $tablesorter = $cal = $share = true;
  47              break;
  48  
  49          case 'plugins':
  50          case 'tools':
  51              $tablesorter = true;
  52              break;
  53  
  54          case 'login':
  55              $_title_page = 'Login';
  56              break;
  57  
  58          case 'install':
  59          case 'new':
  60          case 'upgrade':
  61              break;
  62      }
  63  
  64      // Force no cache for all admin pages
  65      if( yourls_is_admin() && !headers_sent() ) {
  66          yourls_no_cache_headers();
  67          yourls_no_frame_header();
  68          yourls_content_type_header( yourls_apply_filter( 'html_head_content-type', 'text/html' ) );
  69          yourls_do_action( 'admin_headers', $context, $title );
  70      }
  71  
  72      // Store page context
  73      yourls_set_html_context($context);
  74  
  75      // Body class
  76      $bodyclass = yourls_apply_filter( 'bodyclass', '' );
  77      $bodyclass .= ( yourls_is_mobile_device() ? 'mobile' : 'desktop' );
  78  
  79      // Page title
  80      $_title = 'YOURLS &mdash; Your Own URL Shortener | ' . yourls_link();
  81      $_title = $_title_page ? $_title_page . ' &mdash; ' . $_title : $_title;
  82      $title = $title ? $title . " &laquo; " . $_title : $_title;
  83      $title = yourls_apply_filter( 'html_title', $title, $context );
  84  
  85      ?>
  86  <!DOCTYPE html>
  87  <html <?php yourls_html_language_attributes(); ?>>
  88  <head>
  89      <title><?php echo $title ?></title>
  90      <meta http-equiv="Content-Type" content="<?php echo yourls_apply_filter( 'html_head_meta_content-type', 'text/html; charset=utf-8' ); ?>" />
  91      <meta name="generator" content="YOURLS <?php echo YOURLS_VERSION ?>" />
  92      <meta name="description" content="YOURLS &raquo; Your Own URL Shortener' | <?php yourls_site_url(); ?>" />
  93      <?php yourls_do_action('html_head_meta', $context); ?>
  94      <?php yourls_html_favicon(); ?>
  95      <script src="<?php yourls_site_url(); ?>/js/jquery-3.5.1.min.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script>
  96      <script src="<?php yourls_site_url(); ?>/js/common.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script>
  97      <script src="<?php yourls_site_url(); ?>/js/jquery.notifybar.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script>
  98      <link rel="stylesheet" href="<?php yourls_site_url(); ?>/css/style.css?v=<?php echo YOURLS_VERSION; ?>" type="text/css" media="screen" />
  99      <?php if ( $tabs ) { ?>
 100          <link rel="stylesheet" href="<?php yourls_site_url(); ?>/css/infos.css?v=<?php echo YOURLS_VERSION; ?>" type="text/css" media="screen" />
 101          <script src="<?php yourls_site_url(); ?>/js/infos.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script>
 102      <?php } ?>
 103      <?php if ( $tablesorter ) { ?>
 104          <link rel="stylesheet" href="<?php yourls_site_url(); ?>/css/tablesorter.css?v=<?php echo YOURLS_VERSION; ?>" type="text/css" media="screen" />
 105          <script src="<?php yourls_site_url(); ?>/js/jquery-3.tablesorter.min.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script>
 106          <script src="<?php yourls_site_url(); ?>/js/tablesorte.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script>
 107      <?php } ?>
 108      <?php if ( $insert ) { ?>
 109          <script src="<?php yourls_site_url(); ?>/js/insert.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script>
 110      <?php } ?>
 111      <?php if ( $share ) { ?>
 112          <link rel="stylesheet" href="<?php yourls_site_url(); ?>/css/share.css?v=<?php echo YOURLS_VERSION; ?>" type="text/css" media="screen" />
 113          <script src="<?php yourls_site_url(); ?>/js/share.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script>
 114          <script src="<?php yourls_site_url(); ?>/js/clipboard.min.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script>
 115      <?php } ?>
 116      <?php if ( $cal ) { ?>
 117          <link rel="stylesheet" href="<?php yourls_site_url(); ?>/css/cal.css?v=<?php echo YOURLS_VERSION; ?>" type="text/css" media="screen" />
 118          <?php yourls_l10n_calendar_strings(); ?>
 119          <script src="<?php yourls_site_url(); ?>/js/jquery.cal.js?v=<?php echo YOURLS_VERSION; ?>" type="text/javascript"></script>
 120      <?php } ?>
 121      <?php if ( $charts ) { ?>
 122              <script type="text/javascript" src="https://www.google.com/jsapi"></script>
 123              <script type="text/javascript">
 124                       google.load('visualization', '1.0', {'packages':['corechart', 'geochart']});
 125              </script>
 126      <?php } ?>
 127      <script type="text/javascript">
 128      //<![CDATA[
 129          var ajaxurl  = '<?php echo yourls_admin_url( 'admin-ajax.php' ); ?>';
 130      //]]>
 131      </script>
 132      <?php yourls_do_action( 'html_head', $context ); ?>
 133  </head>
 134  <body class="<?php echo $context; ?> <?php echo $bodyclass; ?>">
 135  <div id="wrap">
 136      <?php
 137  }
 138  
 139  /**
 140   * Display HTML footer (including closing body & html tags)
 141   *
 142   * Function yourls_die() will call this function with the optional param set to false: most likely, if we're using yourls_die(),
 143   * there's a problem, so don't maybe add to it by sending another SQL query
 144   *
 145   * @param  bool $can_query  If set to false, will not try to send another query to DB server
 146   * @return void
 147   */
 148  function yourls_html_footer($can_query = true) {
 149      if($can_query & yourls_get_debug_mode()) {
 150          $num_queries = yourls_get_num_queries();
 151          $num_queries = ' &ndash; '. sprintf( yourls_n( '1 query', '%s queries', $num_queries ), $num_queries );
 152      } else {
 153          $num_queries = '';
 154      }
 155  
 156      ?>
 157      </div><?php // wrap ?>
 158      <footer id="footer" role="contentinfo"><p>
 159          <?php
 160          $footer  = yourls_s( 'Powered by %s', '<a href="http://yourls.org/" title="YOURLS">YOURLS</a> v ' . YOURLS_VERSION );
 161          $footer .= $num_queries;
 162          echo yourls_apply_filter( 'html_footer_text', $footer );
 163          ?>
 164      </p></footer>
 165      <?php if( yourls_get_debug_mode() ) {
 166          echo '<div style="text-align:left"><pre>';
 167          echo join( "\n", yourls_get_debug_log() );
 168          echo '</pre></div>';
 169      } ?>
 170      <?php yourls_do_action( 'html_footer', yourls_get_html_context() ); ?>
 171      </body>
 172      </html>
 173      <?php
 174  }
 175  
 176  /**
 177   * Display "Add new URL" box
 178   *
 179   * @param string $url URL to prefill the input with
 180   * @param string $keyword Keyword to prefill the input with
 181   * @return void
 182   */
 183  function yourls_html_addnew( $url = '', $keyword = '' ) {
 184      $pre = yourls_apply_filter( 'shunt_html_addnew', false, $url, $keyword );
 185      if ( false !== $pre ) {
 186          return $pre;
 187      }
 188      ?>
 189      <main role="main">
 190      <div id="new_url">
 191          <div>
 192              <form id="new_url_form" action="" method="get">
 193                  <div>
 194                      <label for="add-url"><strong><?php yourls_e( 'Enter the URL' ); ?></strong></label>:
 195                      <input type="text" id="add-url" name="url" value="<?php echo $url; ?>" class="text" size="80" placeholder="https://" />
 196                      <label for="add-keyword"><?php yourls_e( 'Optional '); ?> : <strong><?php yourls_e('Custom short URL'); ?></strong></label>:
 197                      <input type="text" id="add-keyword" name="keyword" value="<?php echo $keyword; ?>" class="text" size="8" />
 198                      <?php yourls_nonce_field( 'add_url', 'nonce-add' ); ?>
 199                      <input type="button" id="add-button" name="add-button" value="<?php yourls_e( 'Shorten The URL' ); ?>" class="button" onclick="add_link();" />
 200                  </div>
 201              </form>
 202              <div id="feedback" style="display:none"></div>
 203          </div>
 204          <?php yourls_do_action( 'html_addnew' ); ?>
 205      </div>
 206      <?php
 207  }
 208  
 209  /**
 210   * Display main table's footer
 211   *
 212   * The $param array is defined in /admin/index.php, check the yourls_html_tfooter() call
 213   *
 214   * @param array $params Array of all required parameters
 215   * @return void
 216   */
 217  function yourls_html_tfooter( $params = array() ) {
 218      // Manually extract all parameters from the array. We prefer doing it this way, over using extract(),
 219      // to make things clearer and more explicit about what var is used.
 220      $search       = $params['search'];
 221      $search_text  = $params['search_text'];
 222      $search_in    = $params['search_in'];
 223      $sort_by      = $params['sort_by'];
 224      $sort_order   = $params['sort_order'];
 225      $page         = $params['page'];
 226      $perpage      = $params['perpage'];
 227      $click_filter = $params['click_filter'];
 228      $click_limit  = $params['click_limit'];
 229      $total_pages  = $params['total_pages'];
 230      $date_filter  = $params['date_filter'];
 231      $date_first   = $params['date_first'];
 232      $date_second  = $params['date_second'];
 233  
 234      ?>
 235      <tfoot>
 236          <tr>
 237              <th colspan="6">
 238              <div id="filter_form">
 239                  <form action="" method="get">
 240                      <div id="filter_options">
 241                          <?php
 242  
 243                          // First search control: text to search
 244                          $_input = '<input aria-label="' .yourls__( 'Search for' ). '" type="text" name="search" class="text" size="12" value="' . yourls_esc_attr( $search_text ) . '" />';
 245                          $_options = array(
 246                              'all'     => yourls__( 'All fields' ),
 247                              'keyword' => yourls__( 'Short URL' ),
 248                              'url'     => yourls__( 'URL' ),
 249                              'title'   => yourls__( 'Title' ),
 250                              'ip'      => yourls__( 'IP' ),
 251                          );
 252                          $_select = yourls_html_select( 'search_in', $_options, $search_in, false, yourls__( 'Search in' ) );
 253                          /* //translators: "Search for <input field with text to search> in <select dropdown with URL, title...>" */
 254                          yourls_se( 'Search for %1$s in %2$s', $_input , $_select );
 255                          echo "&ndash;\n";
 256  
 257                          // Second search control: order by
 258                          $_options = array(
 259                              'keyword'      => yourls__( 'Short URL' ),
 260                              'url'          => yourls__( 'URL' ),
 261                              'title'        => yourls__( 'Title' ),
 262                              'timestamp'    => yourls__( 'Date' ),
 263                              'ip'           => yourls__( 'IP' ),
 264                              'clicks'       => yourls__( 'Clicks' ),
 265                          );
 266                          $_select = yourls_html_select( 'sort_by', $_options, $sort_by, false,  yourls__( 'Sort by' ) );
 267                          $sort_order = isset( $sort_order ) ? $sort_order : 'desc' ;
 268                          $_options = array(
 269                              'asc'  => yourls__( 'Ascending' ),
 270                              'desc' => yourls__( 'Descending' ),
 271                          );
 272                          $_select2 = yourls_html_select( 'sort_order', $_options, $sort_order, false,  yourls__( 'Sort order' ) );
 273                          /* //translators: "Order by <criteria dropdown (date, clicks...)> in <order dropdown (Descending or Ascending)>" */
 274                          yourls_se( 'Order by %1$s %2$s', $_select , $_select2 );
 275                          echo "&ndash;\n";
 276  
 277                          // Third search control: Show XX rows
 278                          /* //translators: "Show <text field> rows" */
 279                          $_input = '<input aria-label="' .yourls__( 'Number of rows to show' ). '" type="text" name="perpage" class="text" size="2" value="' . $perpage . '" />';
 280                          yourls_se( 'Show %s rows',  $_input );
 281                          echo "<br/>\n";
 282  
 283                          // Fourth search control: Show links with more than XX clicks
 284                          $_options = array(
 285                              'more' => yourls__( 'more' ),
 286                              'less' => yourls__( 'less' ),
 287                          );
 288                          $_select = yourls_html_select( 'click_filter', $_options, $click_filter, false, yourls__( 'Show links with' ) );
 289                          $_input  = '<input aria-label="' .yourls__( 'Number of clicks' ). '" type="text" name="click_limit" class="text" size="4" value="' . $click_limit . '" /> ';
 290                          /* //translators: "Show links with <more/less> than <text field> clicks" */
 291                          yourls_se( 'Show links with %1$s than %2$s clicks', $_select, $_input );
 292                          echo "<br/>\n";
 293  
 294                          // Fifth search control: Show links created before/after/between ...
 295                          $_options = array(
 296                              'before'  => yourls__('before'),
 297                              'after'   => yourls__('after'),
 298                              'between' => yourls__('between'),
 299                          );
 300                          $_select = yourls_html_select( 'date_filter', $_options, $date_filter, false, yourls__('Show links created') );
 301                          $_input  = '<input aria-label="' .yourls__('Select a date') . '" type="text" name="date_first" id="date_first" class="text" size="12" value="' . $date_first . '" />';
 302                          $_and    = '<span id="date_and"' . ( $date_filter === 'between' ? ' style="display:inline"' : '' ) . '> &amp; </span>';
 303                          $_input2 = '<input aria-label="' .yourls__('Select an end date') . '" type="text" name="date_second" id="date_second" class="text" size="12" value="' . $date_second . '"' . ( $date_filter === 'between' ? ' style="display:inline"' : '' ) . '/>';
 304                          /* //translators: "Show links created <before/after/between> <date input> <"and" if applicable> <date input if applicable>" */
 305                          yourls_se( 'Show links created %1$s %2$s %3$s %4$s', $_select, $_input, $_and, $_input2 );
 306                          ?>
 307  
 308                          <div id="filter_buttons">
 309                              <input type="submit" id="submit-sort" value="<?php yourls_e('Search'); ?>" class="button primary" />
 310                              &nbsp;
 311                              <input type="button" id="submit-clear-filter" value="<?php yourls_e('Clear'); ?>" class="button" onclick="window.parent.location.href = 'index.php'" />
 312                          </div>
 313  
 314                      </div>
 315                  </form>
 316              </div>
 317  
 318              <?php
 319              // Remove empty keys from the $params array so it doesn't clutter the pagination links
 320              $params = array_filter( $params, function($val){ return $val !== '';} ); // remove keys with empty values
 321  
 322              if( isset( $search_text ) ) {
 323                  $params['search'] = $search_text;
 324                  unset( $params['search_text'] );
 325              }
 326              ?>
 327  
 328              <div id="pagination">
 329                  <span class="navigation">
 330                  <?php if( $total_pages > 1 ) { ?>
 331                      <span class="nav_total"><?php echo sprintf( yourls_n( '1 page', '%s pages', $total_pages ), $total_pages ); ?></span>
 332                      <?php
 333                      $base_page = yourls_admin_url( 'index.php' );
 334                      // Pagination offsets: min( max ( zomg! ) );
 335                      $p_start = max(  min( $total_pages - 4, $page - 2 ), 1 );
 336                      $p_end = min( max( 5, $page + 2 ), $total_pages );
 337                      if( $p_start >= 2 ) {
 338                          $link = yourls_add_query_arg( array_merge( $params, array( 'page' => 1 ) ), $base_page );
 339                          echo '<span class="nav_link nav_first"><a href="' . $link . '" title="' . yourls_esc_attr__('Go to First Page') . '">' . yourls__( '&laquo; First' ) . '</a></span>';
 340                          echo '<span class="nav_link nav_prev"></span>';
 341                      }
 342                      for( $i = $p_start ; $i <= $p_end; $i++ ) {
 343                          if( $i == $page ) {
 344                              echo "<span class='nav_link nav_current'>$i</span>";
 345                          } else {
 346                              $link = yourls_add_query_arg( array_merge( $params, array( 'page' => $i ) ), $base_page );
 347                              echo '<span class="nav_link nav_goto"><a href="' . $link . '" title="' . sprintf( yourls_esc_attr( 'Page %s' ), $i ) .'">'.$i.'</a></span>';
 348                          }
 349                      }
 350                      if( ( $p_end ) < $total_pages ) {
 351                          $link = yourls_add_query_arg( array_merge( $params, array( 'page' => $total_pages ) ), $base_page );
 352                          echo '<span class="nav_link nav_next"></span>';
 353                          echo '<span class="nav_link nav_last"><a href="' . $link . '" title="' . yourls_esc_attr__('Go to Last Page') . '">' . yourls__( 'Last &raquo;' ) . '</a></span>';
 354                      }
 355                      ?>
 356                  <?php } ?>
 357                  </span>
 358              </div>
 359              </th>
 360          </tr>
 361          <?php yourls_do_action( 'html_tfooter' ); ?>
 362      </tfoot>
 363      <?php
 364  }
 365  
 366  /**
 367   * Return or display a select dropdown field
 368   *
 369   * @since 1.6
 370   *
 371   * @param  string  $name      HTML 'name' (also use as the HTML 'id')
 372   * @param  array   $options   array of 'value' => 'Text displayed'
 373   * @param  string  $selected  optional 'value' from the $options array that will be highlighted
 374   * @param  boolean $display   false (default) to return, true to echo
 375   * @param  string  $label     ARIA label of the element
 376   * @return string HTML content of the select element
 377   */
 378  function yourls_html_select( $name, $options, $selected = '', $display = false, $label = '' ) {
 379      // Allow plugins to filter the options -- see #3262
 380      $options = yourls_apply_filter( 'html_select_options', $options, $name, $selected, $display, $label );
 381      $html = "<select aria-label='$label' name='$name' id='$name' size='1'>\n";
 382      foreach( $options as $value => $text ) {
 383          $html .= "<option value='$value' ";
 384          $html .= $selected == $value ? ' selected="selected"' : '';
 385          $html .= ">$text</option>\n";
 386      }
 387      $html .= "</select>\n";
 388      $html  = yourls_apply_filter( 'html_select', $html, $name, $options, $selected, $display );
 389      if( $display )
 390          echo $html;
 391      return $html;
 392  }
 393  
 394  
 395  /**
 396   * Display the Quick Share box
 397   *
 398   * @param string $longurl          Long URL
 399   * @param string $shorturl         Short URL
 400   * @param string $title            Title
 401   * @param string $text             Text to display
 402   * @param string $shortlink_title  Optional replacement for 'Your short link'
 403   * @param string $share_title      Optional replacement for 'Quick Share'
 404   * @param bool   $hidden           Optional. Hide the box by default (with css "display:none")
 405   * @return void
 406   */
 407  function yourls_share_box( $longurl, $shorturl, $title = '', $text='', $shortlink_title = '', $share_title = '', $hidden = false ) {
 408      if ( $shortlink_title == '' )
 409          $shortlink_title = '<h2>' . yourls__( 'Your short link' ) . '</h2>';
 410      if ( $share_title == '' )
 411          $share_title = '<h2>' . yourls__( 'Quick Share' ) . '</h2>';
 412  
 413      // Allow plugins to short-circuit the whole function
 414      $pre = yourls_apply_filter( 'shunt_share_box', false );
 415      if ( false !== $pre )
 416          return $pre;
 417  
 418      // Make sure IDN domains are in their UTF8 form
 419      $shorturl = yourls_normalize_uri($shorturl);
 420  
 421      $text   = ( $text ? '"'.$text.'" ' : '' );
 422      $title  = ( $title ? "$title " : '' );
 423      $share  = yourls_esc_textarea( $title.$text.$shorturl );
 424      $count  = 280 - strlen( $share );
 425      $hidden = ( $hidden ? 'style="display:none;"' : '' );
 426  
 427      // Allow plugins to filter all data
 428      $data = compact( 'longurl', 'shorturl', 'title', 'text', 'shortlink_title', 'share_title', 'share', 'count', 'hidden' );
 429      $data = yourls_apply_filter( 'share_box_data', $data );
 430      extract( $data );
 431  
 432      $_share = rawurlencode( $share );
 433      $_url   = rawurlencode( $shorturl );
 434      ?>
 435  
 436      <div id="shareboxes" <?php echo $hidden; ?>>
 437  
 438          <?php yourls_do_action( 'shareboxes_before', $longurl, $shorturl, $title, $text ); ?>
 439  
 440          <div id="copybox" class="share">
 441          <?php echo $shortlink_title; ?>
 442              <p><input id="copylink" class="text" size="32" value="<?php echo yourls_esc_url( $shorturl ); ?>" /></p>
 443              <p><small><?php yourls_e( 'Long link' ); ?>: <a id="origlink" href="<?php echo yourls_esc_url( $longurl ); ?>"><?php echo yourls_esc_url( $longurl ); ?></a></small>
 444              <?php if( yourls_do_log_redirect() ) { ?>
 445              <br/><small><?php yourls_e( 'Stats' ); ?>: <a id="statlink" href="<?php echo yourls_esc_url( $shorturl ); ?>+"><?php echo yourls_esc_url( $shorturl ); ?>+</a></small>
 446              <input type="hidden" id="titlelink" value="<?php echo yourls_esc_attr( $title ); ?>" />
 447              <?php } ?>
 448              </p>
 449          </div>
 450  
 451          <?php yourls_do_action( 'shareboxes_middle', $longurl, $shorturl, $title, $text ); ?>
 452  
 453          <div id="sharebox" class="share">
 454              <?php echo $share_title; ?>
 455              <div id="tweet">
 456                  <span id="charcount" class="hide-if-no-js"><?php echo $count; ?></span>
 457                  <textarea id="tweet_body"><?php echo $share; ?></textarea>
 458              </div>
 459              <p id="share_links"><?php yourls_e( 'Share with' ); ?>
 460                  <a id="share_tw" href="https://twitter.com/intent/tweet?text=<?php echo $_share; ?>" title="<?php yourls_e( 'Tweet this!' ); ?>" onclick="share('tw');return false">Twitter</a>
 461                  <a id="share_fb" href="https://www.facebook.com/share.php?u=<?php echo $_url; ?>" title="<?php yourls_e( 'Share on Facebook' ); ?>" onclick="share('fb');return false;">Facebook</a>
 462                  <?php
 463                  yourls_do_action( 'share_links', $longurl, $shorturl, $title, $text );
 464                  // Note: on the main admin page, there are no parameters passed to the sharebox when it's drawn.
 465                  ?>
 466              </p>
 467          </div>
 468  
 469          <?php yourls_do_action( 'shareboxes_after', $longurl, $shorturl, $title, $text ); ?>
 470  
 471      </div>
 472  
 473      <?php
 474  }
 475  
 476  /**
 477   * Die die die
 478   *
 479   * @see https://www.youtube.com/watch?v=zSiKETBjARk
 480   * @param string $message
 481   * @param string $title
 482   * @param int $header_code
 483   * @return void
 484   */
 485  function yourls_die( $message = '', $title = '', $header_code = 200 ) {
 486      yourls_do_action( 'pre_yourls_die', $message, $title, $header_code );
 487  
 488      yourls_status_header( $header_code );
 489  
 490      if( !yourls_did_action( 'html_head' ) ) {
 491          yourls_html_head();
 492          yourls_html_logo();
 493      }
 494      echo yourls_apply_filter( 'die_title', "<h2>$title</h2>" );
 495      echo yourls_apply_filter( 'die_message', "<p>$message</p>" );
 496      // Hook into 'yourls_die' to add more elements or messages to that page
 497      yourls_do_action( 'yourls_die' );
 498      if( !yourls_did_action( 'html_footer' ) ) {
 499          yourls_html_footer(false);
 500      }
 501  
 502      // die with a value in case we're running tests, so PHPUnit doesn't exit with 0 as if success
 503      die(1);
 504  }
 505  
 506  /**
 507   * Return an "Edit" row for the main table
 508   *
 509   * @param string $keyword Keyword to edit
 510   * @param string $id
 511   * @return string HTML of the edit row
 512   */
 513  function yourls_table_edit_row( $keyword, $id ) {
 514      $keyword = yourls_sanitize_keyword($keyword);
 515      $url = yourls_get_keyword_longurl( $keyword );
 516      $title = htmlspecialchars( yourls_get_keyword_title( $keyword ) );
 517      $safe_url = yourls_esc_attr( $url );
 518      $safe_title = yourls_esc_attr( $title );
 519      $safe_keyword = yourls_esc_attr( $keyword );
 520  
 521      // Make strings sprintf() safe: '%' -> '%%'
 522      $safe_url = str_replace( '%', '%%', $safe_url );
 523      $safe_title = str_replace( '%', '%%', $safe_title );
 524  
 525      $www = yourls_link();
 526  
 527      $nonce = yourls_create_nonce( 'edit-save_'.$id );
 528  
 529      if( $url ) {
 530          $return = <<<RETURN
 531  <tr id="edit-$id" class="edit-row"><td colspan="5" class="edit-row"><strong>%s</strong>:<input type="text" id="edit-url-$id" name="edit-url-$id" value="$safe_url" class="text" size="70" /><br/><strong>%s</strong>: $www<input type="text" id="edit-keyword-$id" name="edit-keyword-$id" value="$safe_keyword" class="text" size="10" /><br/><strong>%s</strong>: <input type="text" id="edit-title-$id" name="edit-title-$id" value="$safe_title" class="text" size="60" /></td><td colspan="1"><input type="button" id="edit-submit-$id" name="edit-submit-$id" value="%s" title="%s" class="button" onclick="edit_link_save('$id');" />&nbsp;<input type="button" id="edit-close-$id" name="edit-close-$id" value="%s" title="%s" class="button" onclick="edit_link_hide('$id');" /><input type="hidden" id="old_keyword_$id" value="$safe_keyword"/><input type="hidden" id="nonce_$id" value="$nonce"/></td></tr>
 532  RETURN;
 533          $return = sprintf( $return, yourls__( 'Long URL' ), yourls__( 'Short URL' ), yourls__( 'Title' ), yourls__( 'Save' ), yourls__( 'Save new values' ), yourls__( 'Cancel' ), yourls__( 'Cancel editing' ) );
 534      } else {
 535          $return = '<tr class="edit-row notfound"><td colspan="6" class="edit-row notfound">' . yourls__( 'Error, URL not found' ) . '</td></tr>';
 536      }
 537  
 538      $return = yourls_apply_filter( 'table_edit_row', $return, $keyword, $url, $title );
 539  
 540      return $return;
 541  }
 542  
 543  /**
 544   * Return an "Add" row for the main table
 545   *
 546   * @param string $keyword     Keyword (short URL)
 547   * @param string $url         URL (long URL)
 548   * @param string $title       Title
 549   * @param string $ip          IP
 550   * @param string|int $clicks  Number of clicks
 551   * @param string $timestamp   Timestamp
 552   * @param int    $row_id      Numeric value used to form row IDs, defaults to one
 553   * @return string             HTML of the row
 554   */
 555  function yourls_table_add_row( $keyword, $url, $title, $ip, $clicks, $timestamp, $row_id = 1 ) {
 556      $keyword  = yourls_sanitize_keyword($keyword);
 557      $id       = yourls_unique_element_id('yid', $row_id);
 558      $shorturl = yourls_link( $keyword );
 559  
 560      $statlink = yourls_statlink( $keyword );
 561  
 562      $delete_link = yourls_nonce_url( 'delete-link_'.$id,
 563          yourls_add_query_arg( array( 'id' => $id, 'action' => 'delete', 'keyword' => $keyword ), yourls_admin_url( 'admin-ajax.php' ) )
 564      );
 565  
 566      $edit_link = yourls_nonce_url( 'edit-link_'.$id,
 567          yourls_add_query_arg( array( 'id' => $id, 'action' => 'edit', 'keyword' => $keyword ), yourls_admin_url( 'admin-ajax.php' ) )
 568      );
 569  
 570      // Action link buttons: the array
 571      $actions = array(
 572          'stats' => array(
 573              'href'    => $statlink,
 574              'id'      => "statlink-$id",
 575              'title'   => yourls_esc_attr__( 'Stats' ),
 576              'anchor'  => yourls__( 'Stats' ),
 577          ),
 578          'share' => array(
 579              'href'    => '',
 580              'id'      => "share-button-$id",
 581              'title'   => yourls_esc_attr__( 'Share' ),
 582              'anchor'  => yourls__( 'Share' ),
 583              'onclick' => "toggle_share('$id');return false;",
 584          ),
 585          'edit' => array(
 586              'href'    => $edit_link,
 587              'id'      => "edit-button-$id",
 588              'title'   => yourls_esc_attr__( 'Edit' ),
 589              'anchor'  => yourls__( 'Edit' ),
 590              'onclick' => "edit_link_display('$id');return false;",
 591          ),
 592          'delete' => array(
 593              'href'    => $delete_link,
 594              'id'      => "delete-button-$id",
 595              'title'   => yourls_esc_attr__( 'Delete' ),
 596              'anchor'  => yourls__( 'Delete' ),
 597              'onclick' => "remove_link('$id');return false;",
 598          )
 599      );
 600      $actions = yourls_apply_filter( 'table_add_row_action_array', $actions, $keyword );
 601  
 602      // Action link buttons: the HTML
 603      $action_links = '';
 604      foreach( $actions as $key => $action ) {
 605          $onclick = isset( $action['onclick'] ) ? 'onclick="' . $action['onclick'] . '"' : '' ;
 606          $action_links .= sprintf( '<a href="%s" id="%s" title="%s" class="%s" %s>%s</a>',
 607              $action['href'], $action['id'], $action['title'], 'button button_'.$key, $onclick, $action['anchor']
 608          );
 609      }
 610      $action_links = yourls_apply_filter( 'action_links', $action_links, $keyword, $url, $ip, $clicks, $timestamp );
 611  
 612      if( ! $title )
 613          $title = $url;
 614  
 615      $protocol_warning = '';
 616      if( ! in_array( yourls_get_protocol( $url ) , array( 'http://', 'https://' ) ) )
 617          $protocol_warning = yourls_apply_filter( 'add_row_protocol_warning', '<span class="warning" title="' . yourls__( 'Not a common link' ) . '">&#9733;</span>' );
 618  
 619      // Row cells: the array
 620      $cells = array(
 621          'keyword' => array(
 622              'template'      => '<a href="%shorturl%">%keyword_html%</a>',
 623              'shorturl'      => yourls_esc_url( $shorturl ),
 624              'keyword_html'  => yourls_esc_html( $keyword ),
 625          ),
 626          'url' => array(
 627              'template'      => '<a href="%long_url%" title="%title_attr%">%title_html%</a><br/><small>%warning%<a href="%long_url%">%long_url_html%</a></small>',
 628              'long_url'      => yourls_esc_url( $url ),
 629              'title_attr'    => yourls_esc_attr( $title ),
 630              'title_html'    => yourls_esc_html( yourls_trim_long_string( $title ) ),
 631              'long_url_html' => yourls_esc_html( yourls_trim_long_string( urldecode( $url ) ) ),
 632              'warning'       => $protocol_warning,
 633          ),
 634          'timestamp' => array(
 635              'template' => '<span class="timestamp" aria-hidden="true">%timestamp%</span> %date%',
 636              'timestamp' => $timestamp,
 637              'date'     => yourls_date_i18n( yourls_get_datetime_format('M d, Y H:i'), yourls_get_timestamp( $timestamp )),
 638          ),
 639          'ip' => array(
 640              'template' => '%ip%',
 641              'ip'       => $ip,
 642          ),
 643          'clicks' => array(
 644              'template' => '%clicks%',
 645              'clicks'   => yourls_number_format_i18n( $clicks, 0 ),
 646          ),
 647          'actions' => array(
 648              'template' => '%actions% <input type="hidden" id="keyword_%id%" value="%keyword%"/>',
 649              'actions'  => $action_links,
 650              'id'       => $id,
 651              'keyword'  => $keyword,
 652          ),
 653      );
 654      $cells = yourls_apply_filter( 'table_add_row_cell_array', $cells, $keyword, $url, $title, $ip, $clicks, $timestamp );
 655  
 656      // Row cells: the HTML. Replace every %stuff% in 'template' with 'stuff' value.
 657      $row = "<tr id=\"id-$id\">";
 658      foreach( $cells as $cell_id => $elements ) {
 659          $row .= sprintf( '<td class="%s" id="%s">', $cell_id, $cell_id . '-' . $id );
 660          $row .= preg_replace_callback( '/%([^%]+)?%/', function( $match ) use ( $elements ) { return $elements[ $match[1] ]; }, $elements['template'] );
 661          $row .= '</td>';
 662      }
 663      $row .= "</tr>";
 664      $row  = yourls_apply_filter( 'table_add_row', $row, $keyword, $url, $title, $ip, $clicks, $timestamp );
 665  
 666      return $row;
 667  }
 668  
 669  /**
 670   * Echo the main table head
 671   *
 672   * @return void
 673   */
 674  function yourls_table_head() {
 675      $start = '<table id="main_table" class="tblSorter" cellpadding="0" cellspacing="1"><thead><tr>'."\n";
 676      echo yourls_apply_filter( 'table_head_start', $start );
 677  
 678      $cells = yourls_apply_filter( 'table_head_cells', array(
 679          'shorturl' => yourls__( 'Short URL' ),
 680          'longurl'  => yourls__( 'Original URL' ),
 681          'date'     => yourls__( 'Date' ),
 682          'ip'       => yourls__( 'IP' ),
 683          'clicks'   => yourls__( 'Clicks' ),
 684          'actions'  => yourls__( 'Actions' )
 685      ) );
 686      foreach( $cells as $k => $v ) {
 687          echo "<th id='main_table_head_$k'><span>$v</span></th>\n";
 688      }
 689  
 690      $end = "</tr></thead>\n";
 691      echo yourls_apply_filter( 'table_head_end', $end );
 692  }
 693  
 694  /**
 695   * Echo the tbody start tag
 696   *
 697   * @return void
 698   */
 699  function yourls_table_tbody_start() {
 700      echo yourls_apply_filter( 'table_tbody_start', '<tbody>' );
 701  }
 702  
 703  /**
 704   * Echo the tbody end tag
 705   *
 706   * @return void
 707   */
 708  function yourls_table_tbody_end() {
 709      echo yourls_apply_filter( 'table_tbody_end', '</tbody>' );
 710  }
 711  
 712  /**
 713   * Echo the table start tag
 714   *
 715   * @return void
 716   */
 717  function yourls_table_end() {
 718      echo yourls_apply_filter( 'table_end', '</table></main>' );
 719  }
 720  
 721  
 722  
 723  /**
 724   * Echo HTML tag for a link
 725   *
 726   * @param string $href     URL to link to
 727   * @param string $anchor   Anchor text
 728   * @param string $element  Element id
 729   * @return void
 730  */
 731  function yourls_html_link( $href, $anchor = '', $element = '' ) {
 732      if( !$anchor )
 733          $anchor = $href;
 734      if( $element )
 735          $element = sprintf( 'id="%s"', yourls_esc_attr( $element ) );
 736      $link = sprintf( '<a href="%s" %s>%s</a>', yourls_esc_url( $href ), $element, yourls_esc_html( $anchor ) );
 737      echo yourls_apply_filter( 'html_link', $link );
 738  }
 739  
 740  /**
 741   * Display the login screen. Nothing past this point.
 742   *
 743   * @param string $error_msg  Optional error message to display
 744   * @return void
 745   */
 746  function yourls_login_screen( $error_msg = '' ) {
 747      yourls_html_head( 'login' );
 748  
 749      $action = ( isset( $_GET['action'] ) && $_GET['action'] == 'logout' ? '?' : '' );
 750  
 751      yourls_html_logo();
 752      ?>
 753      <main role="main">
 754          <div id="login">
 755              <form method="post" action="<?php echo $action; ?>"> <?php // reset any QUERY parameters ?>
 756                  <?php
 757                      if( !empty( $error_msg ) ) {
 758                          echo '<p id="error-message" class="error">'.$error_msg.'</p>';
 759                      }
 760                      yourls_do_action( 'login_form_top' );
 761                  ?>
 762                  <p>
 763                      <label for="username"><?php yourls_e( 'Username' ); ?></label><br />
 764                      <input type="text" id="username" aria-describedby="error-message" name="username" class="text" autocomplete="username" />
 765                  </p>
 766                  <p>
 767                      <label for="password"><?php yourls_e( 'Password' ); ?></label><br />
 768                      <input type="password" id="password" name="password" class="text" autocomplete="current-password" />
 769                  </p>
 770                  <?php
 771                      yourls_do_action( 'login_form_bottom' );
 772                  ?>
 773                  <p style="text-align: right;">
 774                      <?php yourls_nonce_field('admin_login'); ?>
 775                      <input type="submit" id="submit" name="submit" value="<?php yourls_e( 'Login' ); ?>" class="button" />
 776                  </p>
 777                  <?php
 778                      yourls_do_action( 'login_form_end' );
 779                  ?>
 780              </form>
 781              <script type="text/javascript">$('#username').focus();</script>
 782          </div>
 783      </main>
 784      <?php
 785      yourls_html_footer();
 786      die();
 787  }
 788  
 789  
 790  /**
 791   * Display the admin menu
 792   *
 793   * @return void
 794   */
 795  function yourls_html_menu() {
 796      // Build menu links
 797      if( defined( 'YOURLS_USER' ) ) {
 798          // Create a logout link with a nonce associated to fake user 'logout' : the user is not yet defined
 799          // when the logout check is done -- see yourls_is_valid_user()
 800          $logout_url = yourls_nonce_url( 'admin_logout',
 801          yourls_add_query_arg(['action' => 'logout'], yourls_admin_url('index.php')), 'nonce', 'logout');
 802          $logout_link = yourls_apply_filter('logout_link', sprintf( yourls__('Hello <strong>%s</strong>'), YOURLS_USER ) . ' (<a href="' . $logout_url . '" title="' . yourls_esc_attr__( 'Logout' ) . '">' . yourls__( 'Logout' ) . '</a>)' );
 803      } else {
 804          $logout_link = yourls_apply_filter( 'logout_link', '' );
 805      }
 806      $help_link   = yourls_apply_filter( 'help_link',   '<a href="' . yourls_site_url( false ) .'/readme.html">' . yourls__( 'Help' ) . '</a>' );
 807  
 808      $admin_links    = array();
 809      $admin_sublinks = array();
 810  
 811      $admin_links['admin'] = array(
 812          'url'    => yourls_admin_url( 'index.php' ),
 813          'title'  => yourls__( 'Go to the admin interface' ),
 814          'anchor' => yourls__( 'Admin interface' )
 815      );
 816  
 817      if( yourls_is_admin() ) {
 818          $admin_links['tools'] = array(
 819              'url'    => yourls_admin_url( 'tools.php' ),
 820              'anchor' => yourls__( 'Tools' )
 821          );
 822          $admin_links['plugins'] = array(
 823              'url'    => yourls_admin_url( 'plugins.php' ),
 824              'anchor' => yourls__( 'Manage Plugins' )
 825          );
 826          $admin_sublinks['plugins'] = yourls_list_plugin_admin_pages();
 827      }
 828  
 829      $admin_links    = yourls_apply_filter( 'admin_links',    $admin_links );
 830      $admin_sublinks = yourls_apply_filter( 'admin_sublinks', $admin_sublinks );
 831  
 832      // Now output menu
 833      echo '<nav role="navigation"><ul id="admin_menu">'."\n";
 834      if ( yourls_is_private() && !empty( $logout_link ) )
 835          echo '<li id="admin_menu_logout_link">' . $logout_link .'</li>';
 836  
 837      foreach( (array)$admin_links as $link => $ar ) {
 838          if( isset( $ar['url'] ) ) {
 839              $anchor = isset( $ar['anchor'] ) ? $ar['anchor'] : $link;
 840              $title  = isset( $ar['title'] ) ? 'title="' . $ar['title'] . '"' : '';
 841              printf( '<li id="admin_menu_%s_link" class="admin_menu_toplevel"><a href="%s" %s>%s</a>', $link, $ar['url'], $title, $anchor );
 842          }
 843          // Output submenu if any. TODO: clean up, too many code duplicated here
 844          if( isset( $admin_sublinks[$link] ) ) {
 845              echo "<ul>\n";
 846              foreach( $admin_sublinks[$link] as $link => $ar ) {
 847                  if( isset( $ar['url'] ) ) {
 848                      $anchor = isset( $ar['anchor'] ) ? $ar['anchor'] : $link;
 849                      $title  = isset( $ar['title'] ) ? 'title="' . $ar['title'] . '"' : '';
 850                      printf( '<li id="admin_menu_%s_link" class="admin_menu_sublevel admin_menu_sublevel_%s"><a href="%s" %s>%s</a>', $link, $link, $ar['url'], $title, $anchor );
 851                  }
 852              }
 853              echo "</ul>\n";
 854          }
 855      }
 856  
 857      if ( isset( $help_link ) )
 858          echo '<li id="admin_menu_help_link">' . $help_link .'</li>';
 859  
 860      yourls_do_action( 'admin_menu' );
 861      echo "</ul></nav>\n";
 862      yourls_do_action( 'admin_notices' );
 863      yourls_do_action( 'admin_notice' ); // because I never remember if it's 'notices' or 'notice'
 864      /*
 865      To display a notice:
 866      $message = "<div>OMG, dude, I mean!</div>" );
 867      yourls_add_action( 'admin_notices', function() use ( $message ) { echo (string) $message; } );
 868      */
 869  }
 870  
 871  /**
 872   * Wrapper function to display admin notices
 873   *
 874   * @param string $message Message to display
 875   * @param string $style    Message style (default: 'notice')
 876   * @return void
 877   */
 878  function yourls_add_notice( $message, $style = 'notice' ) {
 879      // Escape single quotes in $message to avoid breaking the anonymous function
 880      $message = yourls_notice_box( strtr( $message, array( "'" => "\'" ) ), $style );
 881      yourls_add_action( 'admin_notices', function() use ( $message ) { echo (string) $message; } );
 882  }
 883  
 884  /**
 885   * Return a formatted notice
 886   *
 887   * @param string $message  Message to display
 888   * @param string $style    CSS class to use for the notice
 889   * @return string          HTML of the notice
 890   */
 891  function yourls_notice_box( $message, $style = 'notice' ) {
 892      return <<<HTML
 893      <div class="$style">
 894      <p>$message</p>
 895      </div>
 896  HTML;
 897  }
 898  
 899  /**
 900   * Display a page
 901   *
 902   * Includes content of a PHP file from the YOURLS_PAGEDIR directory, as if it
 903   * were a standard short URL (ie http://sho.rt/$page)
 904   *
 905   * @since 1.0
 906   * @param string $page  PHP file to display
 907   * @return void
 908   */
 909  function yourls_page( $page ) {
 910      if( !yourls_is_page($page)) {
 911          yourls_die( yourls_s('Page "%1$s" not found', $page), yourls__('Not found'), 404 );
 912      }
 913  
 914      yourls_do_action( 'pre_page', $page );
 915      $load = yourls_include_file_sandbox(YOURLS_PAGEDIR . "/$page.php");
 916      if (is_string($load)) {
 917          yourls_die( $load, yourls__('Not found'), 404 );
 918      }
 919      yourls_do_action( 'post_page', $page );
 920  }
 921  
 922  /**
 923   * Display the language attributes for the HTML tag.
 924   *
 925   * Builds up a set of html attributes containing the text direction and language
 926   * information for the page. Stolen from WP.
 927   *
 928   * @since 1.6
 929   * @return void
 930   */
 931  function yourls_html_language_attributes() {
 932      $attributes = array();
 933      $output = '';
 934  
 935      $attributes[] = ( yourls_is_rtl() ? 'dir="rtl"' : 'dir="ltr"' );
 936  
 937      $doctype = yourls_apply_filter( 'html_language_attributes_doctype', 'html' );
 938      // Experimental: get HTML lang from locale. Should work. Convert fr_FR -> fr-FR
 939      if ( $lang = str_replace( '_', '-', yourls_get_locale() ) ) {
 940          if( $doctype == 'xhtml' ) {
 941              $attributes[] = "xml:lang=\"$lang\"";
 942          } else {
 943              $attributes[] = "lang=\"$lang\"";
 944          }
 945      }
 946  
 947      $output = implode( ' ', $attributes );
 948      $output = yourls_apply_filter( 'html_language_attributes', $output );
 949      echo $output;
 950  }
 951  
 952  /**
 953   * Output translated strings used by the Javascript calendar
 954   *
 955   * @since 1.6
 956   * @return void
 957   */
 958  function yourls_l10n_calendar_strings() {
 959      echo "\n<script>\n";
 960      echo "var l10n_cal_month = " . json_encode( array_values( yourls_l10n_months() ) ) . ";\n";
 961      echo "var l10n_cal_days = " . json_encode( array_values( yourls_l10n_weekday_initial() ) ) . ";\n";
 962      echo "var l10n_cal_today = \"" . yourls_esc_js( yourls__( 'Today' ) ) . "\";\n";
 963      echo "var l10n_cal_close = \"" . yourls_esc_js( yourls__( 'Close' ) ) . "\";\n";
 964      echo "</script>\n";
 965  
 966      // Dummy returns, to initialize l10n strings used in the calendar
 967      yourls__( 'Today' );
 968      yourls__( 'Close' );
 969  }
 970  
 971  
 972  /**
 973   * Display a notice if there is a newer version of YOURLS available
 974   *
 975   * @since 1.7
 976   * @param string $compare_with Optional, YOURLS version to compare to
 977   * @return void
 978   */
 979  function yourls_new_core_version_notice($compare_with = null) {
 980      $compare_with = $compare_with ?: YOURLS_VERSION;
 981  
 982      $checks = yourls_get_option( 'core_version_checks' );
 983      $latest = isset($checks->last_result->latest) ? yourls_sanitize_version($checks->last_result->latest) : false;
 984  
 985      if( $latest AND version_compare( $latest, $compare_with, '>' ) ) {
 986          yourls_do_action('new_core_version_notice', $latest);
 987          $msg = yourls_s( '<a href="%s">YOURLS version %s</a> is available. Please update!', 'http://yourls.org/download', $latest );
 988          yourls_add_notice( $msg );
 989      }
 990  }
 991  
 992  /**
 993   * Display or return HTML for a bookmarklet link
 994   *
 995   * @since 1.7.1
 996   * @param string $href    bookmarklet link (presumably minified code with "javascript:" scheme)
 997   * @param string $anchor  link anchor
 998   * @param bool   $echo    true to display, false to return the HTML
 999   * @return string         the HTML for a bookmarklet link
1000   */
1001  function yourls_bookmarklet_link( $href, $anchor, $echo = true ) {
1002      $alert = yourls_esc_attr__( 'Drag to your toolbar!' );
1003      $link = <<<LINK
1004      <a href="$href" class="bookmarklet" onclick="alert('$alert');return false;">$anchor</a>
1005  LINK;
1006  
1007      if( $echo )
1008          echo $link;
1009      return $link;
1010  }
1011  
1012  /**
1013   * Set HTML context (stats, index, infos, ...)
1014   *
1015   * @since  1.7.3
1016   * @param  string  $context
1017   * @return void
1018   */
1019  function yourls_set_html_context($context) {
1020      yourls_get_db()->set_html_context($context);
1021  }
1022  
1023  /**
1024   * Get HTML context (stats, index, infos, ...)
1025   *
1026   * @since  1.7.3
1027   * @return string
1028   */
1029  function yourls_get_html_context() {
1030      return yourls_get_db()->get_html_context();
1031  }
1032  
1033  /**
1034   * Print HTML link for favicon
1035   *
1036   * @since 1.7.10
1037   * @return mixed|void
1038   */
1039  function yourls_html_favicon() {
1040      // Allow plugins to short-circuit the whole function
1041      $pre = yourls_apply_filter( 'shunt_html_favicon', false );
1042      if ( false !== $pre ) {
1043          return $pre;
1044      }
1045  
1046      printf( '<link rel="shortcut icon" href="%s" />', yourls_get_yourls_favicon_url(false) );
1047  }


Generated: Fri Mar 28 05:10:25 2025 Cross-referenced by PHPXref 0.7.1