Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View Pross's full-sized avatar
💬

Simon Prosser Pross

💬
View GitHub Profile
function high_priority_style() {
printf( "<link rel='stylesheet' id='important-css' href='%s' type='text/css' media='all' />\n", get_stylesheet_directory_uri() . '/wp-pohja-codekit/codekit.css' );
}
add_action('wp_head', 'high_priority_style', 8);
<?php
/*
* NOTE: 2 varibales passed here...
*/
add_filter( 'pl-area-inner-classes', 'my_classes_filter', 10, 2 );
/*
* Filter function now needs 2 variables
* 1st is the actual value being filtered
* 2nd is the section meta data in the form of an array.
<?php // only add this if there isnt one already, its only here to make highlighting work
add_filter( 'pless_vars', 'make_cdn_vars' );
function make_cdn_vars( $vars ) {
$vars['plSectionsRoot'] = str_replace( 'www', 'cdn', $vars['plSectionsRoot'] );
$vars['plRoot'] = str_replace( 'www', 'cdn', $vars['plRoot'] );
$vars['plCrossRoot'] = str_replace( 'www', 'cdn', $vars['plCrossRoot'] );
return $vars;
}
@Pross
Pross / functions.php
Created June 19, 2014 15:45
nav_logo filter
<?php
// we are going to filter navbar_logo section option on the fly..
add_filter( 'pl_opt-navbar_logo', 'change_logo_on_lang' );
function change_logo_on_lang( $val ) { // $val is the value of the setting.
// use some polylang data to get current language
global $curlang;
$curlang = $this->curlang->slug;
// asumming the slug is nl or en
@Pross
Pross / functions.php
Created June 19, 2014 15:54
Add a class to passworded post
<?php
add_filter( 'body_class', 'add_password_class' );
function password_class( $classes ) {
if( post_password_required() ) {
$classes[] = 'password-required';
}
return $classes;
}
<?php
add_filter( 'the_excerpt', 'maybe_get_the_content' );
function maybe_get_the_content( $content ) {
global $wp_query;
if( $wp_query->is_home )
return get_the_content();
else
return $content;
}
#!/bin/bash
echo "" > spam.txt
for url in $(wp site list --field=url)
do
for id in $(wp --url=$url post list --field=ID)
do
printf ":"
content=$(wp --url=$url post get $id --field=content)
if [[ $content =~ .*viagra.* ]]
@Pross
Pross / some.html
Created July 21, 2014 23:40
Disable animation on mobiles.
<script>
jQuery( document ).ready(function() {
var width = jQuery(window).width()
if( width < 480 )
jQuery('div').removeClass('pl-animation')
});
</script>
<script>
jQuery( document ).ready(function() {
jQuery('.ibox-link a').html( 'Mer <i class="icon icon-angle-right"></i>' )
})
</script>
<?php
add_action( 'after_setup_theme', 'my_add_filter' );
function my_add_filter() {
add_filter( 'pless_vars', 'my_pless_vars' );
}
function my_pless_vars( $vars ){
$vars['plBaseFont'] = '"ff-tisa-web-pro",georgia,serif;';
return $vars;