File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,12 +17,15 @@ function elementor_dynamic_tags_register_tags( $dynamic_tags ) {
1717 require_once ( __DIR__ . "/menu.php " );
1818 require_once ( __DIR__ . "/list-pluck.php " );
1919 require_once ( __DIR__ . "/post-field.php " );
20+ require_once ( __DIR__ . "/post-type-label.php " );
2021
2122 $ dynamic_tags ->register ( new \Solid \ParentMeta () );
2223 $ dynamic_tags ->register ( new \Solid \ParentMetaImage () );
2324 $ dynamic_tags ->register ( new \Solid \CustomCallback () );
2425 $ dynamic_tags ->register ( new \Solid \Menu () );
2526 $ dynamic_tags ->register ( new \Solid \ListPluck () );
2627 $ dynamic_tags ->register ( new \Solid \PostField () );
28+ $ dynamic_tags ->register ( new \Solid \PostTypeLabel () );
29+
2730 }
2831}
Original file line number Diff line number Diff line change 1+ <?php
2+ namespace Solid ;
3+
4+ class PostTypeLabel extends \Elementor \Core \DynamicTags \Tag {
5+
6+ public function get_name () {
7+ return 'post-type-label ' ;
8+ }
9+
10+ public function get_categories () {
11+ return [
12+ \Elementor \Modules \DynamicTags \Module::TEXT_CATEGORY ,
13+ ];
14+ }
15+
16+ public function get_group () {
17+ return 'solid-dynamics ' ;
18+ }
19+
20+ public function get_title () {
21+ return __ ('Post Type Label ' , 'solid-dynamics ' );
22+ }
23+
24+ protected function _register_controls () {
25+ $ this ->add_control (
26+ 'label ' ,
27+ [
28+ 'label ' => __ ( 'Label ' , 'solid-dynamics ' ),
29+ 'type ' => \Elementor \Controls_Manager::SELECT ,
30+ 'default ' => 'singular ' ,
31+ 'options ' => [
32+ 'singular ' => __ ( 'Singular ' , 'solid-dynamics ' ),
33+ 'plural ' => __ ( 'Plural ' , 'solid-dynamics ' ),
34+ ],
35+ ]
36+ );
37+ }
38+
39+ public function render () {
40+ global $ post ;
41+ $ label = $ this ->get_settings ( 'label ' );
42+ $ post_type_object = get_post_type_object ($ post ->post_type );
43+
44+ if (!$ post_type_object ) {
45+ return ;
46+ }
47+
48+ switch ($ label ) {
49+ case 'singular ' :
50+ echo $ post_type_object ->labels ->singular_name ;
51+ break ;
52+ case 'plural ' :
53+ echo $ post_type_object ->labels ->name ;
54+ break ;
55+ }
56+ }
57+ }
You can’t perform that action at this time.
0 commit comments