Skip to content

Instantly share code, notes, and snippets.

Dewey Bushaw styledev

Block or report user

Report or block styledev

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
@styledev
styledev / .tm_properties
Created Nov 21, 2018
Textmate Properties
View .tm_properties
# Basic Settings
#
fontName = "Monaco"
fontSize = 16
# Extra files to include
#
myExtraIncludes = ".tm_properties,.htaccess,.gitignore"
fileBrowserGlob = "{*,$myExtraIncludes}"
include = "{$include,$myExtraIncludes}"
@styledev
styledev / WP All Import - pmxi_saved_post
Created Oct 10, 2018
A WordPress Action to sideload images into your site from the imported post content.
View WP All Import - pmxi_saved_post
function action_pmxi_saved_post( $id ) {
$dir = wp_upload_dir();
$img_array = [];
$media = get_attached_media('image', $id);
$thepost = get_post($id);
foreach($media as $media_id => $item) {
$metadata = wp_get_attachment_metadata($item->ID, true);
$directory = explode('/', $metadata['file']);
@styledev
styledev / .htaccess
Created Jun 21, 2018
Apache mod_rewrite.c code for WordPress to load images from a production server if not found locally. Replace https://www.example.com with your production URL.
View .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f [NC]
RewriteRule ^(.*\.(js|css|png|jpe?g|gif|ico)) https://www.example.com/$1 [QSA,L,C]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
@styledev
styledev / Apache2 User Conf
Last active Jan 4, 2019
A OS X Apache2 User Conf file to use with Dnsmasq
View Apache2 User Conf
<VirtualHost *:80>
VirtualDocumentRoot /Users/<username>/Sites/%1
ServerName test
ServerAlias *.test
UseCanonicalName off
SetEnv HOME /Users/<username>
</VirtualHost>
# <VirtualHost *:443>
# VirtualDocumentRoot /Users/<username>/Sites/%1
@styledev
styledev / number.php
Created Jun 18, 2013
Updated create_field to set step to "any" if option is not specified.
View number.php
function create_field( $field )
{
$o = array( 'id', 'class', 'min', 'max', 'step', 'name', 'value' );
$e = '<input type="number"';
foreach( $o as $k )
{
$val = $field[ $k ];
if ( $k == 'step' && empty($val) ) $val = 'any';
$e .= ' ' . $k . '="' . esc_attr( $val ) . '"';
@styledev
styledev / acf-location-field-acf_form.php
Created Jun 13, 2013
How to get the ACF Location Field to show the map when using acf_form().
View acf-location-field-acf_form.php
add_action('wp_head', 'form_acf', 10 );
public function form_acf() {
if ( is_page('Add an Opportunity') ) {
echo '<script src="https://maps.googleapis.com/maps/api/js?sensor=false" type="text/javascript"></script>';
acf_form_head();
}
}
@styledev
styledev / Wordpress-Bug-Fix.php
Last active Dec 15, 2015
This function is a temporary fix for this wp-core bug: http://core.trac.wordpress.org/ticket/18614
View Wordpress-Bug-Fix.php
function wordpress_fix_bug( $wp_query ) {
// The function below is a temporary fix for this bug: http://core.trac.wordpress.org/ticket/18614
if ( $wp_query->is_post_type_archive && $wp_query->is_tax ) {
global $post_type_obj;
$wp_query->is_tax = false;
$post_type_obj = get_queried_object();
if (empty($post_type_obj->labels)) {
$post_type_obj->labels = new stdClass();
$post_type_obj->labels->name = 'dev/hack to fix WordPress Bug';
}
@styledev
styledev / Positional Cropping
Created Feb 26, 2013
Positional Cropping for Wordpress Timthumb Alternative
View Positional Cropping
if ( $crop ) {
$cmp_x = $orig_width / $dest_width;
$cmp_y = $orig_height / $dest_height;
// Calculate x or y coordinate, and width or height of source
if ( $cmp_x > $cmp_y ) {
$src_w = round( $orig_width / $cmp_x * $cmp_y );
$src_x = round( ( $orig_width - ( $orig_width / $cmp_x * $cmp_y ) ) / 2 );
}
else if ( $cmp_y > $cmp_x ) {
$src_h = round( $orig_height / $cmp_y * $cmp_x );
View WP User Register - Custom Field
function function_name($user_id) {
if( isset($_POST['company_name']) ) update_user_meta( $user_id, 'company_name', $_POST['company_name'] );
}
add_action( 'user_register', 'function_name');
View WP Profile Save
public function profile_save( $user_id ) {
$fields = self::$setup['theme']['profile']['fields'];
if ( !current_user_can( 'edit_user', $user_id ) ) return false;
foreach ($fields as $field => $attr) {
if ( isset($_POST[$field]) || isset($_FILES[$field]) ) {
$value = $_POST[$field];
if ( $value ) update_user_meta( $user_id, $field, $value );
}
}
}
You can’t perform that action at this time.