Astra_Target_Rules_Fields::get_current_layout( int $layout_id, string $option )
Get current layout.
Description
Checks of the passed post id of the layout is to be displayed in the page.
Parameters
- $layout_id
-
(int) (Required) Layout ID.
- $option
-
(string) (Required) Option prefix.
Return
(int|boolean) If the current layout is to be displayed it will be returned back else a boolean will be passed.
Source
File: classes/modules/target-rule/class-astra-target-rules-fields.php
public function get_current_layout( $layout_id, $option ) { $post_id = ( ! is_404() && ! is_search() && ! is_archive() && ! is_home() ) ? get_the_id() : false; $current_layout = false; $is_exclude = false; $is_user_role = false; $display_on = get_post_meta( $layout_id, $option . '-location', true ); $exclude_on = get_post_meta( $layout_id, $option . '-exclusion', true ); $user_roles = get_post_meta( $layout_id, $option . '-users', true ); /* Parse Display On Condition */ $is_display = $this->parse_layout_display_condition( $post_id, $display_on ); if ( true == $is_display ) { /* Parse Exclude On Condition */ $is_exclude = $this->parse_layout_display_condition( $post_id, $exclude_on ); /* Parse User Role Condition */ $is_user_role = $this->parse_user_role_condition( $post_id, $user_roles ); } if ( $is_display && ! $is_exclude && $is_user_role ) { $current_layout = $layout_id; } // filter target page settings. $current_layout = apply_filters( 'astra_target_page_settings', $current_layout, $layout_id ); return $current_layout; }
Expand full source code Collapse full source code View on Trac