Skip to content

Instantly share code, notes, and snippets.

@emzo
emzo / disable-plugins.php
Created October 4, 2011 20:11 — forked from markjaquith/disable-plugins-when-doing-local-dev.php
Disables specified WordPress plugins
<?php
/*
Plugin Name: Disable Plugins
Description: Disables plugins that you specify depending on the value of the WP_LOCAL_DEV constant
Version: 0.2
License: GPL version 2 or any later version
Author: Mark Jaquith
Author URI: http://coveredwebservices.com/
*/
@emzo
emzo / dates-meta.php
Created October 25, 2011 15:54
WPAlchemy: Modify cloned item of repeating field group
<a style="float:right; margin:0 10px;" href="#" class="dodelete-dates button">Remove All Dates</a>
<p>Add dates on which this course will run.</p>
<?php while($mb->have_fields_and_multi('dates')): ?>
<?php $mb->the_group_open(); ?>
<?php $mb->the_field('date'); ?>
<p><input type="text" name="<?php $mb->the_name(); ?>" value="<?php $mb->the_value(); ?>" class="datepicker" />
<a href="#" class="dodelete button">Remove Date</a></p>
@emzo
emzo / less_preprocessor.php
Created February 27, 2012 15:54
A LESS preprocessor for Wordless
<?php
require_once "wordless_preprocessor.php";
/**
* Compile LESS files using the `lessc` executable.
*
* LessPreprocessor relies on some preferences to work:
* - css.lessc_path (defaults to "/usr/bin/lessc"): the path to the lessc executable
* - css.output_style (defaults to "compressed"): the output style used to render css files
@emzo
emzo / gist:3052518
Created July 5, 2012 09:17
WP Protect user account from deletion
add_action( 'delete_user', 'dont_delete_user' );
function dont_delete_user( $id ) {
$dont_delete_ids = array( 1, 2, 3, 4 ); // protected user IDs
if ( in_array( $id, $dont_delete_ids ) )
wp_die( 'You cannot delete this user account.' );
}
@emzo
emzo / _sizes.scss
Created November 29, 2012 14:20
Generate human friendly proportional size classes
// Based on the code in Griddle by @necolas
// http://necolas.github.com/griddle/
// =============================================================================
// Helper Functions
// =============================================================================
// Find the greatest common factor of two integers
@function gcf($a, $b) {
@if $b == 0 {
@emzo
emzo / soliloquy-slug.php
Created February 4, 2013 19:31
Add slider slug name to css attributes of soliloquy container div
<?php
// Add slug in CSS class of all sliders
add_filter( 'tgmsp_slider_classes', 'clinicoftcm_slider_classes', 10, 2 );
function clinicoftcm_slider_classes( $classes, $id ) {
$slider = get_post( $id, ARRAY_A );
if( $slider['post_name'] )
$classes[] = 'soliloquy-' . $slider['post_name'];
return $classes;
}
@emzo
emzo / wp_link_query_term_linking.php
Created June 14, 2016 21:57
Allow linking to taxonomy terms as well as posts when performing internal linking
@emzo
emzo / wp_mail_smtp_custom_options.php
Created June 14, 2016 21:59
Alow SSL conections to sites with self-signed or problematic certificates
<?php
add_filter('wp_mail_smtp_custom_options', function( $phpmailer ) {
$phpmailer->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
<?php
function darpar_body_class( $classes ) {
if ( is_singular() && has_post_thumbnail() ) {
array_push( $classes, 'has-thumbnail' );
}
if ( is_product_category() && get_woocommerce_term_meta( get_queried_object_id(), 'thumbnail_id', true ) ) {
array_push( $classes, 'emyr' );
};
<?php
add_action( 'phpmailer_init', function( $phpmailer ) {
$phpmailer->addCustomHeader("X-Mailgun-Drop-Message: yes");
});