Completed
Pull Request — develop (#1350)
by Naveen
03:33
created

Post_Edit_Screen::init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @since 3.31.0
4
 * @author Naveen Muthusamy <[email protected]>
5
 */
6
7
namespace Wordlift\Videoobject\Ui;
8
9
use Wordlift\Scripts\Scripts_Helper;
10
11
class Post_Edit_Screen {
12
13
	public function init() {
14
		$callback = array( $this, 'enqueue_scripts', );
15
		add_action( 'enqueue_block_editor_assets', $callback );
16
		add_action( 'admin_print_scripts-post.php', $callback );
17
		add_action( 'admin_print_scripts-post-new.php', $callback );
18
	}
19
20
	public function enqueue_scripts() {
21
		Scripts_Helper::enqueue_based_on_wordpress_version( 'wl-videoobject',
22
			plugin_dir_url( dirname( dirname( __DIR__ ) ) ) . '/js/dist/videoobject',
23
			array( 'react', 'react-dom', 'wp-hooks', 'wp-i18n', 'wp-polyfill' )
24
		);
25
		wp_enqueue_style( 'wl-videoobject',
26
			plugin_dir_url( dirname( dirname( __DIR__ ) ) ) . '/js/dist/videoobject.css' );
27
		wp_localize_script( 'wl-videoobject', '_wlVideoobjectConfig', array(
28
			'restUrl' => get_rest_url( null, '/wordlift/v1/videos' ),
29
			'nonce'   => wp_create_nonce( 'wp_rest' ),
30
			'postId'  => get_the_ID(),
31
		) );
32
	}
33
34
}