/** * Performs various update functions and set a new verion number. * * This acts as a main() for applying database updates when the update ajax is * called. * * @since 0.3 */ function largo_perform_update() { if (largo_need_updates()) { // this must run before any other function that makes use of of_set_option() largo_set_new_option_defaults(); // Run when updating from pre-0.4 if (version_compare(of_get_option('largo_version'), '0.4') < 0) { largo_home_transition(); largo_update_widgets(); largo_transition_nav_menus(); largo_update_prominence_term_descriptions(); largo_force_settings_update(); largo_enable_if_series(); largo_enable_series_if_landing_page(); } // Repeatable, should be run when updating to 0.4+ largo_remove_topstory_prominence_term(); // Always run largo_update_custom_less_variables(); largo_check_deprecated_widgets(); // Set version. of_set_option('largo_version', largo_version()); } return true; }
function test_largo_update_widgets() { // Backup sidebar widgets, create our own empty sidebar $widgets_backup = get_option('sidebars_widgets'); update_option('sidebars_widgets', array('article-bottom' => array())); // These should all trigger a widget addition. update_option(get_option('stylesheet'), $this->previous_options); largo_preserve_previous_options(); largo_update_widgets(); // Check for expected output // These are all #2 because they are the first instance of the widget $widgets = get_option('sidebars_widgets'); $this->assertEquals('largo-follow-widget-2', $widgets['article-bottom'][0]); $this->assertEquals('largo-post-series-links-widget-2', $widgets['article-bottom'][1]); $this->assertEquals('largo-tag-list-widget-2', $widgets['article-bottom'][2]); $this->assertEquals('largo-author-widget-2', $widgets['article-bottom'][3]); $this->assertEquals('largo-explore-related-widget-2', $widgets['article-bottom'][4]); $this->assertEquals('largo-prev-next-post-links-widget-2', $widgets['article-bottom'][5]); // Cleanup delete_option('sidebars_widgets'); update_option('sidebars_widgets', $widgets_backup); }
function test_largo_update_widgets() { // uses largo_widget_in_region // uses largo_instantiate_widget // Backup sidebar widgets, create our own empty sidebar $widgets_backup = get_option('sidebars_widgets '); update_option('sidebars_widgets', array('article-bottom' => array())); // These should all trigger a widget addition. of_set_option('social_icons_display', 'both'); of_set_option('in_series', NULL); of_set_option('show_tags', 1); of_set_option('show_author_box', 1); of_set_option('show_related_content', 1); of_set_option('show_next_prev_nav_single', 1); largo_update_widgets(); // Check for expected output // These are all #2 because they are the first instance of the widget $widgets = get_option('sidebars_widgets'); $this->assertEquals('largo-follow-widget-2', $widgets['article-bottom'][0]); $this->assertEquals('largo-post-series-links-widget-2', $widgets['article-bottom'][1]); $this->assertEquals('largo-tag-list-widget-2', $widgets['article-bottom'][2]); $this->assertEquals('largo-author-bio-widget-2', $widgets['article-bottom'][3]); $this->assertEquals('largo-explore-related-widget-2', $widgets['article-bottom'][4]); $this->assertEquals('largo-prev-next-post-links-widget-2', $widgets['article-bottom'][5]); // Cleanup of_reset_options(); delete_option('sidebars_widgets'); update_option('sidebars_widgets', $widgets_backup); unset($widgets_backup); }