• Resolved ayishaw

    (@ayishaw)


    Hey,

    This is probably going to be a strange thing to ask about but…I am using this plugin to capture testimonial-type reviews on a site I am working on, and have successfully followed the instructions here (https://pastebin.com/4fvKErcp) to add a custom text field, which is all working fine and displaying in the right places.

    The one thing that is bugging me is that in the Details metabox, my field label is all lowercase – which makes sense in that I named the field lowercase as seems to be the standard with the fields the plugin comes with when I look at them by enabling the custom fields metabox – and I would like it to be capitalised like the others. I have made the label capitalised and this works on the submission form itself, but not in the metabox.

    I am more comfortable with other languages but have very limited knowledge/experience with PHP … Google has informed me that PHP functions ucfirst() and ucwords() exist however I have no idea how I might apply them to the below part of the code, or if this is even the right place (or right thing to do!). Is this possible?

    add_filter('site-reviews/metabox/details', function ($metabox, $review) {
        $ratingKeys = ['personnel_rating', 'service_rating']; // change these as needed
        foreach ($review->custom as $key => $value) {
            if (in_array($key, $ratingKeys)) {
                $value = glsr_star_rating($value); // render the stars from the rating value
            }
            if (is_array($value)) {
                $value = implode(', ', $value);
            }
            $metabox[$key] = $value;
        }
        return $metabox;
    }, 10, 2);
    • This topic was modified 4 years, 10 months ago by ayishaw. Reason: grammar
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Details Metabox – custom field label’ is closed to new replies.