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 / Taxonomy.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
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