diff --git a/core/um-actions-access.php b/core/um-actions-access.php index 1883b660..5acafe5e 100644 --- a/core/um-actions-access.php +++ b/core/um-actions-access.php @@ -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; diff --git a/core/um-short-functions.php b/core/um-short-functions.php index 280ca361..c82b7e32 100644 --- a/core/um-short-functions.php +++ b/core/um-short-functions.php @@ -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; + } \ No newline at end of file