Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* Includes a few useful predicates in the bootstrapped `infiniteScroll` JS object
* that is served along with the rest of the document upon initial page request.
*/
add_filter( 'infinite_scroll_js_settings', 'pla_extra_js_settings' );
function pla_extra_js_settings( $js_settings ) {
$js_settings['text'] = __( "Plus de contenus", "pla" );
@isotrope
isotrope / wpml-language-switcher.php
Last active August 29, 2015 14:10
Adding WPML language switcher supportFeel free to add more classes to the links or the List Items to have more control over the CSS
<?php
// Adding WPML language switcher support
// Feel free to add more classes to the links or
// the List Items to have more control over the CSS
if ( function_exists( 'icl_get_languages' ) ) {
$available_languages = icl_get_languages( 'skip_missing=0' );
foreach ( $available_languages as $l ) {
if ( ! $l['active'] ) {
$langs[] = '<a href="' . $l['url'] . '" class="language_switch_link">' . $l['native_name'] . '</a>';
}
@isotrope
isotrope / save-post-test.php
Created December 1, 2014 18:47
Test to see if save_post hook is firing
<?php
/**
* Test to see if save_post is firing
*
* If it works, you should see an 'iso_save_post' entry in your wp_options table
*
*/
function iso_test_save_post() {
add_option( 'iso_save_post', 'is_saving!' );
@isotrope
isotrope / iso-tax-colour-picker.php
Created December 3, 2014 15:05
Add a colour picker to taxonomies
<?php
/**
* Colour meta box for taxonomies
*
* You know... for kids...
* ...and also for things like labels
*
*/
class Iso_Taxonomy_Colours {
@isotrope
isotrope / hanes_options.php
Last active August 29, 2015 14:11
One trick to keeping all your site's various re-used values in the same place.
<?php
/***
* _____ _ _ _ _ _
* / ____| | (_) | | | | (_)
* | | ___ _ __ ___ ___ | |_ __| | __ _| |_ _ _ __ __ _
* | | / _ \| '_ \/ __|/ _ \| | |/ _` |/ _` | __| | '_ \ / _` |
* | |___| (_) | | | \__ \ (_) | | | (_| | (_| | |_| | | | | (_| |
* \_____\___/|_| |_|___/\___/|_|_|\__,_|\__,_|\__|_|_| |_|\__, |
* / __ \ | | (_) __/ |
* | | | |_ __ | |_ _ ___ _ __ ___ |___/
@isotrope
isotrope / matthew-selectivatorizinate.php
Created January 5, 2015 16:30
For Matthew, a simple way to build options / dropdown menus
<?php
/**
*
* Easily handle a bunch of <option>s
*
*/
$my_options = array(
// name/label => value
@isotrope
isotrope / matt-excerpt.php
Created January 6, 2015 15:03
If first, skip next calls. If second, skip next call,...
<?php
$yoastdesc = get_post_meta( get_the_ID(), '_yoast_wpseo_metadesc', true );
$excerptlength = get_theme_mod( 'excerpt_length', 25 );
//$excerpt = get_the_excerpt(); //moved inside condition
//$content = get_the_content(); //moved inside condition
$screenreader = '<a href="' . get_permalink() . '"><span class="screen-reader-text">' . get_the_title() . '</span>Read More &hellip;</a>';
$echoed_excerpt = '';
if ( ! empty( $yoastdesc ) ) {
@isotrope
isotrope / plugin-template-theme-override.php
Last active August 29, 2015 14:13
If theme has view, use it. Else, use the one included with the plugin.
public function event_template_redirect() {
global $post, $wp;
$plugindir = dirname( __FILE__ );
$return_template = '';
if ( is_tax( 'iso_season' ) ) {
$templatefilename = 'archive-events.php';
if ( file_exists( TEMPLATEPATH . '/' . $templatefilename ) ) {
$return_template = TEMPLATEPATH . '/' . $templatefilename;
@isotrope
isotrope / iso-get-resized-attachment-src.php
Last active August 29, 2015 14:14 — forked from kovshenin/image-shortcode.php
Force resizes and caches images without needing to add_image_size() and bloat the /upoads/ dir
<?php
/**
* Force resizes and caches images without needing to add_image_size() and bloat the /upoads/ dir
*
* Most code is completely based on Konstantin Kovshenin's image-shortcode.php
* https://gist.github.com/kovshenin/1984363
*
* Expects the params similar to wp_get_attachment_image_src()
* http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src
*