Last active
September 13, 2019 19:26
-
-
Save esedic/8aac2c8aac5b691127b1ad24d0750042 to your computer and use it in GitHub Desktop.
Wordpress snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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