Skip to content

Commit

Permalink
Hide query count if debug mode is false
Browse files Browse the repository at this point in the history
  • Loading branch information
ozh committed Mar 14, 2020
1 parent 352b427 commit d5b47a5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
8 changes: 4 additions & 4 deletions includes/functions-html.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ function yourls_html_head( $context = 'index', $title = '' ) {
* @return void
*/
function yourls_html_footer($can_query = true) {
if($can_query) {
if($can_query & yourls_get_debug_mode()) {
$num_queries = yourls_get_num_queries();
$num_queries = sprintf( yourls_n( '1 query', '%s queries', $num_queries ), $num_queries );
$num_queries = ' – '. sprintf( yourls_n( '1 query', '%s queries', $num_queries ), $num_queries );
} else {
$num_queries = '';
}
Expand All @@ -154,11 +154,11 @@ function yourls_html_footer($can_query = true) {
<footer id="footer" role="contentinfo"><p>
<?php
$footer = yourls_s( 'Powered by %s', '<a href="http://yourls.org/" title="YOURLS">YOURLS</a> v ' . YOURLS_VERSION );
$footer .= ' &ndash; '.$num_queries;
$footer .= $num_queries;
echo yourls_apply_filter( 'html_footer_text', $footer );
?>
</p></footer>
<?php if( defined( 'YOURLS_DEBUG' ) && YOURLS_DEBUG == true ) {
<?php if( yourls_get_debug_mode() ) {
echo '<div style="text-align:left"><pre>';
echo join( "\n", yourls_get_debug_log() );
echo '</pre></div>';
Expand Down
14 changes: 12 additions & 2 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2245,7 +2245,7 @@ function yourls_deprecated_function( $function, $version, $replacement = null )
yourls_do_action( 'deprecated_function', $function, $replacement, $version );

// Allow plugin to filter the output error trigger
if ( YOURLS_DEBUG && yourls_apply_filter( 'deprecated_function_trigger_error', true ) ) {
if ( yourls_get_debug_mode() && yourls_apply_filter( 'deprecated_function_trigger_error', true ) ) {
if ( ! is_null( $replacement ) )
trigger_error( sprintf( yourls__('%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $function, $version, $replacement ) );
else
Expand Down Expand Up @@ -2372,7 +2372,7 @@ function yourls_get_debug_log() {
}

/**
* Debug mode toggle
* Debug mode set
*
* @since 1.7.3
* @param bool $bool Debug on or off
Expand All @@ -2392,6 +2392,16 @@ function yourls_debug_mode($bool) {
}
}

/**
* Return YOURLS debug mode
*
* @since 1.7.7
* @return bool
*/
function yourls_get_debug_mode() {
return ( defined( 'YOURLS_DEBUG' ) && YOURLS_DEBUG == true );
}

/**
* Explode a URL in an array of ( 'protocol' , 'slashes if any', 'rest of the URL' )
*
Expand Down

0 comments on commit d5b47a5

Please sign in to comment.