I'm using the latest version of Wordpress and while writing a new post, i'm getting a following error in place of the optional boxes, located below the writing area:
Catchable fatal error: Object of class __PHP_Incomplete_Class could not be converted to string in /home/xxx/public_html/wp-content/themes/xxx/functions/meta-boxes.php on line 466
I've pasted a the problem code below taken from meta-boxes.php
Also, below, i've commented on the 466th line of code to let you know where the point if error is:
<?php
// get review-specific meta fields
global $oswcPostTypes;
$postTypeId = get_post_type( $post->ID );
$postType = $oswcPostTypes->get_type_by_id($postTypeId);
$meta_fields = $postType->meta_fields;
foreach($meta_fields as $meta){
//make backwards compatible
if(is_object($meta)){
$metaName = $meta->name;
}else{
$metaName = $meta;
}
$metaNameSafe = str_replace(" ","_",$metaName); // **466th line of error**
$theMeta = get_post_meta($post->ID, $metaName, $single = true); ?>
<p>
<label for="<?php echo $metaNameSafe; ?>"><?php echo $metaName; ?></label> </td>
<textarea class="widefat" id="<?php echo $metaNameSafe; ?>" name="<?php echo $metaNameSafe; ?>"><?php echo $theMeta; ?></textarea>
</p>
<?php