PluginProbe ʕ •ᴥ•ʔ
AlphaListing / 4.3.4
AlphaListing v4.3.4
trunk 4.3.4 4.3.5 4.3.6 4.3.7 4.4.0
alphalisting / src / Shortcode / QueryParts / ParentTermCommon.php
alphalisting / src / Shortcode / QueryParts Last commit date
Alphabet.php 1 year ago ColumnGap.php 1 year ago ColumnWidth.php 1 year ago Columns.php 1 year ago ExcludePosts.php 1 year ago ExcludeTerms.php 1 year ago HideEmptyTerms.php 1 year ago HideEmpty_Deprecated.php 1 year ago InstanceId.php 1 year ago ParentPost.php 1 year ago ParentTermCommon.php 1 year ago ParentTermId.php 1 year ago ParentTermSlugOrId.php 1 year ago PostType.php 1 year ago PostsTerms.php 1 year ago SymbolsFirst.php 1 year ago Taxonomy.php 1 year ago TermsCommon.php 1 year ago TermsTerms.php 1 year ago
ParentTermCommon.php
58 lines
1 <?php
2 /**
3 * Parent Term Query Part.
4 *
5 * @package alphalisting
6 */
7
8 declare(strict_types=1);
9
10 namespace eslin87\AlphaListing\Shortcode\QueryParts;
11
12 if ( ! defined( 'ABSPATH' ) ) {
13 exit;
14 }
15
16 use \eslin87\AlphaListing\Shortcode\Extension;
17
18 /**
19 * Parent Term Common implementation.
20 */
21 abstract class ParentTermCommon extends Extension {
22 /**
23 * The types of listing this shortcode extension may be used with.
24 *
25 * @since 4.0.0
26 * @var array<string|int>
27 */
28 public $display_types = array( 'terms' );
29
30 /**
31 * Update the query with this extension's additional configuration.
32 *
33 * @param \AlphaListing\Query $query The query.
34 * @param int $parent_id The shortcode attribute value.
35 * @param array $attributes The complete set of shortcode attributes.
36 * @return mixed The updated query.
37 */
38 public function shortcode_query_with_parent_id( $query, int $parent_id, array $attributes ) {
39 if ( isset( $attributes['get-all-children'] ) && alphalisting_is_truthy( $attributes['get-all-children'] ) ) {
40 $parent_selector = 'child_of';
41 } else {
42 $parent_selector = 'parent';
43 }
44
45 if ( -1 < $parent_id ) {
46 $query = wp_parse_args(
47 $query,
48 array( $parent_selector => $parent_id )
49 );
50 }
51
52 return $query;
53 }
54 }
55
56
57
58