Skip to content

Instantly share code, notes, and snippets.

@brettshumaker
brettshumaker / attachment-modal.php
Created January 27, 2017 18:44
Altered file for svg-support/functions/attachment-modal.php Fatal Error
<?php
/**
* Display SVG in attachment modal
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
function bodhi_svgs_response_for_svg( $response, $attachment, $meta ) {
This file has been truncated, but you can view the full file.
;FLAVOR:RepRap
;TIME:4609
;Generated with Cura_SteamEngine 2.3.1
M190 S60
M104 S195
M109 S195
G21 ;metric values
G90 ;absolute positioning
M82 ;set extruder to absolute mode
M107 ;start with the fan off
@brettshumaker
brettshumaker / star-rating.js
Last active December 8, 2016 02:27
Generate Star Rating with Dashicons
/**
* See this on CodePen.io - http://codepen.io/brettshumaker/pen/NbzGjR
*/
jQuery(document).ready(function($) {
// Rating starts as a value out of 100 - 87/100
// You may need to adjust this depending on your data source
var myRating = 87;
// This is just generic code to place the rating HTML into a container
@brettshumaker
brettshumaker / edd-remote-license-check-variable-price-name.php
Created July 11, 2016 15:48
Filter to add variable price name to an EDD Software License remote license check
<?php
add_filter( 'edd_remote_license_check_response', 'bsgist_add_data_to_license_check', 10, 3 );
function bsgist_add_data_to_license_check( $json, $args, $license_id ) {
$price_id = get_post_meta( $license_id, '_edd_sl_download_price_id', true );
$download_id = edd_software_licensing()->get_download_id( $license_id );
$download_variable_prices = get_post_meta($download_id, 'edd_variable_prices', true);
$json['account_level'] = $download_variable_prices[$price_id]['name'];
@brettshumaker
brettshumaker / loop-rows-cols.php
Created April 22, 2016 13:35
This is some boilerplate code to take the content of a WP Query and split the posts into relatively evenly distributed rows and columns.
<?php
$args = array(
'post_type' => 'post',
'posts_per_page' => -1,
);
$posts_loop = new WP_Query( $args );
if ( $posts_loop->have_posts() ) :
// Initialize Output
$output = '';
@brettshumaker
brettshumaker / am_I_doing_it_wrong
Created June 11, 2014 13:46
WordPress - storing array of values in custom post type custom meta field
<?php
// This is essentially what I have adding the post meta field, not doing this from the edit post screen.
$name_meta['first-name'] = "Joe";
$name_meta['middle-name'] = "D.";
$name_meta['last-name'] = "Schmoe";
$name_meta['suffix'] = "Jr.";
update_post_meta($post->ID, '_staff_member_name', $name_meta);
// update_post_meta automatically serializes the array when adding it to the database
<?php
// Adds tiny MCE editor to excerpt
function tinymce_excerpt_js(){
$post_type= get_post_type();
if ($post_type != "shop_order") {?>
<script type="text/javascript">
jQuery(document).ready( tinymce_excerpt );
function tinymce_excerpt() {
jQuery("#excerpt").addClass("mceEditor");
tinyMCE.execCommand("mceAddControl", false, "excerpt");
@brettshumaker
brettshumaker / Plugin-dev-links
Last active December 21, 2015 20:28
Plugin Dev Links
@brettshumaker
brettshumaker / show-included-files-widget.php
Created May 12, 2013 13:41
Adds a Dashboard widget that displays all included theme files. Useful for tracking down bugs because you can see every file that's being loaded in the admin.
function add_show_inc_file_widget() {
wp_add_dashboard_widget('included-files', 'Show Included Theme Files', 'show_included_theme_files');
}
add_action('wp_dashboard_setup', 'add_show_inc_file_widget' );
function show_included_theme_files(){
$included_files = get_included_files();
foreach ($included_files as $filename) {
if (strpos($filename, "THEME-FOLDER-NAME")) echo $filename."<br />";
}
@brettshumaker
brettshumaker / vimeo.php
Created January 23, 2013 15:15
Uses the Vimeo Simple API to download all videos from a Vimeo channel and outputs them in 'pages.'
<?php
/**
* Gets and displays paginated Vimeo videos from a Vimeo channel.
* Replace 'YOUR_CHANNEL_NAME' with the channel you want to pull from.
*
* Accepts 4 Values and Returns 1
*
* @param string $channel_name Name of the Vimeo channel
* @param array $excluded_videos Array of video ID's to exclude from the output