| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly. |
| 3 |
|
| 4 |
class RTMEGA_MENU { |
| 5 |
|
| 6 |
private static $_instance = null; |
| 7 |
|
| 8 |
/** |
| 9 |
* Instance |
| 10 |
* |
| 11 |
* Ensures only one instance of the class is loaded or can be loaded. |
| 12 |
* |
| 13 |
* @since 1.0.0 |
| 14 |
* |
| 15 |
* @access public |
| 16 |
* @static |
| 17 |
* |
| 18 |
* @return Elementor_Test_Extension An instance of the class. |
| 19 |
*/ |
| 20 |
public static function instance() { |
| 21 |
|
| 22 |
if ( is_null( self::$_instance ) ) { |
| 23 |
self::$_instance = new self(); |
| 24 |
} |
| 25 |
return self::$_instance; |
| 26 |
|
| 27 |
} |
| 28 |
|
| 29 |
/** |
| 30 |
* Constructor |
| 31 |
* |
| 32 |
* @since 1.0.0 |
| 33 |
* |
| 34 |
* @access public |
| 35 |
*/ |
| 36 |
public function __construct() { |
| 37 |
|
| 38 |
add_action( 'plugins_loaded', [ $this, 'init' ] ); |
| 39 |
} |
| 40 |
|
| 41 |
/** |
| 42 |
* Initialize the plugin |
| 43 |
* |
| 44 |
* Load the plugin only after Elementor (and other plugins) are loaded. |
| 45 |
* Checks for basic plugin requirements, if one check fail don't continue, |
| 46 |
* if all check have passed load the files required to run the plugin. |
| 47 |
* |
| 48 |
* Fired by `plugins_loaded` action hook. |
| 49 |
* |
| 50 |
* @since 1.0.0 |
| 51 |
* |
| 52 |
* @access public |
| 53 |
*/ |
| 54 |
public function init() { |
| 55 |
if( function_exists( 'register_block_type' ) ){ |
| 56 |
add_theme_support( 'menus' ); |
| 57 |
} |
| 58 |
|
| 59 |
// Add Plugin actions |
| 60 |
add_action( 'elementor/widgets/register', [ $this, 'init_widgets' ] ); |
| 61 |
add_action( 'elementor/elements/categories_registered', [ $this, 'add_category' ] ); |
| 62 |
add_filter( 'plugin_action_links_' . RTMEGA_MENU_PLUGIN_BASE, [ $this, 'rtmega_plugin_action_links' ], 10, 4 ); |
| 63 |
|
| 64 |
} |
| 65 |
|
| 66 |
public function rtmega_plugin_action_links( $plugin_actions, $plugin_file, $plugin_data, $context ) { |
| 67 |
|
| 68 |
$new_actions = array(); |
| 69 |
/* translators: 1: Settings Text */ |
| 70 |
$new_actions['rtmega_plugin_actions_setting'] = sprintf( __( '<a href="%s" target="_self">Settings</a>', 'rt-mega-menu' ), esc_url( admin_url( 'options-general.php?page=rt-mega-menu' ) ) ); |
| 71 |
|
| 72 |
/* translators: 1: Upgrade to pro text. */ |
| 73 |
$new_actions['rtmega_plugin_actions_upgrade'] = sprintf( __( '<a href="%s" style="color: #39b54a; font-weight: bold;" target="_blank">Upgrade to Pro</a>', 'rt-mega-menu' ), esc_url( 'https://rtmega.themewant.com' ) ); |
| 74 |
return array_merge( $new_actions, $plugin_actions ); |
| 75 |
|
| 76 |
} |
| 77 |
|
| 78 |
|
| 79 |
// Add elementor widget category |
| 80 |
public function add_category( $elements_manager ) { |
| 81 |
$elements_manager->add_category( |
| 82 |
'rtmega_category', |
| 83 |
[ |
| 84 |
'title' => esc_html__('RTMEGA Elementor Addons', 'rt-mega-menu' ), |
| 85 |
'icon' => 'fa fa-smile-o', |
| 86 |
] |
| 87 |
); |
| 88 |
} |
| 89 |
|
| 90 |
public function init_widgets() { |
| 91 |
//Nav Widget |
| 92 |
require_once ( RTMEGA_MENU_PL_PATH.'/public/widgets/rtmega-widget.php' ); |
| 93 |
\Elementor\Plugin::instance()->widgets_manager->register( new \RTMEGA_MENU_INLINE() ); |
| 94 |
|
| 95 |
// Register widget |
| 96 |
add_action( 'elementor/elements/categories_registered', [$this, 'add_category'] ); |
| 97 |
} |
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
} |