| 1 |
<?php |
| 2 |
|
| 3 |
if ( ! defined( 'ABSPATH' ) ) { |
| 4 |
exit; |
| 5 |
} |
| 6 |
|
| 7 |
/* |
| 8 |
* Admin menus and such... |
| 9 |
*/ |
| 10 |
function fv_player_admin_page() { |
| 11 |
include dirname( __FILE__ ) . '/../view/admin.php'; |
| 12 |
} |
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
function fv_player_is_admin_screen() { |
| 18 |
if( (isset($_GET['page']) && sanitize_key( $_GET['page'] ) == 'fvplayer') || apply_filters('fv_player_is_admin_screen', false) ) { |
| 19 |
return true; |
| 20 |
} |
| 21 |
return false; |
| 22 |
} |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
function fv_player_stats_page() { |
| 28 |
include dirname( __FILE__ ) . '/../view/stats.php'; |
| 29 |
} |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
add_action( 'fv_player_pro_video_ads_panel', 'fv_player_video_ad_stats_page' ); |
| 35 |
|
| 36 |
function fv_player_video_ad_stats_page() { |
| 37 |
include dirname( __FILE__ ) . '/../view/video-ad-stats.php'; |
| 38 |
} |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
add_filter('plugin_action_links', 'fv_wp_flowplayer_plugin_action_links', 10, 2); |
| 44 |
|
| 45 |
function fv_wp_flowplayer_plugin_action_links($links, $file) { |
| 46 |
if( $file == 'fv-player/fv-player.php') { |
| 47 |
$settings_link = '<a href="https://foliovision.com/pro-support" target="_blank">Premium Support</a>'; |
| 48 |
array_unshift($links, $settings_link); |
| 49 |
$settings_link = '<a href="admin.php?page=fvplayer">Settings</a>'; |
| 50 |
array_unshift($links, $settings_link); |
| 51 |
} |
| 52 |
return $links; |
| 53 |
} |
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
add_action( 'after_plugin_row', 'fv_wp_flowplayer_after_plugin_row', 10, 3 ); |
| 59 |
|
| 60 |
function fv_wp_flowplayer_after_plugin_row( $arg) { |
| 61 |
if( apply_filters('fv_player_skip_ads',false) ) { |
| 62 |
return; |
| 63 |
} |
| 64 |
|
| 65 |
$args = func_get_args(); |
| 66 |
|
| 67 |
if( $args[1]['Name'] == 'FV Player' ) { |
| 68 |
$options = get_option( 'fvwpflowplayer' ); |
| 69 |
if( $options['key'] == 'false' || $options['key'] == '' ) : |
| 70 |
?> |
| 71 |
<tr class="plugin-update-tr fv-wordpress-flowplayer-tr"> |
| 72 |
<td class="plugin-update colspanchange" colspan="3"> |
| 73 |
<div class="update-message"> |
| 74 |
<a href="https://foliovision.com/player/download">All Licenses 20% Off</a> - Easter sale! |
| 75 |
</div> |
| 76 |
</td> |
| 77 |
</tr> |
| 78 |
<?php |
| 79 |
endif; |
| 80 |
} |
| 81 |
} |
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
/** |
| 86 |
* Settings metaboxes close |
| 87 |
*/ |
| 88 |
add_filter( 'get_user_option_closedpostboxes_fv_flowplayer_settings', 'fv_wp_flowplayer_closed_meta_boxes' ); |
| 89 |
|
| 90 |
function fv_wp_flowplayer_closed_meta_boxes( $closed ) { |
| 91 |
if ( false === $closed ) { |
| 92 |
$closed = array( 'fv_flowplayer_amazon_options', 'fv_flowplayer_interface_options', 'fv_flowplayer_default_options', 'fv_flowplayer_ads', 'fv_flowplayer_integrations', 'fv_flowplayer_mobile', 'fv_flowplayer_seo', 'fv_flowplayer_privacy'); |
| 93 |
} |
| 94 |
|
| 95 |
return $closed; |
| 96 |
} |
| 97 |
|
| 98 |
/** |
| 99 |
* Tools metaboxes close |
| 100 |
*/ |
| 101 |
add_filter( 'get_user_option_closedpostboxes_fv_flowplayer_settings_tools', 'fv_flowplayer_settings_tools_closed_meta_boxes' ); |
| 102 |
|
| 103 |
function fv_flowplayer_settings_tools_closed_meta_boxes( $closed ) { |
| 104 |
if ( false === $closed ) { |
| 105 |
$closed = array( 'fv_flowplayer_conversion' ); |
| 106 |
} |
| 107 |
|
| 108 |
return $closed; |
| 109 |
} |
| 110 |
|
| 111 |
/** |
| 112 |
* Skin metaboxes close |
| 113 |
*/ |
| 114 |
add_filter( 'get_user_option_closedpostboxes_fv_flowplayer_settings_skin', 'fv_flowplayer_settings_skin_closed_meta_boxes' ); |
| 115 |
|
| 116 |
function fv_flowplayer_settings_skin_closed_meta_boxes( $closed ) { |
| 117 |
if ( false === $closed ) { |
| 118 |
global $fv_fp; |
| 119 |
$customCSS = $fv_fp->_get_option('customCSS'); |
| 120 |
|
| 121 |
if( strlen( $customCSS ) === 0 ) { |
| 122 |
$closed = array( 'fv_flowplayer_skin_custom_css' ); |
| 123 |
} |
| 124 |
} |
| 125 |
|
| 126 |
return $closed; |
| 127 |
} |
| 128 |
|
| 129 |
/* |
| 130 |
* Saving settings |
| 131 |
*/ |
| 132 |
add_action('admin_init', 'fv_player_settings_save', 9); |
| 133 |
add_action('wp_ajax_fv_flowplayer_settings_save', 'fv_player_settings_save', 9); |
| 134 |
|
| 135 |
function fv_player_settings_save() { |
| 136 |
|
| 137 |
if( isset($_POST['fv-wp-flowplayer-submit']) || isset($_POST['fv-wp-flowplayer-submit-ajax']) ) { |
| 138 |
|
| 139 |
if( isset($_POST['fv-wp-flowplayer-submit-ajax']) ) { |
| 140 |
if( wp_doing_ajax() ) { |
| 141 |
unset($_POST['action']); |
| 142 |
} |
| 143 |
|
| 144 |
if(! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['fv_flowplayer_settings_ajax_nonce'] ) ), 'fv_flowplayer_settings_ajax_nonce' ) ) { |
| 145 |
wp_die('Security check failed'); |
| 146 |
} |
| 147 |
} else { |
| 148 |
check_admin_referer('fv_flowplayer_settings_nonce','fv_flowplayer_settings_nonce'); |
| 149 |
} |
| 150 |
|
| 151 |
global $fv_fp; |
| 152 |
$fv_fp->_set_conf(); |
| 153 |
} |
| 154 |
} |
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
function fv_player_handle_secrets($new, $old) { |
| 160 |
foreach( $new as $k => $v ) { |
| 161 |
if (is_array($v) && strpos($k, '_is_secret_') !== 0 && isset($old[$k]) ) { |
| 162 |
// recursive call for nested settings |
| 163 |
$v = fv_player_handle_secrets($v, $old[$k]); |
| 164 |
$new[$k] = $v; |
| 165 |
} |
| 166 |
|
| 167 |
if(strpos($k, '_is_secret_') === 0 ) { |
| 168 |
$key = str_replace('_is_secret_', '', $k); |
| 169 |
|
| 170 |
if( isset($old[$key]) ) { |
| 171 |
if(is_array($v)) { // array of values, 1 - keep original, 0 - use new |
| 172 |
foreach( $v as $a_k => $a_v ) { |
| 173 |
if( $a_v == '1' ) { |
| 174 |
$new[$key][$a_k] = $old[$key][$a_k]; |
| 175 |
} |
| 176 |
} |
| 177 |
} else if($v == '1') { // single value, 1 - keep original, 0 - use new |
| 178 |
$new[$key] = $old[$key]; |
| 179 |
} |
| 180 |
} |
| 181 |
|
| 182 |
unset($new[$k]); // remove _is_secret_ |
| 183 |
} |
| 184 |
} |
| 185 |
|
| 186 |
return $new; |
| 187 |
} |
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
/* |
| 193 |
* Pointer boxes |
| 194 |
*/ |
| 195 |
add_action('admin_init', 'fv_player_admin_pointer_boxes'); |
| 196 |
|
| 197 |
function fv_player_admin_pointer_boxes() { |
| 198 |
global $fv_fp; |
| 199 |
global $fv_wp_flowplayer_ver, $fv_wp_flowplayer_core_ver; |
| 200 |
|
| 201 |
if( |
| 202 |
$fv_fp->_get_option('video_position_save_enable') && |
| 203 |
! $fv_fp->_get_option('notice_user_video_positions_conversion') && |
| 204 |
( empty( $_GET['page'] ) || 'fv_player_conversion_positions_meta2table' != $_GET['page'] ) |
| 205 |
) { |
| 206 |
$fv_fp->pointer_boxes['fv_flowplayer_video_positions_conversion'] = array( |
| 207 |
'id' => '#wp-admin-bar-new-content', |
| 208 |
'pointerClass' => 'fv_flowplayer_video_positions_conversion', |
| 209 |
'heading' => __( 'FV Player Video Position Conversion', 'fv-player' ), |
| 210 |
'content' => __("<p>In this new version of FV Player the user video positions are stored in separate table. This avoids slowing down the user database (wp_usermeta).</p><p>Please run the tool to migrate the video positions to the new table.</p>"), |
| 211 |
'position' => array( 'edge' => 'top', 'align' => 'left' ), |
| 212 |
'button1' => __( 'Migrate', 'fv-player' ), |
| 213 |
'function1' => 'location.href = "' . admin_url('admin.php?page=fv_player_conversion_positions_meta2table') . '"', |
| 214 |
); |
| 215 |
} |
| 216 |
|
| 217 |
if( |
| 218 |
isset($fv_fp->conf['disable_videochecker']) && $fv_fp->conf['disable_videochecker'] == 'false' && |
| 219 |
( !isset($fv_fp->conf['video_checker_agreement']) || $fv_fp->conf['video_checker_agreement'] != 'true' ) |
| 220 |
) { |
| 221 |
$fv_fp->pointer_boxes['fv_flowplayer_video_checker_service'] = array( |
| 222 |
'id' => '#wp-admin-bar-new-content', |
| 223 |
'pointerClass' => 'fv_flowplayer_video_checker_service', |
| 224 |
'heading' => __( 'FV Player Video Checker', 'fv-player' ), |
| 225 |
'content' => __( "<p>FV Player includes a <a href='https://foliovision.com/player/basic-setup/how-to-use-video-checker' target='_blank'>free video checker</a> which will check your videos for any encoding errors and helps ensure smooth playback of all your videos. To work its magic, our video checker must contact our server.</p><p>Would you like to enable the video encoding checker?</p>", 'fv-player' ), |
| 226 |
'position' => array( 'edge' => 'top', 'align' => 'center' ), |
| 227 |
'button1' => __( 'Allow', 'fv-player' ), |
| 228 |
'button2' => __( 'Disable the video checker', 'fv-player' ) |
| 229 |
); |
| 230 |
} |
| 231 |
|
| 232 |
if( $fv_fp->_get_option('video_sitemap') && $fv_fp->_get_option( 'ui_embed' ) && !$fv_fp->_get_option('notice_xml_sitemap_iframes') ) { |
| 233 |
$fv_fp->pointer_boxes['fv_flowplayer_notice_xml_sitemap_iframes'] = array( |
| 234 |
'id' => '#wp-admin-bar-new-content', |
| 235 |
'pointerClass' => 'fv_flowplayer_notice_xml_sitemap_iframes', |
| 236 |
'heading' => __( 'FV Player Video Sitemap coverage', 'fv-player' ), |
| 237 |
'content' => __( "<p>The XML Video Sitemap now includes a lot more videos as it uses the individual player iframe embed links. Until now it was only possible to put in videos using MP4 format without any kind of download protection.</p><p>Please <a href='https://foliovision.com/support/fv-wordpress-flowplayer/bug-reports#new-post' target='_blank'>let us know</a> in case you notice any issues. Your members only videos stay protected and won't open, but let us know if they appear in sitemap.</p>", 'fv-player' ).'<script>jQuery(".fv_flowplayer_notice_xml_sitemap_iframes .button2").click()</script>', |
| 238 |
'position' => array( 'edge' => 'top', 'align' => 'center' ), |
| 239 |
'button1' => __( 'Thanks for letting me know!', 'fv-player' ), |
| 240 |
'button2' => __( 'Go to setting', 'fv-player' ), |
| 241 |
'function2' => 'location.href = "'.admin_url('admin.php?page=fvplayer').'#fv_flowplayer_seo"', |
| 242 |
); |
| 243 |
} |
| 244 |
|
| 245 |
if( !$fv_fp->_get_option('nag_fv_player_8') ) { |
| 246 |
$fv_fp->pointer_boxes['fv_flowplayer_fv_player_8'] = array( |
| 247 |
'id' => '#wp-admin-bar-new-content', |
| 248 |
'pointerClass' => 'fv_flowplayer_fv_player_8', |
| 249 |
'heading' => __( 'FV Player 8', 'fv-player' ), |
| 250 |
'content' => '<p>Welcome to the brand new FV Player 8! Improvements include:</p>'. |
| 251 |
'<ul style="list-style: circle; padding-left: 3em;"> |
| 252 |
<li>New mobile controls</li> |
| 253 |
<li>New editor interface</li> |
| 254 |
<li>Proper Gutenberg block</li> |
| 255 |
<li>Autoplay respects user scroll position</li> |
| 256 |
<li>Two new playlist styles</li> |
| 257 |
<li>Shortcodes and video links converted to database entries on post save</li> |
| 258 |
<li>PageSpeed Score improvements</li> |
| 259 |
<li>Increased compatibility and performance</li> |
| 260 |
<li>User Video Positions stored in separate database table</li> |
| 261 |
</ul>'. |
| 262 |
'<p>More information in our <a href="https://foliovision.com/player/developers/fv-player-8-changes" target="_blank">blog announcement</a>.</p>', |
| 263 |
'position' => array( 'edge' => 'top', 'align' => 'center' ), |
| 264 |
'button1' => __( 'Thanks for letting me know!', 'fv-player' ), |
| 265 |
); |
| 266 |
} |
| 267 |
} |
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
add_action( 'wp_ajax_fv_foliopress_ajax_pointers', 'fv_wp_flowplayer_pointers_ajax' ); |
| 273 |
|
| 274 |
function fv_wp_flowplayer_pointers_ajax() { |
| 275 |
|
| 276 |
if( isset($_POST['key']) && sanitize_key( $_POST['key'] ) == 'fv_flowplayer_video_checker_service' && isset($_POST['value']) ) { |
| 277 |
check_ajax_referer('fv_flowplayer_video_checker_service'); |
| 278 |
$conf = get_option( 'fvwpflowplayer' ); |
| 279 |
if( $conf ) { |
| 280 |
if( sanitize_key( $_POST['value'] ) == 'true' ) { |
| 281 |
$conf['disable_videochecker'] = 'false'; |
| 282 |
$conf['video_checker_agreement'] = 'true'; |
| 283 |
} else { |
| 284 |
$conf['disable_videochecker'] = 'true'; |
| 285 |
} |
| 286 |
update_option( 'fvwpflowplayer', $conf ); |
| 287 |
} |
| 288 |
die(); |
| 289 |
} |
| 290 |
|
| 291 |
if( isset($_POST['key']) && sanitize_key( $_POST['key'] ) == 'fv_flowplayer_video_positions_conversion' && isset($_POST['value']) ) { |
| 292 |
check_ajax_referer('fv_flowplayer_video_positions_conversion'); |
| 293 |
$conf = get_option( 'fvwpflowplayer' ); |
| 294 |
if( $conf ) { |
| 295 |
$conf['notice_user_video_positions_conversion'] = sanitize_text_field( $_POST['value'] ); |
| 296 |
update_option( 'fvwpflowplayer', $conf ); |
| 297 |
} |
| 298 |
die(); |
| 299 |
} |
| 300 |
|
| 301 |
$notices = array( |
| 302 |
'fv_flowplayer_notice_xml_sitemap_iframes' => 'notice_xml_sitemap_iframes', |
| 303 |
'fv_flowplayer_fv_player_8' => 'nag_fv_player_8', |
| 304 |
); |
| 305 |
|
| 306 |
if( isset($_POST['key']) && isset($_POST['value']) && in_array($_POST['key'], array_keys($notices) ) ) { |
| 307 |
check_ajax_referer( sanitize_key( $_POST['key'] ) ); |
| 308 |
$conf = get_option( 'fvwpflowplayer' ); |
| 309 |
if( $conf ) { |
| 310 |
$conf[ $notices[ sanitize_key( $_POST['key'] ) ] ] = 'true'; |
| 311 |
update_option( 'fvwpflowplayer', $conf ); |
| 312 |
} |
| 313 |
die(); |
| 314 |
} |
| 315 |
|
| 316 |
} |
| 317 |
|
| 318 |
|
| 319 |
/* |
| 320 |
* Making sure FV Player appears properly on settings screen |
| 321 |
*/ |
| 322 |
add_action('admin_enqueue_scripts', 'fv_flowplayer_admin_scripts'); |
| 323 |
|
| 324 |
function fv_flowplayer_admin_scripts() { |
| 325 |
global $fv_wp_flowplayer_ver, $fv_fp; |
| 326 |
|
| 327 |
if( fv_player_is_admin_screen() ) { |
| 328 |
wp_enqueue_media(); |
| 329 |
|
| 330 |
wp_enqueue_script('wp-theme-plugin-editor'); |
| 331 |
wp_enqueue_style('wp-codemirror'); |
| 332 |
|
| 333 |
wp_enqueue_script('common'); |
| 334 |
wp_enqueue_script('wp-lists'); |
| 335 |
wp_enqueue_script('postbox'); |
| 336 |
|
| 337 |
wp_enqueue_script('jquery-minicolors', flowplayer::get_plugin_url().'/js/jquery-minicolors/jquery.minicolors.min.js',array('jquery'), $fv_wp_flowplayer_ver ); |
| 338 |
wp_enqueue_script('fv-player-admin', flowplayer::get_plugin_url().'/js/admin.js',array('jquery','jquery-minicolors'), filemtime( (__DIR__).'/../js/admin.js' ), true ); |
| 339 |
wp_localize_script( 'fv-player-admin', 'fv_player_admin', array( |
| 340 |
'css_logo_positions' => $fv_fp->css_logo_positions, |
| 341 |
) ); |
| 342 |
|
| 343 |
wp_enqueue_script('fv-player-settings', flowplayer::get_plugin_url().'/js/settings.js',array('jquery'), filemtime( (__DIR__).'/../js/settings.js' ), true ); |
| 344 |
|
| 345 |
if( function_exists('wp_enqueue_code_editor') ) { |
| 346 |
wp_localize_script('fv-player-admin', 'cm_settings', wp_enqueue_code_editor(array('type' => 'text/css')) ); |
| 347 |
} |
| 348 |
} |
| 349 |
} |
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
add_action( 'admin_enqueue_scripts', 'fv_player_settings_styles' ); |
| 355 |
|
| 356 |
function fv_player_settings_styles() { |
| 357 |
if( !fv_player_is_admin_screen() ) return; |
| 358 |
|
| 359 |
global $fv_wp_flowplayer_ver; |
| 360 |
wp_enqueue_style('fv-player-admin', flowplayer::get_plugin_url().'/css/license.css',array(), $fv_wp_flowplayer_ver ); |
| 361 |
wp_enqueue_style('jquery-minicolors', flowplayer::get_plugin_url().'/js/jquery-minicolors/jquery.minicolors.css',array(), $fv_wp_flowplayer_ver ); |
| 362 |
} |
| 363 |
|
| 364 |
add_action('admin_footer', 'flowplayer_admin_footer'); |
| 365 |
|
| 366 |
function flowplayer_admin_footer() { |
| 367 |
if( !fv_player_is_admin_screen() ) return; |
| 368 |
|
| 369 |
flowplayer_prepare_scripts(); |
| 370 |
flowplayer_display_scripts(); |
| 371 |
} |
| 372 |
|
| 373 |
function fv_player_get_aws_regions() { |
| 374 |
|
| 375 |
return array( |
| 376 |
'af-south-1' => __('Africa (Cape Town)', 'fv-player' ), |
| 377 |
'ap-east-1' => __('Asia Pacific (Hong Kong)', 'fv-player' ), |
| 378 |
'ap-south-2' => __('Asia Pacific (Hyderabad)', 'fv-player' ), |
| 379 |
'ap-southeast-3' => __('Asia Pacific (Jakarta)', 'fv-player' ), |
| 380 |
'ap-southeast-5' => __('Asia Pacific (Malaysia)', 'fv-player' ), |
| 381 |
'ap-southeast-4' => __('Asia Pacific (Melbourne)', 'fv-player' ), |
| 382 |
'ap-south-1' => __('Asia Pacific (Mumbai)', 'fv-player' ), |
| 383 |
'ap-northeast-3' => __('Asia Pacific (Osaka)', 'fv-player' ), |
| 384 |
'ap-northeast-2' => __('Asia Pacific (Seoul)', 'fv-player' ), |
| 385 |
'ap-southeast-1' => __('Asia Pacific (Singapore)', 'fv-player' ), |
| 386 |
'ap-southeast-2' => __('Asia Pacific (Sydney)', 'fv-player' ), |
| 387 |
'ap-northeast-1' => __('Asia Pacific (Tokyo)', 'fv-player' ), |
| 388 |
|
| 389 |
'ca-central-1' => __('Canada (Central)', 'fv-player' ), |
| 390 |
'ca-west-1' => __('Canada West (Calgary)', 'fv-player' ), |
| 391 |
|
| 392 |
'cn-north-1' => __('China (Beijing)', 'fv-player' ), |
| 393 |
'cn-northwest-1' => __('China (Ningxia)', 'fv-player' ), |
| 394 |
|
| 395 |
'eu-central-1' => __('Europe (Frankfurt)', 'fv-player' ), |
| 396 |
'eu-west-1' => __('Europe (Ireland)', 'fv-player' ), |
| 397 |
'eu-west-2' => __('Europe (London)', 'fv-player' ), |
| 398 |
'eu-south-1' => __('Europe (Milan)', 'fv-player' ), |
| 399 |
'eu-west-3' => __('Europe (Paris)', 'fv-player' ), |
| 400 |
'eu-south-2' => __('Europe (Spain)', 'fv-player' ), |
| 401 |
'eu-north-1' => __('Europe (Stockholm)', 'fv-player' ), |
| 402 |
'eu-central-2' => __('Europe (Zurich)', 'fv-player' ), |
| 403 |
|
| 404 |
'il-central-1' => __('Israel (Tel Aviv)', 'fv-player' ), |
| 405 |
|
| 406 |
'me-south-1' => __('Middle East (Bahrain)', 'fv-player' ), |
| 407 |
'me-central-1' => __('Middle East (UAE)', 'fv-player' ), |
| 408 |
|
| 409 |
'sa-east-1' => __('South America (São Paulo)', 'fv-player' ), |
| 410 |
|
| 411 |
'us-west-1' => __('US West (N. California)', 'fv-player' ), |
| 412 |
'us-east-1' => __('US East (N. Virginia)', 'fv-player' ), |
| 413 |
'us-east-2' => __('US East (Ohio)', 'fv-player' ), |
| 414 |
'us-west-2' => __('US West (Oregon)', 'fv-player' ) |
| 415 |
|
| 416 |
); |
| 417 |
} |
| 418 |
|