Skip to content

Instantly share code, notes, and snippets.

@ideag
ideag / limit_blogname.php
Last active October 8, 2015 07:27
A short function to limit WordPress blog title to 40 symbols.
<?php
add_filter( 'pre_update_option_blogname', 'arunas_limit_blogname', 10, 2 );
function arunas_limit_blogname( $value, $old_value ) {
// check for length (pr do any other kind of validation)
if ( 40 < strlen($value) ) {
// throw error via Settings API
add_settings_error(
'blogname', // option name
'blogname', // error id
__( 'Blog title is too long', 'plugin-slug' ),
@ellenmva
ellenmva / sb-dynamic-image.php
Last active August 29, 2015 14:17
Filter for elSue Single Bits for DMS that takes image from Dynamic Featured Image plugin and replaces as background for Single Bits container when Featured Image option is selected.
<?php
add_filter('elsue_bits_img_id' , 'sb_dynamic_image');
function sb_dynamic_image($thumb_id) {
global $post;
if( class_exists('Dynamic_Featured_Image') ) {
global $dynamic_featured_image;
// Get all dynmaic images
$featured_images = $dynamic_featured_image->get_featured_images( $post->ID );
<?php
/*
Seperate Woocommerce reviews from comments and make a reviews moderation panel.
*/
class PL_Woo_Review_Mods {
function __construct() {
add_action( 'current_screen', array( $this, 'check_current_page' ), 10, 2 );
add_action( 'admin_menu', array( $this, 'add_product_reviews' ) );
}
function check_current_page( $screen ) {
@Pross
Pross / functions.php
Created July 30, 2014 19:42
Add ACF support for DMS2
<?php
add_filter('acf/location/rule_types', 'acf_location_rules_types');
function acf_location_rules_types( $choices ) {
$choices['Page']['pagelinespage'] = 'Pagelines Page';
return $choices;
}
// Find pages
add_filter('acf/location/rule_values/pagelinespage', 'acf_location_rules_values_pagelinespage');
@mathetos
mathetos / gist:6c4d3dc77ee3591e0a74
Created July 22, 2014 04:45
Admin Enqueue Iris.js
<?php
function load_mc_iris() {
if (wp_script_is( 'iris', 'enqueued' )) {
return; // if it's already enqueued, don't enqueue it again.
} else { // since it's NOT enqueued, let's enqueue it
wp_enqueue_script(
'iris', //iris.js handle
admin_url( 'js/iris.min.js' ), //path to wordpress iris file
<?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
// filter the Gravity Forms button type
add_filter("gform_submit_button_1", "form_submit_button", 10, 2);
function form_submit_button($button, $form){
return "<button class='button' id='gform_submit_button_{$form["id"]}'><span><i class='fa fa-share fa-2x'></i> Send </span></button>";
}
//Change hook of gform_submit_button_X to the form that you are using
//Change <span><i class='fa fa-share fa-2x'></i> Send </span> to Font awesome and text of your choice
@cliffordp
cliffordp / dms-makestuffinsidefullwidth.less
Created April 24, 2014 18:43
Change content-width sections inside a DMS Canvas Area to full-width -- http://www.pagelinestheme.com/make-content-width-section-full-width/
// from http://www.pagelinestheme.com/make-content-width-section-full-width/
// overriding dms/dms/less/pl-structure.less
body.display-boxed #site .boxed-wrap .pl-area.makestuffinsidefullwidth .pl-area-wrap > .pl-content {
padding-left: 0px;
padding-right: 0px;
}
body.display-full #site .pl-area.makestuffinsidefullwidth .pl-content {
max-width: none;
}
@Pross
Pross / functions.php
Created April 4, 2014 22:46
Remove thumbnail from single posts
<?php
function remove_post_thumbnail($metadata, $object_id, $meta_key, $single){
if( isset($meta_key) && '_thumbnail_id' === $meta_key && is_single() )
return false;
else
return $metadata;
}
add_filter('get_post_metadata', 'remove_post_thumbnail', true, 4);
<?php
class Section_Overide {
function __construct() {
add_filter( 'pagelines_render_section', array( $this, 'section_overide' ), 10, 2 );
}
function section_overide( $s, $class ) {