Skip to content

Instantly share code, notes, and snippets.

@richardmtl
richardmtl / gist:8060045
Last active December 31, 2015 23:29
Remove link on Jetpack Facebook Like Box widget title; edit plugin here: http://plugins.trac.wordpress.org/browser/jetpack/trunk/modules/widgets/facebook-likebox.php#L75
if ( ! empty( $title ) ) :
echo $before_title;
echo esc_html( $title );
echo $after_title
endif;
@richardmtl
richardmtl / functions.php
Created January 31, 2014 18:53 — forked from kraftbj/functions.php
Make homepage og:image be an image from the latest post
<?php
function fb_home_image( $tags ) {
if ( is_home() ) {
$latest_post = get_posts("post_type=post&numberposts=1");
$latest_post = $latest_cpt[0]->ID;
if ( class_exists( 'Jetpack_PostImages' ) ) {
$post_images = Jetpack_PostImages::get_images( $latest_post, array( 'width' => 200, 'height' => 200 ) );
if ( $post_images && !is_wp_error( $post_images ) ) {
$image = array();
@richardmtl
richardmtl / Remove JP Stats from Homepage
Created July 15, 2014 16:56
Remove Jetpack Stats from homepage only
add_action( 'init', 'jp_remove_stats');
add_action( 'template_redirect', 'jp_maybe_add_tracking_code', 1);
function jp_remove_stats(){
remove_action( 'template_redirect', 'stats_template_redirect', 1 );
}
function jp_maybe_add_tracking_code(){
if( !is_home() ){
stats_template_redirect();
}
}
<?php
/*
* Plugin Name: AA Test Plugin
* Plugin URI: http://wordpress.org/extend/plugins/test
* Description: Testing all kinds of things!
* Author: Richard Archambault
* Version: 1.0
* License: GPL2+
*/
@richardmtl
richardmtl / jp_restrict_rp.php
Created August 4, 2014 14:19
Restrict Jetpack's Related Posts to a specific time-frame
function jetpackme_related_posts_date_restricted( $date_range, $post_id ) {
// We can change this based on $post_id too but let's just filter everything
$date_range = array(
'from' => strtotime( '1 January 2013' ),
'to' => time(),
);
return $date_range;
}
add_filter( 'jetpack_relatedposts_filter_date_range', 'jetpackme_related_posts_date_restricted' );
@richardmtl
richardmtl / 0_reuse_code.js
Last active August 29, 2015 14:15
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@richardmtl
richardmtl / css_resources.md
Last active August 29, 2015 14:15 — forked from jookyboi/css_resources.md
CSS libraries and guides to bring some order to the chaos.

Libraries

  • 960 Grid System - An effort to streamline web development workflow by providing commonly used dimensions, based on a width of 960 pixels. There are two variants: 12 and 16 columns, which can be used separately or in tandem.
  • Compass - Open source CSS Authoring Framework.
  • Bootstrap - Sleek, intuitive, and powerful mobile first front-end framework for faster and easier web development.
  • Font Awesome - The iconic font designed for Bootstrap.
  • Zurb Foundation - Framework for writing responsive web sites.
  • SASS - CSS extension language which allows variables, mixins and rules nesting.
  • Skeleton - Boilerplate for responsive, mobile-friendly development.

Guides

@richardmtl
richardmtl / wpcomfollow-allposts.php
Last active November 3, 2017 14:32
Adding WordPress.com Follow button to all posts
add_filter ('the_content', 'insertWPcomFollowerButton');
function insertWPcomFollowerButton($content) {
if(is_single()) {
$content.= '<a class="wordpress-follow-button" href="http://exoticmysticism.com" data-blog="http://exoticmysticism.com" data-lang="en">Follow Lisa Joy on WordPress.com</a>';
$content.= '<script type="text/javascript">(function(d){var f = d.getElementsByTagName('SCRIPT')[0], p = d.createElement('SCRIPT');p.type = 'text/javascript';p.async = true;p.src = '//widgets.wp.com/platform.js';f.parentNode.insertBefore(p,f);}(document));</script>';
}
return $content;
}
@richardmtl
richardmtl / gist:1b3e78f7e9bc26942888271b4cd2c49e
Created March 27, 2019 15:22
limit WPJM Applications allowed file types (untested)
function restrict_wpjm_applications_mime_types( $allowed_mime_types, $field) {
if ( $field['label'] == 'My Field' ) {
unset( $allowed_mime_types['png'] );
$allowed_mime_types['json'] = 'application/json';
}
return $allowed_mime_types;
}
add_filter( 'job_manager_mime_types', 'restrict_wpjm_applications_mime_types' );
@richardmtl
richardmtl / redirect.php
Created December 5, 2019 14:43
Redirect after a resume is submitted
add_action( 'resume_manager_resume_submitted', 'wpjmres_final_redirect', 99);
function wpjmres_final_redirect(){
wp_redirect('https://DOMAIN.COM');
exit();
}