__( 'Announcements', 'apollo-bar' ), 'singular_name' => __( 'Announcement', 'apollo-bar' ), 'add_new' => __( 'Add New', 'apollo-bar' ), 'add_new_item' => __( 'Add New Announcement', 'apollo-bar' ), 'all_items' => __( 'All items', 'apollo-bar' ), 'edit_item' => __( 'Edit Announcement', 'apollo-bar' ), 'new_item' => __( 'New Announcement', 'apollo-bar' ), 'view_item' => __( 'View Announcement', 'apollo-bar' ), 'search_items' => __( 'Search Announcements', 'apollo-bar' ), 'not_found' => __( 'No Announcements found', 'apollo-bar' ), 'not_found_in_trash' => __( 'No Announcements found in Trash', 'apollo-bar' ), 'parent_item_colon' => '', 'menu_name' => __( 'Apollo Bar', 'apollo-bar' ) ); $args = array( 'labels' => $labels, 'singular_label' => __( 'Announcement', 'announcements', 'apollo-bar' ), 'public' => true, 'capability_type' => 'post', 'rewrite' => false, 'supports' => array( 'title', 'editor' ), ); register_post_type( 'announcements', $args ); } add_action( 'init', 'apb_register_announcements' ); // Add Menu Icon function apollo_bar_icons() { echo ''; } add_action( 'admin_head', 'apollo_bar_icons' ); // Add Custom Screen Icon function apollo_bar_screen_icon() { $post_type = get_current_screen()->post_type; if ( 'announcements' == $post_type ) { echo ''; } } add_action( 'admin_head', 'apollo_bar_screen_icon' ); // Creating Custom Meta Boxes // Adding Meta Box function apb_add_metabox() { add_meta_box( 'apb_metabox_id', __( 'Scheduling', 'apollo-bar' ), 'apb_metabox', 'announcements', 'side', 'high' ); } add_action( 'add_meta_boxes', 'apb_add_metabox' ); // Adding the Fields function apb_metabox( $post ) { $values = get_post_custom( $post->ID ); $start_date = isset( $values['apb_start_date'] ) ? esc_attr( $values['apb_start_date'][0] ) : ''; $end_date = isset( $values['apb_end_date'] ) ? esc_attr( $values['apb_end_date'][0] ) : ''; wp_nonce_field( 'apb_metabox_nonce', 'metabox_nonce' ); ?>

post_type != 'announcements' ) ) return; wp_enqueue_style( 'jquery-ui-fresh', APOLLO_BAR_PATH . 'css/jquery-ui-fresh.css' ); wp_enqueue_script( 'announcements', APOLLO_BAR_PATH . 'js/apollo-bar-core.js', array( 'jquery', 'jquery-ui-datepicker' ) ); } add_action( 'admin_enqueue_scripts', 'apb_backend_scripts' ); // Frontend function apb_frontend_scripts() { wp_enqueue_style( 'announcements-style', APOLLO_BAR_PATH . 'css/apollo-bar.css' ); wp_enqueue_script( 'announcements', APOLLO_BAR_PATH . 'js/apollo-bar-core.js', array( 'jquery' ) ); wp_enqueue_script( 'cookies', APOLLO_BAR_PATH . 'js/jquery.cookie.js', array( 'jquery' ) ); wp_enqueue_script( 'cycle', APOLLO_BAR_PATH . 'js/jquery.cycle.lite.js', array( 'jquery' ) ); } add_action( 'wp_enqueue_scripts', 'apb_frontend_scripts' ); // Displaying Apollo Bar function apb_filter_where( $where = '' ) { // ...where dates are blank $where .= " OR (mt1.meta_key = 'apb_start_date' AND CAST(mt1.meta_value AS CHAR) = '') OR (mt2.meta_key = 'apb_end_date' AND CAST(mt2.meta_value AS CHAR) = '')"; return $where; } function apb_display_announcement() { global $wpdb, $apb_options; $today = date( 'Y-m-d' ); $args = array( 'post_type' => 'announcements', 'posts_per_page' => 0, 'meta_key' => 'apb_end_date', 'orderby' => 'meta_value_num', 'order' => 'ASC', 'meta_query' => array( array( 'key' => 'apb_start_date', 'value' => $today, 'compare' => '<=', ), array( 'key' => 'apb_end_date', 'value' => $today, 'compare' => '>=', ) ) ); // Add a filter to do complex 'where' clauses... add_filter( 'posts_where', 'apb_filter_where' ); $query = new WP_Query( $args ); // Take the filter away again so this doesn't apply to all queries. remove_filter( 'posts_where', 'apb_filter_where' ); $announcements = $query->posts; if ( $announcements && $apb_options['apollo_bar_display'] == true ) : ?>
Download Apollo Bar
post_content ) ) ); ?>