Skip to content

Instantly share code, notes, and snippets.

View designbuildtest's full-sized avatar

designbuildtest

View GitHub Profile
@designbuildtest
designbuildtest / gist:d3b4723f6f98179e7018
Created February 17, 2015 03:17
Remove ATTRIBUTES and EXCERPT meta boxes when viewing the Homepage.
function myplugin_remove_homepage_metaboxes() {
if ( isset( $_GET['post'] ) ) {
$post_id = $_GET['post'];
} elseif ( isset( $_POST['post_ID'] ) ) {
$post_id = $_POST['post_ID'];
}
$front_page = get_option( 'page_on_front' );
if ( ! isset( $post_id ) ) {
@designbuildtest
designbuildtest / gist:591eb6e3d3cc3364fac7
Created February 17, 2015 03:38
Prevent Homepage from being deleted
function myplugin_remove_homepage_delete($allcaps, $cap, $args) {
if ( ! is_super_admin() ) {
if ( 'delete_post' == $args[0] ) {
if ( get_option( 'page_on_front' ) == $args[2] ) {
$allcaps[$cap[0]] = false;
}
}
return $allcaps;
}
@designbuildtest
designbuildtest / gist:cb48bf5b32d362baaf46
Created February 17, 2015 03:41
Exclude Homepage from main Admin query
function exclude_this_page( $query ) {
if( ! is_admin() )
return $query;
global $pagenow;
if( 'edit.php' == $pagenow && ( get_query_var( 'post_type' ) && 'page' == get_query_var( 'post_type' ) ) )
$query->set( 'post__not_in', array(2) ); // Change '2' to the ID of your Homepage
return $query;
}
@designbuildtest
designbuildtest / gist:391974a2caa82ff28f53
Created February 18, 2015 23:08
Manage Posts & Edit Post SCREEN customizations
// Remove default columns from manage view.
function myplugin_custom_manage_post_columns( $columns ) {
unset( $columns['cb'] );
unset( $columns['title'] );
unset( $columns['author'] );
unset( $columns['categories'] );
unset( $columns['tags'] );
unset( $columns['comments'] );
unset( $columns['date'] );
@designbuildtest
designbuildtest / gist:cab0678b67c4a6711f6e
Created February 20, 2015 22:53
Remove %20 from filenames
// http://webdevstudios.com/2015/02/19/10-things-i-learned-migrating-websites-to-wordpress/
// In your function where you save the original url, sanitize the filename before you store it
$cleaned_image_filename = santize_file_name( $image_filename );
update_post_meta( $post_id, ‘_orig_url’, $cleaned_image_filename );
// In the wds_redirect_old_traffic function update line 9
$request = santize_file_name( $wp->request );
// In the wds_get_post_id_from_external_url function update the following on line 35
@designbuildtest
designbuildtest / gist:486307a8526ef05bc5bf
Last active December 1, 2022 18:13
Gravity Forms capabilities
function myplugin_add_remove_theme_caps() {
$role = get_role( 'client' );
// This only works, because it accesses the class instance.
// Would allow the author to edit others' posts for current theme only
$role->remove_cap( 'gravityforms_export_entries' );
$role->add_cap( 'gravityforms_export_entries' );
gform_full_access
@designbuildtest
designbuildtest / gist:975db28eadabdf7c7065
Created February 25, 2015 03:45
Reset Post Data - partially effective
http://stackoverflow.com/questions/23593897/wordpress-global-post-changed-after-query
global $post;
$backup_post = $post;
...
$post = $backup_post;
@designbuildtest
designbuildtest / gist:af405bd787ffd1309c3b
Created March 5, 2015 08:58
Breadcrumbs - Modified/Big Brother theme
/**
* Breadcrumbs @ https://wpcom-themes.svn.automattic.com/big-brother/functions.php
*/
function myplugin_breadcrumbs() { ?>
<div class="breadcrumbs">
<?php
$sep = '<span class="breadcrumbs-seperator">' . __( '&raquo;' ) . '</span>';
$before = '<span class="breadcrumbs-current">' . $sep ;
$after = '</span>';
@designbuildtest
designbuildtest / gist:28ca93348d446104986f
Created March 5, 2015 09:14
Announcement Customizer & HTML
if ( current_theme_supports( 'announcement' ) ) {
function announcement_customizer( $wp_customize ) {
$wp_customize->add_section( 'announcement', array(
'title' => __( 'Announcement' ),
'description' => __( 'A summary of this page will appear in the header area of your website.' ),
'priority' => 64,
)
);
$wp_customize->add_setting( 'announcement_page', array(
@designbuildtest
designbuildtest / gist:63062ec6a7accb670337
Created August 7, 2015 02:31
WordPress Gallery settings filter
function dbt_gallery_defaults( $settings ) {
$settings['galleryDefaults']['size'] = 'thumbnail';
$settings['galleryDefaults']['link'] = 'file';
$settings['galleryDefaults']['columns'] = 2;
return $settings;
}
add_filter( 'media_view_settings', 'dbt_gallery_defaults');