| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 4 |
register_activation_hook( __FILE__, 'wpestate_stream_elementor_activate_functionality_base' ); |
| 5 |
|
| 6 |
function wpestate_stream_elementor_activate_functionality_base(){ |
| 7 |
//update_option('elementor_container_width','1170'); |
| 8 |
update_option('elementor_space_between_widgets','10'); |
| 9 |
} |
| 10 |
|
| 11 |
final class WpStream_Elementor_Base { |
| 12 |
|
| 13 |
/** |
| 14 |
* Plugin Version |
| 15 |
* |
| 16 |
* @since 1.2.0 |
| 17 |
* @var string The plugin version. |
| 18 |
*/ |
| 19 |
const VERSION = '1.0.0'; |
| 20 |
|
| 21 |
/** |
| 22 |
* Minimum Elementor Version |
| 23 |
* |
| 24 |
* @since 1.2.0 |
| 25 |
* @var string Minimum Elementor version required to run the plugin. |
| 26 |
*/ |
| 27 |
const MINIMUM_ELEMENTOR_VERSION = '2.0.0'; |
| 28 |
|
| 29 |
/** |
| 30 |
* Minimum PHP Version |
| 31 |
* |
| 32 |
* @since 1.2.0 |
| 33 |
* @var string Minimum PHP version required to run the plugin. |
| 34 |
*/ |
| 35 |
const MINIMUM_PHP_VERSION = '7.0'; |
| 36 |
|
| 37 |
/** |
| 38 |
* Constructor |
| 39 |
* |
| 40 |
* @since 1.0.0 |
| 41 |
* @access public |
| 42 |
*/ |
| 43 |
public function __construct() { |
| 44 |
|
| 45 |
// Load translation |
| 46 |
add_action( 'init', array( $this, 'i18n' ) ); |
| 47 |
|
| 48 |
// Init Plugin |
| 49 |
add_action( 'plugins_loaded', array( $this, 'init' ) ); |
| 50 |
} |
| 51 |
|
| 52 |
/** |
| 53 |
* Load Textdomain |
| 54 |
* |
| 55 |
* Load plugin localization files. |
| 56 |
* Fired by `init` action hook. |
| 57 |
* |
| 58 |
* @since 1.2.0 |
| 59 |
* @access public |
| 60 |
*/ |
| 61 |
public function i18n() { |
| 62 |
load_plugin_textdomain( 'wpstream' ); |
| 63 |
} |
| 64 |
|
| 65 |
/** |
| 66 |
* Initialize the plugin |
| 67 |
* |
| 68 |
* Validates that Elementor is already loaded. |
| 69 |
* Checks for basic plugin requirements, if one check fail don't continue, |
| 70 |
* if all check have passed include the plugin class. |
| 71 |
* |
| 72 |
* Fired by `plugins_loaded` action hook. |
| 73 |
* |
| 74 |
* @since 1.2.0 |
| 75 |
* @access public |
| 76 |
*/ |
| 77 |
public function init() { |
| 78 |
|
| 79 |
// Check if Elementor installed and activated |
| 80 |
if ( ! did_action( 'elementor/loaded' ) ) { |
| 81 |
add_action( 'admin_notices', array( $this, 'admin_notice_missing_main_plugin' ) ); |
| 82 |
return; |
| 83 |
} |
| 84 |
|
| 85 |
// Check for required Elementor version |
| 86 |
if ( ! version_compare( ELEMENTOR_VERSION, self::MINIMUM_ELEMENTOR_VERSION, '>=' ) ) { |
| 87 |
add_action( 'admin_notices', array( $this, 'admin_notice_minimum_elementor_version' ) ); |
| 88 |
return; |
| 89 |
} |
| 90 |
|
| 91 |
// Check for required PHP version |
| 92 |
if ( version_compare( PHP_VERSION, self::MINIMUM_PHP_VERSION, '<' ) ) { |
| 93 |
add_action( 'admin_notices', array( $this, 'admin_notice_minimum_php_version' ) ); |
| 94 |
return; |
| 95 |
} |
| 96 |
|
| 97 |
// Once we get here, We have passed all validation checks so we can safely include our plugin |
| 98 |
require_once( 'wpstream-elementor-base.php' ); |
| 99 |
} |
| 100 |
|
| 101 |
/** |
| 102 |
* Admin notice |
| 103 |
* |
| 104 |
* Warning when the site doesn't have Elementor installed or activated. |
| 105 |
* |
| 106 |
* @since 1.0.0 |
| 107 |
* @access public |
| 108 |
*/ |
| 109 |
public function admin_notice_missing_main_plugin() { |
| 110 |
return; |
| 111 |
if ( isset( $_GET['activate'] ) ) { |
| 112 |
unset( $_GET['activate'] ); |
| 113 |
} |
| 114 |
|
| 115 |
$message = sprintf( |
| 116 |
/* translators: 1: Plugin name 2: Elementor */ |
| 117 |
esc_html__( '"%1$s" requires "%2$s" to be installed and activated.', 'wpstream' ), |
| 118 |
'<strong>' . esc_html__( 'WpStream Elementor', 'wpstream' ) . '</strong>', |
| 119 |
'<strong>' . esc_html__( 'Elementor', 'wpstream' ) . '</strong>' |
| 120 |
); |
| 121 |
|
| 122 |
printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message ); |
| 123 |
} |
| 124 |
|
| 125 |
/** |
| 126 |
* Admin notice |
| 127 |
* |
| 128 |
* Warning when the site doesn't have a minimum required Elementor version. |
| 129 |
* |
| 130 |
* @since 1.0.0 |
| 131 |
* @access public |
| 132 |
*/ |
| 133 |
public function admin_notice_minimum_elementor_version() { |
| 134 |
return; |
| 135 |
if ( isset( $_GET['activate'] ) ) { |
| 136 |
unset( $_GET['activate'] ); |
| 137 |
} |
| 138 |
|
| 139 |
$message = sprintf( |
| 140 |
/* translators: 1: Plugin name 2: Elementor 3: Required Elementor version */ |
| 141 |
esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'wpstream' ), |
| 142 |
'<strong>' . esc_html__( 'WpStream Elementor ', 'wpstream' ) . '</strong>', |
| 143 |
'<strong>' . esc_html__( 'Elementor', 'wpstream' ) . '</strong>', |
| 144 |
self::MINIMUM_ELEMENTOR_VERSION |
| 145 |
); |
| 146 |
|
| 147 |
printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message ); |
| 148 |
} |
| 149 |
|
| 150 |
/** |
| 151 |
* Admin notice |
| 152 |
* |
| 153 |
* Warning when the site doesn't have a minimum required PHP version. |
| 154 |
* |
| 155 |
* @since 1.0.0 |
| 156 |
* @access public |
| 157 |
*/ |
| 158 |
public function admin_notice_minimum_php_version() { |
| 159 |
return; |
| 160 |
if ( isset( $_GET['activate'] ) ) { |
| 161 |
unset( $_GET['activate'] ); |
| 162 |
} |
| 163 |
|
| 164 |
$message = sprintf( |
| 165 |
/* translators: 1: Plugin name 2: PHP 3: Required PHP version */ |
| 166 |
esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'wpstream' ), |
| 167 |
'<strong>' . esc_html__( 'WpStream Elementor', 'wpstream' ) . '</strong>', |
| 168 |
'<strong>' . esc_html__( 'PHP', 'wpstream' ) . '</strong>', |
| 169 |
self::MINIMUM_PHP_VERSION |
| 170 |
); |
| 171 |
|
| 172 |
printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message ); |
| 173 |
} |
| 174 |
} |
| 175 |
|
| 176 |
// Instantiate Wpstream elementor. |
| 177 |
new WpStream_Elementor_Base(); |