wordpress/wp-content/themes/basic/themify/themify-metabox/includes/themify-metabox-utils.php
/**
 * Check if assignments are applied in the current context
 *
 * @since 1.0
 */
Check if assignments are applied in the current context
@since 1.0
Check if assignments are applied in the current context @since 1 . 0
function themify_verify_assignments( $assignments ) {
	$query_object = get_queried_object();
	if ( ! empty( $assignments['roles'] )
		&& ! count( array_intersect( wp_get_current_user()->roles, array_keys( $assignments['roles'], true ) ) )
	) {
		return false; 
	}
	unset( $assignments['roles'] );
	if ( ! empty($assignments ) ) {
		if (
			( isset($assignments['general']['home']) && is_front_page())
			|| (isset( $assignments['general']['page'] ) &&  is_page() && ! is_front_page() )
			|| ( is_singular('post') && isset($assignments['general']['single']) )
			|| ( isset($assignments['general']['search']) && is_search() )
			|| ( isset($assignments['general']['author'])  && is_author())
			|| ( isset($assignments['general']['category']) && is_category())
			|| ( isset($assignments['general']['tag'])  && is_tag())
			|| ( isset($query_object->post_type,$assignments['general'][$query_object->post_type]) && is_singular() && $query_object->post_type !== 'page' && $query_object->post_type !== 'post' )
			|| ( isset($query_object->taxonomy,$assignments['general'][$query_object->taxonomy]) && is_tax())
		) {
			return true;
		} else { 
			if ( ! empty( $assignments['tax'] ) ) {
				if ( is_single() ) {
					if ( ! empty( $assignments['tax']['category_single'] ) ) {
						$categories = wp_get_post_categories( get_queried_object_id(), array( 'fields' => 'slugs' ) );
						if ( array_intersect( array_keys( $assignments['tax']['category_single'], true ), $categories ) ) {
							return true;
						}
					}
				} else {
					foreach ( $assignments['tax'] as $tax => $terms ) {
						$terms = array_keys( $terms );
						if ( ( $tax === 'category' && is_category($terms) ) || ( $tax === 'post_tag' && is_tag( $terms ) ) || ( is_tax( $tax, $terms ) )
						) {
							return true;
						}
					}
				}
			}
			if (! empty( $assignments['post_type'] ) ) {
				foreach ( $assignments['post_type'] as $post_type => $posts ) {
					$posts = array_keys( $posts );
					if ( $post_type === 'page' && ! empty( $query_object->post_parent ) ) {
						$post_name = str_replace( home_url(), '', get_permalink( $query_object->ID ) );
						if ( in_array( $post_name, $posts ) ) {
							return true;
						}
					}
					if (
						( $post_type === 'post' && is_single() && is_single( $posts ) )
						|| ( $post_type === 'page' && (
								( is_page( $posts ) )
								|| ( ! is_front_page() && is_home() && in_array( get_post_field( 'post_name', get_option( 'page_for_posts' ) ), $posts ,true ) ) 
								|| ( themify_metabox_is_shop() && in_array( get_post_field( 'post_name', themify_metabox_shop_pageId()), $posts,true  ) ) 
						) )
						|| ( is_singular( $post_type ) && in_array( $query_object->post_name, $posts,true ) )
					) {
						return true;
					}
				}
			}
		}
	}
	return false;
}
function themify_verify_assignments ( $ assignments ) { $ query_object = get_queried_object ( ) ; if ( ! empty ( $ assignments [ 'roles' ] ) && ! count ( array_intersect ( wp_get_current_user ( ) -> roles , array_keys ( $ assignments [ 'roles' ] , true ) ) ) ) { return false ; } unset ( $ assignments [ 'roles' ] ) ; if ( ! empty ( $ assignments ) ) { if ( ( isset ( $ assignments [ 'general' ] [ 'home' ] ) && is_front_page ( ) ) || ( isset ( $ assignments [ 'general' ] [ 'page' ] ) && is_page ( ) && ! is_front_page ( ) ) || ( is_singular ( 'post' ) && isset ( $ assignments [ 'general' ] [ 'single' ] ) ) || ( isset ( $ assignments [ 'general' ] [ 'search' ] ) && is_search ( ) ) || ( isset ( $ assignments [ 'general' ] [ 'author' ] ) && is_author ( ) ) || ( isset ( $ assignments [ 'general' ] [ 'category' ] ) && is_category ( ) ) || ( isset ( $ assignments [ 'general' ] [ 'tag' ] ) && is_tag ( ) ) || ( isset ( $ query_object -> post_type , $ assignments [ 'general' ] [ $ query_object -> post_type ] ) && is_singular ( ) && $ query_object -> post_type !== 'page' && $ query_object -> post_type !== 'post' ) || ( isset ( $ query_object -> taxonomy , $ assignments [ 'general' ] [ $ query_object -> taxonomy ] ) && is_tax ( ) ) ) { return true ; } else { if ( ! empty ( $ assignments [ 'tax' ] ) ) { if ( is_single ( ) ) { if ( ! empty ( $ assignments [ 'tax' ] [ 'category_single' ] ) ) { $ categories = wp_get_post_categories ( get_queried_object_id ( ) , array ( 'fields' => 'slugs' ) ) ; if ( array_intersect ( array_keys ( $ assignments [ 'tax' ] [ 'category_single' ] , true ) , $ categories ) ) { return true ; } } } else { foreach ( $ assignments [ 'tax' ] as $ tax => $ terms ) { $ terms = array_keys ( $ terms ) ; if ( ( $ tax === 'category' && is_category ( $ terms ) ) || ( $ tax === 'post_tag' && is_tag ( $ terms ) ) || ( is_tax ( $ tax , $ terms ) ) ) { return true ; } } } } if ( ! empty ( $ assignments [ 'post_type' ] ) ) { foreach ( $ assignments [ 'post_type' ] as $ post_type => $ posts ) { $ posts = array_keys ( $ posts ) ; if ( $ post_type === 'page' && ! empty ( $ query_object -> post_parent ) ) { $ post_name = str_replace ( home_url ( ) , '' , get_permalink ( $ query_object -> ID ) ) ; if ( in_array ( $ post_name , $ posts ) ) { return true ; } } if ( ( $ post_type === 'post' && is_single ( ) && is_single ( $ posts ) ) || ( $ post_type === 'page' && ( ( is_page ( $ posts ) ) || ( ! is_front_page ( ) && is_home ( ) && in_array ( get_post_field ( 'post_name' , get_option ( 'page_for_posts' ) ) , $ posts , true ) ) || ( themify_metabox_is_shop ( ) && in_array ( get_post_field ( 'post_name' , themify_metabox_shop_pageId ( ) ) , $ posts , true ) ) ) ) || ( is_singular ( $ post_type ) && in_array ( $ query_object -> post_name , $ posts , true ) ) ) { return true ; } } } } } return false ; }
Check if assignments are applied in the current context
 @since 1.0
Check if assignments are applied in the current context @since 1 . 0
// check if *any* of user's role(s) matches // bail early. // let's dig deeper into more specific visibility rules /* child pages have unique names based on their permalink */ // Post single // Page view // check for Posts page // check for Shop page // Custom Post Types single view check