FileSpin_Auth::is_connected(), 'email' => isset( $c['email'] ) ? (string) $c['email'] : '', 'canSettings' => current_user_can( 'manage_options' ), 'settingsUrl' => FileSpin_Settings::url(), 'signupUrl' => FileSpin_Settings::signup_url(), 'dashboardUrl' => FileSpin_Settings::dashboard_url(), ); } /** * Register a built script (from build/, made with @wordpress/scripts from src/). * * @param string $name Entry name. * @param array $deps Extra dependencies. */ private static function register_build( $name, array $deps = array() ) { $asset = include FILESPIN_PLUGIN_DIR . 'build/' . $name . '.asset.php'; wp_register_script( 'filespin-' . $name, FILESPIN_PLUGIN_URL . 'build/' . $name . '.js', array_merge( $asset['dependencies'], $deps ), $asset['version'], true ); wp_set_script_translations( 'filespin-' . $name, 'filespin' ); wp_add_inline_script( 'filespin-' . $name, 'window.FileSpinConfig = ' . wp_json_encode( self::config() ) . ';', 'before' ); if ( file_exists( FILESPIN_PLUGIN_DIR . 'build/' . $name . '.css' ) ) { wp_enqueue_style( 'filespin-' . $name, FILESPIN_PLUGIN_URL . 'build/' . $name . '.css', array( 'wp-components' ), $asset['version'] ); } wp_enqueue_script( 'filespin-' . $name ); } /** The FileSpin sidebar in the block editor. */ public static function enqueue_editor() { if ( current_user_can( 'upload_files' ) ) { self::register_build( 'editor' ); } } /** The FileSpin tab in the media window, wherever WordPress loads it. */ public static function enqueue_modal() { if ( is_admin() && current_user_can( 'upload_files' ) ) { self::register_build( 'media-modal', array( 'media-views' ) ); } } /** "Connect FileSpin" for admins, on the Plugins and Media screens only. */ public static function notice() { if ( ! current_user_can( 'manage_options' ) || FileSpin_Auth::is_connected() ) { return; } $screen = get_current_screen(); if ( ! $screen || ! in_array( $screen->id, array( 'upload', 'plugins' ), true ) ) { return; } if ( get_option( FileSpin_Auth::LOST_OPTION ) ) { $text = __( 'The FileSpin connection has ended, so FileSpin images can\'t be added. Images already on your pages keep working.', 'filespin' ); $link = __( 'Connect again', 'filespin' ); $type = 'notice-warning'; } else { $text = __( 'Connect FileSpin to add your FileSpin images and videos to posts and pages.', 'filespin' ); $link = __( 'Connect to FileSpin', 'filespin' ); $type = 'notice-info'; } printf( '
%2$s %4$s
' . esc_html( $asset ) . '' . esc_html__( 'Served from FileSpin. Edit the file in FileSpin.', 'filespin' ) . '
', ); } return $fields; } /** * Plugins screen: a Settings link. * * @param array $links Links. * @return array */ public static function action_links( $links ) { array_unshift( $links, '' . esc_html__( 'Settings', 'filespin' ) . '' ); return $links; } }