mirror of
https://github.com/10h30/ultimatemember.git
synced 2026-07-13 11:46:27 +09:00
Add action hook for current page type in access settings
This commit is contained in:
@@ -144,6 +144,11 @@
|
||||
$post_id = get_option('woocommerce_shop_page_id');
|
||||
|
||||
} else if ( is_archive() || is_front_page() || is_home() || is_search() || in_the_loop() || is_feed() ) {
|
||||
|
||||
$current_page_type = um_get_current_page_type();
|
||||
|
||||
do_action("um_access_post_type",$current_page_type);
|
||||
do_action("um_access_post_type_{$current_page_type}");
|
||||
|
||||
return;
|
||||
|
||||
|
||||
@@ -1647,3 +1647,44 @@ function um_fetch_user( $user_id ) {
|
||||
|
||||
return $lang_code;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current page type
|
||||
* @return string
|
||||
*/
|
||||
function um_get_current_page_type() {
|
||||
global $wp_query;
|
||||
$loop = 'notfound';
|
||||
|
||||
if ( $wp_query->is_page ) {
|
||||
$loop = is_front_page() ? 'front' : 'page';
|
||||
} elseif ( $wp_query->is_home ) {
|
||||
$loop = 'home';
|
||||
} elseif ( $wp_query->is_single ) {
|
||||
$loop = ( $wp_query->is_attachment ) ? 'attachment' : 'single';
|
||||
} elseif ( $wp_query->is_category ) {
|
||||
$loop = 'category';
|
||||
} elseif ( $wp_query->is_tag ) {
|
||||
$loop = 'tag';
|
||||
} elseif ( $wp_query->is_tax ) {
|
||||
$loop = 'tax';
|
||||
} elseif ( $wp_query->is_archive ) {
|
||||
if ( $wp_query->is_day ) {
|
||||
$loop = 'day';
|
||||
} elseif ( $wp_query->is_month ) {
|
||||
$loop = 'month';
|
||||
} elseif ( $wp_query->is_year ) {
|
||||
$loop = 'year';
|
||||
} elseif ( $wp_query->is_author ) {
|
||||
$loop = 'author';
|
||||
} else {
|
||||
$loop = 'archive';
|
||||
}
|
||||
} elseif ( $wp_query->is_search ) {
|
||||
$loop = 'search';
|
||||
} elseif ( $wp_query->is_404 ) {
|
||||
$loop = 'notfound';
|
||||
}
|
||||
|
||||
return $loop;
|
||||
}
|
||||
Reference in New Issue
Block a user