Side projects are one of the most exciting things I’ve done since I started working full time. I started a lot of them! And I really mean it, a lot. I’m done with very, very few of them though ?♂️.
When you are working in the web field, it is always thrilling to discover new things, to practice new technologies, etc….
But you have to know how to curb your ambitions, otherwise, you quickly end up with a myriad of unfinished exciting projects.
I just published a new version of this WordPress plugin (the only side project I’ve been able to complete in the last six months ?). I had planned a few weeks ago to completely refactor its code, but it’s a pretty long job; so I decided to move forward step by step, and publish new versions as I go along.
So my little advice to myself today is:
You’re not going to create the best software/tool in the world in two days, Justin. Move forward little by little, and above all, SHIP IT. NOW!
On Saturday, September 21, 2019, the WordPress Meetup group of Cotonou held its second meeting. The topic of the day was WordPress new features in 2019.
I had the pleasure of hosting this meeting, and I share here the notes I took when I was preparing myself.
And the goal is to bump this minimum version to PHP 7+ by the beginning of next year
One of the major critics against WordPress was that it has been using for a long time older and sometimes not supported anymore versions of PHP.
Now, PHP 5.6 is the minimum requirement, and, while sites using lower versions of PHP will still receiving security updates, they won’t be able to upgrade to newer versions of WordPress.
This release focuses on polishing and improving Gutenberg’s performance. It also introduced Site Health, to help to have an overview of a site, and other information about WordPress and the server of a site.
Before 5.2, when an error occurs on a WordPress site, either because of a broken plugin or theme or because of a manipulation error on the dashboard, it leads to a « white screen of death » and one of the method to restore the site was to put the hand in server stuff.
With the new recovery mode, errors on the site will throw a screen notifying that the site is experiencing difficulties. And better, an email is sent to the site admin with a link to enter a recovery mode and fix the error.
Millions of peoples use WordPress in 200+ languages to create content, run their business, advertise, etc… WordPress Translation Day is dedicated to localizing the WordPress platform and its ecosystem and giving the voice to thousand of contributors who work to make WordPress accessible in theses languages.
WordCamps are the gathering for people of WordPress to exchange, contribute, discuss to the CMS, and also to party. WCEU 2019 was the biggest WordPress in history and was the place of great and major talks about WordPress.
One of the major projects from 2019 focuses is to expand the block editor beyond the content area and into other parts of the site. This included, so far, explorations to bring blocks into other screens within the dashboard as well as converting existing widgets into blocks.
The next major WordPress update is 5.3 and is targeted for November 12, 2019. It’ll introduce a new default theme, 2020.
The theme development will be lead by Ian Belanger, a sponsored WordPress Core Contributor by Bluehost. The design of the theme is inspired by Chaplin, a WordPress theme by Anders Norén, who will lead the design.
That’s all for WordPress new features in 2019 ?.
Want to have continuous updates about WordPress new features? Follow the project blog not to miss anything.
Last month, while I was working on a WordPress plugin, I needed to find and return in a readable format the extensions of the images uploaded to the media gallery (png, jpeg, etc…).
At the time, I thought about using the full paths of the images with their names and then extracting the extension with native PHP functions as substr() combined with explode(). I tried to implement the solution this way, but I realized that it was not the optimal method.
So I started searching the internet for a better solution, and it really wasn’t a pleasure. Among other things, I had trouble finding the right wording for my problem. Also, the solution approaches I found while browsing the forums, although some of them worked, were not all WordPress oriented. It must be said that when developing for WordPress, I always try to use the native features of the CMS, for more comfort.
A small search in the WordPress developer reference handbook then allowed me to discover a rather useful function that perfectly met my expectations.
It is called wp_check_filetype(), and was introduced in 2006 with version 2.0.4 of WordPress. Basically, the function takes as main parameter the name or path to the file (or the image in my case) and returns its type. Quite simple.
Here is a basic description of how I used it.
I first request a query to get the URL of the images uploaded with the function wp_get_attachment_url(). This step can be done in several other ways.
/**
* Retrieve all the medias uploaded in the media library
* with wp_get_attachment_url()
*
* @since 2.1.0
*
* @param (int) (Optional) Attachment post ID. Defaults to global $post.
*
* @link https://developer.wordpress.org/reference/functions/wp_get_attachment_url
*/
function co_retrieve_images() {
$query_images_args = array(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'post_status' => 'inherit',
'posts_per_page' => '-1',
);
$query_images = new WP_Query( $query_images_args );
foreach ( $query_images->posts as $image_info ) {
$co_medias_url_list[] = wp_get_attachment_url( $image_info->ID );
}
return $co_medias_url_list;
}
I then use the table of paths to the images that I pass one by one as a parameter to the wp_check_filetype() function.
/**
* Retrieve the extensions of medias uploaded in the media gallery
* using wp_check_filetype()
*
* @since 2.0.4
*
* @param (string) (Required) File name or path.
*
* @link https://developer.wordpress.org/reference/functions/wp_check_filetype
*/
function co_images_extensions() {
$medias_url_list = co_retrieve_images();
$single_image_extension = '';
$images_extension_list = [];
foreach ( $medias_url_list as $single_image_url ) {
$single_image_extension = wp_check_filetype( $single_image_url );
$images_extension_list[] = strtoupper( $single_image_extension['ext'] );
}
return $images_extension_list;
}
These examples are deliberately simplified and detailed to make the code more transparent. The complete source is available here.
Voila, now we have the extensions of our images that we can use as we please. For example, I encoded mine in JSON to generate graphs with FusionCharts.
Well, bye-bye ?. Have fun. And see you again soon.