diff --git a/src/advanced-gutenberg.php b/src/advanced-gutenberg.php index 09b27d4e..49836272 100644 --- a/src/advanced-gutenberg.php +++ b/src/advanced-gutenberg.php @@ -3,8 +3,8 @@ * Plugin Name: PublishPress Blocks * Plugin URI: https://publishpress.com/blocks/ * Description: PublishPress Blocks has everything you need to build professional websites with the Gutenberg editor. - * Version: 3.1.4.2 - * Tested up to: 6.2 + * Version: 3.1.4.3 + * Tested up to: 6.2.2 * Author: PublishPress * Author URI: https://publishpress.com/ * License: GPL2 @@ -61,7 +61,7 @@ if (! defined('ADVANCED_GUTENBERG_LOADED')) { if (! defined('ADVANCED_GUTENBERG_VERSION')) { - define('ADVANCED_GUTENBERG_VERSION', '3.1.4.2'); + define('ADVANCED_GUTENBERG_VERSION', '3.1.4.3'); } if (! defined('ADVANCED_GUTENBERG_PLUGIN')) { diff --git a/src/assets/blocks/recent-posts/block.php b/src/assets/blocks/recent-posts/block.php index 4448bf72..6845b51a 100644 --- a/src/assets/blocks/recent-posts/block.php +++ b/src/assets/blocks/recent-posts/block.php @@ -1113,12 +1113,28 @@ function advgbGetImageCaption( $post ) { } /** - * Returns the Series order + * Returns the Series order for each post * * @return int */ function advgbGetSeriesOrder( $post ) { - return get_post_meta( $post['id'], '_series_part', true ); + + // Series 2.11.4+ meta_key now uses _series_part_${id} + if ( function_exists( 'publishpress_multi_series_supported' ) + && publishpress_multi_series_supported() ) { + + // Get the terms array from a post so later we can get the term id + $terms = wp_get_post_terms( $post['id'], 'series' ); + + if( count( $terms ) && $terms[0]->term_id ) { + return (int) get_post_meta( $post['id'], '_series_part_' . $terms[0]->term_id, true ); + } + } else { + // Series Pro 2.11.3- and Series Free 2.11.2- + return get_post_meta( $post['id'], '_series_part', true ); + } + + return null; } /** @@ -1288,9 +1304,23 @@ function advgbGetAuthorFilterREST( $args, $request ) { */ function advgbSetSeriesOrderREST( $args, $request ) { $orderby = esc_html( $request['orderby'] ); - if ( isset( $orderby ) && $orderby === 'series_order' ) { + + if ( isset( $orderby ) && $orderby === 'series_order' && isset( $request['series'] ) ) { $args['orderby'] = 'meta_value_num'; - $args['meta_key'] = '_series_part'; + + // Series 2.11.4+ meta_key now uses _series_part_${id} + if ( function_exists( 'publishpress_multi_series_supported' ) + && publishpress_multi_series_supported() ) { + + $ids = array_map( 'intval', $request['series'] ); + foreach( $ids as $id ) { + $args['meta_key'][] = '_series_part_' . $id; + } + } else { + // Series Pro 2.11.3- and Series Free 2.11.2- + $args['meta_key'] = '_series_part'; + } + } return $args; } @@ -1360,8 +1390,28 @@ function advgbSeriesOrderSort() { return $query; } $query->set('orderby', 'meta_value'); - $query->set('meta_key', '_series_part'); + // Series 2.11.4+ meta_key now uses _series_part_${id} + if ( function_exists( 'publishpress_multi_series_supported' ) + && publishpress_multi_series_supported() ) { + + // We get the terms titles. The same stored in block's taxonomies->series attribute + // @TODO - Store and use term ids instead as attributes + $terms = $query->query_vars['tax_query'][0]['terms']; + $metakeys = []; + if( count( $terms ) ) { + foreach( $terms as $term ) { + // Get the term object and then use the id to get the meta_key + $term_obj = get_term_by( 'name', $term, 'series' ); + $metakeys[] = '_series_part_' . (int) $term_obj->term_id; + } + $query->set( 'meta_key', $metakeys ); + } + } else { + // Series Pro 2.11.3- and Series Free 2.11.2- + $query->set( 'meta_key', '_series_part' ); + } + return $query; } ); } diff --git a/src/readme.txt b/src/readme.txt index 6c627490..faac4591 100644 --- a/src/readme.txt +++ b/src/readme.txt @@ -2,8 +2,8 @@ Contributors: publishpress, stevejburge, htmgarcia Tags: gutenberg, gutenberg blocks, gutenberg block, block editor, blocks, accordion block, gallery block, slider block, tabs block, maps block, block controls Requires at least: 5.0 -Tested up to: 6.2 -Stable tag: 3.1.4.2 +Tested up to: 6.2.2 +Stable tag: 3.1.4.3 Requires PHP: 7.2.5 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html @@ -270,6 +270,9 @@ Yes, we use the phrase "publishpress-advg-install" to share install links. You w == Changelog == += 3.1.4.3 - 15 May 2023 = + * Add: Support for new dynamic meta_key for Series in Content Display block + = 3.1.4.2 - 12 Apr 2023 = * Fix: Allowed block types for non-saved block types in post edit * Fix: Widget Group block type not saved as active