meta_value中的空参数

时间:2017-06-07 12:24:42

标签: php wordpress alert

我有一个选项,用户可以在其中添加警报消息,当页面被加载时,应该显示它。问题是警报显示,但是消息是用户写的消息,我不确定原因。

if( !empty( $postdata ) ) {
                foreach( $postdata as $dx_section ) {
                    var_dump( $dx_section );
                    foreach ( $dx_section->column_array as $value ) {
                        if ( $value->column_view == 'alert' && $value->column_indx == $id ) {
                            $column_data  = isset( $value->column_data ) ? $value->column_data : "";
                            $column_alert = isset( $value->column_alert ) ? $value->column_alert : "";

                            if ( $column_alert == 'On Page Load' ) {
                                if (isset( $column_data )) {
                                    echo '<script>alert( "' . $column_data . '" )</script>';
                                }
                            } else if ( isset( $value->column_alert_ids ) ) {
                                $id_array = explode( " ", $value->column_alert_ids );
                                echo '<script>';
                                foreach ( $id_array as $key ) {
                                    echo 'jQuery(document).ready(function($){
                                            $(document).find("#' . $key . '").click(function() {
                                                alert("' . $column_data . '");
                                            } );
                                    } );';
                                }
                                echo '</script>';
                            }
                        }
                    }
                }
        }

column_data为空,应该是消息。 这是转储的$ dx_section变量

object(stdClass)[258]
  public 'section_order' => int 1
  public 'section_name' => string 'First Section Name' (length=18)
  public 'section_classes' => string 'Section Classes' (length=15)
  public 'section_margin' => string '' (length=0)
  public 'section_padding' => string '' (length=0)
  public 'column_array' => 
    array (size=2)
      0 => 
        object(stdClass)[257]
          public 'row_class' => string '' (length=0)
          public 'column_name' => string 'Alert Window 1' (length=14)
          public 'column_size' => string '12' (length=2)
          public 'col_class' => string 'Column Classes' (length=14)
          public 'column_view' => string 'alert' (length=5)
          public 'column_indx' => int 1
          public 'column_alert' => string 'On Page Load' (length=12)
          public 'column_alert_ids' => string '' (length=0)
          public 'column_data' => string '' (length=0)
          public 'extension_data' => 
            object(stdClass)[595]
              ...
      1 => 
        object(stdClass)[596]
          public 'row_class' => string '' (length=0)
          public 'column_name' => string 'Custom Text' (length=11)
          public 'column_size' => string '12' (length=2)
          public 'col_class' => string 'Column Classes' (length=14)
          public 'column_view' => string 'custom_text' (length=11)
          public 'column_indx' => int 2
          public 'column_class' => string '' (length=0)
          public 'column_padding' => string '' (length=0)
          public 'column_padding_type' => string '' (length=0)
          public 'column_background' => string '' (length=0)
          public 'column_boder' => string '' (length=0)
          public 'column_data' => string '<p><strong>Custom data...</strong></p>
' (length=39)
          public 'extension_data' => 
            object(stdClass)[594]
              ...

0 个答案:

没有答案