Wpallimport 新手从组合字段中提取特定数据

问题描述

大家好,希望一切顺利,我是新手,所以如果以下任何内容听起来很傻,请原谅,但非常感谢任何提示和反馈。我正在尝试的是从 Tourmaster 预订栏 CPT 组合字段“tourmaster-tour-option”的“自定义表单”选项中的“$tour_option['form-custom-code']”中提取 i-frame 代码。下面是 PHP 字段:

echo '<div class="tourmaster-template-wrapper" >';

// tourmaster booking bar
if( !post_password_required() && $tour_option['form-settings'] != 'none' ){
    echo '<div class="tourmaster-tour-booking-bar-container tourmaster-container" >';
    echo '<div class="tourmaster-tour-booking-bar-container-inner" >';
    echo '<div class="tourmaster-tour-booking-bar-anchor tourmaster-item-mglr" ></div>';
    echo '<div class="tourmaster-tour-booking-bar-wrap tourmaster-item-mglr" id="tourmaster-tour-booking-bar-wrap" >';
    echo '<div class="tourmaster-tour-booking-bar-outer" >';
    echo $header_price;

    echo '<div class="tourmaster-tour-booking-bar-inner" >';
    
    if(  $tour_option['form-settings'] == 'both' ){
        echo '<div class="tourmaster-booking-tab-title clearfix" id="tourmaster-booking-tab-title" >';
        echo '<div class="tourmaster-booking-tab-title-item tourmaster-active" data-tourmaster-tab="booking" >' . esc_html__('Booking Form','tourmaster') . '</div>';
        echo '<div class="tourmaster-booking-tab-title-item" data-tourmaster-tab="enquiry" >' . esc_html__('Enquiry Form','tourmaster') . '</div>';
        echo '</div>';
    }

    // custom form
    if( $tour_option['form-settings'] == 'custom' && !empty($tour_option['form-custom-code']) ){
        echo '<div class="tourmaster-tour-booking-custom-code-wrap" >';
        echo tourmaster_text_filter($tour_option['form-custom-code']);
        echo '</div>';
    }

    // enquiry form
    if( $tour_option['form-settings'] == 'enquiry' || $tour_option['form-settings'] == 'both' ){
        echo ($tour_option['form-settings'] == 'both')? '<div class="tourmaster-booking-tab-content" data-tourmaster-tab="enquiry" >': '';

        echo '<div class="tourmaster-tour-booking-enquiry-wrap" >';
        echo tourmaster_get_enquiry_form(get_the_ID());
        echo '</div>';

        echo ($tour_option['form-settings'] == 'both')? '</div>': '';
    }

    // booking form
    if( $tour_option['form-settings'] == 'booking' || $tour_option['form-settings'] == 'both' ){
        echo ($tour_option['form-settings'] == 'both')? '<div class="tourmaster-booking-tab-content tourmaster-active" data-tourmaster-tab="booking" >': '';

        // external url ( referer )
        if( !empty($tour_option['link-proceed-booking-to-external-url']) ){

            echo '<div class="tourmaster-single-tour-booking-referral" >';
            if( !empty($tour_option['external-url-text']) ){
                echo '<div class="tourmaster-single-tour-booking-referral-text" >';
                echo tourmaster_content_filter($tour_option['external-url-text']);
                echo '</div>';
            } 
            echo '<a class="tourmaster-button" href="' . esc_html($tour_option['link-proceed-booking-to-external-url']) . '" target="_blank" >' . esc_html__('Proceed Booking','tourmaster') . '</a>';
            echo '</div>';

        // normal form
        }else{
            $update_header_price = tourmaster_get_option('general','update-header-price','enable');
            $form_class = ($update_header_price == 'enable')? 'tourmaster-update-header-price': '';

            echo '<form class="tourmaster-single-tour-booking-fields ' . esc_attr($form_class) . ' tourmaster-form-field tourmaster-with-border" method="post" ';
            echo 'action="' . esc_url(tourmaster_get_template_url('payment')) . '" ';
            echo 'id="tourmaster-single-tour-booking-fields" data-ajax-url="' . esc_url(TOURMASTER_AJAX_URL) . '" >';

            echo '<input type="hidden" name="tour-id" value="' . esc_attr(get_the_ID()) . '" />';
            $available_date = get_post_meta(get_the_ID(),'tourmaster-tour-date-avail',true);
            if( !empty($available_date) ){  
                $available_date = explode(',',$available_date);

                echo '<div class="tourmaster-tour-booking-date clearfix" data-step="1" >';
                echo '<i class="fa fa-calendar" ></i>';
                echo '<div class="tourmaster-tour-booking-date-input" >';

                $selected_date = $available_date[0];
                if( !empty($temp_data['tour-date']) ){
                    $selected_date = $temp_data['tour-date'];
                    unset($temp_data['tour-date']);
                }
                if( sizeof($available_date) == 1 ){
                    echo '<div class="tourmaster-tour-booking-date-display" >' . tourmaster_date_format($selected_date) . '</div>';
                    echo '<input type="hidden" name="tour-date" value="' . esc_attr($selected_date) . '" />';
                }else{
                    $date_selection_type = empty($tour_option['date-selection-type'])? 'calendar': $tour_option['date-selection-type'];

                    if( $date_selection_type == 'calendar' ){
                        echo '<div class="tourmaster-datepicker-wrap" >';
                        echo '<input type="text" class="tourmaster-datepicker" readonly ';
                        echo 'value="' . esc_attr($selected_date) . '" ';
                        echo 'data-date-format="' . esc_attr(tourmaster_get_option('general','datepicker-date-format','d M yy')) . '" ';
                        echo 'data-tour-range="' . (empty($tour_option['multiple-duration'])? 1: intval($tour_option['multiple-duration'])) . '" ';
                        echo 'data-tour-date="' . esc_attr(json_encode($available_date)) . '" />';
                        echo '<input type="hidden" name="tour-date" class="tourmaster-datepicker-alt" />';
                        echo '</div>';

                    }else if( $date_selection_type == 'date-list'){
                        echo '<div class="tourmaster-comboBox-wrap tourmaster-tour-date-comboBox" >';
                        echo '<select name="tour-date" >';
                        foreach( $available_date as $available_date_single ){
                            echo '<option value="' . esc_attr($available_date_single) . '" ' . ($selected_date == $available_date_single? 'selected': '') . ' >';
                            echo tourmaster_date_format($available_date_single);
                            echo '</option>';
                        }
                        echo '</select>';
                        echo '</div>';
                    }
                }
                echo '</div>';
                echo '</div>'; // tourmaster-tour-booking-date

                $booking_value = array();
                if( !empty($temp_data) ){
                    $booking_value = array(
                        'tour-people' => empty($temp_data['tour-people'])? '': $temp_data['tour-people'],'tour-room' => empty($temp_data['tour-room'])? '': $temp_data['tour-room'],'tour-adult' => empty($temp_data['tour-adult'])? '': $temp_data['tour-adult'],'tour-children' => empty($temp_data['tour-children'])? '': $temp_data['tour-children'],'tour-student' => empty($temp_data['tour-student'])? '': $temp_data['tour-student'],'tour-infant' => empty($temp_data['tour-infant'])? '': $temp_data['tour-infant'],'package' => empty($temp_data['package'])? '': $temp_data['package'],);
                    unset($temp_data['tour-people']);
                    unset($temp_data['tour-room']);
                    unset($temp_data['tour-adult']);
                    unset($temp_data['tour-children']);
                    unset($temp_data['tour-student']);
                    unset($temp_data['tour-infant']);
                    unset($temp_data['tour-infant']);
                    unset($temp_data['package']);
                }else{
                    $date_price = tourmaster_get_tour_date_price($tour_option,get_the_ID(),$selected_date);
                    if( !empty($date_price['package']) ){
                        foreach( $date_price['package'] as $package ){
                            if( !empty($package['default-package']) && $package['default-package'] == 'enable' ){
                                $booking_value['package'] = $package['title'];
                                break;
                            }
                        }
                    }
                }

                echo tourmaster_get_tour_booking_fields(array(
                    'tour-id' => get_the_ID(),'tour-date' => $selected_date,'step' => 1
                ),$booking_value);
            }else{
                echo '<div class="tourmaster-tour-booking-bar-error" data-step="999" >';
                echo apply_filters('tourmaster_tour_not_available_text',esc_html__('The tour is not available yet.','tourmaster'));
                echo '</div>';
            }

            // carry over data
            if( !empty($temp_data) ){
                foreach( $temp_data as $field_name => $field_value ){
                    if( is_array($field_value) ){
                        foreach( $field_value as $field_single_value ){
                            echo '<input type="hidden" name="' . esc_attr($field_name) . '[]" value="' . esc_attr($field_single_value) . '" />';
                        }
                    }else{
                        echo '<input type="hidden" name="' . esc_attr($field_name) . '" value="' . esc_attr($field_value) . '" />';
                    }
                }
            }
            
            echo '</form>'; // tourmaster-tour-booking-fields

        } // normal form

        // if not logging in print the login before proceed form
        if( !is_user_logged_in() ){
            $guest_booking = tourmaster_get_option('general','enable-guest-booking','enable');
            $guest_booking = ($guest_booking == 'enable')? true: false;
            echo tourmaster_lightBox_content(array(
                'id' => 'proceed-without-login','title' => esc_html__('Proceed Booking','tourmaster'),'content' => tourmaster_get_login_form2(false,array(
                    'continue-as-guest'=>$guest_booking,'redirect'=>'payment'
                ))
            ));
        }

        echo ($tour_option['form-settings'] == 'both')? '</div>': '';

    } // booking form

    // bottom bar for wish list and view count
    echo '<div class="tourmaster-booking-bottom clearfix" >';
    
    // wishlist section
    $logged_in = is_user_logged_in();
    if( !$logged_in ){
        echo '<div class="tourmaster-save-wish-list" data-tmlb="wish-list-login" >';
    }else{
        $wish_list = get_user_Meta($current_user->ID,'tourmaster-wish-list',true);
        $wish_list = empty($wish_list)? array(): $wish_list;
        $wish_list_active = in_array(get_the_ID(),$wish_list);

        if( !$wish_list_active ){
            echo '<div class="tourmaster-save-wish-list" ';
            echo 'id="tourmaster-save-wish-list" ';
            echo 'data-ajax-url="' . esc_url(TOURMASTER_AJAX_URL) . '" ';
            echo 'data-tour-id="' . esc_attr(get_the_ID()) . '" ';
            echo '>';
        }else{
            echo '<div class="tourmaster-save-wish-list tourmaster-active" >';
        }
    }
    echo '<span class="tourmaster-save-wish-list-icon-wrap" >';
    echo '<i class="tourmaster-icon-active fa fa-heart" ></i>';
    echo '<i class="tourmaster-icon-inactive fa fa-heart-o" ></i>';
    echo '</span>';
    echo esc_html__('Save To Wish List','tourmaster');
    echo '</div>'; // tourmaster-save-wish-list
    if( !$logged_in ){
        echo tourmaster_lightBox_content(array(
            'id' => 'wish-list-login','title' => esc_html__('Adding item to wishlist requires an account','content' => tourmaster_get_login_form2(false)
        ));
    }

    echo '<div class="tourmaster-view-count" >';
    echo '<i class="fa fa-eye" ></i>';
    echo '<span class="tourmaster-view-count-text" >' . $view_count . '</span>';
    echo '</div>'; // tourmaster-view-count
    echo '</div>'; // tourmaster-booking-bottom

    echo '</div>'; // tourmaster-tour-booking-bar-inner
    echo '</div>'; // tourmaster-tour-booking-bar-outer

    // sidebar widget
    if( !empty($tour_option['sidebar-widget']) && $tour_option['sidebar-widget'] != 'none' ){
        $sidebar_class = apply_filters('gdlr_core_sidebar_class','');

        $mobile_widget = tourmaster_get_option('general','enable-single-sidebar-widget-on-mobile','enable');
        if( $mobile_widget == 'disable' ){
            $sidebar_class .= ' tourmaster-hide-on-mobile';
        }

        echo '<div class="tourmaster-tour-booking-bar-widget ' . esc_attr($sidebar_class) . '" >';
        if( $tour_option['sidebar-widget'] == 'default' ){
            $sidebar_name = tourmaster_get_option('general','single-tour-default-sidebar','none');
            if( $sidebar_name != 'none' && is_active_sidebar($sidebar_name) ){
                dynamic_sidebar($sidebar_name); 
            }
        }else{
            if( is_active_sidebar($tour_option['sidebar-widget']) ){ 
                dynamic_sidebar($tour_option['sidebar-widget']); 
            }
        }
        echo '</div>';
    }
    echo '</div>'; // tourmaster-tour-booking-bar-wrap
    echo '</div>'; // tourmaster-tour-booking-bar-container-inner
    echo '</div>'; // tourmaster-tour-booking-bar-container
}

尝试以下操作但没有成功,因为结果显示了 iframe 代码和其余不需要的数据; Wp all import print screen

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)