Created
April 22, 2014 14:58
-
-
Save jillmugge/11182525 to your computer and use it in GitHub Desktop.
Making LoopBuddy compatible with other themes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//LoopBuddy Support. Place in functions.php | |
add_theme_support('loop-standard'); | |
if ( ! function_exists( 'dynamic_loop' ) ) { | |
function dynamic_loop() { | |
global $dynamic_loop_handlers; | |
if ( empty( $dynamic_loop_handlers ) || ! is_array( $dynamic_loop_handlers ) ) | |
return false; | |
ksort( $dynamic_loop_handlers ); | |
foreach ( (array) $dynamic_loop_handlers as $handlers ) { | |
foreach ( (array) $handlers as $function ) { | |
if ( is_callable( $function ) && ( false != call_user_func( $function ) ) ) { | |
return true; | |
} | |
} | |
} | |
return false; | |
} | |
} | |
if ( ! function_exists( 'register_dynamic_loop_handler' ) ) { | |
function register_dynamic_loop_handler( $function, $priority = 10 ) { | |
global $dynamic_loop_handlers; | |
if ( ! is_numeric( $priority ) ) | |
$priority = 10; | |
if ( ! isset( $dynamic_loop_handlers ) || ! is_array( $dynamic_loop_handlers ) ) | |
$dynamic_loop_handlers = array(); | |
if ( ! isset( $dynamic_loop_handlers[$priority] ) || ! is_array( $dynamic_loop_handlers[$priority] ) ) | |
$dynamic_loop_handlers[$priority] = array(); | |
$dynamic_loop_handlers[$priority][] = $function; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment