| @@ -4,37 +4,10 @@ | ||
| 4 | 4 | defined( 'ABSPATH' ) || exit; |
| 5 | 5 | |
| 6 | 6 | final class Borderless_Elementor { |
| 7 | 7 | |
| 8 | - /** | |
| 9 | - * Plugin Version | |
| 10 | - */ | |
| 11 | - const VERSION = '1.0.0'; | |
| 12 | - | |
| 13 | - /** | |
| 14 | - * Minimum Elementor Version | |
| 15 | - */ | |
| 16 | - const MINIMUM_ELEMENTOR_VERSION = '2.0.0'; | |
| 17 | - | |
| 18 | - /** | |
| 19 | - * Minimum PHP Version | |
| 20 | - */ | |
| 21 | - const MINIMUM_PHP_VERSION = '7.0'; | |
| 22 | - | |
| 23 | - /** | |
| 24 | - * Instance | |
| 25 | - * | |
| 26 | - * @var Borderless_Elementor The single instance of the class. | |
| 27 | - */ | |
| 28 | 8 | private static $_instance = null; |
| 29 | 9 | |
| 30 | - /** | |
| 31 | - * Instance | |
| 32 | - * | |
| 33 | - * Ensures only one instance of the class is loaded or can be loaded. | |
| 34 | - * | |
| 35 | - * @return Borderless_Elementor An instance of the class. | |
| 36 | - */ | |
| 37 | 10 | public static function instance() { |
| 38 | 11 | |
| 39 | 12 | if ( is_null( self::$_instance ) ) { |
| 40 | 13 | self::$_instance = new self(); |
| @@ -42,41 +15,14 @@ | ||
| 42 | 15 | return self::$_instance; |
| 43 | 16 | |
| 44 | 17 | } |
| 45 | 18 | |
| 46 | - /** | |
| 47 | - * Constructor | |
| 48 | - */ | |
| 49 | 19 | public function __construct() { |
| 50 | 20 | |
| 51 | 21 | add_action( 'plugins_loaded', [ $this, 'on_plugins_loaded' ] ); |
| 52 | 22 | |
| 53 | - require_once('assets.php'); | |
| 54 | - borderless_elementor_assets()->init(); | |
| 55 | - | |
| 56 | 23 | } |
| 57 | 24 | |
| 58 | - /** | |
| 59 | - * Load Textdomain | |
| 60 | - * | |
| 61 | - * Load plugin localization files. | |
| 62 | - * | |
| 63 | - * Fired by `init` action hook. | |
| 64 | - */ | |
| 65 | - public function i18n() { | |
| 66 | - | |
| 67 | - load_plugin_textdomain( 'borderless' ); | |
| 68 | - | |
| 69 | - } | |
| 70 | - | |
| 71 | - /** | |
| 72 | - * On Plugins Loaded | |
| 73 | - * | |
| 74 | - * Checks if Elementor has loaded, and performs some compatibility checks. | |
| 75 | - * If All checks pass, inits the plugin. | |
| 76 | - * | |
| 77 | - * Fired by `plugins_loaded` action hook. | |
| 78 | - */ | |
| 79 | 25 | public function on_plugins_loaded() { |
| 80 | 26 | |
| 81 | 27 | if ( $this->is_compatible() ) { |
| 82 | 28 | add_action( 'elementor/init', [ $this, 'init' ] ); |
| @@ -83,167 +29,61 @@ | ||
| 83 | 29 | } |
| 84 | 30 | |
| 85 | 31 | } |
| 86 | 32 | |
| 87 | - /** | |
| 88 | - * Compatibility Checks | |
| 89 | - * | |
| 90 | - * Checks if the installed version of Elementor meets the plugin's minimum requirement. | |
| 91 | - * Checks if the installed PHP version meets the plugin's minimum requirement. | |
| 92 | - */ | |
| 93 | 33 | public function is_compatible() { |
| 94 | 34 | |
| 95 | - // Check if Elementor installed and activated | |
| 96 | - if ( ! did_action( 'elementor/loaded' ) ) { | |
| 97 | - //add_action( 'admin_notices', [ $this, 'admin_notice_missing_main_plugin' ] ); | |
| 98 | - return false; | |
| 99 | - } | |
| 100 | - | |
| 101 | - // Check for required Elementor version | |
| 102 | - if ( ! version_compare( ELEMENTOR_VERSION, self::MINIMUM_ELEMENTOR_VERSION, '>=' ) ) { | |
| 103 | - add_action( 'admin_notices', [ $this, 'admin_notice_minimum_elementor_version' ] ); | |
| 104 | - return false; | |
| 105 | - } | |
| 106 | - | |
| 107 | - // Check for required PHP version | |
| 108 | - if ( version_compare( PHP_VERSION, self::MINIMUM_PHP_VERSION, '<' ) ) { | |
| 109 | - add_action( 'admin_notices', [ $this, 'admin_notice_minimum_php_version' ] ); | |
| 110 | - return false; | |
| 111 | - } | |
| 112 | - | |
| 113 | 35 | return true; |
| 114 | 36 | |
| 115 | 37 | } |
| 116 | 38 | |
| 117 | - /** | |
| 118 | - * Initialize the plugin | |
| 119 | - * | |
| 120 | - * Load the plugin only after Elementor (and other plugins) are loaded. | |
| 121 | - * Load the files required to run the plugin. | |
| 122 | - * | |
| 123 | - * Fired by `plugins_loaded` action hook. | |
| 124 | - */ | |
| 125 | 39 | public function init() { |
| 126 | - | |
| 127 | - $this->i18n(); | |
| 128 | 40 | |
| 41 | + wp_register_style( | |
| 42 | + 'font-awesome-5', | |
| 43 | + ELEMENTOR_ASSETS_URL . 'lib/font-awesome/css/all.min.css', | |
| 44 | + false, | |
| 45 | + BORDERLESS__VERSION | |
| 46 | + ); | |
| 47 | + | |
| 129 | 48 | // Add Plugin actions |
| 130 | 49 | add_action( 'elementor/widgets/widgets_registered', [ $this, 'init_widgets' ] ); |
| 131 | - add_action( 'elementor/elements/categories_registered', [ $this, 'register_borderless_elementor_category' ] ); | |
| 50 | + add_action( 'elementor/elements/categories_registered', [ $this, 'register_borderless_elementor_category' ] ); | |
| 132 | 51 | |
| 133 | 52 | } |
| 134 | 53 | |
| 135 | - /** | |
| 136 | - * Init Widgets | |
| 137 | - */ | |
| 138 | 54 | public function init_widgets() { |
| 139 | 55 | |
| 140 | 56 | // Include Widget files |
| 141 | 57 | require_once('helper.php'); |
| 142 | - require_once('widgets/animated-text.php'); | |
| 143 | 58 | require_once('widgets/circular-progress-bar.php'); |
| 144 | - require_once('widgets/contact-form-7.php'); | |
| 145 | - require_once('widgets/hero.php'); | |
| 146 | - require_once('widgets/info-box.php'); | |
| 59 | + require_once('widgets/contact-form-7.php'); | |
| 147 | 60 | require_once('widgets/marquee-text.php'); |
| 148 | - require_once('widgets/portfolio.php'); | |
| 149 | - require_once('widgets/pricing-table.php'); | |
| 150 | 61 | require_once('widgets/progress-bar.php'); |
| 151 | 62 | require_once('widgets/semi-circular-progress-bar.php'); |
| 152 | - require_once('widgets/slider.php'); | |
| 153 | - require_once('widgets/split-hero.php'); | |
| 154 | 63 | require_once('widgets/team-member.php'); |
| 155 | 64 | require_once('widgets/testimonial.php'); |
| 156 | 65 | |
| 157 | 66 | // Register widget |
| 158 | - \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Animated_Text() ); | |
| 159 | - \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Circular_Progress_Bar() ); | |
| 160 | - \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Contact_Form_7() ); | |
| 161 | - \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Hero() ); | |
| 162 | - \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Info_Box() ); | |
| 163 | - \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Marquee_text() ); | |
| 164 | - \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Portfolio() ); | |
| 165 | - \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Pricing_Table() ); | |
| 166 | - \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Progress_Bar() ); | |
| 167 | - \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Semi_Circular_Progress_Bar() ); | |
| 168 | - \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Slider() ); | |
| 169 | - \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Split_Hero() ); | |
| 170 | - \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Team_Member() ); | |
| 171 | - \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Testimonial() ); | |
| 67 | + \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Circular_Progress_Bar() ); | |
| 68 | + \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Contact_Form_7() ); | |
| 69 | + \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Marquee_text() ); | |
| 70 | + \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Progress_Bar() ); | |
| 71 | + \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Semi_Circular_Progress_Bar() ); | |
| 72 | + \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Team_Member() ); | |
| 73 | + \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Borderless\Widgets\Testimonial() ); | |
| 172 | 74 | |
| 173 | 75 | } |
| 174 | 76 | |
| 175 | - public function register_borderless_elementor_category( $elements_manager ) { | |
| 176 | - $elements_manager->add_category( | |
| 177 | - 'borderless', | |
| 178 | - [ | |
| 179 | - 'title' => __( 'Borderless', 'borderless' ), | |
| 180 | - 'icon' => 'borderless-icon-borderless', | |
| 181 | - ] | |
| 182 | - ); | |
| 183 | - } | |
| 184 | - | |
| 185 | - /** | |
| 186 | - * Admin notice | |
| 187 | - * | |
| 188 | - * Warning when the site doesn't have Elementor installed or activated. | |
| 189 | - */ | |
| 190 | - public function admin_notice_missing_main_plugin() { | |
| 191 | - | |
| 192 | - if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] ); | |
| 193 | - | |
| 194 | - $message = sprintf( | |
| 195 | - /* translators: 1: Plugin name 2: Elementor */ | |
| 196 | - esc_html__( '"%1$s" requires "%2$s" to be installed and activated.', 'borderless' ), | |
| 197 | - '<strong>' . esc_html__( 'Borderless', 'borderless' ) . '</strong>', | |
| 198 | - '<strong>' . esc_html__( 'Elementor', 'borderless' ) . '</strong>' | |
| 77 | + public function register_borderless_elementor_category( $elements_manager ) { | |
| 78 | + $elements_manager->add_category( | |
| 79 | + 'borderless', | |
| 80 | + [ | |
| 81 | + 'title' => __( 'Borderless', 'borderless' ), | |
| 82 | + 'icon' => 'fa fa-plug', | |
| 83 | + ] | |
| 199 | 84 | ); |
| 200 | - | |
| 201 | - printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message ); | |
| 202 | - | |
| 203 | 85 | } |
| 204 | 86 | |
| 205 | - /** | |
| 206 | - * Admin notice | |
| 207 | - * | |
| 208 | - * Warning when the site doesn't have a minimum required Elementor version. | |
| 209 | - */ | |
| 210 | - public function admin_notice_minimum_elementor_version() { | |
| 211 | - | |
| 212 | - if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] ); | |
| 213 | - | |
| 214 | - $message = sprintf( | |
| 215 | - /* translators: 1: Plugin name 2: Elementor 3: Required Elementor version */ | |
| 216 | - esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'borderless' ), | |
| 217 | - '<strong>' . esc_html__( 'Elementor Test Extension', 'borderless' ) . '</strong>', | |
| 218 | - '<strong>' . esc_html__( 'Elementor', 'borderless' ) . '</strong>', | |
| 219 | - self::MINIMUM_ELEMENTOR_VERSION | |
| 220 | - ); | |
| 221 | - | |
| 222 | - printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message ); | |
| 223 | - | |
| 224 | - } | |
| 225 | - | |
| 226 | - /** | |
| 227 | - * Admin notice | |
| 228 | - * | |
| 229 | - * Warning when the site doesn't have a minimum required PHP version. | |
| 230 | - */ | |
| 231 | - public function admin_notice_minimum_php_version() { | |
| 232 | - | |
| 233 | - if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] ); | |
| 234 | - | |
| 235 | - $message = sprintf( | |
| 236 | - /* translators: 1: Plugin name 2: PHP 3: Required PHP version */ | |
| 237 | - esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'borderless' ), | |
| 238 | - '<strong>' . esc_html__( 'Elementor Test Extension', 'borderless' ) . '</strong>', | |
| 239 | - '<strong>' . esc_html__( 'PHP', 'borderless' ) . '</strong>', | |
| 240 | - self::MINIMUM_PHP_VERSION | |
| 241 | - ); | |
| 242 | - | |
| 243 | - printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message ); | |
| 244 | - | |
| 245 | - } | |
| 246 | - | |
| 247 | 87 | } |
| 248 | 88 | |
| 249 | -Borderless_Elementor::instance(); | |
| 89 | +Borderless_Elementor::instance(); | |