Esempio n. 1
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.");
 }
Esempio n. 2
0
/**
 * Puts new widgets into sidebars as appropriate based on old theme options
 */
function largo_update_widgets()
{
    /* checks and adds if necessary:
    		social_icons_display ('btm' or 'both')
    		add series widget
    		show_tags
    		show_author_box
    		show_related_content
    		show_next_prev_nav_single
    	*/
    $checks = array();
    $checks['social_icons_display'] = array('values' => array('btm', 'both'), 'widget' => 'largo-follow', 'settings' => array('title' => ''));
    //this is a dummy check
    $checks['in_series'] = array('values' => NULL, 'widget' => 'largo-post-series-links', 'settings' => array('title' => __('Related Series', 'largo')));
    $checks['show_tags'] = array('values' => array(1), 'widget' => 'largo-tag-list', 'settings' => array('title' => __('Filed Under:', 'largo'), 'tag_limit' => 20));
    $checks['show_author_box'] = array('values' => array('1'), 'widget' => 'largo-author-bio', 'settings' => array('title' => __('Author', 'largo')));
    $checks['show_related_content'] = array('values' => array('1'), 'widget' => 'largo-explore-related', 'settings' => array('title' => __('More About', 'largo'), 'topics' => 6, 'posts' => 3));
    $checks['show_next_prev_nav_single'] = array('values' => array('1'), 'widget' => 'largo-prev-next-post-links', 'settings' => array());
    //loop thru, see if value is present, then see if widget exists, if not, create one
    foreach ($checks as $option => $i) {
        $opt = of_get_option($option);
        if ($i['values'] === NULL || in_array($opt, $i['values'])) {
            //we found an option that suggests we need to add a widget.
            //if there's not aleady one present, add it
            if (!largo_widget_in_region($i['widget'])) {
                largo_instantiate_widget($i['widget'], $i['settings'], 'article-bottom');
            }
        }
    }
}
Esempio n. 3
0
 function test_largo_widget_in_region()
 {
     // uses WP_Error
     $widgets_backup = get_option('sidebars_widgets ');
     // A widget that exists in a sidebar that does
     update_option('sidebars_widgets', array('sidebar-single' => array(0 => 'archives-2')));
     $return = largo_widget_in_region('archives', 'sidebar-single');
     $this->assertTrue($return);
     unset($return);
     // A widget that does not exist in a sidebar that does
     update_option('sidebars_widgets', array('sidebar-single' => array(0 => 'archives-2')));
     $return = largo_widget_in_region('wodget', 'sidebar-single');
     $this->assertFalse($return);
     unset($return);
     // A widget that exists in a sidebar that does not
     update_option('sidebars_widgets', array('sidebar-single' => array(0 => 'archives-2')));
     $return = largo_widget_in_region('archives', 'missing-region');
     $this->assertTrue($return instanceof WP_Error);
     unset($return);
     // A widget that does not exist in a sidebar that also does not
     update_option('sidebars_widgets', array('sidebar-single' => array(0 => 'archives-2')));
     $return = largo_widget_in_region('wodget', 'missing-region');
     $this->assertTrue($return instanceof WP_Error);
     unset($return);
     // Cleanup
     delete_option('sidebars_widgets');
     update_option('sidebars_widgets', $widgets_backup);
     unset($widgets_backup);
 }