Skip to content

Instantly share code, notes, and snippets.

Avatar
🚀
👨‍🏭

Jeremy Herve jeherve

🚀
👨‍🏭
View GitHub Profile
View plugin.php
<?php
/**
* Plugin Name: Add a list of Jetpack related posts to the bottom of each post in the Rest API Posts Embeds shortcode.
* Plugin URI: http://jeremy.hu/
* Description: Add a list of Jetpack related posts to the bottom of each post in the Rest API Posts Embeds shortcode.
* Author: Jeremy Herve
* Version: 1.0.0
* Author URI: https://jeremy.hu
* License: GPL2+
*/
@jeherve
jeherve / stats.md
Created Feb 21, 2017
Differences between different Stats plugins
View stats.md

The kStats Reloaded plugin hasn't been updated in the past 7 years, and offers few ways to exclude visits. It will consequently count a lot of bots, crawlers, and search engines.

WP Statistics is updated a lot more often, but since it relies on data included in the plugin itself, you can expect some bots to be included in the stats. You can find out more in the plugin's FAQ (see I'm using another statistics plugin/service and get different numbers for them, why?). It may also count your own visits.

Jetpack Stats, on the other hand, will exclude visits from logged in users by default. It also relies on the WordPress.com cloud to filter and exclude bots and other crawlers, and all calculatations happen on our servers so it won't affect your site's performance.

@jeherve
jeherve / plugin.php
Last active Feb 7, 2017
[Jetpack] Add tracking parameters to a post URL, and then have that tracked URL shortened by goo.gl, and then use that short URL in sharing buttons
View plugin.php
<?php
/**
* Overwrite the links used in Jetpack's Sharing module.
*
* @see https://wordpress.org/support/topic/how-to-use-utm-codes-with-jetpack-sharing
*
* @param string $url
* @param int $post_id
* @param int $sharing_id
* @filter sharing_permalink
View jp-rm-jpmenu.php
<?php
/*
* Plugin Name: Jetpack Only for Admins
* Plugin URI: http://wordpress.org/extend/plugins/
* Description: Hides the Jetpack menu for all non-admins
* Author: Jeremy Herve
* Version: 1.1
* Author URI: http://jeremyherve.com
* License: GPL2+
* Text Domain: jetpack
View jeherve-force-deactivate-protect.php
<?php
/**
* Plugin Name: Force Deactivate Jetpack's Protect Module.
* Plugin URI: https://jetpack.com/support/security-features/#unblock
* Description: If you have lost access to your site's dashboard, you can use this plugin to deactivate the Protect module.
* Author: Automattic
* Version: 1.0.0
* Author URI: http://jetpack.com
* License: GPL2+
*
@jeherve
jeherve / functions.php
Last active Oct 10, 2016
[Jetpack] Customize the contents of the "Older Posts" text appearing when activating Infinite Scroll.
View functions.php
<?php
function jeherve_custom_infinite_more() {
if ( is_home() || is_archive() ) {
?>
<script type="text/javascript">
//<![CDATA[
infiniteScroll.settings.text = "Custom Text";
//]]>
</script>
@jeherve
jeherve / plugin.php
Last active Sep 11, 2016
[Jetpack] Remove the Youtube shortcode
View plugin.php
<?php
/*
* Plugin Name: Remove Jetpack's Youtube shortcode
* Plugin URI: http://wordpress.org/extend/plugins/jetpack/
* Description: Removes Jetpack's Youtueb shortcode
* Author: Jeremy Herve
* Version: 1.0
* Author URI: http://jeremyherve.com
* License: GPL2+
*/
@jeherve
jeherve / plugin.php
Created Dec 9, 2013
[Jetpack] Force deactivate all modules but stats
View plugin.php
<?php
// Force deactivate all Jetpack modules, except for stats
function jeherve_force_deactivate_everything_but_stats() {
if ( class_exists( 'Jetpack_Options' ) )
Jetpack_Options::update_option( 'active_modules', array_unique( array( 'stats' ) ) );
}
add_action( 'init', 'jeherve_force_deactivate_everything_but_stats' );
View output.bash
$ curl -I https://i0.wp.com/jeremy.hu/wp-content/uploads/watson-5818.jpg
HTTP/1.1 200 OK
Server: nginx
Date: Tue, 07 Jun 2016 16:42:27 GMT
Content-Type: image/jpeg
Content-Length: 94394
Connection: keep-alive
Last-Modified: Tue, 07 Jun 2016 16:37:17 GMT
Expires: Fri, 08 Jun 2018 04:37:17 GMT
Cache-Control: public, max-age=63115200
@jeherve
jeherve / plugin.php
Last active Jun 6, 2016
Create an ordered list of popular posts, using Jetpack's Site Stats. See wordpress.org/support/topic/2883315
View plugin.php
<?php
/**
* Create an ordered list of popular posts, using Jetpack's Site Stats.
*
* @see wordpress.org/support/topic/2883315
*/
function jeherve_new_top_posts() {
if ( ! function_exists( 'stats_get_csv' ) ) {
You can’t perform that action at this time.