PluginProbe
Sight – Professional Image Gallery and Portfolio / 1.1.0
Sight – Professional Image Gallery and Portfolio v1.1.0
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8
sight / core / core-video-settings.php

core-video-settings.php in Sight – Professional Image Gallery and Portfolio 1.1.0, at core/core-video-settings.php

108 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The Video Settings.
4 *
5 * @link https://codesupply.co
6 * @since 1.0.0
7 *
8 * @package Sight
9 */
10
11 /**
12 * The initialize block.
13 */
14 class Sight_Video_Settings {
15 /**
16 * Initialize
17 */
18 public function __construct() {
19 add_action( 'init', array( $this, 'register_video_settings' ) );
20 add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_block_editor_assets' ), 100 );
21 }
22
23 /**
24 * Enqueue assets for gutenberg panels
25 */
26 public function enqueue_block_editor_assets() {
27 $post_id = get_the_ID();
28
29 if ( ! $post_id ) {
30 return;
31 }
32
33 // Data.
34 $panels_data = array(
35 'postType' => get_post_type( $post_id ),
36 );
37
38 // Enqueue scripts.
39 wp_enqueue_script(
40 'sight-video-settings',
41 SIGHT_URL . 'gutenberg/jsx/video-panel.js',
42 array(
43 'wp-i18n',
44 'wp-blocks',
45 'wp-edit-post',
46 'wp-element',
47 'wp-editor',
48 'wp-components',
49 'wp-data',
50 'wp-plugins',
51 'wp-edit-post',
52 'wp-hooks',
53 ),
54 filemtime( SIGHT_PATH . 'gutenberg/jsx/video-panel.js' ),
55 true
56 );
57
58 // Localize scripts.
59 wp_localize_script( 'sight-video-settings', 'sightVideoSettings', $panels_data );
60 }
61
62 /**
63 * Register video settings
64 */
65 public function register_video_settings() {
66
67 register_post_meta(
68 'sight-projects',
69 'sight_post_video_url',
70 array(
71 'show_in_rest' => true,
72 'type' => 'string',
73 'single' => true,
74 'auth_callback' => function () {
75 return current_user_can( 'edit_posts' );
76 },
77 )
78 );
79
80 register_post_meta(
81 'sight-projects',
82 'sight_post_video_bg_start_time',
83 array(
84 'show_in_rest' => true,
85 'type' => 'number',
86 'single' => true,
87 'auth_callback' => function () {
88 return current_user_can( 'edit_posts' );
89 },
90 )
91 );
92
93 register_post_meta(
94 'sight-projects',
95 'sight_post_video_bg_end_time',
96 array(
97 'show_in_rest' => true,
98 'type' => 'number',
99 'single' => true,
100 'auth_callback' => function () {
101 return current_user_can( 'edit_posts' );
102 },
103 )
104 );
105 }
106 }
107 new Sight_Video_Settings();
108