Diff: STRATO-apps/wordpress_03/app/wp-content/plugins/tutor-pro/addons/content-bank/src/Assets.php
Keine Baseline-Datei – Diff nur gegen leer.
1
-
1
+
<?php
2
+
/**
3
+
* Manage Assets for content bank.
4
+
*
5
+
* @package TutorPro\ContentBank
6
+
* @author Themeum <support@themeum.com>
7
+
* @link https://themeum.com
8
+
* @since 3.7.0
9
+
*/
10
+
11
+
namespace TutorPro\ContentBank;
12
+
13
+
use TUTOR\Input;
14
+
use Tutor\Options_V2;
15
+
16
+
/**
17
+
* Assets Class.
18
+
*
19
+
* @since 3.7.0
20
+
*/
21
+
class Assets {
22
+
/**
23
+
* Register hooks and dependency
24
+
*/
25
+
public function __construct() {
26
+
add_action( 'admin_enqueue_scripts', array( $this, 'admin_script' ) );
27
+
add_filter( 'tutor_localize_data', array( $this, 'extend_localize_data' ) );
28
+
}
29
+
30
+
/**
31
+
* Load admin assets
32
+
*
33
+
* @since 3.7.0
34
+
*
35
+
* @return void
36
+
*/
37
+
public function admin_script() {
38
+
$page = Input::get( 'page' );
39
+
if ( Menu::PAGE_SLUG === $page ) {
40
+
wp_enqueue_editor();
41
+
42
+
wp_enqueue_media();
43
+
wp_enqueue_script( 'tutor-content-bank-backend', Helper::asset_url( 'js/manage-contents/index.js' ), array( 'wp-i18n', 'wp-date', 'wp-element' ), TUTOR_PRO_VERSION, true );
44
+
}
45
+
}
46
+
47
+
/**
48
+
* Extend localize data
49
+
*
50
+
* @since 3.7.0
51
+
*
52
+
* @param array $data data.
53
+
*
54
+
* @return array
55
+
*/
56
+
public function extend_localize_data( $data ) {
57
+
$page = Input::get( 'page' );
58
+
if ( Menu::PAGE_SLUG !== $page ) {
59
+
return $data;
60
+
}
61
+
62
+
$required_options = array(
63
+
'monetize_by',
64
+
'supported_video_sources',
65
+
'chatgpt_enable',
66
+
'hide_admin_bar_for_users',
67
+
'pagination_per_page',
68
+
);
69
+
70
+
$full_settings = get_option( 'tutor_option', array() );
71
+
$settings = Options_V2::get_only( $required_options );
72
+
$settings['chatgpt_key_exist'] = tutor()->has_pro && ! empty( $full_settings['chatgpt_api_key'] ?? '' );
73
+
$settings['youtube_api_key_exist'] = ! empty( $full_settings['lesson_video_duration_youtube_api_key'] ?? '' );
74
+
75
+
$supported_video_sources = array();
76
+
$saved_video_source_list = (array) ( $full_settings['supported_video_sources'] ?? array() );
77
+
78
+
foreach ( tutor_utils()->get_video_sources( true ) as $value => $label ) {
79
+
if ( in_array( $value, $saved_video_source_list, true ) ) {
80
+
$supported_video_sources[] = array(
81
+
'label' => $label,
82
+
'value' => $value,
83
+
);
84
+
}
85
+
}
86
+
87
+
$new_data = array( 'settings' => $settings );
88
+
$new_data['supported_video_sources'] = $supported_video_sources;
89
+
90
+
$data = array_merge( $data, $new_data );
91
+
92
+
return $data;
93
+
}
94
+
}
95
+