*/ final class Core extends AbstractCore { /** * The i18n class of the plugin. * * @since 2.0.0 * @access protected * @var I18n $i18n The i18n class of the plugin. */ protected $i18n; /** * The ajax of the plugin. * * @since 2.0.0 * @access public * @var Ajax $ajax The ajax of the plugin. */ public $ajax; /** * The views of the plugin. * * @since 2.0.0 * @access private * @var View $views The views of the plugin. */ private $views; /** * Api class * * @since 2.7 * @access private * @var Api $api Api class. */ private $api; /** * NoPub instance * * @since 3.2.0 * @access private * @var \ActirisePublic\Includes\NoPub $no_pub NoPub instance */ private $no_pub; /** * Initialize the class and set its properties. * * @since 2.0.0 * @param string $plugin_name The name of this plugin. * @param string $plugin_prefix The unique prefix of this plugin. * @param string $version The version of this plugin. * @param \Actirise\Includes\Loader $loader The loader of this plugin. * @param \ActirisePublic\Includes\NoPub $no_pub NoPub instance. */ public function __construct( $plugin_name, $plugin_prefix, $version, $loader, $no_pub ) { $this->plugin_name = $plugin_name; $this->plugin_prefix = $plugin_prefix; $this->version = $version; $this->loader = $loader; $this->no_pub = $no_pub; $this->views = new View(); $this->ajax = new Ajax( $plugin_name ); $this->api = new Api(); $this->no_pub->register_meta_box(); $this->register_ajax_event(); if ( ! wp_doing_ajax() ) { $this->get_user_currency(); $this->check_debug_token(); $this->maybe_check_organization_fields(); } if ( ACTIRISE_CRON !== 'true' ) { EventAnnotation::update_event_annotation(); } } /** * Register the JavaScript for the admin area. * * @since 2.0.0 * @param string $hook_suffix The current admin page. * @return void */ public function enqueue_scripts( $hook_suffix ) { wp_register_script( $this->plugin_name, ACTIRISE_URL . 'admin/assets/js/main-' . $this->version . '.js', array(), $this->version, true ); wp_register_style( $this->plugin_name, ACTIRISE_URL . 'admin/assets/css/main-' . $this->version . '.css', array(), $this->version ); $this->localize_script( $hook_suffix ); // Enqueue WordPress media library scripts for image picker wp_enqueue_media(); wp_enqueue_script( $this->plugin_name ); wp_enqueue_style( $this->plugin_name ); add_filter( 'script_loader_tag', array( $this, 'transform_to_module' ), 10, 3 ); } /** * Transform script to module * * @param string $tag The script tag. * @param string $handle The script handle. * @param string $src The script src. * * @return string */ public function transform_to_module( $tag, $handle, $src ) { if ( 'actirise' === $handle ) { $tag = str_replace( '