! empty( $defaults['head'] ) ? $defaults['head'] : '', 'body' => ! empty( $defaults['body'] ) ? $defaults['body'] : '', 'footer' => ! empty( $defaults['footer'] ) ? $defaults['footer'] : '', 'do_shortcode' => ! empty( $defaults['do_shortcode'] ) ? $defaults['do_shortcode'] : 'n', ); update_option( 'auhfc_settings_sitewide', $sitewide ); $homepage = array( 'head' => ! empty( $defaults['homepage_head'] ) ? $defaults['homepage_head'] : '', 'body' => ! empty( $defaults['homepage_body'] ) ? $defaults['homepage_body'] : '', 'footer' => ! empty( $defaults['homepage_footer'] ) ? $defaults['homepage_footer'] : '', 'behavior' => ! empty( $defaults['homepage_behavior'] ) ? $defaults['homepage_behavior'] : 'append', ); update_option( 'auhfc_settings_homepage', $homepage ); $article = array( 'post_types' => ! empty( $defaults['post_types'] ) ? $defaults['post_types'] : array(), ); update_option( 'auhfc_settings_article', $article ); // Now delete old single option. delete_option( 'auhfc_settings' ); } /** * Fix PHP Warning: in_array() expects parameter 2 to be array, null given in head-footer-code/inc/front.php on line 46, 111, and 176 */ function auhfc_update_6() { $article = get_option( 'auhfc_settings_article' ); if ( ! is_array( $article ) ) { return; } if ( is_null( $article['post_types'] ) ) { $article['post_types'] = array(); update_option( 'auhfc_settings_article', $article ); } } /** * Do Shortcode per location */ function auhfc_update_7() { // Get options from DB. $sitewide = get_option( 'auhfc_settings_sitewide' ); if ( ! is_array( $sitewide ) ) { return; } if ( ! empty( $sitewide['do_shortcode'] ) ) { $sitewide['do_shortcode_h'] = 'n'; $sitewide['do_shortcode_b'] = 'n'; $sitewide['do_shortcode_f'] = $sitewide['do_shortcode']; } else { $sitewide['do_shortcode_h'] = 'n'; $sitewide['do_shortcode_b'] = 'n'; $sitewide['do_shortcode_f'] = 'n'; } unset( $sitewide['do_shortcode'] ); update_option( 'auhfc_settings_sitewide', $sitewide ); } /** * Add or not homepage in Blog Post mode on paged pages */ function auhfc_update_8() { // Get options from DB. $homepage = get_option( 'auhfc_settings_homepage' ); if ( ! is_array( $homepage ) ) { return; } if ( empty( $homepage['paged'] ) ) { $homepage['paged'] = 'yes'; } update_option( 'auhfc_settings_homepage', $homepage ); } /** * Add option to allow unprivileged user roles to manage article-specific HFC */ function auhfc_update_9() { // Get options from DB. $homepage = get_option( 'auhfc_settings_homepage' ); if ( ! is_array( $homepage ) ) { return; } if ( empty( $homepage['allowed_roles'] ) ) { $homepage['allowed_roles'] = array(); } update_option( 'auhfc_settings_homepage', $homepage ); } /** * Migration for v. 1.5.3 * Clean up double slashes from existing meta data caused by previous double-slashing. * Processes 500 records at a time and stays on DB version 9 until * all records are cleaned to prevent timeouts and memory exhaustion. */ function auhfc_update_10() { global $wpdb; $meta_key = '_auhfc'; $batch_size = 500; $has_more = false; /** * Strip slashes from Post Metas when actually contain backslashes (\\) in meta_value. */ $post_metas = $wpdb->get_results( $wpdb->prepare( "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value LIKE %s LIMIT %d", $meta_key, '%' . $wpdb->esc_like( '\\' ) . '%', $batch_size ) ); if ( ! empty( $post_metas ) ) { $has_more = true; foreach ( $post_metas as $meta ) { $original_data = maybe_unserialize( $meta->meta_value ); if ( is_array( $original_data ) ) { $cleaned_data = stripslashes_deep( $original_data ); if ( $cleaned_data !== $original_data ) { update_post_meta( $meta->post_id, $meta_key, wp_slash( $cleaned_data ) ); } } } } /** * Strip slashes from Taxonomies (Terms) within available batch capacity. */ if ( count( $post_metas ) < $batch_size ) { $term_metas = $wpdb->get_results( $wpdb->prepare( "SELECT term_id, meta_value FROM $wpdb->termmeta WHERE meta_key = %s AND meta_value LIKE %s LIMIT %d", $meta_key, '%' . $wpdb->esc_like( '\\' ) . '%', $batch_size - count( $post_metas ) ) ); if ( ! empty( $term_metas ) ) { $has_more = true; foreach ( $term_metas as $meta ) { $original_data = maybe_unserialize( $meta->meta_value ); if ( is_array( $original_data ) ) { $cleaned_data = stripslashes_deep( $original_data ); if ( $cleaned_data !== $original_data ) { update_term_meta( $meta->term_id, $meta_key, wp_slash( $cleaned_data ) ); } } } } } /** * Revert DB versin if there is more work in batches so * Main::plugins_loaded() triggers this function agaiuntil completion. */ if ( $has_more ) { update_option( 'auhfc_db_ver', 9 ); } } /** * Migration for v. 1.5.4 * Add support for taxonomies and pre-select 'category'. */ function auhfc_update_11() { // Get options from DB. $article = get_option( 'auhfc_settings_article' ); if ( ! is_array( $article ) ) { return; } if ( empty( $article['taxonomies'] ) ) { $article['taxonomies'] = array( 'category' ); } update_option( 'auhfc_settings_article', $article ); }