| 1 |
<?php |
| 2 |
|
| 3 |
namespace Elementor\Core\Isolation; |
| 4 |
|
| 5 |
use Elementor\Core\Settings\Manager; |
| 6 |
use Elementor\Core\Upgrade\Manager as Upgrade_Manager; |
| 7 |
|
| 8 |
class Wordpress_Adapter implements Wordpress_Adapter_Interface { |
| 9 |
|
| 10 |
public function get_plugins(): array { |
| 11 |
return get_plugins(); |
| 12 |
} |
| 13 |
|
| 14 |
public function is_plugin_active( $plugin_path ): bool { |
| 15 |
return is_plugin_active( $plugin_path ); |
| 16 |
} |
| 17 |
|
| 18 |
public function wp_nonce_url( $url, $action ): string { |
| 19 |
return wp_nonce_url( $url, $action ); |
| 20 |
} |
| 21 |
|
| 22 |
public function self_admin_url( $path ): string { |
| 23 |
return self_admin_url( $path ); |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* Retrieves an array of pages (or hierarchical post type items). |
| 28 |
* |
| 29 |
* @return WP_Post[]|false Array of pages (or hierarchical post type items). Boolean false if the |
| 30 |
* specified post type is not hierarchical or the specified status is not |
| 31 |
* supported by the post type. |
| 32 |
*/ |
| 33 |
public function get_pages( $args ): ?array { |
| 34 |
return get_pages( $args ); |
| 35 |
} |
| 36 |
|
| 37 |
/** |
| 38 |
* Creates and returns a wp query instance. |
| 39 |
* |
| 40 |
* @return \WP_Query |
| 41 |
*/ |
| 42 |
public function get_query( $args ): ?\WP_Query { |
| 43 |
return new \WP_Query( $args ); |
| 44 |
} |
| 45 |
|
| 46 |
public function get_option( $option_key ) { |
| 47 |
return get_option( $option_key ); |
| 48 |
} |
| 49 |
|
| 50 |
public function update_option( $option_key, $option_value ): void { |
| 51 |
update_option( $option_key, $option_value ); |
| 52 |
} |
| 53 |
|
| 54 |
public function add_option( $option_key, $option_value ): void { |
| 55 |
add_option( $option_key, $option_value ); |
| 56 |
} |
| 57 |
|
| 58 |
public function get_user_preferences( $preference_key ) { |
| 59 |
return Manager::get_settings_managers( 'editorPreferences' ) |
| 60 |
->get_model() |
| 61 |
->get_settings( $preference_key ); |
| 62 |
} |
| 63 |
|
| 64 |
public function set_user_preferences( $preference_key, $value ) { |
| 65 |
Manager::get_settings_managers( 'editorPreferences' ) |
| 66 |
->get_model() |
| 67 |
->set_settings( $preference_key, $value ); |
| 68 |
} |
| 69 |
|
| 70 |
public function is_new_installation() { |
| 71 |
return Upgrade_Manager::is_new_installation(); |
| 72 |
} |
| 73 |
|
| 74 |
public function add_query_arg( $args, $url ): string { |
| 75 |
return add_query_arg( $args, $url ); |
| 76 |
} |
| 77 |
|
| 78 |
public function has_custom_logo(): bool { |
| 79 |
return has_custom_logo(); |
| 80 |
} |
| 81 |
|
| 82 |
public function current_user_can( $capability, $args ): bool { |
| 83 |
return current_user_can( $capability, $args ); |
| 84 |
} |
| 85 |
|
| 86 |
public function get_post_status( $post_id ): string { |
| 87 |
return get_post_status( $post_id ); |
| 88 |
} |
| 89 |
|
| 90 |
public function get_posts( $args ): array { |
| 91 |
return get_posts( $args ); |
| 92 |
} |
| 93 |
|
| 94 |
public function get_post_types( $args = [], $output = 'names', $operator = 'and' ): array { |
| 95 |
return get_post_types( $args, $output, $operator ); |
| 96 |
} |
| 97 |
} |
| 98 |
|