From d34281a65c429aa1c46955cf5d2ec73ced64dfc4 Mon Sep 17 00:00:00 2001 From: Michal Date: Wed, 31 May 2023 11:52:15 +0200 Subject: [PATCH 01/32] conversion: refactor use abstract iteration & html build --- models/conversion/conversion-base.class.php | 97 +++--------------- models/conversion/shortcode2DB.class.php | 107 +++++++++++++++++++- 2 files changed, 118 insertions(+), 86 deletions(-) diff --git a/models/conversion/conversion-base.class.php b/models/conversion/conversion-base.class.php index 89b13ca64..45e8c31d7 100644 --- a/models/conversion/conversion-base.class.php +++ b/models/conversion/conversion-base.class.php @@ -9,6 +9,7 @@ abstract class FV_Player_Conversion_Base { protected $slug = 'conversion-slug'; protected $screen; protected $help; + protected $screen_fields = array(); abstract function convert_one($post); @@ -18,6 +19,10 @@ abstract function get_count(); abstract function conversion_button(); + abstract function iterate_data( $data ); + + abstract function build_output_html( $data , $percent_done); + function __construct( $args ) { $this->title = $args['title']; $this->help = $args['help']; @@ -29,9 +34,6 @@ function __construct( $args ) { add_action( 'wp_ajax_'. $this->screen, array( $this, 'ajax_convert') ); add_action( 'fv_player_conversion_buttons', array( $this, 'conversion_button') ); - if( isset($_GET['fv-conversion-export']) && !empty($_GET['page']) && $_GET['page'] === $this->screen ) { - add_action('admin_init', array( $this, 'csv_export' ) ); - } } function admin_page() { @@ -41,15 +43,12 @@ function admin_page() { function ajax_convert() { if ( current_user_can( 'install_plugins' ) && check_ajax_referer( $this->screen ) ) { - if( function_exists( 'FV_Player_Pro' ) ) { // takes too long to save if not removed remove_filter( 'content_save_pre', array( FV_Player_Pro(), 'save_post' ), 10 ); } - $conversions_output = array(); $convert_error = false; - $html = array(); $offset = intval($_POST['offset']); $offset = 0 + intval($_POST['offset2']) + $offset; @@ -59,37 +58,17 @@ function ajax_convert() { $total = $this->get_count(); - foreach( $posts AS $post ) { - $result = $this->convert_one($post); - // mark post if conversion failed - if( !empty( $result['errors'] ) ) { - update_post_meta( $post->ID, '_fv_player_' . $this->slug . '_failed', $result['errors'] ); - $convert_error = true; - } else { - if( $result['content_updated'] ) { - // no problem, unmark - delete_post_meta( $post->ID, '_fv_player_' . $this->slug . '_failed' ); - } - } - - $conversions_output = array_merge( $conversions_output, $result['output_data'] ); + // iterate data + $result = $this->iterate_data( $posts ); - if( $this->is_live() && $result['content_updated'] ) { - wp_update_post( array( 'ID' => $post->ID, 'post_content' => $result['new_content'] ) ); - } - } + $convert_error = $result['convert_error']; + $conversions_output = $result['conversions_output']; $percent_done = $total > 0 ? round ( (($offset + $limit) / $total) * 100 ) : 0; $left = $total - ($offset + $limit); // build html output - foreach( $conversions_output as $output_data ) { - $html[] = " #". $output_data['ID'] . "". $output_data['title'] . "" . $output_data['type'] . "". $output_data['shortcode'] . "" . $output_data['output'] . "" . $output_data['error'] . ""; - } - - if( empty($html) && $percent_done == 0 ) { - $html[] = "No matching players found."; - } + $html = $this->build_output_html( $conversions_output, $percent_done ); // response echo json_encode( @@ -105,47 +84,6 @@ function ajax_convert() { die(); } - function csv_export() { - if( !current_user_can('install_plugins') ) return; - - global $wpdb; - - $filename = $this->slug . '-export-' . date('Y-m-d') . '.csv'; - - header('Content-type: text/csv'); - header("Content-Disposition: attachment; filename=$filename"); - header("Pragma: no-cache"); - header("Expires: 0"); - - $meta_key = '_fv_player_' . $this->slug . '_failed'; - - $sql = $wpdb->prepare( "SELECT {$wpdb->postmeta}.meta_value FROM {$wpdb->postmeta} JOIN {$wpdb->posts} ON {$wpdb->postmeta}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->postmeta}.meta_key = '%s' ORDER BY {$wpdb->posts}.post_date_gmt DESC ", $meta_key ); - - $results = $wpdb->get_col( $sql ); - - if( !empty( $results ) ) { - $fp = fopen('php://output', 'wb'); - - $header = array('ID','Title','Post-Link','Edit-Link','Shortcode','Message'); - - fputcsv($fp, $header); - - foreach( $results as $result ) { - $unserialized = unserialize( $result ); - - foreach( $unserialized as $row ) { - $row['post_link'] = htmlspecialchars_decode( $row['post_link'] ); - $row['post_edit'] = htmlspecialchars_decode( $row['post_edit'] ); - fputcsv($fp, $row); - } - } - - fclose($fp); - } - - die(); - } - function conversion_screen() { global $fv_wp_flowplayer_ver; wp_enqueue_script('fv-player-convertor', flowplayer::get_plugin_url().'/js/admin-convertor.js', array('jquery'), filemtime( dirname(__FILE__).'/../../js/admin-convertor.js' ) ); @@ -172,7 +110,7 @@ function conversion_screen() { help); ?>

- + @@ -190,12 +128,9 @@ function conversion_screen() { - - - - - - + screen_fields as $field ) : ?> + + @@ -216,9 +151,9 @@ function conversion_screen() { set_live ; } -} \ No newline at end of file +} diff --git a/models/conversion/shortcode2DB.class.php b/models/conversion/shortcode2DB.class.php index 84d09d5d4..2c7224a44 100644 --- a/models/conversion/shortcode2DB.class.php +++ b/models/conversion/shortcode2DB.class.php @@ -50,6 +50,19 @@ function __construct() { ); $this->supported_atts = array_merge( $this->supported_video_atts, $this->supported_player_atts ); + + $this->screen_fields = array( + 'ID', + 'Title', + 'Post Type', + 'Shortcode', + 'Result', + 'Error' + ); + + if( isset($_GET['fv-conversion-export']) && !empty($_GET['page']) && $_GET['page'] === $this->screen ) { + add_action('admin_init', array( $this, 'csv_export' ) ); + } } /** @@ -226,7 +239,7 @@ function worker( $shortcode, $post, $new_content, $meta_key = false ) { $video_index = 0; $import_video_atts[$video_index] = array(); // add video atts - foreach( $this->supported_video_atts as $video_att ) { + foreach( $this->supported_video_atts as $video_att ) { if( isset( $import_atts[$video_att] ) ) { $import_video_atts[$video_index][$video_att] = $import_atts[$video_att]; } @@ -334,7 +347,7 @@ function worker( $shortcode, $post, $new_content, $meta_key = false ) { } else { $import_player_atts[$player_att] = $import_atts[$player_att]; } - + } else if(strcmp( $player_att, 'speed' ) == 0) { // subtitles if( $import_atts[$player_att] == 'buttons' ) { $import_player_atts[$player_att] = 'yes'; @@ -349,7 +362,7 @@ function worker( $shortcode, $post, $new_content, $meta_key = false ) { } // add metadata - $import_player_atts['meta'] = array( + $import_player_atts['meta'] = array( array( 'meta_key' => 'post_id', 'meta_value' => $post->ID @@ -406,7 +419,7 @@ function worker( $shortcode, $post, $new_content, $meta_key = false ) { $output_msg = "Would create new FV Player"; } } - + $type = $post->post_type; if( $meta_key ) { $type .= '
meta_key: '.$meta_key.''; @@ -427,7 +440,91 @@ function worker( $shortcode, $post, $new_content, $meta_key = false ) { ); } + function build_output_html($data, $percent_done) { + $html = array(); + + foreach( $data as $output_data ) { + $html[] = ""; + } + + if( empty($html) && $percent_done == 0 ) { + $html[] = ""; + } + + return $html; + } + + function iterate_data($data) { + $conversions_output = array(); + + foreach( $data AS $post ) { + $result = $this->convert_one($post); + // mark post if conversion failed + if( !empty( $result['errors'] ) ) { + update_post_meta( $post->ID, '_fv_player_' . $this->slug . '_failed', $result['errors'] ); + $convert_error = true; + } else { + if( $result['content_updated'] ) { + // no problem, unmark + delete_post_meta( $post->ID, '_fv_player_' . $this->slug . '_failed' ); + } + } + + $conversions_output = array_merge( $conversions_output, $result['output_data'] ); + + if( $this->is_live() && $result['content_updated'] ) { + wp_update_post( array( 'ID' => $post->ID, 'post_content' => $result['new_content'] ) ); + } + } + + return array( + 'convert_error' => $convert_error, + 'conversions_output' => $conversions_output + ); + } + + function csv_export() { + if( !current_user_can('install_plugins') ) return; + + global $wpdb; + + $filename = $this->slug . '-export-' . date('Y-m-d') . '.csv'; + + header('Content-type: text/csv'); + header("Content-Disposition: attachment; filename=$filename"); + header("Pragma: no-cache"); + header("Expires: 0"); + + $meta_key = '_fv_player_' . $this->slug . '_failed'; + + $sql = $wpdb->prepare( "SELECT {$wpdb->postmeta}.meta_value FROM {$wpdb->postmeta} JOIN {$wpdb->posts} ON {$wpdb->postmeta}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->postmeta}.meta_key = '%s' ORDER BY {$wpdb->posts}.post_date_gmt DESC ", $meta_key ); + + $results = $wpdb->get_col( $sql ); + + if( !empty( $results ) ) { + $fp = fopen('php://output', 'wb'); + + $header = array('ID','Title','Post-Link','Edit-Link','Shortcode','Message'); + + fputcsv($fp, $header); + + foreach( $results as $result ) { + $unserialized = unserialize( $result ); + + foreach( $unserialized as $row ) { + $row['post_link'] = htmlspecialchars_decode( $row['post_link'] ); + $row['post_edit'] = htmlspecialchars_decode( $row['post_edit'] ); + fputcsv($fp, $row); + } + } + + fclose($fp); + } + + die(); + } + } global $FV_Player_Shortcode2Database_Conversion; -$FV_Player_Shortcode2Database_Conversion = new FV_Player_Shortcode2Database_Conversion; \ No newline at end of file +$FV_Player_Shortcode2Database_Conversion = new FV_Player_Shortcode2Database_Conversion; From 03c93ea8714846e25ee0df2e18fc874f3cab4333 Mon Sep 17 00:00:00 2001 From: Michal Date: Wed, 31 May 2023 11:55:34 +0200 Subject: [PATCH 02/32] conversion: use generic name function --- models/conversion/conversion-base.class.php | 4 ++-- models/conversion/shortcode2DB.class.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/models/conversion/conversion-base.class.php b/models/conversion/conversion-base.class.php index 45e8c31d7..e60b2e00c 100644 --- a/models/conversion/conversion-base.class.php +++ b/models/conversion/conversion-base.class.php @@ -13,7 +13,7 @@ abstract class FV_Player_Conversion_Base { abstract function convert_one($post); - abstract function get_posts_with_shortcode( $offset, $limit ); + abstract function get_items( $offset, $limit ); abstract function get_count(); @@ -54,7 +54,7 @@ function ajax_convert() { $offset = 0 + intval($_POST['offset2']) + $offset; $limit = intval($_POST['limit']); - $posts = $this->get_posts_with_shortcode( $offset, $limit ); + $posts = $this->get_items( $offset, $limit ); $total = $this->get_count(); diff --git a/models/conversion/shortcode2DB.class.php b/models/conversion/shortcode2DB.class.php index 2c7224a44..7a0c47a7a 100644 --- a/models/conversion/shortcode2DB.class.php +++ b/models/conversion/shortcode2DB.class.php @@ -80,7 +80,7 @@ function get_count() { * * @return object|null $result */ - function get_posts_with_shortcode($offset, $limit) { + function get_items($offset, $limit) { global $wpdb; // Each row is the matching wp_posts row or wp_posts row with matching meta_value From 264f2dd35cd5c9b287a95e8287033798386bd5bc Mon Sep 17 00:00:00 2001 From: Michal Date: Wed, 31 May 2023 12:10:06 +0200 Subject: [PATCH 03/32] conversion: implement get_count in abstract class --- models/conversion/conversion-base.class.php | 27 +++++++++++++++++++-- models/conversion/shortcode2DB.class.php | 10 -------- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/models/conversion/conversion-base.class.php b/models/conversion/conversion-base.class.php index e60b2e00c..a27d85bba 100644 --- a/models/conversion/conversion-base.class.php +++ b/models/conversion/conversion-base.class.php @@ -15,8 +15,6 @@ abstract function convert_one($post); abstract function get_items( $offset, $limit ); - abstract function get_count(); - abstract function conversion_button(); abstract function iterate_data( $data ); @@ -41,6 +39,21 @@ function admin_page() { remove_submenu_page( 'fv_player', $this->screen ); } + /** + * Count old data + * + * @return int $count + */ + function get_count() { + global $wpdb; + return $wpdb->get_var( "SELECT FOUND_ROWS()" ); + } + + /** + * Convert data to new format using ajax + * + * @return void + */ function ajax_convert() { if ( current_user_can( 'install_plugins' ) && check_ajax_referer( $this->screen ) ) { if( function_exists( 'FV_Player_Pro' ) ) { @@ -84,6 +97,11 @@ function ajax_convert() { die(); } + /** + * Create admin page for conversion screen + * + * @return void + */ function conversion_screen() { global $fv_wp_flowplayer_ver; wp_enqueue_script('fv-player-convertor', flowplayer::get_plugin_url().'/js/admin-convertor.js', array('jquery'), filemtime( dirname(__FILE__).'/../../js/admin-convertor.js' ) ); @@ -152,6 +170,11 @@ function conversion_screen() { set_live ; } diff --git a/models/conversion/shortcode2DB.class.php b/models/conversion/shortcode2DB.class.php index 7a0c47a7a..21c23f7a0 100644 --- a/models/conversion/shortcode2DB.class.php +++ b/models/conversion/shortcode2DB.class.php @@ -65,16 +65,6 @@ function __construct() { } } - /** - * Count posts with old shortcode - * - * @return int $count - */ - function get_count() { - global $wpdb; - return $wpdb->get_var( "SELECT FOUND_ROWS()" ); - } - /** * Get posts with [fvplayer/flowplayer src...] shortcodes * From 2a224aa867c08f81fb311bc441da49407e12a982 Mon Sep 17 00:00:00 2001 From: Michal Date: Wed, 31 May 2023 12:32:09 +0200 Subject: [PATCH 04/32] conversion: rename posts to items in base class --- models/conversion/conversion-base.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/models/conversion/conversion-base.class.php b/models/conversion/conversion-base.class.php index a27d85bba..bfb2fd9cd 100644 --- a/models/conversion/conversion-base.class.php +++ b/models/conversion/conversion-base.class.php @@ -28,7 +28,7 @@ function __construct( $args ) { $this->matchers = $args['matchers']; $this->screen = 'fv_player_conversion_' . $this->slug; - add_action('admin_menu', array( $this, 'admin_page' ) ); + add_action( 'admin_menu', array( $this, 'admin_page' ) ); add_action( 'wp_ajax_'. $this->screen, array( $this, 'ajax_convert') ); add_action( 'fv_player_conversion_buttons', array( $this, 'conversion_button') ); @@ -67,12 +67,12 @@ function ajax_convert() { $offset = 0 + intval($_POST['offset2']) + $offset; $limit = intval($_POST['limit']); - $posts = $this->get_items( $offset, $limit ); + $items = $this->get_items( $offset, $limit ); $total = $this->get_count(); // iterate data - $result = $this->iterate_data( $posts ); + $result = $this->iterate_data( $items ); $convert_error = $result['convert_error']; $conversions_output = $result['conversions_output']; From 138bff7c7666066e16044f3c95e7cbc95e1dfc74 Mon Sep 17 00:00:00 2001 From: Michal Date: Wed, 31 May 2023 14:23:09 +0200 Subject: [PATCH 05/32] conversion: init convert_error --- models/conversion/shortcode2DB.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/models/conversion/shortcode2DB.class.php b/models/conversion/shortcode2DB.class.php index 21c23f7a0..8e780cbd7 100644 --- a/models/conversion/shortcode2DB.class.php +++ b/models/conversion/shortcode2DB.class.php @@ -446,6 +446,7 @@ function build_output_html($data, $percent_done) { function iterate_data($data) { $conversions_output = array(); + $convert_error = false; foreach( $data AS $post ) { $result = $this->convert_one($post); From f6bdb4c435bb1b65988b65bb9fcffe808f02953a Mon Sep 17 00:00:00 2001 From: Michal Date: Wed, 31 May 2023 14:23:29 +0200 Subject: [PATCH 06/32] conversion: ajax limit add TODO --- js/admin-convertor.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/js/admin-convertor.js b/js/admin-convertor.js index e4a0d6024..8ab90498f 100644 --- a/js/admin-convertor.js +++ b/js/admin-convertor.js @@ -72,7 +72,7 @@ $.fn.Progressor = function(args) { var opts = $.extend({ action: 'Action', cancel: 'Cancel', - limit: 1, // limit jobs count + limit: 1, // limit jobs count, TODO: increase to 10 nonce: '', }, args); @@ -83,7 +83,7 @@ $.fn.Progressor = function(args) { var messages = $('#messages'); var original = $(opts.start).val(); var button; - + $(opts.start).click(function() { button = this; @@ -108,7 +108,7 @@ $.fn.Progressor = function(args) { $('#loading').show(); $(wrapper).fadeIn(); $('#progress').css('width', '0px'); - + // Now kick-start a timer to perform the progressor setTimeout(timer, 0); } @@ -121,4 +121,4 @@ $.fn.Progressor = function(args) { function showAlert() { alert('There is an error') -} \ No newline at end of file +} From 44409b572c98f75504a5a05acc93afacdc004b0c Mon Sep 17 00:00:00 2001 From: Michal Date: Wed, 31 May 2023 16:58:15 +0200 Subject: [PATCH 07/32] conversion: implement conversion of meta positions to new table - WIP --- flowplayer.php | 3 +- models/conversion/conversion-base.class.php | 5 + models/conversion/positionsMeta2Table.php | 295 ++++++++++++++++++++ 3 files changed, 302 insertions(+), 1 deletion(-) create mode 100644 models/conversion/positionsMeta2Table.php diff --git a/flowplayer.php b/flowplayer.php index 560516edf..bf5722f73 100644 --- a/flowplayer.php +++ b/flowplayer.php @@ -96,7 +96,7 @@ if( version_compare(phpversion(),'5.5.0') != -1 ) { include_once(dirname( __FILE__ ) . '/models/media-browser.php'); } - + if( version_compare(phpversion(),'7.3.5') != -1 ) { include_once(dirname( __FILE__ ) . '/models/media-browser-s3.php'); @@ -106,6 +106,7 @@ include_once(dirname( __FILE__ ). '/models/conversion/conversion-base.class.php'); include_once(dirname( __FILE__ ). '/models/conversion/shortcode2DB.class.php'); + include_once(dirname( __FILE__ ). '/models/conversion/positionsMeta2Table.php'); include_once(dirname( __FILE__ ) . '/models/conversion.php'); include_once( dirname( __FILE__ ) .'/models/splash-download.php'); diff --git a/models/conversion/conversion-base.class.php b/models/conversion/conversion-base.class.php index bfb2fd9cd..ecc0aa683 100644 --- a/models/conversion/conversion-base.class.php +++ b/models/conversion/conversion-base.class.php @@ -2,6 +2,11 @@ abstract class FV_Player_Conversion_Base { + /** + * If set to true, it will convert data to db + * + * @var boolean + */ public $set_live = false; protected $matchers = array(); diff --git a/models/conversion/positionsMeta2Table.php b/models/conversion/positionsMeta2Table.php new file mode 100644 index 000000000..aea400677 --- /dev/null +++ b/models/conversion/positionsMeta2Table.php @@ -0,0 +1,295 @@ + 'FV Player PositionsMeta2Table Conversion', + 'slug' => 'positions_meta2table', + 'matchers' => array( + + ), + 'help' => __("This converts position values from usermeta to fv_player_user_video_positions table", 'fv-wordpress-flowplayer') + ) ); + + $this->screen_fields = array( + 'ID', + 'Name', + 'Error' + ); + + } + + /** + * Override parent method + * + * @return int + */ + function get_count() { + global $wpdb; + return (int) $wpdb->get_var( "SELECT COUNT(*) AS count FROM `$wpdb->usermeta` WHERE meta_key LIKE 'fv_wp_flowplayer_%'" ); + } + + function get_items( $offset, $limit ) { + global $wpdb; + + $meta_data = $wpdb->get_results( "SELECT * FROM `$wpdb->usermeta` WHERE meta_key LIKE 'fv_wp_flowplayer_%' LIMIT {$offset},{$limit}" ); + + return $meta_data; + } + + function convert_one($meta) { + $output_data = array(); // output for html + $errors = array(); // all errors for export + + // get meta data + $meta_key = $meta->meta_key; + $meta_value = $meta->meta_value; + $user_id = $meta->user_id; + + $type = ''; + + if( strpos($meta_key, 'fv_wp_flowplayer_position') !== false ) { // last + $type = 'last_postion'; + } else if ( strpos($meta_key, 'fv_wp_flowplayer_saw') !== false ) { // finished + $type = 'finished'; + } else if ( strpos($meta_key, 'fv_wp_flowplayer_top_position') !== false ) { // top + $type = 'top_position'; + } else if ( strpos($meta_key, 'fv_wp_flowplayer_player_playlist') !== false ) { // playlist + $type = 'playlist'; + } + + if( $type == 'playlist' ) { + preg_match('/fv_wp_flowplayer_player_playlist_(\d+)/', $meta_key, $matches); + if( isset( $matches[1] ) ) { + $playlist_id = $matches[1]; + + if( $this->is_live() ) { + + // check if its db video or external + $row_exitst = $this->position_row_exists( $user_id, $playlist_id, 'playlist' ); + + $result = $this->insert_update_playlist_row( $user_id, $playlist_id, $meta_value, $row_exitst ); + + if( $result ) { + $output_data[] = array( + 'ID' => $user_id, + 'Name' => $meta_key + ); + } else { + $errors[] = array( + 'ID' => $user_id, + 'Name' => $meta_key + ); + } + + } else { + $output_data[] = array( + 'ID' => $user_id, + 'Name' => $meta_key + ); + } + } else { + // failed to get playlist id + $errors[] = array( + 'ID' => $user_id, + 'Name' => $meta_key + ); + } + + } else { + preg_match('/fv_wp_flowplayer_\w+_(\w+)/', $meta_key, $matches); + if( isset( $matches[1] ) ) { + $video_id = $matches[1]; + + $video_exitst = $this->video_exists( $video_id ); + $row_exitst = $this->position_row_exists( $user_id, $video_id, 'position' ); + + if( $this->is_live() ) { + $result = $this->insert_update_video_row( $user_id, $video_id, $type, $meta_value, $row_exitst, $video_exitst ); + + if( $result ) { + $output_data[] = array( + 'ID' => $user_id, + 'Name' => $meta_key + ); + } else { + $errors[] = array( + 'ID' => $user_id, + 'Name' => $meta_key + ); + } + + } else { + $output_data[] = array( + 'ID' => $user_id, + 'Name' => $meta_key + ); + } + + } else { + // failed to get video id + $errors[] = array( + 'ID' => $user_id, + 'Name' => $meta_key + ); + } + + } + + return array( + 'output_data' => $output_data, + 'errors' => $errors + ); + + } + + function insert_update_video_row( $user_id, $video_id, $type, $value, $row_exitst, $video_exitst ) { + global $wpdb; + + if( !$video_exitst ) { + $legacy_id = $video_id; + $video_id = 0; + } else { + $legacy_id = ''; + } + + if( $row_exitst ) { + $res = $wpdb->update( + $wpdb->prefix . 'fv_player_user_video_positions', + array( + $type => $value + ), + array( + 'user_id' => $user_id, + 'video_id' => $video_id, + 'legacy_video_id' => $legacy_id + ) + ); + } else { + $res = $wpdb->insert( + $wpdb->prefix . 'fv_player_user_video_positions', + array( + $type => $value, + 'user_id' => $user_id, + 'video_id' => $video_id, + 'position' => $value, + 'legacy_video_id' => $legacy_id + ) + ); + } + + return $res; + } + + function insert_update_playlist_row( $user_id, $playlist_id, $value, $exitst ) { + global $wpdb; + + if( $exitst ) { + $res = $wpdb->update( + $wpdb->prefix . 'player_user_playlist_positions', + array( + 'position' => $value + ), + array( + 'user_id' => $user_id, + 'player_id' => $playlist_id + ) + ); + } else { + $res = $wpdb->insert( + $wpdb->prefix . 'player_user_playlist_positions', + array( + 'user_id' => $user_id, + 'player_id' => $playlist_id, + 'position' => $value + ) + ); + } + + return $res; + } + + function video_exists( $video_id ) { + global $wpdb; + + $row = $wpdb->get_row( "SELECT * FROM `{$wpdb->prefix}fv_player_videos` WHERE id = {$video_id}" ); + + return $row; + } + + function position_row_exists( $user_id, $id, $type, $video_exitst = false ) { + global $wpdb; + + if( $type == 'position' ) { + + if( $video_exitst ) { + $row = $wpdb->get_row( "SELECT * FROM `{$wpdb->prefix}fv_player_user_video_positions` WHERE user_id = {$user_id} AND video_id = {$id}" ); + } else { + $row = $wpdb->get_row( "SELECT * FROM `{$wpdb->prefix}fv_player_user_video_positions` WHERE user_id = {$user_id} AND legacy_video_id = {$id}" ); + } + + } + + if( $type == 'playlist' ) { + $row = $wpdb->get_row( "SELECT * FROM `{$wpdb->prefix}player_user_playlist_positions` WHERE user_id = {$user_id} AND player_id = {$id}" ); + } + + return $row; + } + + function conversion_button() { + ?> + + + + + convert_one( $meta ); + + if( !empty($result['errors']) ) { + $convert_error = true; + } + + $conversions_output = array_merge( $conversions_output, $result['output_data'] ); + } + + return array( + 'convert_error' => $convert_error, + 'conversions_output' => $conversions_output + ); + } + + function build_output_html( $data, $percent_done ) { + $html = array(); + + foreach( $data as $output_data ) { + $html[] = ""; + } + + if( empty($html) && $percent_done == 0 ) { + $html[] = ""; + } + + return $html; + } + +} + +global $FV_Player_Positions_Meta2Table_Conversion; +$FV_Player_Positions_Meta2Table_Conversion = new FV_Player_Positions_Meta2Table_Conversion; From 080c9d9cb8ea311d88a4c559190635d0e6045206 Mon Sep 17 00:00:00 2001 From: Michal Date: Thu, 1 Jun 2023 11:09:41 +0200 Subject: [PATCH 08/32] conversion: table fix, output, error --- models/conversion/positionsMeta2Table.php | 108 +++++++++++++++++++--- 1 file changed, 93 insertions(+), 15 deletions(-) diff --git a/models/conversion/positionsMeta2Table.php b/models/conversion/positionsMeta2Table.php index aea400677..0b151a7d1 100644 --- a/models/conversion/positionsMeta2Table.php +++ b/models/conversion/positionsMeta2Table.php @@ -19,7 +19,8 @@ function __construct() { $this->screen_fields = array( 'ID', 'Name', - 'Error' + 'Result', + 'Error', ); } @@ -78,9 +79,18 @@ function convert_one($meta) { if( $result ) { $output_data[] = array( 'ID' => $user_id, - 'Name' => $meta_key + 'Name' => $meta_key, + 'output' => 'Playlist position updated', + 'error' => '' ); - } else { + } else { // failed to update + $output_data[] = array( + 'ID' => $user_id, + 'Name' => $meta_key, + 'output' => 'Playlist position failed to update', + 'error' => 'Failed to update playlist position' + ); + $errors[] = array( 'ID' => $user_id, 'Name' => $meta_key @@ -90,11 +100,20 @@ function convert_one($meta) { } else { $output_data[] = array( 'ID' => $user_id, - 'Name' => $meta_key + 'Name' => $meta_key, + 'output' => 'Playlist position updated', + 'error' => '' ); } } else { // failed to get playlist id + $output_data[] = array( + 'ID' => $user_id, + 'Name' => $meta_key, + 'output' => 'Playlist position failed to update', + 'error' => 'Cannot get playlist id' + ); + $errors[] = array( 'ID' => $user_id, 'Name' => $meta_key @@ -106,6 +125,7 @@ function convert_one($meta) { if( isset( $matches[1] ) ) { $video_id = $matches[1]; + // check if video exitst in db $video_exitst = $this->video_exists( $video_id ); $row_exitst = $this->position_row_exists( $user_id, $video_id, 'position' ); @@ -115,9 +135,18 @@ function convert_one($meta) { if( $result ) { $output_data[] = array( 'ID' => $user_id, - 'Name' => $meta_key + 'Name' => $meta_key, + 'output' => 'Video position updated', + 'error' => '' ); } else { + $output_data[] = array( + 'ID' => $user_id, + 'Name' => $meta_key, + 'output' => 'Video position failed to update', + 'error' => 'Failed to update position' + ); + $errors[] = array( 'ID' => $user_id, 'Name' => $meta_key @@ -127,11 +156,20 @@ function convert_one($meta) { } else { $output_data[] = array( 'ID' => $user_id, - 'Name' => $meta_key + 'Name' => $meta_key, + 'output' => 'Video position updated', + 'error' => '' ); } } else { + $output_data[] = array( + 'ID' => $user_id, + 'Name' => $meta_key, + 'output' => 'Video position failed to update', + 'error' => 'Cannot get video id' + ); + // failed to get video id $errors[] = array( 'ID' => $user_id, @@ -148,14 +186,27 @@ function convert_one($meta) { } + /** + * Insert or update video row + * + * @param int $user_id + * @param int $video_id + * @param string $type + * @param int $value + * @param boolean $row_exitst + * @param boolean $video_exitst + * + * @return int|false $res result of insert or update + */ function insert_update_video_row( $user_id, $video_id, $type, $value, $row_exitst, $video_exitst ) { global $wpdb; - if( !$video_exitst ) { + if( !$video_exitst ) { // non db video $legacy_id = $video_id; $video_id = 0; - } else { + } else { // db video $legacy_id = ''; + $video_id = intval($video_id); } if( $row_exitst ) { @@ -186,12 +237,22 @@ function insert_update_video_row( $user_id, $video_id, $type, $value, $row_exits return $res; } + /** + * Insert or update playlist row + * + * @param int $user_id + * @param int $playlist_id + * @param int $value + * @param boolean $exitst + * + * @return int|false $res result of insert or update + */ function insert_update_playlist_row( $user_id, $playlist_id, $value, $exitst ) { global $wpdb; if( $exitst ) { $res = $wpdb->update( - $wpdb->prefix . 'player_user_playlist_positions', + $wpdb->prefix . 'fv_player_user_playlist_positions', array( 'position' => $value ), @@ -202,7 +263,7 @@ function insert_update_playlist_row( $user_id, $playlist_id, $value, $exitst ) { ); } else { $res = $wpdb->insert( - $wpdb->prefix . 'player_user_playlist_positions', + $wpdb->prefix . 'fv_player_user_playlist_positions', array( 'user_id' => $user_id, 'player_id' => $playlist_id, @@ -214,6 +275,13 @@ function insert_update_playlist_row( $user_id, $playlist_id, $value, $exitst ) { return $res; } + /** + * Check if video exitst in db + * + * @param int $video_id + * + * @return object|null + */ function video_exists( $video_id ) { global $wpdb; @@ -222,21 +290,31 @@ function video_exists( $video_id ) { return $row; } + /** + * Check if position or playlist row exitst + * + * @param int $user_id + * @param int|string $id + * @param string $type + * @param boolean $video_exitst + * + * @return object|null + */ function position_row_exists( $user_id, $id, $type, $video_exitst = false ) { global $wpdb; if( $type == 'position' ) { - if( $video_exitst ) { + if( $video_exitst ) { // db video $row = $wpdb->get_row( "SELECT * FROM `{$wpdb->prefix}fv_player_user_video_positions` WHERE user_id = {$user_id} AND video_id = {$id}" ); - } else { + } else { // legacy video $row = $wpdb->get_row( "SELECT * FROM `{$wpdb->prefix}fv_player_user_video_positions` WHERE user_id = {$user_id} AND legacy_video_id = {$id}" ); } } if( $type == 'playlist' ) { - $row = $wpdb->get_row( "SELECT * FROM `{$wpdb->prefix}player_user_playlist_positions` WHERE user_id = {$user_id} AND player_id = {$id}" ); + $row = $wpdb->get_row( "SELECT * FROM `{$wpdb->prefix}fv_player_user_playlist_positions` WHERE user_id = {$user_id} AND player_id = {$id}" ); } return $row; @@ -279,11 +357,11 @@ function build_output_html( $data, $percent_done ) { $html = array(); foreach( $data as $output_data ) { - $html[] = ""; + $html[] = ""; } if( empty($html) && $percent_done == 0 ) { - $html[] = ""; + $html[] = ""; } return $html; From ad3706cb7952afff6fadb71bdce29dbc3c66098e Mon Sep 17 00:00:00 2001 From: Michal Date: Thu, 1 Jun 2023 13:13:53 +0200 Subject: [PATCH 09/32] conversion: insert update $res to boolean, fix typos --- models/conversion/positionsMeta2Table.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/models/conversion/positionsMeta2Table.php b/models/conversion/positionsMeta2Table.php index 0b151a7d1..466bb8b5c 100644 --- a/models/conversion/positionsMeta2Table.php +++ b/models/conversion/positionsMeta2Table.php @@ -55,7 +55,7 @@ function convert_one($meta) { $type = ''; if( strpos($meta_key, 'fv_wp_flowplayer_position') !== false ) { // last - $type = 'last_postion'; + $type = 'last_position'; } else if ( strpos($meta_key, 'fv_wp_flowplayer_saw') !== false ) { // finished $type = 'finished'; } else if ( strpos($meta_key, 'fv_wp_flowplayer_top_position') !== false ) { // top @@ -196,7 +196,7 @@ function convert_one($meta) { * @param boolean $row_exitst * @param boolean $video_exitst * - * @return int|false $res result of insert or update + * @return boolean $res result of insert or update */ function insert_update_video_row( $user_id, $video_id, $type, $value, $row_exitst, $video_exitst ) { global $wpdb; @@ -221,6 +221,8 @@ function insert_update_video_row( $user_id, $video_id, $type, $value, $row_exits 'legacy_video_id' => $legacy_id ) ); + + $res = is_numeric($res); } else { $res = $wpdb->insert( $wpdb->prefix . 'fv_player_user_video_positions', @@ -228,10 +230,11 @@ function insert_update_video_row( $user_id, $video_id, $type, $value, $row_exits $type => $value, 'user_id' => $user_id, 'video_id' => $video_id, - 'position' => $value, 'legacy_video_id' => $legacy_id ) ); + + $res = !empty($res); } return $res; @@ -245,7 +248,7 @@ function insert_update_video_row( $user_id, $video_id, $type, $value, $row_exits * @param int $value * @param boolean $exitst * - * @return int|false $res result of insert or update + * @return boolean $res result of insert or update */ function insert_update_playlist_row( $user_id, $playlist_id, $value, $exitst ) { global $wpdb; @@ -254,22 +257,26 @@ function insert_update_playlist_row( $user_id, $playlist_id, $value, $exitst ) { $res = $wpdb->update( $wpdb->prefix . 'fv_player_user_playlist_positions', array( - 'position' => $value + 'item_index' => $value ), array( 'user_id' => $user_id, 'player_id' => $playlist_id ) ); + + $res = is_numeric($res); } else { $res = $wpdb->insert( $wpdb->prefix . 'fv_player_user_playlist_positions', array( 'user_id' => $user_id, 'player_id' => $playlist_id, - 'position' => $value + 'item_index' => $value ) ); + + $res = !empty($res); } return $res; From 7c105a872de3340676a7dfb3090421e44ea7bb3b Mon Sep 17 00:00:00 2001 From: Michal Date: Fri, 2 Jun 2023 13:25:30 +0200 Subject: [PATCH 10/32] conversion: custom limit, custom start warning, bugfix --- models/conversion/conversion-base.class.php | 7 +++- models/conversion/positionsMeta2Table.php | 43 +++++++++++---------- models/conversion/shortcode2DB.class.php | 4 ++ 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/models/conversion/conversion-base.class.php b/models/conversion/conversion-base.class.php index ecc0aa683..db9b59bd5 100644 --- a/models/conversion/conversion-base.class.php +++ b/models/conversion/conversion-base.class.php @@ -15,6 +15,8 @@ abstract class FV_Player_Conversion_Base { protected $screen; protected $help; protected $screen_fields = array(); + protected $start_warning_text = 'This will convert your data to new format. Please make sure you have a backup of your database before continuing.'; + protected $conversion_limit = 1; abstract function convert_one($post); @@ -135,7 +137,7 @@ function conversion_screen() { - + @@ -168,7 +170,8 @@ function conversion_screen() { cancel: '', url: '', nonce: 'screen)?>', - finished: '' + finished: '', + limit: 'conversion_limit; ?>' }); }); diff --git a/models/conversion/positionsMeta2Table.php b/models/conversion/positionsMeta2Table.php index 466bb8b5c..5dc8d6d39 100644 --- a/models/conversion/positionsMeta2Table.php +++ b/models/conversion/positionsMeta2Table.php @@ -16,9 +16,13 @@ function __construct() { 'help' => __("This converts position values from usermeta to fv_player_user_video_positions table", 'fv-wordpress-flowplayer') ) ); + $this->conversion_limit = 100; + + $this->start_warning_text = __('This will convert positions from usermeta to new tables. Please make sure you have a backup of your database before continuing.', 'fv-wordpress-flowplayer'); + $this->screen_fields = array( - 'ID', - 'Name', + 'User ID', + 'Video ID', 'Result', 'Error', ); @@ -69,18 +73,17 @@ function convert_one($meta) { if( isset( $matches[1] ) ) { $playlist_id = $matches[1]; - if( $this->is_live() ) { + // check if its db video or external + $row_exitst = $this->position_row_exists( $user_id, $playlist_id, 'playlist' ); - // check if its db video or external - $row_exitst = $this->position_row_exists( $user_id, $playlist_id, 'playlist' ); - - $result = $this->insert_update_playlist_row( $user_id, $playlist_id, $meta_value, $row_exitst ); + $result = $this->insert_update_playlist_row( $user_id, $playlist_id, $meta_value, $row_exitst ); + if( $this->is_live() ) { if( $result ) { $output_data[] = array( 'ID' => $user_id, 'Name' => $meta_key, - 'output' => 'Playlist position updated', + 'output' => $row_exitst ? 'Playlist position updated' : 'Playlist position inserted', 'error' => '' ); } else { // failed to update @@ -101,7 +104,7 @@ function convert_one($meta) { $output_data[] = array( 'ID' => $user_id, 'Name' => $meta_key, - 'output' => 'Playlist position updated', + 'output' => $row_exitst ? 'Playlist position updated' : 'Playlist position inserted', 'error' => '' ); } @@ -126,17 +129,17 @@ function convert_one($meta) { $video_id = $matches[1]; // check if video exitst in db - $video_exitst = $this->video_exists( $video_id ); - $row_exitst = $this->position_row_exists( $user_id, $video_id, 'position' ); + $video_exists = $this->video_exists( $video_id ); + $row_exitst = $this->position_row_exists( $user_id, $video_id, 'position', $video_exists ); if( $this->is_live() ) { - $result = $this->insert_update_video_row( $user_id, $video_id, $type, $meta_value, $row_exitst, $video_exitst ); + $result = $this->insert_update_video_row( $user_id, $video_id, $type, $meta_value, $row_exitst, $video_exists ); if( $result ) { $output_data[] = array( 'ID' => $user_id, 'Name' => $meta_key, - 'output' => 'Video position updated', + 'output' => $row_exitst ? 'Video position updated' : 'Video position inserted', 'error' => '' ); } else { @@ -157,7 +160,7 @@ function convert_one($meta) { $output_data[] = array( 'ID' => $user_id, 'Name' => $meta_key, - 'output' => 'Video position updated', + 'output' => $row_exitst ? 'Video position updated' : 'Video position inserted', 'error' => '' ); } @@ -194,14 +197,14 @@ function convert_one($meta) { * @param string $type * @param int $value * @param boolean $row_exitst - * @param boolean $video_exitst + * @param boolean $video_exists * * @return boolean $res result of insert or update */ - function insert_update_video_row( $user_id, $video_id, $type, $value, $row_exitst, $video_exitst ) { + function insert_update_video_row( $user_id, $video_id, $type, $value, $row_exitst, $video_exists ) { global $wpdb; - if( !$video_exitst ) { // non db video + if( !$video_exists ) { // non db video $legacy_id = $video_id; $video_id = 0; } else { // db video @@ -303,16 +306,16 @@ function video_exists( $video_id ) { * @param int $user_id * @param int|string $id * @param string $type - * @param boolean $video_exitst + * @param boolean $video_exists * * @return object|null */ - function position_row_exists( $user_id, $id, $type, $video_exitst = false ) { + function position_row_exists( $user_id, $id, $type, $video_exists = false ) { global $wpdb; if( $type == 'position' ) { - if( $video_exitst ) { // db video + if( $video_exists ) { // db video $row = $wpdb->get_row( "SELECT * FROM `{$wpdb->prefix}fv_player_user_video_positions` WHERE user_id = {$user_id} AND video_id = {$id}" ); } else { // legacy video $row = $wpdb->get_row( "SELECT * FROM `{$wpdb->prefix}fv_player_user_video_positions` WHERE user_id = {$user_id} AND legacy_video_id = {$id}" ); diff --git a/models/conversion/shortcode2DB.class.php b/models/conversion/shortcode2DB.class.php index 8e780cbd7..64a21d92e 100644 --- a/models/conversion/shortcode2DB.class.php +++ b/models/conversion/shortcode2DB.class.php @@ -24,6 +24,10 @@ function __construct() { 'help' => __("This converts the [fvplayer src=...] and [flowplayer src=...] shortcodes into database [fvplayer id=...] shortcodes.", 'fv-wordpress-flowplayer') ) ); + $this->conversion_limit = 1; + + $this->start_warning_text = __('Please make sure you backup your database before continuing. You can use post revisions to get back to previous version of your posts as well.', 'fv-wordpress-flowplayer'); + // atts for video that are supported $this->supported_video_atts = array( 'src', From dc7747a356d31f20512c37cc27f49ef9c8d7b102 Mon Sep 17 00:00:00 2001 From: Michal Date: Fri, 2 Jun 2023 13:34:19 +0200 Subject: [PATCH 11/32] conversion: video id matcher improve --- models/conversion/positionsMeta2Table.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/conversion/positionsMeta2Table.php b/models/conversion/positionsMeta2Table.php index 5dc8d6d39..6e7e299e4 100644 --- a/models/conversion/positionsMeta2Table.php +++ b/models/conversion/positionsMeta2Table.php @@ -124,7 +124,7 @@ function convert_one($meta) { } } else { - preg_match('/fv_wp_flowplayer_\w+_(\w+)/', $meta_key, $matches); + preg_match('/fv_wp_flowplayer_\w+_(.*)/', $meta_key, $matches); if( isset( $matches[1] ) ) { $video_id = $matches[1]; From 5bfa20463306b23f775b9769e6d3b0da27540320 Mon Sep 17 00:00:00 2001 From: Michal Date: Fri, 2 Jun 2023 13:50:55 +0200 Subject: [PATCH 12/32] positions table: legacy_video_id add index --- flowplayer.php | 2 +- models/player-position-save.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/flowplayer.php b/flowplayer.php index bf5722f73..06361ba85 100644 --- a/flowplayer.php +++ b/flowplayer.php @@ -34,7 +34,7 @@ } global $fv_wp_flowplayer_ver; -$fv_wp_flowplayer_ver = '7.9.3.24'; +$fv_wp_flowplayer_ver = '7.9.3.25'; $fv_wp_flowplayer_core_ver = '7.2.14.11'; include_once( dirname( __FILE__ ) . '/includes/extra-functions.php' ); if( file_exists( dirname( __FILE__ ) . '/includes/module.php' ) ) { diff --git a/models/player-position-save.php b/models/player-position-save.php index 69a894439..e13a5450d 100644 --- a/models/player-position-save.php +++ b/models/player-position-save.php @@ -29,7 +29,8 @@ function plugin_update_database() { legacy_video_id varchar(255) NOT NULL, PRIMARY KEY (id), KEY user_id (user_id), - KEY video_id (video_id) + KEY video_id (video_id), + Key legacy_video_id (legacy_video_id) )" . $wpdb->get_charset_collate() . ";"; // create table to store position in playlists From 0dc14cdfa67dfedcb0639486125de6514f01d256 Mon Sep 17 00:00:00 2001 From: Michal Date: Fri, 2 Jun 2023 13:55:16 +0200 Subject: [PATCH 13/32] conversion: order items by umeta_id ASC --- models/conversion/positionsMeta2Table.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/conversion/positionsMeta2Table.php b/models/conversion/positionsMeta2Table.php index 6e7e299e4..2ce82be2d 100644 --- a/models/conversion/positionsMeta2Table.php +++ b/models/conversion/positionsMeta2Table.php @@ -42,7 +42,7 @@ function get_count() { function get_items( $offset, $limit ) { global $wpdb; - $meta_data = $wpdb->get_results( "SELECT * FROM `$wpdb->usermeta` WHERE meta_key LIKE 'fv_wp_flowplayer_%' LIMIT {$offset},{$limit}" ); + $meta_data = $wpdb->get_results( "SELECT * FROM `$wpdb->usermeta` WHERE meta_key LIKE 'fv_wp_flowplayer_%' ORDER BY umeta_id ASC LIMIT {$offset},{$limit}" ); return $meta_data; } From 50838b7cedd9c86b53dc07219b809131fda3295e Mon Sep 17 00:00:00 2001 From: Michal Date: Fri, 2 Jun 2023 16:35:44 +0200 Subject: [PATCH 14/32] conversion: pointer box --- controller/settings.php | 109 ++++++++++++++++++++++++---------------- 1 file changed, 66 insertions(+), 43 deletions(-) diff --git a/controller/settings.php b/controller/settings.php index 3f0916952..f32728e24 100644 --- a/controller/settings.php +++ b/controller/settings.php @@ -63,10 +63,10 @@ function fv_wp_flowplayer_after_plugin_row( $arg) { if( apply_filters('fv_player_skip_ads',false) ) { return; } - + $args = func_get_args(); - - if( $args[1]['Name'] == 'FV Player' ) { + + if( $args[1]['Name'] == 'FV Player' ) { $options = get_option( 'fvwpflowplayer' ); if( $options['key'] == 'false' || $options['key'] == '' ) : ?> @@ -143,13 +143,13 @@ function fv_player_settings_save() { $_GET['post_mime_type'] = 'image'; } } - + if( isset($_POST['fv-wp-flowplayer-submit']) ) { check_admin_referer('fv_flowplayer_settings_nonce','fv_flowplayer_settings_nonce'); - + global $fv_fp; if( method_exists($fv_fp,'_set_conf') ) { - if( + if( // pro not installed or !function_exists('FV_Player_Pro') || // pro installed and version is at least 7.5.25.728 @@ -189,9 +189,9 @@ function fv_player_handle_secrets($new, $old) { } } } else if($v == '1') { // single value, 1 - keep original, 0 - use new - $new[$key] = $old[$key]; + $new[$key] = $old[$key]; } - } + } unset($new[$k]); // remove _is_secret_ } @@ -212,6 +212,19 @@ function fv_player_admin_pointer_boxes() { global $fv_fp; global $fv_wp_flowplayer_ver, $fv_wp_flowplayer_core_ver; + if( !$fv_fp->_get_option('notice_user_video_positions_conversion') ) { + $fv_fp->pointer_boxes['fv_flowplayer_video_positions_conversion'] = array( + 'id' => '#wp-admin-bar-new-content', + 'pointerClass' => 'fv_flowplayer_video_positions_conversion', + 'heading' => __('FV Player Video Positions Conversion', 'fv-wordpress-flowplayer'), + 'content' => __("

Video positions are now stored in the separate table.

Would you like to convert your video positions to the new format?

"), + 'position' => array( 'edge' => 'top', 'align' => 'left' ), + 'button1' => __('Migrate', 'fv-wordpress-flowplayer'), + 'button2' => __('Close', 'fv-wordpress-flowplayer'), + 'function1' => 'location.href = "'.admin_url('admin.php?page=fv_player_conversion_positions_meta2table'), + ); + } + if( isset($fv_fp->conf['disable_videochecker']) && $fv_fp->conf['disable_videochecker'] == 'false' && ( !isset($fv_fp->conf['video_checker_agreement']) || $fv_fp->conf['video_checker_agreement'] != 'true' ) @@ -226,7 +239,7 @@ function fv_player_admin_pointer_boxes() { 'button2' => __('Disable the video checker', 'fv-wordpress-flowplayer') ); } - + if( !$fv_fp->_get_option('notice_7_5') ) { $fv_fp->pointer_boxes['fv_flowplayer_notice_7_5'] = array( 'id' => '#wp-admin-bar-new-content', @@ -244,7 +257,7 @@ function fv_player_admin_pointer_boxes() { 'button1' => __('Thanks for letting me know!', 'fv-wordpress-flowplayer') ); } - + if( !$fv_fp->_get_option('notice_new_lightbox') ) { $fv_fp->pointer_boxes['fv_flowplayer_new_lightbox'] = array( 'id' => '#wp-admin-bar-new-content', @@ -255,7 +268,7 @@ function fv_player_admin_pointer_boxes() { 'button1' => __('Thanks for letting me know!', 'fv-wordpress-flowplayer') ); } - + if( !$fv_fp->_get_option('notice_db') ) { $fv_fp->pointer_boxes['fv_flowplayer_db'] = array( 'id' => '#wp-admin-bar-new-content', @@ -266,7 +279,7 @@ function fv_player_admin_pointer_boxes() { 'button1' => __('Thanks for letting me know!', 'fv-wordpress-flowplayer') ); } - + if( $fv_fp->_get_option('video_sitemap') && !$fv_fp->_get_option('disableembedding') && !$fv_fp->_get_option('notice_xml_sitemap_iframes') ) { $fv_fp->pointer_boxes['fv_flowplayer_notice_xml_sitemap_iframes'] = array( 'id' => '#wp-admin-bar-new-content', @@ -278,8 +291,8 @@ function fv_player_admin_pointer_boxes() { 'button2' => __('Go to setting', 'fv-wordpress-flowplayer'), 'function2' => 'location.href = "'.admin_url('options-general.php?page=fvplayer').'#fv_flowplayer_seo"', ); - } - + } + if( !$fv_fp->_get_option('notice_db') && !$fv_fp->_get_option('nag_fv_player_7') ) { $fv_fp->pointer_boxes['fv_flowplayer_fv_player_7'] = array( 'id' => '#wp-admin-bar-new-content', @@ -297,11 +310,11 @@ function fv_player_admin_pointer_boxes() { 'button1' => __('Thanks for letting me know!', 'fv-wordpress-flowplayer'), ); } - - if( - (stripos( $_SERVER['REQUEST_URI'], '/plugins.php') !== false ||fv_player_is_admin_screen() ) - && $pnotices = get_option('fv_wordpress_flowplayer_persistent_notices') - ) { + + if( + (stripos( $_SERVER['REQUEST_URI'], '/plugins.php') !== false ||fv_player_is_admin_screen() ) + && $pnotices = get_option('fv_wordpress_flowplayer_persistent_notices') + ) { $fv_fp->pointer_boxes['fv_flowplayer_license_expired'] = array( 'id' => '#wp-admin-bar-new-content', 'pointerClass' => 'fv_flowplayer_license_expired', @@ -311,9 +324,9 @@ function fv_player_admin_pointer_boxes() { 'position' => array( 'edge' => 'top', 'align' => 'center' ), 'button1' => __('Hide this notice', 'fv-wordpress-flowplayer'), 'button2' => __('I\'ll check this later', 'fv-wordpress-flowplayer') - ); + ); } - + /*if( !$fv_fp->_get_option('disable_video_hash_links') && !$fv_fp->_get_option('notification_video_links') ) { $fv_fp->pointer_boxes['fv_player_notification_video_links'] = array( 'id' => '#wp-admin-bar-new-content', @@ -324,7 +337,7 @@ function fv_player_admin_pointer_boxes() { 'button1' => __('Open Settings', 'fv-wordpress-flowplayer'), 'button2' => __('Dismiss', 'fv-wordpress-flowplayer') ); - + add_action( 'admin_print_footer_scripts', 'fv_player_pointer_scripts' ); }*/ } @@ -335,7 +348,7 @@ function fv_player_admin_pointer_boxes() { add_action( 'wp_ajax_fv_foliopress_ajax_pointers', 'fv_wp_flowplayer_pointers_ajax' ); function fv_wp_flowplayer_pointers_ajax() { - + if( isset($_POST['key']) && $_POST['key'] == 'fv_flowplayer_video_checker_service' && isset($_POST['value']) ) { check_ajax_referer('fv_flowplayer_video_checker_service'); $conf = get_option( 'fvwpflowplayer' ); @@ -350,13 +363,23 @@ function fv_wp_flowplayer_pointers_ajax() { } die(); } - + + if( isset($_POST['key']) && $_POST['key'] == 'fv_flowplayer_video_positions_conversion' && isset($_POST['value']) ) { + check_ajax_referer('fv_flowplayer_video_positions_conversion'); + $conf = get_option( 'fvwpflowplayer' ); + if( $conf ) { + $conf['notice_user_video_positions_conversion'] = $_POST['value']; + update_option( 'fvwpflowplayer', $conf ); + } + die(); + } + if( isset($_POST['key']) && $_POST['key'] == 'fv_flowplayer_license_expired' && isset($_POST['value']) && $_POST['value'] === 'true' ) { check_ajax_referer('fv_flowplayer_license_expired'); delete_option("fv_wordpress_flowplayer_persistent_notices"); die(); - } - + } + $notices = array( 'fv_flowplayer_notice_7_5' => 'notice_7_5', 'fv_flowplayer_new_lightbox' => 'notice_new_lightbox', @@ -365,7 +388,7 @@ function fv_wp_flowplayer_pointers_ajax() { 'fv_flowplayer_fv_player_7' => 'nag_fv_player_7', 'fv_player_notification_video_links' => 'notification_video_links', ); - + if( isset($_POST['key']) && isset($_POST['value']) && in_array($_POST['key'], array_keys($notices) ) ) { check_ajax_referer($_POST['key']); $conf = get_option( 'fvwpflowplayer' ); @@ -375,7 +398,7 @@ function fv_wp_flowplayer_pointers_ajax() { } die(); } - + } @@ -390,7 +413,7 @@ function fv_player_pointer_scripts() { window.location = '#playlist_advance'; }); }); - })(jQuery); + })(jQuery); + ?>
IDTitlePost TypeShortcodeResultError
#". $output_data['ID'] . "". $output_data['title'] . "" . $output_data['type'] . "". $output_data['shortcode'] . "" . $output_data['output'] . "" . $output_data['error'] . "
No matching players found.
+

+ +

+
". $output_data['ID'] . "". $output_data['Name'] ."". $output_data['Error'] ."
No matching players found.
". $output_data['ID'] . "". $output_data['Name'] ."". $output_data['Error'] ."
". $output_data['ID'] . "". $output_data['Name'] ."". $output_data['output'] ."". $output_data['error'] ."
No matching players found.
No matching meta found.