Skip to content

Plugin download tracker JS #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ This is a set of plugins, themes, and configuration files for jQuery's website i
ServerName local.jquery.com
ServerAlias *.jquery.com *.jqueryui.com *.jquery.org *.qunitjs.com *.sizzlejs.com *.jquerymobile.com
DocumentRoot "/srv/www/jquery"
<Directory "/srv/www/jquery">
Options All
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
```

Expand Down
4 changes: 1 addition & 3 deletions install.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ function jquery_install_site( $site, $user ) {
$default_options = jquery_default_site_options();
$default_options['admin_email'] = $user->user_email;

var_dump( $domain, $path, $site );

if ( 1 !== $details['blog_id'] ) {
$blog_id = insert_blog( JQUERY_STAGING_PREFIX . $domain, $path, 1 );
if ( $blog_id != $details['blog_id'] )
Expand All @@ -89,6 +87,6 @@ function jquery_install_site( $site, $user ) {
foreach ( $options as $option => $value )
update_option( $option, $value );

flush_rewrite_rules();
delete_option( 'rewrite_rules' );
restore_current_blog();
}
9 changes: 9 additions & 0 deletions mu-plugins/jquery-filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,12 @@ function jquery_unfiltered_html_for_term_descriptions() {

// Bypass multisite checks.
add_filter( 'ms_site_check', '__return_true' );

// Add body classes found in postmeta.
add_filter( 'body_class', function( $classes ) {
if ( ! is_singular() )
return $classes;
if ( ! $post_classes = get_post_meta( get_queried_object_id(), 'body_class', true ) )
return $classes;
return array_merge( $classes, explode( ' ', $post_classes ) );
});
2 changes: 2 additions & 0 deletions sunrise.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
$current_blog->blog_id = $current_blog->site_id = $current_blog->public = 1;
$current_blog->archived = $current_blog->deleted = $current_blog->spam = 0;

add_filter( 'ms_site_check', '__return_true' );

if ( ! defined( 'WP_INSTALLING' ) ) {
// Okay, see if we can find the main site in the DB.
// If not, time for a new network install.
Expand Down
3 changes: 2 additions & 1 deletion themes/plugins.jquery.com/content-jquery_plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
* @subpackage Twenty_Eleven
* @since Twenty Eleven 1.0
*/
?>

wp_enqueue_script( 'jquery-plugin-download' ); ?>

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="entry-content clearfix">
Expand Down
4 changes: 4 additions & 0 deletions themes/plugins.jquery.com/functions.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php

add_action( 'wp_enqueue_scripts', function() {
wp_register_script( 'jquery-plugin-download', get_stylesheet_directory_uri() . '/js/download-tracker.js', array(), null, true );
});

function jq_plugin_meta( $attr ) {
$post = get_post( get_the_ID() );
$main_post = empty( $post->post_parent ) ? $post->ID : $post->post_parent;
Expand Down
17 changes: 17 additions & 0 deletions themes/plugins.jquery.com/js/download-tracker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
$(document).ready(function() {
// Tracks clicks of the plugin download button
$("a.download").click(function(event) {
// Query parameter distinguishes click tracking request from normal page load
var clickTrackerURL = window.location + "?d=1";
var downloadURL = $(this).attr("href");

event.preventDefault();

$.ajax({
type: "HEAD",
url: clickTrackerURL
}).done(function() {
window.location = downloadURL;
});
});
});