'wordpress', 'utm_medium' => $medium, ), untrailingslashit( VIGI_VIDEO_APP_URL ) . $path ); } /** * Messages after an action. */ private static function notices() { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- display only. $notice = isset( $_GET['vigi_notice'] ) ? sanitize_key( wp_unslash( $_GET['vigi_notice'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- display only. $detail = isset( $_GET['vigi_detail'] ) ? sanitize_text_field( wp_unslash( $_GET['vigi_detail'] ) ) : ''; $messages = array( 'connected' => array( 'success', __( 'Connected to ViGi. Your videos are below.', 'videopronto' ) ), 'disconnected' => array( 'info', __( 'Disconnected. Videos already on your pages keep playing.', 'videopronto' ) ), 'cancelled' => array( 'warning', __( 'Connection cancelled.', 'videopronto' ) ), 'expired' => array( 'error', __( 'That connection link expired. Please click Connect again.', 'videopronto' ) ), 'failed' => array( 'error', __( "We couldn't finish connecting to ViGi. Please try again.", 'videopronto' ) ), 'placed' => array( 'success', __( 'Video added to the page.', 'videopronto' ) ), 'place_error' => array( 'error', $detail ), 'refreshed' => array( 'success', __( 'Videos refreshed from ViGi.', 'videopronto' ) ), ); $quick = Vigi_Video_Quick_Create::notice_message(); if ( $quick ) { printf( '
%2$s
%2$s
' . esc_html( $error->get_error_message() ) . '
'; if ( 'vigi_unauthorized' === $error->get_error_code() && current_user_can( 'manage_options' ) ) { self::render_connect(); } return; } Vigi_Video_Review::render(); self::render_essentials( $essentials, $pages ); self::render_quick_create( $videos ); self::render_other_videos( $videos, $essentials ); } /** * The 9 essentials. * * @param array $essentials Linked videos by key. * @param WP_Post[] $pages Pages. */ private static function render_essentials( $essentials, $pages ) { $defs = Vigi_Video_Essentials::all(); $done = 0; $placed = 0; foreach ( $defs as $key => $def ) { $video = isset( $essentials[ $key ]['video'] ) ? $essentials[ $key ]['video'] : null; if ( $video ) { ++$done; if ( Vigi_Video_Placement::placed_page( $key, $video['id'] ) ) { ++$placed; } } } ?>
| # | |||
|---|---|---|---|
| ' . (int) $n . ' | '; echo '' . esc_html( $def['name'] ) . ' ' . esc_html( $def['why'] ) . ' | ';
echo ''; self::render_video_cell( $video ); echo ' | '; self::render_place_cell( $key, $def, $video, $pages ); echo ' |
' . esc_html__( 'None yet.', 'videopronto' ) . '
'; } else { echo '' . esc_html__( 'Add any video to a post or page with the "VideoPronto" block, or paste its shortcode (works in page builders like Elementor and Divi too).', 'videopronto' ) . '
'; echo '| '; self::render_video_cell( $video ); echo ' | '; if ( $video['ready'] ) { echo ''; } echo ' |
'; echo esc_html( sprintf( /* translators: %d: number of unfinished videos */ _n( '%d unfinished video is hidden here.', '%d unfinished videos are hidden here.', $drafts, 'videopronto' ), $drafts ) ); echo ' ' . esc_html__( 'Finish them in ViGi', 'videopronto' ) . '
'; } echo ''; } /** * Quick create: a video for any page or post, newest first. * * @param array $videos All of the account's videos. */ private static function render_quick_create( $videos ) { $by_id = array(); foreach ( $videos as $video ) { $by_id[ $video['id'] ] = $video; } $posts = get_posts( array( 'post_type' => Vigi_Video_Quick_Create::post_types(), 'post_status' => array( 'publish', 'draft', 'pending', 'future', 'private' ), 'posts_per_page' => 10, 'orderby' => 'modified', 'order' => 'DESC', ) ); $stages = array( 'making' => __( 'Being made in ViGi', 'videopronto' ), 'review' => __( 'Ready for your review', 'videopronto' ), 'publishing' => __( 'Publishing', 'videopronto' ), 'ready' => __( 'Live on the page', 'videopronto' ), 'error' => __( "Couldn't be made", 'videopronto' ), ); echo '' . esc_html__( 'Wrote a new blog post or service page? ViGi turns what the page says into a video and adds it to the top of the page. It goes live as soon as you review and publish it in ViGi. You can also click "Make a ViGi video" under any post in your Posts or Pages list, or use the VideoPronto block in the editor.', 'videopronto' ) . '
'; if ( empty( $posts ) ) { echo '' . esc_html__( 'No pages or posts yet.', 'videopronto' ) . '
'; return; } echo '| ' . esc_html( $post->post_title ? $post->post_title : __( '(no title)', 'videopronto' ) ) . ' '; echo esc_html( ( $type ? $type->labels->singular_name : $post->post_type ) . ' · ' . get_post_status_object( $post->post_status )->label ); echo ' | '; if ( $quick && Vigi_Video_Placement::page_has_video( $post, $quick['video_id'] ) ) { $video = isset( $by_id[ $quick['video_id'] ] ) ? $by_id[ $quick['video_id'] ] : null; // The page may have seen it go live more recently than the list. $cached = Vigi_Video_Api::cached( $quick['video_id'] ); if ( $cached && ! empty( $cached['ready'] ) && ( ! $video || empty( $video['ready'] ) ) ) { $video = $cached; } $stage = $video ? Vigi_Video_Api::stage( $video ) : 'making'; echo '' . esc_html( $stages[ $stage ] ) . ' '; if ( 'ready' !== $stage ) { $link = $video && ! empty( $video['edit_url'] ) ? $video['edit_url'] : untrailingslashit( VIGI_VIDEO_APP_URL ) . '/videos/' . rawurlencode( $quick['video_id'] ); $label = 'review' === $stage ? __( 'Review & publish in ViGi', 'videopronto' ) : __( 'Open in ViGi', 'videopronto' ); echo '' . esc_html( $label ) . ''; } if ( 'error' === $stage ) { echo ' · ' . esc_html__( 'Try again', 'videopronto' ) . ''; } } elseif ( Vigi_Video_Placement::page_has_any_video( $post ) ) { echo '' . esc_html__( 'Has a ViGi video', 'videopronto' ) . ''; } elseif ( '' !== Vigi_Video_Placement::page_builder( $post ) ) { echo '' . esc_html__( 'Built with a page builder: add a video with the shortcode', 'videopronto' ) . ''; } else { echo '' . esc_html__( 'Make a video', 'videopronto' ) . ''; } echo ' |