| 1 |
<?php |
| 2 |
|
| 3 |
namespace Elementor\Modules\GlobalClasses\Utils; |
| 4 |
|
| 5 |
use Elementor\Core\Base\Document; |
| 6 |
use Elementor\Core\Kits\Documents\Kit; |
| 7 |
use Elementor\Plugin; |
| 8 |
use Elementor\TemplateLibrary\Source_Local; |
| 9 |
|
| 10 |
if ( ! defined( 'ABSPATH' ) ) { |
| 11 |
exit; // Exit if accessed directly. |
| 12 |
} |
| 13 |
|
| 14 |
class Kit_Utils { |
| 15 |
/** |
| 16 |
* Returns all kit documents on the current site. |
| 17 |
* |
| 18 |
* @return Kit[] |
| 19 |
*/ |
| 20 |
public static function get_all_kit_documents(): array { |
| 21 |
$kit_ids = get_posts( [ |
| 22 |
'post_type' => Source_Local::CPT, |
| 23 |
'post_status' => 'any', |
| 24 |
'fields' => 'ids', |
| 25 |
'posts_per_page' => -1, |
| 26 |
'no_found_rows' => true, |
| 27 |
'update_post_meta_cache' => false, |
| 28 |
'meta_query' => [ |
| 29 |
[ |
| 30 |
'key' => Document::TYPE_META_KEY, |
| 31 |
'value' => 'kit', |
| 32 |
], |
| 33 |
], |
| 34 |
] ); |
| 35 |
|
| 36 |
$kits = []; |
| 37 |
|
| 38 |
foreach ( $kit_ids as $kit_id ) { |
| 39 |
$kit = Plugin::$instance->kits_manager->get_kit( $kit_id ); |
| 40 |
|
| 41 |
if ( $kit ) { |
| 42 |
$kits[] = $kit; |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
return $kits; |
| 47 |
} |
| 48 |
} |
| 49 |
|