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]
);
}