Last active
February 7, 2018 15:56
-
-
Save joshfeck/26ced2d13aee9f1c7aa1c897a581eec6 to your computer and use it in GitHub Desktop.
Add support for Restrict Content Pro's settings for Event Espresso events post types
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 | |
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file | |
// modify Event Espresso event CPT's show_ui setting | |
add_filter( 'FHEE__EE_Register_CPTs__get_CPTs__cpts', 'rcee_modify_visibility_of_event_espresso_cpt_in_admin' ); | |
function rcee_modify_visibility_of_event_espresso_cpt_in_admin( $cpt_registry_array ) { | |
if ( isset( $cpt_registry_array['espresso_events'] ) ) { | |
$cpt_registry_array['espresso_events']['args']['show_ui'] = true; | |
} | |
return $cpt_registry_array; | |
} | |
// add submenu item, change priority 10 to a larger value to move the menu item from the top | |
add_action('admin_menu', 'rcee_add_restrict_access_admin_menu_item', 10); | |
function rcee_add_restrict_access_admin_menu_item() { | |
add_submenu_page( | |
'espresso_events', | |
'Restrict Event Access', | |
'Restrict Event Access', | |
'manage_options', | |
'edit.php?post_type=espresso_events&page=rcp-restrict-post-type-espresso_events' | |
); | |
} | |
// set the_content filter to a later priority for EE event post type | |
add_action('template_redirect', 'rcee_move_the_content_filter_priority'); | |
function rcee_move_the_content_filter_priority() { | |
if('espresso_events' == get_post_type()){ | |
remove_filter( 'the_content', 'rcp_filter_restricted_content' , 100 ); | |
add_filter( 'the_content', 'rcp_filter_restricted_content' , 200 ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment