Created
November 29, 2017 04:27
-
-
Save anonymous/299d675caaba5954dae4a9fe1f858b40 to your computer and use it in GitHub Desktop.
This file contains 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
/** | |
* Get notice ticker details. | |
* | |
* @since 1.0.0 | |
*/ | |
function education_hub_notice_ticker_details(){ | |
$output = array(); | |
$notice_category = education_hub_get_option( 'notice_category' ); | |
$notice_number = education_hub_get_option( 'notice_number' ); | |
$qargs = array( | |
'posts_per_page' => absint( $notice_number ), | |
'no_found_rows' => true, | |
'post_type' => 'post', | |
); | |
/** | |
* Detect plugin. For use on Front End only. | |
*/ | |
include_once( ABSPATH . 'wp-admin/includes/plugin.php' ); | |
// check for plugin using plugin name | |
if ( is_plugin_active( 'the-events-calendar/the-events-calendar.php' ) ) { | |
$qargs['post_type'] = 'tribe_events'; | |
} else { | |
if ( absint( $notice_category ) > 0 ) { | |
$qargs['category'] = absint( $notice_category ); | |
} | |
} | |
$all_posts = get_posts( $qargs ); | |
if ( $all_posts ) { | |
$i=0; | |
foreach ( $all_posts as $post ) { | |
$output[$i]['text'] = apply_filters( 'the_title', $post->post_title ); | |
$output[$i]['link'] = get_permalink( $post->ID ); | |
$i++; | |
} | |
} | |
return $output; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment