setup_hooks(); } /** * To setup action/filter. * * @return void */ protected function setup_hooks() { add_action( 'plugins_loaded', array( $this, 'elementor_init' ) ); add_action( 'elementor/editor/after_enqueue_scripts', array( $this, 'elementor_enqueue_scripts' ) ); } /** * To enqueue scripts and styles in elementor admin. * * @param string $hook_suffix Admin page name. * * @return void */ public function elementor_enqueue_scripts( $hook_suffix ) { wp_enqueue_script( 'rmp_elementor_scripts', RMP_PLUGIN_URL_V4 . '/assets/admin/js/rmp-elementor.js', array( 'jquery' ), RMP_PLUGIN_VERSION, true ); } /** * Initialize the plugin * * Validates that Elementor is already loaded. * Checks for basic plugin requirements, if one check fail don't continue, * if all check have passed include the plugin class. * * Fired by `plugins_loaded` action hook. * * @since 4.0.2 * @access public */ public function elementor_init() { // Check if Elementor installed and activated. if ( ! did_action( 'elementor/loaded' ) ) { add_action( 'admin_notices', array( $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', array( $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', array( $this, 'admin_notice_minimum_php_version' ) ); return; } add_action( 'elementor/widgets/widgets_registered', array( $this, 'register_widgets' ) ); } /** * Admin notice * * Warning when the site doesn't have Elementor installed or activated. * * @since 4.0.2 * @access public */ public function admin_notice_missing_main_plugin() { return sprintf( wp_kses( '
"%1$s" requires "%2$s" to be installed and activated.
"%1$s" requires "%2$s" version %3$s or greater.
"%1$s" requires "%2$s" version %3$s or greater.