PluginProbe ʕ •ᴥ•ʔ
Kubio AI Page Builder / 2.8.3
Kubio AI Page Builder v2.8.3
2.8.4 2.8.3 2.8.2 2.8.1 trunk 1.0.0 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.9.0 2.0.0 2.1.1 2.1.2 2.1.3 2.2.0 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.5 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.6.1 2.6.2 2.6.3 2.6.5 2.6.6 2.6.7 2.7.0 2.7.1 2.7.2 2.7.3 2.8.0
kubio / lib / integrations / image-hub / image-hub.php
kubio / lib / integrations / image-hub Last commit date
image-hub.php 9 months ago media-modal.js 1 year ago styles.css 1 year ago
image-hub.php
85 lines
1 <?php
2
3 use Kubio\PluginsManager;
4 use Kubio\Core\ThirdPartyPluginAssetLoaderInEditor;
5 use Kubio\Flags;
6
7 class KubioImageHubIntegration {
8 private static $PLUGIN_SLUG = 'image-hub';
9
10
11 public function __construct() {
12 ThirdPartyPluginAssetLoaderInEditor::addPlugin('image-hub', array($this, 'getIsPluginActive'), false);
13
14 // no need to show the modal if we already have the plugin or if not enabled yet
15 if ( $this->getIsPluginActive()) {
16 return;
17 }
18
19 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_media_library_scripts' ) );
20
21 add_action( 'wp_ajax_kubio-image-hub-install-plugin', array( $this, 'install_image_hub_plugin' ) );
22 add_filter( 'script_loader_tag', array( $this, 'add_module_attribute' ), 10, 2 );
23
24
25
26 }
27
28 public function getIsPluginActive() {
29 $plugin_manager = PluginsManager::getInstance();
30 return $plugin_manager->isPluginActive( self::$PLUGIN_SLUG );
31 }
32
33
34
35
36 public function enqueue_media_library_scripts() {
37
38 wp_enqueue_style(
39 'kubio-image-hub-integration-style',
40 plugin_dir_url( __FILE__ ) . 'styles.css',
41 array(),
42 filemtime( plugin_dir_path( __FILE__ ) . 'styles.css' )
43 );
44
45 wp_enqueue_script(
46 'kubio-image-hub-integration-media-modal',
47 plugin_dir_url( __FILE__ ) . 'media-modal.js',
48 array( 'wp-i18n', 'wp-components', 'wp-element', 'media-views', 'kubio-utils', 'wp-dom-ready' ),
49 filemtime( plugin_dir_path( __FILE__ ) . 'media-modal.js' ),
50 true
51 );
52
53 wp_enqueue_style( 'kubio-utils' );
54 wp_enqueue_style( 'wp-components' );
55 }
56
57
58 public function add_module_attribute( $tag, $handle ) {
59 if ( 'kubio-image-hub-integration-media-modal' === $handle ) {
60 return str_replace( 'src', 'type="module" src', $tag );
61 }
62 return $tag;
63 }
64
65
66 public function install_image_hub_plugin() {
67 check_ajax_referer( 'kubio_ajax_nonce' );
68 if(!current_user_can( 'install_plugins' )) {
69 wp_send_json_error('Not allowed');
70 }
71 $plugin_manager = PluginsManager::getInstance();
72 $plugin_manager->installPlugin( self::$PLUGIN_SLUG );
73 $plugin_manager->activatePlugin( self::$PLUGIN_SLUG, false );
74
75 wp_send_json_success( 'Plugin installed successfully' );
76 }
77
78
79 public static function init() {
80 new self();
81 }
82 }
83
84 KubioImageHubIntegration::init();
85