function doInitialUpgrade() {
		$_option = $this->getSlug();
		$options = get_option( 'pressbooks_theme_options_' . $_option, $this->defaults );

		// Replace pdf_page_size with pdf_page_width and pdf_page_height
		if ( isset( $options['pdf_page_size'] ) ) {
			switch ( $options['pdf_page_size'] ) {
				case 1:
					$options['pdf_page_width'] = '5.5in';
					$options['pdf_page_height'] = '8.5in';
					break;
				case 2:
					$options['pdf_page_width'] = '6in';
					$options['pdf_page_height'] = '9in';
					break;
				case 3:
					$options['pdf_page_width'] = '8.5in';
					$options['pdf_page_height'] = '11in';
					break;
				case 4:
					$options['pdf_page_width'] = '8.5in';
					$options['pdf_page_height'] = '9.25in';
					break;
				case 5:
					$options['pdf_page_width'] = '5in';
					$options['pdf_page_height'] = '7.75in';
					break;
				case 6:
					$options['pdf_page_width'] = '4.25in';
					$options['pdf_page_height'] = '7in';
					break;
				case 7:
					$options['pdf_page_width'] = '21cm';
					$options['pdf_page_height'] = '29.7cm';
					break;
				case 8:
					$options['pdf_page_width'] = '14.8cm';
					$options['pdf_page_height'] = '21cm';
					break;
				case 9:
					$options['pdf_page_width'] = '5in';
					$options['pdf_page_height'] = '8in';
					break;
				default:
					$options['pdf_page_width'] = '5.5in';
					$options['pdf_page_height'] = '8.5in';
			}
			unset( $options['pdf_page_size'] );
		}

		// Substitute human-readable values
		if ( ! isset( $options['pdf_paragraph_separation'] ) || 1 === absint( $options['pdf_paragraph_separation'] ) ) {
			$options['pdf_paragraph_separation'] = 'indent';
		} elseif ( 2 === absint( $options['pdf_paragraph_separation'] ) ) {
			$options['pdf_paragraph_separation'] = 'skiplines';
		}

		if ( ! isset( $options['pdf_blankpages'] ) || 1 === absint( $options['pdf_blankpages'] ) ) {
			$options['pdf_blankpages'] = 'include';
		} elseif ( 2 === absint( $options['pdf_blankpages'] ) ) {
			$options['pdf_blankpages'] = 'remove';
		}

		if ( ! isset( $options['pdf_footnotes_style'] ) || 1 === absint( $options['pdf_footnotes_style'] ) ) {
			$options['pdf_footnotes_style'] = 'footnotes';
		} elseif ( 2 === absint( $options['pdf_footnotes_style'] ) ) {
			$options['pdf_footnotes_style'] = 'endnotes';
		}

		// Add missing defaults.
		foreach ( $this->defaults as $key => $value ) {
			if ( ! isset( $options[ $key ] ) ) {
				$options[ $key ] = $value;
			}
		}

		update_option( 'pressbooks_theme_options_' . $_option, $options );
	}
function doInitialUpgrade() {
		$_option = $this->getSlug();
		$options = get_option( 'pressbooks_theme_options_' . $_option, $this->defaults );

		// Replace pdf_page_size with pdf_page_width and pdf_page_height
		if ( isset( $options['pdf_page_size'] ) ) {
			switch ( $options['pdf_page_size'] ) {
				case 1:
					$options['pdf_page_width'] = '5.5in';
					$options['pdf_page_height'] = '8.5in';
					break;
				case 2:
					$options['pdf_page_width'] = '6in';
					$options['pdf_page_height'] = '9in';
					break;
				case 3:
					$options['pdf_page_width'] = '8.5in';
					$options['pdf_page_height'] = '11in';
					break;
				case 4:
					$options['pdf_page_width'] = '8.5in';
					$options['pdf_page_height'] = '9.25in';
					break;
				case 5:
					$options['pdf_page_width'] = '5in';
					$options['pdf_page_height'] = '7.75in';
					break;
				case 6:
					$options['pdf_page_width'] = '4.25in';
					$options['pdf_page_height'] = '7in';
					break;
				case 7:
					$options['pdf_page_width'] = '21cm';
					$options['pdf_page_height'] = '29.7cm';
					break;
				case 8:
					$options['pdf_page_width'] = '14.8cm';
					$options['pdf_page_height'] = '21cm';
					break;
				case 9:
					$options['pdf_page_width'] = '5in';
					$options['pdf_page_height'] = '8in';
					break;
				default:
					$options['pdf_page_width'] = '5.5in';
					$options['pdf_page_height'] = '8.5in';
			}
			unset( $options['pdf_page_size'] );
		}

		// Substitute human-readable values
		if ( ! isset( $options['pdf_paragraph_separation'] ) || 1 === absint( $options['pdf_paragraph_separation'] ) ) {
			$options['pdf_paragraph_separation'] = 'indent';
		} elseif ( 2 === absint( $options['pdf_paragraph_separation'] ) ) {
			$options['pdf_paragraph_separation'] = 'skiplines';
		}

		if ( ! isset( $options['pdf_blankpages'] ) || 1 === absint( $options['pdf_blankpages'] ) ) {
			$options['pdf_blankpages'] = 'include';
		} elseif ( 2 === absint( $options['pdf_blankpages'] ) ) {
			$options['pdf_blankpages'] = 'remove';
		}

		if ( ! isset( $options['pdf_footnotes_style'] ) || 1 === absint( $options['pdf_footnotes_style'] ) ) {
			$options['pdf_footnotes_style'] = 'footnotes';
		} elseif ( 2 === absint( $options['pdf_footnotes_style'] ) ) {
			$options['pdf_footnotes_style'] = 'endnotes';
		}

		// Add missing defaults.
		foreach ( $this->defaults as $key => $value ) {
			if ( ! isset( $options[ $key ] ) ) {
				$options[ $key ] = $value;
			}
		}

		update_option( 'pressbooks_theme_options_' . $_option, $options );
	}
