Skip to content

Commit

Permalink
Add PACE loader option.
Browse files Browse the repository at this point in the history
  • Loading branch information
tlongren committed Oct 6, 2013
1 parent f7d7dca commit 0d0b8b4
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 2 deletions.
38 changes: 37 additions & 1 deletion functions.php
Expand Up @@ -10,7 +10,7 @@ function rootdip_layout_view() {
if ( ! isset( $content_width ) ) $content_width = 580;

// Set rootdip version
define( 'rootdip_version', '2.5.6' );
define( 'rootdip_version', '2.5.5' );
function rootdip_getinfo( $show = '' ) {
$output = '';

Expand Down Expand Up @@ -69,6 +69,10 @@ function rootdip_register_scripts() {
wp_enqueue_script( 'totop', get_stylesheet_directory_uri() . '/js/jquery.ui.totop.js', array( 'jquery' ), '1.1', true );
}

if ( $options['pace_loader'] == 1 ) {
wp_enqueue_script( 'pace_loader', get_stylesheet_directory_uri() . '/js/pace.min.js', array( 'jquery' ), '1.1', true );
}

if ( $options['enable_slimbox'] == 1 ) {
wp_enqueue_script( 'slimbox2', get_stylesheet_directory_uri() . '/js/slimbox2.js', array( 'jquery' ), '2.04', true );
}
Expand Down Expand Up @@ -403,5 +407,37 @@ function rootdip_custom_background_callback() {
<?php

}

// PressTrends theme tracking
add_action('wp_head', 'presstrends');
function presstrends() {
// Add your PressTrends and Theme API Keys
$api_key = 'a772ez0rwkeszmbwt9glta1bimxxfevhah4f';
$auth = 'bjt6p2d21y2cygqofqp6lkk0c9iy1snqf';

// NO NEED TO EDIT BELOW
$data = get_transient( 'presstrends_data' );
if (!$data || $data == ''){
$api_base = 'http://api.presstrends.io/index.php/api/sites/add/auth/';
$url = $api_base . $auth . '/api/' . $api_key . '/';
$data = array();
$count_posts = wp_count_posts();
$comments_count = wp_count_comments();
$theme_data = wp_get_theme(get_template_directory() . '/style.css');
$plugin_count = count(get_option('active_plugins'));
$data['url'] = stripslashes(str_replace(array('http://', '/', ':' ), '', site_url()));
$data['posts'] = $count_posts->publish;
$data['comments'] = $comments_count->total_comments;
$data['theme_version'] = $theme_data['Version'];
$data['theme_name'] = str_replace( ' ', '', get_bloginfo( 'name' ));
$data['plugins'] = $plugin_count;
$data['wpversion'] = get_bloginfo('version');
foreach ( $data as $k => $v ) {
$url .= $k . '/' . $v . '/';
}
$response = wp_remote_get( $url );
set_transient('presstrends_data', $data, 60*60*24);
}}

require( get_template_directory() . '/custom-header.php' );
?>
2 changes: 1 addition & 1 deletion style.css
Expand Up @@ -4,7 +4,7 @@ Theme URI: http://www.longren.org/wordpress/rootdip
Description: HTML5 & CSS3 theme designed by <a href="http://jayj.dk">Jesper</a> and coded by <a href="http://www.longren.org/wordpress/rootdip">Tyler</a>.
Author: Tyler Longren
Author URI: http://www.longren.org/
Version: 2.5.6
Version: 2.5.5
Tags: black, white, pink, blue, red, green, orange, two-columns, fixed-width, threaded-comments, custom-menu, right-sidebar, translation-ready
License: GNU General Public License
License URI: license.txt
Expand Down
12 changes: 12 additions & 0 deletions theme-options.php
Expand Up @@ -363,6 +363,12 @@ function rootdip_theme_options_page() {
<label for="back_to_top">Enabled</label>
</td>
</tr>
<tr valign="top"><th scope="row"><label for="pace_loader"><a href="http://github.hubspot.com/pace/docs/welcome/" target="_blank">Pace</a> Page Load Indicator</label></th>
<td>
<input type="checkbox" id="pace_loader" name="rootdip_options[pace_loader]" value="1" <?php checked( true, $options['pace_loader'] ); ?> />
<label for="pace_loader">Enabled</label>
</td>
</tr>
<tr valign="top"><th scope="row"><label for="show_tagline">Show Tagline In Header</label></th>
<td>
<input type="checkbox" id="show_tagline" name="rootdip_options[show_tagline]" value="1" <?php checked( true, $options['show_tagline'] ); ?> />
Expand Down Expand Up @@ -562,6 +568,12 @@ function rootdip_validate_options( $input ) {
// We verify if the input is a boolean value
$input['back_to_top'] = ( $input['back_to_top'] == 1 ? 1 : 0 );

// If the checkbox has not been checked, we void it
if ( ! isset( $input['pace_loader'] ) )
$input['pace_loader'] = null;
// We verify if the input is a boolean value
$input['pace_loader'] = ( $input['pace_loader'] == 1 ? 1 : 0 );

return $input;
}

Expand Down

0 comments on commit 0d0b8b4

Please sign in to comment.