Skip to content

Instantly share code, notes, and snippets.

View designbuildtest's full-sized avatar

designbuildtest

View GitHub Profile
@designbuildtest
designbuildtest / gist:8d77c02c54b1ebf2b2cb
Created December 22, 2014 05:16
Modular Custom CSS reloaded
/**
* Enable Administrators to add a Custom CSS Control to the Customiser.
*/
function onehundred_enable_custom_css() {
if ( current_user_can('create_users') ) {
function onehundred_enable_custom_css_option() {
register_setting('general', 'onehundred_enable_custom_css', 'wp_filter_nohtml_kses');
add_settings_field('onehundred_enable_custom_css', __('Enable Custom CSS?', 'onehundred') , 'onehundred_enable_custom_css_form', 'general');
function onehundred_testimonials_register_post_type() {
$args = array(
'labels' => array(
'name' => _x( 'Testimonials', 'post type general name', 'onehundred' ),
'singular_name' => _x( 'Testimonial', 'post type singular name', 'onehundred' ),
'add_new' => _x( 'Add New', 'location', 'onehundred' ),
'add_new_item' => __( 'Add Testimonial', 'onehundred' ),
'edit_item' => __( 'Edit Testimonial', 'onehundred' ),
'new_item' => __( 'New Testimonial', 'onehundred' ),
'all_items' => __( 'All Testimonials', 'onehundred' ),
@designbuildtest
designbuildtest / gist:54145bd7b03b3273a6cb
Created January 7, 2015 05:21
Customizer Upload Image / Use as Custom Header
$wp_customize->add_section( 'header_background', array(
'title' => __( 'Custom Header Image', 'onehundred' ),
'priority' => 40,
) );
$wp_customize->add_setting( 'header_background', array(
'sanitize_callback' => 'construction_sanitize_file_url',
) );
$wp_customize->add_control( new WP_Customize_Image_Control( $wp_customize, 'header_background', array(
$button_slug = 'fetch';
$js_button_data = array(
'qt_button_text' => __( 'iframe' ),
'button_tooltip' => __( 'iframe' ),
'icon' => 'dashicons-admin-appearance',
'l10ncancel' => __( 'Cancel' ),
'l10ninsert' => __( 'Insert' ),
'modalHeight' => '400',
//'width' => 500,
@designbuildtest
designbuildtest / gist:dbf518509744e9565d44
Last active August 29, 2015 14:14
Creating a dynamically named / namespaced function
function mytheme_get_color_schemes() {
$industry = get_option( 'mytheme_industry', 'construction' );
$function_name = 'mytheme_' . $industry . '_get_color_schemes';
return $function_name();
}
@designbuildtest
designbuildtest / gist:e87304341dca223a6dfd
Created February 10, 2015 00:49
De-register widgets
function mytheme_remove_default_widgets() {
$widgets = array(
'WP_Nav_Menu_Widget',
'WP_Widget_Archives',
'WP_Widget_Calendar',
'WP_Widget_Categories',
'WP_Widget_Meta',
'WP_Widget_Pages',
'WP_Widget_Recent_Comments',
'WP_Widget_Recent_Posts',
@designbuildtest
designbuildtest / gist:584efcc0405c5ef4d37a
Created February 10, 2015 04:44
Disable Google Open Sans font in the Admin area
/**
* Disable Google Open Sans font in the Admin area . Implementation idea from ... https://wordpress.org/plugins/disable-google-fonts/
*/
function myplugin_admin_area_minus_open_sans_style() {
// Remove Open Sans. Doesn't work :-(
// See 'Disable_Google_Fonts' class below as an alternative.
wp_dequeue_style('open-sans-css');
// Add custom style definitions to compensate for the removal of Open Sans
wp_enqueue_style('myplugin-admin-minus-open-sans', plugins_url( 'css/admin-minus-open-sans.css', __FILE__ ), false, '1.0.0', 'all');
@designbuildtest
designbuildtest / gist:504cf2dac7b7dbe88809
Created February 10, 2015 04:52
Remove all Dashboard Widgets and make Dashboard a single colum display.
function myplugin_admin_custom_ui() {
if ( is_admin() ) {
// Remove All Dashboard Widgets.
remove_meta_box( 'dashboard_activity', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_right_now', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_recent_comments', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_plugins', 'dashboard', 'normal' );
remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' );
@designbuildtest
designbuildtest / gist:cb54d8e3f793bc28bfdf
Last active August 29, 2015 14:15
jpeg_quality filter
/** Resulting image is actually really big :-( */
function smashing_jpeg_quality() {
return 100;
}
add_filter( 'jpeg_quality', 'smashing_jpeg_quality' );
@designbuildtest
designbuildtest / gist:45b9aca250ad2d2ef7de
Created February 15, 2015 06:16
Header Image using WP_Customize_Image_Control
<?php
if ( current_theme_supports( 'onehundred-header-image' ) ) {
function myplugin_header_image_customize_register( $wp_customize ) {
// Pre-selected header images.
$wp_customize->add_setting( 'header_image_selection', array(
'default' => 'default',
'sanitize_callback' => 'myplugin_sanitize_header_image_select_choice',
'transport' => 'postMessage',