function doInitialUpgrade ( ) { $ _option = $ this -> getSlug ( ) ; $ options = get_option ( 'pressbooks_theme_options_' . $ _option , $ this -> defaults ) ; // Replace pdf_page_size with pdf_page_width and pdf_page_height if ( isset ( $ options [ 'pdf_page_size' ] ) ) { switch ( $ options [ 'pdf_page_size' ] ) { case 1 : $ options [ 'pdf_page_width' ] = '5.5in' ; $ options [ 'pdf_page_height' ] = '8.5in' ; break ; case 2 : $ options [ 'pdf_page_width' ] = '6in' ; $ options [ 'pdf_page_height' ] = '9in' ; break ; case 3 : $ options [ 'pdf_page_width' ] = '8.5in' ; $ options [ 'pdf_page_height' ] = '11in' ; break ; case 4 : $ options [ 'pdf_page_width' ] = '8.5in' ; $ options [ 'pdf_page_height' ] = '9.25in' ; break ; case 5 : $ options [ 'pdf_page_width' ] = '5in' ; $ options [ 'pdf_page_height' ] = '7.75in' ; break ; case 6 : $ options [ 'pdf_page_width' ] = '4.25in' ; $ options [ 'pdf_page_height' ] = '7in' ; break ; case 7 : $ options [ 'pdf_page_width' ] = '21cm' ; $ options [ 'pdf_page_height' ] = '29.7cm' ; break ; case 8 : $ options [ 'pdf_page_width' ] = '14.8cm' ; $ options [ 'pdf_page_height' ] = '21cm' ; break ; case 9 : $ options [ 'pdf_page_width' ] = '5in' ; $ options [ 'pdf_page_height' ] = '8in' ; break ; default : $ options [ 'pdf_page_width' ] = '5.5in' ; $ options [ 'pdf_page_height' ] = '8.5in' ; } unset ( $ options [ 'pdf_page_size' ] ) ; } // Substitute human-readable values if ( ! isset ( $ options [ 'pdf_paragraph_separation' ] ) || 1 === absint ( $ options [ 'pdf_paragraph_separation' ] ) ) { $ options [ 'pdf_paragraph_separation' ] = 'indent' ; } elseif ( 2 === absint ( $ options [ 'pdf_paragraph_separation' ] ) ) { $ options [ 'pdf_paragraph_separation' ] = 'skiplines' ; } if ( ! isset ( $ options [ 'pdf_blankpages' ] ) || 1 === absint ( $ options [ 'pdf_blankpages' ] ) ) { $ options [ 'pdf_blankpages' ] = 'include' ; } elseif ( 2 === absint ( $ options [ 'pdf_blankpages' ] ) ) { $ options [ 'pdf_blankpages' ] = 'remove' ; } if ( ! isset ( $ options [ 'pdf_footnotes_style' ] ) || 1 === absint ( $ options [ 'pdf_footnotes_style' ] ) ) { $ options [ 'pdf_footnotes_style' ] = 'footnotes' ; } elseif ( 2 === absint ( $ options [ 'pdf_footnotes_style' ] ) ) { $ options [ 'pdf_footnotes_style' ] = 'endnotes' ; } // Add missing defaults. foreach ( $ this -> defaults as $ key => $ value ) { if ( ! isset ( $ options [ $ key ] ) ) { $ options [ $ key ] = $ value ; } } update_option ( 'pressbooks_theme_options_' . $ _option , $ options ) ; }
Substitute human-readable values, add new defaults, replace pdf_page_size
with pdf_page_width and pdf_page_height.
Substitute human - readable values add new defaults replace pdf_page_size with pdf_page_width and pdf_page_height .