PluginProbe
EleSpare – News, Magazine and Blog Addons for Elementor / 1.0.0
EleSpare – News, Magazine and Blog Addons for Elementor v1.0.0
trunk 1.0.0 2.0.0 3.1.1
elespare / elespare.php

elespare.php in EleSpare – News, Magazine and Blog Addons for Elementor 1.0.0, at elespare.php

271 lines 8.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Elespare - News Magazine and Blog Elements Addons for Elementor
4 *
5 * @package Elespare
6 *
7 * Plugin Name: Elespare
8 * Description: Free News Magazine and Blog Elements Addons for Elementor
9 * Plugin URI: https://afthemes.com/plugins/elespare/
10 * Version: 1.2.0
11 * Elementor tested up to: 3.10.0
12 * Elementor Pro tested up to: 3.3.1
13 * Author: Elespare
14 * Author URI: https://www.afthemes.com/plugins/elespare/
15 * Text Domain: elespare
16 */
17
18
19 if ( ! defined( 'ABSPATH' ) ) {
20 // Exit if accessed directly.
21 exit;
22 }
23 define( 'ELESPARE_VERSION', '1.2.0' );
24 define( 'ELESPARE', __FILE__ );
25 define( 'ELESPARE_DIR_PATH', plugin_dir_path( ELESPARE ) );
26 define( 'ELESPARE_DIR_URL', plugin_dir_url( ELESPARE ) );
27 defined( 'ELESPARE_SHOW_PRO_NOTICES' ) || define( 'ELESPARE_SHOW_PRO_NOTICES', true );
28
29 /**
30 * Main Elespare Class
31 *
32 * The init class that runs the Elementor Elespare plugin.
33 * Intended To make sure that the plugin's minimum requirements are met.
34 * You should only modify the constants to match your plugin's needs.
35 *
36 * Any custom code should go inside Plugin Class in the class-widgets.php file.
37 */
38 final class Elespare {
39
40 /**
41 * Plugin Version
42 *
43 * @since 1.0.0
44 * @var string The plugin version.
45 */
46 const VERSION = '1.1.6';
47
48 /**
49 * Minimum Elementor Version
50 *
51 * @since 1.0.0
52 * @var string Minimum Elementor version required to run the plugin.
53 */
54 const MINIMUM_ELEMENTOR_VERSION = '3.5.5';
55
56 /**
57 * Minimum PHP Version
58 *
59 * @since 1.0.0
60 * @var string Minimum PHP version required to run the plugin.
61 */
62 const MINIMUM_PHP_VERSION = '5.4';
63
64 /**
65 * Constructor
66 *
67 * @since 1.0.0
68 * @access public
69 */
70 public function __construct() {
71 // Load the translation.
72 add_action( 'init', array( $this, 'i18n' ) );
73
74 // Initialize the plugin.
75 add_action( 'plugins_loaded', array( $this, 'init' ) );
76
77 // Register widget style
78 add_action( 'elementor/frontend/after_enqueue_styles', [ $this, 'ElespareWidgetStyle' ] );
79
80 add_action( 'elementor/elements/categories_registered', [ $this, 'register_widget_category' ] );
81
82 add_action( 'activated_plugin', [ $this, 'elespare_activation_redirect' ] );
83 }
84
85 public function ElespareWidgetStyle()
86 {
87 wp_register_style( 'elespare-posts-grid', plugins_url( 'dist/elespare.style.build.min.css', ELESPARE ), array(), self::VERSION );
88 wp_enqueue_style( 'elespare-posts-grid' );
89 }
90
91 /**
92 * Load Textdomain
93 *
94 * Load plugin localization files.
95 * Fired by `init` action hook.
96 *
97 * @since 1.0.0
98 * @access public
99 */
100 public function i18n() {
101 load_plugin_textdomain( 'elespare' );
102 }
103
104 /**
105 * Initialize the plugin
106 *
107 * Validates that Elementor is already loaded.
108 * Checks for basic plugin requirements, if one check fail don't continue,
109 * if all check have passed include the plugin class.
110 *
111 * Fired by `plugins_loaded` action hook.
112 *
113 * @since 1.0.0
114 * @access public
115 */
116 public function init() {
117
118 add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'editor_enqueue' ] );
119
120 include_once ELESPARE_DIR_PATH .'inc/admin/class-admin-dashboard.php';
121
122 // Check if Elementor installed and activated.
123 if ( ! did_action( 'elementor/loaded' ) ) {
124 add_action( 'admin_notices', array( $this, 'admin_notice_missing_main_plugin' ) );
125 return;
126 }
127
128 // Check for required Elementor version.
129 if ( ! version_compare( ELEMENTOR_VERSION, self::MINIMUM_ELEMENTOR_VERSION, '>=' ) ) {
130 add_action( 'admin_notices', array( $this, 'admin_notice_minimum_elementor_version' ) );
131 return;
132 }
133
134 // Check for required PHP version.
135 if ( version_compare( PHP_VERSION, self::MINIMUM_PHP_VERSION, '<' ) ) {
136 add_action( 'admin_notices', array( $this, 'admin_notice_minimum_php_version' ) );
137 return;
138 }
139
140 // Once we get here, We have passed all validation checks so we can safely include our widgets.
141 require_once 'class-elespare.php';
142 include_once ELESPARE_DIR_PATH.'header-footer/init.php';
143 require(ELESPARE_DIR_PATH.'inc/functions.php');
144
145
146 }
147
148 /**
149 * Admin notice
150 *
151 * Warning when the site doesn't have Elementor installed or activated.
152 *
153 * @since 1.0.0
154 * @access public
155 */
156 public function admin_notice_missing_main_plugin() {
157 $view_demos = __( 'View Demos', 'elespare' );
158 $docs_support = __( 'Documentations', 'elespare' );
159 $contact_support = __( 'Need Help?', 'elespare' );
160 if ( file_exists( WP_PLUGIN_DIR . '/elementor/elementor.php' ) ) {
161 $notice_title = __( 'Activate Elementor', 'elespare' );
162 $notice_url = wp_nonce_url( 'plugins.php?action=activate&plugin=elementor/elementor.php&plugin_status=all&paged=1', 'activate-plugin_elementor/elementor.php' );
163 }else{
164 $notice_title = __( 'Install Elementor', 'elespare' );
165 $notice_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=elementor' ), 'install-plugin_elementor' );
166 }
167
168 $messages = sprintf(
169 /* translators: 1: Plugin name 2: Elementor */
170 esc_html__( '%3$s %1$s requires %2$s to be installed and activated to get the outstanding News,Magazine and Blog elements (widgets) and Header/Footer builder.%4$s %3$s %5$s %6$s %7$s %8$s %4$s', 'elespare' ),
171 '<strong>' . esc_html__( 'Elespare', 'elespare' ) . '</strong>',
172 '<strong>' . esc_html__( 'Elementor', 'elespare' ) . '</strong>',
173 '<p>',
174 '</p>',
175 '<a class="button-primary" href="' . esc_url( $notice_url ) . '">' . $notice_title . '</a>',
176 '<a class="button-secondary" target="_blank" href="' . esc_url( 'http://afthemes.com/plugins/elespare/' ) . '">' . $view_demos . '</a>',
177 '<a class="button-secondary" target="_blank" href="' . esc_url( 'https://afthemes.com/plugins/elespare/elespare-docs/' ) . '">' . $docs_support . '</a>',
178 '<a class="button-secondary" target="_blank" href="' . esc_url( 'http://afthemes.com/supports/' ) . '">' . $contact_support . '</a>'
179
180 );
181
182
183 printf( '<div class="notice notice-warning is-dismissible">%1$s</div>', $messages );
184 }
185
186 /**
187 * Admin notice
188 *
189 * Warning when the site doesn't have a minimum required Elementor version.
190 *
191 * @since 1.0.0
192 * @access public
193 */
194 public function admin_notice_minimum_elementor_version() {
195 // deactivate_plugins( plugin_basename( ELESPARE ) );
196
197 $ele_version = sprintf(
198 '<div class="notice notice-warning is-dismissible"><p><strong>"%1$s"</strong> requires <strong>"%2$s"</strong> version %3$s or greater.</p></div>',
199 'Elespare',
200 'Elementor',
201 self::MINIMUM_ELEMENTOR_VERSION
202 );
203
204 echo wp_kses($ele_version, array(
205 'div' => array(
206 'class' => array(),
207 'p' => array(),
208 'strong' => array(),
209 ),
210 ));
211 }
212
213 /**
214 * Admin notice
215 *
216 * Warning when the site doesn't have a minimum required PHP version.
217 *
218 * @since 1.0.0
219 * @access public
220 */
221 public function admin_notice_minimum_php_version() {
222 // deactivate_plugins( plugin_basename( ELESPARE ) );
223
224 $ele_php_version = sprintf(
225
226 '<div class="notice notice-warning is-dismissible"><p><strong>"%1$s"</strong> requires <strong>"%2$s"</strong> version %3$s or greater.</p></div>',
227 'Elespare',
228 'PHP',
229 self::MINIMUM_PHP_VERSION
230 );
231
232 echo wp_kses($ele_php_version, array(
233 'div' => array(
234 'class' => array(),
235 'p' => array(),
236 'strong' => array(),
237 ),
238 ));
239 }
240
241
242 public function register_widget_category( $elements_manager ) {
243
244 $elements_manager->add_category(
245 'elespare',
246 [
247 'title' => esc_html__( 'Elespare', 'elespare' ),
248 'icon' => 'fa fa-plug',
249 ]
250 );
251
252 }
253
254 function editor_enqueue(){
255 wp_enqueue_style(
256 'elespare-icons',
257 ELESPARE_DIR_URL . 'assets/font/elespare-icons.css',
258 null,
259 ELESPARE_VERSION
260 );
261 }
262
263 function elespare_activation_redirect($plugin){
264 if( $plugin == plugin_basename( ELESPARE ) ) {
265 exit( wp_redirect( add_query_arg(['page' => 'elespare_dashboard'], admin_url('admin.php') )));
266 }
267 }
268 }
269
270 // Instantiate Elespare.
271 new Elespare();