Classic_Editor::post_edit_assets( string $hook )
Add scripts to custom post edit page
Parameters
- $hook
-
(Required)
Source
File: includes/libs/admin/editor/classic-editor.class.php
public function post_edit_assets( $hook ){
if( 'post.php' !== $hook && 'post-new.php' !== $hook ){
return;
}
global $post;
if( ! $post ){
return;
}
$_post = Helper::get_video_post( $post );
// video/playlist shortcode functionality
wp_enqueue_style(
'cvm-shortcode-modal',
VIMEOTHEQUE_URL . 'assets/back-end/css/shortcode-modal.css',
[ 'wp-jquery-ui-dialog' ],
'1.0'
);
wp_enqueue_script(
'cvm-shortcode-modal',
VIMEOTHEQUE_URL . 'assets/back-end/js/shortcode-modal.js',
[ 'jquery-ui-dialog' ],
'1.0'
);
wp_localize_script(
'cvm-shortcode-modal',
'CVM_SHORTCODE_MODAL',
[
'playlist_title' => __( 'Videos in playlist', 'codeflavors-vimeo-video-post-lite' ),
'no_videos' => sprintf(
'%s <br />%s',
__( 'No videos selected.', 'codeflavors-vimeo-video-post-lite' ),
__( 'To create a playlist check some videos from the list on the right.', 'codeflavors-vimeo-video-post-lite' )
),
'deleteItem' => __( 'Delete from playlist', 'codeflavors-vimeo-video-post-lite' ),
'insert_playlist' => __( 'Add shortcode into post', 'codeflavors-vimeo-video-post-lite' ),
'deleteCategory' => __( 'Remove category', 'codeflavors-vimeo-video-post-lite' ),
'no_categories' => __( 'Select some categories to display videos from. Categories can be added by clicking "Add category to shortcode" button above the posts table.', 'codeflavors-vimeo-video-post-lite' )
]
);
// some files are needed only on custom post type edit page
if( $_post->is_video() ){
// add video player for video preview on post
Helper::enqueue_player();
wp_enqueue_script(
'cvm-video-edit',
VIMEOTHEQUE_URL . 'assets/back-end/js/video-edit.js',
[ 'jquery', 'wp-color-picker' ],
'1.0'
);
wp_enqueue_style('wp-color-picker');
wp_enqueue_style(
'cvm-video-thumbnail',
VIMEOTHEQUE_URL . 'assets/back-end/css/video-thumbnail.css',
false,
'1.0'
);
if( !$this->screen->is_block_editor ) {
// video thumbnail functionality
wp_enqueue_script(
'cvm-video-thumbnail',
VIMEOTHEQUE_URL . 'assets/back-end/js/video-thumbnail.js',
[ 'jquery' ],
'1.0'
);
wp_localize_script(
'cvm-video-thumbnail',
'cvm_thumb_message',
[
'loading' => __( '... importing thumbnail', 'codeflavors-vimeo-video-post-lite' ),
'still_loading' => __( '... hold on, still loading' )
]
);
}
/**
* Run hook when Vimeotheque loads scripts and styles for the Classic editor.
* @ignore
*/
do_action( 'vimeotheque\editor\classic-editor-enqueue');
}
}
