'video/3gpp2', '3gp' => 'video/3gpp', '3gp2' => 'video/3gpp2', '3gpp' => 'video/3gpp', 'avi' => 'video/avi', 'm4v' => 'video/mp4', 'mov' => 'video/quicktime', 'mp4' => 'video/mp4', 'mpe' => 'video/mpeg', 'mpeg' => 'video/mpeg', 'mpg' => 'video/mpeg', 'ogv' => 'video/ogg', 'wmv' => 'video/x-ms-wmv', ); } /** * Initialize the admin resources. */ public static function admin_init() { add_action( 'admin_enqueue_scripts', array( __CLASS__, 'enqueue_admin_scripts' ) ); } /** * Main plugin settings page. */ public static function plugin_settings_page() { ?>
should_enable_tracking( new Terms_Of_Service(), $status ); } /** * Enqueue plugin admin scripts and styles. */ public static function enqueue_admin_scripts() { Assets::register_script( self::JETPACK_VIDEOPRESS_PKG_NAMESPACE, '../build/admin/index.js', __FILE__, array( 'in_footer' => true, 'textdomain' => 'jetpack-videopress-pkg', ) ); Assets::enqueue_script( self::JETPACK_VIDEOPRESS_PKG_NAMESPACE ); // Required for Media Library access wp_enqueue_media(); // Required for Analytics. if ( self::can_use_analytics() ) { Tracking::register_tracks_functions_scripts( true ); } // Initial JS state including JP Connection data. Connection_Initial_State::render_script( self::JETPACK_VIDEOPRESS_PKG_NAMESPACE ); wp_add_inline_script( self::JETPACK_VIDEOPRESS_PKG_NAMESPACE, self::render_initial_state(), 'before' ); } /** * Render the initial state into a JavaScript variable. * * @return string */ public static function render_initial_state() { return 'var jetpackVideoPressInitialState=JSON.parse(decodeURIComponent("' . rawurlencode( wp_json_encode( self::initial_state() ) ) . '"));'; } /** * Get the initial state data for hydrating the React UI. * * @return array */ public static function initial_state() { return array( 'apiRoot' => esc_url_raw( rest_url() ), 'apiNonce' => wp_create_nonce( 'wp_rest' ), 'registrationNonce' => wp_create_nonce( 'jetpack-registration-nonce' ), 'adminUrl' => self::get_admin_page_url(), 'adminUri' => 'admin.php?page=' . self::ADMIN_PAGE_SLUG, 'paidFeatures' => array( 'isVideoPressSupported' => Current_Plan::supports( 'videopress' ), 'isVideoPress1TBSupported' => Current_Plan::supports( 'videopress-1tb-storage' ), 'isVideoPressUnlimitedSupported' => Current_Plan::supports( 'videopress-unlimited-storage' ), ), 'siteSuffix' => ( new Status() )->get_site_suffix(), 'productData' => Plan::get_product(), 'productPrice' => Plan::get_product_price(), 'siteProductData' => My_Jetpack_Products::get_product( 'videopress' ), 'allowedVideoExtensions' => self::get_allowed_video_extensions(), 'initialState' => Data::get_initial_state(), 'contentNonce' => wp_create_nonce( 'videopress-content-nonce' ), ); } /** * Replaces the edit link for videopress videos * * @param string $link - the post link. * @param int $post_id - the post ID. * @param string $context - the context. * * @return string */ public static function edit_video_link( $link, $post_id, $context ) { $post_id = (int) $post_id; if ( ! $post_id ) { return $link; } $post = get_post( $post_id ); if ( ! $post ) { return $link; } if ( 'attachment' !== $post->post_type || 'video/videopress' !== $post->post_mime_type ) { return $link; } $route = sprintf( '#/video/%d/edit', $post_id ); $url = self::get_admin_page_url() . $route; if ( 'display' === $context ) { return esc_url( $url ); } return esc_url_raw( $url ); } /** * Gets the SVG for the sub brand Jetpack VideoPress logo * * @return string */ protected static function get_logo_svg() { return ''; } // phpcs:disable WordPress.Security.EscapeOutput.UnsafePrintingFunction // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped /** * Overwrites the backbone template for the attachment details modal * * This template is originally added in WP core in wp-includes/media-templates.php * * We override the initialize method of the TwoColumn view class (located at core's js/media/view/attachment/detail-two-column.js) * and use the custom template only for VideoPress videos. * * @return void */ public static function attachment_details_two_column_template() { ?>