admin
1 year ago
app
2 years ago
base
1 year ago
behaviors
3 years ago
breakpoints
2 years ago
common
1 year ago
debug
1 year ago
document-types
1 year ago
dynamic-tags
1 year ago
editor
1 year ago
experiments
1 year ago
files
1 year ago
frontend
1 year ago
isolation
1 year ago
kits
1 year ago
logger
2 years ago
page-assets
1 year ago
responsive
2 years ago
role-manager
2 years ago
settings
1 year ago
upgrade
1 year ago
utils
1 year ago
documents-manager.php
1 year ago
modules-manager.php
1 year ago
wp-api.php
1 year ago
wp-api.php
69 lines
| 1 | <?php |
| 2 | namespace Elementor\Core; |
| 3 | |
| 4 | use Elementor\Core\Utils\Collection; |
| 5 | |
| 6 | if ( ! defined( 'ABSPATH' ) ) { |
| 7 | exit; // Exit if accessed directly. |
| 8 | } |
| 9 | |
| 10 | /** |
| 11 | * This class is responsible for the interaction with WordPress Core API. |
| 12 | * The main benefit is making it easy to mock in testing |
| 13 | * and it can help to create unit tests without the hustle of mocking WordPress itself. |
| 14 | */ |
| 15 | class Wp_Api { |
| 16 | /** |
| 17 | * @var Collection |
| 18 | */ |
| 19 | private $plugins; |
| 20 | |
| 21 | /** |
| 22 | * @return Collection |
| 23 | */ |
| 24 | public function get_plugins() { |
| 25 | if ( ! function_exists( 'get_plugins' ) ) { |
| 26 | require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 27 | } |
| 28 | |
| 29 | if ( ! $this->plugins ) { |
| 30 | $this->plugins = new Collection( get_plugins() ); |
| 31 | } |
| 32 | |
| 33 | return $this->plugins; |
| 34 | } |
| 35 | |
| 36 | /** |
| 37 | * @return Collection |
| 38 | */ |
| 39 | public function get_active_plugins() { |
| 40 | return $this->get_plugins() |
| 41 | ->only( get_option( 'active_plugins' ) ); |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * @return object|array |
| 46 | */ |
| 47 | public function plugins_api( $action, $args ) { |
| 48 | return plugins_api( $action, $args ); |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * @return bool |
| 53 | */ |
| 54 | public function is_plugin_active( $plugin ) { |
| 55 | return is_plugin_active( $plugin ); |
| 56 | } |
| 57 | |
| 58 | /** |
| 59 | * @return bool|int|null|true |
| 60 | */ |
| 61 | public function activate_plugin( $plugin ) { |
| 62 | return activate_plugin( $plugin ); |
| 63 | } |
| 64 | |
| 65 | public function wp_attachment_is_image( $post = null ) { |
| 66 | return wp_attachment_is_image( $post ); |
| 67 | } |
| 68 | } |
| 69 |