'; echo '

' . esc_html__( 'Loading the calendar…', 'advently' ) . '

'; echo ''; echo '
'; } /** * @param string $hook Current admin page hook suffix. */ public static function enqueue( $hook ): void { if ( '' === self::$hook || $hook !== self::$hook ) { return; } $asset_file = ADVENTLY_DIR . 'assets/build/admin/index.asset.php'; $asset = is_readable( $asset_file ) ? require $asset_file : [ 'dependencies' => [], 'version' => ADVENTLY_VERSION, ]; wp_enqueue_media(); wp_enqueue_style( 'wp-components' ); // The live preview renders the real visitor calendar with its own stylesheet. wp_enqueue_style( Renderer::HANDLE ); wp_enqueue_style( self::HANDLE, ADVENTLY_URL . 'assets/build/admin/style-index.css', [ 'wp-components' ], $asset['version'] ); wp_enqueue_script( self::HANDLE, ADVENTLY_URL . 'assets/build/admin/index.js', $asset['dependencies'], $asset['version'], [ 'in_footer' => true ] ); wp_set_script_translations( self::HANDLE, 'advently', ADVENTLY_DIR . 'languages' ); $data = [ 'pageUrl' => self::url(), 'docsUrl' => 'https://advently.webkodingtheme.com/docs/', 'shopName' => get_bloginfo( 'name' ), 'timezone' => wp_timezone_string(), 'currency' => html_entity_decode( get_woocommerce_currency_symbol(), ENT_QUOTES, 'UTF-8' ), 'couponsUrl' => admin_url( 'edit.php?post_type=shop_coupon' ), 'exportUrl' => Export::url(), 'ordersUrl' => self::ordersUrl(), 'proUrl' => self::proUrl(), 'limits' => [ 'minDoors' => Config::MIN_DOORS, 'maxDoors' => Config::MAX_DOORS, 'maxValidity' => Config::MAX_VALIDITY_HOURS, 'prefixLength' => Config::PREFIX_LENGTH, ], ]; $data['readOnly'] = false; $data['notice'] = ''; /** * Filters the data handed to the admin app. * * `readOnly` (bool) shows `notice` above the editor and stops asking before * leaving with unsaved changes; saving itself is refused on the server. * * @param array $data Admin app data. */ $data = (array) apply_filters( 'advently_admin_data', $data ); wp_add_inline_script( self::HANDLE, 'window.adventlyAdmin = ' . wp_json_encode( $data ) . ';', 'before' ); /** * Fires after the admin app is enqueued, for add-ons that extend it. Their * scripts should depend on the `advently-admin` handle. */ do_action( 'advently_admin_enqueue' ); } /** * Where the one-line Advently Pro mention links to, or '' to hide it. */ private static function proUrl(): string { /** * Filters whether to mention Advently Pro in the admin. Advently Pro turns it off. * * @param bool $show Whether to show it. */ return apply_filters( 'advently_show_pro', true ) ? self::PRO_URL : ''; } /** * The orders screen, on HPOS or on posts storage. */ private static function ordersUrl(): string { $hpos = class_exists( \Automattic\WooCommerce\Utilities\OrderUtil::class ) && \Automattic\WooCommerce\Utilities\OrderUtil::custom_orders_table_usage_is_enabled(); return $hpos ? admin_url( 'admin.php?page=wc-orders' ) : admin_url( 'edit.php?post_type=shop_order' ); } /** * @param string[] $links Plugin row links. * @return string[] */ public static function actionLinks( $links ): array { $settings = '' . esc_html__( 'Calendar', 'advently' ) . ''; array_unshift( $links, $settings ); if ( '' !== self::proUrl() ) { $links[] = '' . esc_html__( 'Get Pro', 'advently' ) . ''; } return $links; } }