Skip to content

Instantly share code, notes, and snippets.

Stephanie Leary sillybean

Block or report user

Report or block sillybean

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sillybean
sillybean / functions.php
Last active Oct 4, 2019
Specify meta boxes that should be hidden by default for new users.
View functions.php
<?php
add_filter( 'default_hidden_meta_boxes', 'custom_default_hidden_screen_options', 10, 2 );
function custom_default_hidden_screen_options( $hidden, $screen ) {
$hide_these = array(
'dashboard_primary',
'postcustom',
'trackbacksdiv',
@sillybean
sillybean / png_quality_filter.php
Last active Sep 13, 2019
Filter PNG image quality in WordPress
View png_quality_filter.php
<?php
// well-known filter to change JPG quality:
add_filter( 'jpeg_quality', function( $arg ){ return 100; } );
// lesser-known filter to change quality for any image type:
add_filter( 'wp_editor_set_quality', 'any_image_quality', 10, 2 );
add_filter( 'jpeg_quality', 'any_image_quality' );
function any_image_quality( $default_quality, $mime_type = NULL ) {
@sillybean
sillybean / print-acf-field-group.php
Created Jul 29, 2019
Print all ACF fields in a group with labels and values
View print-acf-field-group.php
<?php
$fields = array();
$field_group = get_page_by_title( 'GROUP TITLE HERE', OBJECT, 'acf-field-group' );
if ( is_object( $field_group ) ) {
$acf_fields = acf_get_fields_by_id( $field_group->ID );
$fields = wp_list_pluck( $acf_fields, 'label', 'name' );
}
foreach ( $fields as $field_name => $field_label ) {
@sillybean
sillybean / userstyles.css
Last active Jul 19, 2019
Hide new Twitter's right sidebar full of crap
View userstyles.css
.r-1ovo9ad div {
width: 0px !important;
}
.r-1ovo9ad div div.r-1oszu61 {
width: 360px !important;
}
.r-1ovo9ad form div {
width: inherit !important;
@sillybean
sillybean / blockquote-cite-tinymce.js
Created Oct 16, 2016
Blockquote + Cite TinyMCE button JS
View blockquote-cite-tinymce.js
(function() {
tinymce.PluginManager.add('blockquote_cite', function( editor, url ) {
editor.addButton( 'blockquote_cite', {
title: 'Blockquote & Cite',
icon: "icon dashicons-testimonial",
onclick: function() {
editor.windowManager.open( {
title: 'Insert Blockquote and Citation',
body: [
{
@sillybean
sillybean / functions.php
Last active Oct 8, 2018
Redirect private page 404 errors to the login screen with a message
View functions.php
<?php
add_action( 'wp', 'my_private_page_404' );
function my_private_page_404() {
$queried_object = get_queried_object();
if ( isset( $queried_object->post_status ) && 'private' == $queried_object->post_status && !is_user_logged_in() ) {
wp_safe_redirect( add_query_arg( 'private', '1', wp_login_url( $_SERVER['REQUEST_URI'] ) ) );
exit;
}
@sillybean
sillybean / tinymce-widget-styleselect.txt
Created Sep 5, 2017
Customizing TinyMCE's Formats (style_select) dropdown in rich text widgets in WordPress 4.8x
View tinymce-widget-styleselect.txt
<?php
// PHP goes in functions.php or similar
// Callback function to filter the MCE settings
function my_mce_style_options( $init_array ) {
// Define the style_formats array
$style_formats = my_mce_styleselect_options();
// Insert the array, JSON ENCODED, into 'style_formats'
$init_array['style_formats'] = json_encode( $style_formats );
@sillybean
sillybean / 404.php
Created May 18, 2012
Better 404 Error Page
View 404.php
<?php get_header(); ?>
<div id="content" class="section">
<h2>I'm sorry. I couldn't find the page you requested.</h2>
<p>You can try searching for it or looking for it in the <a href="/sitemap">site map</a>.</p>
<?php get_template_part( 'searchform' ); ?>
<?php
@sillybean
sillybean / functions.php
Last active Jun 5, 2018
Filter Genesis "no posts found" message
View functions.php
<?php
add_filter( 'genesis_noposts_text', 'my_custom_404_message', 10, 2 );
function my_custom_404_message( $text ) {
$queried_object = get_queried_object();
if ( isset( $queried_object->post_status ) && 'private' == $queried_object->post_status && !is_user_logged_in() )
$text = sprintf( __( 'This page is restricted. Please <a href="%s">log in or register</a>.' ), wp_login_url( $_SERVER['REQUEST_URI'] ) );
elseif ( is_search() )
@sillybean
sillybean / wp_private_page_filters.php
Last active Mar 7, 2018
Private page filters for WordPress. Related to ticket #8592.
View wp_private_page_filters.php
<?php
/*
Plugin Name: Unpublished Hierarchies
Description: A tiny plugin to allow draft, private, scheduled, and password-protected pages to be selected as parents.
Author: Stephanie Leary
Version: 1.0
Author URI: http://stephanieleary.com
License: GPL2
*/
You can’t perform that action at this time.