Import legacy nurinda.co.id website

This commit is contained in:
dirga committed 2026-10-01 14:27:19 +07:00
1 parent 3f59bb9038
commit 6e21646ac4
13389 files changed
+3246690

No files matched your search

File diff suppressed because it is too large. Load diff
@@ -0,0 +1,32 @@
<?php
class us_migration_2_2 extends US_Migration_Translator {
// Content
public function translate_content( &$content ) {
return $this->_translate_content( $content );
}
public function translate_us_gmaps( &$name, &$params, &$content ) {
$changed = FALSE;
$markers = array();
for ( $i = 2; $i <= 5; $i ++ ) {
if ( ( ! empty( $params['marker' . $i . '_address'] ) ) AND ( ! empty( $params['marker' . $i . '_text'] ) ) ) {
$markers[] = array(
'marker_address' => $params['marker' . $i . '_address'],
'marker_text' => rawurldecode( base64_decode( $params['marker' . $i . '_text'] ) ),
);
unset( $params['marker' . $i . '_address'] );
unset( $params['marker' . $i . '_text'] );
$changed = TRUE;
}
}
if ( $changed ) {
$params['markers'] = rawurlencode( json_encode( $markers ) );
}
return $changed;
}
}
@@ -0,0 +1,35 @@
<?php
class us_migration_2_3 extends US_Migration_Translator {
// Content
public function translate_content( &$content ) {
return $this->_translate_content( $content );
}
public function translate_us_cta( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ! empty( $params['message'] ) ) {
$content = $params['message'] . '[/us_cta]';
unset( $params['message'] );
$changed = TRUE;
}
return $changed;
}
public function translate_vc_icon( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ! us_get_option( 'enable_unsupported_vc_shortcodes' ) ) {
global $usof_options;
usof_load_options_once();
$usof_options['enable_unsupported_vc_shortcodes'] = TRUE;
update_option( 'usof_options_' . US_THEMENAME, $usof_options, TRUE );
}
return $changed;
}
}
@@ -0,0 +1,13 @@
<?php
class us_migration_2_7 extends US_Migration_Translator {
// Options
public function translate_theme_options( &$options ) {
$favicon_id = us_get_option( 'favicon' );
if ( $favicon_id != '' ) {
update_option( 'site_icon', $favicon_id );
}
}
}
@@ -0,0 +1,159 @@
<?php
class us_migration_2_8 extends US_Migration_Translator {
// Content
public function translate_content( &$content ) {
return $this->_translate_content( $content );
}
public function translate_vc_row( &$name, &$params, &$content ) {
global $us_migration_current_row_is_width;
if ( ! empty( $params['width'] ) AND $params['width'] == 'full' ) {
$us_migration_current_row_is_width = TRUE;
} else {
$us_migration_current_row_is_width = FALSE;
}
}
public function translate_us_blog( &$name, &$params, &$content ) {
global $us_migration_current_post_id, $us_migration_current_row_is_width;
$changed = FALSE;
if ( empty( $params['layout'] ) OR $params['layout'] == 'large' ) {
$params['layout'] = 'classic';
$params['columns'] = 1;
$changed = TRUE;
}
if ( in_array( $params['layout'], array( 'smallcircle', 'smallsquare', 'compact' ) ) ) {
$params['columns'] = 1;
$changed = TRUE;
}
if ( in_array( $params['layout'], array( 'grid', 'masonry' ) ) ) {
// Get sidebar info
$post_type = get_post_type( $us_migration_current_post_id );
if ( $post_type == 'post' ) {
// Posts and attachments
$sidebar_pos = us_get_option( 'post_sidebar', 'right' );
} elseif ( $post_type == 'us_portfolio' ) {
// Portfolio page
$sidebar_pos = us_get_option( 'portfolio_sidebar', 'none' );
} elseif ( $post_type == 'page' ) {
// Page
$sidebar_pos = us_get_option( 'page_sidebar', 'none' );
} elseif ( $post_type == 'product' ) {
// WooCommerce product
$sidebar_pos = us_get_option( 'product_sidebar', 'right' );
} else {
$sidebar_pos = 'none';
}
if ( usof_meta( 'us_sidebar', array(), $us_migration_current_post_id ) != '' ) {
$sidebar_pos = usof_meta( 'us_sidebar', array(), $us_migration_current_post_id );
}
// Some wrong value may came from various theme options, so filtering it
if ( ! in_array( $sidebar_pos, array( 'right', 'left', 'none' ) ) ) {
$sidebar_pos = 'right';
}
if ( $sidebar_pos == 'none' ) {
$params['columns'] = 3;
if ( $us_migration_current_row_is_width ) {
$params['columns'] = 5;
}
}
if ( $params['layout'] == 'grid' ) {
$params['layout'] = 'classic';
}
$changed = TRUE;
}
return $changed;
}
// Options
public function translate_theme_options( &$options ) {
$changed = FALSE;
// Blog Home Page
if ( in_array( $options['blog_layout'], array( 'smallcircle', 'smallsquare', 'compact' ) ) ) {
$options['blog_cols'] = 1;
$changed = TRUE;
}
if ( $options['blog_layout'] == 'large' ) {
$options['blog_layout'] = 'classic';
$options['blog_cols'] = 1;
$changed = TRUE;
}
if ( in_array( $options['blog_layout'], array( 'grid', 'masonry' ) ) ) {
if ( $options['blog_sidebar'] == 'none' ) {
$options['blog_cols'] = 3;
} else {
$options['blog_cols'] = 2;
}
if ( $options['blog_layout'] == 'grid' ) {
$options['blog_layout'] = 'classic';
}
$changed = TRUE;
}
// Archive Page
if ( in_array( $options['archive_layout'], array( 'smallcircle', 'smallsquare', 'compact' ) ) ) {
$options['archive_cols'] = 1;
$changed = TRUE;
}
if ( $options['archive_layout'] == 'large' ) {
$options['archive_layout'] = 'classic';
$options['archive_cols'] = 1;
$changed = TRUE;
}
if ( in_array( $options['archive_layout'], array( 'grid', 'masonry' ) ) ) {
if ( $options['archive_sidebar'] == 'none' ) {
$options['archive_cols'] = 3;
} else {
$options['archive_cols'] = 2;
}
if ( $options['archive_layout'] == 'grid' ) {
$options['archive_layout'] = 'classic';
}
$changed = TRUE;
}
// Search Page
if ( in_array( $options['search_layout'], array( 'smallcircle', 'smallsquare', 'compact' ) ) ) {
$options['search_cols'] = 1;
$changed = TRUE;
}
if ( $options['search_layout'] == 'large' ) {
$options['search_layout'] = 'classic';
$options['search_cols'] = 1;
$changed = TRUE;
}
if ( in_array( $options['search_layout'], array( 'grid', 'masonry' ) ) ) {
if ( $options['search_sidebar'] == 'none' ) {
$options['search_cols'] = 3;
} else {
$options['search_cols'] = 2;
}
if ( $options['search_layout'] == 'grid' ) {
$options['search_layout'] = 'classic';
}
$changed = TRUE;
}
return $changed;
}
}
@@ -0,0 +1,179 @@
<?php
class us_migration_3_0 extends US_Migration_Translator {
// Options
public function translate_theme_options( &$options ) {
$changed = FALSE;
if ( isset( $options['color_header_bg'] ) ) {
$options['color_header_middle_bg'] = $options['color_header_bg'];
unset( $options['color_header_bg'] );
$changed = TRUE;
}
if ( isset( $options['color_header_text'] ) ) {
$options['color_header_middle_text'] = $options['color_header_text'];
unset( $options['color_header_text'] );
$changed = TRUE;
}
if ( isset( $options['color_header_text_hover'] ) ) {
$options['color_header_middle_text_hover'] = $options['color_header_text_hover'];
unset( $options['color_header_text_hover'] );
$changed = TRUE;
}
if ( isset( $options['color_header_ext_bg'] ) ) {
$options['color_header_top_bg'] = $options['color_header_ext_bg'];
$options['color_header_bottom_bg'] = $options['color_header_ext_bg'];
unset( $options['color_header_ext_bg'] );
$changed = TRUE;
}
if ( isset( $options['color_header_ext_text'] ) ) {
$options['color_header_top_text'] = $options['color_header_ext_text'];
$options['color_header_bottom_text'] = $options['color_header_ext_text'];
unset( $options['color_header_ext_text'] );
$changed = TRUE;
}
if ( isset( $options['color_header_ext_text_hover'] ) ) {
$options['color_header_top_text_hover'] = $options['color_header_ext_text_hover'];
$options['color_header_bottom_text_hover'] = $options['color_header_ext_text_hover'];
unset( $options['color_header_ext_text_hover'] );
$changed = TRUE;
}
if ( isset( $options['header_layout'] ) ) {
$new_value = NULL;
switch ( $options['header_layout'] ) {
case 'standard':
$new_value = 'simple_1';
break;
case 'extended':
$new_value = 'extended_1';
break;
case 'advanced':
$new_value = 'extended_2';
break;
case 'centered':
$new_value = 'centered_1';
break;
case 'sided':
$new_value = 'vertical_1';
break;
}
if ( $new_value ) {
$options['header_layout'] = $new_value;
$changed = TRUE;
}
}
if ( isset( $options['header_sticky'] ) AND $options['header_sticky'] ) {
$options['header_sticky'] = array( 'default' );
if ( isset( $options['header_sticky_disable_width'] ) ) {
if ( $options['header_sticky_disable_width'] < 901 ) {
$options['header_sticky'][] = 'tablets';
}
if ( $options['header_sticky_disable_width'] < 601 ) {
$options['header_sticky'][] = 'mobiles';
}
}
$changed = TRUE;
}
if ( isset( $options['header_main_height'] ) ) {
$options['header_middle_height'] = $options['header_main_height'];
unset( $options['header_main_height'] );
$changed = TRUE;
}
if ( isset( $options['header_main_sticky_height_1'] ) AND ( $options['header_layout'] == 'simple_1' OR $options['header_layout'] == 'extended_1' ) ) {
$options['header_middle_sticky_height'] = $options['header_main_sticky_height_1'];
unset( $options['header_main_sticky_height_1'] );
$changed = TRUE;
}
if ( isset( $options['header_main_sticky_height_2'] ) AND ( $options['header_layout'] == 'extended_2' OR $options['header_layout'] == 'centered_1' ) ) {
$options['header_middle_sticky_height'] = $options['header_main_sticky_height_2'];
unset( $options['header_main_sticky_height_2'] );
$changed = TRUE;
}
if ( isset( $options['header_extra_height'] ) ) {
$options['header_top_height'] = $options['header_extra_height'];
$options['header_bottom_height'] = $options['header_extra_height'];
unset( $options['header_extra_height'] );
$changed = TRUE;
}
if ( isset( $options['header_extra_sticky_height_1'] ) ) {
$options['header_top_sticky_height'] = $options['header_extra_sticky_height_1'];
unset( $options['header_extra_sticky_height_1'] );
$changed = TRUE;
}
if ( isset( $options['header_extra_sticky_height_2'] ) ) {
$options['header_bottom_sticky_height'] = $options['header_extra_sticky_height_2'];
unset( $options['header_extra_sticky_height_2'] );
$changed = TRUE;
}
if ( isset( $options['header_layout'] ) AND $options['header_layout'] == 'vertical_1' AND isset( $options['logo_width'] ) AND isset( $options['logo_image'] ) ) {
$img = usof_get_image_src( $options['logo_image'] );
if ( $img AND ( ! empty( $img[1] ) AND ! empty( $img[2] ) ) ) {
$logo_height = round( $options['logo_width'] / $img[1] * $img[2] );
$options['logo_height'] = intval( $logo_height );
}
$changed = TRUE;
}
if ( isset( $options['page_comments'] ) AND $options['page_comments'] == 0 ) {
$all_pages = get_posts(
array(
'posts_per_page' => - 1,
'post_type' => 'page',
'numberposts' => - 1,
)
);
foreach ( $all_pages as $_page ) {
wp_update_post(
array(
'ID' => $_page->ID,
'comment_status' => 'closed',
)
);
}
}
return $changed;
}
public function translate_meta( &$meta, $post_type ) {
$changed = FALSE;
$translate_meta_for = array(
'post',
'page',
'us_portfolio',
'forum',
'topic',
);
if ( ! in_array( $post_type, $translate_meta_for ) ) {
return $changed;
}
if ( isset( $meta['us_header_show'][0] ) AND $meta['us_header_show'][0] == "onscroll" ) {
$meta['us_header_show_onscroll'][0] = 1;
unset( $meta['us_header_show'] );
$changed = TRUE;
}
return $changed;
}
}
@@ -0,0 +1,165 @@
<?php
class us_migration_3_1 extends US_Migration_Translator {
// Options
public function translate_theme_options( &$options ) {
$changed = FALSE;
if ( isset( $options['color_content_primary'] ) ) {
$options['color_content_link'] = $options['color_content_primary'];
$changed = TRUE;
}
if ( isset( $options['color_content_secondary'] ) ) {
$options['color_content_link_hover'] = $options['color_content_secondary'];
$changed = TRUE;
}
if ( isset( $options['color_alt_content_primary'] ) ) {
$options['color_alt_content_link'] = $options['color_alt_content_primary'];
$changed = TRUE;
}
if ( isset( $options['color_alt_content_secondary'] ) ) {
$options['color_alt_content_link_hover'] = $options['color_alt_content_secondary'];
$changed = TRUE;
}
return $changed;
}
// Content
public function translate_content( &$content ) {
return $this->_translate_content( $content );
}
public function translate_us_btn( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ! empty( $params['size'] ) ) {
if ( $params['size'] == 'small' ) {
$params['size'] = '13px';
$changed = TRUE;
} elseif ( $params['size'] == 'large' ) {
$params['size'] = '18px';
$changed = TRUE;
}
}
return $changed;
}
public function translate_us_cta( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ! empty( $params['btn_size'] ) ) {
if ( $params['btn_size'] == 'small' ) {
$params['btn_size'] = '13px';
$changed = TRUE;
} elseif ( $params['btn_size'] == 'large' ) {
$params['btn_size'] = '18px';
$changed = TRUE;
}
}
if ( ! empty( $params['btn2_size'] ) ) {
if ( $params['btn2_size'] == 'small' ) {
$params['btn2_size'] = '13px';
$changed = TRUE;
} elseif ( $params['btn2_size'] == 'large' ) {
$params['btn2_size'] = '18px';
$changed = TRUE;
}
}
return $changed;
}
public function translate_us_pricing( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ! empty( $params['items'] ) ) {
$items = json_decode( urldecode( $params['items'] ), TRUE );
if ( is_array( $items ) ) {
foreach ( $items as $index => $item ) {
if ( ! empty( $item['btn_size'] ) ) {
if ( $item['btn_size'] == 'small' ) {
$items[$index]['btn_size'] = '13px';
$changed = TRUE;
} elseif ( $item['btn_size'] == 'large' ) {
$items[$index]['btn_size'] = '18px';
$changed = TRUE;
}
}
}
if ( $changed ) {
$params['items'] = urlencode( json_encode( $items ) );
}
}
}
return $changed;
}
public function translate_us_social_links( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ! empty( $params['size'] ) ) {
if ( $params['size'] == 'small' ) {
$params['size'] = '17px';
$changed = TRUE;
} elseif ( $params['size'] == 'medium' ) {
$params['size'] = '20px';
$changed = TRUE;
} elseif ( $params['size'] == 'large' ) {
$params['size'] = '24px';
$changed = TRUE;
}
} else {
$params['size'] = '17px';
$changed = TRUE;
}
return $changed;
}
public function translate_widgets( &$name, &$instance ) {
if ( $name == 'us_socials' ) {
if ( isset( $instance['size'] ) ) {
if ( $instance['size'] == 'small ' ) {
$instance['size'] = '17px';
} elseif ( $instance['size'] == 'medium' ) {
$instance['size'] = '20px';
} elseif ( $instance['size'] == 'large' ) {
$instance['size'] = '24px';
}
return TRUE;
}
}
}
}
@@ -0,0 +1,86 @@
<?php
class us_migration_3_2 extends US_Migration_Translator {
private $clients_items = '';
private $clients_processed = FALSE;
// Content
public function translate_content( &$content ) {
return $this->_translate_content( $content );
}
public function translate_us_logos( &$name, &$params, &$content ) {
if ( ! $this->clients_processed ) {
// Register us_clients
register_post_type(
'us_client', array(
'labels' => array(
'name' => 'Clients Logos',
'singular_name' => 'Client Logo',
'add_new' => 'Add Client Logo',
),
'public' => FALSE,
'publicly_queryable' => FALSE,
'exclude_from_search' => FALSE,
'show_in_nav_menus' => FALSE,
'show_ui' => TRUE,
'has_archive' => FALSE,
'query_var' => FALSE,
'supports' => array( 'title', 'thumbnail' ),
'can_export' => TRUE,
'capability_type' => 'us_client',
'map_meta_cap' => TRUE,
'menu_icon' => 'dashicons-awards',
)
);
// Get all us_clients posts
$args = array(
'posts_per_page' => - 1,
'post_type' => 'us_client',
'post_status' => 'publish',
'numberposts' => - 1,
);
$clients = get_posts( $args );
$items = array();
foreach ( $clients as $client ) {
if ( has_post_thumbnail( $client ) ) {
$tnail = wp_get_attachment_image_src( get_post_thumbnail_id( $client->ID ), 'medium' );
if ( $tnail ) {
$item = array(
'image' => get_post_thumbnail_id( $client->ID ),
);
$url = usof_meta( 'us_client_url', array(), $client->ID );
if ( $url != '' ) {
$target = usof_meta( 'us_client_new_tab', array(), $client->ID ) ? 'target:%20_blank|' : '|';
$item['link'] = 'url:' . urlencode( $url ) . '||' . $target;
}
$items[] = $item;
}
}
}
if ( count( $items ) > 0 ) {
$this->clients_items = urlencode( json_encode( $items ) );
}
$this->clients_processed = TRUE;
// Deregister us_clients
global $wp_post_types;
if ( isset( $wp_post_types['us_clients'] ) ) {
unset( $wp_post_types['us_clients'] );
}
}
$params['items'] = $this->clients_items;
return TRUE;
}
}
@@ -0,0 +1,174 @@
<?php
class us_migration_3_3 extends US_Migration_Translator {
// Content
public function translate_content( &$content ) {
return $this->_translate_content( $content );
}
public function translate_us_blog( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ! empty( $params['layout'] ) AND $params['layout'] == 'masonry' ) {
$params['layout'] = 'flat';
$params['masonry'] = 1;
$changed = TRUE;
}
if ( ! empty( $params['layout'] ) AND $params['layout'] == 'cards' ) {
$params['masonry'] = 1;
$changed = TRUE;
}
return $changed;
}
// Options
public function translate_theme_options( &$options ) {
$changed = FALSE;
if ( isset( $options['blog_layout'] ) AND $options['blog_layout'] == 'masonry' ) {
$options['blog_layout'] = 'flat';
$options['blog_masonry'] = 1;
$changed = TRUE;
}
if ( isset( $options['blog_layout'] ) AND $options['blog_layout'] == 'cards' ) {
$options['blog_masonry'] = 1;
$changed = TRUE;
}
if ( isset( $options['archive_layout'] ) AND $options['archive_layout'] == 'masonry' ) {
$options['archive_layout'] = 'flat';
$options['archive_masonry'] = 1;
$changed = TRUE;
}
if ( isset( $options['archive_layout'] ) AND $options['archive_layout'] == 'cards' ) {
$options['archive_masonry'] = 1;
$changed = TRUE;
}
if ( isset( $options['search_layout'] ) AND $options['search_layout'] == 'masonry' ) {
$options['search_layout'] = 'flat';
$options['search_masonry'] = 1;
$changed = TRUE;
}
if ( isset( $options['search_layout'] ) AND $options['search_layout'] == 'cards' ) {
$options['search_masonry'] = 1;
$changed = TRUE;
}
return $changed;
}
public function translate_meta( &$meta, $post_type ) {
$changed = FALSE;
$translate_meta_for = array(
'post',
'page',
'us_portfolio',
'product',
);
if ( ! in_array( $post_type, $translate_meta_for ) ) {
return $changed;
}
// Titlebar image overlay
if ( isset( $meta['us_titlebar_overlay_color'][0] ) AND isset( $meta['us_titlebar_overlay_opacity'][0] ) AND ( $meta['us_titlebar_overlay_opacity'][0] > 0 ) ) {
$meta['us_titlebar_overlay_color'][0] = $this->hex2rgba( $meta['us_titlebar_overlay_color'][0], $meta['us_titlebar_overlay_opacity'][0] / 100 );
$meta['us_titlebar_overlay_opacity'][0] = 0;
$changed = TRUE;
}
// Portfolio lighbox
if ( isset( $meta['us_lightbox'][0] ) AND $meta['us_lightbox'][0] == TRUE ) {
$meta['us_tile_action'][0] = 'lightbox';
$meta['us_lightbox'][0] = FALSE;
$changed = TRUE;
}
// Portfolio custom link
if ( isset( $meta['us_custom_link'][0] ) AND $meta['us_custom_link'][0] != '' ) {
$meta['us_tile_action'][0] = 'link';
$value = array(
'url' => $meta['us_custom_link'][0],
'target' => '',
);
if ( isset( $meta['us_custom_link_blank'][0] ) AND $meta['us_custom_link_blank'][0] == TRUE ) {
$value['target'] = '_blank';
}
$meta['us_tile_link'][0] = json_encode( $value );
$meta['us_custom_link'][0] = '';
$meta['us_custom_link_blank'][0] = FALSE;
$changed = TRUE;
}
return $changed;
}
/**
* Convert HEX value of color to RGBA format. Credits: http://mekshq.com/how-to-convert-hexadecimal-color-code-to-rgb-or-rgba-using-php/
*
* @param $color
* @param bool|FALSE $opacity
*
* @return string
*/
private function hex2rgba( $color, $opacity = FALSE ) {
$default = 'rgb(0,0,0)';
//Return default if no color provided
if ( empty( $color ) ) {
return $default;
}
//Sanitize $color if "#" is provided
if ( $color[0] == '#' ) {
$color = substr( $color, 1 );
}
//Check if color has 6 or 3 characters and get values
if ( strlen( $color ) == 6 ) {
$hex = array( $color[0] . $color[1], $color[2] . $color[3], $color[4] . $color[5] );
} elseif ( strlen( $color ) == 3 ) {
$hex = array( $color[0] . $color[0], $color[1] . $color[1], $color[2] . $color[2] );
} else {
return $default;
}
//Convert hexadec to rgb
$rgb = array_map( 'hexdec', $hex );
//Check if opacity is set(rgba or rgb)
if ( $opacity ) {
if ( abs( $opacity ) > 1 ) {
$opacity = 1.0;
}
$output = 'rgba(' . implode( ",", $rgb ) . ',' . $opacity . ')';
} else {
$output = 'rgb(' . implode( ",", $rgb ) . ')';
}
//Return rgb(a) color string
return $output;
}
}
@@ -0,0 +1,105 @@
<?php
class us_migration_3_4 extends US_Migration_Translator {
// Options
public function translate_theme_options( &$options ) {
$changed = FALSE;
global $wp_registered_sidebars;
$registered_sidebars_count = count( $wp_registered_sidebars );
// $registered_sidebars_count = 5;
$widget_areas = get_option( 'us_widget_areas' );
if ( empty( $widget_areas ) ) {
$widget_areas = array();
}
if ( class_exists( 'woocommerce' ) ) {
$registered_sidebars_count ++;
$widget_areas = array_merge( $widget_areas, array( 'shop_sidebar' => 'Shop Sidebar' ) );
update_option( 'us_widget_areas', $widget_areas );
$options['shop_sidebar_id'] = 'shop_sidebar';
$options['product_sidebar_id'] = 'shop_sidebar';
$changed = TRUE;
}
if ( class_exists( 'bbPress' ) ) {
$registered_sidebars_count ++;
$widget_areas = array_merge( $widget_areas, array( 'bbpress_sidebar' => 'bbPress Sidebar' ) );
update_option( 'us_widget_areas', $widget_areas );
$options['forum_sidebar_id'] = 'bbpress_sidebar';
$changed = TRUE;
}
$old_sbg_sidebars = get_option( 'sbg_sidebars' );
if ( is_array( $old_sbg_sidebars ) ) {
foreach ( $old_sbg_sidebars as $sidebar ) {
$registered_sidebars_count ++;
$widget_areas = array_merge( $widget_areas, array( "sidebar-$registered_sidebars_count" => $sidebar ) );
}
update_option( 'us_widget_areas', $widget_areas );
update_option( 'old_sbg_sidebars', $old_sbg_sidebars );
update_option( 'sbg_sidebars', '' );
}
return $changed;
}
public function translate_meta( &$meta, $post_type ) {
$changed = FALSE;
$translate_meta_for = array(
'post',
'page',
'us_portfolio',
);
if ( ! in_array( $post_type, $translate_meta_for ) ) {
return $changed;
}
$sidebars_name_replacement = array(
'Footer Column 1' => 'Footer First Widget',
'Footer Column 2' => 'Footer Second Widget',
'Footer Column 3' => 'Footer Third Widget',
'Footer Column 4' => 'Footer Fourth Widget',
);
if ( ! empty( $meta['sbg_selected_sidebar_replacement'][0] ) ) {
global $wp_registered_sidebars;
if ( is_array( $wp_registered_sidebars ) AND ! empty( $wp_registered_sidebars ) ) {
foreach ( $wp_registered_sidebars as $sidebar ) {
if ( isset( $sidebars_name_replacement[$sidebar['name']] ) ) {
$sidebar['name'] = $sidebars_name_replacement[$sidebar['name']];
}
if ( $meta['sbg_selected_sidebar_replacement'][0] == $sidebar['name'] OR strpos( $meta['sbg_selected_sidebar_replacement'][0], '"' . $sidebar['name'] . '"' ) !== FALSE ) {
$meta['us_sidebar_id'] = array( 0 => $sidebar['id'] );
$changed = TRUE;
}
}
}
if ( ! $changed ) {
$widget_areas = get_option( 'us_widget_areas' );
if ( is_array( $widget_areas ) ) {
foreach ( $widget_areas as $id => $sidebar ) {
if ( isset( $sidebars_name_replacement[$sidebar] ) ) {
$sidebar = $sidebars_name_replacement[$sidebar];
}
if ( $meta['sbg_selected_sidebar_replacement'][0] == $sidebar OR strpos( $meta['sbg_selected_sidebar_replacement'][0], '"' . $sidebar . '"' ) !== FALSE ) {
$meta['us_sidebar_id'] = array( 0 => $id );
$changed = TRUE;
}
}
}
}
}
return $changed;
}
}
@@ -0,0 +1,69 @@
<?php
class us_migration_3_7 extends US_Migration_Translator {
// Content
public function translate_content( &$content ) {
return $this->_translate_content( $content );
}
public function translate_vc_row( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ! empty( $params['us_bg_video'] ) AND $params['us_bg_video'] == 1 ) {
if ( isset( $params['video_mp4'] ) AND $params['video_mp4'] != '' ) {
$params['us_bg_video'] = $params['video_mp4'];
} elseif ( isset( $params['video_webm'] ) AND $params['video_webm'] != '' ) {
$params['us_bg_video'] = $params['video_webm'];
} elseif ( isset( $params['video_ogg'] ) AND $params['video_ogg'] != '' ) {
$params['us_bg_video'] = $params['video_ogg'];
} else {
unset( $params['us_bg_video'] );
}
unset( $params['video_mp4'] );
unset( $params['video_webm'] );
unset( $params['video_ogg'] );
$changed = TRUE;
}
return $changed;
}
// Options
public function translate_theme_options( &$options ) {
$changed = FALSE;
if ( isset( $options['rounded_corners'] ) AND $options['rounded_corners'] == FALSE ) {
$options['button_border_radius'] = 0;
$changed = TRUE;
}
return $changed;
}
// Meta
public function translate_meta( &$meta, $post_type ) {
$changed = FALSE;
$translate_meta_for = array(
'post',
'page',
'us_portfolio',
'product',
);
if ( ! in_array( $post_type, $translate_meta_for ) ) {
return $changed;
}
if ( isset( $meta['us_header_show_onscroll'][0] ) AND $meta['us_header_show_onscroll'][0] == TRUE ) {
$meta['us_header_sticky_pos'][0] = 'above';
$changed = TRUE;
}
return $changed;
}
}
@@ -0,0 +1,334 @@
<?php
class us_migration_3_8 extends US_Migration_Translator {
// Content
public function translate_content( &$content ) {
return $this->_translate_content( $content );
}
public function translate_us_btn( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ! empty( $params['icon'] ) ) {
$new_icon = $this->translate_icon_class( $params['icon'] );
if ( $new_icon != $params['icon'] ) {
$params['icon'] = $new_icon;
$changed = TRUE;
}
}
return $changed;
}
public function translate_us_cta( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ! empty( $params['btn_icon'] ) ) {
$new_icon = $this->translate_icon_class( $params['btn_icon'] );
if ( $new_icon != $params['btn_icon'] ) {
$params['btn_icon'] = $new_icon;
$changed = TRUE;
}
}
if ( ! empty( $params['btn2_icon'] ) ) {
$new_icon = $this->translate_icon_class( $params['btn2_icon'] );
if ( $new_icon != $params['btn2_icon'] ) {
$params['btn2_icon'] = $new_icon;
$changed = TRUE;
}
}
return $changed;
}
public function translate_us_iconbox( &$name, &$params, &$content ) {
if ( ! empty( $params['icon'] ) ) {
$new_icon = $this->translate_icon_class( $params['icon'] );
if ( $new_icon != $params['icon'] ) {
$params['icon'] = $new_icon;
}
}
if ( ! empty( $params['style'] ) AND ( $params['style'] == 'circle' OR $params['style'] == 'outlined' ) ) {
if ( ! empty( $params['size'] ) AND $params['size'] == 'tiny' ) {
$params['size'] = '20px';
if ( empty( $params['title_size'] ) ) {
$params['title_size'] = '20px';
}
} elseif ( ! empty( $params['size'] ) AND $params['size'] == 'small' ) {
$params['size'] = '28px';
} elseif ( empty( $params['size'] ) OR $params['size'] == 'medium' ) {
$params['size'] = '36px';
} elseif ( ! empty( $params['size'] ) AND $params['size'] == 'large' ) {
$params['size'] = '44px';
} elseif ( ! empty( $params['size'] ) AND $params['size'] == 'huge' ) {
$params['size'] = '52px';
}
} else {
if ( ! empty( $params['size'] ) AND $params['size'] == 'tiny' ) {
$params['size'] = '24px';
if ( empty( $params['title_size'] ) ) {
$params['title_size'] = '20px';
}
} elseif ( ! empty( $params['size'] ) AND $params['size'] == 'small' ) {
$params['size'] = '36px';
} elseif ( empty( $params['size'] ) OR $params['size'] == 'medium' ) {
$params['size'] = '48px';
} elseif ( ! empty( $params['size'] ) AND $params['size'] == 'large' ) {
$params['size'] = '70px';
} elseif ( ! empty( $params['size'] ) AND $params['size'] == 'huge' ) {
$params['size'] = '90px';
if ( ! empty( $params['img'] ) AND $params['iconpos'] != 'left' ) {
$params['size'] = '350px';
}
}
}
return TRUE;
}
public function translate_us_message( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ! empty( $params['icon'] ) ) {
$new_icon = $this->translate_icon_class( $params['icon'] );
if ( $new_icon != $params['icon'] ) {
$params['icon'] = $new_icon;
$changed = TRUE;
}
}
return $changed;
}
public function translate_us_person( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ! empty( $params['custom_icon'] ) ) {
$new_icon = $this->translate_icon_class( $params['custom_icon'] );
if ( $new_icon != $params['custom_icon'] ) {
$params['custom_icon'] = $new_icon;
$changed = TRUE;
}
}
return $changed;
}
public function translate_us_pricing( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ! empty( $params['items'] ) ) {
$items = json_decode( urldecode( $params['items'] ), TRUE );
if ( is_array( $items ) ) {
foreach ( $items as $index => $item ) {
if ( ! empty( $item['btn_icon'] ) ) {
$new_icon = $this->translate_icon_class( $item['btn_icon'] );
if ( $new_icon != $item['btn_icon'] ) {
$items[$index]['btn_icon'] = $new_icon;
$changed = TRUE;
}
}
}
if ( $changed ) {
$params['items'] = urlencode( json_encode( $items ) );
}
}
}
return $changed;
}
public function translate_us_separator( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ! empty( $params['icon'] ) ) {
$new_icon = $this->translate_icon_class( $params['icon'] );
if ( $new_icon != $params['icon'] ) {
$params['icon'] = $new_icon;
$changed = TRUE;
}
}
return $changed;
}
public function translate_us_social_links( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ! empty( $params['custom_icon'] ) ) {
$new_icon = $this->translate_icon_class( $params['custom_icon'] );
if ( $new_icon != $params['custom_icon'] ) {
$params['custom_icon'] = $new_icon;
$changed = TRUE;
}
}
if ( ! empty( $params['style'] ) AND $params['style'] == 'colored' ) {
$params['color'] = 'brand';
$changed = TRUE;
} elseif ( empty( $params['style'] ) OR $params['style'] == 'desaturated' ) {
$params['color'] = 'text';
$changed = TRUE;
}
if ( empty( $params['style'] ) OR $params['style'] != 'outlined_square' ) {
$params['style'] = 'outlined_square';
$changed = TRUE;
}
return $changed;
}
public function translate_vc_tta_section( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ! empty( $params['icon'] ) ) {
$new_icon = $this->translate_icon_class( $params['icon'] );
if ( $new_icon != $params['icon'] ) {
$params['icon'] = $new_icon;
$changed = TRUE;
}
}
return $changed;
}
// Options
public function translate_theme_options( &$options ) {
$changed = FALSE;
if ( ! empty( $options['header_contacts_custom_icon'] ) ) {
$new_icon = $this->translate_icon_class( $options['header_contacts_custom_icon'] );
if ( $new_icon != $options['header_contacts_custom_icon'] ) {
$options['header_contacts_custom_icon'] = $new_icon;
$changed = TRUE;
}
}
if ( ! empty( $options['header_socials_custom_icon'] ) ) {
$new_icon = $this->translate_icon_class( $options['header_socials_custom_icon'] );
if ( $new_icon != $options['header_socials_custom_icon'] ) {
$options['header_socials_custom_icon'] = $new_icon;
$changed = TRUE;
}
}
if ( isset( $options['header']['data'] ) AND is_array( $options['header']['data'] ) ) {
foreach ( $options['header']['data'] as $index => $item ) {
if ( ! empty( $item['icon'] ) ) {
$new_icon = $this->translate_icon_class( $item['icon'] );
if ( $new_icon != $item['icon'] ) {
$options['header']['data'][$index]['icon'] = $new_icon;
$changed = TRUE;
}
}
if ( ! empty( $item['custom_icon'] ) ) {
$new_icon = $this->translate_icon_class( $item['custom_icon'] );
if ( $new_icon != $item['custom_icon'] ) {
$options['header']['data'][$index]['custom_icon'] = $new_icon;
$changed = TRUE;
}
}
if ( substr( $index, 0, 7 ) == 'socials' ) {
if ( ! empty( $item['style'] ) ) {
if ( $item['style'] == 'colored' ) {
$options['header']['data'][$index]['color'] = 'brand';
$changed = TRUE;
} elseif ( $item['style'] == 'desaturated' ) {
$options['header']['data'][$index]['color'] = 'text';
$changed = TRUE;
}
}
}
}
}
return $changed;
}
// Widgets
public function translate_widgets( &$name, &$instance ) {
$changed = FALSE;
if ( $name == 'text' ) {
$text = $instance['text'];
if ( $this->translate_content( $text ) ) {
$instance['text'] = $text;
$changed = TRUE;
}
} elseif ( $name == 'us_socials' ) {
if ( ! empty( $instance['color'] ) ) {
if ( $instance['color'] == 'colored' ) {
$instance['color'] = 'brand';
$changed = TRUE;
} elseif ( $instance['color'] == 'desaturated' ) {
$instance['color'] = 'text';
$changed = TRUE;
}
}
if ( empty( $instance['style'] ) OR $instance['style'] != 'outlined_square' ) {
$instance['style'] = 'outlined_square';
$changed = TRUE;
}
}
return $changed;
}
private function translate_icon_class( $icon_class ) {
$icon_class = trim( $icon_class );
if ( substr( $icon_class, 0, 4 ) == 'mdfi' ) {
$icon_class = preg_replace( '/^mdfi_[^_]+_/', '', $icon_class );
} elseif ( substr( $icon_class, 0, 3 ) != 'fa-' AND substr( $icon_class, 0, 3 ) != 'fa ' ) {
$icon_class = 'fa-' . $icon_class;
}
return $icon_class;
}
}
@@ -0,0 +1,75 @@
<?php
class us_migration_3_8_2 extends US_Migration_Translator {
// Dirty hack to use theme options function to migrate sliders
public function translate_theme_options( &$options ) {
$layers_changed = FALSE;
global $wpdb;
if($wpdb->get_var('SHOW TABLES LIKE "' . $wpdb->prefix . 'revslider_slides"') == $wpdb->prefix . 'revslider_slides' ) {
$wpdb_query = 'SELECT `id`, `layers` FROM `' . $wpdb->prefix . 'revslider_slides`';
foreach ( $wpdb->get_results( $wpdb_query ) as $row ) {
$layers = $row->layers;
$layers = json_decode( $layers, TRUE );
foreach ( $layers as $id => $layer ) {
if ( ! empty( $layer['text'] ) ) {
$layer_text = $layer['text'];
$text_changed = $this->_translate_content( $layer_text );
if ( $text_changed ) {
$layers[$id]['text'] = $layer_text;
$layers_changed = TRUE;
}
}
}
if ( $layers_changed ) {
$layers = json_encode( $layers );
$wpdb->update(
$wpdb->prefix . 'revslider_slides', array(
'layers' => $layers,
), array(
'id' => $row->id,
)
);
}
}
}
return FALSE;
}
public function translate_us_btn( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ! empty( $params['icon'] ) ) {
$new_icon = $this->translate_icon_class( $params['icon'] );
if ( $new_icon != $params['icon'] ) {
$params['icon'] = $new_icon;
$changed = TRUE;
}
}
if ( ! empty( $content ) ) {
$content = '';
}
return $changed;
}
private function translate_icon_class( $icon_class ) {
$icon_class = trim( $icon_class );
if ( substr( $icon_class, 0, 4 ) == 'mdfi' ) {
$icon_class = preg_replace( '/^mdfi_[^_]+_/', '', $icon_class );
} elseif ( substr( $icon_class, 0, 3 ) != 'fa-' AND substr( $icon_class, 0, 3 ) != 'fa ' ) {
$icon_class = 'fa-' . $icon_class;
}
return $icon_class;
}
}
@@ -0,0 +1,108 @@
<?php
class us_migration_3_9 extends US_Migration_Translator {
// Content
public function translate_content( &$content ) {
return $this->_translate_content( $content );
}
public function translate_vc_row( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ! empty( $params['columns_type'] ) ) {
if ( $params['columns_type'] == 'small' ) {
unset( $params['columns_type'] );
$changed = TRUE;
} elseif ( $params['columns_type'] == 'medium' ) {
unset( $params['columns_type'] );
$params['gap'] = '20';
$changed = TRUE;
} elseif ( $params['columns_type'] == 'large' ) {
unset( $params['columns_type'] );
$params['gap'] = '35';
$changed = TRUE;
} elseif ( $params['columns_type'] == 'none' ) {
$params['columns_type'] = 'boxes';
$changed = TRUE;
}
}
return $changed;
}
public function translate_vc_row_inner( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ! empty( $params['columns_type'] ) ) {
if ( $params['columns_type'] == 'small' ) {
unset( $params['columns_type'] );
$changed = TRUE;
} elseif ( $params['columns_type'] == 'medium' ) {
unset( $params['columns_type'] );
$params['gap'] = '20';
$changed = TRUE;
} elseif ( $params['columns_type'] == 'large' ) {
unset( $params['columns_type'] );
$params['gap'] = '35';
$changed = TRUE;
} elseif ( $params['columns_type'] == 'none' ) {
$params['columns_type'] = 'boxes';
$changed = TRUE;
}
}
return $changed;
}
public function translate_us_testimonial( &$name, &$params, &$content ) {
$existing_testimonials_posts = get_posts( array( 'post_type' => 'us_testimonial', 'posts_per_page' => -1 ) );
$existing_testimonials = array();
foreach ( $existing_testimonials_posts as $testimonials_post ) {
$existing_testimonials[$testimonials_post->post_title] = $testimonials_post->post_content;
}
if ( in_array( $content, $existing_testimonials ) ) {
return FALSE;
}
$testimonial_number = 100;
$testimonial_title = 'Testimonial ' . $testimonial_number;
while ( isset( $existing_testimonials[$testimonial_title] ) AND $testimonial_number > 0 ) {
$testimonial_number--;
$testimonial_title = 'Testimonial ' . $testimonial_number;
}
$testimonials_post_array = array(
'post_type' => 'us_testimonial',
'post_date' => date( 'Y-m-d H:i', time() - ( 101 - $testimonial_number ) * 86400 ),
'post_title' => $testimonial_title,
'post_content' => $content,
'post_status' => 'publish',
);
$testimonials_post_id = wp_insert_post( $testimonials_post_array );
if ( ! empty( $params['author'] ) ) {
update_post_meta( $testimonials_post_id, 'us_testimonial_author', $params['author'] );
}
if ( ! empty( $params['company'] ) ) {
update_post_meta( $testimonials_post_id, 'us_testimonial_role', $params['company'] );
}
if ( ! empty( $params['link'] ) ) {
update_post_meta( $testimonials_post_id, 'us_testimonial_link', $params['link'] );
}
if ( ! empty( $params['img'] ) ) {
set_post_thumbnail( $testimonials_post_id, $params['img'] );
}
return FALSE;
}
}
@@ -0,0 +1,249 @@
<?php
class us_migration_4_0 extends US_Migration_Translator {
// Content
public function translate_content( &$content ) {
return $this->_translate_content( $content );
}
public function translate_vc_row( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ( ! empty( $params['columns_type'] ) AND $params['columns_type'] == 'boxes' ) AND ( empty( $params['content_placement'] ) OR $params['content_placement'] == 'default' ) ) {
$params['content_placement'] = 'middle';
$changed = TRUE;
}
return $changed;
}
public function translate_vc_row_inner( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ( ! empty( $params['columns_type'] ) AND $params['columns_type'] == 'boxes' ) AND ( empty( $params['content_placement'] ) OR $params['content_placement'] == 'default' ) ) {
$params['content_placement'] = 'middle';
$changed = TRUE;
}
return $changed;
}
public function translate_us_cta( &$name, &$params, &$content ) {
$changed = FALSE;
if ( empty( $params['btn_color'] ) ) {
$params['btn_color'] = 'primary';
$changed = TRUE;
}
return $changed;
}
public function translate_us_progbar( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ! empty( $params['color'] ) AND $params['color'] == 'contrast' ) {
$params['color'] = 'heading';
$changed = TRUE;
}
if ( empty( $params['style'] ) OR $params['style'] == '1' ) {
if ( empty( $params['size'] ) OR $params['size'] == 'medium' ) {
$params['size'] = '10px';
$changed = TRUE;
} elseif ( $params['size'] == 'small' ) {
$params['size'] = '5px';
$changed = TRUE;
} elseif ( $params['size'] == 'large' ) {
$params['size'] = '15px';
$changed = TRUE;
}
} elseif ( $params['style'] == '2' ) {
if ( empty( $params['size'] ) OR $params['size'] == 'medium' ) {
$params['size'] = '32px';
$changed = TRUE;
} elseif ( $params['size'] == 'small' ) {
$params['size'] = '24px';
$changed = TRUE;
} elseif ( $params['size'] == 'large' ) {
$params['size'] = '40px';
$changed = TRUE;
}
} elseif ( $params['style'] == '3' ) {
if ( empty( $params['size'] ) OR $params['size'] == 'medium' ) {
$params['size'] = '6px';
$changed = TRUE;
} elseif ( $params['size'] == 'small' ) {
$params['size'] = '4px';
$changed = TRUE;
} elseif ( $params['size'] == 'large' ) {
$params['size'] = '8px';
$changed = TRUE;
}
} elseif ( $params['style'] == '4' ) {
if ( empty( $params['size'] ) OR $params['size'] == 'medium' ) {
$params['size'] = '6px';
$changed = TRUE;
} elseif ( $params['size'] == 'small' ) {
$params['size'] = '4px';
$changed = TRUE;
} elseif ( $params['size'] == 'large' ) {
$params['size'] = '8px';
$changed = TRUE;
}
} elseif ( $params['style'] == '5' ) {
if ( empty( $params['size'] ) OR $params['size'] == 'medium' ) {
$params['size'] = '4px';
$changed = TRUE;
} elseif ( $params['size'] == 'small' ) {
$params['size'] = '2px';
$changed = TRUE;
} elseif ( $params['size'] == 'large' ) {
$params['size'] = '6px';
$changed = TRUE;
}
}
return $changed;
}
public function translate_theme_options( &$options ) {
// Adding default footer post
$footer_sidebars_names = array(
1 => 'footer_first',
2 => 'footer_second',
3 => 'footer_third',
4 => 'footer_fourth',
);
if ( ! get_posts(
array(
'name' => 'default-footer',
'post_type' => 'us_footer',
'post_status' => 'publish',
'numberposts' => 1,
)
)
) {
$footer_content = '';
if ( isset( $options['footer_show_top'] ) AND $options['footer_show_top'] ) {
$footer_content .= '[vc_row gap="20" color_scheme="footer-top"]';
$footer_columns = ( isset( $options['footer_columns'] ) AND in_array(
$options['footer_columns'], array(
1,
2,
3,
4,
)
) ) ? $options['footer_columns'] : 3;
$width_attribute = '';
if ( $footer_columns != 1 ) {
$width_attribute = ' width="1/' . $footer_columns . '"';
}
for ( $i = 1; $i <= $footer_columns; $i ++ ) {
$footer_content .= '[vc_column' . $width_attribute . '][vc_widget_sidebar sidebar_id="' . $footer_sidebars_names[$i] . '"][/vc_column]';
}
$footer_content .= '[/vc_row]';
}
$disabled_attribute = $copyright_text = '';
if ( ! isset( $options['footer_show_bottom'] ) OR ( ! $options['footer_show_bottom'] ) ) {
$disabled_attribute = ' disable_element="yes"';
}
if ( ! empty( $options['footer_copyright'] ) ) {
$copyright_text = $options['footer_copyright'];
}
$menu_name = 'us_footer_menu';
$locations = get_nav_menu_locations();
if ( isset( $locations[$menu_name] ) ) {
$footer_content .= '[vc_row height="small" color_scheme="footer-bottom" el_class="align_center_xs"' . $disabled_attribute . ']
[vc_column width="1/2"][vc_column_text]' . $copyright_text . '[/vc_column_text][/vc_column]
[vc_column width="1/2"][vc_wp_custommenu layout="hor" align="right" nav_menu="' . $locations[$menu_name] . '"][/vc_column]
[/vc_row]';
} else {
$footer_content .= '[vc_row height="small" color_scheme="footer-bottom"' . $disabled_attribute . ']
[vc_column][vc_column_text]<p style="text-align: center;">' . $copyright_text . '</p>[/vc_column_text][/vc_column]
[/vc_row]';
}
$footer_post_array = array(
'post_type' => 'us_footer',
'post_date' => date( 'Y-m-d H:i', time() - 86400 ),
'post_name' => 'default-footer',
'post_title' => 'Default Footer',
'post_content' => $footer_content,
'post_status' => 'publish',
);
wp_insert_post( $footer_post_array );
}
$options['footer_id'] = 'default-footer';
// Colors migration
if ( ! empty( $options['color_subfooter_bg'] ) ) {
$options['color_footer_bg_alt'] = $options['color_subfooter_bg'];
}
if ( ! empty( $options['color_subfooter_border'] ) ) {
$options['color_footer_border'] = $options['color_subfooter_border'];
}
// Create custom sidebars
$widget_areas = get_option( 'us_widget_areas' );
if ( empty( $widget_areas ) ) {
$widget_areas = array();
}
$widget_areas = array_merge(
$widget_areas, array(
'footer_first' => 'Footer Column 1',
'footer_second' => 'Footer Column 2',
'footer_third' => 'Footer Column 3',
'footer_fourth' => 'Footer Column 4',
)
);
update_option( 'us_widget_areas', $widget_areas );
return TRUE;
}
// Meta
public function translate_meta( &$meta, $post_type ) {
$changed = FALSE;
$translate_meta_for = array(
'post',
'page',
'us_portfolio',
'product',
);
if ( ! in_array( $post_type, $translate_meta_for ) ) {
return FALSE;
}
if ( isset( $meta['us_tile_action'][0] ) AND $meta['us_tile_action'][0] == 'lightbox') {
global $us_migration_current_post_id;
$thumb_url = get_the_post_thumbnail_url( $us_migration_current_post_id, 'full' );
if ( $thumb_url ) {
$meta['us_tile_link'][0] = '{"url":"' . esc_url( $thumb_url ) . '","target":""}';;
$changed = TRUE;
}
}
if ( isset( $meta['us_footer_show_top'][0] ) AND $meta['us_footer_show_top'][0] == 'hide' AND isset( $meta['us_footer_show_bottom'][0] ) AND $meta['us_footer_show_bottom'][0] == 'hide' ) {
$meta['us_footer_remove'][0] = 1;
$changed = TRUE;
}
return $changed;
}
}
@@ -0,0 +1,341 @@
<?php
class us_migration_4_10 extends US_Migration_Translator {
private $socials_config = array(
'email' => 'Email',
'facebook' => 'Facebook',
'twitter' => 'Twitter',
'google' => 'Google',
'linkedin' => 'LinkedIn',
'youtube' => 'YouTube',
'vimeo' => 'Vimeo',
'flickr' => 'Flickr',
'behance' => 'Behance',
'instagram' => 'Instagram',
'xing' => 'Xing',
'pinterest' => 'Pinterest',
'skype' => 'Skype',
'whatsapp' => 'WhatsApp',
'dribbble' => 'Dribbble',
'vk' => 'Vkontakte',
'tumblr' => 'Tumblr',
'soundcloud' => 'SoundCloud',
'twitch' => 'Twitch',
'yelp' => 'Yelp',
'deviantart' => 'DeviantArt',
'foursquare' => 'Foursquare',
'github' => 'GitHub',
'odnoklassniki' => 'Odnoklassniki',
's500px' => '500px',
'houzz' => 'Houzz',
'medium' => 'Medium',
'tripadvisor' => 'Tripadvisor',
'rss' => 'RSS',
);
private $image_sizes = NULL;
private function get_image_sizes() {
if ( is_array( $this->image_sizes ) ) {
return $this->image_sizes;
}
$this->image_sizes = array();
$custom_tnail_sizes = us_get_option( 'img_size' );
if ( is_array( $custom_tnail_sizes ) ) {
foreach ( $custom_tnail_sizes as $size_index => $size ) {
$crop = ( ! empty( $size['crop'][0] ) );
$crop_str = ( $crop ) ? '_crop' : '';
$width = ( ! empty( $size['width'] ) AND intval( $size['width'] ) > 0 ) ? intval( $size['width'] ) : 0;
$height = ( ! empty( $size['height'] ) AND intval( $size['height'] ) > 0 ) ? intval( $size['height'] ) : 0;
$old_name = 'us_img_size_' . $size_index;
$new_name = 'us_' . $width . '_' . $height . $crop_str;
$this->image_sizes[$old_name] = $new_name;
}
}
return $this->image_sizes;
}
// Content
public function translate_content( &$content ) {
return $this->_translate_content( $content );
}
public function translate_us_social_links( &$name, &$params, &$content ) {
$items = array();
foreach ( $this->socials_config as $social_link => $label ) {
if ( ! empty( $params[$social_link] ) ) {
$items[] = array(
'type' => $social_link,
'url' => $params[$social_link],
);
}
if ( isset( $params[$social_link] ) ) {
unset( $params[$social_link] );
}
}
if ( isset( $params['custom_icon'] ) ) {
$params['custom_icon'] = trim( $params['custom_icon'] );
}
if ( ! empty( $params['custom_icon'] ) AND ! empty( $params['custom_link'] ) ) {
$custom_link = array(
'type' => 'custom',
'url' => $params['custom_link'],
'icon' => $params['custom_icon'],
'color' => '#1abc9c',
);
if ( ! empty ( $params['custom_title'] ) ) {
$custom_link['title'] = $params['custom_title'];
}
if ( ! empty ( $params['custom_color'] ) ) {
$custom_link['color'] = $params['custom_color'];
}
$items[] = $custom_link;
}
if ( isset( $params['custom_icon'] ) ) {
unset( $params['custom_icon'] );
}
if ( isset( $params['custom_link'] ) ) {
unset( $params['custom_link'] );
}
if ( isset( $params['custom_title'] ) ) {
unset( $params['custom_title'] );
}
if ( isset( $params['custom_color'] ) ) {
unset( $params['custom_color'] );
}
if ( count( $items ) ) {
$params['items'] = urlencode( json_encode( $items ) );
}
return TRUE;
}
public function translate_us_blog( &$name, &$params, &$content ) {
$changed = FALSE;
if ( isset( $params['img_size'] ) AND $params['img_size'] == 'tnail-1x1' ) {
$params['img_size'] = 'us_600_600_crop';
$changed = TRUE;
}
if ( isset( $params['img_size'] ) AND $params['img_size'] == 'tnail-1x1-small' ) {
$params['img_size'] = 'us_350_350_crop';
$changed = TRUE;
}
$img_sizes = $this->get_image_sizes();
foreach ( $img_sizes as $old_name => $new_name ) {
if ( isset( $params['img_size'] ) AND $params['img_size'] == $old_name ) {
$params['img_size'] = $new_name;
$changed = TRUE;
}
}
return $changed;
}
public function translate_us_portfolio( &$name, &$params, &$content ) {
$changed = FALSE;
if ( isset( $params['img_size'] ) AND $params['img_size'] == 'tnail-1x1' ) {
$params['img_size'] = 'us_600_600_crop';
$changed = TRUE;
}
if ( isset( $params['img_size'] ) AND $params['img_size'] == 'tnail-1x1-small' ) {
$params['img_size'] = 'us_350_350_crop';
$changed = TRUE;
}
$img_sizes = $this->get_image_sizes();
foreach ( $img_sizes as $old_name => $new_name ) {
if ( isset( $params['img_size'] ) AND $params['img_size'] == $old_name ) {
$params['img_size'] = $new_name;
$changed = TRUE;
}
}
return $changed;
}
public function translate_us_gallery( &$name, &$params, &$content ) {
$changed = FALSE;
if ( isset( $params['img_size'] ) AND $params['img_size'] == 'tnail-1x1' ) {
$params['img_size'] = 'us_600_600_crop';
$changed = TRUE;
}
if ( isset( $params['img_size'] ) AND $params['img_size'] == 'tnail-1x1-small' ) {
$params['img_size'] = 'us_350_350_crop';
$changed = TRUE;
}
$img_sizes = $this->get_image_sizes();
foreach ( $img_sizes as $old_name => $new_name ) {
if ( isset( $params['img_size'] ) AND $params['img_size'] == $old_name ) {
$params['img_size'] = $new_name;
$changed = TRUE;
}
}
return $changed;
}
public function translate_us_image_slider( &$name, &$params, &$content ) {
$changed = FALSE;
if ( isset( $params['img_size'] ) AND $params['img_size'] == 'tnail-1x1' ) {
$params['img_size'] = 'us_600_600_crop';
$changed = TRUE;
}
if ( isset( $params['img_size'] ) AND $params['img_size'] == 'tnail-1x1-small' ) {
$params['img_size'] = 'us_350_350_crop';
$changed = TRUE;
}
$img_sizes = $this->get_image_sizes();
foreach ( $img_sizes as $old_name => $new_name ) {
if ( isset( $params['img_size'] ) AND $params['img_size'] == $old_name ) {
$params['img_size'] = $new_name;
$changed = TRUE;
}
}
return $changed;
}
public function translate_us_single_image( &$name, &$params, &$content ) {
$changed = FALSE;
if ( isset( $params['size'] ) AND $params['size'] == 'tnail-1x1' ) {
$params['size'] = 'us_600_600_crop';
$changed = TRUE;
}
if ( isset( $params['size'] ) AND $params['size'] == 'tnail-1x1-small' ) {
$params['size'] = 'us_350_350_crop';
$changed = TRUE;
}
$img_sizes = $this->get_image_sizes();
foreach ( $img_sizes as $old_name => $new_name ) {
if ( isset( $params['size'] ) AND $params['size'] == $old_name ) {
$params['size'] = $new_name;
$changed = TRUE;
}
}
return $changed;
}
// Options
public function translate_theme_options( &$options ) {
$img_sizes = $this->get_image_sizes();
if ( isset( $options['post_related_img_size'] ) AND $options['post_related_img_size'] == 'tnail-1x1' ) {
$options['post_related_img_size'] = 'us_600_600_crop';
}
if ( isset( $options['post_related_img_size'] ) AND $options['post_related_img_size'] == 'tnail-1x1-small' ) {
$options['post_related_img_size'] = 'us_350_350_crop';
}
if ( isset( $options['blog_img_size'] ) AND $options['blog_img_size'] == 'tnail-1x1' ) {
$options['blog_img_size'] = 'us_600_600_crop';
}
if ( isset( $options['blog_img_size'] ) AND $options['blog_img_size'] == 'tnail-1x1-small' ) {
$options['blog_img_size'] = 'us_350_350_crop';
}
if ( isset( $options['archive_img_size'] ) AND $options['archive_img_size'] == 'tnail-1x1' ) {
$options['archive_img_size'] = 'us_600_600_crop';
}
if ( isset( $options['archive_img_size'] ) AND $options['archive_img_size'] == 'tnail-1x1-small' ) {
$options['archive_img_size'] = 'us_350_350_crop';
}
if ( isset( $options['search_img_size'] ) AND $options['search_img_size'] == 'tnail-1x1' ) {
$options['search_img_size'] = 'us_600_600_crop';
}
if ( isset( $options['search_img_size'] ) AND $options['search_img_size'] == 'tnail-1x1-small' ) {
$options['search_img_size'] = 'us_350_350_crop';
}
foreach ( $img_sizes as $old_name => $new_name ) {
if ( $options['post_related_img_size'] == $old_name ) {
$options['post_related_img_size'] = $new_name;
}
if ( $options['blog_img_size'] == $old_name ) {
$options['blog_img_size'] = $new_name;
}
if ( $options['archive_img_size'] == $old_name ) {
$options['archive_img_size'] = $new_name;
}
if ( $options['search_img_size'] == $old_name ) {
$options['search_img_size'] = $new_name;
}
}
$old_img_sizes = $options['img_size'];
if ( ! is_array( $old_img_sizes ) ) {
$old_img_sizes = array();
}
$new_img_sizes = array(
array(
'width' => 350,
'height' => 350,
'crop' => array( '0' => 'crop' ),
),
array(
'width' => 600,
'height' => 600,
'crop' => array( '0' => 'crop' ),
),
);
foreach ( $old_img_sizes as $size ) {
$new_img_sizes[] = $size;
}
$options['img_size'] = $new_img_sizes;
// Regenerate sizes data for images
$attachments = get_posts(
array(
'post_type' => 'attachment',
'posts_per_page' => - 1,
'post_status' => 'any',
'numberposts' => - 1,
)
);
foreach ( $attachments as $attachment ) {
$attachment_ID = $attachment->ID;
if ( is_array( $imagedata = wp_get_attachment_metadata( $attachment_ID ) ) ) {
if ( isset ( $imagedata['sizes']['tnail-1x1-small'] ) ) {
$imagedata['sizes']['us_350_350_crop'] = $imagedata['sizes']['tnail-1x1-small'];
}
if ( isset ( $imagedata['sizes']['tnail-1x1'] ) ) {
$imagedata['sizes']['us_600_600_crop'] = $imagedata['sizes']['tnail-1x1'];
}
foreach ( $img_sizes as $old_name => $new_name ) {
if ( isset ( $imagedata['sizes'][$old_name] ) ) {
$imagedata['sizes'][$new_name] = $imagedata['sizes'][$old_name];
}
}
wp_update_attachment_metadata( $attachment_ID, $imagedata );
}
}
return TRUE;
}
}
@@ -0,0 +1,27 @@
<?php
class us_migration_4_1_2 extends US_Migration_Translator {
// Content
public function translate_content( &$content ) {
return $this->_translate_content( $content );
}
public function translate_us_gmaps( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ! empty( $params['api_key'] ) ) {
global $usof_options;
usof_load_options_once();
$usof_options['gmaps_api_key'] = $params['api_key'];
usof_save_options( $usof_options );
unset( $params['api_key'] );
$changed = TRUE;
}
return $changed;
}
}
@@ -0,0 +1,131 @@
<?php
class us_migration_4_2 extends US_Migration_Translator {
// Content
public function translate_content( &$content ) {
return $this->_translate_content( $content );
}
public function translate_us_blog( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ! empty( $params['masonry'] ) AND $params['masonry'] == 1 ) {
$params['type'] = 'masonry';
unset( $params['masonry'] );
$changed = TRUE;
}
return $changed;
}
public function translate_us_portfolio( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ! empty( $params['ratio'] ) AND $params['ratio'] == 'initial' ) {
$params['type'] = 'masonry';
unset( $params['ratio'] );
$changed = TRUE;
}
return $changed;
}
public function translate_us_testimonials( &$name, &$params, &$content ) {
$changed = FALSE;
if ( isset( $params['arrows'] ) ) {
$params['carousel_arrows'] = $params['arrows'];
unset( $params['arrows'] );
$changed = TRUE;
}
if ( isset( $params['dots'] ) ) {
$params['carousel_dots'] = $params['dots'];
unset( $params['dots'] );
$changed = TRUE;
}
if ( isset( $params['auto_scroll'] ) ) {
$params['carousel_autoplay'] = $params['auto_scroll'];
unset( $params['auto_scroll'] );
$changed = TRUE;
}
if ( isset( $params['interval'] ) ) {
$params['carousel_interval'] = $params['interval'];
unset( $params['interval'] );
$changed = TRUE;
}
return $changed;
}
public function translate_us_logos( &$name, &$params, &$content ) {
$changed = FALSE;
if ( isset( $params['arrows'] ) ) {
$params['carousel_arrows'] = $params['arrows'];
unset( $params['arrows'] );
$changed = TRUE;
}
if ( isset( $params['dots'] ) ) {
$params['carousel_dots'] = $params['dots'];
unset( $params['dots'] );
$changed = TRUE;
}
if ( isset( $params['auto_scroll'] ) ) {
$params['carousel_autoplay'] = $params['auto_scroll'];
unset( $params['auto_scroll'] );
$changed = TRUE;
}
if ( isset( $params['interval'] ) ) {
$params['carousel_interval'] = $params['interval'];
unset( $params['interval'] );
$changed = TRUE;
}
return $changed;
}
public function translate_us_image_slider( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ! empty( $params['autoplay_period'] ) AND intval( $params['autoplay_period'] ) != 0 ) {
$params['autoplay_period'] = intval( $params['autoplay_period'] ) / 1000;
$changed = TRUE;
}
return $changed;
}
// Options
public function translate_theme_options( &$options ) {
$changed = FALSE;
if ( ! empty( $options['blog_masonry'] ) AND $options['blog_masonry'] == 1 ) {
$options['blog_type'] = 'masonry';
unset( $options['blog_masonry'] );
$changed = TRUE;
}
if ( ! empty( $options['archive_masonry'] ) AND $options['archive_masonry'] == 1 ) {
$options['archive_type'] = 'masonry';
unset( $options['archive_masonry'] );
$changed = TRUE;
}
if ( ! empty( $options['search_masonry'] ) AND $options['search_masonry'] == 1 ) {
$options['search_type'] = 'masonry';
unset( $options['search_masonry'] );
$changed = TRUE;
}
return $changed;
}
}
@@ -0,0 +1,21 @@
<?php
class us_migration_4_3 extends US_Migration_Translator {
// Options
public function translate_theme_options( &$options ) {
$changed = FALSE;
if ( ! empty( $options['enable_unsupported_vc_shortcodes'] ) AND $options['enable_unsupported_vc_shortcodes'] == 1 ) {
$options['disable_extra_vc'] = 0;
} else {
$options['disable_extra_vc'] = 1;
}
unset( $options['enable_unsupported_vc_shortcodes'] );
$changed = TRUE;
return $changed;
}
}
@@ -0,0 +1,354 @@
<?php
class us_migration_4_4 extends US_Migration_Translator {
// Content
public function translate_content( &$content ) {
return $this->_translate_content( $content );
}
public function translate_us_blog( &$name, &$params, &$content ) {
$changed = FALSE;
if (
( empty( $params['type'] ) OR $params['type'] != 'masonry' ) AND (
( ( empty( $params['layout'] ) OR $params['layout'] == 'classic' ) AND ( empty( $params['cols'] ) OR $params['cols'] != 1 ) ) OR
( ! empty( $params['layout'] ) AND in_array( $params['layout'], array( 'flat', 'cards', 'tiles' ) ) )
)
) {
$params['img_size'] = 'us_img_size_2';
$changed = TRUE;
}
if (
( ! empty( $params['type'] ) AND $params['type'] == 'masonry' ) AND
( empty( $params['layout'] ) OR ! in_array( $params['layout'], array( 'smallcircle', 'smallsquare' ) ) )
) {
$params['img_size'] = 'us_img_size_1';
$changed = TRUE;
}
return $changed;
}
public function translate_us_portfolio( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ! empty( $params['img_size'] ) AND $params['img_size'] == 'tnail-masonry' ) {
$params['img_size'] = 'us_img_size_1';
$changed = TRUE;
} elseif ( ! empty( $params['img_size'] ) AND $params['img_size'] == 'tnail-3x2' ) {
$params['img_size'] = 'us_img_size_2';
$changed = TRUE;
} elseif ( empty( $params['img_size'] ) ) {
$params['img_size'] = 'us_img_size_1';
$changed = TRUE;
}
return $changed;
}
public function translate_us_gallery( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ! empty( $params['layout'] ) AND $params['layout'] == 'masonry' AND $params['columns'] < 8 ) {
$params['img_size'] = 'us_img_size_1';
$changed = TRUE;
}
return $changed;
}
public function translate_us_single_image( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ! empty( $params['frame'] ) ) {
$params['style'] = $params['frame'];
unset( $params['frame'] );
$changed = TRUE;
}
if ( ! empty( $params['lightbox'] ) AND $params['lightbox'] ) {
$params['onclick'] = 'lightbox';
unset( $params['lightbox'] );
$changed = TRUE;
}
if ( ! empty( $params['size'] ) AND $params['size'] == 'tnail-masonry' ) {
$params['size'] = 'us_img_size_1';
$changed = TRUE;
} elseif ( ! empty( $params['size'] ) AND $params['size'] == 'tnail-3x2' ) {
$params['size'] = 'us_img_size_2';
$changed = TRUE;
}
return $changed;
}
public function translate_us_image_slider( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ! empty( $params['frame'] ) ) {
$params['style'] = $params['frame'];
unset( $params['frame'] );
$changed = TRUE;
}
if ( ! empty( $params['img_size'] ) AND $params['img_size'] == 'tnail-masonry' ) {
$params['img_size'] = 'us_img_size_1';
$changed = TRUE;
} elseif ( ! empty( $params['img_size'] ) AND $params['img_size'] == 'tnail-3x2' ) {
$params['img_size'] = 'us_img_size_2';
$changed = TRUE;
}
return $changed;
}
// Meta
public function translate_meta( &$meta, $post_type ) {
$changed = FALSE;
$custom_post_types = us_get_option( 'custom_post_types_support' );
$translate_meta_for = array_merge( array( 'page', 'product', 'post', 'us_portfolio' ), $custom_post_types );
if ( ! in_array( $post_type, $translate_meta_for ) ) {
return FALSE;
}
if ( ( ! empty( $meta['us_titlebar_content'][0] ) AND in_array( $meta['us_titlebar_content'][0], array( 'all', 'caption' ) ) ) OR
( empty( $meta['us_titlebar_content'][0] ) AND ( ! empty( $meta['us_titlebar_size'][0] ) OR ! empty( $meta['us_titlebar_color'][0] ) OR ! empty( $meta['us_titlebar_image'][0] ) ) ) ) {
$meta['us_titlebar'][0] = 'custom';
$changed = TRUE;
}
if ( ! empty( $meta['us_titlebar_content'][0] ) AND $meta['us_titlebar_content'][0] == 'hide' ) {
$meta['us_titlebar'][0] = 'hide';
$changed = TRUE;
}
if ( ! empty( $meta['us_titlebar_content'][0] ) AND $meta['us_titlebar_content'][0] == 'all' ) {
$meta['us_titlebar_breadcrumbs'][0] = 'show';
$changed = TRUE;
} elseif ( ! empty( $meta['us_titlebar_content'][0] ) AND $meta['us_titlebar_content'][0] == 'caption' ) {
$meta['us_titlebar_breadcrumbs'][0] = 'hide';
$changed = TRUE;
}
if ( ! empty( $meta['us_titlebar_image_size'][0] ) ) {
$meta['us_titlebar_bg_size'][0] = $meta['us_titlebar_image_size'][0];
$changed = TRUE;
}
if ( ! empty( $meta['us_titlebar_image_parallax'][0] ) AND $meta['us_titlebar_image_parallax'][0] != 'cover' ) {
$meta['us_titlebar_bg_parallax'][0] = $meta['us_titlebar_image_parallax'][0];
$changed = TRUE;
}
if ( isset( $meta['us_titlebar_content'] ) ) {
unset( $meta['us_titlebar_content'] );
unset( $meta['us_titlebar_image_size'] );
unset( $meta['us_titlebar_image_parallax'] );
$changed = TRUE;
}
// Also remove all unused metabox options from old theme versions
if ( isset( $meta['us_subtitle'] ) ) {
unset( $meta['us_subtitle'] );
$changed = TRUE;
}
if ( isset( $meta['us_breadcrumbs'] ) ) {
unset( $meta['us_breadcrumbs'] );
$changed = TRUE;
}
if ( isset( $meta['us_header_type'] ) ) {
unset( $meta['us_header_type'] );
$changed = TRUE;
}
if ( isset( $meta['us_header_layout_type'] ) ) {
unset( $meta['us_header_layout_type'] );
$changed = TRUE;
}
if ( isset( $meta['us_header_image_stretch'] ) ) {
unset( $meta['us_header_image_stretch'] );
$changed = TRUE;
}
if ( isset( $meta['us_header_show_onscroll'] ) ) {
unset( $meta['us_header_show_onscroll'] );
$changed = TRUE;
}
if ( isset( $meta['us_show_subfooter_widgets'] ) ) {
unset( $meta['us_show_subfooter_widgets'] );
$changed = TRUE;
}
if ( isset( $meta['us_show_footer'] ) ) {
unset( $meta['us_show_footer'] );
$changed = TRUE;
}
if ( isset( $meta['us_footer_show_top'] ) ) {
unset( $meta['us_footer_show_top'] );
$changed = TRUE;
}
if ( isset( $meta['us_footer_show_bottom'] ) ) {
unset( $meta['us_footer_show_bottom'] );
$changed = TRUE;
}
if ( isset( $meta['us_portfolio_filter'] ) ) {
unset( $meta['us_portfolio_filter'] );
$changed = TRUE;
}
if ( isset( $meta['us_additional_image'] ) ) {
unset( $meta['us_additional_image'] );
$changed = TRUE;
}
if ( isset( $meta['us_tile_action'] ) ) {
unset( $meta['us_tile_action'] );
$changed = TRUE;
}
if ( isset( $meta['us_title_bg_color'] ) ) {
unset( $meta['us_title_bg_color'] );
$changed = TRUE;
}
if ( isset( $meta['us_title_text_color'] ) ) {
unset( $meta['us_title_text_color'] );
$changed = TRUE;
}
return $changed;
}
// Options
public function translate_theme_options( &$options ) {
if ( ! empty( $options['body_bg_image_attachment'] ) ) {
if ( $options['body_bg_image_attachment'] == 'fixed' ) {
$options['body_bg_image_attachment'] = 0;
} elseif ( $options['body_bg_image_attachment'] == 'scroll' ) {
$options['body_bg_image_attachment'] = 1;
} else {
unset( $options['body_bg_image_attachment'] );
}
}
foreach ( array( 'default', 'tablets', 'mobiles' ) as $state ) {
if ( ! empty( $options['header'][$state]['options']['bg_img_attachment'] ) ) {
if ( $options['header'][$state]['options']['bg_img_attachment'] == 'fixed' ) {
$options['header'][$state]['options']['bg_img_attachment'] = 0;
} elseif ( $options['header'][$state]['options']['bg_img_attachment'] == 'scroll' ) {
$options['header'][$state]['options']['bg_img_attachment'] = 1;
} else {
unset( $options['header'][$state]['options']['bg_img_attachment'] );
}
}
}
if ( isset( $options['post_preview_layout'] ) AND in_array( $options['post_preview_layout'], array( 'modern', 'trendy' ) ) ) {
$options['post_preview_img_size'] = 'full';
}
// Title Bar
if ( isset( $options['titlebar_content'] ) AND $options['titlebar_content'] == 'caption' ) {
$options['titlebar_breadcrumbs'] = 0;
}
if ( isset( $options['titlebar_content'] ) AND $options['titlebar_content'] == 'hide' ) {
$options['titlebar'] = 0;
}
if ( isset( $options['titlebar_portfolio_content'] ) AND in_array( $options['titlebar_portfolio_content'], array( 'all', 'caption' ) ) ) {
$options['titlebar_portfolio'] = 1;
}
if ( isset( $options['titlebar_post_content'] ) AND $options['titlebar_post_content'] == 'all' ) {
$options['titlebar_post'] = 1;
$options['titlebar_post_breadcrumbs'] = 1;
}
if ( isset( $options['titlebar_post_content'] ) AND $options['titlebar_post_content'] == 'caption' ) {
$options['titlebar_post'] = 1;
}
if ( isset( $options['titlebar_archive_content'] ) AND $options['titlebar_archive_content'] == 'all' ) {
$options['titlebar_archive_breadcrumbs'] = 1;
}
if ( isset( $options['titlebar_archive_content'] ) AND $options['titlebar_archive_content'] == 'hide' ) {
$options['titlebar_archive'] = 0;
}
if ( isset( $options['shop_titlebar_content'] ) AND $options['shop_titlebar_content'] == 'all' ) {
$options['titlebar_shop'] = 1;
$options['titlebar_shop_breadcrumbs'] = 1;
}
if ( isset( $options['shop_titlebar_content'] ) AND $options['shop_titlebar_content'] == 'caption' ) {
$options['titlebar_shop'] = 1;
}
if ( isset( $options['titlebar_archive_content'] ) AND $options['titlebar_archive_content'] != $options['titlebar_content'] OR $options['titlebar_archive_size'] != $options['titlebar_size'] OR $options['titlebar_archive_color'] != $options['titlebar_color'] ) {
$options['titlebar_archive_defaults'] = 0;
}
if ( isset( $options['titlebar_post_content'] ) AND $options['titlebar_post_content'] != $options['titlebar_content'] OR $options['titlebar_post_size'] != $options['titlebar_size'] OR $options['titlebar_post_color'] != $options['titlebar_color'] ) {
$options['titlebar_post_defaults'] = 0;
}
if ( $options['blog_type'] != 'masonry' AND ( ( $options['blog_layout'] == 'classic' AND $options['blog_cols'] != 1 ) OR in_array( $options['blog_layout'], array( 'flat', 'cards', 'tiles' ) ) ) ) {
$options['blog_img_size'] = 'us_img_size_2';
} elseif ( $options['blog_type'] == 'masonry' AND ! in_array( $options['blog_layout'], array( 'smallcircle', 'smallsquare' ) ) ) {
$options['blog_img_size'] = 'us_img_size_1';
}
if ( $options['archive_type'] != 'masonry' AND ( ( $options['archive_layout'] == 'classic' AND $options['archive_cols'] != 1 ) OR in_array( $options['archive_layout'], array( 'flat', 'cards', 'tiles' ) ) ) ) {
$options['archive_img_size'] = 'us_img_size_2';
} elseif ( $options['archive_type'] == 'masonry' AND ! in_array( $options['archive_layout'], array( 'smallcircle', 'smallsquare' ) ) ) {
$options['archive_img_size'] = 'us_img_size_1';
}
if ( $options['search_type'] != 'masonry' AND ( ( $options['search_layout'] == 'classic' AND $options['search_cols'] != 1 ) OR in_array( $options['search_layout'], array( 'flat', 'cards', 'tiles' ) ) ) ) {
$options['search_img_size'] = 'us_img_size_2';
} elseif ( $options['search_type'] == 'masonry' AND ! in_array( $options['search_layout'], array( 'smallcircle', 'smallsquare' ) ) ) {
$options['search_img_size'] = 'us_img_size_1';
}
$options['img_size'] = array(
1 => array(
'width' => 600,
'height' => 0,
'crop' => array(),
),
2 => array(
'width' => ( ! empty( $options['blog_img_width'] ) ) ? $options['blog_img_width'] : 600,
'height' => ( ! empty( $options['blog_img_height'] ) ) ? $options['blog_img_height'] : 400,
'crop' => array( '0' => 'crop' ),
),
);
unset( $options['blog_img_width'] );
unset( $options['blog_img_height'] );
unset( $options['titlebar_content'] );
unset( $options['titlebar_portfolio_content'] );
unset( $options['titlebar_post_content'] );
unset( $options['titlebar_archive_content'] );
unset( $options['shop_titlebar_content'] );
$options['titlebar_portfolio_defaults'] = 0;
$options['post_related_img_size'] = 'us_img_size_2';
// Regenerate sizes data for images
$attachments = get_posts( array(
'post_type' => 'attachment',
'posts_per_page' => - 1,
'post_status' => 'any',
'numberposts' => - 1,
) );
foreach ( $attachments as $attachment ) {
$attachment_ID = $attachment->ID;
if ( is_array( $imagedata = wp_get_attachment_metadata( $attachment_ID ) ) ) {
if ( isset ( $imagedata['sizes']['tnail-masonry'] ) ) {
$imagedata['sizes']['us_img_size_1'] = $imagedata['sizes']['tnail-masonry'];
}
if ( isset ( $imagedata['sizes']['tnail-3x2'] ) ) {
$imagedata['sizes']['us_img_size_2'] = $imagedata['sizes']['tnail-3x2'];
}
wp_update_attachment_metadata( $attachment_ID, $imagedata );
}
}
return TRUE;
}
}
@@ -0,0 +1,21 @@
<?php
class us_migration_4_4_1 extends US_Migration_Translator {
// Content
public function translate_content( &$content ) {
return $this->_translate_content( $content );
}
public function translate_us_single_image( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ! empty( $params['link'] ) ) {
$params['onclick'] = 'custom_link';
$changed = TRUE;
}
return $changed;
}
}
@@ -0,0 +1,41 @@
<?php
class us_migration_4_5 extends US_Migration_Translator {
// Options
public function translate_theme_options( &$options ) {
$changed = FALSE;
if ( isset( $options['preloader'] ) AND $options['preloader'] == 2 ) {
$options['preloader'] = 1;
$changed = TRUE;
}
if ( ! empty( $options['heading_font_family'] ) ) {
$result_variant = 0;
$font = explode( '|', $options['heading_font_family'], 2 );
if ( ! empty( $font[1] ) ) {
$selected_font_variants = explode( ',', $font[1] );
if ( is_array( $selected_font_variants ) ) {
foreach ( $selected_font_variants as $variant ) {
if ( strpos( $variant, 'italic' ) === FALSE AND ( $result_variant == 0 OR $result_variant > $variant ) ) {
$result_variant = $variant;
}
}
}
}
if ( $result_variant != 0 ) {
$options['h1_fontweight'] = $result_variant;
$options['h2_fontweight'] = $result_variant;
$options['h3_fontweight'] = $result_variant;
$options['h4_fontweight'] = $result_variant;
$options['h5_fontweight'] = $result_variant;
$options['h6_fontweight'] = $result_variant;
$changed = TRUE;
}
}
return $changed;
}
}
@@ -0,0 +1,482 @@
<?php
class us_migration_4_6 extends US_Migration_Translator {
// Options
public function translate_theme_options( &$options ) {
$changed = FALSE;
// Buttons options
if ( isset( $options['button_text_style'] ) AND in_array( 'bold', $options['button_text_style'] ) ) {
$options['button_fontweight'] = 700;
$changed = TRUE;
}
// Default Sidebar options
if ( isset( $options['page_sidebar_id'] ) ) {
$options['sidebar_id'] = $options['page_sidebar_id'];
unset( $options['page_sidebar_id'] );
$changed = TRUE;
}
if ( isset( $options['page_sidebar'] ) AND in_array( $options['page_sidebar'], array( 'left', 'right' ) ) ) {
$options['sidebar'] = 1;
$options['sidebar_pos'] = $options['page_sidebar'];
unset( $options['page_sidebar'] );
$changed = TRUE;
}
// Portfolio Sidebar
if ( isset( $options['portfolio_sidebar'] ) ) {
if ( $options['portfolio_sidebar'] == 'none' ) {
$options['portfolio_sidebar'] = 0;
$changed = TRUE;
} elseif ( in_array( $options['portfolio_sidebar'], array( 'left', 'right' ) ) ) {
$options['portfolio_sidebar_pos'] = $options['portfolio_sidebar'];
$options['portfolio_sidebar'] = 1;
$changed = TRUE;
}
}
// Portfolio Sided Nav
if ( isset( $options['portfolio_sided_nav'] ) AND $options['portfolio_sided_nav'] == 1 ) {
$options['portfolio_nav'] = 1;
$options['portfolio_nav_invert'] = 1;
$changed = TRUE;
}
if ( isset( $options['portfolio_prevnext_category'] ) AND $options['portfolio_prevnext_category'] == 1 ) {
$options['portfolio_nav_category'] = 1;
$changed = TRUE;
}
// Post Sidebar
if ( isset( $options['post_sidebar'] ) ) {
if ( $options['post_sidebar'] == 'none' ) {
$options['post_sidebar'] = 0;
$changed = TRUE;
} elseif ( in_array( $options['post_sidebar'], array( 'left', 'right' ) ) ) {
$options['post_sidebar_pos'] = $options['post_sidebar'];
$options['post_sidebar'] = 1;
$changed = TRUE;
}
}
// Blog Sidebar
if ( isset( $options['blog_sidebar'] ) ) {
if ( $options['blog_sidebar'] == 'none' ) {
$options['blog_sidebar'] = 0;
$changed = TRUE;
} elseif ( in_array( $options['blog_sidebar'], array( 'left', 'right' ) ) ) {
$options['blog_sidebar_pos'] = $options['blog_sidebar'];
$options['blog_sidebar'] = 1;
$changed = TRUE;
}
}
// Archive Sidebar
if ( isset( $options['archive_sidebar'] ) ) {
if ( $options['archive_sidebar'] == 'none' ) {
$options['archive_sidebar'] = 0;
$changed = TRUE;
} elseif ( in_array( $options['archive_sidebar'], array( 'left', 'right' ) ) ) {
$options['archive_sidebar_pos'] = $options['archive_sidebar'];
$options['archive_sidebar'] = 1;
$changed = TRUE;
}
}
// Search Sidebar
if ( isset( $options['search_sidebar'] ) ) {
if ( $options['search_sidebar'] == 'none' ) {
$options['search_sidebar'] = 0;
$changed = TRUE;
} elseif ( in_array( $options['search_sidebar'], array( 'left', 'right' ) ) ) {
$options['search_sidebar_pos'] = $options['search_sidebar'];
$options['search_sidebar'] = 1;
$changed = TRUE;
}
}
// Shop Sidebar
if ( isset( $options['shop_sidebar'] ) ) {
if ( $options['shop_sidebar'] == 'none' ) {
$options['shop_sidebar'] = 0;
$changed = TRUE;
} elseif ( in_array( $options['shop_sidebar'], array( 'left', 'right' ) ) ) {
$options['shop_sidebar_pos'] = $options['shop_sidebar'];
$options['shop_sidebar'] = 1;
$changed = TRUE;
}
}
// Product Sidebar
if ( isset( $options['product_sidebar'] ) ) {
if ( $options['product_sidebar'] == 'none' ) {
$options['product_sidebar'] = 0;
$changed = TRUE;
} elseif ( in_array( $options['product_sidebar'], array( 'left', 'right' ) ) ) {
$options['product_sidebar_pos'] = $options['product_sidebar'];
$options['product_sidebar'] = 1;
$changed = TRUE;
}
}
// Forum Sidebar
if ( isset( $options['forum_sidebar'] ) ) {
if ( $options['forum_sidebar'] == 'none' ) {
$options['forum_sidebar'] = 0;
$changed = TRUE;
} elseif ( in_array( $options['forum_sidebar'], array( 'left', 'right' ) ) ) {
$options['forum_sidebar_pos'] = $options['forum_sidebar'];
$options['forum_sidebar'] = 1;
$changed = TRUE;
}
}
// Menu
$locations = get_theme_mod( 'nav_menu_locations' );
if ( isset( $locations['us_main_menu'] ) ) {
$menu = wp_get_nav_menu_object( $locations['us_main_menu'] );
if ( $menu ) {
// Setting menu for regular options
$options['menu_source'] = $menu->slug;
// Setting menu for HB
if ( isset( $options['header']['data'] ) and is_array( $options['header']['data'] ) ) {
foreach ( $options['header']['data'] as $name => $data ) {
if ( substr( $name, 0, 4 ) == 'menu' ) {
$options['header']['data'][$name]['source'] = $menu->slug;
}
}
}
$changed = TRUE;
}
}
// Adding Header posts
if ( isset( $options['header']['data'] ) ) {
if ( ! post_type_exists( 'us_header' ) ) {
register_post_type(
'us_header', array(
'labels' => array(
'name' => 'Headers',
'singular_name' => 'Header',
'add_new' => 'Add Header',
'add_new_item' => 'Add Header',
'edit_item' => 'Edit Header',
),
'public' => TRUE,
'show_in_menu' => FALSE,
'exclude_from_search' => TRUE,
'show_in_admin_bar' => FALSE,
'publicly_queryable' => FALSE,
'show_in_nav_menus' => FALSE,
'capability_type' => array( 'us_footer', 'us_footers' ),
'map_meta_cap' => TRUE,
'supports' => FALSE,
'has_archive' => FALSE,
'register_meta_box_cb' => 'ushb_us_header_type_pages',
)
);
}
// If there are no header posts and we are actually performing migration
if ( ! get_posts(
array(
'name' => 'site-header',
'post_type' => 'us_header',
'post_status' => 'publish',
'numberposts' => 1,
)
) AND is_admin()
) {
$header_options = $options['header'];
$header_options['tablets']['options']['breakpoint'] = 900;
$header_options['mobiles']['options']['breakpoint'] = 600;
foreach ( $header_options['data'] as $elm_key => $data ) {
foreach ( $data as $data_key => $data_val ) {
if ( is_array( $data_val ) ) {
foreach ( $data_val as $data_subkey => $data_subval ) {
if ( strpos( $data_subval, '"' ) !== FALSE ) {
$header_options['data'][$elm_key][$data_key][$data_subkey] = str_replace( '"', '\"', $data_subval );
}
}
} elseif ( strpos( $data_val, '"' ) !== FALSE ) {
$header_options['data'][$elm_key][$data_key] = str_replace( '"', '\"', $data_val );
}
}
}
// Translating Headers if WPML is active
if ( class_exists( 'SitePress' ) AND defined( 'ICL_LANGUAGE_CODE' ) ) {
global $wpdb, $sitepress;
$sitepress->switch_lang( $sitepress->get_default_language() );
$translated_headers = array();
$theme_name = US_THEMENAME;
$strings_query = "SELECT id, name FROM {$wpdb->prefix}icl_strings WHERE name LIKE '%[usof_options_{$theme_name}][header][data]%'";
foreach ( $wpdb->get_results( $strings_query ) as $string ) {
$param_string = str_replace( "[usof_options_{$theme_name}][header][data]", '', $string->name );
if ( preg_match( '%\[([a-zA-Z0-9:_]+)\]\[([a-zA-Z0-9:_]+)\]([a-zA-Z0-9_]+)%', $param_string, $matches ) ) {
$element_name = $matches[1];
$param_name = $matches[2];
$subparam_name = $matches[3];
} elseif ( preg_match( '%\[([a-zA-Z0-9:_]+)\]([a-zA-Z0-9_]+)%', $param_string, $matches ) ) {
$element_name = $matches[1];
$param_name = $matches[2];
$subparam_name = NULL;
} else {
continue;
}
$translations_query = "SELECT language, value FROM {$wpdb->prefix}icl_string_translations WHERE string_id = {$string->id} AND status != 0";
foreach ( $wpdb->get_results( $translations_query ) as $translation ) {
if ( ! isset( $translated_headers[$translation->language] ) ) {
$translated_headers[$translation->language] = $header_options;
}
if ( $subparam_name !== NULL ) {
$translated_headers[$translation->language]['data'][$element_name][$param_name][$subparam_name] = $translation->value;
} else {
$translated_headers[$translation->language]['data'][$element_name][$param_name] = $translation->value;
}
}
}
}
if ( defined( 'JSON_UNESCAPED_UNICODE' ) ) {
$post_content = json_encode( $header_options, JSON_UNESCAPED_UNICODE );
} else {
$post_content = json_encode( $header_options );
}
$post_content = str_replace( "\\n", "\\\\n", $post_content );
$header_post_array = array(
'post_type' => 'us_header',
'post_date' => date( 'Y-m-d H:i', time() - 86400 ),
'post_name' => 'site-header',
'post_title' => 'Site Header',
'post_content' => $post_content,
'post_status' => 'publish',
);
ob_start();
$default_header_id = wp_insert_post( $header_post_array );
ob_end_clean();
$options['header_id'] = $default_header_id;
$changed = TRUE;
// Inserting translated Headers if any
if ( class_exists( 'SitePress' ) AND defined( 'ICL_LANGUAGE_CODE' ) AND count( $translated_headers ) > 0 ) {
$wpml_element_type = apply_filters( 'wpml_element_type', 'us_header' );
$set_language_args = array(
'element_id' => $default_header_id,
'element_type' => $wpml_element_type,
'language_code' => $sitepress->get_default_language(),
'trid' => NULL,
);
do_action( 'wpml_set_element_language_details', $set_language_args );
foreach ( $translated_headers as $lang => $translated_header_options ) {
if ( defined( 'JSON_UNESCAPED_UNICODE' ) ) {
$post_content = json_encode( $translated_header_options, JSON_UNESCAPED_UNICODE );
} else {
$post_content = json_encode( $translated_header_options );
}
$post_content = str_replace( "\\n", "\\\\n", $post_content );
$translated_header_post_array = array(
'post_type' => 'us_header',
'post_date' => date( 'Y-m-d H:i', time() - 86400 ),
'post_name' => 'site-header-' . $lang,
'post_title' => 'Site Header [' . $lang . ']',
'post_content' => $post_content,
'post_status' => 'publish',
);
ob_start();
$translated_header_id = wp_insert_post( $translated_header_post_array );
ob_end_clean();
$get_language_args = array('element_id' => $default_header_id, 'element_type' => 'us_header' );
$trid = apply_filters( 'wpml_element_trid', NULL, $default_header_id, $wpml_element_type );
$source_lang_code = apply_filters( 'wpml_element_language_code', $sitepress->get_default_language(), $get_language_args );
$set_language_args = array(
'element_id' => $translated_header_id,
'element_type' => $wpml_element_type,
'trid' => $trid,
'language_code' => $lang,
'source_language_code' => $source_lang_code
);
do_action( 'wpml_set_element_language_details', $set_language_args );
}
}
}
}
// Menu items
$menu_items = array();
foreach ( get_terms( array( 'taxonomy' => 'nav_menu', 'hide_empty' => TRUE ) ) as $menu_obj ) {
$menu_items = array_merge(
$menu_items,
wp_get_nav_menu_items( $menu_obj->term_id, array( 'post_status' => 'any' ) )
);
}
foreach ($menu_items as $menu_item) {
if ( isset( $menu_item->classes ) AND is_array( $menu_item->classes ) ) {
$item_settings = array();
$item_classes_meta = get_post_meta( $menu_item->ID, '_menu_item_classes' );
if ( in_array( 'columns_2', $menu_item->classes ) ) {
$item_settings['columns'] = 2;
if ( ( $key = array_search( 'columns_2', $item_classes_meta[0] ) ) !== FALSE ) {
$item_classes_meta[0][$key] = '';
}
}
if ( in_array( 'columns_3', $menu_item->classes ) ) {
$item_settings['columns'] = 3;
if ( ( $key = array_search( 'columns_3', $item_classes_meta[0] ) ) !== FALSE ) {
$item_classes_meta[0][$key] = '';
}
}
if ( in_array( 'columns_4', $menu_item->classes ) ) {
$item_settings['columns'] = 4;
if ( ( $key = array_search( 'columns_4', $item_classes_meta[0] ) ) !== FALSE ) {
$item_classes_meta[0][$key] = '';
}
}
if ( in_array( 'columns_5', $menu_item->classes ) ) {
$item_settings['columns'] = 5;
if ( ( $key = array_search( 'columns_5', $item_classes_meta[0] ) ) !== FALSE ) {
$item_classes_meta[0][$key] = '';
}
}
if ( in_array( 'columns_6', $menu_item->classes ) ) {
$item_settings['columns'] = 6;
if ( ( $key = array_search( 'columns_6', $item_classes_meta[0] ) ) !== FALSE ) {
$item_classes_meta[0][$key] = '';
}
}
if ( isset( $item_settings['columns'] ) ) {
$item_settings['padding'] = '15';
$item_settings['width'] = 'full';
$item_settings['direction'] = 0;
}
if ( in_array( 'drop_right', $menu_item->classes ) OR in_array( 'drop_left', $menu_item->classes ) ) {
$item_settings['direction'] = 1;
$item_settings['columns'] = 1;
$item_settings['padding'] = 0;
if ( ( $key = array_search( 'drop_left', $item_classes_meta[0] ) ) !== FALSE ) {
$item_classes_meta[0][$key] = '';
}
if ( ( $key = array_search( 'drop_right', $item_classes_meta[0] ) ) !== FALSE ) {
$item_classes_meta[0][$key] = '';
}
}
if ( count( $item_settings ) > 0 ) {
$item_settings['bg_image_size'] = 'cover';
$item_settings['bg_image_repeat'] = 'repeat';
$item_settings['bg_image_position'] = 'top left';
$item_settings['bg_image'] = NULL;
$item_settings['color_bg'] = '';
$item_settings['color_text'] = '';
update_post_meta( $menu_item->ID, 'us_mega_menu_settings', $item_settings );
update_post_meta( $menu_item->ID, '_menu_item_classes', $item_classes_meta[0] );
}
}
}
return $changed;
}
// Meta
public function translate_meta( &$meta, $post_type ) {
$changed = FALSE;
if ( ! empty( $meta['us_header_remove'][0] ) AND $meta['us_header_remove'][0] == 1 ) {
$meta['us_header'][0] = 'hide';
$changed = TRUE;
}
if ( ! empty( $meta['us_header_pos'][0] ) OR ( ! empty( $meta['us_header_bg'][0] ) ) OR ( ! empty( $meta['us_header_sticky_pos'][0] ) ) ) {
$meta['us_header'][0] = 'custom';
$changed = TRUE;
}
if ( ! empty( $meta['us_header_pos'][0] ) AND $meta['us_header_pos'][0] == 'sticky' ) {
$meta['us_header_sticky_override'][0] = 1;
$meta['us_header_sticky'][0] = array( 'default', 'tablets', 'mobiles' );
$changed = TRUE;
}
if ( ! empty( $meta['us_header_pos'][0] ) AND $meta['us_header_pos'][0] == 'static' ) {
$meta['us_header_sticky_override'][0] = 1;
$meta['us_header_sticky'][0] = array();
$changed = TRUE;
}
if ( ! empty( $meta['us_header_bg'][0] ) AND $meta['us_header_bg'][0] == 'transparent' ) {
$meta['us_header_transparent_override'][0] = 1;
$meta['us_header_transparent'][0] = array( 'default', 'tablets', 'mobiles' );
$changed = TRUE;
}
if ( ! empty( $meta['us_header_bg'][0] ) AND $meta['us_header_bg'][0] == 'solid' ) {
$meta['us_header_transparent_override'][0] = 1;
$meta['us_header_transparent'][0] = array();
$changed = TRUE;
}
if ( ! empty( $meta['us_sidebar'][0] ) AND $meta['us_sidebar'][0] == 'none' ) {
$meta['us_sidebar'][0] = 'hide';
$changed = TRUE;
}
if ( ! empty( $meta['us_sidebar'][0] ) AND in_array( $meta['us_sidebar'][0], array( 'right', 'left' ) ) ) {
$meta['us_sidebar_pos'][0] = $meta['us_sidebar'][0];
$meta['us_sidebar'][0] = 'custom';
$changed = TRUE;
}
if ( ! empty( $meta['us_sidebar_id'][0] ) ) {
$meta['us_sidebar'][0] = 'custom';
$changed = TRUE;
}
if ( ! empty( $meta['us_footer_remove'][0] ) AND $meta['us_footer_remove'][0] == 1 ) {
$meta['us_footer'][0] = 'hide';
$changed = TRUE;
}
if ( ! empty( $meta['us_footer_id'][0] ) ) {
$meta['us_footer'][0] = 'custom';
$changed = TRUE;
}
if ( isset( $meta['us_header_remove'][0] ) ) {
unset( $meta['us_header_remove'] );
$changed = TRUE;
}
if ( isset( $meta['us_header_pos'][0] ) ) {
unset( $meta['us_header_pos'] );
$changed = TRUE;
}
if ( isset( $meta['us_header_bg'][0] ) ) {
unset( $meta['us_header_bg'] );
$changed = TRUE;
}
if ( isset( $meta['us_footer_remove'][0] ) ) {
unset( $meta['us_footer_remove'] );
$changed = TRUE;
}
return $changed;
}
}
@@ -0,0 +1,18 @@
<?php
class us_migration_4_7 extends US_Migration_Translator {
// Options
public function translate_theme_options( &$options ) {
if ( isset( $options['generate_css_file'] ) AND $options['generate_css_file'] ) {
$upload_dir = wp_upload_dir();
if ( wp_is_writable( $upload_dir['basedir'] ) ) {
$options['optimize_assets'] = TRUE;
}
}
unset( $options['generate_css_file'] );
return TRUE;
}
}
@@ -0,0 +1,33 @@
<?php
class us_migration_4_8 extends US_Migration_Translator {
// Content
public function translate_content( &$content ) {
return $this->_translate_content( $content );
}
public function translate_us_message( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ! empty( $params['color'] ) AND $params['color'] == 'info' ) {
$params['color'] = 'blue';
$changed = TRUE;
}
if ( ! empty( $params['color'] ) AND $params['color'] == 'attention' ) {
$params['color'] = 'yellow';
$changed = TRUE;
}
if ( ! empty( $params['color'] ) AND $params['color'] == 'success' ) {
$params['color'] = 'green';
$changed = TRUE;
}
if ( ! empty( $params['color'] ) AND $params['color'] == 'error' ) {
$params['color'] = 'red';
$changed = TRUE;
}
return $changed;
}
}
@@ -0,0 +1,73 @@
<?php
class us_migration_4_9 extends US_Migration_Translator {
// Content
public function translate_content( &$content ) {
return $this->_translate_content( $content );
}
public function translate_us_logos( &$name, &$params, &$content ) {
$changed = FALSE;
if ( empty( $params['carousel_autoplay'] ) OR $params['carousel_autoplay'] == 0 ) {
$params['breakpoint_1_autoplay'] = 0;
$params['breakpoint_2_autoplay'] = 0;
$params['breakpoint_3_autoplay'] = 0;
$changed = TRUE;
}
return $changed;
}
// Options
public function translate_theme_options( &$options ) {
update_option( US_THEMENAME . '_editor_caps_set', 1 );
$changed = FALSE;
if ( isset( $options['h1_fontsize'] ) AND isset( $options['h1_letterspacing'] ) AND $options['h1_letterspacing'] != 0 ) {
$options['h1_letterspacing'] = round( $options['h1_letterspacing'] / $options['h1_fontsize'], 2 );
$changed = TRUE;
}
if ( isset( $options['h2_fontsize'] ) AND isset( $options['h2_letterspacing'] ) AND $options['h2_letterspacing'] != 0 ) {
$options['h2_letterspacing'] = round( $options['h2_letterspacing'] / $options['h2_fontsize'], 2 );
$changed = TRUE;
}
if ( isset( $options['h3_fontsize'] ) AND isset( $options['h3_letterspacing'] ) AND $options['h3_letterspacing'] != 0 ) {
$options['h3_letterspacing'] = round( $options['h3_letterspacing'] / $options['h3_fontsize'], 2 );
$changed = TRUE;
}
if ( isset( $options['h4_fontsize'] ) AND isset( $options['h4_letterspacing'] ) AND $options['h4_letterspacing'] != 0 ) {
$options['h4_letterspacing'] = round( $options['h4_letterspacing'] / $options['h4_fontsize'], 2 );
$changed = TRUE;
}
if ( isset( $options['h5_fontsize'] ) AND isset( $options['h5_letterspacing'] ) AND $options['h5_letterspacing'] != 0 ) {
$options['h5_letterspacing'] = round( $options['h5_letterspacing'] / $options['h5_fontsize'], 2 );
$changed = TRUE;
}
if ( isset( $options['h6_fontsize'] ) AND isset( $options['h6_letterspacing'] ) AND $options['h6_letterspacing'] != 0 ) {
$options['h6_letterspacing'] = round( $options['h6_letterspacing'] / $options['h6_fontsize'], 2 );
$changed = TRUE;
}
if ( isset( $options['button_fontsize'] ) AND isset( $options['button_letterspacing'] ) AND $options['button_letterspacing'] != 0 ) {
$options['button_letterspacing'] = round( $options['button_letterspacing'] / $options['button_fontsize'], 2 );
$changed = TRUE;
}
if ( isset( $options['button_hover'] ) AND $options['button_hover'] == 'shadow' ) {
$options['button_hover'] = 'none';
$options['button_shadow_hover'] = 1;
$changed = TRUE;
}
return $changed;
}
}
@@ -0,0 +1,25 @@
<?php
class us_migration_4_9_1 extends US_Migration_Translator {
// Options
public function translate_theme_options( &$options ) {
$changed = FALSE;
if ( isset( $options['disable_effects_width'] ) AND $options['disable_effects_width'] == 1024 ) {
$options['disable_effects_width'] = 1025;
$changed = TRUE;
}
if ( isset( $options['columns_stacking_width'] ) AND $options['columns_stacking_width'] == 1024 ) {
$options['columns_stacking_width'] = 1025;
$changed = TRUE;
}
if ( isset( $options['columns_stacking_width'] ) AND $options['columns_stacking_width'] == 767 ) {
$options['columns_stacking_width'] = 768;
$changed = TRUE;
}
return $changed;
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,339 @@
<?php
class us_migration_5_1 extends US_Migration_Translator {
// Content
public function translate_content( &$content ) {
return $this->_translate_content( $content );
}
public function translate_gallery( &$name, &$params, &$content ) {
$changed = FALSE;
if ( isset( $params['size'] ) AND $params['size'] == 'medium_large' ) {
$params['size'] = 'us_768_0';
$changed = TRUE;
}
return $changed;
}
public function translate_us_gallery( &$name, &$params, &$content ) {
$changed = FALSE;
if ( isset( $params['img_size'] ) AND $params['img_size'] == 'medium_large' ) {
$params['img_size'] = 'us_768_0';
$changed = TRUE;
}
return $changed;
}
public function translate_us_grid( &$name, &$params, &$content ) {
$changed = FALSE;
if ( isset( $params['items_offset'] ) AND $params['items_offset'] != '' ) {
$params['exclude_items'] = 'offset';
$changed = TRUE;
}
if ( isset( $params['img_size'] ) AND $params['img_size'] == 'medium_large' ) {
$params['img_size'] = 'us_768_0';
$changed = TRUE;
}
return $changed;
}
public function translate_us_image_slider( &$name, &$params, &$content ) {
$changed = FALSE;
if ( isset( $params['img_size'] ) AND $params['img_size'] == 'medium_large' ) {
$params['img_size'] = 'us_768_0';
$changed = TRUE;
}
return $changed;
}
public function translate_us_logos( &$name, &$params, &$content ) {
$changed = FALSE;
if ( isset( $params['img_size'] ) AND $params['img_size'] == 'medium_large' ) {
$params['img_size'] = 'us_768_0';
$changed = TRUE;
}
return $changed;
}
public function translate_us_person( &$name, &$params, &$content ) {
$changed = FALSE;
if ( isset( $params['img_size'] ) AND $params['img_size'] == 'medium_large' ) {
$params['img_size'] = 'us_768_0';
$changed = TRUE;
}
return $changed;
}
public function translate_us_single_image( &$name, &$params, &$content ) {
$changed = FALSE;
if ( isset( $params['size'] ) AND $params['size'] == 'medium_large' ) {
$params['size'] = 'us_768_0';
$changed = TRUE;
}
return $changed;
}
public function translate_us_social_links( &$name, &$params, &$content ) {
if ( ! empty( $params['style'] ) AND $params['style'] == 'solid_square' ) {
$params['style'] = 'solid';
if ( us_get_option( 'rounded_corners' ) ) {
$params['shape'] = 'rounded';
}
} elseif ( ! empty( $params['style'] ) AND $params['style'] == 'outlined_square' ) {
$params['style'] = 'outlined';
if ( us_get_option( 'rounded_corners' ) ) {
$params['shape'] = 'rounded';
}
} elseif ( ! empty( $params['style'] ) AND $params['style'] == 'solid_circle' ) {
$params['style'] = 'solid';
$params['shape'] = 'circle';
} elseif ( ! empty( $params['style'] ) AND $params['style'] == 'outlined_circle' ) {
$params['style'] = 'outlined';
$params['shape'] = 'circle';
} else {
$params['gap'] = '0';
}
return TRUE;
}
// Options
public function translate_theme_options( &$options ) {
/*
* Replace medim_large image size for Theme Options
*/
if ( isset( $options['post_preview_img_size'] ) AND $options['post_preview_img_size'] == 'medium_large' ) {
$options['post_preview_img_size'] = 'us_768_0';
}
if ( isset( $options['post_related_img_size'] ) AND $options['post_related_img_size'] == 'medium_large' ) {
$options['post_related_img_size'] = 'us_768_0';
}
if ( isset( $options['blog_img_size'] ) AND $options['blog_img_size'] == 'medium_large' ) {
$options['blog_img_size'] = 'us_768_0';
}
if ( isset( $options['archive_img_size'] ) AND $options['archive_img_size'] == 'medium_large' ) {
$options['archive_img_size'] = 'us_768_0';
}
if ( isset( $options['search_img_size'] ) AND $options['search_img_size'] == 'medium_large' ) {
$options['search_img_size'] = 'us_768_0';
}
$new_img_size_present = FALSE;
if ( empty( $options['img_size'] ) OR ! is_array( $options['img_size'] ) ) {
$options['img_size'] = array();
}
foreach( $options['img_size'] as $i => $size ) {
if ( $size['width'] == 768 AND $size['height'] == 0 AND ( $size['crop'] == array() OR empty( $size['crop'] ) ) ) {
$new_img_size_present = TRUE;
}
}
if ( ! $new_img_size_present ) {
$options['img_size'][] = array(
'width' => 768,
'height' => 0,
'crop' => array(),
);
}
/*
* Translate Social links in headers
*/
ob_start();
$headers = get_posts( array( 'post_type' => 'us_header', 'numberposts' => - 1, ) );
ob_end_clean();
foreach ( $headers as $header ) {
if ( ! empty( $header->post_content ) AND substr( strval( $header->post_content ), 0, 1 ) === '{' ) {
try {
$header_settings = json_decode( $header->post_content, TRUE );
$header_changed = FALSE;
if ( isset( $header_settings['data'] ) and is_array( $header_settings['data'] ) ) {
foreach ( $header_settings['data'] as $name => $data ) {
// Find the social links element
if ( substr( $name, 0, 7 ) == 'socials' ) {
$social_items = array();
foreach ( $this->old_social_links as $link_type => $link_title ) {
if ( ! empty( $data[$link_type] ) ) {
$social_items[] = array(
'type' => $link_type,
'url' => $data[$link_type],
);
}
}
if ( ! empty( $data['custom_url'] ) AND ! empty( $data['custom_icon'] ) ){
$social_items[] = array(
'type' => 'custom',
'url' => $data['custom_url'],
'icon' => $data['custom_icon'],
'title' => ( ! empty ( $data['custom_title'] ) ) ? $data['custom_title'] : '',
'color' => ( ! empty ( $data['custom_color'] ) ) ? $data['custom_color'] : '#1abc9c',
);
}
if ( count( $social_items ) > 0 ) {
$header_settings['data'][$name]['items'] = $social_items;
$header_changed = TRUE;
}
if ( ! empty( $data['hover'] ) AND $data['hover'] == 'default' ) {
$header_settings['data'][$name]['hover'] = 'slide';
}
}
}
}
if ( $header_changed ) {
ob_start();
wp_update_post(
array(
'ID' => $header->ID,
'post_content' => str_replace( "\\'", "'", json_encode( wp_slash( $header_settings ), JSON_UNESCAPED_UNICODE ) ),
)
);
ob_end_clean();
}
}
catch ( Exception $e ) {
}
}
}
/*
* Replace medim_large image size for Grid layouts
*/
ob_start();
$grid_layouts = get_posts( array( 'post_type' => 'us_grid_layout', 'numberposts' => - 1, ) );
ob_end_clean();
foreach ( $grid_layouts as $grid_layout ) {
if ( ! empty( $grid_layout->post_content ) AND substr( strval( $grid_layout->post_content ), 0, 1 ) === '{' ) {
try {
$grid_layout_settings = json_decode( $grid_layout->post_content, TRUE );
$grid_layout_changed = FALSE;
if ( isset( $grid_layout_settings['data'] ) and is_array( $grid_layout_settings['data'] ) ) {
foreach ( $grid_layout_settings['data'] as $name => $data ) {
// Post Image and Post Custom Field elements
if ( substr( $name, 0, 10 ) == 'post_image' OR substr( $name, 0, 17 ) == 'post_custom_field' ) {
if ( ! empty( $data['thumbnail_size'] ) AND $data['thumbnail_size'] == 'medium_large' ) {
$header_settings['data'][$name]['thumbnail_size'] = 'us_768_0';
$grid_layout_changed = TRUE;
}
}
}
}
if ( $grid_layout_changed ) {
ob_start();
wp_update_post(
array(
'ID' => $grid_layout->ID,
'post_content' => str_replace( "\\'", "'", json_encode( wp_slash( $grid_layout_settings ), JSON_UNESCAPED_UNICODE ) ),
)
);
ob_end_clean();
}
}
catch ( Exception $e ) {
}
}
}
/*
* Regenerate sizes data for images
*/
$attachments = get_posts(
array(
'post_type' => 'attachment',
'posts_per_page' => - 1,
'post_status' => 'any',
'numberposts' => - 1,
)
);
foreach ( $attachments as $attachment ) {
$attachment_ID = $attachment->ID;
if ( is_array( $imagedata = wp_get_attachment_metadata( $attachment_ID ) ) ) {
if ( isset ( $imagedata['sizes']['medium_large'] ) ) {
$imagedata['sizes']['us_768_0'] = $imagedata['sizes']['medium_large'];
}
wp_update_attachment_metadata( $attachment_ID, $imagedata );
}
}
return TRUE;
}
public function translate_widgets( &$name, &$instance ) {
$changed = FALSE;
if ( $name == 'us_socials' ) {
if ( ! empty( $instance['style'] ) AND $instance['style'] == 'solid_square' ) {
$instance['style'] = 'solid';
if ( us_get_option( 'rounded_corners' ) ) {
$instance['shape'] = 'rounded';
}
} elseif ( ! empty( $instance['style'] ) AND $instance['style'] == 'outlined_square' ) {
$instance['style'] = 'outlined';
if ( us_get_option( 'rounded_corners' ) ) {
$instance['shape'] = 'rounded';
}
} elseif ( ! empty( $instance['style'] ) AND $instance['style'] == 'solid_circle' ) {
$instance['style'] = 'solid';
$instance['shape'] = 'circle';
} elseif ( ! empty( $instance['style'] ) AND $instance['style'] == 'outlined_circle' ) {
$instance['style'] = 'outlined';
$instance['shape'] = 'circle';
}
$changed = TRUE;
}
return $changed;
}
private $old_social_links = array(
'email' => 'Email',
'facebook' => 'Facebook',
'twitter' => 'Twitter',
'google' => 'Google',
'linkedin' => 'LinkedIn',
'youtube' => 'YouTube',
'vimeo' => 'Vimeo',
'flickr' => 'Flickr',
'behance' => 'Behance',
'instagram' => 'Instagram',
'xing' => 'Xing',
'pinterest' => 'Pinterest',
'skype' => 'Skype',
'whatsapp' => 'WhatsApp',
'dribbble' => 'Dribbble',
'vk' => 'Vkontakte',
'tumblr' => 'Tumblr',
'soundcloud' => 'SoundCloud',
'twitch' => 'Twitch',
'yelp' => 'Yelp',
'deviantart' => 'DeviantArt',
'foursquare' => 'Foursquare',
'github' => 'GitHub',
'odnoklassniki' => 'Odnoklassniki',
's500px' => '500px',
'houzz' => 'Houzz',
'medium' => 'Medium',
'tripadvisor' => 'Tripadvisor',
'rss' => 'RSS',
);
}
@@ -0,0 +1,55 @@
<?php
class us_migration_5_2 extends US_Migration_Translator {
// Options
public function translate_theme_options( &$options ) {
/*
* Translate Text element in headers
*/
ob_start();
$headers = get_posts( array( 'post_type' => 'us_header', 'numberposts' => - 1, ) );
ob_end_clean();
foreach ( $headers as $header ) {
if ( ! empty( $header->post_content ) AND substr( strval( $header->post_content ), 0, 1 ) === '{' ) {
try {
$header_settings = json_decode( $header->post_content, TRUE );
$header_changed = FALSE;
if ( isset( $header_settings['data'] ) and is_array( $header_settings['data'] ) ) {
foreach ( $header_settings['data'] as $name => $data ) {
// Find the text element
if ( substr( $name, 0, 4 ) == 'text' ) {
if ( ! empty( $data['text'] ) AND strpos( $data['text'], '<strong' ) !== FALSE ) {
if ( empty( $header_settings['data'][$name]['text_style'] ) ) {
$header_settings['data'][$name]['text_style'] = array();
}
if ( ! in_array( 'bold', $header_settings['data'][$name]['text_style'] ) ) {
$header_settings['data'][$name]['text_style'][] = 'bold';
}
$header_changed = TRUE;
}
}
}
}
if ( $header_changed ) {
ob_start();
wp_update_post(
array(
'ID' => $header->ID,
'post_content' => str_replace( "\\'", "'", json_encode( wp_slash( $header_settings ), JSON_UNESCAPED_UNICODE ) ),
)
);
ob_end_clean();
}
}
catch ( Exception $e ) {
}
}
}
return FALSE;
}
}
@@ -0,0 +1,864 @@
<?php
class us_migration_5_3 extends US_Migration_Translator {
private $woocommerce_shop_page_id = NULL;
// Content
public function translate_content( &$content ) {
return $this->_translate_content( $content );
}
public function translate_us_gmaps( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ! empty( $params['markers'] ) ) {
try {
$markers = json_decode( urldecode( $params['markers'] ), TRUE );
if ( is_array( $markers ) AND count( $markers ) ) {
foreach ( $markers as $index => $marker ) {
if ( ! empty( $marker['marker_latitude'] ) AND ! empty( $marker['marker_longitude'] ) ) {
$markers[$index]['marker_address'] = $marker['marker_latitude'] . ' ' . $marker['marker_longitude'];
$changed = TRUE;
}
}
}
if ( $changed ) {
$params['markers'] = urlencode( json_encode( $markers ) );
}
}
catch ( Exception $e ) {
}
}
if ( ! empty( $params['latitude'] ) AND ! empty( $params['longitude'] ) ) {
$params['marker_address'] = $params['latitude'] . ' ' . $params['longitude'];
$changed = TRUE;
}
return $changed;
}
public function translate_us_grid( &$name, &$params, &$content ) {
$changed = FALSE;
$known_post_type_taxonomies = array(
'post' => 'category',
'us_portfolio' => 'us_portfolio_category',
'us_testimonial' => 'us_testimonial_category',
'product' => 'product_cat',
);
$post_type = isset( $params['post_type'] ) ? $params['post_type'] : 'post';
if ( isset( $known_post_type_taxonomies[$post_type] ) ) {
$taxonomy = $known_post_type_taxonomies[$post_type];
if ( isset( $params[$post_type . '_categories'] ) ) {
$params['taxonomy_' . $taxonomy] = $params[$post_type . '_categories'];
unset( $params[$post_type . '_categories'] );
$changed = TRUE;
}
if ( isset( $params['filter'] ) AND $params['filter'] == 'category' ) {
$params['filter_' . $post_type] = $taxonomy;
unset( $params['filter'] );
$changed = TRUE;
}
}
return $changed;
}
// Theme Options
public function translate_theme_options( &$options ) {
// Migrate CPT us_footer to us_page_block
ob_start();
register_post_type(
'us_footer', array(
'labels' => array(
'name' => 'Page Blocks',
),
'public' => FALSE,
)
);
$footers = get_posts(
array(
'post_type' => 'us_footer',
'posts_per_page' => - 1,
'post_status' => 'any',
)
);
foreach ( $footers as $footer ) {
wp_update_post(
array(
'ID' => $footer->ID,
'post_type' => 'us_page_block',
)
);
}
// Deregister us_footer CPT
global $wp_post_types;
if ( isset( $wp_post_types['us_footer'] ) ) {
unset( $wp_post_types['us_footer'] );
}
// In case WP mechanism didn't work, change us_footer post type to us_page_block with SQL
global $wpdb;
$wpdb_query = "UPDATE `" . $wpdb->posts . "` SET `post_type` = 'us_page_block' WHERE `post_type` = 'us_footer'";
$wpdb->query( $wpdb_query );
ob_end_clean();
// Get Custom Post Types
$post_type_args = array(
'public' => TRUE,
'_builtin' => FALSE,
);
$post_types = get_post_types( $post_type_args, 'objects', 'and' );
$supported_post_types = array(
// Theme
'us_portfolio',
'us_testimonial',
'us_header',
'us_footer',
'us_grid_layout',
// WooCommerce
'product',
// bbPress
'forum',
'topic',
'reply',
// The Events Calendar
'tribe_events',
'tribe-ea-record'
);
$cpt_as_posts = array();
foreach ( $post_types as $post_type_name => $post_type ) {
if ( ! in_array( $post_type_name, $supported_post_types ) ) {
$cpt_as_posts[$post_type_name] = $post_type_name;
}
}
if ( ! empty( $options['custom_post_types_support'] ) AND is_array( $options['custom_post_types_support'] ) ) {
foreach ( $options['custom_post_types_support'] as $cpt ) {
unset( $cpt_as_posts[$cpt] );
}
}
if ( count( $cpt_as_posts ) > 0 ) {
$options['cpt_as_posts'] = array_keys( $cpt_as_posts );
}
// Footer Settings
$footer_fields_translate = array(
// New field => Old field to copy from
'footer_id' => 'footer_id',
'footer_portfolio_id' => 'footer_portfolio_id',
'footer_post_id' => 'footer_post_id',
'footer_search_id' => 'footer_archive_id', // Dev note: footer_search_id should be set before footer_archive_id
'footer_archive_id' => 'footer_archive_id',
'footer_shop_id' => 'footer_shop_id',
'footer_product_id' => 'footer_product_id',
);
foreach ( $footer_fields_translate as $new_field => $old_field ) {
$defaults_field = str_replace( '_id', '_defaults', $old_field );
if ( $old_field != 'footer_id' AND isset( $options[$defaults_field] ) AND $options[$defaults_field] ) {
$options[$new_field] = '__defaults__';
} else {
if ( isset( $options[$old_field] ) ) {
$args = array(
'name' => $options[$old_field],
'post_type' => 'us_page_block',
'numberposts' => 1
);
$footer_post = get_posts( $args );
if ( $footer_post ) {
$footer_post = $footer_post[0];
$options[$new_field] = $footer_post->ID;
}
}
}
}
// Sidebar for Defaults
$show_default_sidebar = TRUE;
if ( isset( $options['sidebar'] ) AND $options['sidebar'] == 0 ) {
$options['sidebar_id'] = '';
$show_default_sidebar = FALSE;
}
// Sidebars for Portfolio Pages
if ( isset( $options['portfolio_sidebar'] ) AND $options['portfolio_sidebar'] == 0 ) {
if ( $show_default_sidebar ) {
$options['sidebar_portfolio_id'] = '';
}
} else {
$options['sidebar_portfolio_id'] = $options['portfolio_sidebar_id'];
}
$options['sidebar_portfolio_pos'] = $options['portfolio_sidebar_pos'];
// Sidebars for Posts
if ( isset( $options['post_sidebar'] ) AND $options['post_sidebar'] == 0 ) {
if ( $show_default_sidebar ) {
$options['sidebar_post_id'] = '';
}
} else {
$options['sidebar_post_id'] = $options['post_sidebar_id'];
}
$options['sidebar_post_pos'] = $options['post_sidebar_pos'];
// Sidebars for Blog Home page
if ( isset( $options['blog_sidebar'] ) AND $options['blog_sidebar'] == 0 ) {
if ( $show_default_sidebar ) {
$options['sidebar_blog_id'] = '';
}
} else {
$options['sidebar_blog_id'] = $options['blog_sidebar_id'];
}
$options['sidebar_blog_pos'] = $options['blog_sidebar_pos'];
// Sidebars for Archives
if ( isset( $options['archive_sidebar'] ) AND $options['archive_sidebar'] == 0 ) {
if ( $show_default_sidebar ) {
$options['sidebar_archive_id'] = '';
}
} else {
$options['sidebar_archive_id'] = $options['archive_sidebar_id'];
}
$options['sidebar_archive_pos'] = $options['archive_sidebar_pos'];
// Sidebars for Search Results
if ( isset( $options['search_sidebar'] ) AND $options['search_sidebar'] == 0 ) {
if ( $show_default_sidebar ) {
$options['sidebar_search_id'] = '';
}
} else {
$options['sidebar_search_id'] = $options['search_sidebar_id'];
}
$options['sidebar_search_pos'] = $options['search_sidebar_pos'];
// Sidebars for Shop pages
if ( isset( $options['shop_sidebar'] ) AND $options['shop_sidebar'] == 0 ) {
if ( $show_default_sidebar ) {
$options['sidebar_shop_id'] = '';
}
} else {
$options['sidebar_shop_id'] = $options['shop_sidebar_id'];
}
$options['sidebar_shop_pos'] = $options['shop_sidebar_pos'];
// Sidebars for Products
if ( isset( $options['product_sidebar'] ) AND $options['product_sidebar'] == 0 ) {
if ( $show_default_sidebar ) {
$options['sidebar_product_id'] = '';
}
} else {
$options['sidebar_product_id'] = $options['product_sidebar_id'];
}
$options['sidebar_product_pos'] = $options['product_sidebar_pos'];
// Sidebars for Tribe Events
if ( isset( $options['event_sidebar'] ) AND $options['event_sidebar'] == 0 ) {
if ( $show_default_sidebar ) {
$options['sidebar_tribe_events_id'] = '';
}
} else {
$options['sidebar_tribe_events_id'] = $options['event_sidebar_id'];
}
$options['sidebar_tribe_events_pos'] = $options['event_sidebar_pos'];
// Sidebars for Forums
if ( isset( $options['forum_sidebar'] ) AND $options['forum_sidebar'] == 0 ) {
if ( $show_default_sidebar ) {
$options['sidebar_forum_id'] = '';
$options['sidebar_topic_id'] = '';
}
} else {
$options['sidebar_forum_id'] = $options['forum_sidebar_id'];
$options['sidebar_topic_id'] = $options['forum_sidebar_id'];
}
$options['sidebar_forum_pos'] = $options['forum_sidebar_pos'];
$options['sidebar_topic_pos'] = $options['forum_sidebar_pos'];
// Titlebar for Defaults
$show_default_titlebar = FALSE;
$post_title = 'Default Titlebar';
$title = $description = NULL;
$size = isset( $options['titlebar_size'] ) ? $options['titlebar_size'] : NULL;
$color = isset( $options['titlebar_color'] ) ? $options['titlebar_color'] : NULL;
$breadcrumbs = isset( $options['titlebar_breadcrumbs'] ) ? $options['titlebar_breadcrumbs'] : NULL;
$bg_image = isset( $options['titlebar_bg_image'] ) ? $options['titlebar_bg_image'] : NULL;
$bg_size = isset( $options['titlebar_bg_size'] ) ? $options['titlebar_bg_size'] : NULL;
$bg_repeat = isset( $options['titlebar_bg_repeat'] ) ? $options['titlebar_bg_repeat'] : NULL;
$bg_position = isset( $options['titlebar_bg_position'] ) ? $options['titlebar_bg_position'] : NULL;
$bg_parallax = isset( $options['titlebar_bg_parallax'] ) ? $options['titlebar_bg_parallax'] : NULL;
$bg_overlay = isset( $options['titlebar_overlay_color'] ) ? $options['titlebar_overlay_color'] : NULL;
$titlebar_id = $this->add_titlebar( $post_title, $title, $description, $size, $color, $breadcrumbs, $bg_image, $bg_size, $bg_repeat, $bg_position, $bg_parallax, $bg_overlay );
if ( isset( $options['titlebar'] ) AND $options['titlebar'] ) {
$options['titlebar_id'] = $titlebar_id;
$show_default_titlebar = TRUE;
}
// Titlebar for Portfolio Pages
if ( isset( $options['titlebar_portfolio'] ) AND $options['titlebar_portfolio'] ) {
if ( isset( $options['titlebar_portfolio_defaults'] ) AND $options['titlebar_portfolio_defaults'] == 0 ) {
$post_title = 'Titlebar for Portfolio';
$title = $description = NULL;
$size = isset( $options['titlebar_portfolio_size'] ) ? $options['titlebar_portfolio_size'] : NULL;
$color = isset( $options['titlebar_portfolio_color'] ) ? $options['titlebar_portfolio_color'] : NULL;
$breadcrumbs = isset( $options['titlebar_portfolio_breadcrumbs'] ) ? $options['titlebar_portfolio_breadcrumbs'] : NULL;
$bg_image = isset( $options['titlebar_portfolio_bg_image'] ) ? $options['titlebar_portfolio_bg_image'] : NULL;
$bg_size = isset( $options['titlebar_portfolio_bg_size'] ) ? $options['titlebar_portfolio_bg_size'] : NULL;
$bg_repeat = isset( $options['titlebar_portfolio_bg_repeat'] ) ? $options['titlebar_portfolio_bg_repeat'] : NULL;
$bg_position = isset( $options['titlebar_portfolio_bg_position'] ) ? $options['titlebar_portfolio_bg_position'] : NULL;
$bg_parallax = isset( $options['titlebar_portfolio_bg_parallax'] ) ? $options['titlebar_portfolio_bg_parallax'] : NULL;
$bg_overlay = isset( $options['titlebar_portfolio_overlay_color'] ) ? $options['titlebar_portfolio_overlay_color'] : NULL;
$titlebar_portfolio_id = $this->add_titlebar( $post_title, $title, $description, $size, $color, $breadcrumbs, $bg_image, $bg_size, $bg_repeat, $bg_position, $bg_parallax, $bg_overlay );
$options['titlebar_portfolio_id'] = $titlebar_portfolio_id;
} elseif ( ! $show_default_titlebar ) {
$options['titlebar_portfolio_id'] = $titlebar_id;
}
} elseif ( $show_default_titlebar ) {
$options['titlebar_portfolio_id'] = '';
}
// Titlebar for Posts
if ( isset( $options['titlebar_post'] ) AND $options['titlebar_post'] ) {
$post_title = 'Titlebar for Posts';
$title = isset( $options['titlebar_post_title'] ) ? $options['titlebar_post_title'] : NULL;
$description = NULL;
if ( isset( $options['titlebar_post_defaults'] ) AND $options['titlebar_post_defaults'] == 0 ) {
$size = isset( $options['titlebar_post_size'] ) ? $options['titlebar_post_size'] : NULL;
$color = isset( $options['titlebar_post_color'] ) ? $options['titlebar_post_color'] : NULL;
$breadcrumbs = isset( $options['titlebar_post_breadcrumbs'] ) ? $options['titlebar_post_breadcrumbs'] : NULL;
$bg_image = isset( $options['titlebar_post_bg_image'] ) ? $options['titlebar_post_bg_image'] : NULL;
$bg_size = isset( $options['titlebar_post_bg_size'] ) ? $options['titlebar_post_bg_size'] : NULL;
$bg_repeat = isset( $options['titlebar_post_bg_repeat'] ) ? $options['titlebar_post_bg_repeat'] : NULL;
$bg_position = isset( $options['titlebar_post_bg_position'] ) ? $options['titlebar_post_bg_position'] : NULL;
$bg_parallax = isset( $options['titlebar_post_bg_parallax'] ) ? $options['titlebar_post_bg_parallax'] : NULL;
$bg_overlay = isset( $options['titlebar_post_overlay_color'] ) ? $options['titlebar_post_overlay_color'] : NULL;
} else {
$size = isset( $options['titlebar_size'] ) ? $options['titlebar_size'] : NULL;
$color = isset( $options['titlebar_color'] ) ? $options['titlebar_color'] : NULL;
$breadcrumbs = isset( $options['titlebar_breadcrumbs'] ) ? $options['titlebar_breadcrumbs'] : NULL;
$bg_image = isset( $options['titlebar_bg_image'] ) ? $options['titlebar_bg_image'] : NULL;
$bg_size = isset( $options['titlebar_bg_size'] ) ? $options['titlebar_bg_size'] : NULL;
$bg_repeat = isset( $options['titlebar_bg_repeat'] ) ? $options['titlebar_bg_repeat'] : NULL;
$bg_position = isset( $options['titlebar_bg_position'] ) ? $options['titlebar_bg_position'] : NULL;
$bg_parallax = isset( $options['titlebar_bg_parallax'] ) ? $options['titlebar_bg_parallax'] : NULL;
$bg_overlay = isset( $options['titlebar_overlay_color'] ) ? $options['titlebar_overlay_color'] : NULL;
}
$titlebar_post_id = $this->add_titlebar( $post_title, $title, $description, $size, $color, $breadcrumbs, $bg_image, $bg_size, $bg_repeat, $bg_position, $bg_parallax, $bg_overlay );
$options['titlebar_post_id'] = $titlebar_post_id;
} elseif ( $show_default_titlebar ) {
$options['titlebar_post_id'] = '';
}
// Titlebar for Archive pages
if ( isset( $options['titlebar_archive'] ) AND $options['titlebar_archive'] ) {
if ( isset( $options['titlebar_archive_defaults'] ) AND $options['titlebar_archive_defaults'] == 0 ) {
$post_title = 'Titlebar for Archives';
$title = $description = NULL;
$size = isset( $options['titlebar_archive_size'] ) ? $options['titlebar_archive_size'] : NULL;
$color = isset( $options['titlebar_archive_color'] ) ? $options['titlebar_archive_color'] : NULL;
$breadcrumbs = isset( $options['titlebar_archive_breadcrumbs'] ) ? $options['titlebar_archive_breadcrumbs'] : NULL;
$bg_image = isset( $options['titlebar_archive_bg_image'] ) ? $options['titlebar_archive_bg_image'] : NULL;
$bg_size = isset( $options['titlebar_archive_bg_size'] ) ? $options['titlebar_archive_bg_size'] : NULL;
$bg_repeat = isset( $options['titlebar_archive_bg_repeat'] ) ? $options['titlebar_archive_bg_repeat'] : NULL;
$bg_position = isset( $options['titlebar_archive_bg_position'] ) ? $options['titlebar_archive_bg_position'] : NULL;
$bg_parallax = isset( $options['titlebar_archive_bg_parallax'] ) ? $options['titlebar_archive_bg_parallax'] : NULL;
$bg_overlay = isset( $options['titlebar_archive_overlay_color'] ) ? $options['titlebar_archive_overlay_color'] : NULL;
$titlebar_archive_id = $this->add_titlebar( $post_title, $title, $description, $size, $color, $breadcrumbs, $bg_image, $bg_size, $bg_repeat, $bg_position, $bg_parallax, $bg_overlay );
$options['titlebar_archive_id'] = $titlebar_archive_id;
$options['titlebar_search_id'] = $titlebar_archive_id;
} elseif ( ! $show_default_titlebar ) {
$options['titlebar_archive_id'] = $titlebar_id;
$options['titlebar_search_id'] = $titlebar_id;
}
} elseif ( $show_default_titlebar ) {
$options['titlebar_archive_id'] = '';
$options['titlebar_search_id'] = '';
}
unset( $options['titlebar_archive'] );
unset( $options['titlebar_archive_defaults'] );
unset( $options['titlebar_archive_size'] );
unset( $options['titlebar_archive_color'] );
unset( $options['titlebar_archive_breadcrumbs'] );
unset( $options['titlebar_archive_bg_image'] );
unset( $options['titlebar_archive_bg_size'] );
unset( $options['titlebar_archive_bg_repeat'] );
unset( $options['titlebar_archive_bg_position'] );
unset( $options['titlebar_archive_bg_parallax'] );
unset( $options['titlebar_archive_overlay_color'] );
// Titlebar for Shop pages
if ( isset( $options['titlebar_shop'] ) AND $options['titlebar_shop'] ) {
if ( isset( $options['titlebar_shop_defaults'] ) AND $options['titlebar_shop_defaults'] == 0 ) {
$post_title = 'Titlebar for Shop';
$title = $description = NULL;
$size = isset( $options['titlebar_shop_size'] ) ? $options['titlebar_shop_size'] : NULL;
$color = isset( $options['titlebar_shop_color'] ) ? $options['titlebar_shop_color'] : NULL;
$breadcrumbs = isset( $options['titlebar_shop_breadcrumbs'] ) ? $options['titlebar_shop_breadcrumbs'] : NULL;
$bg_image = isset( $options['titlebar_shop_bg_image'] ) ? $options['titlebar_shop_bg_image'] : NULL;
$bg_size = isset( $options['titlebar_shop_bg_size'] ) ? $options['titlebar_shop_bg_size'] : NULL;
$bg_repeat = isset( $options['titlebar_shop_bg_repeat'] ) ? $options['titlebar_shop_bg_repeat'] : NULL;
$bg_position = isset( $options['titlebar_shop_bg_position'] ) ? $options['titlebar_shop_bg_position'] : NULL;
$bg_parallax = isset( $options['titlebar_shop_bg_parallax'] ) ? $options['titlebar_shop_bg_parallax'] : NULL;
$bg_overlay = isset( $options['titlebar_shop_overlay_color'] ) ? $options['titlebar_shop_overlay_color'] : NULL;
$titlebar_shop_id = $this->add_titlebar( $post_title, $title, $description, $size, $color, $breadcrumbs, $bg_image, $bg_size, $bg_repeat, $bg_position, $bg_parallax, $bg_overlay );
$options['titlebar_shop_id'] = $titlebar_shop_id;
$options['titlebar_product_id'] = $titlebar_shop_id;
} elseif ( ! $show_default_titlebar ) {
$options['titlebar_shop_id'] = $titlebar_id;
$options['titlebar_product_id'] = $titlebar_id;
}
$options['shop_remove_title_breadcrumbs'] = 1;
} elseif ( $show_default_titlebar ) {
$options['titlebar_shop_id'] = '';
$options['titlebar_product_id'] = '';
}
// Titlebar for Blog Home & Events
if ( $show_default_titlebar ) {
$options['titlebar_blog_id'] = '';
$options['titlebar_tribe_events_id'] = '';
}
// Headers
if ( isset( $options['header_portfolio_defaults'] ) AND $options['header_portfolio_defaults'] == 1 ) {
$options['header_portfolio_id'] = '__defaults__';
}
if ( isset( $options['header_post_defaults'] ) AND $options['header_post_defaults'] == 1 ) {
$options['header_post_id'] = '__defaults__';
}
if ( isset( $options['header_archive_defaults'] ) AND $options['header_archive_defaults'] == 1 ) {
$options['header_archive_id'] = '__defaults__';
}
if ( isset( $options['header_shop_defaults'] ) AND $options['header_shop_defaults'] == 1 ) {
$options['header_shop_id'] = '__defaults__';
}
if ( isset( $options['header_product_defaults'] ) AND $options['header_product_defaults'] == 1 ) {
$options['header_product_id'] = $options['header_shop_id'];
}
/*
* Translate Dropdown element in Headers
*/
ob_start();
$headers = get_posts( array( 'post_type' => 'us_header', 'numberposts' => - 1, ) );
ob_end_clean();
foreach ( $headers as $header ) {
if ( ! empty( $header->post_content ) AND substr( strval( $header->post_content ), 0, 1 ) === '{' ) {
try {
$header_settings = json_decode( $header->post_content, TRUE );
$header_changed = FALSE;
if ( isset( $header_settings['data'] ) and is_array( $header_settings['data'] ) ) {
foreach ( $header_settings['data'] as $name => $data ) {
// Dropdown element
if ( substr( $name, 0, 8 ) == 'dropdown' ) {
if ( ! empty( $data['source'] ) AND $data['source'] = 'own' AND ! empty( $data['link_qty'] ) ) {
$links = array();
for ( $i = 0; $i < $data['link_qty']; $i ++ ) {
$j = $i +1;
$links[$i] = array(
'label' => $data['link_' . $j . '_label'],
'url' => $data['link_' . $j . '_url'],
);
}
$header_settings['data'][$name]['links'] = $links;
unset( $header_settings['data'][$name]['link_qty'] );
$header_changed = TRUE;
}
}
}
}
if ( $header_changed ) {
ob_start();
wp_update_post(
array(
'ID' => $header->ID,
'post_content' => str_replace( "\\'", "'", json_encode( wp_slash( $header_settings ), JSON_UNESCAPED_UNICODE ) ),
)
);
ob_end_clean();
}
}
catch ( Exception $e ) {
}
}
}
return TRUE;
}
// Meta
public function translate_meta( &$meta, $post_type ) {
global $us_migration_current_post_id;
// Get WooCommerce Shop page ID
if ( $this->woocommerce_shop_page_id === NULL ) {
$this->woocommerce_shop_page_id = get_option( 'woocommerce_shop_page_id', 0 );
}
// Change portfolio type name to correspond to theme options
if ( $post_type == 'us_portfolio' ) {
$post_type = 'portfolio';
// Change type from page to shop if the page is assigned as shop root for WooCommerce
} elseif ( $post_type == 'page' AND $us_migration_current_post_id == $this->woocommerce_shop_page_id ) {
$post_type = 'shop';
}
// Headers from metabox
if ( ! empty( $meta['us_header'][0] ) AND $meta['us_header'][0] == 'custom' AND empty( $meta['us_header_id'][0] ) ) {
if ( us_get_option( 'header_' . $post_type . '_id', '__defaults__' ) != '__defaults__' ) {
$meta['us_header_id'][0] = us_get_option( 'header_' . $post_type . '_id' );
} else {
$meta['us_header_id'][0] = us_get_option( 'header_id' );
}
}
// Custom Titlebar from metabox
if ( ! empty( $meta['us_titlebar'][0] ) AND $meta['us_titlebar'][0] == 'custom' ) {
// Check if the post has sidebar
$has_sidebar = FALSE;
if (
// Set as custom in metabox
( ! empty( $meta['us_sidebar'][0] ) AND $meta['us_sidebar'][0] == 'custom' )
// For this post type the default value is used and the default value is not empty
OR ( us_get_option( 'sidebar_' . $post_type . '_id', '__defaults__' ) == '__defaults__' AND us_get_option( 'sidebar_id', '' ) != '' )
// For this post type the specific sidebar is set
OR us_get_option( 'sidebar_' . $post_type . '_id', '' ) != ''
) {
$has_sidebar = TRUE;
}
$has_vc_row = FALSE;
$post = get_post( $us_migration_current_post_id );
if ( strpos( $post->post_content, '[vc_row' ) !== FALSE ) {
$has_vc_row = TRUE;
}
// Titlebar data
$title = ( $post_type == 'post' ) ? us_get_option( 'titlebar_post_title' ) : NULL;
$description = isset( $meta['us_titlebar_subtitle'][0] ) ? $meta['us_titlebar_subtitle'][0] : '';
// Change product type name to correspond to "shop" theme options
if ( $post_type == 'product' ) {
$post_type = 'shop';
}
if ( ! empty( $meta['us_titlebar_size'][0] ) ) {
$size = $meta['us_titlebar_size'][0];
} elseif ( us_get_option( 'titlebar_' . $post_type . '_defaults', 1 ) == 0 ) {
$size = us_get_option( 'titlebar_' . $post_type . '_size' );
} else {
$size = us_get_option( 'titlebar_size' );
}
if ( ! empty( $meta['us_titlebar_color'][0] ) ) {
$color = $meta['us_titlebar_color'][0];
} elseif ( us_get_option( 'titlebar_' . $post_type . '_defaults', 1 ) == 0 ) {
$color = us_get_option( 'titlebar_' . $post_type . '_color' );
} else {
$color = us_get_option( 'titlebar_color' );
}
if ( ! empty( $meta['us_titlebar_breadcrumbs'][0] ) ) {
$breadcrumbs = ( $meta['us_titlebar_breadcrumbs'][0] == 'show' ) ? 1 : 0;
} elseif ( us_get_option( 'titlebar_' . $post_type . '_defaults', 1 ) == 0 ) {
$breadcrumbs = us_get_option( 'titlebar_' . $post_type . '_breadcrumbs' );
} else {
$breadcrumbs = us_get_option( 'titlebar_breadcrumbs' );
}
if ( ! empty( $meta['us_titlebar_image'][0] ) ) {
$bg_image = $meta['us_titlebar_image'][0];
} elseif ( us_get_option( 'titlebar_' . $post_type . '_defaults', 1 ) == 0 ) {
$bg_image = us_get_option( 'titlebar_' . $post_type . '_bg_image' );
} else {
$bg_image = us_get_option( 'titlebar_bg_image' );
}
if ( ! empty( $meta['us_titlebar_bg_size'][0] ) ) {
$bg_size = $meta['us_titlebar_bg_size'][0];
} elseif ( us_get_option( 'titlebar_' . $post_type . '_defaults', 1 ) == 0 ) {
$bg_size = us_get_option( 'titlebar_' . $post_type . '_bg_size' );
} else {
$bg_size = us_get_option( 'titlebar_bg_size' );
}
if ( ! empty( $meta['us_titlebar_bg_repeat'][0] ) ) {
$bg_repeat = $meta['us_titlebar_bg_repeat'][0];
} elseif ( us_get_option( 'titlebar_' . $post_type . '_defaults', 1 ) == 0 ) {
$bg_repeat = us_get_option( 'titlebar_' . $post_type . '_bg_repeat' );
} else {
$bg_repeat = us_get_option( 'titlebar_bg_repeat' );
}
if ( ! empty( $meta['us_titlebar_bg_position'][0] ) ) {
$bg_position = $meta['us_titlebar_bg_position'][0];
} elseif ( us_get_option( 'titlebar_' . $post_type . '_defaults', 1 ) == 0 ) {
$bg_position = us_get_option( 'titlebar_' . $post_type . '_bg_position' );
} else {
$bg_position = us_get_option( 'titlebar_bg_position' );
}
if ( ! empty( $meta['us_titlebar_bg_parallax'][0] ) ) {
$bg_parallax = $meta['us_titlebar_bg_parallax'][0];
} elseif ( us_get_option( 'titlebar_' . $post_type . '_defaults', 1 ) == 0 ) {
$bg_parallax = us_get_option( 'titlebar_' . $post_type . '_bg_parallax' );
} else {
$bg_parallax = us_get_option( 'titlebar_bg_parallax' );
}
if ( ! empty( $meta['us_titlebar_overlay_color'][0] ) ) {
$bg_overlay = $meta['us_titlebar_overlay_color'][0];
} elseif ( us_get_option( 'titlebar_' . $post_type . '_defaults', 1 ) == 0 ) {
$bg_overlay = us_get_option( 'titlebar_' . $post_type . '_overlay_color' );
} else {
$bg_overlay = us_get_option( 'titlebar_overlay_color' );
}
// If the post has sidebar or has no [vc_row] shortcode(s) in the content, we create titlebar post for it
if ( $has_sidebar OR ( ! $has_vc_row ) ) {
$the_post_title = get_the_title( $us_migration_current_post_id );
if ( empty( $the_post_title ) ) {
$the_post_title = '#' . $us_migration_current_post_id;
}
$post_title = 'Titlebar for page "' . $the_post_title . '"';
$titlebar_meta_id = $this->add_titlebar( $post_title, $title, $description, $size, $color, $breadcrumbs, $bg_image, $bg_size, $bg_repeat, $bg_position, $bg_parallax, $bg_overlay );
$meta['us_titlebar_id'][0] = $titlebar_meta_id;
// If the post has no sidebar we prepend post's content with titlebar content
} else {
$titlebar_content = $this->generate_titlebar_content( $title, $description, $size, $color, $breadcrumbs, $bg_image, $bg_size, $bg_repeat, $bg_position, $bg_parallax, $bg_overlay );
if ( strpos( $post->post_content, $titlebar_content ) == FALSE ) {
$content = $titlebar_content . $post->post_content;
wp_update_post(
array(
'ID' => $post->ID,
'post_content' => $content,
)
);
$meta['us_titlebar'][0] = 'hide';
}
}
unset( $meta['us_titlebar_subtitle'] );
unset( $meta['us_titlebar_size'] );
unset( $meta['us_titlebar_color'] );
unset( $meta['us_titlebar_breadcrumbs'] );
unset( $meta['us_titlebar_image'] );
unset( $meta['us_titlebar_bg_size'] );
unset( $meta['us_titlebar_bg_repeat'] );
unset( $meta['us_titlebar_bg_position'] );
unset( $meta['us_titlebar_bg_parallax'] );
unset( $meta['us_titlebar_overlay_color'] );
}
// Sidebars from metabox
if ( ! empty( $meta['us_sidebar'][0] ) AND $meta['us_sidebar'][0] == 'custom' AND empty( $meta['us_sidebar_id'][0] ) ) {
$meta['us_sidebar_id'][0] = 'default_sidebar';
}
// Footers from metabox
if ( ! empty( $meta['us_footer'][0] ) AND $meta['us_footer'][0] == 'custom' ) {
$args = array(
'name' => $meta['us_footer_id'][0],
'post_type' => 'us_page_block',
'numberposts' => 1,
);
$footer_post = get_posts( $args );
if ( $footer_post ) {
$footer_post = $footer_post[0];
$meta['us_footer_id'][0] = $footer_post->ID;
}
}
return TRUE;
}
// Create the Titlebar post if it doesn't exist
private function add_titlebar(
// Default values
$post_title = 'Default Titlebar',
$title = '', // can be set in Theme Options > Title Bars > Posts only
$description = '', // can be set in metabox only
$size = 'small',
$color = 'default',
$breadcrumbs = TRUE,
$bg_image = '',
$bg_size = 'cover',
$bg_repeat = 'repeat',
$bg_position = 'center center',
$bg_parallax = 'none',
$bg_overlay = ''
) {
$post_content = $this->generate_titlebar_content( $title, $description, $size, $color, $breadcrumbs, $bg_image, $bg_size, $bg_repeat, $bg_position, $bg_parallax, $bg_overlay );
$content_hash = md5( $post_content );
// Check for existing page block with same content
global $wpdb;
$existing_posts_results = $wpdb->get_results(
$wpdb->prepare( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = %s AND meta_value = %s", 'us_migration_content_hash', $content_hash )
);
if ( count( $existing_posts_results ) > 0 ) {
$existing_post = $existing_posts_results[0];
return $existing_post->post_id;
}
$block_post_array = array(
'post_type' => 'us_page_block',
'post_date' => date( 'Y-m-d H:i', time() - 86400 ),
'post_title' => $post_title,
'post_content' => $post_content,
'post_status' => 'publish',
);
ob_start();
$block_post_id = wp_insert_post( $block_post_array );
add_post_meta( $block_post_id, 'us_migration_content_hash', $content_hash );
ob_end_clean();
return $block_post_id;
}
// Generate content for Page Block based on Title Bar settings
private function generate_titlebar_content(
// Default values
$title = '', // can be set in Theme Options > Title Bars > Posts only
$description = '', // can be set in metabox only
$size = 'small',
$color = 'default',
$breadcrumbs = TRUE,
$bg_image = '',
$bg_size = 'cover',
$bg_repeat = 'repeat',
$bg_position = 'center center',
$bg_parallax = 'none',
$bg_overlay = ''
) {
// Row
$content = '[vc_row content_placement="middle"';
if ( $size == 'huge' ) {
$content .= ' height="large"';
} elseif ( $size == 'large' ) {
$content .= ' height="medium"';
} else {
$content .= ' height="small"';
}
if ( $color == 'default' ) {
$content .= ' css=".vc_custom_777{padding-bottom: 0px !important;}"';
} else {
$content .= ' color_scheme="' . $color . '"';
}
if ( $bg_image != '' ) {
$content .= ' us_bg_image="' . intval( $bg_image ) . '"';
$content .= ' us_bg_size="' . $bg_size . '"';
$content .= ' us_bg_repeat="' . $bg_repeat . '"';
$content .= ' us_bg_pos="' . $bg_position . '"';
if ( $bg_parallax == 'vertical_reversed' ) {
$content .= ' us_bg_parallax="vertical" us_bg_parallax_reverse="1"';
} else {
$content .= ' us_bg_parallax="' . $bg_parallax . '"';
}
}
if ( $bg_overlay != '' ) {
$content .= ' us_bg_overlay_color="' . $bg_overlay . '"';
}
$content .= ']';
// First column
if ( $breadcrumbs AND in_array( $size, array( 'small', 'medium' ) ) ) {
$content .= '[vc_column width="1/2"]';
} else {
$content .= '[vc_column]';
}
// Page Title
if ( $title == '' ) {
$content .= '[us_page_title description="1"';
if ( in_array( $size, array( 'small', 'medium' ) ) ) {
$content .= ' font_size="1.8rem" inline="1"';
} elseif ( $size == 'huge' ) {
$content .= ' font_size="3rem" line_height="1.1" align="center"';
} else {
$content .= ' align="center"';
}
$content .= ']';
} else {
$content .= '[vc_column_text]<h1 style="';
if ( in_array( $size, array( 'small', 'medium' ) ) ) {
$content .= 'font-size: 1.8rem;">';
} else {
$content .= 'text-align: center;">';
}
$content .= $title;
$content .= '</h1>[/vc_column_text]';
}
// Description
if ( $description != '' ) {
$content .= '[vc_column_text]';
if ( in_array( $size, array( 'small', 'medium' ) ) ) {
$content .= $description;
} else {
$content .= '<p style="text-align: center;">' . $description . '</p>';
}
$content .= '[/vc_column_text]';
}
// Second column
if ( $breadcrumbs AND in_array( $size, array( 'small', 'medium' ) ) ) {
$content .= '[/vc_column][vc_column width="1/2"]';
}
// Breadcrumbs
if ( $breadcrumbs ) {
$content .= '[us_breadcrumbs show_current="1" font_size="0.9rem"';
if ( in_array( $size, array( 'small', 'medium' ) ) ) {
$content .= ' align="right"]';
} else {
$content .= ' align="center"]';
}
}
$content .= '[/vc_column]';
$content .= '[/vc_row]';
return $content;
}
}
@@ -0,0 +1,100 @@
<?php
class us_migration_5_4 extends US_Migration_Translator {
// Content
public function translate_content( &$content ) {
return $this->_translate_content( $content );
}
public function translate_vc_row( &$name, &$params, &$content ) {
$changed = FALSE;
if ( isset( $params['us_bg_image'] ) AND $params['us_bg_image'] ) {
$params['us_bg_image_source'] = 'media';
$changed = TRUE;
}
return $changed;
}
public function translate_us_counter( &$name, &$params, &$content ) {
$changed = FALSE;
if ( isset( $params['size'] ) AND $params['size'] == 'small' ) {
$params['size'] = '4rem';
$changed = TRUE;
}
if ( isset( $params['size'] ) AND $params['size'] == 'large' ) {
$params['size'] = '6rem';
$changed = TRUE;
}
return $changed;
}
public function translate_us_iconbox( &$name, &$params, &$content ) {
$changed = FALSE;
if ( isset( $params['iconpos'] ) AND $params['iconpos'] == 'left' ) {
$params['alignment'] = 'left';
$changed = TRUE;
}
return $changed;
}
// Theme Options
public function translate_theme_options( &$options ) {
$changed = FALSE;
// 404 error page
$error_404 = get_page_by_path( 'error-404' );
if ( $error_404 ) {
$options['page_404'] = $error_404->ID;
$changed = TRUE;
}
// Maintenance page slug -> ID
if ( ! empty( $options['maintenance_page'] ) ) {
$maintenance_page = get_page_by_path( $options['maintenance_page'] );
if ( $maintenance_page ) {
$options['maintenance_page'] = $maintenance_page->ID;
$changed = TRUE;
}
}
// Portfolio breadcrumbs page slug -> ID
if ( ! empty( $options['portfolio_breadcrumbs_page'] ) ) {
$portfolio_breadcrumbs_page = get_page_by_path( $options['portfolio_breadcrumbs_page'] );
if ( $portfolio_breadcrumbs_page ) {
$options['portfolio_breadcrumbs_page'] = $portfolio_breadcrumbs_page->ID;
$changed = TRUE;
}
}
// Shop Title and Breadcrumbs
if ( isset( $options['shop_remove_title_breadcrumbs'] ) AND $options['shop_remove_title_breadcrumbs'] ) {
$options['shop_elements'] = array();
$changed = TRUE;
}
/* Add new checkboxes if Optimize option is ON */
if ( isset( $options['optimize_assets'] ) AND $options['optimize_assets'] == 1 AND is_array( $options['assets'] ) ) {
$options['assets'] = array_merge(
array(
'animation',
'scroll',
'parallax-hor',
'parallax-ver',
'dropdown',
'ultimate-addons',
),
$options['assets']
);
$changed = TRUE;
}
return $changed;
}
}
@@ -0,0 +1,764 @@
<?php
class us_migration_5_5 extends US_Migration_Translator {
private $button_colors;
// Content
public function translate_content( &$content ) {
return $this->_translate_content( $content );
}
public function translate_vc_row( &$name, &$params, &$content ) {
global $us_row_color_scheme;
$us_row_color_scheme = ( ! empty( $params['color_scheme'] ) AND in_array(
$params['color_scheme'], array(
'primary',
'secondary',
'custom',
'alternate',
)
) ) ? $params['color_scheme'] : 'other';
return FALSE;
}
public function translate_us_pricing( &$name, &$params, &$content ) {
$changed = FALSE;
$this->set_button_colors();
$items = json_decode( urldecode( $params['items'] ), TRUE );
if ( is_array( $items ) AND count( $items ) ) {
foreach ( $items as $index => $item ) {
// If there is no button label, the button is not displayed, no need in migration
if ( empty( $item['btn_text'] ) ) {
continue;
}
// Fail-safe if this button was already migrated
if ( ! empty( $item['btn_style'] ) AND intval( $item['btn_style'] ) > 0 ) {
continue;
}
if ( ! isset( $item['btn_color'] ) OR ! in_array( $item['btn_color'], array_keys( $this->button_colors ) ) ) {
$items[ $index ]['btn_color'] = 'primary';
}
$items[ $index ]['btn_color'] = $this->filter_btn_color( $items[ $index ]['btn_color'] );
if ( isset( $item['btn_style'] ) AND $item['btn_style'] == 'outlined' AND $item['btn_color'] != 'transparent' ) {
$items[ $index ]['btn_style'] = $this->maybe_add_button_style( $items[ $index ]['btn_color'], 'outlined' );
} else {
$items[ $index ]['btn_style'] = $this->maybe_add_button_style( $items[ $index ]['btn_color'], 'solid' );
}
if ( empty( $item['btn_size'] ) ) {
$items[ $index ]['btn_size'] = $this->btn_size();
}
unset( $items[ $index ]['btn_color'] );
$changed = TRUE;
}
}
if ( $changed ) {
$params['items'] = urlencode( json_encode( $items ) );
}
return $changed;
}
public function translate_us_cform( &$name, &$params, &$content ) {
// Fail-safe if this form was already migrated
if ( ! empty( $params['button_style'] ) AND intval( $params['button_style'] ) > 0 ) {
return FALSE;
}
$this->set_button_colors();
if ( ! isset( $params['button_color'] ) OR ! in_array( $params['button_color'], array_keys( $this->button_colors ) ) ) {
$params['button_color'] = 'primary';
}
$params['button_color'] = $this->filter_btn_color( $params['button_color'] );
if ( isset( $params['button_style'] ) AND $params['button_style'] == 'outlined' AND $params['button_color'] != 'transparent' ) {
$params['button_style'] = $this->maybe_add_button_style( $params['button_color'], 'outlined' );
} else {
$params['button_style'] = $this->maybe_add_button_style( $params['button_color'], 'solid' );
}
if ( empty( $params['button_size'] ) ) {
$params['button_size'] = $this->btn_size();
}
unset( $params['button_color'] );
return TRUE;
}
public function translate_us_grid( &$name, &$params, &$content ) {
// Fail-safe if this grid was already migrated
if ( ! empty( $params['pagination_btn_style'] ) AND intval( $params['pagination_btn_style'] ) > 0 ) {
return FALSE;
}
$changed = FALSE;
$this->set_button_colors();
if ( isset( $params['pagination'] ) AND $params['pagination'] == 'ajax' ) {
if ( isset( $params['pagination_btn_style'] ) AND $params['pagination_btn_style'] == 'link' ) {
$params['pagination_btn_style'] = $this->maybe_add_button_style( 'transparent', 'solid' );
} elseif ( isset( $params['pagination_btn_style'] ) AND $params['pagination_btn_style'] == 'btn' ) {
$params['pagination_btn_style'] = $this->maybe_add_button_style( 'primary', 'solid' );
$params['pagination_btn_size'] = $this->btn_size();
} else {
$params['pagination_btn_style'] = $this->maybe_add_button_style( 'loadmore', 'solid' );
$params['pagination_btn_size'] = '1.2rem';
$params['pagination_btn_fullwidth'] = 1;
}
$changed = TRUE;
}
return $changed;
}
public function translate_us_cta( &$name, &$params, &$content ) {
// Fail-safe if this action box was already migrated
if ( ! empty( $params['btn_style'] ) AND intval( $params['btn_style'] ) > 0 ) {
return FALSE;
}
$changed = FALSE;
$this->set_button_colors();
// Button 1
if ( ! empty( $params['btn_label'] ) ) {
if ( ! isset( $params['btn_color'] ) OR ! in_array( $params['btn_color'], array_keys( $this->button_colors ) ) ) {
$params['btn_color'] = 'white';
}
$params['btn_color'] = $this->filter_btn_color( $params['btn_color'] );
if ( isset( $params['btn_style'] ) AND $params['btn_style'] == 'outlined' AND $params['btn_color'] != 'transparent' ) {
$params['btn_style'] = $this->maybe_add_button_style( $params['btn_color'], 'outlined' );
} else {
$params['btn_style'] = $this->maybe_add_button_style( $params['btn_color'], 'solid' );
}
if ( empty( $params['btn_size'] ) ) {
$params['btn_size'] = $this->btn_size();
}
unset( $params['btn_color'] );
$changed = TRUE;
}
// Button 2
if ( isset( $params['second_button'] ) AND $params['second_button'] AND ! empty( $params['btn2_label'] ) ) {
if ( ! isset( $params['btn2_color'] ) OR ! in_array( $params['btn2_color'], array_keys( $this->button_colors ) ) ) {
$params['btn2_color'] = 'secondary';
}
$params['btn2_color'] = $this->filter_btn_color( $params['btn2_color'] );
if ( isset( $params['btn2_style'] ) AND $params['btn2_style'] == 'outlined' AND $params['btn2_color'] != 'transparent' ) {
$params['btn2_style'] = $this->maybe_add_button_style( $params['btn2_color'], 'outlined' );
} else {
$params['btn2_style'] = $this->maybe_add_button_style( $params['btn2_color'], 'solid' );
}
if ( empty( $params['btn2_size'] ) ) {
$params['btn2_size'] = $this->btn_size();
}
unset( $params['btn2_color'] );
$changed = TRUE;
}
return $changed;
}
public function translate_us_btn( &$name, &$params, &$content ) {
// Fail-safe if this button was already migrated
if ( ! empty( $params['style'] ) AND intval( $params['style'] ) > 0 ) {
return FALSE;
}
$this->set_button_colors();
if ( ! isset( $params['color'] ) OR ! in_array( $params['color'], array_keys( $this->button_colors ) ) ) {
$params['color'] = 'primary';
}
$params['color'] = $this->filter_btn_color( $params['color'] );
if ( isset( $params['style'] ) AND $params['style'] == 'outlined' AND $params['color'] != 'transparent' ) {
$params['style'] = $this->maybe_add_button_style( $params['color'], 'outlined' );
} else {
$params['style'] = $this->maybe_add_button_style( $params['color'], 'solid' );
}
if ( empty( $params['size'] ) ) {
$params['size'] = $this->btn_size();
}
unset( $params['color'] );
return TRUE;
}
// Theme Options
public function translate_theme_options( &$options ) {
$changed = FALSE;
$this->del_previous_buttons();
$this->set_button_colors();
// Add Default button style always FIRST
$this->button_colors['default'] = array(
'name' => 'Default Button',
);
$this->maybe_add_button_style( 'default', 'solid' );
// Add "Light" button style always SECOND
$this->maybe_add_button_style( 'light', 'solid' );
/*
* Grid Layout Buttons
*/
ob_start();
$grid_layouts = get_posts( array( 'post_type' => 'us_grid_layout', 'numberposts' => - 1, ) );
ob_end_clean();
foreach ( $grid_layouts as $grid_layout ) {
if ( ! empty( $grid_layout->post_content ) AND substr( strval( $grid_layout->post_content ), 0, 1 ) === '{' ) {
try {
$grid_settings = json_decode( $grid_layout->post_content, TRUE );
$grid_layout_changed = FALSE;
if ( isset( $grid_settings['data'] ) and is_array( $grid_settings['data'] ) ) {
foreach ( $grid_settings['data'] as $name => $data ) {
// Button element
if ( substr( $name, 0, 3 ) == 'btn' ) {
// Fail-safe if this button was already migrated
if ( empty( $data['color'] ) and ! empty( $data['style'] ) AND intval( $data['style'] ) > 0 ) {
continue;
}
if ( ! isset( $data['color'] ) OR ! in_array( $data['color'], array_keys( $this->button_colors ) ) ) {
$data['color'] = 'light';
}
if ( isset( $data['style'] ) AND $data['style'] == 'outlined' ) {
$grid_settings['data'][ $name ]['style'] = $this->maybe_add_button_style( $data['color'], 'outlined' );
} else {
$grid_settings['data'][ $name ]['style'] = $this->maybe_add_button_style( $data['color'], 'solid' );
}
unset( $grid_settings['data'][ $name ]['color'] );
$grid_layout_changed = TRUE;
}
}
}
if ( $grid_layout_changed ) {
ob_start();
wp_update_post(
array(
'ID' => $grid_layout->ID,
'post_content' => str_replace( "\\'", "'", json_encode( wp_slash( $grid_settings ), JSON_UNESCAPED_UNICODE ) ),
)
);
ob_end_clean();
}
}
catch ( Exception $e ) {
}
}
}
/*
* Header Buttons
*/
ob_start();
$headers = get_posts( array( 'post_type' => 'us_header', 'numberposts' => - 1, ) );
ob_end_clean();
$header_btn_index = 0;
foreach ( $headers as $header ) {
if ( ! empty( $header->post_content ) AND substr( strval( $header->post_content ), 0, 1 ) === '{' ) {
try {
$header_settings = json_decode( $header->post_content, TRUE );
$header_changed = FALSE;
if ( isset( $header_settings['data'] ) and is_array( $header_settings['data'] ) ) {
foreach ( $header_settings['data'] as $name => $data ) {
// Button element
if ( substr( $name, 0, 3 ) == 'btn' ) {
// Fail-safe if this button was already migrated
if ( empty( $data['color_bg'] ) OR empty( $data['color_text'] ) ) {
continue;
}
$header_btn_index ++;
$this->button_colors[ 'header_' . $header_btn_index ] = array(
'name' => 'Header ' . $header_btn_index,
'color_bg' => $data['color_bg'],
'color_text' => $data['color_text'],
'color_bg_hover' => $data['color_hover_bg'],
'color_text_hover' => $data['color_hover_text'],
);
if ( isset( $data['style'] ) AND $data['style'] == 'outlined' ) {
$header_settings['data'][ $name ]['style'] = $this->maybe_add_button_style( 'header_' . $header_btn_index, 'outlined' );
} else {
$header_settings['data'][ $name ]['style'] = $this->maybe_add_button_style( 'header_' . $header_btn_index, 'solid' );
}
unset( $header_settings['data'][ $name ]['color_bg'] );
unset( $header_settings['data'][ $name ]['color_text'] );
unset( $header_settings['data'][ $name ]['color_hover_bg'] );
unset( $header_settings['data'][ $name ]['color_hover_text'] );
$header_changed = TRUE;
}
// Cart element
if ( substr( $name, 0, 4 ) == 'cart' ) {
$header_settings['data'][ $name ]['quantity_color_bg'] = $options['color_menu_button_bg'];
$header_settings['data'][ $name ]['quantity_color_text'] = $options['color_menu_button_text'];
$header_changed = TRUE;
}
}
}
// Change tablets & mobiles breakpoints plus one
if ( isset( $header_settings['tablets'] ) and is_array( $header_settings['tablets'] ) ) {
$header_settings['tablets']['options']['breakpoint'] = $header_settings['tablets']['options']['breakpoint'] + 1;
$header_changed = TRUE;
}
if ( isset( $header_settings['mobiles'] ) and is_array( $header_settings['mobiles'] ) ) {
$header_settings['mobiles']['options']['breakpoint'] = $header_settings['mobiles']['options']['breakpoint'] + 1;
$header_changed = TRUE;
}
if ( $header_changed ) {
ob_start();
wp_update_post(
array(
'ID' => $header->ID,
'post_content' => str_replace( "\\'", "'", json_encode( wp_slash( $header_settings ), JSON_UNESCAPED_UNICODE ) ),
)
);
ob_end_clean();
}
}
catch ( Exception $e ) {
}
}
}
/*
* Adding "Leaflet" checkbox if Optimize JS and CSS option is ON
*/
if ( isset( $options['optimize_assets'] ) AND $options['optimize_assets'] == 1 AND is_array( $options['assets'] ) ) {
$options['assets'] = array_merge( $options['assets'], array( 'lmaps' ) );
}
return $changed;
}
// Widgets
public function translate_widgets( &$name, &$instance ) {
$changed = FALSE;
if ( $name == 'text' ) {
$text = $instance['text'];
if ( $this->translate_content( $text ) ) {
$instance['text'] = $text;
$changed = TRUE;
}
}
return $changed;
}
/**
* Apply substyle to button color depending on parent vc_row colors
*/
private function filter_btn_color( $color ) {
global $us_row_color_scheme;
if ( ! empty( $us_row_color_scheme ) AND $us_row_color_scheme == 'alternate' AND in_array( $color, array( 'primary', 'secondary', 'contrast', 'light', 'transparent' ) ) ) {
$filtered_color = $color . '_alt';
}
if ( ! empty( $us_row_color_scheme ) AND in_array( $us_row_color_scheme, array( 'primary', 'secondary', 'custom' ) ) AND $color == 'light' ) {
$filtered_color = 'semitransparent';
}
if ( empty( $filtered_color ) OR ! in_array( $filtered_color, array_keys( $this->button_colors ) ) ) {
$filtered_color = $color;
}
return $filtered_color;
}
/**
* Set values to button_colors array
*/
private function set_button_colors() {
if ( empty( $this->button_colors ) ) {
$this->button_colors = array(
'primary' => array(
'name' => 'Primary',
'color_bg' => us_get_option( 'color_content_primary' ),
'color_text' => '#ffffff',
),
'secondary' => array(
'name' => 'Secondary',
'color_bg' => us_get_option( 'color_content_secondary' ),
'color_text' => '#ffffff',
),
'light' => array(
'name' => 'Light',
'color_bg' => us_get_option( 'color_content_border' ),
'color_text' => us_get_option( 'color_content_text' ),
'color_bg_hover' => 'rgba(0,0,0,0.05)',
),
'contrast' => array(
'name' => 'Dark',
'color_bg' => us_get_option( 'color_content_text' ),
'color_text' => us_get_option( 'color_content_bg' ),
),
'black' => array(
'name' => 'Black',
'color_bg' => '#000000',
'color_text' => '#ffffff',
'color_bg_hover' => 'rgba(255,255,255,0.1)',
),
'white' => array(
'name' => 'White',
'color_bg' => '#ffffff',
'color_text' => '#333333',
'color_bg_hover' => 'rgba(0,0,0,0.08)',
),
'purple' => array(
'name' => 'Purple',
'color_bg' => '#8560a8',
'color_text' => '#ffffff',
),
'pink' => array(
'name' => 'Pink',
'color_bg' => '#ff6b77',
'color_text' => '#ffffff',
),
'red' => array(
'name' => 'Red',
'color_bg' => '#ff4400',
'color_text' => '#ffffff',
),
'yellow' => array(
'name' => 'Yellow',
'color_bg' => '#fac000',
'color_text' => '#ffffff',
),
'lime' => array(
'name' => 'Lime',
'color_bg' => '#baeb59',
'color_text' => '#606652',
'color_bg_hover' => 'rgba(0,0,0,0.08)',
),
'green' => array(
'name' => 'Green',
'color_bg' => '#59ba41',
'color_text' => '#ffffff',
),
'teal' => array(
'name' => 'Teal',
'color_bg' => '#008b83',
'color_text' => '#ffffff',
),
'blue' => array(
'name' => 'Blue',
'color_bg' => '#5ac8ed',
'color_text' => '#ffffff',
),
'navy' => array(
'name' => 'Navy',
'color_bg' => '#1265a8',
'color_text' => '#ffffff',
),
'midnight' => array(
'name' => 'Midnight',
'color_bg' => '#2c3e50',
'color_text' => '#ffffff',
'color_bg_hover' => 'rgba(0,0,0,0.2)',
),
'brown' => array(
'name' => 'Brown',
'color_bg' => '#6a4530',
'color_text' => '#ffffff',
),
'cream' => array(
'name' => 'Cream',
'color_bg' => '#ffe2bf',
'color_text' => '#65584c',
'color_bg_hover' => 'rgba(0,0,0,0.08)',
),
'transparent' => array(
'name' => 'Text Link',
'color_bg' => '',
'color_text' => us_get_option( 'color_content_link' ),
'color_bg_hover' => '',
'color_text_hover' => us_get_option( 'color_content_link_hover' ),
),
'loadmore' => array(
'name' => 'Load More Button',
'color_bg' => us_get_option( 'color_content_bg_alt' ),
'color_text' => us_get_option( 'color_content_text' ),
'color_bg_hover' => us_get_option( 'color_content_border' ),
),
'semitransparent' => array(
'name' => 'Semitransparent',
'color_bg' => 'rgba(255,255,255,0.15)',
'color_border' => 'rgba(255,255,255,0.33)',
'color_text' => '#fff',
'color_bg_hover' => 'rgba(255,255,255,0.33)',
),
);
if ( us_get_option( 'color_content_primary' ) != us_get_option( 'color_alt_content_primary' ) ) {
$this->button_colors['primary_alt'] = array(
'name' => 'Alternate Primary',
'color_bg' => us_get_option( 'color_alt_content_primary' ),
'color_text' => '#ffffff',
);
}
if ( us_get_option( 'color_content_secondary' ) != us_get_option( 'color_alt_content_secondary' ) ) {
$this->button_colors['secondary_alt'] = array(
'name' => 'Alternate Secondary',
'color_bg' => us_get_option( 'color_alt_content_secondary' ),
'color_text' => '#ffffff',
);
}
if ( us_get_option( 'color_content_text' ) != us_get_option( 'color_alt_content_text' ) OR us_get_option( 'color_content_bg' ) != us_get_option( 'color_alt_content_bg' ) ) {
$this->button_colors['contrast_alt'] = array(
'name' => 'Alternate Dark',
'color_bg' => us_get_option( 'color_alt_content_text' ),
'color_text' => us_get_option( 'color_alt_content_bg' ),
);
}
if ( us_get_option( 'color_content_text' ) != us_get_option( 'color_alt_content_text' ) OR us_get_option( 'color_content_border' ) != us_get_option( 'color_alt_content_border' ) ) {
$this->button_colors['light_alt'] = array(
'name' => 'Alternate Light',
'color_bg' => us_get_option( 'color_alt_content_border' ),
'color_text' => us_get_option( 'color_alt_content_text' ),
'color_bg_hover' => 'rgba(0,0,0,0.05)',
);
}
if ( us_get_option( 'color_content_link' ) != us_get_option( 'color_alt_content_link' ) OR us_get_option( 'color_content_link_hover' ) != us_get_option( 'color_alt_content_link_hover' ) ) {
$this->button_colors['transparent_alt'] = array(
'name' => 'Alternate Text Link',
'color_bg' => '',
'color_text' => us_get_option( 'color_alt_content_link' ),
'color_bg_hover' => '',
'color_text_hover' => us_get_option( 'color_alt_content_link_hover' ),
);
}
}
}
/**
* Delete default buttons sets after install theme before migration
*/
private function del_previous_buttons() {
global $usof_options;
usof_load_options_once();
$updated_options = $usof_options;
if ( ! empty( $updated_options['buttons'] ) AND is_array( $updated_options['buttons'] ) ) {
unset( $updated_options['buttons'] );
}
usof_save_options( $updated_options );
}
/**
* Check if button style is added, add if needed and return it's ID
*/
private function maybe_add_button_style( $color, $style ) {
global $usof_options;
$updated_options = $usof_options;
usof_load_options_once();
$style_key = $color . '_' . $style;
if ( ! empty( $usof_options['buttons'] ) AND is_array( $usof_options['buttons'] ) ) {
foreach ( $usof_options['buttons'] as $_button_style ) {
if ( ! empty( $_button_style['_migrated_key'] ) AND $_button_style['_migrated_key'] == $style_key ) {
return $_button_style['id'];
}
}
}
// Add "Outlined" to the name if set
$style_name = ( $style == 'solid' ) ? '' : ' Outlined';
// Set colors for "Default Style" button style
if ( $color == 'default' ) {
$color_bg = us_get_option( 'color_content_primary' );
$color_bg_hover = us_get_option( 'color_content_secondary' );
$color_text = $color_text_hover = '#ffffff';
$color_border = $color_border_hover = '';
// Set colors for Header buttons
} elseif ( strpos( $color, 'header' ) !== FALSE ) {
if ( $usof_options['button_hover'] == 'none' ) {
$color_bg = $color_bg_hover = ( $style == 'solid' ) ? $this->button_colors[ $color ]['color_bg'] : '';
$color_border = $color_border_hover = ( $style == 'solid' ) ? '' : $this->button_colors[ $color ]['color_text'];
$color_text = $color_text_hover = $this->button_colors[ $color ]['color_text'];
} else {
$color_bg = ( $style == 'solid' ) ? $this->button_colors[ $color ]['color_bg'] : '';
$color_bg_hover = $this->button_colors[ $color ]['color_bg_hover'];
$color_border = $color_border_hover = ( $style == 'solid' ) ? '' : $this->button_colors[ $color ]['color_text'];
$color_text = $this->button_colors[ $color ]['color_text'];
$color_text_hover = $this->button_colors[ $color ]['color_text_hover'];
}
// Set colors depending on former global hover style for all other buttons
} else {
// Set border color
if ( ! isset( $this->button_colors[ $color ]['color_border'] ) ) {
$this->button_colors[ $color ]['color_border'] = $this->button_colors[ $color ]['color_bg'];
}
if ( $usof_options['button_hover'] == 'none' ) {
$color_bg = $color_bg_hover = ( $style == 'solid' ) ? $this->button_colors[ $color ]['color_bg'] : '';
$color_border = $color_border_hover = ( $style == 'solid' ) ? '' : $this->button_colors[ $color ]['color_border'];
$color_text = $color_text_hover = ( $style == 'solid' ) ? $this->button_colors[ $color ]['color_text'] : $this->button_colors[ $color ]['color_bg'];
} elseif ( $usof_options['button_hover'] == 'reverse' ) {
$color_bg = ( $style == 'solid' ) ? $this->button_colors[ $color ]['color_bg'] : '';
$color_bg_hover = ( $style == 'solid' ) ? '' : $this->button_colors[ $color ]['color_bg'];
$color_border = ( $style == 'solid' ) ? '' : $this->button_colors[ $color ]['color_border'];
$color_border_hover = ( $style == 'solid' ) ? $this->button_colors[ $color ]['color_border'] : '';
$color_text = ( $style == 'solid' ) ? $this->button_colors[ $color ]['color_text'] : $this->button_colors[ $color ]['color_bg'];
$color_text_hover = ( $style == 'solid' ) ? $this->button_colors[ $color ]['color_bg'] : $this->button_colors[ $color ]['color_text'];
} elseif ( $usof_options['button_hover'] == 'slide' ) {
$color_bg = ( $style == 'solid' ) ? $this->button_colors[ $color ]['color_bg'] : '';
if ( ! isset( $this->button_colors[ $color ]['color_bg_hover'] ) ) {
$this->button_colors[ $color ]['color_bg_hover'] = 'rgba(0,0,0,0.15)';
}
$color_bg_hover = ( $style == 'solid' ) ? $this->button_colors[ $color ]['color_bg_hover'] : $this->button_colors[ $color ]['color_bg'];
$color_border = $color_border_hover = ( $style == 'solid' ) ? '' : $this->button_colors[ $color ]['color_border'];
$color_text = ( $style == 'solid' ) ? $this->button_colors[ $color ]['color_text'] : $this->button_colors[ $color ]['color_bg'];
$color_text_hover = $this->button_colors[ $color ]['color_text'];
} else { /* if ( $usof_options['button_hover'] == 'fade' ) */
$color_bg = ( $style == 'solid' ) ? $this->button_colors[ $color ]['color_bg'] : '';
$color_bg_hover = ( $style == 'solid' ) ? us_shade_color( $this->button_colors[ $color ]['color_bg'] ) : $this->button_colors[ $color ]['color_bg'];
$color_border = $color_border_hover = ( $style == 'solid' ) ? '' : $this->button_colors[ $color ]['color_border'];
$color_text = ( $style == 'solid' ) ? $this->button_colors[ $color ]['color_text'] : $this->button_colors[ $color ]['color_bg'];
$color_text_hover = $this->button_colors[ $color ]['color_text'];
}
}
// Exception for "Light" button text color
if ( in_array( $color, array( 'light', 'light_alt', 'semitransparent' ) ) ) {
$color_text = $color_text_hover = $this->button_colors[ $color ]['color_text'];
}
// Exception for "Transparent" button
if ( in_array( $color, array( 'transparent', 'transparent_alt' ) ) ) {
$shadow = $shadow_hover = $width = $height = $letter_spacing = $border_radius = 0;
$font = 'body';
$text_style = array();
$font_weight = '400';
$hover = 'fade';
// Exception for "Load More" button
} elseif ( $color == 'loadmore' ) {
$shadow = $shadow_hover = $letter_spacing = $border_radius = 0;
$width = $height = 1.2;
$font = 'body';
$text_style = array();
$font_weight = '700';
$hover = 'fade';
} else {
$shadow = $usof_options['button_shadow'];
$shadow_hover = ( ! empty( $usof_options['button_shadow_hover'] ) ) ? $usof_options['button_shadow_hover'] : $usof_options['button_shadow'];
$width = $usof_options['button_width'];
$height = ( $usof_options['button_height'] - 1.2 ) / 2;
$font = $usof_options['button_font'];
$text_style = $usof_options['button_text_style'];
$font_weight = $usof_options['button_fontweight'];
$letter_spacing = $usof_options['button_letterspacing'];
$border_radius = $usof_options['button_border_radius'];
$hover = ( $usof_options['button_hover'] == 'slide' ) ? 'slide' : 'fade';
}
// Exception for buttons with text color on hover
if ( ! empty( $this->button_colors[ $color ]['color_text_hover'] ) ) {
$color_text_hover = $this->button_colors[ $color ]['color_text_hover'];
}
if ( ! isset( $updated_options['buttons'] ) OR ! is_array( $updated_options['buttons'] ) ) {
$updated_options['buttons'] = array();
}
$id = 1;
foreach ( $updated_options['buttons'] as $_button_style ) {
$id = max( intval( $_button_style['id'] ) + 1, $id );
}
$button_style = array(
'_migrated_key' => $style_key,
'id' => $id,
'name' => $this->button_colors[ $color ]['name'] . $style_name,
'hover' => $hover,
'color_bg' => $color_bg,
'color_bg_hover' => $color_bg_hover,
'color_border' => $color_border,
'color_border_hover' => $color_border_hover,
'color_text' => $color_text,
'color_text_hover' => $color_text_hover,
'shadow' => $shadow,
'shadow_hover' => $shadow_hover,
'height' => $height,
'width' => $width,
'font' => $font,
'text_style' => $text_style,
'font_weight' => $font_weight,
'border_radius' => $border_radius,
'letter_spacing' => $letter_spacing,
'border_width' => 2,
);
$updated_options['buttons'][] = $button_style;
// Filling the missed options with default values
$updated_options = array_merge( usof_defaults(), $updated_options );
// Saving the changed options
usof_save_options( $updated_options );
return $id;
}
/**
* Set global button size if it was differ from body font-size
*/
private function btn_size() {
$btn_size = '';
if ( us_get_option( 'button_fontsize' ) !== us_get_option( 'body_fontsize' ) ) {
$btn_size = us_get_option( 'button_fontsize' ) . 'px';
}
return $btn_size;
}
}
@@ -0,0 +1,93 @@
<?php
class us_migration_5_5_3 extends US_Migration_Translator {
// Theme Options
public function translate_theme_options( &$options ) {
$changed = FALSE;
/*
* Grid Layout Buttons
*/
ob_start();
$grid_layouts = get_posts( array( 'post_type' => 'us_grid_layout', 'numberposts' => - 1, ) );
ob_end_clean();
foreach ( $grid_layouts as $grid_layout ) {
if ( ! empty( $grid_layout->post_content ) AND substr( strval( $grid_layout->post_content ), 0, 1 ) === '{' ) {
try {
$grid_settings = json_decode( $grid_layout->post_content, TRUE );
$grid_layout_changed = FALSE;
if ( isset( $grid_settings['data'] ) and is_array( $grid_settings['data'] ) ) {
foreach ( $grid_settings['data'] as $name => $data ) {
// HTML element
if ( substr( $name, 0, 4 ) == 'html' ) {
// Check if maybe the HTML was already encoded
if (preg_match('%^[a-zA-Z0-9/+]*={0,2}$%', $data['content'])) {
continue;
}
$grid_settings['data'][ $name ]['content'] = base64_encode( rawurlencode( $data['content'] ) );
$grid_layout_changed = TRUE;
}
}
}
if ( $grid_layout_changed ) {
ob_start();
wp_update_post(
array(
'ID' => $grid_layout->ID,
'post_content' => str_replace( "\\'", "'", json_encode( wp_slash( $grid_settings ), JSON_UNESCAPED_UNICODE ) ),
)
);
ob_end_clean();
}
}
catch ( Exception $e ) {
}
}
}
/*
* Header HTML Elements
*/
ob_start();
$headers = get_posts( array( 'post_type' => 'us_header', 'numberposts' => - 1, ) );
ob_end_clean();
foreach ( $headers as $header ) {
if ( ! empty( $header->post_content ) AND substr( strval( $header->post_content ), 0, 1 ) === '{' ) {
try {
$header_settings = json_decode( $header->post_content, TRUE );
$header_changed = FALSE;
if ( isset( $header_settings['data'] ) and is_array( $header_settings['data'] ) ) {
foreach ( $header_settings['data'] as $name => $data ) {
// HTML element
if ( substr( $name, 0, 4 ) == 'html' ) {
// Check if maybe the HTML was already encoded
if (preg_match('%^[a-zA-Z0-9/+]*={0,2}$%', $data['content'])) {
continue;
}
$header_settings['data'][ $name ]['content'] = base64_encode( rawurlencode( $data['content'] ) );
$header_changed = TRUE;
}
}
}
if ( $header_changed ) {
ob_start();
wp_update_post(
array(
'ID' => $header->ID,
'post_content' => str_replace( "\\'", "'", json_encode( wp_slash( $header_settings ), JSON_UNESCAPED_UNICODE ) ),
)
);
ob_end_clean();
}
}
catch ( Exception $e ) {
}
}
}
return $changed;
}
}
@@ -0,0 +1,820 @@
<?php
class us_migration_5_6 extends US_Migration_Translator {
// Content
public function translate_content( &$content ) {
$content = str_replace(
array( 'cl-counter', 'cl-popup', 'cl-itext', 'cl-flipbox' ), array(
'cl_counter',
'cl_popup',
'cl_itext',
'cl_flipbox',
), $content
);
return $this->_translate_content( $content );
}
// CL Popup
public function translate_cl_popup( &$name, &$params, &$content ) {
$name = 'us_popup';
if ( ( ! isset( $params['show_on'] ) OR in_array(
$params['show_on'], array(
'button',
'text',
)
) ) AND ! isset( $params['btn_style'] ) ) {
global $usof_options, $popup_btn_index;
$updated_options = $usof_options;
$popup_btn_index = ( ! empty( $popup_btn_index ) ) ? $popup_btn_index + 1 : 1;
usof_load_options_once();
$buttons_option_config = us_config( 'theme-options.buttons.fields.buttons.params', array() );
$button_style = array();
// Getting std values for default button
if ( isset( $updated_options['buttons'] ) AND is_array( $updated_options['buttons'] ) AND count( $updated_options['buttons'] ) > 0 ) {
$button_styles = array_values( $updated_options['buttons'] );
$button_style = array_shift( $button_styles );
} else {
foreach ( $buttons_option_config as $btn_param_name => $btn_param ) {
$button_style[ $btn_param_name ] = $btn_param['std'];
}
}
$button_style['color_border'] = '';
$button_style['color_border_hover'] = '';
if ( ! isset( $params['show_on'] ) OR $params['show_on'] == 'button' ) {
if ( ! empty( $params['btn_bgcolor'] ) ) {
$button_style['color_bg'] = $params['btn_bgcolor'];
$button_style['color_bg_hover'] = $params['btn_bgcolor'];
unset( $params['btn_bgcolor'] );
}
if ( ! empty( $params['btn_color'] ) ) {
$button_style['color_text'] = $params['btn_color'];
$button_style['color_text_hover'] = $params['btn_color'];
unset( $params['btn_color'] );
}
} elseif ( $params['show_on'] == 'text' ) {
$button_style['height'] = '0';
$button_style['width'] = '0';
$button_style['shadow'] = '0';
$button_style['shadow_hover'] = '0';
$button_style['color_bg'] = '';
$button_style['color_bg_hover'] = '';
$button_style['color_text'] = '';
$button_style['color_text_hover'] = '';
if ( ! empty( $params['text_color'] ) ) {
$button_style['color_text'] = $params['text_color'];
$button_style['color_text_hover'] = $params['text_color'];
unset( $params['text_color'] );
}
}
$button_style['name'] = 'Popup Button ' . $popup_btn_index;
if ( ! isset( $updated_options['buttons'] ) OR ! is_array( $updated_options['buttons'] ) ) {
$updated_options['buttons'] = array();
}
$btn_style_id = 1;
foreach ( $updated_options['buttons'] as $_button_style ) {
$btn_style_id = max( intval( $_button_style['id'] ) + 1, $btn_style_id );
}
$button_style['id'] = $btn_style_id;
$params['btn_style'] = $btn_style_id;
$updated_options['buttons'][] = $button_style;
// Filling the missed options with default values
$updated_options = array_merge( usof_defaults(), $updated_options );
// Saving the changed options
usof_save_options( $updated_options );
}
if ( isset( $params['size'] ) ) {
switch ( $params['size'] ) {
case 's':
$params['popup_width'] = '400px';
$params['popup_padding'] = '40px';
break;
case 'm':
$params['popup_width'] = '600px';
$params['popup_padding'] = '40px';
break;
case 'l':
$params['popup_width'] = '800px';
break;
case 'xl':
$params['popup_width'] = '1000px';
break;
case 'f':
$params['popup_width'] = '100%';
break;
}
unset( $params['size'] );
} else {
$params['popup_width'] = '400px';
$params['popup_padding'] = '40px';
}
if ( isset( $params['paddings'] ) AND $params['paddings'] == 'none' ) {
$params['popup_padding'] = 0;
unset( $params['paddings'] );
}
if ( isset( $params['border_radius'] ) ) {
$params['popup_border_radius'] = $params['border_radius'];
unset( $params['border_radius'] );
}
if ( ! isset( $params['btn_label'] ) ) {
$params['btn_label'] = 'READ MORE';
}
if ( isset( $params['text_size'] ) ) {
$params['btn_size'] = intval( $params['text_size'] ) . 'px';
unset( $params['text_size'] );
}
return TRUE;
}
// CL FlipBox
public function translate_cl_flipbox( &$name, &$params, &$content ) {
$name = 'us_flipbox';
if ( ! empty( $params['duration'] ) ) {
$params['duration'] = intval( $params['duration'] ) / 1000;
}
if ( ! empty( $params['front_icon_name'] ) ) {
global $us_template_directory;
$_filename = trailingslashit( $us_template_directory ) . 'functions/migrations/us_migration_5_0.php';
if ( file_exists( $_filename ) ) {
include_once $_filename;
$migration50 = new us_migration_5_0();
$translated_icon = $migration50->translate_icon_name( 'fa-' . $params['front_icon_name'] );
if ( $translated_icon != $params['front_icon_name'] ) {
$params['front_icon_name'] = $translated_icon;
}
}
}
if ( ! empty( $params['front_elmorder'] ) AND $params['front_elmorder'] == 'tid' ) {
$params['front_icon_pos'] = 'below_title';
unset( $params['front_elmorder'] );
} elseif ( ! empty( $params['front_elmorder'] ) AND $params['front_elmorder'] == 'tdi' ) {
$params['front_icon_pos'] = 'below_desc';
unset( $params['front_elmorder'] );
}
if ( ! empty( $params['border_size'] ) OR ! empty( $params['border_radius'] ) OR ! empty( $params['padding'] ) ) {
$params['css'] = '.vc_custom_9999{';
if ( ! empty( $params['border_size'] ) ) {
$params['css'] .= 'border: ' . intval( $params['border_size'] ) . 'px solid ' . $params['border_color'] . ' !important;';
unset( $params['border_size'] );
unset( $params['border_color'] );
}
if ( ! empty( $params['border_radius'] ) ) {
$params['css'] .= 'border-radius: ' . intval( $params['border_radius'] ) . 'px !important;';
unset( $params['border_radius'] );
}
if ( ! empty( $params['padding'] ) ) {
$params['css'] .= 'padding: ' . $params['padding'] . ' !important;';
unset( $params['padding'] );
}
$params['css'] .= '}';
}
if ( isset( $params['link_type'] ) AND $params['link_type'] == 'btn' ) {
global $usof_options, $flipbox_btn_index;
$updated_options = $usof_options;
$flipbox_btn_index = ( ! empty( $flipbox_btn_index ) ) ? $flipbox_btn_index + 1 : 1;
usof_load_options_once();
$buttons_option_config = us_config( 'theme-options.buttons.fields.buttons.params', array() );
$button_style = array();
// Getting std values for default button
// Getting std values for default button
if ( isset( $updated_options['buttons'] ) AND is_array( $updated_options['buttons'] ) AND count( $updated_options['buttons'] ) > 0 ) {
$button_styles = array_values( $updated_options['buttons'] );
$button_style = array_shift( $button_styles );
} else {
foreach ( $buttons_option_config as $btn_param_name => $btn_param ) {
$button_style[ $btn_param_name ] = $btn_param['std'];
}
}
$button_style['color_border'] = '';
$button_style['color_border_hover'] = '';
if ( ! empty( $params['back_btn_bgcolor'] ) ) {
$button_style['color_bg'] = $params['back_btn_bgcolor'];
$button_style['color_bg_hover'] = $params['back_btn_bgcolor'];
unset( $params['back_btn_bgcolor'] );
}
if ( ! empty( $params['back_btn_color'] ) ) {
$button_style['color_text'] = $params['back_btn_color'];
$button_style['color_text_hover'] = $params['back_btn_color'];
unset( $params['back_btn_color'] );
}
$button_style['name'] = 'FlipBox Button ' . $flipbox_btn_index;
if ( ! isset( $updated_options['buttons'] ) OR ! is_array( $updated_options['buttons'] ) ) {
$updated_options['buttons'] = array();
}
$btn_style_id = 1;
foreach ( $updated_options['buttons'] as $_button_style ) {
$btn_style_id = max( intval( $_button_style['id'] ) + 1, $btn_style_id );
}
$button_style['id'] = $btn_style_id;
$params['btn_style'] = $btn_style_id;
$updated_options['buttons'][] = $button_style;
// Filling the missed options with default values
$updated_options = array_merge( usof_defaults(), $updated_options );
// Saving the changed options
usof_save_options( $updated_options );
}
if ( ! empty( $params['back_btn_label'] ) ) {
$params['btn_label'] = $params['back_btn_label'];
unset( $params['back_btn_label'] );
}
if ( isset( $params['back_elmorder'] ) ) {
unset( $params['back_elmorder'] );
}
if ( isset( $params['valign'] ) ) {
unset( $params['valign'] );
}
if ( ! empty( $params['front_icon_size'] ) ) {
$params['front_icon_size'] = intval( $params['front_icon_size'] ) . 'px';
}
if ( ! empty( $params['front_icon_style'] ) AND $params['front_icon_style'] == 'square' ) {
$params['front_icon_style'] = 'circle';
}
if ( ! empty( $params['height'] ) ) {
$params['custom_height'] = intval( $params['height'] ) . 'px';
unset( $params['height'] );
}
if ( ! empty( $params['width'] ) ) {
$params['custom_width'] = $params['width'];
unset( $params['width'] );
}
return TRUE;
}
// CL iText
public function translate_cl_itext( &$name, &$params, &$content ) {
$name = 'us_itext';
if ( ! empty( $params['duration'] ) ) {
$params['duration'] = intval( $params['duration'] ) / 1000;
}
if ( ! isset( $params['font_size'] ) OR empty( $params['font_size'] ) ) {
$params['font_size'] = '50px';
}
if ( ! empty( $params['font_size_mobile'] ) ) {
$params['font_size_mobiles'] = $params['font_size_mobile'];
unset( $params['font_size_mobile'] );
} else {
$params['font_size_mobiles'] = '30px';
}
return TRUE;
}
// CL Counter
public function translate_cl_counter( &$name, &$params, &$content ) {
$name = 'us_counter';
$params['title_tag'] = 'div';
if ( ! isset( $params['final'] ) ) {
$params['final'] = '100';
}
if ( ! isset( $params['title'] ) ) {
$params['title'] = '';
}
if ( ! isset( $params['title_size'] ) ) {
$params['title_size'] = '20px';
}
if ( ! empty( $params['duration'] ) ) {
$params['duration'] = intval( $params['duration'] ) / 1000;
}
if ( ! empty( $params['value_size'] ) ) {
$params['size'] = intval( $params['value_size'] ) . 'px';
unset( $params['value_size'] );
} else {
$params['size'] = '50px';
}
if ( ! empty( $params['value_color'] ) ) {
$params['color'] = 'custom';
$params['custom_color'] = $params['value_color'];
unset( $params['value_color'] );
} else {
$params['color'] = 'text';
}
return TRUE;
}
// Single Image
public function translate_us_single_image( &$name, &$params, &$content ) {
$name = 'us_image';
return TRUE;
}
// Button
public function translate_us_btn( &$name, &$params, &$content ) {
if ( isset( $params['text'] ) ) {
$params['label'] = $params['text'];
unset( $params['text'] );
}
if ( ! empty( $params['size'] ) ) {
$params['font_size'] = $params['size'];
unset( $params['size'] );
}
if ( ! empty( $params['size_mobiles'] ) ) {
$params['font_size_mobiles'] = $params['size_mobiles'];
unset( $params['size_mobiles'] );
}
if ( ! empty( $params['width'] ) ) {
$params['custom_width'] = $params['width'];
unset( $params['width'] );
}
return TRUE;
}
// Counter
public function translate_us_counter( &$name, &$params, &$content ) {
if ( ! isset( $params['initial'] ) ) {
$params['initial'] = '0';
}
if ( isset( $params['target'] ) ) {
$params['final'] = $params['target'];
unset( $params['target'] );
}
if ( isset( $params['prefix'] ) ) {
$params['initial'] = $params['prefix'] . $params['initial'];
$params['final'] = $params['prefix'] . $params['final'];
unset( $params['prefix'] );
}
if ( isset( $params['suffix'] ) ) {
$params['initial'] = $params['initial'] . $params['suffix'];
$params['final'] = $params['final'] . $params['suffix'];
unset( $params['suffix'] );
}
if ( ! isset( $params['color'] ) ) {
$params['color'] = 'heading';
}
if ( ! isset( $params['font'] ) ) {
$params['font'] = 'heading';
}
return TRUE;
}
// Social Links
public function translate_us_social_links( &$name, &$params, &$content ) {
$name = 'us_socials';
if ( ! isset( $params['gap'] ) ) {
$params['gap'] = '0.1em';
}
return TRUE;
}
// Sharing
public function translate_us_sharing( &$name, &$params, &$content ) {
if ( ! empty( $params['providers'] ) ) {
return FALSE;
}
$params['providers'] = '';
if ( isset( $params['email'] ) AND $params['email'] ) {
$params['providers'] .= ',email';
unset( $params['email'] );
}
if ( isset( $params['facebook'] ) AND $params['facebook'] ) {
$params['providers'] .= ',facebook';
unset( $params['facebook'] );
}
if ( isset( $params['twitter'] ) AND $params['twitter'] ) {
$params['providers'] .= ',twitter';
unset( $params['twitter'] );
}
if ( isset( $params['gplus'] ) AND $params['gplus'] ) {
$params['providers'] .= ',gplus';
unset( $params['gplus'] );
}
if ( isset( $params['linkedin'] ) AND $params['linkedin'] ) {
$params['providers'] .= ',linkedin';
unset( $params['linkedin'] );
}
if ( isset( $params['pinterest'] ) AND $params['pinterest'] ) {
$params['providers'] .= ',pinterest';
unset( $params['pinterest'] );
}
if ( isset( $params['vk'] ) AND $params['vk'] ) {
$params['providers'] .= ',vk';
unset( $params['vk'] );
}
$params['providers'] = substr( $params['providers'], 1 );
if ( empty( $params['providers'] ) ) {
unset( $params['providers'] );
}
return TRUE;
}
// Separator
public function translate_us_separator( &$name, &$params, &$content ) {
$changed = FALSE;
if ( isset( $params['type'] ) ) {
if ( $params['type'] == 'default' ) {
$params['show_line'] = '1';
$params['line_width'] = 'default';
} elseif ( $params['type'] == 'fullwidth' ) {
$params['show_line'] = '1';
$params['line_width'] = 'screen';
} elseif ( $params['type'] == 'short' ) {
$params['show_line'] = '1';
$params['line_width'] = '30';
}
$changed = TRUE;
unset( $params['type'] );
}
return $changed;
}
// Empty Space
public function translate_vc_empty_space( &$name, &$params, &$content ) {
$name = 'us_separator';
$params['size'] = 'custom';
if ( ! isset( $params['height'] ) ) {
$params['height'] = '32px';
} else {
preg_match( '~^([0-9]+)([a-z]+|%)?$~', trim( $params['height'] ), $matches );
$value = isset( $matches[1] ) ? $matches[1] : '';
$units = isset( $matches[2] ) ? $matches[2] : 'px';
if ( ! empty( $value ) ) {
$params['height'] = $value . $units;
}
}
return TRUE;
}
// Default WP Gallery
public function translate_gallery( &$name, &$params, &$content ) {
$changed = FALSE;
if ( empty( $params['size'] ) ) {
$columns = ( isset( $params['columns'] ) ) ? $params['columns'] : 3;
if ( isset( $params['layout'] ) AND $params['layout'] == 'masonry' AND $columns > 1 ) {
$params['size'] = ( $columns < 6 ) ? 'large' : 'medium';
$changed = TRUE;
} else/*if($layout == 'default')*/ {
if ( $columns == 1 ) {
$params['size'] = 'full';
$changed = TRUE;
} elseif ( $columns < 5 ) {
$params['size'] = 'us_600_600_crop';
$changed = TRUE;
} elseif ( $columns < 8 ) {
$params['size'] = 'us_350_350_crop';
$changed = TRUE;
}
}
}
return $changed;
}
// Theme Options
public function translate_theme_options( &$options ) {
/* Add new checkboxes if Optimize option is ON */
if ( isset( $options['optimize_assets'] ) AND $options['optimize_assets'] == 1 AND is_array( $options['assets'] ) ) {
$options['assets'] = array_merge(
array(
'popups',
'flipbox',
'itext',
), $options['assets']
);
}
// Buttons
$btn_styles = isset( $options['buttons'] ) ? $options['buttons'] : array();
foreach ( $btn_styles as $key => $btn_style ) {
$options['buttons'][ $key ]['shadow'] = ( substr( $btn_style['shadow'], - 2 ) != 'em' ) ? floatval( $btn_style['shadow'] ) . 'em' : $btn_style['shadow'];
$options['buttons'][ $key ]['shadow_hover'] = ( substr( $btn_style['shadow_hover'], - 2 ) != 'em' ) ? floatval( $btn_style['shadow_hover'] ) . 'em' : $btn_style['shadow_hover'];
$options['buttons'][ $key ]['height'] = ( substr( $btn_style['height'], - 2 ) != 'em' ) ? floatval( $btn_style['height'] ) . 'em' : $btn_style['height'];
$options['buttons'][ $key ]['width'] = ( substr( $btn_style['width'], - 2 ) != 'em' ) ? floatval( $btn_style['width'] ) . 'em' : $btn_style['width'];
$options['buttons'][ $key ]['border_radius'] = ( substr( $btn_style['border_radius'], - 2 ) != 'em' ) ? floatval( $btn_style['border_radius'] ) . 'em' : $btn_style['border_radius'];
$options['buttons'][ $key ]['letter_spacing'] = ( substr( $btn_style['letter_spacing'], - 2 ) != 'em' ) ? floatval( $btn_style['letter_spacing'] ) . 'em' : $btn_style['letter_spacing'];
$options['buttons'][ $key ]['border_width'] = ( substr( $btn_style['border_width'], - 2 ) != 'px' ) ? intval( $btn_style['border_width'] ) . 'px' : $btn_style['border_width'];
}
$slider_suffixes_map = array(
'back_to_top_display' => 'vh',
'smooth_scroll_duration' => 'ms',
'site_canvas_width' => 'px',
'site_content_width' => 'px',
'sidebar_width' => '%',
'content_width' => '%',
'columns_stacking_width' => 'px',
'disable_effects_width' => 'px',
// Header settings
'header_top_height' => 'px',
'header_top_sticky_height' => 'px',
'header_middle_height' => 'px',
'header_middle_sticky_height' => 'px',
'header_bottom_height' => 'px',
'header_bottom_sticky_height' => 'px',
'header_main_width' => 'px',
'logo_font_size' => 'px',
'logo_font_size_tablets' => 'px',
'logo_font_size_mobiles' => 'px',
'logo_height' => 'px',
'logo_height_sticky' => 'px',
'logo_height_tablets' => 'px',
'logo_height_mobiles' => 'px',
'menu_fontsize' => 'px',
'menu_indents' => 'px',
'menu_sub_fontsize' => 'px',
'menu_mobile_width' => 'px',
// Typography
'body_fontsize' => 'px',
'body_lineheight' => 'px',
'body_fontsize_mobile' => 'px',
'body_lineheight_mobile' => 'px',
'h1_fontsize' => 'px',
'h1_fontsize_mobile' => 'px',
'h1_letterspacing' => 'em',
'h2_fontsize' => 'px',
'h2_fontsize_mobile' => 'px',
'h2_letterspacing' => 'em',
'h3_fontsize' => 'px',
'h3_fontsize_mobile' => 'px',
'h3_letterspacing' => 'em',
'h4_fontsize' => 'px',
'h4_fontsize_mobile' => 'px',
'h4_letterspacing' => 'em',
'h5_fontsize' => 'px',
'h5_fontsize_mobile' => 'px',
'h5_letterspacing' => 'em',
'h6_fontsize' => 'px',
'h6_fontsize_mobile' => 'px',
'h6_letterspacing' => 'em',
// Blog
'post_related_items_gap' => 'rem',
'blog_items_gap' => 'rem',
'archive_items_gap' => 'rem',
'search_items_gap' => 'rem',
'shop_items_gap' => 'rem',
);
foreach ( $slider_suffixes_map as $param => $suffix ) {
if ( substr( $options[ $param ], - strlen( $suffix ) ) != $suffix ) {
if ( in_array( $suffix, array( 'em', 'rem' ) ) ) {
$options[ $param ] = floatval( $options[ $param ] ) . $suffix;
} else {
$options[ $param ] = intval( $options[ $param ] ) . $suffix;
}
}
}
/*
* Grid Layouts
*/
ob_start();
$grid_layouts = get_posts( array( 'post_type' => 'us_grid_layout', 'numberposts' => - 1, ) );
ob_end_clean();
foreach ( $grid_layouts as $grid_layout ) {
if ( ! empty( $grid_layout->post_content ) AND substr( strval( $grid_layout->post_content ), 0, 1 ) === '{' ) {
try {
$grid_settings = json_decode( $grid_layout->post_content, TRUE );
if ( isset( $grid_settings['data'] ) and is_array( $grid_settings['data'] ) ) {
foreach ( $grid_settings['data'] as $name => $data ) {
// Button
if ( substr( $name, 0, 3 ) == 'btn' ) {
$grid_settings['data'][ $name ]['font_size'] = ( empty( $data['size'] ) OR intval( $data['size'] ) == 0 ) ? '' : ( intval( $data['size'] ) . 'px' );
$grid_settings['data'][ $name ]['font_size_tablets'] = ( empty( $data['size_tablets'] ) OR intval( $data['size_tablets'] ) == 0 ) ? '' : ( intval( $data['size_tablets'] ) . 'px' );
$grid_settings['data'][ $name ]['font_size_mobiles'] = ( empty( $data['size_mobiles'] ) OR intval( $data['size_mobiles'] ) == 0 ) ? '' : ( intval( $data['size_mobiles'] ) . 'px' );
}
$grid_settings['data'][ $name ]['transition_duration'] = isset( $data['transition_duration'] ) ? floatval( $data['transition_duration'] ) . 's' : '0.35s';
$grid_settings['data'][ $name ]['translateX'] = intval( $data['translateX'] ) . '%';
$grid_settings['data'][ $name ]['translateX_hover'] = intval( $data['translateX_hover'] ) . '%';
$grid_settings['data'][ $name ]['translateY'] = intval( $data['translateY'] ) . '%';
$grid_settings['data'][ $name ]['translateY_hover'] = intval( $data['translateY_hover'] ) . '%';
}
}
ob_start();
wp_update_post(
array(
'ID' => $grid_layout->ID,
'post_content' => str_replace( "\\'", "'", json_encode( wp_slash( $grid_settings ), JSON_UNESCAPED_UNICODE ) ),
)
);
ob_end_clean();
}
catch ( Exception $e ) {
}
}
}
/*
* Headers
*/
ob_start();
$headers = get_posts( array( 'post_type' => 'us_header', 'numberposts' => - 1, ) );
ob_end_clean();
foreach ( $headers as $header ) {
if ( ! empty( $header->post_content ) AND substr( strval( $header->post_content ), 0, 1 ) === '{' ) {
try {
$header_settings = json_decode( $header->post_content, TRUE );
// Elements
if ( isset( $header_settings['data'] ) and is_array( $header_settings['data'] ) ) {
foreach ( $header_settings['data'] as $name => $data ) {
// Image
if ( substr( $name, 0, 5 ) == 'image' ) {
$header_settings['data'][ $name ]['height'] = intval( $data['height'] ) . 'px';
$header_settings['data'][ $name ]['height_tablets'] = intval( $data['height_tablets'] ) . 'px';
$header_settings['data'][ $name ]['height_mobiles'] = intval( $data['height_mobiles'] ) . 'px';
$header_settings['data'][ $name ]['height_sticky'] = intval( $data['height_sticky'] ) . 'px';
$header_settings['data'][ $name ]['height_sticky_tablets'] = intval( $data['height_sticky_tablets'] ) . 'px';
$header_settings['data'][ $name ]['height_sticky_mobiles'] = intval( $data['height_sticky_mobiles'] ) . 'px';
}
// Text
if ( substr( $name, 0, 4 ) == 'text' OR substr( $name, 0, 3 ) == 'btn' ) {
$header_settings['data'][ $name ]['font_size'] = $data['size'] . 'px';
$header_settings['data'][ $name ]['font_size_tablets'] = $data['size_tablets'] . 'px';
$header_settings['data'][ $name ]['font_size_mobiles'] = $data['size_mobiles'] . 'px';
$header_settings['data'][ $name ]['text_styles'] = isset( $data['text_style'] ) ? $data['text_style'] : array();
}
// Menu
if ( substr( $name, 0, 4 ) == 'menu' ) {
$header_settings['data'][ $name ]['font_size'] = intval( $data['font_size'] ) . 'px';
$header_settings['data'][ $name ]['indents'] = ( substr( $data['indents'], - 2 ) != 'px' ) ? ( intval( $data['indents'] ) / 2 ) . 'px' : $data['indents'];
$header_settings['data'][ $name ]['dropdown_font_size'] = intval( $data['dropdown_font_size'] ) . 'px';
$header_settings['data'][ $name ]['mobile_font_size'] = intval( $data['mobile_font_size'] ) . 'px';
$header_settings['data'][ $name ]['mobile_dropdown_font_size'] = intval( $data['mobile_dropdown_font_size'] ) . 'px';
$header_settings['data'][ $name ]['mobile_icon_size'] = ( ! empty( $data['mobile_icon_size'] ) AND intval( $data['mobile_icon_size'] ) > 0 ) ? intval( $data['mobile_icon_size'] ) . 'px' : '';
$header_settings['data'][ $name ]['mobile_icon_size_tablets'] = ( ! empty( $data['mobile_icon_size_tablets'] ) AND intval( $data['mobile_icon_size_tablets'] ) > 0 ) ? intval( $data['mobile_icon_size_tablets'] ) . 'px' : '';
$header_settings['data'][ $name ]['mobile_icon_size_mobiles'] = ( ! empty( $data['mobile_icon_size_mobiles'] ) AND intval( $data['mobile_icon_size_mobiles'] ) > 0 ) ? intval( $data['mobile_icon_size_mobiles'] ) . 'px' : '';
}
// Links Menu
if ( substr( $name, 0, 15 ) == 'additional_menu' ) {
$header_settings['data'][ $name ]['size'] = intval( $data['size'] ) . 'px';
$header_settings['data'][ $name ]['size_tablets'] = intval( $data['size_tablets'] ) . 'px';
$header_settings['data'][ $name ]['size_mobiles'] = intval( $data['size_mobiles'] ) . 'px';
$header_settings['data'][ $name ]['indents'] = ( substr( $data['indents'], - 2 ) != 'px' ) ? ( intval( $data['indents'] ) / 2 ) . 'px' : $data['indents'];
$header_settings['data'][ $name ]['indents_tablets'] = ( substr( $data['indents_tablets'], - 2 ) != 'px' ) ? ( intval( $data['indents_tablets'] ) / 2 ) . 'px' : $data['indents_tablets'];
$header_settings['data'][ $name ]['indents_mobiles'] = ( substr( $data['indents_mobiles'], - 2 ) != 'px' ) ? ( intval( $data['indents_mobiles'] ) / 2 ) . 'px' : $data['indents_mobiles'];
}
// Search
if ( substr( $name, 0, 6 ) == 'search' ) {
$header_settings['data'][ $name ]['icon_size'] = ( ! empty( $data['icon_size'] ) AND intval( $data['icon_size'] ) > 0 ) ? intval( $data['icon_size'] ) . 'px' : '';
$header_settings['data'][ $name ]['icon_size_tablets'] = ( ! empty( $data['icon_size_tablets'] ) AND intval( $data['icon_size_tablets'] ) > 0 ) ? intval( $data['icon_size_tablets'] ) . 'px' : '';
$header_settings['data'][ $name ]['icon_size_mobiles'] = ( ! empty( $data['icon_size_mobiles'] ) AND intval( $data['icon_size_mobiles'] ) > 0 ) ? intval( $data['icon_size_mobiles'] ) . 'px' : '';
$header_settings['data'][ $name ]['field_width'] = intval( $data['width'] ) . 'px';
$header_settings['data'][ $name ]['field_width_tablets'] = intval( $data['width_tablets'] ) . 'px';
}
// Dropdown, Social Links, Cart
if ( substr( $name, 0, 8 ) == 'dropdown' OR substr( $name, 0, 7 ) == 'socials' OR substr( $name, 0, 4 ) == 'cart' ) {
$header_settings['data'][ $name ]['size'] = intval( $data['size'] ) . 'px';
$header_settings['data'][ $name ]['size_tablets'] = intval( $data['size_tablets'] ) . 'px';
$header_settings['data'][ $name ]['size_mobiles'] = intval( $data['size_mobiles'] ) . 'px';
}
}
}
// Settings
$states = array( 'default', 'tablets', 'mobiles' );
foreach ( $states as $state ) {
if ( isset( $header_settings[ $state ] ) ) {
$header_settings[ $state ]['options']['width'] = intval( $header_settings[ $state ]['options']['width'] ) . 'px';
$header_settings[ $state ]['options']['top_height'] = intval( $header_settings[ $state ]['options']['top_height'] ) . 'px';
$header_settings[ $state ]['options']['top_sticky_height'] = intval( $header_settings[ $state ]['options']['top_sticky_height'] ) . 'px';
$header_settings[ $state ]['options']['middle_height'] = intval( $header_settings[ $state ]['options']['middle_height'] ) . 'px';
$header_settings[ $state ]['options']['middle_sticky_height'] = intval( $header_settings[ $state ]['options']['middle_sticky_height'] ) . 'px';
$header_settings[ $state ]['options']['bottom_height'] = intval( $header_settings[ $state ]['options']['bottom_height'] ) . 'px';
$header_settings[ $state ]['options']['bottom_sticky_height'] = intval( $header_settings[ $state ]['options']['bottom_sticky_height'] ) . 'px';
}
}
ob_start();
wp_update_post(
array(
'ID' => $header->ID,
'post_content' => str_replace( "\\'", "'", json_encode( wp_slash( $header_settings ), JSON_UNESCAPED_UNICODE ) ),
)
);
ob_end_clean();
}
catch ( Exception $e ) {
}
}
}
// Menu items
$menu_items = array();
foreach ( get_terms( array( 'taxonomy' => 'nav_menu', 'hide_empty' => TRUE ) ) as $menu_obj ) {
$menu_items = array_merge(
$menu_items, wp_get_nav_menu_items( $menu_obj->term_id, array( 'post_status' => 'any' ) )
);
}
foreach ( $menu_items as $menu_item ) {
$menu_item_changed = FALSE;
$mega_menu_settings = get_post_meta( $menu_item->ID, 'us_mega_menu_settings', TRUE );
if ( ! empty( $mega_menu_settings['custom_width'] ) AND substr( $mega_menu_settings['custom_width'], - 2 ) != 'px' ) {
$mega_menu_settings['custom_width'] = intval( $mega_menu_settings['custom_width'] ) . 'px';
$menu_item_changed = TRUE;
}
if ( ! empty( $mega_menu_settings['padding'] ) AND substr( $mega_menu_settings['padding'], - 2 ) != 'px' ) {
$mega_menu_settings['padding'] = intval( $mega_menu_settings['padding'] ) . 'px';
$menu_item_changed = TRUE;
}
if ( $menu_item_changed ) {
update_post_meta( $menu_item->ID, 'us_mega_menu_settings', $mega_menu_settings );
}
}
return TRUE;
}
// Widgets
public function translate_widgets( &$name, &$instance ) {
$changed = FALSE;
if ( $name == 'text' ) {
$text = $instance['text'];
if ( $this->translate_content( $text ) ) {
$instance['text'] = $text;
$changed = TRUE;
}
}
return $changed;
}
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,291 @@
<?php
class us_migration_5_8 extends US_Migration_Translator {
// Content
public function translate_content( &$content ) {
return $this->_translate_content( $content );
}
public function translate_us_post_content( &$name, &$params, &$content ) {
$changed = $this->migrate_text_styles( $params ) OR FALSE;
return $changed;
}
public function translate_us_post_comments( &$name, &$params, &$content ) {
$changed = $this->migrate_text_styles( $params ) OR FALSE;
return $changed;
}
public function translate_us_post_taxonomy( &$name, &$params, &$content ) {
$changed = $this->migrate_text_styles( $params ) OR FALSE;
return $changed;
}
public function translate_us_post_custom_field( &$name, &$params, &$content ) {
$changed = $this->migrate_text_styles( $params ) OR FALSE;
return $changed;
}
public function translate_us_post_date( &$name, &$params, &$content ) {
$changed = $this->migrate_text_styles( $params ) OR FALSE;
return $changed;
}
public function translate_us_post_author( &$name, &$params, &$content ) {
$changed = $this->migrate_text_styles( $params ) OR FALSE;
return $changed;
}
public function translate_us_post_title( &$name, &$params, &$content ) {
$changed = $this->migrate_text_styles( $params ) OR FALSE;
return $changed;
}
public function translate_us_page_title( &$name, &$params, &$content ) {
$changed = $this->migrate_text_styles( $params ) OR FALSE;
return $changed;
}
public function translate_us_itext( &$name, &$params, &$content ) {
$changed = $this->migrate_text_styles( $params ) OR FALSE;
return $changed;
}
public function translate_us_counter( &$name, &$params, &$content ) {
$changed = $this->migrate_text_styles( $params ) OR FALSE;
return $changed;
}
public function translate_vc_tta_tabs( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ! empty( $params['title_text_styles'] ) ) {
if ( strpos( $params['title_text_styles'], 'bold' ) !== FALSE ) {
$params['title_weight'] = '700';
}
if ( strpos( $params['title_text_styles'], 'uppercase' ) !== FALSE ) {
$params['title_transform'] = 'uppercase';
}
unset( $params['title_text_styles'] );
$changed = TRUE;
}
return $changed;
}
public function translate_vc_tta_tour( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ! empty( $params['title_text_styles'] ) ) {
if ( strpos( $params['title_text_styles'], 'bold' ) !== FALSE ) {
$params['title_weight'] = '700';
}
if ( strpos( $params['title_text_styles'], 'uppercase' ) !== FALSE ) {
$params['title_transform'] = 'uppercase';
}
unset( $params['title_text_styles'] );
$changed = TRUE;
}
return $changed;
}
// Theme Options
public function translate_theme_options( &$options ) {
if ( isset( $options['heading_font_family'] ) ) {
$options['h1_font_family'] = $options['heading_font_family'];
unset( $options['heading_font_family'] );
}
/*
* Grid Layouts
*/
ob_start();
$grid_layouts = get_posts( array( 'post_type' => 'us_grid_layout', 'numberposts' => - 1, ) );
ob_end_clean();
foreach ( $grid_layouts as $grid_layout ) {
if ( ! empty( $grid_layout->post_content ) AND substr( strval( $grid_layout->post_content ), 0, 1 ) === '{' ) {
try {
$grid_settings = json_decode( $grid_layout->post_content, TRUE );
$grid_layout_changed = FALSE;
if ( isset( $grid_settings['data'] ) and is_array( $grid_settings['data'] ) ) {
foreach ( $grid_settings['data'] as $name => $data ) {
// Check font
if ( ! empty( $data['font'] ) AND $data['font'] == 'heading' ) {
$grid_settings['data'][ $name ]['font'] = 'h1';
$grid_layout_changed = TRUE;
}
// Check text styles
if ( ! empty( $data['text_styles'] ) AND is_array( $data['text_styles'] ) ) {
if ( in_array( 'bold', $data['text_styles'] ) ) {
$grid_settings['data'][ $name ]['font_weight'] = '700';
}
if ( in_array( 'uppercase', $data['text_styles'] ) ) {
$grid_settings['data'][ $name ]['text_transform'] = 'uppercase';
}
if ( in_array( 'italic', $data['text_styles'] ) ) {
$grid_settings['data'][ $name ]['font_style'] = 'italic';
}
unset( $grid_settings['data'][ $name ]['text_styles'] );
$grid_layout_changed = TRUE;
}
}
}
if ( $grid_layout_changed ) {
ob_start();
wp_update_post(
array(
'ID' => $grid_layout->ID,
'post_content' => str_replace( "\\'", "'", json_encode( wp_slash( $grid_settings ), JSON_UNESCAPED_UNICODE ) ),
)
);
ob_end_clean();
}
}
catch ( Exception $e ) {
}
}
}
/*
* Headers
*/
ob_start();
$headers = get_posts( array( 'post_type' => 'us_header', 'numberposts' => - 1, ) );
ob_end_clean();
foreach ( $headers as $header ) {
if ( ! empty( $header->post_content ) AND substr( strval( $header->post_content ), 0, 1 ) === '{' ) {
try {
$header_settings = json_decode( $header->post_content, TRUE );
$header_changed = FALSE;
if ( isset( $header_settings['data'] ) and is_array( $header_settings['data'] ) ) {
foreach ( $header_settings['data'] as $name => $data ) {
// Text element
if ( substr( $name, 0, 4 ) == 'text' ) {
if ( ! empty( $data['font'] ) AND $data['font'] == 'heading' ) {
$header_settings['data'][ $name ]['font'] = 'h1';
$header_changed = TRUE;
}
// Check text styles
if ( ! empty( $data['text_styles'] ) AND is_array( $data['text_styles'] ) ) {
if ( in_array( 'bold', $data['text_styles'] ) ) {
$header_settings['data'][ $name ]['font_weight'] = '700';
}
if ( in_array( 'uppercase', $data['text_styles'] ) ) {
$header_settings['data'][ $name ]['text_transform'] = 'uppercase';
}
if ( in_array( 'italic', $data['text_styles'] ) ) {
$header_settings['data'][ $name ]['font_style'] = 'italic';
}
unset( $header_settings['data'][ $name ]['text_styles'] );
$header_changed = TRUE;
}
}
// Menu element
if ( substr( $name, 0, 4 ) == 'menu' ) {
if ( ! empty( $data['font'] ) AND $data['font'] == 'heading' ) {
$header_settings['data'][ $name ]['font'] = 'h1';
$header_changed = TRUE;
}
// Check text style
if ( ! empty( $data['text_style'] ) AND is_array( $data['text_style'] ) ) {
if ( in_array( 'bold', $data['text_style'] ) ) {
$header_settings['data'][ $name ]['font_weight'] = '700';
}
if ( in_array( 'uppercase', $data['text_style'] ) ) {
$header_settings['data'][ $name ]['text_transform'] = 'uppercase';
}
if ( in_array( 'italic', $data['text_style'] ) ) {
$header_settings['data'][ $name ]['font_style'] = 'italic';
}
unset( $header_settings['data'][ $name ]['text_style'] );
$header_changed = TRUE;
}
}
}
}
if ( $header_changed ) {
ob_start();
wp_update_post(
array(
'ID' => $header->ID,
'post_content' => str_replace( "\\'", "'", json_encode( wp_slash( $header_settings ), JSON_UNESCAPED_UNICODE ) ),
)
);
ob_end_clean();
}
}
catch ( Exception $e ) {
}
}
}
return TRUE;
}
// Common Text Styles migration
private function migrate_text_styles( &$params ) {
$changed = FALSE;
if ( ! empty( $params['font'] ) AND $params['font'] == 'heading' ) {
$params['font'] = 'h1';
$changed = TRUE;
}
if ( ! empty( $params['text_styles'] ) ) {
if ( strpos( $params['text_styles'], 'bold' ) !== FALSE ) {
$params['font_weight'] = '700';
}
if ( strpos( $params['text_styles'], 'uppercase' ) !== FALSE ) {
$params['text_transform'] = 'uppercase';
}
if ( strpos( $params['text_styles'], 'italic' ) !== FALSE ) {
$params['font_style'] = 'italic';
}
unset( $params['text_styles'] );
$changed = TRUE;
}
return $changed;
}
}
@@ -0,0 +1,564 @@
<?php
class us_migration_6_0 extends US_Migration_Translator {
/**
* @var bool Possibly dangerous translation that needs to be migrated manually
*/
public $should_be_manual = TRUE;
private $previous_theme_options;
// Get Grid Layout & Gap which were set in former Shop options
private function get_products_grid( $type = '', $for_terms = FALSE ) {
$layout = 'shop_standard';
$gap = '1.2rem';
if ( $this->previous_theme_options['shop_listing_style'] == 'modern' ) {
$layout = 'shop_modern';
$gap = '5px';
} elseif ( $this->previous_theme_options['shop_listing_style'] == 'trendy' ) {
$layout = ( $for_terms ) ? 'tile_21_right' : 'shop_trendy';
$gap = ( $for_terms ) ? '10px' : '';
} elseif ( $this->previous_theme_options['shop_listing_style'] == 'custom' ) {
$layout = $this->previous_theme_options['shop_layout'];
$gap = $this->previous_theme_options['shop_items_gap'];
}
return ( $type == 'gap' ) ? $gap : $layout;
}
// Content
public function translate_content( &$content ) {
return $this->_translate_content( $content );
}
// Row
public function translate_vc_row( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ! empty( $params['gap'] ) ) {
$params['gap'] = ( intval( $params['gap'] ) / 2 ) . 'px';
$changed = TRUE;
}
return $changed;
}
// Inner Row
public function translate_vc_inner_row( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ! empty( $params['gap'] ) ) {
$params['gap'] = ( intval( $params['gap'] ) / 2 ) . 'px';
$changed = TRUE;
}
return $changed;
}
// Grid into Carousel
public function translate_us_grid( &$name, &$params, &$content ) {
$changed = FALSE;
if ( ! empty( $params['type'] ) AND $params['type'] == 'carousel' ) {
$name = 'us_carousel';
unset( $params['type'] );
$changed = TRUE;
}
return $changed;
}
// Product
public function translate_product( &$name, &$params, &$content ) {
$name = 'us_grid';
$params['post_type'] = 'ids';
$params['no_items_message'] = '';
$params['columns'] = '4';
$params['items_layout'] = $this->get_products_grid();
$params['items_gap'] = $this->get_products_grid( 'gap' );
if ( ! empty( $params['id'] ) ) {
$params['ids'] = $params['id'];
unset( $params['id'] );
}
return TRUE;
}
// Products
public function translate_products( &$name, &$params, &$content ) {
$name = 'us_grid';
if ( ! empty( $params['ids'] ) ) {
$params['post_type'] = 'ids';
} else {
$params['post_type'] = 'product';
}
$params['no_items_message'] = '';
$params['items_layout'] = $this->get_products_grid();
$params['items_gap'] = $this->get_products_grid( 'gap' );
if ( ! empty( $params['orderby'] ) AND $params['orderby'] == 'include' ) {
$params['orderby'] = 'post__in';
}
return TRUE;
}
// Top Rated Products
public function translate_top_rated_products( &$name, &$params, &$content ) {
$name = 'us_grid';
$params['post_type'] = 'product';
$params['orderby'] = 'rating';
$params['items_layout'] = $this->get_products_grid();
$params['items_gap'] = $this->get_products_grid( 'gap' );
if ( isset( $params['per_page'] ) ) {
$params['items_quantity'] = $params['per_page'];
unset( $params['per_page'] );
}
return TRUE;
}
// Best Selling Products
public function translate_best_selling_products( &$name, &$params, &$content ) {
$name = 'us_grid';
$params['post_type'] = 'product';
$params['orderby'] = 'popularity';
$params['items_layout'] = $this->get_products_grid();
$params['items_gap'] = $this->get_products_grid( 'gap' );
if ( isset( $params['per_page'] ) ) {
$params['items_quantity'] = $params['per_page'];
unset( $params['per_page'] );
}
return TRUE;
}
// Product category
public function translate_product_category( &$name, &$params, &$content ) {
$name = 'us_grid';
$params['post_type'] = 'product';
$params['items_layout'] = $this->get_products_grid();
$params['items_gap'] = $this->get_products_grid( 'gap' );
if ( isset( $params['per_page'] ) ) {
$params['items_quantity'] = $params['per_page'];
unset( $params['per_page'] );
}
if ( isset( $params['category'] ) ) {
$params['taxonomy_product_cat'] = $params['category'];
unset( $params['category'] );
}
if ( ! empty( $params['orderby'] ) ) {
if ( $params['orderby'] == 'title' ) {
$params['orderby'] = 'alpha';
}
if ( ! empty( $params['order'] ) AND $params['order'] == 'ASC' ) {
if ( $params['orderby'] == 'date' ) {
$params['orderby'] = 'date_asc';
} elseif ( $params['orderby'] == 'modified' ) {
$params['orderby'] = 'modified_asc';
}
unset( $params['order'] );
}
}
return TRUE;
}
// Product categories
public function translate_product_categories( &$name, &$params, &$content ) {
$name = 'us_grid';
$params['post_type'] = 'taxonomy_terms';
$params['related_taxonomy'] = 'product_cat';
$params['terms_include'] = 'children';
$params['terms_orderby'] = 'name';
$params['no_items_message'] = '';
$params['title_size'] = '1.4rem';
$params['items_layout'] = $this->get_products_grid( '', TRUE );
$params['items_gap'] = $this->get_products_grid( 'gap', TRUE );
if ( isset( $params['number'] ) ) {
$params['items_quantity'] = $params['number'];
unset( $params['number'] );
}
if ( isset( $params['orderby'] ) ) {
$params['terms_orderby'] = $params['orderby'];
}
return TRUE;
}
// Recent products
public function translate_recent_products( &$name, &$params, &$content ) {
$name = 'us_grid';
$params['post_type'] = 'product';
$params['items_layout'] = $this->get_products_grid();
$params['items_gap'] = $this->get_products_grid( 'gap' );
if ( isset( $params['per_page'] ) ) {
$params['items_quantity'] = $params['per_page'];
unset( $params['per_page'] );
}
if ( ! empty( $params['orderby'] ) ) {
if ( $params['orderby'] == 'title' ) {
$params['orderby'] = 'alpha';
}
if ( ! empty( $params['order'] ) AND $params['order'] == 'ASC' ) {
if ( $params['orderby'] == 'date' ) {
$params['orderby'] = 'date_asc';
} elseif ( $params['orderby'] == 'modified' ) {
$params['orderby'] = 'modified_asc';
}
unset( $params['order'] );
}
}
return TRUE;
}
// Featured products
public function translate_featured_products( &$name, &$params, &$content ) {
$name = 'us_grid';
$params['post_type'] = 'product';
$params['products_include'] = 'featured';
$params['items_layout'] = $this->get_products_grid();
$params['items_gap'] = $this->get_products_grid( 'gap' );
if ( isset( $params['per_page'] ) ) {
$params['items_quantity'] = $params['per_page'];
unset( $params['per_page'] );
}
if ( ! empty( $params['orderby'] ) ) {
if ( $params['orderby'] == 'title' ) {
$params['orderby'] = 'alpha';
}
if ( ! empty( $params['order'] ) AND $params['order'] == 'ASC' ) {
if ( $params['orderby'] == 'date' ) {
$params['orderby'] = 'date_asc';
} elseif ( $params['orderby'] == 'modified' ) {
$params['orderby'] = 'modified_asc';
}
unset( $params['order'] );
}
}
return TRUE;
}
// Sale products
public function translate_sale_products( &$name, &$params, &$content ) {
$name = 'us_grid';
$params['post_type'] = 'product';
$params['products_include'] = 'sale';
$params['items_layout'] = $this->get_products_grid();
$params['items_gap'] = $this->get_products_grid( 'gap' );
if ( isset( $params['per_page'] ) ) {
$params['items_quantity'] = $params['per_page'];
unset( $params['per_page'] );
}
if ( ! empty( $params['orderby'] ) ) {
if ( $params['orderby'] == 'title' ) {
$params['orderby'] = 'alpha';
}
if ( ! empty( $params['order'] ) AND $params['order'] == 'ASC' ) {
if ( $params['orderby'] == 'date' ) {
$params['orderby'] = 'date_asc';
} elseif ( $params['orderby'] == 'modified' ) {
$params['orderby'] = 'modified_asc';
}
unset( $params['order'] );
}
}
return TRUE;
}
// Theme Options
public function translate_theme_options( &$options ) {
$this->previous_theme_options = $options;
// Set new content templates for WooCommerce pages
if ( class_exists( 'woocommerce' ) ) {
// Check metabox settings of Shop Page
$shop_page = get_post( wc_get_page_id( 'shop' ) );
if ( $shop_page ) {
// Getting the shop page header ID from metaboxes
$shop_meta = get_post_meta( $shop_page->ID );
// Titlebar ID from metaboxes
if ( ! empty( $shop_meta['us_titlebar'][0] ) ) {
// Custom Titlebar
if ( $shop_meta['us_titlebar'][0] == 'custom' AND isset( $shop_meta['us_titlebar_id'][0] ) ) {
$options['titlebar_shop_id'] = $shop_meta['us_titlebar_id'][0];
// Hide Titlebar
} elseif ( $shop_meta['us_titlebar'][0] == 'hide' ) {
$options['titlebar_shop_id'] = '';
}
}
// Sidebar settings from metaboxes
if ( ! empty( $shop_meta['us_sidebar'][0] ) ) {
// Custom Sidebar
if ( $shop_meta['us_sidebar'][0] == 'custom' AND isset( $shop_meta['us_sidebar_id'][0] ) ) {
$options['sidebar_shop_id'] = $shop_meta['us_sidebar_id'][0];
if ( isset( $shop_meta['us_sidebar_pos'][0] ) ) {
$options['sidebar_shop_pos'] = $shop_meta['us_sidebar_pos'][0];
}
// Hide Sidebar
} elseif ( $shop_meta['us_sidebar'][0] == 'hide' ) {
$options['sidebar_shop_id'] = '';
}
}
// Footer settings from metaboxes
if ( isset( $shop_meta['us_footer'][0] ) ) {
if ( $shop_meta['us_footer'][0] == '' ) {
$shop_footer_id = '__defaults__';
} elseif ( $shop_meta['us_footer'][0] == 'hide' ) {
$shop_footer_id = '';
} else {
$shop_footer_id = isset( $shop_meta['us_footer_id'][0] ) ? $shop_meta['us_footer_id'][0] : '__defaults__';
}
} else {
$shop_footer_id = '__defaults__';
}
$options['footer_shop_id'] = $shop_footer_id;
}
// Create templates for Shop Page and Products
$this->create_shop_template( TRUE );
$this->create_shop_template();
}
// Calculate width for NEW sidebar column
$rem = intval( $options['body_fontsize'] );
$content_width = intval( $options['site_content_width'] );
$old_sidebar_width = intval( $options['sidebar_width'] );
$new_sidebar_width = 100 * ( $content_width * $old_sidebar_width / 100 + 3 * $rem ) / ( $content_width + 3 * $rem );
$options['sidebar_width'] = number_format( $new_sidebar_width, 2 );
// Force Titlebar & Sidebar option
$options['enable_sidebar_titlebar'] = TRUE;
return TRUE;
}
// Meta settings
public function translate_meta( &$meta, $post_type ) {
if ( ! empty( $meta['us_migration_version'][0] ) AND $meta['us_migration_version'][0] == '6.0' ) {
return FALSE;
}
// Header
if ( isset( $meta['us_header'][0] ) ) {
if ( $meta['us_header'][0] == '' ) {
$meta['us_header_id'][0] = '__defaults__';
} elseif ( $meta['us_header'][0] == 'hide' ) {
$meta['us_header_id'][0] = '';
}
unset( $meta['us_header'] );
} else {
$meta['us_header_id'][0] = '__defaults__';
}
// Titlebar
if ( isset( $meta['us_titlebar'][0] ) ) {
if ( $meta['us_titlebar'][0] == '' ) {
$meta['us_titlebar_id'][0] = '__defaults__';
} elseif ( $meta['us_titlebar'][0] == 'hide' ) {
$meta['us_titlebar_id'][0] = '';
}
unset( $meta['us_titlebar'] );
} else {
$meta['us_titlebar_id'][0] = '__defaults__';
}
// Content
if ( isset( $meta['us_content'][0] ) ) {
if ( $meta['us_content'][0] == '' ) {
$meta['us_content_id'][0] = '__defaults__';
} elseif ( $meta['us_content'][0] == 'hide' ) {
$meta['us_content_id'][0] = '';
}
unset( $meta['us_content'] );
} else {
$meta['us_content_id'][0] = '__defaults__';
}
// Sidebar
if ( isset( $meta['us_sidebar'][0] ) ) {
if ( $meta['us_sidebar'][0] == '' ) {
$meta['us_sidebar_id'][0] = '__defaults__';
} elseif ( $meta['us_sidebar'][0] == 'hide' ) {
$meta['us_sidebar_id'][0] = '';
}
unset( $meta['us_sidebar'] );
} else {
$meta['us_sidebar_id'][0] = '__defaults__';
$meta['us_sidebar_pos'][0] = 'right';
}
// Footer
if ( isset( $meta['us_footer'][0] ) ) {
if ( $meta['us_footer'][0] == '' ) {
$meta['us_footer_id'][0] = '__defaults__';
} elseif ( $meta['us_footer'][0] == 'hide' ) {
$meta['us_footer_id'][0] = '';
}
unset( $meta['us_footer'] );
} else {
$meta['us_footer_id'][0] = '__defaults__';
}
// Grid former ids
if ( isset( $meta['us_grid_layout_ids'][0] ) ) {
$meta['_us_in_content_ids'][0] = $meta['us_grid_layout_ids'][0];
unset( $meta['us_grid_layout_ids'] );
}
// Remove extra meta, added by 5.7 migration
if ( isset( $meta['us_special_page_type'][0] ) ) {
unset( $meta['us_special_page_type'] );
}
$meta['us_migration_version'][0] = '6.0';
return TRUE;
}
// Create Page Block for Shop & Products
private function create_shop_template( $is_shop = FALSE ) {
// Get Grid Layout & Gap which were set in former Shop options
$products_grid_layout = $this->get_products_grid();
$products_grid_gap = $this->get_products_grid( 'gap' );
// Check if it's Shop or Product
if ( $is_shop ) {
$page_block_title = 'Shop template';
$shop_page_content = '[vc_row height="auto" width="full"][vc_column][us_post_content type="full_content"][/vc_column][/vc_row]';
$content_template = '[us_hwrapper alignment="justify" valign="middle"]';
if ( in_array( 'shop_title', $this->previous_theme_options['shop_elements'] ) ) {
$content_template .= '[us_page_title tag="h1" font="h1"]';
}
$content_template .= '[us_product_ordering align="right"]';
$content_template .= '[/us_hwrapper][us_post_content type="excerpt_only"]';
$content_template .= '[us_separator size="small"]';
if ( get_option( 'woocommerce_shop_page_display', '' ) != '' ) {
$content_template .= '[us_grid post_type="taxonomy_terms" related_taxonomy="product_cat" no_items_message=""';
$content_template .= ' items_layout="' . $this->get_products_grid( '', TRUE ) . '" items_gap="' . $products_grid_gap . '"';
$content_template .= ' columns="' . $this->previous_theme_options['shop_columns'] . '"';
$content_template .= ' css=".vc_custom_1204201900001{margin-bottom: 3rem !important;}"';
$content_template .= ']';
}
$content_template .= '[us_grid post_type="current_query" pagination="regular"';
$content_template .= ' items_layout="' . $products_grid_layout . '" items_gap="' . $products_grid_gap . '"';
$content_template .= ' columns="' . $this->previous_theme_options['shop_columns'] . '"';
$content_template .= ']';
} else {
$page_block_title = 'Product template';
$shop_page_content = '';
$content_template = '[vc_row_inner][vc_column_inner width="1/2"]';
$content_template .= '[us_product_gallery][/vc_column_inner]';
$content_template .= '[vc_column_inner width="1/2"]';
$content_template .= '[us_product_field type="sale_badge" font_size="13px" font_weight="700" text_transform="uppercase" css=".vc_custom_1204201900002{margin-bottom: 1rem !important;padding-right: 0.8rem !important;padding-left: 0.8rem !important;border-radius: 35px !important;}"]';
// Breadcrumbs
if ( in_array( 'breadcrumbs', $this->previous_theme_options['shop_elements'] ) ) {
$content_template .= '[us_breadcrumbs show_current="1" font_size="0.9rem" separator_type="custom" css=".vc_custom_1204201900003{margin-bottom: 0.6rem !important;}"]';
}
// Title
if ( in_array( 'product_title', $this->previous_theme_options['shop_elements'] ) ) {
$content_template .= '[us_post_title tag="h1" font="h1" css=".vc_custom_1204201900004{margin-bottom: 0.5rem !important;padding-top: 0px !important;}"]';
}
$content_template .= '[us_hwrapper valign="middle" wrap="1" css=".vc_custom_1204201900005{margin-bottom: 1rem !important;}"][us_product_field type="rating"][us_post_comments layout="amount" hide_zero="1" color_link="" font_size="0.9rem"][/us_hwrapper]';
$content_template .= '[us_product_field font_weight="600" font_size="1.6rem" css=".vc_custom_1204201900006{margin-bottom: 1.5rem !important;}"][us_post_content type="excerpt_only"][us_separator size="small"][us_add_to_cart][us_separator size="small"]';
$content_template .= '[us_product_field type="sku" font_size="0.9rem"][us_post_taxonomy taxonomy_name="product_cat" color_link="" text_before="' . us_translate( 'Category', 'woocommerce' ) . ':" font_size="0.9rem"][us_post_taxonomy taxonomy_name="product_tag" color_link="" text_before="' . us_translate( 'Tags', 'woocommerce' ) . ':" font_size="0.9rem"]';
$content_template .= '[/vc_column_inner][/vc_row_inner]';
$content_template .= '[us_separator]';
// Tabs for product
$content_template .= '[vc_tta_tabs][vc_tta_section title="' . us_translate( 'Description', 'woocommerce' ) . '" tab_id="description"][us_post_content type="full_content"][/vc_tta_section]';
$content_template .= '[vc_tta_section title="' . us_translate( 'Additional information', 'woocommerce' ) . '" tab_id="info"][us_product_field type="weight"][us_product_field type="dimensions"][us_product_field type="pa_color"][/vc_tta_section]';
$content_template .= '[vc_tta_section title="' . us_translate( 'Reviews', 'woocommerce' ) . ' ({{comment_count}})" tab_id="reviews"][us_post_comments][/vc_tta_section][/vc_tta_tabs]';
// Upsells
$content_template .= '[us_separator show_line="1"]';
$content_template .= '[vc_column_text]<h4>' . us_translate( 'You may also like&hellip;', 'woocommerce' ) . '</h4>[/vc_column_text]';
$content_template .= '[us_separator size="small"]';
$content_template .= '[us_grid post_type="product_upsells" no_items_message=""';
$content_template .= ' items_quantity="' . $this->previous_theme_options['product_related_qty'] . '"';
$content_template .= ' columns="' . $this->previous_theme_options['product_related_qty'] . '"';
$content_template .= ' items_layout="' . $products_grid_layout . '" items_gap="' . $products_grid_gap . '"';
$content_template .= ']';
// Related products
$content_template .= '[us_separator show_line="1"]';
$content_template .= '[vc_column_text]<h4>' . us_translate( 'Related products', 'woocommerce' ) . '</h4>[/vc_column_text]';
$content_template .= '[us_separator size="small"]';
$content_template .= '[us_grid post_type="related" related_taxonomy="product_cat" no_items_message=""';
$content_template .= ' items_quantity="' . $this->previous_theme_options['product_related_qty'] . '"';
$content_template .= ' columns="' . $this->previous_theme_options['product_related_qty'] . '"';
$content_template .= ' items_layout="' . $products_grid_layout . '" items_gap="' . $products_grid_gap . '"';
$content_template .= ']';
$content_template .= '[us_separator size="large"]';
}
// Combine content
$page_block_content = $shop_page_content . '[vc_row][vc_column]' . $content_template . '[/vc_column][/vc_row]';
$content_hash = md5( $page_block_content );
// Check for existing page block with same content
global $wpdb;
$existing_posts_results = $wpdb->get_results(
$wpdb->prepare( "SELECT post_id FROM {$wpdb->postmeta} WHERE meta_key = %s AND meta_value = %s", 'us_migration_content_hash', $content_hash )
);
if ( count( $existing_posts_results ) > 0 ) {
$existing_post = $existing_posts_results[0];
return TRUE;
}
// Create Page Block and return its ID
ob_start();
$page_block_id = wp_insert_post(
array(
'post_type' => 'us_page_block',
'post_date' => date( 'Y-m-d H:i', time() - 86400 ),
'post_status' => 'publish',
'post_title' => $page_block_title,
'post_content' => $page_block_content,
)
);
add_post_meta( $page_block_id, 'us_migration_content_hash', $content_hash );
if ( $is_shop ) {
add_post_meta( $page_block_id, 'us_migration_6_for', 'shop' );
} else {
add_post_meta( $page_block_id, 'us_migration_6_for', 'product' );
}
ob_end_clean();
return TRUE;
}
}
@@ -0,0 +1,20 @@
<?php
class us_migration_6_0_4 extends US_Migration_Translator {
// Theme Options
public function translate_theme_options( &$options ) {
// old string from migration_5_6
$text_fix_56_css = ".wpb_text_column:not(:last-child) { margin-bottom: 1.5rem; } /* migration 5.6 fix */ \n";
if ( strpos( $options['custom_css'], $text_fix_56_css ) !== FALSE ) {
$options['custom_css'] = str_replace( $text_fix_56_css, '', $options['custom_css'] );
} else {
$options['text_bottom_indent'] = '0rem';
}
return TRUE;
}
}