-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplugin.php
50 lines (46 loc) · 1.44 KB
/
plugin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
/**
* Plugin Name: Elementor Oembed Widget
* Description: This plugin adds Oembed widget to Elementor.
* Plugin URI: https://elementor.com/
* Version: 1.0.0
* Author: Bainternet
* Author URI: https://elementor.com/
* Text Domain: elementor-oembed-widget
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
/**
* elementor_oembed_widget_init
* Checks for elementor plugin loaded and includes the widget file
* @return void
*/
function elementor_oembed_widget_init(){
// Notice if the Elementor is not active
if ( ! did_action( 'elementor/loaded' ) ) {
add_action( 'admin_notices', 'eow_elementor_not_loaded' );
add_action( 'admin_init', 'eow_self_deactivate' );
return;
}
// Require the main plugin file
require( __DIR__ . '/widget-loader.php' );
}
add_action( 'plugins_loaded', 'elementor_oembed_widget_init');
/**
* eow_self_deactivate
* Deactivate this plugin if elementor is not installed and active.
* @return void
*/
function eow_self_deactivate(){
deactivate_plugins( plugin_basename( __FILE__ ) );
}
/**
* eow_elementor_not_loaded
* @return [type] [description]
*/
function eow_elementor_not_loaded(){
$message = __('This plugin requires you have Elementor installed and activated to work., the plugin was deactivated', 'elementor-oembed-widget');
echo '<div class="error">' . $message . '</div>';
if ( isset( $_GET['activate'] ) ){
unset( $_GET['activate'] );
}
}