Changeset 3145395
- Timestamp:
- 09/02/2024 01:41:51 PM (18 months ago)
- Location:
- dynamictags
- Files:
-
- 2 edited
-
tags/1.3.0/Lib/DynamicTags/PostType.php (modified) (3 diffs)
-
trunk/Lib/DynamicTags/PostType.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dynamictags/tags/1.3.0/Lib/DynamicTags/PostType.php
r3145303 r3145395 4 4 5 5 use DynamicTags\Lib\ElementBase; 6 use Elementor\Controls_Manager; 6 7 use Elementor\Core\DynamicTags\Tag; 7 8 use ElementorPro\Modules\DynamicTags\Module; … … 14 15 use ElementBase; 15 16 16 public function get_name() {17 public function get_name(): string { 17 18 return 'dynamic-tags-post-type'; 18 19 } 19 20 20 public function get_title() {21 public function get_title(): string { 21 22 return __( 'Post-Type', 'elementor-pro' ); 22 23 } 23 24 24 public function get_group() {25 public function get_group(): string { 25 26 return Module::POST_GROUP; 26 27 } 27 28 28 public function get_categories() {29 public function get_categories(): array { 29 30 return [ Module::TEXT_CATEGORY ]; 30 31 } 31 32 32 public function render() { 33 protected function register_controls(): void { 34 $this->add_control( 35 'format', 36 [ 37 'label' => __( 'Format', 'dynamic-tags' ), 38 'type' => Controls_Manager::SELECT, 39 'label_block' => true, 40 'default' => 'plain', 41 'options' => [ 42 'plain' => 'Plain', 43 'singular' => 'Singular', 44 'plural' => 'Plural', 45 ], 46 ] 47 ); 48 49 } 50 51 public function render(): void { 33 52 $post = get_post(); 34 53 … … 37 56 } 38 57 39 echo $post->post_type; 58 switch ( $this->get_settings('format')) { 59 case 'singular': 60 echo get_post_type_object($post->post_type)->labels->singular_name; 61 break; 62 case 'plural': 63 echo get_post_type_object($post->post_type)->labels->name; 64 break; 65 case'plain': 66 default: 67 echo $post->post_type; 68 break; 69 } 70 } 71 72 public function get_panel_template_setting_key(): string { 73 return 'format'; 40 74 } 41 75 } -
dynamictags/trunk/Lib/DynamicTags/PostType.php
r2509935 r3145395 4 4 5 5 use DynamicTags\Lib\ElementBase; 6 use Elementor\Controls_Manager; 6 7 use Elementor\Core\DynamicTags\Tag; 7 8 use ElementorPro\Modules\DynamicTags\Module; … … 14 15 use ElementBase; 15 16 16 public function get_name() {17 public function get_name(): string { 17 18 return 'dynamic-tags-post-type'; 18 19 } 19 20 20 public function get_title() {21 public function get_title(): string { 21 22 return __( 'Post-Type', 'elementor-pro' ); 22 23 } 23 24 24 public function get_group() {25 public function get_group(): string { 25 26 return Module::POST_GROUP; 26 27 } 27 28 28 public function get_categories() {29 public function get_categories(): array { 29 30 return [ Module::TEXT_CATEGORY ]; 30 31 } 31 32 32 public function render() { 33 protected function register_controls(): void { 34 $this->add_control( 35 'format', 36 [ 37 'label' => __( 'Format', 'dynamic-tags' ), 38 'type' => Controls_Manager::SELECT, 39 'label_block' => true, 40 'default' => 'plain', 41 'options' => [ 42 'plain' => 'Plain', 43 'singular' => 'Singular', 44 'plural' => 'Plural', 45 ], 46 ] 47 ); 48 49 } 50 51 public function render(): void { 33 52 $post = get_post(); 34 53 … … 37 56 } 38 57 39 echo $post->post_type; 58 switch ( $this->get_settings('format')) { 59 case 'singular': 60 echo get_post_type_object($post->post_type)->labels->singular_name; 61 break; 62 case 'plural': 63 echo get_post_type_object($post->post_type)->labels->name; 64 break; 65 case'plain': 66 default: 67 echo $post->post_type; 68 break; 69 } 70 } 71 72 public function get_panel_template_setting_key(): string { 73 return 'format'; 40 74 } 41 75 }
Note: See TracChangeset
for help on using the changeset viewer.