Hướng dẫn viết widget Elementor (ok)

C:\xampp\htdocs\oec\src\wp-content\themes\ecademy-child\functions.php

class My_Elementor_Widgets {
  protected static $instance = null;
  public static function get_instance() {
    if ( ! isset( static::$instance ) ) {
      static::$instance = new static;
    }
    return static::$instance;
  }
  protected function __construct() {
    require_once('newsletter-ct.php');
    add_action( 'elementor/widgets/widgets_registered', [ $this, 'register_widgets' ] );
  }
  public function register_widgets() {
    \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Elementor\eCademy_Newsletter_Ct() );
  }
}
Plugin::instance()->widgets_manager->unregister_widget_type('eCademy_Newsletter');
add_action( 'init', 'my_elementor_init' );
function my_elementor_init() {
  My_Elementor_Widgets::get_instance();
}

C:\xampp\htdocs\oec\src\wp-content\themes\ecademy-child\newsletter-ct.php

Last updated

Was this helpful?