| 1 |
<?php |
| 2 |
/** |
| 3 |
* Elementor document type for Loop Builder item templates. |
| 4 |
* |
| 5 |
* @package King_Addons |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace King_Addons\Loop_Builder; |
| 9 |
|
| 10 |
use Elementor\Core\DocumentTypes\Post; |
| 11 |
|
| 12 |
if (!defined('ABSPATH')) { |
| 13 |
exit; |
| 14 |
} |
| 15 |
|
| 16 |
/** |
| 17 |
* One repeated card, designed in Elementor and rendered per post by Loop Grid. |
| 18 |
*/ |
| 19 |
class Document extends Post |
| 20 |
{ |
| 21 |
/** |
| 22 |
* Meta key holding the post type a template was designed for. |
| 23 |
*/ |
| 24 |
public const META_SOURCE = 'ka_loop_source'; |
| 25 |
|
| 26 |
/** |
| 27 |
* Meta key holding the post used for the editor preview. |
| 28 |
*/ |
| 29 |
public const META_PREVIEW_ID = 'ka_loop_preview_id'; |
| 30 |
|
| 31 |
/** |
| 32 |
* Document type name. |
| 33 |
* |
| 34 |
* @return string |
| 35 |
*/ |
| 36 |
public static function get_type(): string |
| 37 |
{ |
| 38 |
return 'king-addons-loop-item'; |
| 39 |
} |
| 40 |
|
| 41 |
/** |
| 42 |
* Document type title. |
| 43 |
* |
| 44 |
* @return string |
| 45 |
*/ |
| 46 |
public static function get_title(): string |
| 47 |
{ |
| 48 |
return esc_html__('Loop Item', 'king-addons'); |
| 49 |
} |
| 50 |
|
| 51 |
/** |
| 52 |
* Document properties. |
| 53 |
* |
| 54 |
* @return array<string,mixed> |
| 55 |
*/ |
| 56 |
public static function get_properties(): array |
| 57 |
{ |
| 58 |
return array_merge(parent::get_properties(), [ |
| 59 |
'location' => 'king-addons-loop', |
| 60 |
'support_wp_page_templates' => false, |
| 61 |
'support_site_editor' => false, |
| 62 |
'has_elements' => true, |
| 63 |
'support_kit' => true, |
| 64 |
'cpt' => ['elementor_library'], |
| 65 |
]); |
| 66 |
} |
| 67 |
|
| 68 |
/** |
| 69 |
* Open the template straight in the editor from the library list. |
| 70 |
* |
| 71 |
* @return string |
| 72 |
*/ |
| 73 |
public function get_edit_url(): string |
| 74 |
{ |
| 75 |
$url = parent::get_edit_url(); |
| 76 |
|
| 77 |
if ($url) { |
| 78 |
$url = add_query_arg('action', 'elementor', $url); |
| 79 |
} |
| 80 |
|
| 81 |
return $url; |
| 82 |
} |
| 83 |
} |
| 84 |
|