. */ if ( ! defined( 'ABSPATH' ) ) { exit; } add_action('wp_footer','flowplayer_prepare_scripts',9); add_action('wp_footer','flowplayer_display_scripts',100); add_action('widget_text','do_shortcode'); add_filter( 'run_ngg_resource_manager', '__return_false' ); /** * Remove any other "flowplayer" script. * * Verify that it's not in our plugin folder, or the old plugin folder first. * We mainly need this when loading FV Player for the block editor, * which is an iframe blob without wp_footer, so we load the scripts in the * head. */ function fv_flowplayer_remove_bad_scripts() { global $wp_scripts; if( isset( $wp_scripts->registered['flowplayer'], $wp_scripts->registered['flowplayer']->src ) ) { $src = $wp_scripts->registered['flowplayer']->src; if ( stripos( $src, 'fv-player/') === false && stripos( $src, 'fv-wordpress-flowplayer/') === false ) { wp_deregister_script( 'flowplayer' ); } } } add_action( 'wp_print_scripts', 'fv_flowplayer_remove_bad_scripts', 100 ); add_filter( 'run_ngg_resource_manager', '__return_false' ); // Nextgen Gallery compatibility fix function fv_flowplayer_ap_action_init(){ // Localization load_plugin_textdomain('fv-player', false, dirname(dirname(plugin_basename(__FILE__))) . "/languages"); } add_action('init', 'fv_flowplayer_ap_action_init'); function fv_flowplayer_get_js_translations() { $aStrings = array( 0 => '', 1 => __('Video loading aborted', 'fv-player' ), 2 => __('Network error', 'fv-player' ), 3 => __('Video not properly encoded', 'fv-player' ), 4 => __('Video file not found', 'fv-player' ), 5 => __('Unsupported video', 'fv-player' ), 6 => __('Skin not found', 'fv-player' ), 7 => __('SWF file not found', 'fv-player' ), 8 => __('Subtitles not found', 'fv-player' ), 10 => __('Unsupported video format.', 'fv-player' ), 11 => __('Click to watch the video', 'fv-player' ), 12 => __('[This post contains video, click to play]', 'fv-player' ), 'video_expired' => __('
Starting in %d.
', 'fv-player' ), 'live_stream_retry'=>__( 'Retrying in %d ...
', 'fv-player' ), 'live_stream_continue'=>__( 'Retrying in %d ...
', 'fv-player' ), 'embed_copied' =>__('Embed Code Copied to Clipboard', 'fv-player' ), 'error_copy_clipboard' => __('Error copying text into clipboard!', 'fv-player' ), 'subtitles_disabled' =>__('Subtitles disabled', 'fv-player' ), 'subtitles_switched' =>__('Subtitles switched to ', 'fv-player' ), 'warning_iphone_subs' => __('This video has subtitles, that are not supported on your device.', 'fv-player' ), 'warning_unstable_android' => __('You are using an old Android device. If you experience issues with the video please use Firefox.', 'fv-player' ), 'warning_samsungbrowser' => __('You are using the Samsung Browser which is an older and buggy version of Google Chrome. If you experience issues with the video please use Firefox or other modern browser.', 'fv-player' ), 'warning_old_safari' => __('You are using an old Safari browser. If you experience issues with the video please use Firefox or other modern browser.', 'fv-player' ), 'warning_old_chrome' => __('You are using an old Chrome browser. Please make sure you use the latest version.', 'fv-player' ), 'warning_old_firefox' => __('You are using an old Firefox browser. Please make sure you use the latest version.', 'fv-player' ), 'warning_old_ie' => __('You are using a deprecated browser. If you experience issues with the video please use Firefox or other modern browser.', 'fv-player' ), 'quality' => __('Quality', 'fv-player' ), 'closed_captions' => __('Closed Captions', 'fv-player' ), 'no_subtitles' => __('No subtitles', 'fv-player' ), 'speed' => __('Speed', 'fv-player' ), 'duration_1_day' => __( "%s day" ), 'duration_n_days' => _n( '%s day', '%s days', 5 ), 'duration_1_hour' => __( "%s hour" ), 'duration_n_hours' => _n( '%s hour', '%s hours', 5 ), 'duration_1_minute' => __( "%s min" ), 'duration_n_minutes' => _n( '%s min', '%s mins', 5 ), 'duration_1_second' => __( "%s second" ), 'duration_n_seconds' => _n( '%s second', '%s seconds', 5 ), 'and' => sprintf( __( '%1$s and %2$s' ), '', '' ), 'chrome_extension_disable_html5_autoplay' => __('It appears you are using the Disable HTML5 Autoplay Chrome extension, disable it to play videos', 'fv-player' ), 'audio_button' => __('AUD', 'fv-player' ), 'audio_menu' => __('Audio', 'fv-player' ), 'iphone_swipe_up_location_bar' => __('To enjoy fullscreen swipe up to hide location bar.', 'fv-player' ), 'invalid_youtube' => __('Invalid Youtube video ID.', 'fv-player'), 'redirection' => __( "Admin note:\n\nThis player is set to redirect to a URL at the end of the video:\n\n%url%\n\nWould you like to be redirected?\n\nThis note only shows to logged in Administrators and Editors for security reasons, other users are redirected without any popup or confirmation.", 'fv-player' ), 'video_loaded' => __('Video loaded, click to play.', 'fv-player'), 'msg_no_skipping' => __('Skipping is not allowed.', 'fv-player' ), 'msg_watch_video' => __('Please watch the video carefully.', 'fv-player' ), ); return $aStrings; } /** * Replaces the flowplayer tags in post content by players and fills the $GLOBALS['fv_fp_scripts'] array. * * @param string Content to be parsed * @return string Modified content string */ function flowplayer_content( $content ) { global $fv_fp; $content_matches = array(); preg_match_all('/\[(flowplayer|fvplayer)\ [^\]]+\]/i', $content, $content_matches); // process all found tags foreach ($content_matches[0] as $tag) { $ntag = str_replace("\'",''',$tag); //search for URL preg_match("/src='([^']*?)'/i",$ntag,$tmp); if( $tmp[1] == NULL ) { preg_match_all("/src=([^,\s\]]*)/i",$ntag,$tmp); $media = $tmp[1][0]; } else $media = $tmp[1]; //strip the additional /videos/ from the beginning if present preg_match('/(.*)\/videos\/(.*)/',$media,$matches); if ($matches[0] == NULL) $media = $media; else if ($matches[1] == NULL) { $media = $matches[2]; } else { $media = $matches[2]; } unset($arguments['src']); unset($arguments['src1']); unset($arguments['src2']); unset($arguments['width']); unset($arguments['height']); unset($arguments['autoplay']); unset($arguments['splash']); unset($arguments['splashend']); unset($arguments['popup']); unset($arguments['controlbar']); unset($arguments['redirect']); unset($arguments['loop']); //width and heigth preg_match("/width=(\d*)/i",$ntag,$width); preg_match("/height=(\d*)/i",$ntag,$height); if( $width[1] != NULL) $arguments['width'] = $width[1]; if( $height[1] != NULL) $arguments['height'] = $height[1]; //search for redirect preg_match("/redirect='([^']*?)'/i",$ntag,$tmp); if ($tmp[1]) $arguments['redirect'] = $tmp[1]; //search for autoplay preg_match("/[\s]+autoplay([\s]|])+/i",$ntag,$tmp); if (isset($tmp[0])){ $arguments['autoplay'] = true; } else { preg_match("/autoplay='([A-Za-z]*)'/i",$ntag,$tmp); if ( $tmp[1] == NULL ) preg_match("/autoplay=([A-Za-z]*)/i",$ntag,$tmp); if (isset($tmp[1])) $arguments['autoplay'] = $tmp[1]; } //search for popup in quotes preg_match("/popup='([^']*?)'/i",$ntag,$tmp); if ($tmp[1]) $arguments['popup'] = $tmp[1]; //search for loop preg_match("/[\s]+loop([\s]|])+/i",$ntag,$tmp); if (isset($tmp[0])){ $arguments['loop'] = true; } else { preg_match("/loop='([A-Za-z]*)'/i",$ntag,$tmp); if ( $tmp[1] == NULL ) preg_match("/loop=([A-Za-z]*)/i",$ntag,$tmp); if (isset($tmp[1])) $arguments['loop'] = $tmp[1]; } // search for splash image preg_match("/splash='([^']*?)'/i",$ntag,$tmp); //quotes version if( $tmp[1] == NULL ) { preg_match_all("/splash=([^,\s\]]*)/i",$ntag,$tmp); //non quotes version preg_match('/(.*)\/videos\/(.*)/i',$tmp[1][0],$matches); if ($matches[0] == NULL) $arguments['splash'] = $tmp[1][0]; else if ($matches[1] == NULL) { $arguments['splash'] = $matches[2];//$tmp[1][0]; } else { $arguments['splash'] = $matches[2]; } } else { preg_match('/(.*)\/videos\/(.*)/',$tmp[1],$matches); if ($matches[0] == NULL) $arguments['splash'] = $tmp[1]; elseif ($matches[1] == NULL) $arguments['splash'] = $matches[2]; else $arguments['splash'] = $matches[2];//$tmp[1]; } // search for src1 preg_match("/src1='([^']*?)'/i",$ntag,$tmp); //quotes version if( $tmp[1] == NULL ) { preg_match_all("/src1=([^,\s\]]*)/i",$ntag,$tmp); //non quotes version preg_match('/(.*)\/videos\/(.*)/i',$tmp[1][0],$matches); if ($matches[0] == NULL) $arguments['src1'] = $tmp[1][0]; else if ($matches[1] == NULL) { $arguments['src1'] = $matches[2];//$tmp[1][0]; } else { $arguments['src1'] = $matches[2]; } } else { preg_match('/(.*)\/videos\/(.*)/',$tmp[1],$matches); if ($matches[0] == NULL) $arguments['src1'] = $tmp[1]; elseif ($matches[1] == NULL) $arguments['src1'] = $matches[2]; else $arguments['src1'] = $matches[2];//$tmp[1]; } // search for src1 preg_match("/src2='([^']*?)'/i",$ntag,$tmp); //quotes version if( $tmp[1] == NULL ) { preg_match_all("/src2=([^,\s\]]*)/i",$ntag,$tmp); //non quotes version preg_match('/(.*)\/videos\/(.*)/i',$tmp[1][0],$matches); if ($matches[0] == NULL) $arguments['src2'] = $tmp[1][0]; else if ($matches[1] == NULL) { $arguments['src2'] = $matches[2];//$tmp[1][0]; } else { $arguments['src2'] = $matches[2]; } } else { preg_match('/(.*)\/videos\/(.*)/',$tmp[1],$matches); if ($matches[0] == NULL) $arguments['src2'] = $tmp[1]; elseif ($matches[1] == NULL) $arguments['src2'] = $matches[2]; else $arguments['src2'] = $matches[2];//$tmp[1]; } //search for splashend preg_match("/[\s]+splashend([\s]|])+/i",$ntag,$tmp); if (isset($tmp[0])){ $arguments['splashend'] = true; } else { preg_match("/splashend='([A-Za-z]*)'/i",$ntag,$tmp); if ( $tmp[1] == NULL ) preg_match("/splashend=([A-Za-z]*)/i",$ntag,$tmp); if (isset($tmp[1])) $arguments['splashend'] = $tmp[1]; } //search for controlbar preg_match("/[\s]+controlbar([\s]|])+/i",$ntag,$tmp); if (isset($tmp[0])){ $arguments['controlbar'] = true; } else { preg_match("/controlbar='([A-Za-z]*)'/i",$ntag,$tmp); if ( $tmp[1] == NULL ) preg_match("/controlbar=([A-Za-z]*)/i",$ntag,$tmp); if (isset($tmp[1])) $arguments['controlbar'] = $tmp[1]; } if (trim($media) != '') { // build new player $new_player = $fv_fp->build_min_player($media,$arguments); $content = str_replace($tag, $new_player['html'],$content); if (!empty($new_player['script'])) { $GLOBALS['fv_fp_scripts'] = $new_player['script']; } } } return $content; } function flowplayer_prepare_scripts() { global $fv_fp, $fv_wp_flowplayer_ver, $fv_wp_flowplayer_core_ver; // don't load script in Optimize Press 2 preview if( flowplayer::is_special_editor() ) { return; } if( isset($GLOBALS['fv_fp_scripts']) || $fv_fp->should_force_load_js() || isset( $_GET['fv_wp_flowplayer_check_template'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_GET['fv_wp_flowplayer_check_template'] ) ), 'fv_wp_flowplayer_check_template' ) ){ $aDependencies = array('jquery'); if( $fv_fp->should_force_load_js() || $fv_fp->load_tabs ) { wp_enqueue_script('jquery-ui-tabs', false, array('jquery','jquery-ui-core'), $fv_wp_flowplayer_ver, true); $aDependencies[] = 'jquery-ui-tabs'; } if( !$fv_fp->bCSSLoaded ) $fv_fp->css_enqueue(true); $sLogo = $fv_fp->_get_option('logo') ? $fv_fp->_get_option('logo') : ''; // Load base Freedom Video Player library $path = '/freedom-video-player/freedomplayer.min.js'; if( file_exists(dirname(__FILE__).'/../freedom-video-player/freedomplayer.js') ) { $path = '/freedom-video-player/freedomplayer.js'; } $version = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? filemtime( dirname(__FILE__).'/../'.$path ) : $fv_wp_flowplayer_core_ver; wp_enqueue_script( 'flowplayer', flowplayer::get_plugin_url().$path, $aDependencies, $version, true ); $aDependencies[] = 'flowplayer'; // Load modules if( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ) { $path = '/freedom-video-player/modules/fv-player.js'; wp_enqueue_script( 'fv-player', flowplayer::get_plugin_url().$path, $aDependencies, filemtime( dirname(__FILE__).'/../'.$path ), true ); $aDependencies[] = 'fv-player'; foreach( glob( dirname(dirname(__FILE__)).'/freedom-video-player/modules/*.module.js') as $filename ) { $path = '/freedom-video-player/modules/'.basename($filename); wp_enqueue_script( 'fv-player-'.basename($filename), flowplayer::get_plugin_url().$path, $aDependencies, filemtime( dirname(__FILE__).'/../'.$path ), true); } } else { wp_enqueue_script( 'fv-player', flowplayer::get_plugin_url().'/freedom-video-player/fv-player.min.js', $aDependencies, $fv_wp_flowplayer_ver, true ); } if( current_user_can('manage_options') && !$fv_fp->_get_option('disable_videochecker') && ( $fv_fp->_get_option('video_checker_agreement') || $fv_fp->_get_option('key_automatic') ) ) { wp_enqueue_script( 'fv-player-video-checker', flowplayer::get_plugin_url().'/js/video-checker.js', array('flowplayer'), $fv_wp_flowplayer_ver, true ); $aConf['video_checker'] = true; } if( $fv_fp->_get_option('ui_speed_increment') == 0.25){ $aConf['speeds'] = array( 0.25,0.5,0.75,1,1.25,1.5,1.75,2 ); }elseif( $fv_fp->_get_option('ui_speed_increment') == 0.1){ $aConf['speeds'] = array( 0.25,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2 ); }elseif( $fv_fp->_get_option('ui_speed_increment') == 0.5){ $aConf['speeds'] = array( 0.5,1,1.5,2 ); } $aConf['video_hash_links'] = empty($fv_fp->aCurArgs['linking']) ? $fv_fp->_get_option( 'ui_video_links' ) : $fv_fp->aCurArgs['linking'] === 'true'; if( apply_filters( 'fv_flowplayer_safety_resize', true) ) { $aConf['safety_resize'] = true; } if( $fv_fp->_get_option('cbox_compatibility') ) { $aConf['cbox_compatibility'] = true; } if( current_user_can('manage_options') && !$fv_fp->_get_option('disable_videochecker') ) { $aConf['video_checker_site'] = home_url(); } if( $sLogo ) $aConf['logo'] = $sLogo; if ( $fv_fp->_get_option( 'logo_over_video' ) ) $aConf['logo_over_video'] = true; // Used to restore volume, removed in JS if volume stored in browser localStorage $aConf['volume'] = floatval( $fv_fp->_get_option('volume') ); if( $aConf['volume'] > 1 ) { $aConf['volume'] = 1; } $aConf['default_volume'] = $aConf['volume']; if( $val = $fv_fp->_get_option('mobile_native_fullscreen') ) $aConf['mobile_native_fullscreen'] = $val; if( $val = $fv_fp->_get_option('mobile_force_fullscreen') ) $aConf['mobile_force_fullscreen'] = $val; if( $val = $fv_fp->_get_option('mobile_alternative_fullscreen') ) $aConf['mobile_alternative_fullscreen'] = $val; $aConf['mobile_landscape_fullscreen'] = true; if ( $fv_fp->_get_option('video_position_save_enable') ) { $aConf['video_position_save_enable'] = $fv_fp->_get_option('video_position_save_enable'); } if( is_user_logged_in() ) $aConf['is_logged_in'] = true; if ( current_user_can( 'edit_posts' ) ) { $aConf['is_logged_in_editor'] = true; } $aConf['sticky_video'] = $fv_fp->_get_option('sticky_video'); $aConf['sticky_place'] = $fv_fp->_get_option('sticky_place'); $aConf['sticky_min_width'] = intval( apply_filters( 'fv_player_sticky_desktop_min_width', 1020 ) ); global $post; if( $post && isset($post->ID) && $post->ID > 0 ) { if( get_post_meta($post->ID, 'fv_player_mobile_native_fullscreen', true) ) $aConf['mobile_native_fullscreen'] = true; if( get_post_meta($post->ID, 'fv_player_mobile_force_fullscreen', true) ) $aConf['mobile_force_fullscreen'] = true; } if( $fv_fp->should_force_load_js() || $fv_fp->load_hlsjs ) { wp_enqueue_script( 'flowplayer-hlsjs', flowplayer::get_plugin_url().'/freedom-video-player/hls.min.js', array('flowplayer'), '1.7.0-beta.1', true ); } $aConf['script_hls_js'] = flowplayer::get_plugin_url().'/freedom-video-player/hls.min.js?ver=1.7.0-beta.1'; $dashjs_version = '3.2.2-mod'; $fv_player_dashjs = 'fv-player-dashjs.min.js'; if( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ) $fv_player_dashjs = 'fv-player-dashjs.dev.js'; if( $fv_fp->should_force_load_js() || $fv_fp->load_dash ) { wp_enqueue_script( 'dashjs', flowplayer::get_plugin_url().'/freedom-video-player/dash.mediaplayer.min.js', array('flowplayer'), $dashjs_version, true ); wp_enqueue_script( 'fv-player-dash', flowplayer::get_plugin_url().'/freedom-video-player/'.$fv_player_dashjs, array('dashjs'), $fv_wp_flowplayer_ver, true ); } // Used by FV Player Pro in case Dash.js was not loaded for the page $aConf['script_dash_js'] = flowplayer::get_plugin_url().'/freedom-video-player/dash.mediaplayer.min.js?ver='.$dashjs_version; $aConf['script_dash_js_engine'] = flowplayer::get_plugin_url().'/freedom-video-player/'.$fv_player_dashjs.'?ver='.$fv_wp_flowplayer_ver; if( $fv_fp->should_force_load_js() || FV_Player_YouTube()->bYoutube || did_action('fv_player_extensions_admin_load_assets') ) { $youtube_js = 'fv-player-youtube.min.js'; $youtube_ver = $fv_wp_flowplayer_ver; if( defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ) { $youtube_js = 'fv-player-youtube.dev.js'; $youtube_ver = filemtime( dirname(__FILE__).'/../freedom-video-player/'.$youtube_js ); } wp_enqueue_script( 'fv-player-youtube', flowplayer::get_plugin_url().'/freedom-video-player/' . $youtube_js , array('flowplayer'), $youtube_ver, true ); } if( $fv_fp->_get_option('googleanalytics') ) { $aConf['fvanalytics'] = $fv_fp->_get_option('googleanalytics'); } if( $fv_fp->_get_option('matomo_domain') && $fv_fp->_get_option('matomo_site_id') ) { // take the domain name from Matomo Domain setting in case somebody entered full URL $matomo_domain = $fv_fp->_get_option('matomo_domain'); $parsed = wp_parse_url($matomo_domain); if( $parsed && !empty($parsed['host']) ) { $matomo_domain = $parsed['host']; if( !empty($parsed['path']) ) { $matomo_domain .= '/'.$parsed['path']; } } $aConf['matomo_domain'] = $matomo_domain; $aConf['matomo_site_id'] = $fv_fp->_get_option('matomo_site_id'); } if( $fv_fp->_get_option('ui_airplay') ) { $aConf['airplay'] = true; } if ( $fv_fp->_get_option('debug_log') ) { $aConf['debug_log'] = true; } $aConf['chromecast'] = false; // tell core Freedom Video Player and FV Player Pro <= 7.4.43.727 to not load Chromecast if( $fv_fp->_get_option('chromecast') ) { $aConf['chromecast'] = array( 'applicationId' => '908E271B' ); } if( $fv_fp->_get_option('hd_streaming') ) { $aConf['hd_streaming'] = true; } if( $fv_fp->_get_option('multiple_playback') ) { $aConf['multiple_playback'] = true; } if( $fv_fp->_get_option('disable_localstorage') ) { $aConf['disable_localstorage'] = true; } if( $fv_fp->_get_option('autoplay_preload') && $fv_fp->_get_option('autoplay_preload') != 'false' ) { $aConf['autoplay_preload'] = $fv_fp->_get_option('autoplay_preload'); } if( $fv_fp->_get_option('youtube_browser_chrome') ) { $aConf['youtube_browser_chrome'] = $fv_fp->_get_option('youtube_browser_chrome'); } $aConf['hlsjs'] = array( 'startLevel' => -1, 'fragLoadingMaxRetry' => 3, 'levelLoadingMaxRetry' => 3, 'capLevelToPlayerSize' => true, 'use_for_safari' => class_exists( 'FV_Player_DRM' ), ); // The above HLS.js config doesn't work well on Chrome and Firefox, so we detect that in JS and use this config for it instead. Todo: make this a per-video thing if( class_exists('FV_Player_Pro_DaCast') ) { $aConf['dacast_hlsjs'] = array( 'autoLevelEnabled' => false // disable ABR. If you set startLevel or capLevelToPlayerSize it will be enabled again. So this way everybody on desktop gets top quality and they have to switch to lower each time. ); } if( is_admin() ) $aConf['wpadmin'] = true; // Is it the wp-admin -> FV Player -> Settings screen? if ( did_action( 'admin_head-fv-player_page_fvplayer' ) ) { $aConf['skin_preview'] = true; } $aConf['msg'] = array( 'click_to_unmute' => __('Click to unmute', 'fv-player' ), ); $aConf = apply_filters( 'fv_flowplayer_conf', $aConf ); $aLocalize = array( 'ajaxurl' => site_url() . '/wp-admin/admin-ajax.php', 'nonce' => wp_create_nonce( 'fv_player_frontend' ), 'email_signup_nonce' => wp_create_nonce( 'fv_player_email_signup' ), 'video_position_save_nonce' => wp_create_nonce( 'fv_player_video_position_save' ), ); if ( is_user_logged_in() ) { $aLocalize['is_user_logged_in'] = true; $aLocalize['audio_name'] = get_user_meta( get_current_user_id(), 'fv_player_audio_name', true ); $aLocalize['audio_lang'] = get_user_meta( get_current_user_id(), 'fv_player_audio_lang', true ); } wp_localize_script( 'flowplayer', 'fv_flowplayer_conf', $aConf ); if( current_user_can('manage_options') ) { $aLocalize['admin_input'] = true; $aLocalize['admin_js_test'] = true; } if( current_user_can('edit_posts') ) { $aLocalize['user_edit'] = true; } wp_localize_script( 'flowplayer', 'fv_player', $aLocalize ); wp_localize_script( 'flowplayer', 'fv_flowplayer_translations', fv_flowplayer_get_js_translations()); wp_localize_script( 'flowplayer', 'fv_flowplayer_playlists', array() ); // has to be defined for FV Player Pro 0.6.20 and such if( isset($GLOBALS['fv_fp_scripts']) && count($GLOBALS['fv_fp_scripts']) > 0 ) { foreach( $GLOBALS['fv_fp_scripts'] AS $sKey => $aScripts ) { wp_localize_script( 'flowplayer', $sKey.'_array', $aScripts ); } } } FV_Player_lightbox()->maybe_load(); } /** * Prints flowplayer javascript content to the bottom of the page. */ function flowplayer_display_scripts() { if( flowplayer::is_special_editor() ) { return; } if( is_user_logged_in() || isset($_GET['fv_wp_flowplayer_check_template']) ) { echo "\n\n\n"; } } /** * This is the template tag. Use the standard Flowplayer shortcodes */ function flowplayer($shortcode) { echo apply_filters('the_content',$shortcode); } /* Make sure our div won't be wrapped in any P tag and that html attributes don't break the shortcode */ function fv_flowplayer_the_content( $c ) { if( flowplayer::is_special_editor() ) { return $c; } $c = preg_replace( '!]*?>(\[(?:fvplayer|flowplayer).*?[^\\\]\])
!', "\n".'$1'."\n", $c ); $c = preg_replace_callback( '!\[(?:fvplayer|flowplayer).*?[^\\\]\]!', 'fv_flowplayer_shortfcode_fix_attrs', $c ); return $c; } add_filter( 'the_content', 'fv_flowplayer_the_content', 0 ); function fv_flowplayer_shortfcode_fix_attrs( $aMatch ) { $aMatch[0] = preg_replace_callback( '!(?:ad|popup)="(.*?[^\\\])"!', 'fv_flowplayer_shortfcode_fix_attr', $aMatch[0] ); return $aMatch[0]; } function fv_flowplayer_shortfcode_fix_attr( $aMatch ) { $aMatch[0] = str_replace( $aMatch[1], ''.base64_encode($aMatch[1]), $aMatch[0] ); return $aMatch[0]; } /* Handle attachment pages which contain videos */ function fv_flowplayer_attachment_page_video( $c ) { global $post; if( stripos($post->post_mime_type, 'video/') !== 0 && stripos($post->post_mime_type, 'audio/') !== 0 ) { return $c; } if( !$src = wp_get_attachment_url($post->ID) ) { return $c; } $meta = get_post_meta( $post->ID, '_wp_attachment_metadata', true ); $size = (isset($meta['width']) && isset($meta['height']) && intval($meta['width'])>0 && intval($meta['height'])>0 ) ? ' width="'.intval($meta['width']).'" height="'.intval($meta['height']).'"' : false; $shortcode = '[fvplayer src="'.$src.'"'.$size.']'; $c = preg_replace( '~