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


Generated: Wed Sep 18 05:10:18 2024 Cross-referenced by PHPXref 0.7.1