PluginProbe ʕ •ᴥ•ʔ
AlphaListing / 4.4.0
AlphaListing v4.4.0
trunk 4.3.4 4.3.5 4.3.6 4.3.7 4.4.0
alphalisting / src / Shortcode / QueryParts / ParentPost.php
alphalisting / src / Shortcode / QueryParts Last commit date
Alphabet.php 1 month ago BackToTop.php 1 month ago ColumnGap.php 1 month ago ColumnWidth.php 1 month ago Columns.php 1 month ago ExcludePosts.php 1 month ago ExcludeTerms.php 1 month ago HideEmptyTerms.php 1 month ago HideEmpty_Deprecated.php 1 month ago InstanceId.php 1 month ago ParentPost.php 1 month ago ParentTermCommon.php 1 month ago ParentTermId.php 1 month ago ParentTermSlugOrId.php 1 month ago PostType.php 1 month ago PostsTerms.php 1 month ago SymbolsFirst.php 1 month ago Taxonomy.php 1 month ago TermsCommon.php 1 month ago TermsTerms.php 1 month ago
ParentPost.php
58 lines
1 <?php
2 /**
3 * Parent Post 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 Post Query Part extension
20 */
21 class ParentPost extends Extension {
22 /**
23 * The attribute for this Query Part.
24 *
25 * @since 4.0.0
26 * @var string
27 */
28 public $attribute_name = 'parent-post';
29
30 /**
31 * The types of listing this shortcode extension may be used with.
32 *
33 * @since 4.0.0
34 * @var array<string>
35 */
36 public $display_types = array( 'posts' );
37
38 /**
39 * Update the query with this extension's additional configuration.
40 *
41 * @param \AlphaListing\Query $query The query.
42 * @param string $display The display/query type.
43 * @param string $key The name of the attribute.
44 * @param mixed $value The shortcode attribute value.
45 * @param array $attributes The complete set of shortcode attributes.
46 * @return mixed The updated query.
47 */
48 public function shortcode_query_for_display_and_attribute( $query, string $display, string $key, $value, array $attributes ) {
49 if ( isset( $attributes['get-all-children'] ) && alphalisting_is_truthy( $attributes['get-all-children'] ) ) {
50 $query['child_of'] = $value;
51 } else {
52 $query['post_parent'] = $value;
53 }
54
55 return $query;
56 }
57 }
58