Skip to content

Commit

Permalink
Rearranged some of the logic when updating from legacy options
Browse files Browse the repository at this point in the history
  • Loading branch information
aprea committed May 22, 2014
1 parent ee3c176 commit 53930af
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions class/advanced-excerpt.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ function load_options() {
* the option storage to the new method (all options stored in a single row in the DB as an array)
*/
$update_options = false;
$update_from_legacy = false;
if ( false !== get_option( 'advancedexcerpt_length' ) ) {
$legacy_options = array( 'length', 'use_words', 'no_custom', 'no_shortcode', 'finish_word', 'finish_sentence', 'ellipsis', 'read_more', 'add_link', 'allowed_tags' );

Expand All @@ -119,19 +120,12 @@ function load_options() {
delete_option( $option_name );
}

// convert legacy option '_all' in the allowed_tags option to it's updated equivalent
if ( false !== ( $all_key = array_search( '_all', $this->options['allowed_tags'] ) ) ) {
unset( $this->options['allowed_tags'][$all_key] );
$this->options['allowed_tags_option'] = 'dont_remove_any';
} else {
$this->options['allowed_tags_option'] = 'remove_all_tags_except';
}

// filtering the_content() is disabled by default when migrating from version 4.1.1 of the plugin
$this->options['the_excerpt'] = 1;
$this->options['the_content'] = 0;

$update_options = true;
$update_from_legacy = true;
} else {
$this->options = get_option( 'advanced_excerpt' );
}
Expand Down Expand Up @@ -159,6 +153,16 @@ function load_options() {
$update_options = true;
}

// convert legacy option '_all' in the allowed_tags option to it's updated equivalent
if ( isset( $this->options['allowed_tags'] ) ) {
if ( false !== ( $all_key = array_search( '_all', $this->options['allowed_tags'] ) ) ) {
unset( $this->options['allowed_tags'][$all_key] );
$this->options['allowed_tags_option'] = 'dont_remove_any';
} elseif( $update_from_legacy ) {
$this->options['allowed_tags_option'] = 'remove_all_tags_except';
}
}

// if no options exist then this is a fresh install, set up some default options
if ( empty( $this->options ) ) {
$this->options = $this->default_options;
Expand Down

0 comments on commit 53930af

Please sign in to comment.