: : :
'; $_options = array( 'all' => yourls__( 'All fields' ), 'keyword' => yourls__( 'Short URL' ), 'url' => yourls__( 'URL' ), 'title' => yourls__( 'Title' ), 'ip' => yourls__( 'IP' ), ); $_select = yourls_html_select( 'search_in', $_options, $search_in ); /* //translators: "Search for in ' ); echo "
\n"; // Fourth search control: Show links with more than XX clicks $_options = array( 'more' => yourls__( 'more' ), 'less' => yourls__( 'less' ), ); $_select = yourls_html_select( 'click_filter', $_options, $click_filter ); $_input = ' '; /* //translators: "Show links with than clicks" */ yourls_se( 'Show links with %1$s than %2$s clicks', $_select, $_input ); echo "
\n"; // Fifth search control: Show links created before/after/between ... $_options = array( 'before' => yourls__('before'), 'after' => yourls__('after'), 'between' => yourls__('between'), ); $_select = yourls_html_select( 'date_filter', $_options, $date_filter ); $_input = ''; $_and = ' & '; $_input2 = ''; /* //translators: "Show links created <"and" if applicable> " */ yourls_se( 'Show links created %1$s %2$s %3$s %4$s', $_select, $_input, $_and, $_input2 ); ?>
 
'Text displayed' * @param string $selected optional 'value' from the $options array that will be highlighted * @param boolean $display false (default) to return, true to echo * @return string HTML content of the select element */ function yourls_html_select( $name, $options, $selected = '', $display = false ) { $html = "

:
: +

$title" ); echo yourls_apply_filter( 'die_message', "

$message

" ); // Hook into 'yourls_die' to add more elements or messages to that page yourls_do_action( 'yourls_die' ); if( !yourls_did_action( 'html_footer' ) ) { yourls_html_footer(); } die(); } /** * Return an "Edit" row for the main table * * @param string $keyword Keyword to edit * @return string HTML of the edit row */ function yourls_table_edit_row( $keyword ) { $keyword = yourls_sanitize_string( $keyword ); $id = yourls_string2htmlid( $keyword ); // used as HTML #id $url = yourls_get_keyword_longurl( $keyword ); $title = htmlspecialchars( yourls_get_keyword_title( $keyword ) ); $safe_url = yourls_esc_attr( rawurldecode( $url ) ); $safe_title = yourls_esc_attr( $title ); // Make strings sprintf() safe: '%' -> '%%' $safe_url = str_replace( '%', '%%', $safe_url ); $safe_title = str_replace( '%', '%%', $safe_title ); $www = yourls_link(); $nonce = yourls_create_nonce( 'edit-save_'.$id ); if( $url ) { $return = <<%s:
%s: $www
%s:   RETURN; $return = sprintf( $return, yourls__( 'Long URL' ), yourls__( 'Short URL' ), yourls__( 'Title' ), yourls__( 'Save' ), yourls__( 'Save new values' ), yourls__( 'Cancel' ), yourls__( 'Cancel editing' ) ); } else { $return = '' . yourls__( 'Error, URL not found' ) . ''; } $return = yourls_apply_filter( 'table_edit_row', $return, $keyword, $url, $title ); return $return; } /** * Return an "Add" row for the main table * * @return string HTML of the edit row */ function yourls_table_add_row( $keyword, $url, $title = '', $ip, $clicks, $timestamp ) { $keyword = yourls_sanitize_string( $keyword ); $id = yourls_string2htmlid( $keyword ); // used as HTML #id $shorturl = yourls_link( $keyword ); $statlink = yourls_statlink( $keyword ); $delete_link = yourls_nonce_url( 'delete-link_'.$id, yourls_add_query_arg( array( 'id' => $id, 'action' => 'delete', 'keyword' => $keyword ), yourls_admin_url( 'admin-ajax.php' ) ) ); $edit_link = yourls_nonce_url( 'edit-link_'.$id, yourls_add_query_arg( array( 'id' => $id, 'action' => 'edit', 'keyword' => $keyword ), yourls_admin_url( 'admin-ajax.php' ) ) ); // Action link buttons: the array $actions = array( 'stats' => array( 'href' => $statlink, 'id' => "statlink-$id", 'title' => yourls_esc_attr__( 'Stats' ), 'anchor' => yourls__( 'Stats' ), ), 'share' => array( 'href' => '', 'id' => "share-button-$id", 'title' => yourls_esc_attr__( 'Share' ), 'anchor' => yourls__( 'Share' ), 'onclick' => "toggle_share('$id');return false;", ), 'edit' => array( 'href' => $edit_link, 'id' => "edit-button-$id", 'title' => yourls_esc_attr__( 'Edit' ), 'anchor' => yourls__( 'Edit' ), 'onclick' => "edit_link_display('$id');return false;", ), 'delete' => array( 'href' => $delete_link, 'id' => "delete-button-$id", 'title' => yourls_esc_attr__( 'Delete' ), 'anchor' => yourls__( 'Delete' ), 'onclick' => "remove_link('$id');return false;", ) ); $actions = yourls_apply_filter( 'table_add_row_action_array', $actions ); // Action link buttons: the HTML $action_links = ''; foreach( $actions as $key => $action ) { $onclick = isset( $action['onclick'] ) ? 'onclick="' . $action['onclick'] . '"' : '' ; $action_links .= sprintf( '%s', $action['href'], $action['id'], $action['title'], 'button button_'.$key, $onclick, $action['anchor'] ); } $action_links = yourls_apply_filter( 'action_links', $action_links, $keyword, $url, $ip, $clicks, $timestamp ); if( ! $title ) $title = $url; $protocol_warning = ''; if( ! in_array( yourls_get_protocol( $url ) , array( 'http://', 'https://' ) ) ) $protocol_warning = yourls_apply_filter( 'add_row_protocol_warning', '' ); // Row cells: the array $cells = array( 'keyword' => array( 'template' => '%keyword_html%', 'shorturl' => yourls_esc_url( $shorturl ), 'keyword_html' => yourls_esc_html( $keyword ), ), 'url' => array( 'template' => '%title_html%
%warning%%long_url_html%', 'long_url' => yourls_esc_url( $url ), 'title_attr' => yourls_esc_attr( $title ), 'title_html' => yourls_esc_html( yourls_trim_long_string( $title ) ), 'long_url_html' => yourls_esc_html( yourls_trim_long_string( $url ) ), 'warning' => $protocol_warning, ), 'timestamp' => array( 'template' => '%date%', 'date' => date( 'M d, Y H:i', $timestamp +( YOURLS_HOURS_OFFSET * 3600 ) ), ), 'ip' => array( 'template' => '%ip%', 'ip' => $ip, ), 'clicks' => array( 'template' => '%clicks%', 'clicks' => yourls_number_format_i18n( $clicks, 0, '', '' ), ), 'actions' => array( 'template' => '%actions% ', 'actions' => $action_links, 'id' => $id, 'keyword' => $keyword, ), ); $cells = yourls_apply_filter( 'table_add_row_cell_array', $cells, $keyword, $url, $title, $ip, $clicks, $timestamp ); // Row cells: the HTML. Replace every %stuff% in 'template' with 'stuff' value. $row = ""; foreach( $cells as $cell_id => $elements ) { $callback = new yourls_table_add_row_callback( $elements ); $row .= sprintf( '', $cell_id, $cell_id . '-' . $id ); $row .= preg_replace_callback( '/%([^%]+)?%/', array( $callback, 'callback' ), $elements['template'] ); // For the record, in PHP 5.3+ we don't need to introduce a class in order to pass additional parameters // to the callback function. Instead, we would have used the 'use' keyword : // $row .= preg_replace_callback( '/%([^%]+)?%/', function( $match ) use ( $elements ) { return $elements[ $match[1] ]; }, $elements['template'] ); $row .= ''; } $row .= ""; $row = yourls_apply_filter( 'table_add_row', $row, $keyword, $url, $title, $ip, $clicks, $timestamp ); return $row; } /** * Callback class for yourls_table_add_row * * See comment about PHP 5.3+ in yourls_table_add_row() * * @since 1.7 */ class yourls_table_add_row_callback { private $elements; function __construct($elements) { $this->elements = $elements; } function callback( $matches ) { return $this->elements[ $matches[1] ]; } } /** * Echo the main table head * */ function yourls_table_head() { $start = ''."\n"; echo yourls_apply_filter( 'table_head_start', $start ); $cells = yourls_apply_filter( 'table_head_cells', array( 'shorturl' => yourls__( 'Short URL' ), 'longurl' => yourls__( 'Original URL' ), 'date' => yourls__( 'Date' ), 'ip' => yourls__( 'IP' ), 'clicks' => yourls__( 'Clicks' ), 'actions' => yourls__( 'Actions' ) ) ); foreach( $cells as $k => $v ) { echo "\n"; } $end = "\n"; echo yourls_apply_filter( 'table_head_end', $end ); } /** * Echo the tbody start tag * */ function yourls_table_tbody_start() { echo yourls_apply_filter( 'table_tbody_start', '' ); } /** * Echo the tbody end tag * */ function yourls_table_tbody_end() { echo yourls_apply_filter( 'table_tbody_end', '' ); } /** * Echo the table start tag * */ function yourls_table_end() { echo yourls_apply_filter( 'table_end', '
$v