Categories
WordPress

What’s new 🆕 in WordPress in 2019?

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.

WordPress in 2019
WordPress in 2019

I had the pleasure of hosting this meeting, and I share here the notes I took when I was preparing myself.

Privacy (GDPR) 🔒 – May 17, 2018

WordPress 4.9.6 was released in May 2018 and one of its focus was privacy.

From wordpress.org/news

To comply with the European Union’s General Data Protection Regulation, some privacy features were added to Core as:

  • Possibility to opt-in or out about the saving of personals info on posts comments
  • Sample of privacy police pages
  • Possibility for site owners to export and erase users data

WordPress 5.0 “Bebo” – December 6, 2018

One of the biggest changes in WordPress Core so far. This release introduced Gutenberg, the new block editor based on JavaScript with React.js.

Gutenberg changed the editing experience and received a warm welcome (as well as some controversies) from the community.

Related

  • Twenty Nineteen: a new default theme that is based on Gutenberg blocks
  • Classic editor: a plugin to disable the new editor, and continue using TinyMCE

PHP 5.6 as the minimum version supported by WordPress – December 8, 2018

And the goal is to bump this minimum version to PHP 7+ by the beginning of next year

From wordpress.org/news

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.

WordPress Governance Project – January 7, 2019

The WordPress Governance Project was introduced by Rachel Cherry and Morten Rand-Hendriksen.

The purpose of the project is to explore:

  • The governance of the WordPress open source project and its various community components, and
  • WordPress’ role in the governance of the open web including representation in forums where decisions about the web platform and the Internet are made.

WordPress 5.1 “Betty” 🎙️ – February 21, 2019

A Little Better Every Day

From wordpress.org/news

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.

One-third of the web 🎉 – March 15, 2019

WordPress reaches the bar of 33% of websites powered around March 2019 (according to W3Techs).

This part is still growing, and today, we’re approaching 35%.

From W3Techs

Better, the market share of WordPress among other content management systems is now > 61%

From W3Techs

WordPress 5.2 “Jaco” – May 7, 2019

From wordpress.org/news

This release was one of the most awaited of the year, as it introduced a lot of interesting features.

One of them is the Fatal Error Recovery mode.

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.

WordPress Translation Day 4 🌍 – May 11, 2019

From wordpress.org/stats

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.

WordCamp Europe 2019 – June 20-22, 2019

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.

First Asia WordCamp will take place in Bangkok, Thailand – February 21-23, 2020

From 2020.asia.wordcamp.org

WordPress 5.2.3 Security and Maintenance Release 🛡️ – September 5, 2019

WordPress 5.2.3 fixes 6 security issues, most were related to cross-scripting (XSS).

It also updated the jQuery version used in WordPress to 3.4.0.

Expanding Gutenberg, Content-Block Areas – September, 2019

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 step is the content area.

From make.wordpress.org/core

New default theme Twenty Twenty – September 6, 2019

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.

From joost.blog

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.

Categories
WordPress

How to retrieve the files type of WordPress media gallery files?

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.

Guys who overdo it on StackOverflow

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.

Images extensions chart WPMA

Well, bye-bye 🤗. Have fun. And see you again soon.

Featured image by Shahadat Shemul on Unsplash.