Skip to content

Instantly share code, notes, and snippets.

@tanjimahmmed
Created June 17, 2020 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tanjimahmmed/d800d0cc0ae9bc7f7a1f416b78ad2f88 to your computer and use it in GitHub Desktop.
Save tanjimahmmed/d800d0cc0ae9bc7f7a1f416b78ad2f88 to your computer and use it in GitHub Desktop.
<?php
/**
* Plugin Name: Timer Element Elementor
* Plugin URI:
* Description:
* Version: 1.0
* Author: MD Tanjim
* License: GPLv2 or later
* Text Domain: timerelement
* Domain Path: /languages/
*/
use \ELEMENTOR\Plugin as Plugin;
if(!defined('ABSPATH')){
die(__("Direct Access is not allowed", 'timerelement'));
}
final class TimerElementExtension{
const VERSION = "1.0.0";
const MINIMUM_ELEMENTOR_VERSION = "2.9.11";
const MINIMUM_PHP_VERSION = "7.0";
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( 'plugins_loaded', [ $this, 'init' ] );
}
public function init() {
load_plugin_textdomain( 'timerelement', false, dirname(__FILE__) ."/languages" );
// Check if Elementor installed and activated
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_action( 'elementor/widgets/widgets_registered', [ $this, 'init_widgets' ] );
add_action("elementor/elements/categories_registered", [ $this, 'register_new_category' ]);
add_action("elementor/frontend/after_enqueue_styles", [ $this, 'frontend_assets_styles' ]);
add_action("elementor/editor/after_enqueue_scripts", [ $this, 'frontend_assets_scripts' ]);
}
function frontend_assets_scripts(){
}
function frontend_assets_styles(){
}
function pricing_editor_assets(){
wp_enqueue_script("pricing-editor-js", plugins_url("/assets/js/main.js",__FILE__), array("jquery"),time(),true);
}
public function register_new_category($manager){
$manager->add_category('Md Tanjim', [
'title'=>__('Md Tanjim Elementor','timerelement'),
'icon' =>'fa fa-image'
]);
}
public function init_widgets(){
}
public function admin_notice_minimum_php_version(){
if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
$message = sprintf(
/* translators: 1: Plugin name 2: PHP 3: Required PHP version */
esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'timerelement' ),
'<strong>' . esc_html__( 'Elementor Test Extension', 'timerelement' ) . '</strong>',
'<strong>' . esc_html__( 'PHP', 'timerelement' ) . '</strong>',
self::MINIMUM_PHP_VERSION
);
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(
/* translators: 1: Plugin name 2: Elementor 3: Required Elementor version */
esc_html__( '"%1$s" requires "%2$s" version %3$s or greater.', 'timerelement' ),
'<strong>' . esc_html__( 'Elementor Test Extension', 'timerelement' ) . '</strong>',
'<strong>' . esc_html__( 'Elementor', 'timerelement' ) . '</strong>',
self::MINIMUM_ELEMENTOR_VERSION
);
printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message );
}
public function admin_notice_missing_main_plugin(){
if ( isset( $_GET['activate'] ) ) unset( $_GET['activate'] );
$message = sprintf(
/* translators: 1: Plugin name 2: Elementor */
esc_html__( '"%1$s" requires "%2$s" to be installed and activated.', 'timerelement' ),
'<strong>' . esc_html__( 'Elementor Test Extension', 'timerelement' ) . '</strong>',
'<strong>' . esc_html__( 'Elementor', 'timerelement' ) . '</strong>'
);
printf( '<div class="notice notice-warning is-dismissible"><p>%1$s</p></div>', $message );
}
public function includes() {}
}
ElementorTestExtension::instance();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment