Skip to content

Instantly share code, notes, and snippets.

@esedic
Last active September 13, 2019 19:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esedic/8aac2c8aac5b691127b1ad24d0750042 to your computer and use it in GitHub Desktop.
Save esedic/8aac2c8aac5b691127b1ad24d0750042 to your computer and use it in GitHub Desktop.
Wordpress snippets
<?php
// hide admin bar
show_admin_bar( false );
// Remove ACF for non admin users
function remove_acf(){
if( wp_get_current_user()->ID != 1 ) {
remove_menu_page( 'edit.php?post_type=acf' );
}
}
add_action( 'admin_menu', 'remove_acf',100 );
// Allow svg
function cc_mime_types($mimes) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter('upload_mimes', 'cc_mime_types');
// Get post featured image
function get_post_featured_img( $object ) {
//get the id of the post object array
$post_id = $object['id'];
return array(
'full' => wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), 'full')[0],
'medium' => wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), 'medium')[0],
'large' => wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), 'large')[0]
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment