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
InstanceId.php
62 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Instance ID 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 | * Instance ID Query Part extension |
| 20 | */ |
| 21 | class InstanceId extends Extension { |
| 22 | /** |
| 23 | * The attribute for this Query Part. |
| 24 | * |
| 25 | * @since 4.0.0 |
| 26 | * @var string |
| 27 | */ |
| 28 | public $attribute_name = 'instance-id'; |
| 29 | |
| 30 | /** |
| 31 | * The instance ID. |
| 32 | * |
| 33 | * @var string |
| 34 | */ |
| 35 | public $instance_id = ''; |
| 36 | |
| 37 | /** |
| 38 | * Update the query with this extension's additional configuration. |
| 39 | * |
| 40 | * @param \AlphaListing\Query $query The query. |
| 41 | * @param string $display The display/query type. |
| 42 | * @param string $key The name of the attribute. |
| 43 | * @param mixed $value The shortcode attribute value. |
| 44 | * @param array $attributes The complete set of shortcode attributes. |
| 45 | * @return mixed The updated query. |
| 46 | */ |
| 47 | public function shortcode_query( $query, string $display, string $key, $value, array $attributes ) { |
| 48 | $this->instance_id = $value; |
| 49 | $this->add_hook( 'filter', 'alphalisting_instance_id', array( $this, 'return_instance_id' ), 10, 1 ); |
| 50 | return $query; |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Return the ID for this instance. |
| 55 | * |
| 56 | * @return string |
| 57 | */ |
| 58 | public function return_instance_id(): string { |
| 59 | return $this->instance_id; |
| 60 | } |
| 61 | } |
| 62 |