s (show_on) // if ( $action == 'add filter' && $field['type'] !== 'group' ) { // // Update old show_on value // if ( isset( $field['show_on'] ) ) { $new_show_on = array(); if ( ! empty( $field['_show_on_parent'] ) ) { $type_id = $field['_show_on_parent']; $rep_id = 'ovr_' . $args['id'] . '-' . $field['_show_on_parent']; } else { // // remove text after last _ to detect the parent field id for replacement // We suggest to add "_show_on_parent" to parent. // $type_id = explode( '_', $field['id'] ); if ( count( $type_id ) > 1 ) { array_pop( $type_id ); } $type_id = implode( '_', $type_id ); $rep_id = 'ovr_' . $args['id'] . '-' . $type_id; } // renames old ID's to new id foreach ( $field['show_on'] as $show_l1 ) { $_show_l1 = array(); foreach ( $show_l1 as $show_l2 ) { $_show_l1[] = str_replace( $type_id, $rep_id, $show_l2 ); } $new_show_on[] = $_show_l1; } // add new filter to show on foreach ( $new_show_on as $idx => $_ ) { $new_show_on[ $idx ][] = $condition_field_id . '=1'; } $field['show_on'] = $new_show_on; } else { $field['show_on'] = array( array( $condition_field_id . '=1' ) ); } } if ( $field['type'] === 'group' && $field['level'] == 2 ) { $override_fields[ $id . '-close' ] = array( 'type' => 'group_close', 'ajax-tab-field' => $args['ajax-section-field'], 'level' => 'all', ); } if ( $field['type'] !== 'group_close' ) { $field['id'] = $id; $field['ajax-tab-field'] = $args['ajax-section-field']; $override_fields[ $id ] = $field; } // // auto close for old group // if ( $field['type'] === 'group' && $field['level'] == 4 && ! $closed ) { $override_fields[ $id . '-close' ] = array( 'type' => 'group_close', 'ajax-tab-field' => $args['ajax-section-field'], ); $closed = TRUE; } // // group start -> condition field should be added // if ( $field['type'] === 'group' && $field['level'] == 4 ) { $action = 'add condition'; } // // End of group -> clear // elseif ( $field['type'] === 'group_close' ) { $action = ''; $condition_field_id = ''; $closed = TRUE; } } return $override_fields; } // better_ads_inject_override_ad_section_fields } if ( ! function_exists( 'better_ads_section_override_fields_list' ) ) { /** * Prepares fields to opened group in ajax action of panel * * @param $args * * @return array */ function better_ads_section_override_fields_list( $args ) { $section_fields_list = better_ads_get_override_fields_list( array(), $args ); if ( empty( $args['ajax-section-field'] ) ) { $args['ajax-section-field'] = 'ajax-section-field'; } $section_fields = better_ads_inject_override_ad_section_fields( array( 'id' => $args['section'], 'name' => $args['section-name'], 'fields' => $section_fields_list, 'ajax-section-field' => $args['ajax-section-field'], ) ); return $section_fields; } } if ( ! function_exists( 'better_ads_section_disable_fields_list' ) ) { /** * Prepares fields to opened group in ajax action of panel * * @param array $fields * @param array $args * * @return array */ function better_ads_section_disable_fields_list( $fields = array(), $args = array() ) { $args = bf_merge_args( $args, array( 'type' => 'post', ) ); $fields['bam_disable_all'] = array( 'name' => __( 'Disable All Ads?', 'better-studio' ), 'id' => 'bam_disable_all', 'type' => 'switch', 'on-label' => __( 'Yes', 'better-studio' ), 'off-label' => __( 'No', 'better-studio' ), 'desc' => __( 'Hides all ads.', 'better-studio' ), ); $fields['bam_disable_locations'] = array( 'name' => __( 'Disable All Ad Locations?', 'better-studio' ), 'id' => 'bam_disable_locations', 'type' => 'switch', 'on-label' => __( 'Yes', 'better-studio' ), 'off-label' => __( 'No', 'better-studio' ), 'desc' => __( 'Hides only ad locations.', 'better-studio' ), 'show_on' => array( array( 'bam_disable_all=0', ), ), ); $fields['bam_disable_widgets'] = array( 'name' => __( 'Disable All Widgets?', 'better-studio' ), 'id' => 'bam_disable_widgets', 'type' => 'switch', 'on-label' => __( 'Yes', 'better-studio' ), 'off-label' => __( 'No', 'better-studio' ), 'desc' => __( 'Hides ad widgets.', 'better-studio' ), 'show_on' => array( array( 'bam_disable_all=0', ), ), ); if ( $args['type'] === 'post' ) { $fields['bam_disable_post_content'] = array( 'name' => __( 'Disable All Content Ads?', 'better-studio' ), 'id' => 'bam_disable_post_content', 'type' => 'switch', 'on-label' => __( 'Yes', 'better-studio' ), 'off-label' => __( 'No', 'better-studio' ), 'desc' => __( 'Hides post content ads.', 'better-studio' ), 'show_on' => array( array( 'bam_disable_all=0', ), ), ); } return $fields; } }