loop.php
88 lines
| 1 | <?php |
| 2 | namespace ElementorPro\Modules\ThemeBuilder\Documents; |
| 3 | use ElementorPro\Modules\ThemeBuilder\Documents\Single; |
| 4 | use ElementorPro\Modules\ThemeBuilder\Module; |
| 5 | |
| 6 | if ( ! defined( 'ABSPATH' ) ) { |
| 7 | exit; // Exit if accessed directly |
| 8 | } |
| 9 | |
| 10 | class Loop extends Single { |
| 11 | |
| 12 | public static function get_properties() { |
| 13 | $properties = parent::get_properties(); |
| 14 | |
| 15 | $properties['condition_type'] = 'loop'; |
| 16 | //$properties['location'] = 'archive'; |
| 17 | $properties['location'] = 'single'; |
| 18 | $properties['support_kit'] = true; |
| 19 | $properties['support_site_editor'] = true; |
| 20 | return $properties; |
| 21 | } |
| 22 | |
| 23 | protected static function get_site_editor_type() { |
| 24 | return 'loop'; |
| 25 | } |
| 26 | |
| 27 | public function get_name() { |
| 28 | return 'loop'; |
| 29 | } |
| 30 | |
| 31 | public static function get_type() { |
| 32 | return 'loop'; |
| 33 | } |
| 34 | |
| 35 | protected static function get_site_editor_thumbnail_url() { |
| 36 | return ELECS_URL . 'assets/images/loop.svg'; |
| 37 | } |
| 38 | |
| 39 | public static function get_title() { |
| 40 | return __( 'Loop', 'ele-custom-skin' ); |
| 41 | } |
| 42 | |
| 43 | /* |
| 44 | |
| 45 | Let's be undependable from Preview As options |
| 46 | |
| 47 | */ |
| 48 | public static function get_preview_as_options() { |
| 49 | $post_types = self::get_public_post_types();//Module::get_public_post_types(); |
| 50 | |
| 51 | $post_types['attachment'] = get_post_type_object( 'attachment' )->label; |
| 52 | $post_types_options = []; |
| 53 | |
| 54 | foreach ( $post_types as $post_type => $label ) { |
| 55 | $post_types_options[ 'single/' . $post_type ] = get_post_type_object( $post_type )->labels->singular_name; |
| 56 | } |
| 57 | |
| 58 | return [ |
| 59 | 'single' => [ |
| 60 | 'label' => __( 'Single', 'elementor-pro' ), |
| 61 | 'options' => $post_types_options, |
| 62 | ], |
| 63 | 'page/404' => __( '404', 'elementor-pro' ), |
| 64 | ]; |
| 65 | } |
| 66 | |
| 67 | public static function get_public_post_types(){ |
| 68 | //Array ( [post] => Posts [page] => Pages ) |
| 69 | $post_types_options = []; |
| 70 | $args = array( |
| 71 | 'public' => true, |
| 72 | ); |
| 73 | $output = 'objects'; // names or objects |
| 74 | $post_types = get_post_types( $args, $output ); |
| 75 | foreach ( $post_types as $post_type ) { |
| 76 | if ('elementor_library' != $post_type->name) $post_types_options[$post_type->name]= $post_type->label ; |
| 77 | } |
| 78 | return $post_types_options; |
| 79 | } |
| 80 | /* |
| 81 | |
| 82 | I want a preview like the template not default |
| 83 | |
| 84 | */ |
| 85 | |
| 86 | |
| 87 | } |
| 88 |