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 | |
/** | |
* Allow users who don't have edit_posts capability to edit attachment metadata. | |
* From @grapplerulrich on https://core.trac.wordpress.org/ticket/19834#comment:42 | |
*/ | |
add_filter( 'register_post_type_args', function( $args, $post_type ) { | |
if ( 'attachment' === $post_type ) { | |
$args['capabilities']['edit_posts'] = 'upload_files'; | |
$args['capabilities']['upload_files'] = 'upload_files'; | |
} |
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 | |
$start_of_week = date( 'Y-m-d', strtotime( 'monday this week' ) ); | |
$end_of_week = date( 'Y-m-d', strtotime( 'sunday this week' ) ); | |
$event_args['meta_query'] = array( | |
array( | |
'relation' => 'AND', | |
// Event starts before end of week, and finishes after start of week. | |
// This covers all instances of events overlapping the week period. | |
array( |
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 | |
/** | |
* Adds admin area filtering for custom post type tags. | |
* | |
* This is separate because, for some reason, the taxonomy | |
* is 'post_tag' but the query var is 'tag'. | |
* | |
* @param string $post_type The post type slug. | |
* @return void | |
*/ |
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 | |
/** | |
* Adds admin area filtering for CPT taxonomies. | |
* | |
* @param string $post_type The post type slug. | |
* @return void | |
*/ | |
function filter_cpt_by_taxonomies( $post_type ) { | |
// Apply this only on a specific post type |