PluginProbe ʕ •ᴥ•ʔ
Shortcodes and extra features for Phlox theme / trunk
Shortcodes and extra features for Phlox theme vtrunk
2.17.21 2.17.20 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.6 1.0.9 1.1.0 1.3.0 1.3.1 1.3.10 1.3.14 1.3.2 1.3.3 1.3.6 1.4.0 1.4.1 1.4.2 1.5.0 1.5.2 1.6.0 1.6.2 1.6.4 1.7.0 1.7.2 2.10.0 2.10.1 2.10.3 2.10.5 2.10.7 2.10.8 2.10.9 2.11.0 2.11.1 2.11.2 2.12.0 2.14.0 2.15.0 2.15.2 2.15.4 2.15.5 2.15.6 2.15.7 2.15.8 2.15.9 2.16.0 2.16.1 2.16.2 2.16.3 2.16.4 2.17.0 2.17.1 2.17.12 2.17.13 2.17.14 2.17.15 2.17.16 2.17.2 2.17.3 2.17.4 2.17.5 2.17.6 2.17.8 2.17.9 2.4.12 2.4.13 2.4.14 2.4.16 2.4.18 2.4.19 2.4.9 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.14 2.5.15 2.5.16 2.5.17 2.5.19 2.5.2 2.5.20 2.5.3 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.10 2.6.12 2.6.13 2.6.14 2.6.15 2.6.16 2.6.17 2.6.19 2.6.2 2.6.20 2.6.4 2.6.5 2.6.7 2.7.0 2.7.1 2.7.10 2.7.11 2.7.12 2.7.13 2.7.14 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.9 2.9.0 2.9.12 2.9.14 2.9.15 2.9.16 2.9.17 2.9.18 2.9.19 2.9.2 2.9.20 2.9.21 2.9.22 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 2.9.8
auxin-elements / includes / elementor / modules / query-control / controls / group-control-related.php
auxin-elements / includes / elementor / modules / query-control / controls Last commit date
group-control-posts.php 2 years ago group-control-query.php 6 years ago group-control-related.php 6 years ago query.php 6 years ago
group-control-related.php
120 lines
1 <?php
2 namespace Auxin\Plugin\CoreElements\Elementor\Modules\QueryControl\Controls;
3
4 use Elementor\Controls_Manager;
5
6 if ( ! defined( 'ABSPATH' ) ) {
7 exit; // Exit if accessed directly
8 }
9
10 class Group_Control_Related extends Group_Control_Query {
11
12 public static function get_type() {
13 return 'aux-related-query';
14 }
15
16 /**
17 * Build the group-controls array
18 * Note: this method completely overrides any settings done in Group_Control_Posts
19 * @param string $name
20 *
21 * @return array
22 */
23 protected function init_fields_by_name( $name ) {
24 $fields = parent::init_fields_by_name( $name );
25
26 $tabs_wrapper = $name . '_query_args';
27 $include_wrapper = $name . '_query_include';
28
29 $fields['post_type']['options']['related'] = __( 'Related', 'auxin-elements' );
30 $fields['include_term_ids']['condition']['post_type!'][] = 'related';
31 $fields['related_taxonomies']['condition']['post_type'][] = 'related';
32 $fields['include_authors']['condition']['post_type!'][] = 'related';
33 $fields['exclude_authors']['condition']['post_type!'][] = 'related';
34 $fields['avoid_duplicates']['condition']['post_type!'][] = 'related';
35 $fields['offset']['condition']['post_type!'][] = 'related';
36
37 $related_taxonomies = [
38 'label' => __( 'Term', 'auxin-elements' ),
39 'type' => Controls_Manager::SELECT2,
40 'options' => $this->get_supported_taxonomies(),
41 'label_block' => true,
42 'multiple' => true,
43 'condition' => [
44 'include' => 'terms',
45 'post_type' => [
46 'related',
47 ],
48 ],
49 'tabs_wrapper' => $tabs_wrapper,
50 'inner_tab' => $include_wrapper,
51 ];
52
53 $related_fallback = [
54 'label' => __( 'Fallback', 'auxin-elements' ),
55 'type' => Controls_Manager::SELECT,
56 'options' => [
57 'fallback_none' => __( 'None', 'auxin-elements' ),
58 'fallback_by_id' => __( 'Manual Selection', 'auxin-elements' ),
59 'fallback_recent' => __( 'Recent Posts', 'auxin-elements' ),
60 ],
61 'default' => 'fallback_none',
62 'description' => __( 'Displayed if no relevant results are found. Manual selection display order is random', 'auxin-elements' ),
63 'condition' => [
64 'post_type' => 'related',
65 ],
66 'separator' => 'before',
67 ];
68
69 $fallback_ids = [
70 'label' => __( 'Search & Select', 'auxin-elements' ),
71 'type' => 'aux-query',
72 'post_type' => '',
73 'options' => [],
74 'label_block' => true,
75 'multiple' => true,
76 'filter_type' => 'by_id',
77 'condition' => [
78 'post_type' => 'related',
79 'related_fallback' => 'fallback_by_id',
80 ],
81 'export' => false,
82 ];
83
84 $fields = \Elementor\Utils::array_inject( $fields, 'include_term_ids', [ 'related_taxonomies' => $related_taxonomies ] );
85 $fields = \Elementor\Utils::array_inject( $fields, 'offset', [ 'related_fallback' => $related_fallback ] );
86 $fields = \Elementor\Utils::array_inject( $fields, 'related_fallback', [ 'fallback_ids' => $fallback_ids ] );
87
88 return $fields;
89 }
90
91 protected function get_supported_taxonomies() {
92 $supported_taxonomies = [];
93
94 $public_types = auxin_get_public_post_types();
95
96 foreach ( $public_types as $type => $title ) {
97 $taxonomies = get_object_taxonomies( $type, 'objects' );
98 foreach ( $taxonomies as $key => $tax ) {
99 if ( ! array_key_exists( $key, $supported_taxonomies ) ) {
100 $label = $tax->label;
101 if ( in_array( $tax->label, $supported_taxonomies ) ) {
102 $label = $tax->label . ' (' . $tax->name . ')';
103 }
104 $supported_taxonomies[ $key ] = $label;
105 }
106 }
107 }
108
109 return $supported_taxonomies;
110 }
111
112 protected static function init_presets() {
113 parent::init_presets();
114 static::$presets['related'] = [
115 'related_fallback',
116 'fallback_ids',
117 ];
118 }
119 }
120