예제 #1
0
/**
 * 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()) {
        // Stash the options from the previous version of the theme for later use
        $previous_options = largo_preserve_previous_options();
        if (!isset($previous_options['largo_version'])) {
            $previous_options['largo_version'] = null;
        }
        // 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($previous_options['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_replace_deprecated_widgets();
        largo_check_deprecated_widgets();
        // Set version.
        of_set_option('largo_version', largo_version());
    }
    return true;
}
예제 #2
0
 function test_largo_replace_deprecated_widgets()
 {
     // First, create some deprecated widgets
     largo_instantiate_widget('largo-sidebar-featured', array('title' => 'Foo'), 'sidebar-single');
     largo_instantiate_widget('largo-footer-featured', array('title' => 'Bar'), 'footer-1');
     largo_instantiate_widget('largo-featured', array('title' => 'Baz'), 'sidebar-main');
     largo_instantiate_widget('largo-follow', array('title' => 'Baz'), 'homepage-alert');
     largo_instantiate_widget('largo-recent-posts', array('title' => 'Baz'), 'homepage-alert');
     // chek that things were set up correctly
     $this->assertTrue(largo_widget_in_region('largo-sidebar-featured', 'sidebar-single'), "The Largo Sidebar Featured widget was left in the Sidebar Single widget area.");
     $this->assertTrue(largo_widget_in_region('largo-footer-featured', 'footer-1'), "The Largo Footer Featured widget was left in the Footer 1 widget area.");
     $this->assertTrue(largo_widget_in_region('largo-featured', 'sidebar-main'), "Setup: The old Largo Featured widget was not created in the Sidebar Main widget area.");
     $this->assertTrue(largo_widget_in_region('largo-follow', 'homepage-alert'), "Setup: The Largo Follow widget was not created in the Homepage Alert widget area.");
     $this->assertTrue(largo_widget_in_region('largo-recent-posts', 'homepage-alert'), "Setup: The Largo Recent Posts was not created in the Homepage Alert widget area.");
     // Run the actual updates
     largo_replace_deprecated_widgets();
     // This array is currently unused.
     $updates = array('largo-sidebar-featured' => array('name' => 'largo-recent-posts', 'count' => 0), 'largo-sidebar-featured' => array('name' => 'largo-recent-posts', 'count' => 0), 'largo-featured' => array('name' => 'largo-recent-posts', 'count' => 0));
     // You will want to check this later;
     $this->assertFalse(largo_widget_in_region('largo-sidebar-featured', 'sidebar-single'), "The Largo Sidebar Featured widget was left in the Sidebar Single widget area.");
     $this->assertFalse(largo_widget_in_region('largo-footer-featured', 'footer-1'), "The Largo Footer Featured widget was left in the Footer 1 widget area.");
     $this->assertTrue(largo_widget_in_region('largo-recent-posts', 'sidebar-single'), "The new Largo Featured widget was not found in the Sidebar Single widget area.");
     $this->assertTrue(largo_widget_in_region('largo-recent-posts', 'footer-1'), "The new Largo Featured widget was not found in the Footer 1 widget area.");
     $this->assertTrue(largo_widget_in_region('largo-recent-posts', 'sidebar-main'), "The old Largo Featured widget was not found in the Sidebar Main widget area.");
     $this->assertTrue(largo_widget_in_region('largo-follow', 'homepage-alert'), "The Largo Follow widget was not found in the Homepage Alert widget area.");
     $this->assertTrue(largo_widget_in_region('largo-recent-posts', 'homepage-alert'), "The old Largo Featured widget was not found in the Homepage Alert widget area.");
 }