PluginProbe ʕ •ᴥ•ʔ
AlphaListing / 4.3.6
AlphaListing v4.3.6
trunk 4.3.4 4.3.5 4.3.6 4.3.7 4.4.0
alphalisting / src / Shortcode / QueryParts / Taxonomy.php
alphalisting / src / Shortcode / QueryParts Last commit date
Alphabet.php 9 months ago ColumnGap.php 9 months ago ColumnWidth.php 9 months ago Columns.php 9 months ago ExcludePosts.php 9 months ago ExcludeTerms.php 9 months 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 9 months 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
Taxonomy.php
66 lines
1 <?php
2 /**
3 * Taxonomy 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 use \eslin87\AlphaListing\Strings;
18
19 /**
20 * Taxonomy Query Part extension
21 */
22 class Taxonomy extends Extension {
23 /**
24 * The attribute for this Query Part.
25 *
26 * @since 4.0.0
27 * @var string
28 */
29 public $attribute_name = 'taxonomy';
30
31 /**
32 * The types of listing this shortcode extension may be used with.
33 *
34 * @since 4.0.0
35 * @var array<string>
36 */
37 public $display_types = array( 'terms' );
38
39 /**
40 * Sanitize the shortcode attribute.
41 *
42 * @param string $value The value of the shortcode attribute.
43 * @param array $attributes The complete set of shortcode attributes.
44 * @return string The sanitized value.
45 */
46 public function sanitize_attribute( $value, array $attributes ) {
47 $value = trim( $value );
48 return $value ? $value : '';
49 }
50
51 /**
52 * Update the query with this extension's additional configuration.
53 *
54 * @param \AlphaListing\Query $query The query.
55 * @param string $display The display/query type.
56 * @param string $key The name of the attribute.
57 * @param mixed $value The shortcode attribute value.
58 * @param array $attributes The complete set of shortcode attributes.
59 * @return mixed The updated query.
60 */
61 public function shortcode_query_for_display_and_attribute( $query, string $display, string $key, $value, array $attributes ) {
62 $query['taxonomy'] = Strings::maybe_mb_split( ',', $value );
63 return $query;
64 }
65 }
66