';
//TODO: Migration
$table_name = $wpdb->prefix . 'posts';
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Migration tool, table name from $wpdb->prefix.
$products = $wpdb->get_results( "SELECT ID FROM $table_name WHERE (post_type='atkp_product') ", OBJECT );
echo 'products: ' . esc_html( count( $products ) ) . '
';
foreach ( $products as $row ) {
$post_id = $row->ID;
echo 'updating ' . esc_html( $post_id ) . '
';
$isv3 = ATKPTools::get_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_v3_plus' );
if ( $isv3 ) {
continue;
}
ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_title', null );
ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_mpn', null );
ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_productgroup', null );
ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_manufacturer', null );
ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_author', null );
ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_numberofpages', null );
ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_brand', null );
ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_releasedate', null );
ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_description', null );
ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_features', null );
ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_v3_plus', true );
}
ATKPTools::set_setting( 'atkp_migration_done', 1 );
echo esc_html( 'migration plus finished ' );
//header( 'Location: ' . $_SERVER['HTTP_REFERER'] );
exit;
} else {
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Static HTML with escaped dynamic values.
echo '' . esc_html__( 'If you didnt modified product data (title, brand, manufacturer, make, description, features,..) you should use this upgrade function:', 'affiliate-toolkit-starter' ) . '
';
echo '' . esc_html__( 'Migrate my products (including productdata) to V3', 'affiliate-toolkit-starter' ) . ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
';
//TODO: Migration
$table_name = $wpdb->prefix . 'posts';
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.InterpolatedNotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter -- Migration tool, table name from $wpdb->prefix.
$products = $wpdb->get_results( "SELECT ID FROM $table_name WHERE (post_type='atkp_product') ", OBJECT );
echo 'products: ' . esc_html( count( $products ) ) . '
';
foreach ( $products as $row ) {
$post_id = $row->ID;
echo 'updating ' . esc_html( $post_id ) . '
';
$isv3 = ATKPTools::get_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_v3' );
if ( $isv3 ) {
continue;
}
$refreshreviewinfo = ATKPTools::get_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_refreshreviewinforegulary' );
$refreshpriceinfo = ATKPTools::get_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_refreshpriceinforegulary' );
$refreshproducturl = ATKPTools::get_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_refreshproducturlregulary' );
$refreshimages = ATKPTools::get_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_refreshimagesregulary' );
//$refreshmoreoffers = ATKPTools::get_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_refreshmoreoffersregulary' );
if ( $refreshimages == true ) {
ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_smallimageurl', null );
ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_mediumimageurl', null );
ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_largeimageurl', null );
ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_images', null );
}
if ( $refreshproducturl == true ) {
ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_producturl', null );
ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_addtocarturl', null );
ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_customerreviewsurl', null );
}
if ( $refreshreviewinfo == true ) {
//ratings werden nur überschrieben wenn welche vorhanden sind
ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_rating', null );
ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_reviewcount', null );
}
ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_parentasin', null );
ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_variationname', null );
ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_variations', null );
if ( $refreshpriceinfo == true ) {
ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_listpricefloat', null );
ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_salepricefloat', null );
ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_shippingfloat', null );
ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_listprice', null );
ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_saleprice', null );
ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_availability', null );
ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_shipping', null );
ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_isprime', null );
ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_iswarehouse', null );
ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_amountsaved', null );
ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_amountsavedfloat', null );
ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_percentagesaved', null );
}
ATKPTools::set_post_setting( $post_id, ATKP_PRODUCT_POSTTYPE . '_v3', true );
}
ATKPTools::set_setting( 'atkp_migration_done', 1 );
echo esc_html( 'migration finished ' );
//header( 'Location: ' . $_SERVER['HTTP_REFERER'] );
exit;
} else {
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Static HTML with escaped dynamic values.
echo '' . esc_html__( 'If you modified product data (title, brand, manufacturer, make, description, features,..) you should use this upgrade function:', 'affiliate-toolkit-starter' ) . '
';
echo '' . esc_html__( 'Migrate my products to V3', 'affiliate-toolkit-starter' ) . ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
exists_table();
$tablename2 = $tbl->exists_detailtable();
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Admin debug page, access controlled by capability check.
if ( isset( $_GET['atkp_action'] ) && sanitize_text_field( wp_unslash( $_GET['atkp_action'] ) ) == 'recreate_queuetable' ) {
/* translators: %s: table name */
echo esc_html( sprintf( __( 'generating table structure for %s', 'affiliate-toolkit-starter' ), $tablename[1] ) );
//drop table
if ( $tablename[0] ) {
$wpdb->query( 'DROP TABLE ' . $tablename[1] ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
}
if ( $tablename2[0] ) {
$wpdb->query( 'DROP TABLE ' . $tablename2[1] ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
}
//create table
$tbl->check_table_structure( true );
header( 'Location: ' . ( isset( $_SERVER['HTTP_REFERER'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '' ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
exit;
} else {
/* translators: %s: SQL table name */
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.WP.I18n.MissingTranslatorsComment -- HTML tags are static, dynamic values are escaped with esc_html__() and esc_html().
echo( $tablename[0] ? '' . sprintf( esc_html__( 'SQL table "%s" exists', 'affiliate-toolkit-starter' ), esc_html( $tablename[1] ) ) . '' : '' . sprintf( esc_html__( 'SQL table "%s" does not exist', 'affiliate-toolkit-starter' ), esc_html( $tablename[1] ) ) . '' ) ?>
' . sprintf( esc_html__( 'SQL table "%s" exists', 'affiliate-toolkit-starter' ), esc_html( $tablename2[1] ) ) . '' : '' . sprintf( esc_html__( 'SQL table "%s" does not exist', 'affiliate-toolkit-starter' ), esc_html( $tablename2[1] ) ) . '' ) ?>
' . esc_html__( 'Drop & create queue table (data will be deleted)', 'affiliate-toolkit-starter' ) . ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
exists_table();
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Admin debug page, access controlled by capability check.
if ( isset( $_GET['atkp_action'] ) && sanitize_text_field( wp_unslash( $_GET['atkp_action'] ) ) == 'recreate_producttable' ) {
/* translators: %s: table name */
echo esc_html( sprintf( __( 'generating table structure for %s', 'affiliate-toolkit-starter' ), $tablename[1] ) );
//drop table
if ( $tablename[0] ) {
$wpdb->query( 'DROP TABLE ' . $tablename[1] ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
}
//create table
$tbl->check_table_structure( true );
header( 'Location: ' . ( isset( $_SERVER['HTTP_REFERER'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '' ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
exit;
} else {
/* translators: %s: SQL table name */
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.WP.I18n.MissingTranslatorsComment -- HTML tags are static, dynamic values are escaped.
echo( $tablename[0] ? '' . sprintf( esc_html__( 'SQL table "%s" exists', 'affiliate-toolkit-starter' ), esc_html( $tablename[1] ) ) . '' : '' . sprintf( esc_html__( 'SQL table "%s" does not exist', 'affiliate-toolkit-starter' ), esc_html( $tablename[1] ) ) . '' ) ?>
' . esc_html__( 'Drop & create product table (data will be deleted)', 'affiliate-toolkit-starter' ) . ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
exists_table();
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Admin debug page, access controlled by capability check.
if ( isset( $_GET['atkp_action'] ) && sanitize_text_field( wp_unslash( $_GET['atkp_action'] ) ) == 'recreate_listtable' ) {
/* translators: %s: table name */
echo esc_html( sprintf( __( 'generating table structure for %s', 'affiliate-toolkit-starter' ), $tablename[1] ) );
//drop table
if ( $tablename[0] ) {
$wpdb->query( 'DROP TABLE ' . $tablename[1] ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.PreparedSQL.NotPrepared, PluginCheck.Security.DirectDB.UnescapedDBParameter
}
//create table
$tbl->check_table_structure( true );
header( 'Location: ' . ( isset( $_SERVER['HTTP_REFERER'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_REFERER'] ) ) : '' ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
exit;
} else {
$tbl = new atkp_listtable_helper();
$tablename = $tbl->exists_table();
/* translators: %s: SQL table name */
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.WP.I18n.MissingTranslatorsComment -- HTML tags are static, dynamic values are escaped.
echo( $tablename[0] ? '' . sprintf( esc_html__( 'SQL table "%s" exists', 'affiliate-toolkit-starter' ), esc_html( $tablename[1] ) ) . '' : '' . sprintf( esc_html__( 'SQL table "%s" does not exist', 'affiliate-toolkit-starter' ), esc_html( $tablename[1] ) ) . '' ) ?>
' . esc_html__( 'Drop & create list table (data will be deleted)', 'affiliate-toolkit-starter' ) . ''; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>