ID, 'data_group_array', true) ); $data_group_array = is_array($data_group_array)? array_values($data_group_array): array(); if ( empty( $data_group_array ) ) { $data_group_array[0] =array( 'data_array' => array( array( 'key_1' => 'post_type', 'key_2' => 'equal', 'key_3' => 'none', ) ) ); } //security check wp_nonce_field( 'adsforwp_select_action_nonce', 'adsforwp_select_name_nonce' );?> array( 'post_type' => esc_html__("Post Type",'ads-for-wp'), 'show_globally' => esc_html__("Show Globally",'ads-for-wp'), 'user_type' => esc_html__("Logged in User Type",'ads-for-wp'), ), esc_html__("Post",'ads-for-wp') => array( 'post' => esc_html__("Post",'ads-for-wp'), 'post_category' => esc_html__("Post Category",'ads-for-wp'), 'post_format' => esc_html__("Post Format",'ads-for-wp'), ), esc_html__("Page",'ads-for-wp') => array( 'page' => esc_html__("Page",'ads-for-wp'), 'page_template' => esc_html__("Page Template",'ads-for-wp'), ), esc_html__("Other",'ads-for-wp') => array( 'ef_taxonomy' => esc_html__("Taxonomy Term",'ads-for-wp'), 'User' => esc_html__("User",'ads-for-wp'), ) ); $comparison = array( 'equal' => esc_html__( 'Equal to', 'ads-for-wp'), 'not_equal' => esc_html__( 'Not Equal to', 'ads-for-wp'), ); $total_group_fields = count( $data_group_array ); ?>
0){ echo 'Or'; } ?>
adsforwp_ajax_select_creator($selected_val_key_1, $selected_val_key_3, $i, $j ); if($selected_val_key_1 == 'ef_taxonomy'){ $ajax_select_box_obj->adsforwp_create_ajax_select_taxonomy($selected_val_key_3, $selected_val_key_4, $i, $j); } ?>
Or
post_type; } if ( $comparison == 'equal' ) { if ( $current_post_type == $data ) { $result = true; } } if ( $comparison == 'not_equal') { if ( $current_post_type != $data ) { $result = true; } } break; // Logged in User Type case 'user_type': if ( $comparison == 'equal') { if ( in_array( $data, (array) $user->roles ) ) { $result = true; } } if ( $comparison == 'not_equal') { require_once ABSPATH . 'wp-admin/includes/user.php'; // Get all the registered user roles $roles = get_editable_roles(); $all_user_types = array(); foreach ($roles as $key => $value) { $all_user_types[] = $key; } // Flip the array so we can remove the user that is selected from the dropdown $all_user_types = array_flip( $all_user_types ); // User Removed unset( $all_user_types[$data] ); // Check and make the result true that user is not found if ( in_array( $data, (array) $all_user_types ) ) { $result = true; } } break; // Post Controls ------------ // Posts case 'post': $current_post =''; if(is_singular()){ $current_post = $post->ID; } if ( $comparison == 'equal' ) { if ( $current_post == $data ) { $result = true; } } if ( $comparison == 'not_equal') { if ( $current_post != $data ) { $result = true; } } break; // Post Category case 'post_category': $current_category = ''; $postcat = get_the_category( $post->ID ); if(!empty($postcat)){ if(is_object($postcat[0])){ $current_category = $postcat[0]->cat_ID; } } if ( $comparison == 'equal') { if ( $data == $current_category ) { $result = true; } } if ( $comparison == 'not_equal') { if ( $data != $current_category ) { $result = true; } } break; // Post Format case 'post_format': $current_post_format = get_post_format( $post->ID ); if ( $current_post_format === false ) { $current_post_format = 'standard'; } if ( $comparison == 'equal') { if ( $data == $current_post_format ) { $result = true; } } if ( $comparison == 'not_equal') { if ( $data != $current_post_format ) { $result = true; } } break; // Page Controls ---------------- // Page case 'page': global $redux_builder_amp; if(function_exists('ampforwp_is_front_page')){ if(ampforwp_is_front_page()){ $current_post = $redux_builder_amp['amp-frontpage-select-option-pages']; } else{ $current_post = $post->ID; } }else{ $current_post = $post->ID; } if ( $comparison == 'equal' ) { if ( $current_post == $data ) { $result = true; } } if ( $comparison == 'not_equal') { if ( $current_post != $data ) { $result = true; } } break; // Page Template case 'page_template': $current_page_template = get_page_template_slug( $post->ID ); if ( $current_page_template == false ) { $current_page_template = 'default'; } if ( $comparison == 'equal' ) { if ( $current_page_template == $data ) { $result = true; } } if ( $comparison == 'not_equal') { if ( $current_page_template != $data ) { $result = true; } } break; // Other Controls --------------- // Taxonomy Term case 'ef_taxonomy': // Get all the post registered taxonomies // Get the list of all the taxonomies associated with current post $taxonomy_names = get_post_taxonomies( $post->ID ); $checker = ''; $post_terms = ''; if ( $data != 'all') { $post_terms = wp_get_post_terms($post->ID, $data); if ( $comparison == 'equal' ) { if ( $post_terms ) { $result = true; } } if ( $comparison == 'not_equal') { $checker = in_array($data, $taxonomy_names); if ( ! $checker ) { $result = true; } } if($result==true && isset( $input['key_4'] ) && $input['key_4'] !='all'){ $term_data = $input['key_4']; $terms = wp_get_post_terms( $post->ID ,$data); if(count($terms)>0){ $termChoices = array(); foreach ($terms as $key => $termvalue) { $termChoices[] = $termvalue->slug; } } $result = false; if(in_array($term_data, $termChoices)){ $result = true; } }//if closed for key_4 } else { if ( $comparison == 'equal' ) { if ( $taxonomy_names ) { $result = true; } } if ( $comparison == 'not_equal') { if ( ! $taxonomy_names ) { $result = true; } } } break; default: $result = false; break; } return $result; } public function adsforwp_generate_field_data( $post_id ){ $data_group_array = get_post_meta( $post_id, 'data_group_array', true); $output = array(); if($data_group_array){ foreach ($data_group_array as $gropu){ $output[] = array_map(array($this, 'adsforwp_comparison_logic_checker'), $gropu['data_array']); } } return $output; } public function adsforwp_get_post_conditions_status($post_id){ $unique_checker = ''; $resultset = $this->adsforwp_generate_field_data( $post_id ); if($resultset){ $condition_array = array(); foreach ($resultset as $result){ $data = array_filter($result); $number_of_fields = count($data); $checker = 0; if ( $number_of_fields > 0 ) { $checker = count( array_unique($data) ); $array_is_false = in_array(false, $result); if ( $array_is_false ) { $checker = 0; } } $condition_array[] = $checker; } $array_is_true = in_array(true,$condition_array); if($array_is_true){ $unique_checker = 1; } }else{ $unique_checker ='notset'; } return $unique_checker; } } if (class_exists('adsforwp_view_placement')) { new adsforwp_view_placement; };