Skip to content

Instantly share code, notes, and snippets.

@purcebr
purcebr / mime_by_role.php
Last active July 22, 2016 14:32
Allow Media MIME Type Uploads based on user role
add_filter('upload_mimes', 'admin_upload_svg');
function admin_upload_svg ( $existing_mimes=array() ) {
$user = wp_get_current_user();
// If the user is an admin, add the svg mimetype to the list.
if(in_array( 'administrator', (array) $user->roles )) {
@purcebr
purcebr / gist:f6f260aeddf0894fd1e5
Last active September 3, 2015 20:32
Add custom item to the end of a menu
function add_member_link_item_to_menu( $items, $args ){
//change theme location with your them location name
if( is_admin() || $args->theme_location != 'primary-right-menu' )
return $items;
$link = '<a href="#">Member Area</a>';
return $items .= '<li id="members-only-link" class="menu-item menu-type-link">'. $link . '</li>';
}
/**
* A Little Helper for getting specific image sizes from image custom fields.
*/
function get_image_field($field, $size = 'thumbnail')
{
return acf_get_image_thumnails($field, $size, 'field');
}
function get_image_sub_field($field, $size = 'thumbnail')
/* Print Styles for wp_help */
@media print {
/* WP Admin Elements */
#adminmenuwrap {
display:none;
}