未定义的变量错误

时间:2018-11-28 08:12:48

标签: php

我的孩子主题配置器出现以下错误,不知道如何修复。

  

注意:未定义变量:中的列   /www/sydney_744/public/wp-content/plugins/yachtcharter-shortcodes-post-types-boom-edited/includes/shortcodes/boat_carousel.php   在第22行

这是该文件中的代码。

第22行是

$sc_att_columns = $columns;

代码在下面。

<?php

function ycbe_boat_carousel_shortcode( $atts, $content = null ) {

    extract( shortcode_atts( array(
        'section_title' => '',
        'section_intro' => '',
        'posts_per_page' => '12',
        'order' => '',
        'price_from'        => '',
        'price_to'          => '',
        'locations'         => '',
        'features'          => '',
        'options'           => '',
        'charter_lengths'   => '',
        'total_boat_capacity' => '',
    ), $atts ) );


    $sc_att_order = $order;
    $sc_att_posts_per_page = $posts_per_page;
    $sc_att_columns = $columns;
    $sc_att_price_from = $price_from;
    $sc_att_price_to = $price_to;
    $sc_att_charter_lengths = $charter_lengths;
    $sc_att_locations = $locations;
    $sc_att_features = $features;
    $sc_att_options = $options;
    $sc_att_charter_lengths = $charter_lengths;
    $sc_filtered_boat_capacity = $total_boat_capacity;

    if ( $sc_att_order == 'newest' ) {
        $sc_att_order = 'DESC';
    } elseif ( $sc_att_order == 'oldest' ) {
        $sc_att_order = 'ASC';
    } else {
        $sc_att_order = 'DESC';
    }

    $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;

    if( isset( $_GET['from'] ) && $_GET['from'] !== '' ) {
        $filtered_price_from = (int)$_GET['from'];
    }

    if( isset( $_GET['to'] ) && $_GET['to'] !== '' ) {
        $filtered_price_to = (int)$_GET['to'];
    }

    if( isset( $_GET['boat_capacity'] ) && $_GET['boat_capacity'] !== '' ) {
        $filtered_boat_capacity = (int)$_GET[ 'boat_capacity' ];
    }

    if( isset( $_GET['buffet_dining_capacity'] ) && $_GET['buffet_dining_capacity'] !== '' ) {
        $filtered_buffet_dining_capacity = (int)$_GET['buffet_dining_capacity'];
    }

    if( isset( $_GET['cocktail_capacity'] ) && $_GET['cocktail_capacity'] !== '' ) {
        $filtered_cocktail_capacity = (int)$_GET['cocktail_capacity'];
    }

    if( isset( $_GET['formal_capacity'] ) && $_GET['formal_capacity'] !== '' ) {
        $filtered_formal_dining_capacity = (int)$_GET['formal_capacity'];
    }

    if( isset( $_GET['offshore_capacity'] ) && $_GET['offshore_capacity'] !== '' ) {
        $filtered_offshore_capacity = (int)$_GET['offshore_capacity'];
    }

    if( isset( $_GET['overnight_capacity'] ) && $_GET['overnight_capacity'] !== '' ) {
        $filtered_overnight_capacity = (int)$_GET['overnight_capacity'];
    }

    if( get_query_var( 'ycbe_locations' ) !== 'any' ) {
        $filtered_locations = get_query_var( 'ycbe_locations' );
    }

    if( get_query_var( 'ycbe_features' ) !== 'any' ) {
        $filtered_features = get_query_var( 'ycbe_features' );
    }

    if( get_query_var( 'ycbe_options' ) !== 'any' ) {
        $filtered_options = get_query_var( 'ycbe_options' );
    }

    if( get_query_var( 'ycbe_charter_lengths' ) !== 'any' ) {
        $filtered_charter_lengths = get_query_var( 'ycbe_charter_lengths' );
    }

    $meta_query = array( 'relation' => 'AND' );
    $tax_query = array( 'relation' => 'AND' );

    if( isset( $sc_att_price_from ) && $sc_att_price_from !== '' ) {

        $meta_query[] = array(
            'key'        => '_ycbe_price_from',
            'value'        => $sc_att_price_from,
            'compare'    => '>=',
            'type'        => 'DECIMAL',
        );

    } else {

        if( isset( $filtered_price_from ) ) {

            $meta_query[] = array(
                'key'        => '_ycbe_price_from',
                'value'      => $filtered_price_from,
                'compare'    => '>=',
                'type'       => 'DECIMAL',
                );

        }
    }

    if( isset( $sc_att_price_to ) && $sc_att_price_to !== '' ) {

        $meta_query[] = array(
            'key'       => '_ycbe_price_from',
            'value'     => $sc_att_price_to,
            'compare'   => '>=',
            'type'      => 'DECIMAL',
        );

    } else {

        if( isset( $filtered_price_to ) ) {

            $meta_query[] = array(
                'key'        => '_ycbe_price_from',
                'value'      => $filtered_price_to,
                'compare'    => '<=',
                'type'       => 'DECIMAL',
            );

        }

    }

    if( isset( $sc_filtered_boat_capacity ) && $sc_filtered_boat_capacity != '' ) {

        $meta_query[] = array(
            'key'       => '_ycbe_boat_capacity',
            'value'     => $sc_filtered_boat_capacity,
            'compare'   => '>=',
            'type'      => 'DECIMAL',
        );

    }

    if( isset( $filtered_buffet_dining_capacity ) ) {

        $meta_query[] = array(
            'key'       => '_ycbe_buffet_dining_capacity',
            'value'     => $filtered_buffet_dining_capacity,
            'compare'   => '>=',
            'type'      => 'DECIMAL',
        );

    }

    if( isset( $filtered_cocktail_capacity ) ) {

        $meta_query[] = array(
            'key'       => '_ycbe_cocktail_capacity',
            'value'     => $filtered_cocktail_capacity,
            'compare'   => '>=',
            'type'      => 'DECIMAL',
        );

    }

    if( isset( $filtered_formal_dining_capacity ) ) {

        $meta_query[] = array(
            'key'       => '_ycbe_formal_dining_capacity',
            'value'     => $filtered_formal_dining_capacity,
            'compare'   => '>=',
            'type'      => 'DECIMAL',
        );

    }

    if( isset( $filtered_offshore_capacity ) ) {

        $meta_query[] = array(
            'key'       => '_ycbe_offshore_capacity',
            'value'     => $filtered_offshore_capacity,
            'compare'   => '>=',
            'type'      => 'DECIMAL',
        );

    }

    if( isset( $filtered_overnight_capacity ) ) {

        $meta_query[] = array(
            'key'       => '_ycbe_overnight_capacity',
            'value'     => $filtered_offshore_capacity,
            'compare'   => '>=',
            'type'      => 'DECIMAL',
        );

    }

    if( isset( $sc_att_locations ) && $sc_att_locations !== '' ) {

        $sc_att_locations = explode( '+', $sc_att_locations );

        $tax_query_child = array();

        foreach( $sc_att_locations as $sc_att_location ) {

            $tax_query_child[] = array(
                'taxonomy'  => 'ycbe_location',
                'field'     => 'slug',
                'terms'     => $sc_att_location,
            );

        }

        $tax_query[] = array_merge( ['relation'=>'OR'], $tax_query_child );

    } else {

        if( isset( $filtered_locations ) && $filtered_locations !== '' ) {

            $filtered_locations = explode( '+', $filtered_locations );

            $tax_query_child = array();

            foreach( $filtered_locations as $filtered_location ) {

                $tax_query_child[] = array(
                    'taxonomy'  => 'ycbe_location',
                    'field'     => 'slug',
                    'terms'     => $filtered_location,
                );

            }

            $tax_query[] = array_merge( ['relation'=>'OR'], $tax_query_child );

        }

    }

    if( isset( $sc_att_features ) && $sc_att_features !== '' ) {

        $sc_att_features = explode( '+', $sc_att_features );


        foreach( $sc_att_features as $sc_att_feature ) {

            $tax_query[] = array(
                'taxonomy'  => 'ycbe_feature',
                'field'     => 'slug',
                'terms'     => $sc_att_feature,
            );

        }

    } else {

        if( isset( $filtered_features ) && $filtered_features !== '' ) {

            $filtered_features = explode( '+', $filtered_features );

            foreach( $filtered_features as $filtered_feature ) {

                $tax_query[] = array(
                    'taxonomy'  => 'ycbe_feature',
                    'field'     => 'slug',
                    'terms'     => $filtered_feature,
                );

            }

        }

    }

    if( isset( $sc_att_options ) && $sc_att_options !== '' ) {

        $sc_att_options = explode( '+', $sc_att_options );

        foreach( $sc_att_options as $sc_att_option ) {

            $tax_query[] = array(
                'taxonomy'  => 'ycbe_option',
                'field'     => 'slug',
                'terms'     => $sc_att_option,
            );

        }

    } else {

        if( isset( $filtered_options ) && $filtered_options !== '' ) {

            $filtered_options = explode( '+', $filtered_options );

            foreach( $filtered_options as $filtered_option ) {

                $tax_query[] = array(
                    'taxonomy'  => 'ycbe_option',
                    'field'     => 'slug',
                    'terms'     => $filtered_option,
                );

            }

        }

    }

    if( isset( $sc_att_charter_lengths ) && $sc_att_charter_lengths !== '' ) {

        $sc_att_charter_lengths = explode( '+', $sc_att_charter_lengths );

        $tax_query_child = array();

        foreach( $sc_att_charter_lengths as $sc_att_charter_length ) {

        $tax_query_child[] = array(
                    'relation' => 'OR',
                    array (
                        'taxonomy'  => 'ycbe_charter_length',
                        'field'     => 'slug',
                        'terms'     => $filtered_charter_length,
                    ),
                );

        }
        $tax_query[] = array_merge( ['relation'=>'OR'], $tax_query_child );

    } else {

        if( isset( $filtered_charter_lengths ) && $filtered_charter_lengths !== '' ) {

            $filtered_charter_lengths = explode( '+', $filtered_charter_lengths );

            $tax_query_child = array();

            foreach( $filtered_charter_lengths as $filtered_charter_length ) {

                $tax_query_child[] = array(
                    'taxonomy'  => 'ycbe_charter_length',
                    'field'     => 'slug',
                    'terms'     => $filtered_charter_length,
                );

            }

            $tax_query[] = array_merge( ['relation'=>'OR'], $tax_query_child );

        }

    }


    $post_query = new WP_Query(
        array(
            'post_type'         => 'ycbe_boat',
            'order'             => $sc_att_order,
            'posts_per_page'    => $sc_att_posts_per_page,
            'paged'             => $paged,
            'meta_query'        => $meta_query,
            'tax_query'         => $tax_query,
        )
    );



    global $post;
    global $wp_query;


    ob_start(); ?>

    <div class="our-yachts-sections">
        <div class="yacht-charter-carousel-wrapper">
            <h3 class="center-title"><?php echo $section_title; ?></h3>
            <div class="title-block2"></div>
            <p class="yacht-intro-text"><?php echo $section_intro; ?></p>
            <div class="owl-carousel1 yacht-block-wrapper">
                <?php if( isset( $order ) ) {
                    if ( $order == 'oldest' ) {
                        $yacht_order = 'ASC';
                    } else {
                        $yacht_order = 'DESC';
                    }
                }
                $args = array(
                    'post_type' => 'ycbe_boat',
                    'posts_per_page' => $posts_per_page,
                    'order' => $yacht_order
                );

                //$post_query = new WP_Query( $args );
                if( $post_query->have_posts() ) {
                    while( $post_query->have_posts() ) {
                        $post_query->the_post(); ?>
                        <div class="yacht-block">
                    <?php if( has_post_thumbnail() ) { ?>
                        <div class="yacht-block-image">
                            <?php $yacht_diff_days = yacht_diff_days( date( 'Y-m-d' ), get_the_time( 'Y-m-d' ) ); ?>
                            <?php if ( $yacht_diff_days < 20 ) { ?>
                                <div class="new-icon"><?php _e( 'New', 'yachtcharter' ); ?></div>
                            <?php }
                            $src = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'medium' ); ?>
                            <a href="<?php echo the_permalink(); ?>"><img src="<?php echo $src[0]; ?>" /></a>
                        </div>
                    <?php } ?>
                    <div class="yacht-block-content">
                        <h3><a href="<?php echo the_permalink(); ?>"><?php the_title(); ?></a></h3>
                        <?php  echo '<p class="element-excerpt">' .  get_the_excerpt( get_the_ID()) . '</p>' ; ?>
                        <div class="title-block5"></div>
                        <?php
                        $main_feature_1 = get_post_meta( get_the_ID(), '_ycbe_boat_capacity', true );
                        $main_feature_2 = get_post_meta( get_the_ID(), '_ycbe_price_from', true );
                        $main_feature_3 = get_the_excerpt( get_the_ID());
                        if( $main_feature_1 || $main_feature_2 || $main_feature_3 ) { ?>
                            <ul>
                                <?php

                                if( $main_feature_1 ) { echo '<li>' . '<span class="element-capacity">' .'Total Capacity: <strong>' . get_post_meta( get_the_ID(), '_ycbe_boat_capacity', true ) . '</strong></span>' .'</li>'; }
                                if( $main_feature_2 ) { echo '<li>' . '<span class="element-price-from">' .'Starting Price: <strong>$'. get_post_meta( get_the_ID(), '_ycbe_price_from', true ) . '</strong></span>' . '</li>'; }

                                ?>
                            </ul>
                        <?php }
                        $boatAddress =  "/boats/" . get_the_title();
                        $boatAddress = str_replace(" ","-", $boatAddress); ?>
                        <a class="seeMoreButton" href="<?php echo the_permalink(); ?>">See More</a>
                    </div>
                </div>
                    <?php }
                } ?>
            </div>
        </div>
    </div>

    <?php wp_reset_postdata();
    return ob_get_clean();

}

add_shortcode( 'boat_carousel', 'ycbe_boat_carousel_shortcode' ); ?>

任何忠告收到的人

谢谢

丹尼

1 个答案:

答案 0 :(得分:0)

错误非常简单:

  

注意:未定义的变量:列

根本没有SELECT CONCAT(IF(MAX(Dealer_Name) <> '', MAX(Dealer_Name), Dealer_ID), '*', Dealer_ID ) AS cc FROM received_invoices WHERE Customer_ID = 'CED130828MJ8' GROUP BY Dealer_ID ORDER BY cc ASC 变量。 (您没有将其放入摘录中)

column行也是重复的,您已经输入了两次。