示例#1
0
 /**
  * Enqueue our core javascript and css files
  *
  * @since 1.0
  * @global LARGO_DEBUG
  */
 function largo_enqueue_js()
 {
     /*
      * Use minified assets if LARGO_DEBUG is false.
      */
     $suffix = LARGO_DEBUG ? '' : '.min';
     $version = largo_version();
     // Our primary stylesheet. Often overridden by custom-less-variables version.
     wp_enqueue_style('largo-stylesheet', get_template_directory_uri() . '/css/style' . $suffix . '.css', null, $version);
     // Core JS includes some utilities, initializes carousels, search form behavior,
     // popovers, responsive header image, etc.
     wp_enqueue_script('largoCore', get_template_directory_uri() . '/js/largoCore' . $suffix . '.js', array('jquery'), $version, true);
     // Navigation-related JS
     wp_enqueue_script('largo-navigation', get_template_directory_uri() . '/js/navigation' . $suffix . '.js', array('largoCore'), $version, true);
     // Largo configuration object for use in frontend JS
     wp_localize_script('largoCore', 'Largo', array('is_home' => is_home(), 'is_single' => is_single() || is_singular(), 'sticky_nav_options' => array('sticky_nav_display_article' => (bool) of_get_option('sticky_nav_display_article', 1), 'main_nav_hide_article' => (bool) of_get_option('main_nav_hide_article', 0), 'nav_overflow_label' => of_get_option('nav_overflow_label', 'More'))));
     /*
      * The following files are already minified:
      *
      * - modernizr.custom.js
      * - largoPlugins.js
      * - jquery.idTabs.js
      */
     wp_enqueue_script('largo-modernizr', get_template_directory_uri() . '/js/modernizr.custom.js', null, $version);
     wp_enqueue_script('largoPlugins', get_template_directory_uri() . '/js/largoPlugins.js', array('jquery'), $version, true);
     // Only load jquery tabs for the related content box if it's active
     if (is_single()) {
         wp_enqueue_script('idTabs', get_template_directory_uri() . '/js/jquery.idTabs.js', array('jquery'), $version, true);
     }
 }
示例#2
0
/**
 * Checks if updates need to be run.
 *
 * @since 0.3
 *
 * @return boolean if updates need to be run
 */
function largo_need_updates()
{
    // try to figure out which versions of the options are stored. Implemented in 0.3
    if (of_get_option('largo_version')) {
        $compare = version_compare(largo_version(), of_get_option('largo_version'));
        if ($compare == 1) {
            return true;
        } else {
            return false;
        }
    }
    // if 'largo_version' isn't present, the settings are old!
    return true;
}
示例#3
0
 function test_largo_perform_update()
 {
     // requires largo_need_updates
     // Backup sidebar widgets, create our own empty sidebar
     $widgets_backup = get_option('sidebars_widgets ');
     update_option('sidebars_widgets', array('article-bottom' => array()));
     // force updates by setting current version of largo to 0.0
     of_set_option('largo_version', '0.0');
     largo_perform_update();
     // check that options have been set
     $this->assertEquals(largo_version(), of_get_option('largo_version'));
     // Cleanup
     of_reset_options();
     delete_option('sidebars_widgets');
     update_option('sidebars_widgets', $widgets_backup);
     unset($widgets_backup);
 }
示例#4
0
/**
 * Performs various database updates upon Largo version change.
 *
 * @since 0.3
 */
function largo_perform_update()
{
    if (largo_need_updates()) {
        // 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();
        of_set_option('largo_version', largo_version());
    }
    return true;
}
示例#5
0
 function test_largo_ajax_update_database_false()
 {
     // If the install doesn't need to be updated, this should return json with success == false
     of_set_option('largo_version', largo_version());
     try {
         $this->_handleAjax("largo_ajax_update_database");
     } catch (WPAjaxDieContinueException $e) {
         $resp = json_decode($this->_last_response, true);
         $this->assertTrue($resp['success'] == false);
     }
 }
示例#6
0
 /**
  * Enqueue script for "load more posts" functionality
  *
  * @since 0.5.3
  * @global LARGO_DEBUG
  */
 function largo_load_more_posts_enqueue_script()
 {
     $suffix = LARGO_DEBUG ? '' : '.min';
     $version = largo_version();
     wp_enqueue_script('load-more-posts', get_template_directory_uri() . '/js/load-more-posts' . $suffix . '.js', array('jquery'), $version, false);
 }
示例#7
0
    function largo_floating_social_button_js()
    {
        $template = get_post_template(null);
        if (is_null($template)) {
            $template = of_get_option('single_template');
        }
        $is_single_column = (bool) strstr($template, 'single-one-column') || $template == 'normal' || is_null($template);
        if (is_single() && of_get_option('single_floating_social_icons', '1') == '1' && $is_single_column) {
            ?>
			<script type="text/javascript" src="<?php 
            $suffix = LARGO_DEBUG ? '' : '.min';
            $version = largo_version();
            echo get_template_directory_uri() . '/js/floating-social-buttons' . $suffix . '.js?ver=' . $version;
            ?>
" async></script>
			<?php 
        }
    }