Beispiel #1
0
    /**
     * Handles displaying dynamic content such as LiveSearch, RollingArchives
     *
     * @uses do_action() Provides 'k2_dynamic_content' action
     */
    function dynamic_content()
    {
        $k2dynamic = get_query_var('k2dynamic');
        if ($k2dynamic) {
            define('DOING_AJAX', true);
            // Send the header
            header('Content-Type: ' . get_bloginfo('html_type') . '; charset=' . get_bloginfo('charset'));
            get_template_part('blocks/k2-loop');
            if ('init' == $k2dynamic) {
                $rolling_state = k2_get_rolling_archives_state();
                ?>
				<script type="text/javascript">
				// <![CDATA[
					K2.RollingArchives.setState(
						<?php 
                echo $rolling_state['curpage'];
                ?>
,
						<?php 
                echo $rolling_state['maxpage'];
                ?>
,
						<?php 
                echo json_encode($rolling_state['query']);
                ?>
,
						<?php 
                echo json_encode($rolling_state['pagedates']);
                ?>
					);
				// ]]>
				</script>

			<?php 
            }
            // K2 Hook
            do_action('k2_dynamic_content', $k2dynamic);
            exit;
        }
    }
Beispiel #2
0
/**
 * Initializes Rolling Archives and LiveSearch
 */
function k2_init_advanced_navigation()
{
    global $wp_scripts;
    $rolling_state = k2_get_rolling_archives_state();
    ?>
<script type="text/javascript">
//<![CDATA[

	//  Set in motion all of K2's AJAX hotness (RA and LS).
	function initK2() {
		K2.AjaxURL	= "<?php 
    bloginfo('url');
    ?>
/" // For our AJAX calls
		K2.Animations	= <?php 
    echo (int) get_option('k2animations');
    ?>
 // Fetch the animations option

		// Insert the Rolling Archives UI and init.
		K2.RollingArchives = new RollingArchives({
			content:	".content",
			posts:		".content .post",
			parent:		".primary",
			pagetext:	"<?php 
    /* translators: Page X of Y */
    echo esc_js(__('of', 'k2'));
    ?>
",
			older:		"<?php 
    echo esc_js(__('Older', 'k2'));
    ?>
",
			newer:		"<?php 
    echo esc_js(__('Newer', 'k2'));
    ?>
",
			loading:	"<?php 
    echo esc_js(__('Loading', 'k2'));
    ?>
",
			offsetTop:	50,
			pagenumber:	<?php 
    echo $rolling_state['curpage'];
    ?>
,
			pagecount:	<?php 
    echo $rolling_state['maxpage'];
    ?>
,
			query:		<?php 
    echo json_encode($rolling_state['query']);
    ?>
,
			pagedates:	<?php 
    echo json_encode($rolling_state['pagedates']);
    ?>
,
			search:		"<?php 
    echo esc_js(__('Search', 'k2'));
    ?>
"
		});

		K2.LiveSearch	= new LiveSearch( RA.search || 'Search' );

		 // Looks for fragment changes
		jQuery(window).bind( 'hashchange', K2.parseFragments );

		// Parse and execute waiting fragments.
		jQuery(window).trigger( 'hashchange' );

		<?php 
    /* JS to run after jQuery Ajax calls */
    if (get_option('k2ajaxdonejs') != '') {
        ?>
		jQuery('.content').ajaxComplete(function () {
			<?php 
        echo get_option('k2ajaxdonejs');
        ?>
		});
		<?php 
    }
    ?>
	}

	// Make ready K2's sub-systems
	jQuery(document).ready( function() { initK2(); });
//]]>
</script>
<?php 
}