Image Processing Queue Transient Bug

Image Processing Queue Transient Bug

Prior to GP Premium 1.10.0, we used a library called Image Processing Queue to add on-the-fly image resizing for your featured images.

We were pretty happy with it until we started seeing some reports of databases getting lots of entries in the wp_options table related to the background process. When these 「jobs」 are initiated, something called a 「transient」 is added to your database to track the job. When the job is finished, the transient is cleaned up and that』s it. However, it seems like in some rare cases, those transients weren』t being cleaned up.

This isn』t something we』ve been able to reproduce on our end using multiple different servers/environments, which is a good thing, as it means it』s not something most people are affected by. However, it also makes it tricky to fix the problem, and even a few people being affected by this was enough for us to want to completely scrap the library and start over, so that』s what we did in 1.10.0.

Is this something you need to worry about? Definitely not. It』s not a security issue, and if you haven』t noticed any frontend issues, chances are the library is working just fine on your server.

If this issue has affected you, it』s still nothing to worry about. Simply update to GP Premium 1.10.0, then use a plugin like Transients Manager to delete your existing transients.

If you』d prefer a non-plugin method, you can search your database for the transients (inside your database manager):

SELECT * FROM wp_options WHERE option_name LIKE '%wp_image_processing%'

Then delete them:

DELETE FROM wp_options WHERE option_name LIKE '%wp_image_processing%'

Adding Image Sizes

Adding Image Sizes

As of GP Premium 1.10.0, we removed on-the-fly image sizing for featured images in our Blog module. WordPress itself has a hard time with this, and all of the available solutions have pretty significant downfalls.

By default, WordPress has a handful of image sizes to choose from:

full – the full sized imagelargemediumthumbnail

You can find these image sizes in Settings > Media.

It』s possible to create new image sizes specific to your site with a simple function. For example:

add_action( 'init', function() {
add_image_size( 'my-archive-featured-image', 500, 200, true ); // 500 width, 200 height, crop
} );

Learn more about the available parameters here.

You can add more than one size at once:

add_action( 'init', function() {
add_image_size( 'my-archive-featured-image', 500, 200, true ); // 500 width, 200 height, crop

add_image_size( 'my-single-featured-image', 800, 500 );
} );

Once you』ve added your image sizes, you can choose them from the 「Size」 dropdown in Customize > Layout > Blog.

The last thing you need to do is regenerate your thumbnails. WordPress doesn』t do this by default, so it』s necessary to use a plugin like this.

generate_category_list_output

generate_category_list_output

The generate_category_list_output filter controls the output of your categories as shown in your post meta along with your blog posts.

For example, we can use this PHP snippet to remove the link attached to the category output:

add_filter( 'generate_category_list_output', function() {
$categories = apply_filters( 'generate_show_categories', true );

$term_separator = apply_filters( 'generate_term_separator', _x( ', ', 'Used between list items, there is a space after the comma.', 'generatepress' ), 'categories' );
$categories_list = get_the_category_list( $term_separator );

return sprintf( '%3$s%1$s %2$s ', // WPCS: XSS ok, sanitization ok.
esc_html_x( 'Categories', 'Used before category names.', 'generatepress' ),
strip_tags( $categories_list ),
apply_filters( 'generate_inside_post_meta_item_output', '', 'categories' )
);
} );

Footer Bar Widget Area

Footer Bar Widget Area

You can add widgets into the footer bar, which is the area that holds your copyright message.
This can be super useful for adding things like menus or social icons.
Adding a footer menu
First, you want to create a new menu in Appearance > Menus that will be dedicated to your footer. You can learn how to that here.
Then, go to Appearance > Widgets and drag the Navigation Menu widget into the Footer Bar widget area.
Inside that widget, you can select your newly created menu.
Adding social icons
You can use a plugin like Lightweight Social Icons which adds a social icon widget to your site, or you can use a menu along with Font Awesome as explained in this article.
Footer Bar Alignment
By default, there』s 3 different position for the footer bar – left, center and right.
You can choose your alignment in Customize > Layout > Footer.

generate_footer_meta_post_types

generate_footer_meta_post_types

This filter allows you to tell the footer entry meta to display on your custom post types. By default, it only shows for the post post type.

add_filter( 'generate_footer_meta_post_types', function( $types ) {
$types[] = 'my-post-type';
$types[] = 'recipes';

return $types;
} );

Creating a Shortcode

Creating a Shortcode

The PHP snippet below provides an example to use [my_shortcode] to output text string of 「short code example」:

add_shortcode( 'my_shortcode', function() {
ob_start();
// Start your PHP below

echo 'short code example';

// End your PHP above
return ob_get_clean();
} );

generate_term_separator

generate_term_separator

The generate_term_separator filter allows change the default comma between each meta terms.

For example, we can use this snippet to change the separator to dash:

add_filter( 'generate_term_separator', function() {
return '-';
} );