Skip to content

Instantly share code, notes, and snippets.

View ControlledChaos's full-sized avatar

Controlled Chaos Design ControlledChaos

View GitHub Profile
@ControlledChaos
ControlledChaos / font-stacks.css
Created October 10, 2019 05:23 — forked from don1138/font-stacks.css
CSS Modern Font Stacks
/* Modern Font Stacks */
/* System */
font-family: system, -apple-system, ".SFNSText-Regular", "San Francisco", "Roboto", "Segoe UI", "Helvetica Neue", "Lucida Grande", sans-serif;
/* Times New Roman-based serif */
font-family: Cambria, "Hoefler Text", Utopia, "Liberation Serif", "Nimbus Roman No9 L Regular", Times, "Times New Roman", serif;
/* A modern Georgia-based serif */
font-family: Constantia, "Lucida Bright", Lucidabright, "Lucida Serif", Lucida, "DejaVu Serif", "Bitstream Vera Serif", "Liberation Serif", Georgia, serif;
@ControlledChaos
ControlledChaos / wp-get-image-sizes.php
Created September 7, 2019 18:40 — forked from eduardozulian/wp-get-image-sizes.php
Get all the registered image sizes along with their dimensions
<?php
/**
* Get all the registered image sizes along with their dimensions
*
* @global array $_wp_additional_image_sizes
*
* @link http://core.trac.wordpress.org/ticket/18947 Reference ticket
* @return array $image_sizes The image sizes
*/
function _get_all_image_sizes() {
@ControlledChaos
ControlledChaos / README.md
Created September 4, 2019 22:15 — forked from chrisvanpatten/README.md
WordPress Admin Tabs

Huh?

Believe it or not, WordPress doesn't have a fully-fleshed out common tab style for plugins or theme authors to use in metaboxes.

The style exists for categories, but it hasn't been fully adapted for the half-complete wp-tab setup. Trac ticket #17959 has a solution that not only fleshes the style but it also adds a global JavaScript file to give the wp-tab HTML some action. Until that ticket is accepted into core, this Gist adapts that code so it's available to use independently in your theme or plugin.

How?

Just enqueue the CSS and JavaScript in the admin_enqueue_scripts script hook and drop the tab HTML in a metabox. It will automatically adapt to the normal and side column widths, much like category tabs.

@ControlledChaos
ControlledChaos / README.md
Last active August 25, 2019 23:59
Display a random logo image from an ACF gallery field.

Random ACF Logo w/ Customizer Fallback

Displays a random logo image from a gallery field. Falls back first to the logo in the Customizer, then to a theme default file.

Requirements

  • Requires Advanced Custom Fields Pro to be active to display a random inage.
  • Set the ACF gallery to return the URL of images.
  • Use in a template as <?php ccd_random_logo(); ?>
@ControlledChaos
ControlledChaos / honeypot-example.php
Last active August 15, 2019 00:58 — forked from andrewlimaza/honeypot-example.php
Simple honeypot for an HTML form using PHP
<?php
//check if form was sent
if($_POST){
$to = 'some@email.com';
$subject = 'Testing HoneyPot';
$header = "From: $name <$name>";
$name = $_POST['name'];
$email = $_POST['email'];
@ControlledChaos
ControlledChaos / gist:8d5488678a30831730b1b1922bcb59bb
Created June 5, 2019 18:20 — forked from pragmatic-web/gist:1885364
WordPress function to add the TinyMCE WYSIWYG editor to any custom field of type 'Textarea'
// important: note the priority of 99, the js needs to be placed after tinymce loads
// important: note that this assumes you're using http://wordpress.org/extend/plugins/verve-meta-boxes/
// to create the textarea - otherwise change your selector
function admin_add_wysiwyg_custom_field_textarea()
{ ?>
<script type="text/javascript">/* <![CDATA[ */
jQuery(function($){
var i=1;
$('.verve_meta_box_content textarea').each(function(e)
@ControlledChaos
ControlledChaos / array-insert-after.php
Created June 4, 2019 22:59 — forked from wpscholar/array-insert-after.php
Insert a value or key/value pair after a specific key in an array. If key doesn't exist, value is appended to the end of the array.
<?php
/**
* Insert a value or key/value pair after a specific key in an array. If key doesn't exist, value is appended
* to the end of the array.
*
* @param array $array
* @param string $key
* @param array $new
*
@ControlledChaos
ControlledChaos / README.md
Last active June 1, 2019 15:46
Show reusable blocks in the admin menu.

Show Reusable Blocks in the Admin Menu

WordPress Snippet

@ControlledChaos
ControlledChaos / paste-as-plain-text.php
Created May 23, 2019 18:27 — forked from tillkruss/paste-as-plain-text.php
Force the WordPress editor to always paste as plain text.
<?php
// always paste as plain text
foreach ( array( 'tiny_mce_before_init', 'teeny_mce_before_init') as $filter ) {
add_filter( $filter, function( $mceInit ) {
$mceInit[ 'paste_text_sticky' ] = true;
$mceInit[ 'paste_text_sticky_default' ] = true;
return $mceInit;
});
}
@ControlledChaos
ControlledChaos / full-width-dashboard-widget.php
Created May 10, 2019 13:58 — forked from renventura/full-width-dashboard-widget.php
Add a full-width dashboard widget in WordPress
<?php // Mind this opening PHP tag
/**
* Adds hidden content to admin_footer, then shows with jQuery, and inserts after welcome panel
*
* @author Ren Ventura <EngageWP.com>
* @see http://www.engagewp.com/how-to-create-full-width-dashboard-widget-wordpress
*/
add_action( 'admin_footer', 'rv_custom_dashboard_widget' );
function rv_custom_dashboard_widget() {