File: /var/www/Application/wp-content/plugins/zoomy-core/zoomy-core.php
<?php
/**
* Plugin Name: Zoomy Core
* Plugin URI: https://themeforest.net/user/creativegigs/portfolio
* Description: This plugin adds the core features to the Zoomy WordPress theme. You must have to install this plugin to get all the features included with the Zoomy theme.
* Version: 1.0.3
* Author: Spider Themes
* Author URI: https://themeforest.net/user/creativegigs/portfolio
* Text domain: zoomy-core
*/
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
// Zoomy Core Directories
define( 'SC_IMAGES', plugins_url( 'widgets/images/', __FILE__ ) );
define( 'ZOOMY_PATH', plugin_dir_path( __FILE__ ) );
define( 'ZOOMY_URL', plugin_dir_url( __FILE__ ) );
// Make sure the same class is not loaded twice in free/premium versions.
if ( ! class_exists( 'Zoomy_core' ) ) {
/**
* Main Zoomy Core Class
*
* The main class that initiates and runs the Zoomy Core plugin.
*/
class Zoomy_core {
/**
* Zoomy Core Version
*
* Holds the version of the plugin.
*
* @var string The plugin version.
*/
const VERSION = '1.0';
/**
* Minimum Elementor Version
*
* Holds the minimum Elementor version required to run the plugin.
*
* @var string Minimum Elementor version required to run the plugin.
*/
const MINIMUM_ELEMENTOR_VERSION = '2.6.0';
/**
* Minimum PHP Version
*
* Holds the minimum PHP version required to run the plugin.
*
* @var string Minimum PHP version required to run the plugin.
*/
const MINIMUM_PHP_VERSION = '5.4';
/**
* Plugin's directory paths
* @since 1.0
*/
const CSS = null;
const JS = null;
const IMG = null;
const VEND = null;
/**
* Instance
*
* Holds a single instance of the `Zoomy_Core` class.
*
* @access private
* @static
*
* @var Zoomy_Core A single instance of the class.
*/
private static $_instance = null;
/**
* Instance
*
* Ensures only one instance of the class is loaded or can be loaded.
*
* @access public
* @static
*
* @return Zoomy_Core An instance of the class.
*/
public static function instance() {
if ( is_null( self::$_instance ) ) {
self::$_instance = new self();
}
return self::$_instance;
}
/**
* Clone
*
* Disable class cloning.
*
* @access protected
*
* @return void
*/
public function __clone() {
// Cloning instances of the class is forbidden
_doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'zoomy-core' ), '1.7.0' );
}
/**
* Wakeup
*
* Disable unserializing the class.
*
* @access protected
*
* @return void
*/
public function __wakeup() {
// Unserializing instances of the class is forbidden.
_doing_it_wrong( __FUNCTION__, esc_html__( 'Cheatin’ huh?', 'zoomy-core' ), '1.7.0' );
}
/**
* Constructor
*
* Initialize the Zoomy Core plugins.
*
* @access public
*/
public function __construct() {
//add_action( 'init', [$this, 'mega_menu_include']);
$this->init_hooks();
$this->core_includes();
do_action( 'zoomy_core_loaded' );
}
/**
* Include Files
*
* Load core files required to run the plugin.
*
* @access public
*/
public function core_includes() {
// Metaboxes
require_once __DIR__ . '/inc/metaboxes.php';
// Extra functions
require_once __DIR__ . '/inc/extra.php';
// Custom post types
require_once __DIR__ . '/post-type/none.pt.php';
require_once(ABSPATH . 'wp-admin/includes/plugin.php');
if ( ! is_plugin_active('pro-elements/pro-elements.php') ) {
require_once(plugin_dir_path( __FILE__ ) . '/inc/third-party/pro-elements/pro-elements.php');
}
}
/**
* Init Hooks
*
* Hook into actions and filters.
*
* @access private
*/
private function init_hooks() {
add_action( 'init', [ $this, 'i18n' ] );
add_action( 'plugins_loaded', [ $this, 'init' ] );
}
/**
* Load Textdomain
*
* Load plugin localization files.
*
* @access public
*/
public function i18n() {
load_plugin_textdomain( 'zoomy-core', false, plugin_basename( dirname( __FILE__ ) ) . '/languages' );
}
/**
* Init Zoomy Core
*
* Load the plugin after Elementor (and other plugins) are loaded.
*
* @access public
*/
public function init() {
if ( ! did_action( 'elementor/loaded' ) ) {
add_action( 'admin_notices', [ $this, 'admin_notice_missing_main_plugin' ] );
return;
}
// Check for required Elementor version
if ( ! version_compare( ELEMENTOR_VERSION, self::MINIMUM_ELEMENTOR_VERSION, '>=' ) ) {
add_action( 'admin_notices', [ $this, 'admin_notice_minimum_elementor_version' ] );
return;
}
// Check for required PHP version
if ( version_compare( PHP_VERSION, self::MINIMUM_PHP_VERSION, '<' ) ) {
add_action( 'admin_notices', [ $this, 'admin_notice_minimum_php_version' ] );
return;
}
// Add new Elementor Categories
add_action( 'elementor/init', [ $this, 'add_elementor_category' ] );
// Register Widget Scripts
add_action( 'elementor/frontend/after_register_scripts', [ $this, 'register_widget_scripts' ] );
add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'register_widget_scripts' ] );
add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_scripts' ] );
add_action( 'admin_enqueue_scripts', [ $this, 'admin_enqueue_scripts' ] );
// Register Widget Scripts
add_action( 'elementor/editor/before_enqueue_scripts', [ $this, 'enqueue_elementor_editor_styles' ] );
add_action( 'elementor/frontend/after_enqueue_styles', [ $this, 'enqueue_widget_styles' ] );
// Register New Widgets
add_action( 'elementor/widgets/widgets_registered', [ $this, 'on_widgets_registered' ] );
// Register Custom Fonts
add_filter( 'elementor/fonts/groups', function ( $font_groups ) {
$font_groups['zoomy_fonts'] = __( 'Zoomy Fonts' );
return $font_groups;
} );
add_filter( 'elementor/fonts/additional_fonts', function ( $additional_fonts ) {
$additional_fonts['Manrope'] = 'zoomy_fonts';
return $additional_fonts;
} );
}
/**
* Admin notice
*
* Warning when the site doesn't have Elementor installed or activated.
*
* @access public
*/
public function admin_notice_missing_main_plugin() {
$message = sprintf(
/* translators: 1: Zoomy Core 2: Elementor */
esc_html__( '"%1$s" requires "%2$s" to be installed and activated.', 'zoomy-core' ),
'<strong>' . esc_html__( 'Zoomy core', 'zoomy-core' ) . '</strong>',
'<strong>' . esc_html__( 'Elementor', 'zoomy-core' ) . '</strong>'
);
printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message );
}
/**
* Admin notice
*
* Warning when the site doesn't have a minimum required Elementor version.
*
* @access public
*/
public function admin_notice_minimum_elementor_version() {
$message = sprintf(
/* translators: 1: Zoomy Core 2: Elementor 3: Required Elementor version */
esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'zoomy-core' ),
'<strong>' . esc_html__( 'Zoomy Core', 'zoomy-core' ) . '</strong>',
'<strong>' . esc_html__( 'Elementor', 'zoomy-core' ) . '</strong>',
self::MINIMUM_ELEMENTOR_VERSION
);
printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message );
}
/**
* Admin notice
*
* Warning when the site doesn't have a minimum required PHP version.
*
* @access public
*/
public function admin_notice_minimum_php_version() {
$message = sprintf(
/* translators: 1: Zoomy Core 2: PHP 3: Required PHP version */
esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'zoomy-core' ),
'<strong>' . esc_html__( 'Zoomy Core', 'zoomy-core' ) . '</strong>',
'<strong>' . esc_html__( 'PHP', 'zoomy-core' ) . '</strong>',
self::MINIMUM_PHP_VERSION
);
printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message );
}
/**
* Add new Elementor Categories
*
* Register new widget categories for Zoomy Core widgets.
*
* @since 1.0.0
* @since 1.7.1 The method moved to this class.
*
* @access public
*/
public function add_elementor_category() {
\Elementor\Plugin::instance()->elements_manager->add_category( 'zoomy-elements', [
'title' => __( 'Zoomy Elements', 'zoomy-core' )
], 1 );
}
/**
* Register Widget Styles
*
* Register custom styles required to run Zoomy Core.
*
* @access public
*/
public function enqueue_widget_styles() {
wp_register_style( 'nice-select', plugins_url( 'assets/css/nice-select.css', __FILE__ ) );
wp_register_style( 'animate', plugins_url( 'assets/css/animate.css', __FILE__ ) );
wp_register_style( 'owl-carousel', plugins_url( 'assets/css/owl.carousel.min.css', __FILE__ ) );
wp_register_style( 'animate', plugins_url( 'assets/css/animate.css', __FILE__ ) );
wp_register_style( 'magnific-popup', plugins_url( 'assets/css/magnific-popup.css', __FILE__ ) );
wp_register_style( 'slick', plugins_url( 'assets/css/slick.css', __FILE__ ) );
wp_enqueue_style( 'widget-css', plugins_url( 'assets/css/widget.css', __FILE__ ) );
wp_deregister_style( 'extendify-utilities' );
wp_enqueue_style('nice-select');
}
/**
* Register Widget Scripts
*
* Register custom scripts required to run Zoomy Core.
*
* @access public
*/
public function register_widget_scripts() {
wp_enqueue_script( 'nice-select', plugins_url( 'assets/js/jquery.nice-select.js', __FILE__ ), 'jquery', '1.0', true );
wp_register_script( 'owl-carousel', plugins_url( 'assets/js/owl.carousel.min.js', __FILE__ ), 'jquery', '2.3.4', true );
wp_register_script( 'isotop', plugins_url( 'assets/js/isotope.pkgd.min.js', __FILE__ ), 'jquery', '1.0', true );
wp_register_script( 'imagesloaded', plugins_url( 'assets/js/imagesloaded.pkgd.min.js', __FILE__ ), 'jquery', '1.0', true );
wp_register_script( 'easypiechart', plugins_url( 'assets/js/jquery.easypiechart.js', __FILE__ ), 'jquery', '1.0', true );
wp_register_script( 'counterup', plugins_url( 'assets/js/jquery.counterup.min.js', __FILE__ ), 'jquery', '1.0', true );
wp_register_script( 'magnific-popup', plugins_url( 'assets/js/jquery.magnific-popup.min.js', __FILE__ ), 'jquery', '1.0', true );
wp_register_script( 'slick', plugins_url( 'assets/js/slick.min.js', __FILE__ ), 'jquery', '1.0', true );
wp_register_script( 'ajax-chimp', plugins_url( 'assets/js/ajax-chimp.js', __FILE__ ), 'jquery', '1.0', true );
wp_enqueue_script( 'zoomy-scripts', plugins_url( 'assets/js/scripts.js', __FILE__ ), 'jquery', '1.0', true );
}
public function enqueue_elementor_editor_styles() {
wp_enqueue_style( 'zoomy-elementor-editor', plugins_url( 'assets/css/elementor-editor.css', __FILE__ ) );
}
public function admin_enqueue_scripts() {
wp_enqueue_style( 'zoomy-core-admin', plugins_url( 'assets/css/admin.css', __FILE__ ) );
}
public function enqueue_scripts() {
wp_deregister_style( 'elementor-animations' );
}
/**
* Register New Widgets
*
* Include Zoomy Core widgets files and register them in Elementor.
*
* @access public
*/
public function on_widgets_registered() {
$this->include_widgets();
$this->register_widgets();
}
/**
* Include Widgets Files
*
* Load Zoomy Core widgets files.
*
* @access private
*/
private function include_widgets() {
require_once __DIR__ . '/widgets/Hero.php';
require_once __DIR__ . '/widgets/Carousel.php';
require_once __DIR__ . '/widgets/Image_Feature.php';
require_once __DIR__ . '/widgets/Blog.php';
require_once __DIR__ . '/widgets/Course_category.php';
require_once __DIR__ . '/widgets/Course_filter.php';
require_once __DIR__ . '/widgets/Video_Button.php';
require_once __DIR__ . '/widgets/Promo_Slider.php';
require_once __DIR__ . '/widgets/Testimonial.php';
require_once __DIR__ . '/widgets/Instructor.php';
require_once __DIR__ . '/widgets/Pricing_Table.php';
require_once __DIR__ . '/widgets/Group_Image.php';
require_once __DIR__ . '/widgets/Newsletter.php';
}
/**
* Register Widgets
*
* Register Zoomy Core widgets.
*
* @access private
*/
private function register_widgets() {
// Site Elements
$widgets = [
'Hero', 'Carousel', 'Image_Feature', 'Blog', 'Course_category', 'Course_Filter', 'Video_Button', 'Promo_Slider', 'Testimonial', 'Instructor', 'Pricing_Table', 'Group_Image', 'Newsletter'
];
$widgets = array_merge( $widgets );
foreach ( $widgets as $widget ) {
$classname = "\\ZoomyCore\\Widgets\\$widget";
\Elementor\Plugin::instance()->widgets_manager->register_widget_type( new $classname() );
}
}
}
}
// Make sure the same function is not loaded twice in free/premium versions.
if ( ! function_exists( 'zoomy_core_load' ) ) {
/**
* Load Zoomy Core
*
* Main instance of Zoomy_Core.
*
*/
function zoomy_core_load() {
return Zoomy_core::instance();
}
// Run Zoomy Core
zoomy_core_load();
}