'twitter', 'name' => 'Twitter', 'title' => sprintf( __( 'Follow %s on Twitter', 'graphene' ), get_bloginfo( 'name' ) ), 'url' => $graphene_settings['twitter_url'] ); unset( $graphene_settings['twitter_url'] ); } // Add the Facebook url if the url is set if ( !empty( $graphene_settings['facebook_url'] ) ) { $graphene_settings['social_profiles'][] = array ( 'type' => 'facebook', 'name' => 'Facebook', 'title' => sprintf( __( "Visit %s's Facebook page", 'graphene' ), get_bloginfo( 'name' ) ), 'url' => $graphene_settings['facebook_url'] ); unset( $graphene_settings['facebook_url'] ); } // Convert the custom social media to social media of "Custom" type $social_media = $graphene_settings['social_media']; if ( ! empty( $social_media ) ){ foreach ( $social_media as $slug => $social_medium ){ $graphene_settings['social_profiles'][] = array( 'type' => 'custom', 'name' => 'Custom', 'title' => $social_medium['title'], 'url' => $social_medium['url'], 'icon_url' => $social_medium['icon'], ); } } // If there is no social media (including RSS), set the setting to false if ( empty( $graphene_settings['social_profiles'] ) ) $graphene_settings['social_profiles'] = array( 0 => false ); /* Merge current settings with the default settings */ $graphene_settings = array_merge($graphene_defaults, $graphene_settings); /* Only save options that have different values than the default values */ foreach ( $graphene_settings as $key => $value ){ if ( ( $graphene_defaults[$key] === $value || $value === '' ) && $key != 'db_version' ) { unset( $graphene_settings[$key] ); } } update_option('graphene_settings', $graphene_settings); } function graphene_update_db_to_1_2(){ $graphene_settings = get_option( 'graphene_settings', array() ); $graphene_settings['db_version'] = '1.2'; /* because the column modus have been renamed we need to update the DB! */ if ( isset( $graphene_settings['column_mode'] ) ) { $graphene_settings['column_mode'] = str_replace( '-', '_', $graphene_settings['column_mode'] ); } if ( isset( $graphene_settings['bbp_column_mode'] ) ) { $graphene_settings['bbp_column_mode'] = str_replace( '-', '_', $graphene_settings['bbp_column_mode'] ); } if ( isset( $graphene_settings['column_width'] ) && is_array( $graphene_settings['column_width'] ) ) { $two_col = $graphene_settings['column_width']['two-col']; $three_col = $graphene_settings['column_width']['three-col']; $graphene_settings['column_width'] = array( 'two_col' => $two_col, 'three_col' => $three_col ); } update_option('graphene_settings', $graphene_settings); } /** * Migrate options from previous versions */ function graphene_update_db_to_1_3(){ global $graphene_defaults; $graphene_settings = get_option( 'graphene_settings', array() ); update_option( 'graphene_legacy_settings', $graphene_settings ); $graphene_settings['db_version'] = '1.3'; /* Migrate our custom CSS option to WordPress native custom CSS feature */ if ( isset( $graphene_settings['custom_css'] ) ) { $theme = wp_get_theme(); $css = wp_get_custom_css( $theme->stylesheet ); $css .= PHP_EOL . $graphene_settings['custom_css']; wp_update_custom_css_post( $css ); } /* Migrate option for infinite scroll method */ if ( isset( $graphene_settings['inf_scroll_click'] ) ) { $graphene_settings['inf_scroll_method'] = 'click'; } /* Convert option for homepage panes post type */ if ( isset( $graphene_settings['show_post_type'] ) && $graphene_settings['show_post_type'] == 'cat-latest-posts' ) { $graphene_settings['show_post_type'] = 'latest-posts'; } /* Migrate options with modified field name */ $field_map = array( 'top_bar_top_bg' => 'top_bar_bg', 'menu_primary_top_bg' => 'menu_primary_bg', 'menu_primary_active_top_bg' => 'menu_primary_active_bg', 'menu_sec_dd_top_bg' => 'menu_sec_dd_bg', 'bg_content_wrapper' => 'content_wrapper_bg', 'bg_content' => 'content_bg', 'bg_meta_border' => 'meta_border', 'bg_sticky_content' => 'sticky_border', 'bg_child_page_content' => 'child_page_content_bg', 'bg_widget_item' => 'widget_item_bg', 'bg_widget_list' => 'widget_list', 'bg_widget_header_border' => 'widget_header_border', 'bg_button' => 'button_bg', 'bg_button_label' => 'button_label', 'bg_archive_left' => 'archive_bg', 'bg_archive_label' => 'archive_label', 'bg_archive_text' => 'archive_text', 'bg_comments' => 'comments_bg', 'bg_author_comments_border' => 'author_comments_border', ); foreach ( $field_map as $old_field => $new_field ){ if ( isset( $graphene_settings[$old_field] ) ) { $graphene_settings[$new_field] = $graphene_settings[$old_field]; unset( $graphene_settings[$old_field] ); } } /* Remove values for options that are no longer available */ foreach ( $graphene_settings as $key => $value ){ if ( ! array_key_exists( $key, $graphene_defaults ) ) unset( $graphene_settings[$key] ); elseif ( ( $graphene_defaults[$key] === $value || $value === '' ) && $key != 'db_version' ) { unset( $graphene_settings[$key] ); } } /* Convert the column width settings */ if ( isset( $graphene_settings['container_width'] ) && $graphene_settings['container_width'] <= $graphene_defaults['container_width'] ) unset( $graphene_settings['container_width'] ); if ( isset( $graphene_settings['grid_width'] ) ) unset( $graphene_settings['grid_width'] ); if ( isset( $graphene_settings['gutter_width'] ) ) unset( $graphene_settings['gutter_width'] ); if ( isset( $graphene_settings['column_width'] ) ) { foreach ( $graphene_settings['column_width'] as $column_mode => $cols_width ) { $total_width = array_sum( $cols_width ); foreach ( $cols_width as $col => $col_width ) { $graphene_settings['column_width'][$column_mode][$col] = round( $col_width / $total_width * 12 ); } } } update_option( 'graphene_settings', $graphene_settings ); } /** * This DB update converts the theme's custom fields into a single database entry for each posts and pages */ function graphene_convert_meta( $post_id ){ /* Do the conversion */ $custom_fields = graphene_custom_fields_defaults(); $graphene_meta = array(); foreach ( $custom_fields as $custom_field => $default_val ) { $current_value = get_post_meta( $post_id, '_graphene_' . $custom_field, true ); if ( $current_value !== false ) { if ( $default_val !== $current_value && $current_value != 'global' ) $graphene_meta[$custom_field] = $current_value; delete_post_meta( $post_id, '_graphene_' . $custom_field ); } } if ( $graphene_meta ) update_post_meta( $post_id, '_graphene_meta', $graphene_meta ); }