Home > database >  Trying to get property 'ID' of non-object (and) Undefined index: listing_type
Trying to get property 'ID' of non-object (and) Undefined index: listing_type

Time:05-10

Trying to get property 'ID' of non-object (and) Undefined index: listing_type

if (!file_exists($upload['basedir'].'/ulisting/css/'.$args['listing_type']->ID.'/'.$css_file_name.".css")) {
    $style_url = $upload['baseurl']."/ulisting/css/".$css_file_name.".css";
} else {
    $style_url = $upload['baseurl'].'/ulisting/css/'.$args['listing_type']->ID.'/'.$css_file_name.".css";
}

CodePudding user response:

Try to verify what is actually in $args. Make some simple dump above your lines of code

    var_dump($args);die;
if (!file_exists($upload['basedir'].'/ulisting/css/'.$args['listing_type']->ID.'/'.$css_file_name.".css")) {
    $style_url = $upload['baseurl']."/ulisting/css/".$css_file_name.".css";
} else {
    $style_url = $upload['baseurl'].'/ulisting/css/'.$args['listing_type']->ID.'/'.$css_file_name.".css";
}

CodePudding user response:

Not solved the full function is

=enter code herepublic static function kenter code here`render($sections, $css_file_name, $args) { $content = ""; $upload = wp_get_upload_dir();

    if (!file_exists($upload['basedir'].'/ulisting/css/'.$args['listing_type']->ID.'/'.$css_file_name.".css")) {
        $style_url = $upload['baseurl']."/ulisting/css/".$css_file_name.".css";
    } else {
        $style_url = $upload['baseurl'].'/ulisting/css/'.$args['listing_type']->ID.'/'.$css_file_name.".css";
    }
    wp_enqueue_style('ulisting_builder_stytle_'.$css_file_name, $style_url);

    if(is_array($sections) AND !empty($sections)){
        foreach ($sections as $section)
            $content .= StmListingTemplate::load_template('builder/section',['section' => $section, 'args' => $args]);
    }
    return $content;
}
  • Related