Skip to content

WordPress get attachment image caption

I tried to get attachment meta caption value as mentioned here, but couldn`t get any output. Other meta arrays like [created_timestamp] or [iso] gave their values. This issue happens to both and [title]. Any help is much appreciated. Answer The caption and title you are looking to get from wp_get_attachment_m…

Sendgrid inbound email with PHP

I have configured a service for inbound email with record MX on Sendgrid. When receive email the callback URL has this function: and it work perfect, now i need to get the information from email, i have read the documentation: https://sendgrid.com/docs/API_Reference/Webhooks/parse.html and it say to use POST,…

preg_match accented characters

I have an issue using preg_match with php. I want my users to fill the Name field with only valid characters. Ex: no numbers or special chars. My site will eventually be bilingual but most of my visitors are french Canadians I prefer utf-8 for my encoding. So at the top of my document i have this tag : I

Determine if PHP files is Running as Part of a `phar` archive

Is there a way to determine, at runtime, if a PHP file is running as part of a phar archive? i.e., a native implementation might look something like this However, this might not work if the user has renamed the phar to have a different file extension, or symlinked the phar to remove the file extension. Answer…

Difference between EloquentModel::get() and all()

What is the difference between uses User::all() and User::get() on Eloquent? On Laravel API it describes only all() on EloquentModel.Maybe get() is described on EloquentBuilder. Answer User::all() and User::get() will do the exact same thing. all() is a static method on the EloquentModel. All it does is creat…

Correct way to add comments to a Regular Expression in PHP

I’m trying to add comments to make a regexp clearer But i get the warning Warning: preg_replace(): Unknown modifier ‘/’ in on line 280 How should i comment it? Answer This may not be the cleanest approach, but you could enclose each section in quotes and concatenate them. Something like this…