Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Plugin Name: RRF Commerce Elementor
- * Description: Custom Elementor extension for RRF Commerce Theme.
- * Plugin URI: https://anything.com/
- * Version: 1.0.0
- * Author: Rasel Ahmed
- * Author URI: https://anythingauthor.com/
- * Text Domain: rrfcommerce-elementor
- */
- if ( ! defined( 'ABSPATH' ) ) {
- exit;
- }
- final class RRF_Commerce_Extension {
- const VERSION = '1.0.0';
- const MINIMUM_ELEMENTOR_VERSION = '2.0.0';
- const MINIMUM_PHP_VERSION = '5.6';
- private static $_instance = null;
- public static function instance() {
- if ( is_null( self::$_instance ) ) {
- self::$_instance = new self();
- }
- return self::$_instance;
- }
- public function __construct() {
- add_action( 'init', [ $this, 'i18n' ] );
- add_action( 'plugins_loaded', [ $this, 'init' ] );
- }
- public function i18n() {
- load_plugin_textdomain( 'rrfcommerce-elementor' );
- }
- public function init() {
- if ( ! did_action( 'elementor/loaded' ) ) {
- add_action( 'admin_notices', [ $this, 'admin_notice_missing_main_plugin' ] );
- return;
- }
- if ( ! version_compare( ELEMENTOR_VERSION, self::MINIMUM_ELEMENTOR_VERSION, '>=' ) ) {
- add_action( 'admin_notices', [ $this, 'admin_notice_minimum_elementor_version' ] );
- return;
- }
- if ( version_compare( PHP_VERSION, self::MINIMUM_PHP_VERSION, '<' ) ) {
- add_action( 'admin_notices', [ $this, 'admin_notice_minimum_php_version' ] );
- return;
- }
- add_action( 'elementor/widgets/widgets_registered', [ $this, 'init_widgets' ] );
- add_action( 'elementor/frontend/after_enqueue_styles', [ $this, 'widget_styles' ] );
- }
- public function admin_notice_missing_main_plugin() {
- if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
- $message = sprintf(
- esc_html__( '"%1$s" requires "%2$s" to be installed and activated.', 'rrfcommerce-elementor' ),
- '<strong>' . esc_html__( 'Elementor Test Extension', 'rrfcommerce-elementor' ) . '</strong>',
- '<strong>' . esc_html__( 'Elementor', 'rrfcommerce-elementor' ) . '</strong>'
- );
- printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message );
- }
- public function admin_notice_minimum_elementor_version() {
- if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
- $message = sprintf(
- esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'rrfcommerce-elementor' ),
- '<strong>' . esc_html__( 'Elementor Test Extension', 'rrfcommerce-elementor' ) . '</strong>',
- '<strong>' . esc_html__( 'Elementor', 'rrfcommerce-elementor' ) . '</strong>',
- self::MINIMUM_ELEMENTOR_VERSION
- );
- printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message );
- }
- public function admin_notice_minimum_php_version() {
- if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
- $message = sprintf(
- esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'rrfcommerce-elementor' ),
- '<strong>' . esc_html__( 'Elementor Test Extension', 'rrfcommerce-elementor' ) . '</strong>',
- '<strong>' . esc_html__( 'PHP', 'rrfcommerce-elementor' ) . '</strong>',
- self::MINIMUM_PHP_VERSION
- );
- printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message );
- }
- public function init_widgets() {
- require_once( __DIR__ . '/widgets/slider.php' );
- require_once( __DIR__ . '/widgets/content-block.php' );
- \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \RRFCommerce_Slider_Widget() );
- \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \RRFCommerce_ContentBlock_Widget() );
- }
- public function widget_styles() {
- wp_enqueue_style( 'rrfcommerce-slider', plugins_url( 'widgets/css/slider.css', __FILE__ ) );
- wp_enqueue_style( 'rrfcommerce-content-block', plugins_url( 'widgets/css/content-box.css', __FILE__ ) );
- }
- }
- RRF_Commerce_Extension::instance();
- function rrf_commerce_plugin_scripts() {
- wp_enqueue_style( 'slick', plugins_url( 'assets/css/slick.css', __FILE__ ) );
- wp_enqueue_script( 'slick', plugins_url( 'assets/js/slick.min.js', __FILE__ ), array('jquery'), '20151215', true );
- }
- add_action( 'wp_enqueue_scripts', 'rrf_commerce_plugin_scripts' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement