Skip to content

Commit

Permalink
Merge pull request #1281 from publishpress/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
htmgarcia authored Jun 15, 2023
2 parents a372d96 + dfaf7f6 commit efe8f44
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/advanced-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')) {
Expand Down
60 changes: 55 additions & 5 deletions src/assets/blocks/recent-posts/block.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
} );
}
Expand Down
7 changes: 5 additions & 2 deletions src/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit efe8f44

Please sign in to comment.