示例#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()) {
        // 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;
}
示例#2
0
 function test_largo_transition_nav_menus()
 {
     // Test the function's ability to create the Main Navigation nav menu
     $this->assertFalse(wp_get_nav_menu_object('Main Navigation'));
     largo_transition_nav_menus();
     $this->assertObjectHasAttribute('name', wp_get_nav_menu_object('Main Navigation'));
     // Let's create some menus and menu items to be transitioned:
     $locations = get_nav_menu_locations();
     $navs = array('Navbar Categories' => 'navbar-categories', 'Navbar Supplemental' => 'navbar-supplemental', 'Sticky Nav' => 'sticky-nav');
     foreach ($navs as $nav_title => $nav_slug) {
         // create the menu
         $id = wp_create_nav_menu($nav_title);
         $locations[$nav_slug] = $id;
         // create a nav menu item
         wp_update_nav_menu_item($id, 0, array('menu-item-title' => $nav_title . ' item', 'menu-item-classes' => $nav_slug, 'menu-item-url' => home_url('/' . $nav_slug . '/'), 'menu-item-status' => 'publish'));
     }
     set_theme_mod('nav_menu_locations', $locations);
     // make sure that they're created, and we have no spares
     $this->assertEquals(4, count(get_nav_menu_locations()));
     largo_transition_nav_menus();
     // make sure the old navs are deleted
     $this->assertEquals(1, count(get_nav_menu_locations()));
     // make sure the old navs' items made it to the Main Navigation menu
     $this->assertEquals(3, count(wp_get_nav_menu_items('Main Navigation')));
 }