Skip to content

Instantly share code, notes, and snippets.

<?
/////////////////////
// slack2html
// by @levelsio
/////////////////////
//
/////////////////////
// WHAT DOES THIS DO?
/////////////////////
//
@hereswhatidid
hereswhatidid / custom-acf-wysiwyg-css.php
Last active September 27, 2022 15:27
Applies defined CSS classes to the ACF WYSIWYG editor so that you can individually style them.
<?php
function hwid_acf_admin_footer() {
?>
<script>
( function( $) {
acf.add_filter( 'wysiwyg_tinymce_settings', function( mceInit, id ) {
// grab the classes defined within the field admin and put them in an array
var classes = $( '#' + id ).closest( '.acf-field-wysiwyg' ).attr( 'class' );
@theeventscalendar
theeventscalendar / functions.php
Last active May 17, 2016 03:18 — forked from ckpicker/gist:ba9b617afdbdb3867159
Change the word Event/Events globally on your calendar. This example uses Meeting/Meetings instead. Change the single and plural options below to whatever word you'd like to use.
<?php
// Singular
add_filter( 'tribe_event_label_singular', 'event_display_name' );
function event_display_name() {
return 'Meeting';
}
add_filter( 'tribe_event_label_singular_lowercase', 'event_display_name_lowercase' );
function event_display_name_lowercase() {
return 'meeting';
@chinchang
chinchang / xmlToJson.js
Last active September 7, 2023 02:39
Function to convert XML to JSON
/**
* Changes XML to JSON
* Modified version from here: http://davidwalsh.name/convert-xml-json
* @param {string} xml XML DOM tree
*/
function xmlToJson(xml) {
// Create the return object
var obj = {};
if (xml.nodeType == 1) {
add_filter( 'preprocess_comment', 'nyt_preprocess_comment' );
function nyt_preprocess_comment($comment) {
if ( strlen( $comment['comment_content'] ) > 5000 ) {
wp_die('Comment is too long.');
}
return $comment;
}
@cgrymala
cgrymala / no-subscriber-admin.php
Created February 12, 2015 20:28
Keep Subscribers Out of the WP Admin Area
<?php
add_action( 'admin_init', 'hide_backend_from_user' );
/**
* Hide the backend from specific user levels
* @uses VFH_User_Controls::$options['login_redirect_to'] to determine where the user should be redirected
* @uses VFH_User_Controls::$user_levels to see if the user needs to be redirected
*/
function hide_backend_from_user( $level='edit_posts' ) {
/**
* Attempt not to short-circuit AJAX requests
@nickcernis
nickcernis / functions.php
Last active January 24, 2016 21:23
Fix for the wpMandrill WordPress plugin for blogs that send both plain text and HTML email
<?php
// Add to functions.php and leave the “Content” box unticked in Settings > Mandrill
// Be sure to omit the opening <?php tag when copying this code
// Add paragraph breaks to plain text notifications sent by Mandrill
add_filter('mandrill_payload', 'wpmandrill_auto_add_breaks');
function wpmandrill_auto_add_breaks($message) {
$html = $message['html'];
@benhuson
benhuson / cust-vimeo-oembed
Last active April 18, 2020 23:30
Customise WordPress Vimeo oEmbed
<?php
/**
* Customise WordPress Vimeo oEmbed
* https://developer.vimeo.com/apis/oembed
*/
function my_oembed_fetch_url( $provider, $url, $args ) {
if ( strpos( $provider, 'vimeo.com' ) !== false) {
@adamsilverstein
adamsilverstein / expanded_alowed_tags
Last active April 3, 2024 18:15
WordPress expanded allowed tags for wp_kses with iframe, forms, etc.
function expanded_alowed_tags() {
$my_allowed = wp_kses_allowed_html( 'post' );
// iframe
$my_allowed['iframe'] = array(
'src' => array(),
'height' => array(),
'width' => array(),
'frameborder' => array(),
'allowfullscreen' => array(),
);
@magnificode
magnificode / _part-tabs.scss
Last active January 23, 2017 19:49
Dynamic tabs that switch to an accordion on mobile.
.tabs{
margin: {top:40px;}
&:last-child{
margin: {bottom:80px;}
}
h2{
color: $color-1;
font: {
size: emCalc(36px);
}