ures' => 'https://go.elementor.com/app-notes',
] );
}
/**
* Define the module tables in `wpdb`.
*
* @return void
*/
private function define_tables() {
global $wpdb;
$tables = [
self::TABLE_NOTES,
self::TABLE_NOTES_USERS_RELATIONS,
];
foreach ( $tables as $table ) {
$wpdb->$table = $wpdb->prefix . $table;
$wpdb->tables[] = $table;
}
}
private function on_elementor_pro_init() {
$has_license = API::is_license_active() && API::is_licence_has_feature( static::LICENSE_FEATURE_NAME );
if ( ! $has_license ) {
return;
}
// Things that should be happened if the feature is active (not depends on the current user)
$this->define_tables();
add_action( 'switch_blog', function () {
// Reinitialize the Notes tables when switching between sites on a multisite, since each site has its own tables prefix.
$this->define_tables();
} );
( new Capabilities() )->register();
( new Preferences() )->register();
( new Delete_User() )->register();
( new Personal_Data() )->register();
( new Notes_Database_Updater() )->register();
( new Admin_Bar() )->register();
( new Admin_Page() )->register();
( new Document_Events() )->register();
( new Usage() )->register();
Plugin::elementor()->data_manager_v2->register_controller( new Controller() );
// Things that should be happened if the current user can read notes.
if ( is_user_logged_in() && current_user_can( Capabilities::READ_NOTES ) ) {
add_action( 'template_redirect', function () {
// Only now the 'queried_object' is available for the config.
$this->add_config();
} );
add_action( 'elementor/frontend/before_enqueue_styles', [ $this, 'enqueue_styles' ] );
add_action( 'elementor/frontend/after_register_scripts', function () {
$is_preview = Plugin::elementor()->preview->is_preview();
if ( ! $is_preview ) {
$this->enqueue_main_scripts();
}
$this->enqueue_app_initiator( $is_preview );
} );
add_action( 'elementor/editor/before_enqueue_scripts', function () {
$this->enqueue_main_scripts();
} );
add_filter( 'elementor-pro/editor/v2/packages', function ( $packages ) {
$packages[] = 'editor-notes';
return $packages;
} );
}
}
public function __construct() {
parent::__construct();
add_action( 'elementor_pro/init', function() {
$this->on_elementor_pro_init();
} );
}
}