| @@ -1,11 +1,14 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace HelloPlus\Includes; |
| 3 | 3 | |
| 4 | 4 | if ( ! defined( 'ABSPATH' ) ) { |
| 5 | - exit; | |
| 5 | + exit; // Exit if accessed directly. | |
| 6 | 6 | } |
| 7 | 7 | |
| 8 | +/** | |
| 9 | + * class Utils | |
| 10 | + **/ | |
| 8 | 11 | class Utils { |
| 9 | 12 | |
| 10 | 13 | public static function elementor(): ?\Elementor\Plugin { |
| 11 | 14 | return class_exists( '\Elementor\Plugin' ) ? \Elementor\Plugin::instance() : null; |
| @@ -14,41 +17,10 @@ | ||
| 14 | 17 | public static function has_pro(): bool { |
| 15 | 18 | return defined( 'ELEMENTOR_PRO_VERSION' ); |
| 16 | 19 | } |
| 17 | 20 | |
| 18 | - public static function create_home_page(): int { | |
| 19 | - $page_data = [ | |
| 20 | - 'post_title' => __( 'Homepage', 'hello-plus' ), | |
| 21 | - 'post_content' => '', | |
| 22 | - 'post_status' => 'publish', | |
| 23 | - 'post_type' => 'page', | |
| 24 | - 'meta_input' => [ | |
| 25 | - '_elementor_edit_mode' => 'builder', | |
| 26 | - '_elementor_template_type' => 'wp-page', | |
| 27 | - ], | |
| 28 | - ]; | |
| 29 | - | |
| 30 | - $page_id = wp_insert_post( $page_data ); | |
| 31 | - | |
| 32 | - if ( is_wp_error( $page_id ) ) { | |
| 33 | - throw new \Exception( 'Failed to create Elementor page: ' . esc_html( $page_id->get_error_message() ) ); | |
| 34 | - } | |
| 35 | - | |
| 36 | - if ( ! $page_id ) { | |
| 37 | - throw new \Exception( 'Page creation returned invalid ID' ); | |
| 38 | - } | |
| 39 | - | |
| 40 | - update_option( 'page_on_front', $page_id ); | |
| 41 | - update_option( 'show_on_front', 'page' ); | |
| 42 | - | |
| 43 | - return $page_id; | |
| 44 | - } | |
| 45 | - | |
| 46 | 21 | public static function are_we_on_elementor_domains(): bool { |
| 47 | 22 | $current_domain = filter_input( INPUT_SERVER, 'HTTP_HOST', FILTER_SANITIZE_URL ); |
| 48 | - if ( null === $current_domain ) { | |
| 49 | - return false; | |
| 50 | - } | |
| 51 | 23 | $allowed_domains = [ |
| 52 | 24 | 'elementor.com', |
| 53 | 25 | 'elementor.red', |
| 54 | 26 | ]; |
| @@ -108,8 +80,9 @@ | ||
| 108 | 80 | } |
| 109 | 81 | |
| 110 | 82 | public static function get_update_elementor_message(): string { |
| 111 | 83 | return sprintf( |
| 84 | + /* translators: %s: Elementor version number. */ | |
| 112 | 85 | __( 'Elementor plugin version needs to be at least %s for Hello Plus to Work. Please update.', 'hello-plus' ), |
| 113 | 86 | HELLOPLUS_MIN_ELEMENTOR_VERSION, |
| 114 | 87 | ); |
| 115 | 88 | } |
| @@ -274,28 +247,6 @@ | ||
| 274 | 247 | return true; |
| 275 | 248 | } |
| 276 | 249 | |
| 277 | 250 | return false; |
| 278 | - } | |
| 279 | - | |
| 280 | - public static function has_at_least_one_kit() { | |
| 281 | - static $is_setup_wizard_completed = null; | |
| 282 | - | |
| 283 | - if ( ! class_exists( '\Elementor\App\Modules\ImportExport\Processes\Revert' ) ) { | |
| 284 | - return false; | |
| 285 | - } | |
| 286 | - | |
| 287 | - if ( ! is_null( $is_setup_wizard_completed ) ) { | |
| 288 | - return $is_setup_wizard_completed; | |
| 289 | - } | |
| 290 | - | |
| 291 | - $sessions = \Elementor\App\Modules\ImportExport\Processes\Revert::get_import_sessions(); | |
| 292 | - | |
| 293 | - if ( ! $sessions ) { | |
| 294 | - return false; | |
| 295 | - } | |
| 296 | - | |
| 297 | - $last_session = end( $sessions ); | |
| 298 | - | |
| 299 | - return ! empty( $last_session ); | |
| 300 | 251 | } |
| 301 | 252 | } |