Alphabet.php
9 months ago
BackToTop.php
1 month ago
ColumnGap.php
1 month ago
ColumnWidth.php
1 month ago
Columns.php
1 month ago
ExcludePosts.php
9 months ago
ExcludeTerms.php
1 month ago
HideEmptyTerms.php
9 months ago
HideEmpty_Deprecated.php
9 months ago
InstanceId.php
9 months ago
ParentPost.php
9 months ago
ParentTermCommon.php
9 months ago
ParentTermId.php
9 months ago
ParentTermSlugOrId.php
9 months ago
PostType.php
1 month ago
PostsTerms.php
9 months ago
SymbolsFirst.php
9 months ago
Taxonomy.php
9 months ago
TermsCommon.php
9 months ago
TermsTerms.php
9 months ago
ParentTermId.php
48 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 | /** |
| 17 | * Parent Term ID implementation. |
| 18 | */ |
| 19 | class ParentTermId extends ParentTermCommon { |
| 20 | /** |
| 21 | * The attribute for this Query Part. |
| 22 | * |
| 23 | * @since 4.0.0 |
| 24 | * @var string |
| 25 | */ |
| 26 | public $attribute_name = 'parent-term-id'; |
| 27 | |
| 28 | /** |
| 29 | * Update the query with this extension's additional configuration. |
| 30 | * |
| 31 | * @param \AlphaListing\Query $query The query. |
| 32 | * @param string $display The display/query type. |
| 33 | * @param string $key The name of the attribute. |
| 34 | * @param mixed $value 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_for_display_and_attribute( $query, string $display, string $key, $value, array $attributes ) { |
| 39 | if ( is_numeric( $value ) ) { |
| 40 | $parent_id = intval( $value ); |
| 41 | } else { |
| 42 | $parent_id = -1; |
| 43 | } |
| 44 | |
| 45 | return $this->shortcode_query_with_parent_id( $query, $parent_id, $attributes ); |
| 46 | } |
| 47 | } |
| 48 |