loop-item.php
141 lines
| 1 | <?php |
| 2 | if ( ! defined( 'ABSPATH' ) ) { |
| 3 | exit; // Exit if accessed directly |
| 4 | } |
| 5 | |
| 6 | class Ele_Custom_Loop_Item_Widget extends \Elementor\Widget_Base { |
| 7 | |
| 8 | /** |
| 9 | * Get widget name. |
| 10 | * |
| 11 | * Retrieve Term List widget name. |
| 12 | * |
| 13 | * @since 0.1 |
| 14 | * @access public |
| 15 | * |
| 16 | * @return string Widget name. |
| 17 | */ |
| 18 | public function get_name() { |
| 19 | return 'ele-loop-item'; |
| 20 | } |
| 21 | |
| 22 | /** |
| 23 | * Get widget title. |
| 24 | * |
| 25 | * Retrieve Term List widget title. |
| 26 | * |
| 27 | * @since 0.1 |
| 28 | * @access public |
| 29 | * |
| 30 | * @return string Widget title. |
| 31 | */ |
| 32 | public function get_title() { |
| 33 | return __( 'Loop Item', 'ele-custom-skin' ); |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * Get widget icon. |
| 38 | * |
| 39 | * Retrieve Term List widget icon. |
| 40 | * |
| 41 | * @since 0.1 |
| 42 | * @access public |
| 43 | * |
| 44 | * @return string Widget icon. |
| 45 | */ |
| 46 | public function get_icon() { |
| 47 | return 'eicon-info-box'; |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Get widget categories. |
| 52 | * |
| 53 | * Retrieve the list of categories the Term List widget belongs to. |
| 54 | * |
| 55 | * @since 0.1 |
| 56 | * @access public |
| 57 | * |
| 58 | * @return array Widget categories. |
| 59 | */ |
| 60 | public function get_categories() { |
| 61 | return [ 'ele-custom-grid']; |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Register Term List widget controls. |
| 66 | * |
| 67 | * Adds different input fields to allow the user to change and customize the widget settings. |
| 68 | * |
| 69 | * @since 0.1 |
| 70 | * @access protected |
| 71 | */ |
| 72 | protected function register_controls() { |
| 73 | |
| 74 | $this->start_controls_section( |
| 75 | 'content_section', |
| 76 | [ |
| 77 | 'label' => __( 'Content', 'ele-term-list' ), |
| 78 | 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, |
| 79 | ] |
| 80 | ); |
| 81 | |
| 82 | $this->add_control( |
| 83 | 'important_note', |
| 84 | [ |
| 85 | 'label' => __( 'Loop Item Place Holder', 'ele-term-list' ), |
| 86 | 'type' => \Elementor\Controls_Manager::RAW_HTML, |
| 87 | 'raw' => __( 'Place this widget where the Loop Item you want to show in Ele Custom Skin.', 'ele-term-list' ), |
| 88 | 'content_classes' => 'your-class', |
| 89 | 'selector'=>'{{wrapper}} .ecs-loop-preview' |
| 90 | ] |
| 91 | ); |
| 92 | |
| 93 | |
| 94 | $this->end_controls_section(); |
| 95 | |
| 96 | |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * Render Term List widget output on the frontend. |
| 101 | * |
| 102 | * Written in PHP and used to generate the final HTML. |
| 103 | * |
| 104 | * @since 0.1 |
| 105 | * @access protected |
| 106 | */ |
| 107 | protected function render() { |
| 108 | |
| 109 | if ( $this->show_nice() ) { |
| 110 | $this->content_template(); |
| 111 | } else { |
| 112 | echo "{{ecs-article}}"; |
| 113 | } |
| 114 | |
| 115 | } |
| 116 | |
| 117 | protected function show_nice(){ |
| 118 | $is_preview=false; |
| 119 | $document = elecs_get_document( get_the_ID() ); |
| 120 | //print_r ( $document->get_type()); |
| 121 | if($document) if('custom_grid' == $document->get_type()){ |
| 122 | if (isset($_GET['action'])) $is_preview = $_GET['action'] == 'elementor' ? true : false; |
| 123 | } |
| 124 | return $is_preview; |
| 125 | } |
| 126 | |
| 127 | protected function content_template() { |
| 128 | |
| 129 | ?> |
| 130 | <div class="ecs-loop-preview"> |
| 131 | <div class="ecs-image-holder">=^_^=</div> |
| 132 | <h3> |
| 133 | Lorem Ipsum |
| 134 | </h3> |
| 135 | <span>Nunc vos habere ultimum potentiae, ad excogitandum vestri malesuada euismod. Liber esto atque exprimere te.</span> |
| 136 | </div> |
| 137 | <?php |
| 138 | } |
| 139 | |
| 140 | } |
| 141 |