loop.php
70 lines
| 1 | <?php |
| 2 | |
| 3 | |
| 4 | use ElementorPro\Modules\ThemeBuilder\Module; |
| 5 | use ElementorPro\Core\Utils; |
| 6 | use ElementorPro\Modules\ThemeBuilder\Conditions\Post; |
| 7 | |
| 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 9 | exit; // Exit if accessed directly |
| 10 | } |
| 11 | |
| 12 | class ECS_Loop_Conditions extends ElementorPro\Modules\ThemeBuilder\Conditions\Condition_Base { |
| 13 | |
| 14 | protected $sub_conditions = [ |
| 15 | 'front_page', |
| 16 | ]; |
| 17 | |
| 18 | public static function get_type() { |
| 19 | return 'loop'; |
| 20 | } |
| 21 | |
| 22 | public function get_name() { |
| 23 | return 'loop'; |
| 24 | } |
| 25 | |
| 26 | public static function get_priority() { |
| 27 | return 60; |
| 28 | } |
| 29 | |
| 30 | public function get_label() { |
| 31 | return __( 'Loop', 'ele-custom-skin' ); |
| 32 | } |
| 33 | |
| 34 | public function get_all_label() { |
| 35 | return __( 'No Conditions', 'ele-custom-skin' ); |
| 36 | } |
| 37 | |
| 38 | public function register_sub_conditions() { |
| 39 | $post_types = Utils::get_public_post_types(); |
| 40 | |
| 41 | $post_types['attachment'] = get_post_type_object( 'attachment' )->label; |
| 42 | |
| 43 | foreach ( $post_types as $post_type => $label ) { |
| 44 | $condition = new Post( [ |
| 45 | 'post_type' => $post_type, |
| 46 | ] ); |
| 47 | |
| 48 | $this->register_sub_condition( $condition ); |
| 49 | } |
| 50 | |
| 51 | $this->sub_conditions[] = 'child_of'; |
| 52 | |
| 53 | $this->sub_conditions[] = 'any_child_of'; |
| 54 | |
| 55 | $this->sub_conditions[] = 'by_author'; |
| 56 | |
| 57 | // Last condition. |
| 58 | $this->sub_conditions[] = 'not_found404'; |
| 59 | } |
| 60 | |
| 61 | public function check( $args ) { |
| 62 | return false; |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | add_action( 'elementor/theme/register_conditions', function( $conditions_manager ) { |
| 67 | $conditions_manager->get_condition('general')->register_sub_condition( new ECS_Loop_Conditions() ); |
| 68 | |
| 69 | },100); |
| 70 |