'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); } /** * 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 ); }