/** * Migrate old styling settings. If sites are using the old * default 400px field width, switch it to 100% * * @since 2.0.4 */ private function migrate_to_25() { // get the style that was created with the style migration $frm_style = new FrmStyle(); $styles = $frm_style->get_all('post_date', 'ASC', 1); if (empty($styles)) { return; } foreach ($styles as $style) { if ($style->post_content['field_width'] == '400px') { $style->post_content['field_width'] = '100%'; $frm_style->save((array) $style); return; } } }
/** * Migrate style to custom post type */ private static function migrate_to_27() { $new_post = array('post_type' => FrmStylesController::$post_type, 'post_title' => __('Formidable Style', 'formidable'), 'post_status' => 'publish', 'post_content' => array(), 'menu_order' => 1); $exists = get_posts(array('post_type' => $new_post['post_type'], 'post_status' => $new_post['post_status'], 'numberposts' => 1)); if ($exists) { $new_post['ID'] = reset($exists)->ID; } $frmpro_settings = get_option('frmpro_options'); // If unserializing didn't work if (!is_object($frmpro_settings)) { if ($frmpro_settings) { //workaround for W3 total cache conflict $frmpro_settings = unserialize(serialize($frmpro_settings)); } } if (!is_object($frmpro_settings)) { return; } $frm_style = new FrmStyle(); $default_styles = $frm_style->get_defaults(); foreach ($default_styles as $setting => $default) { if (isset($frmpro_settings->{$setting})) { $new_post['post_content'][$setting] = $frmpro_settings->{$setting}; } } $frm_style->save($new_post); }