This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Mind you, this does not make SVG files safe. This script is meant for sites where only trusted people can upload. | |
add_action("init", function() { | |
// First line of defence defused | |
add_filter('upload_mimes', function ($mimes) { | |
$mimes['svg'] = 'image/svg+xml'; | |
return $mimes; | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Do NOT include the opening php tag | |
add_filter( 'gform_field_choice_markup_pre_render', function ( $choice_markup, $choice, $field ) { | |
if ( $field->get_input_type() == 'select' ) { | |
$choice_value = rgar( $choice, 'value' ); | |
if ( $choice_value === 'optgroup-start' ) { | |
return sprintf( '<optgroup label="%s">', esc_html( $choice['text'] ) ); | |
} elseif ( $choice_value === 'optgroup-end' ) { | |
return '</optgroup>'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add height field to ACF WYSIWYG | |
*/ | |
function wysiwyg_render_field_settings( $field ) { | |
acf_render_field_setting( $field, array( | |
'label' => __('Height of Editor'), | |
'instructions' => __('Height of Editor after Init'), | |
'name' => 'wysiwyg_height', | |
'type' => 'number', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Advanced Custom Fields: Nowhere location rules | |
Description: Adds a "Nowhere" location rule in ACF | |
*/ | |
add_filter('acf/location/rule_types', function($rules) { | |
$rules['Extra']['nowhere'] = 'Nowhere'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Disable REST API | |
* Version: 0 | |
*/ | |
// completely disable wp-json access | |
add_filter( 'rest_authentication_errors', function( $access ){ | |
return new WP_Error( 'rest_cannot_access', 'Bye', array( 'status' => 403 ) ); | |
} ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// ACF upload prefilter | |
function gist_acf_upload_dir_prefilter($errors, $file, $field) { | |
// Only allow editors and admins, change capability as you see fit | |
if( !current_user_can('edit_pages') ) { | |
$errors[] = 'Only Editors and Administrators may upload attachments'; | |
} | |
// This filter changes directory just for item being uploaded |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Remove Rev Slider Metabox | |
*/ | |
if ( is_admin() ) { | |
function remove_revolution_slider_meta_boxes() { | |
remove_meta_box( 'mymetabox_revslider_0', 'page', 'normal' ); | |
remove_meta_box( 'mymetabox_revslider_0', 'post', 'normal' ); | |
remove_meta_box( 'mymetabox_revslider_0', 'YOUR_CUSTOM_POST_TYPE', 'normal' ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# Basic Usage: | |
# Applies default markup to all forms | |
gw_multi_file_merge_tag()->register_settings(); | |
# Exclude Form(s): | |
# Applies default markup to all forms excluding the specified forms | |
gw_multi_file_merge_tag()->register_settings( array( | |
'exclude_forms' => 2 // multiple forms: array( 2, 4 ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Change text strings | |
* | |
* @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext | |
*/ | |
function my_text_strings( $translated_text, $text, $domain ) { | |
switch ( $translated_text ) { | |
case 'Sale!' : | |
$translated_text = __( 'Clearance!', 'woocommerce' ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$args = array( | |
// Normal query goes here // | |
'no_found_rows' => true, // counts posts, remove if pagination required | |
'update_post_term_cache' => false, // grabs terms, remove if terms required (category, tag...) | |
'update_post_meta_cache' => false, // grabs post meta, remove if post meta required | |
); |
NewerOlder