PluginProbe ʕ •ᴥ•ʔ
AlphaListing / 4.3.4
AlphaListing v4.3.4
trunk 4.3.4 4.3.5 4.3.6 4.3.7 4.4.0
alphalisting / src / Shortcode / QueryParts / ColumnWidth.php
alphalisting / src / Shortcode / QueryParts Last commit date
Alphabet.php 1 year ago ColumnGap.php 1 year ago ColumnWidth.php 1 year ago Columns.php 1 year ago ExcludePosts.php 1 year ago ExcludeTerms.php 1 year ago HideEmptyTerms.php 1 year ago HideEmpty_Deprecated.php 1 year ago InstanceId.php 1 year ago ParentPost.php 1 year ago ParentTermCommon.php 1 year ago ParentTermId.php 1 year ago ParentTermSlugOrId.php 1 year ago PostType.php 1 year ago PostsTerms.php 1 year ago SymbolsFirst.php 1 year ago Taxonomy.php 1 year ago TermsCommon.php 1 year ago TermsTerms.php 1 year ago
ColumnWidth.php
65 lines
1 <?php
2 /**
3 * Alphabet 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 * Column Width Query Part extension
20 */
21 class ColumnWidth extends Extension {
22 /**
23 * The attribute for this Query Part.
24 *
25 * @since 4.0.0
26 * @var string
27 */
28 public $attribute_name = 'column-width';
29
30 /**
31 * The column width.
32 *
33 * @var string
34 */
35 public $column_width = '15em';
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->column_width = $value;
49 $this->add_hook( 'filter', 'alphalisting_styles', array( $this, 'return_styles' ), 10, 3 );
50 return $query;
51 }
52
53 /**
54 * Return the stylesheet for this instance.
55 *
56 * @param string $styles The stylesheet.
57 * @param \AlphaListing\Query $alphalisting The AlphaListing Query object.
58 * @param string $instance_id The instance ID.
59 * @return string
60 */
61 public function return_styles( $styles, $alphalisting, $instance_id ): string {
62 return "$styles --alphalisting-column-width: $this->column_width; ";
63 }
64 }
65