array( 'name' => __( 'FAQ', 'acf' ), 'singular_name' => __( 'FAQ', 'acf' ), 'add_new' => __( 'Add New', 'acf' ), 'add_new_item' => __( 'Add New Question', 'acf' ), 'edit' => __( 'Edit', 'acf' ), 'edit_item' => __( 'Edit Question', 'acf' ), 'new_item' => __( 'New Question', 'acf' ), 'view' => __( 'View FAQ', 'acf' ), 'view_item' => __( 'View Question', 'acf' ), 'search_items' => __( 'Search FAQ', 'acf' ), 'not_found' => __( 'No FAQs found', 'acf' ), 'not_found_in_trash' => __( 'No FAQs found in Trash', 'acf' ) ), 'public' => true, 'query_var' => true, 'menu_position' => 20, 'menu_icon' => ACF_URL . 'images/faq-16x16.png', 'has_archive' => true, 'supports' => array( 'title', 'editor', 'revisions' ), 'rewrite' => array( 'slug' => 'faqs', 'with_front' => false ) ) ); register_post_type( 'faq', $args ); } /** Modify updated messages on post type save */ function updated_messages( $messages ) { global $post, $post_ID; $messages['faq'] = array( 0 => '', // Unused. Messages start at index 1. 1 => sprintf( __('FAQ updated. View staff'), esc_url( get_permalink($post_ID) ) ), 2 => __('Custom field updated.'), 3 => __('Custom field deleted.'), 4 => __('FAQ updated.'), /* translators: %s: date and time of the revision */ 5 => isset($_GET['revision']) ? sprintf( __('FAQ restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, 6 => sprintf( __('FAQ published. View FAQ'), esc_url( get_permalink($post_ID) ) ), 7 => __('FAQ saved.'), 8 => sprintf( __('FAQ submitted. Preview FAQ'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), 9 => sprintf( __('FAQ scheduled for: %1$s. Preview FAQ'), // translators: Publish box date format, see http://php.net/date date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ), 10 => sprintf( __('FAQ draft updated. Preview FAQ'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ), ); return $messages; } /** * Add the post-type icon to the admin screen */ function post_type_admin_image() { printf( '', ACF_URL . 'images/faq-32x32.png' ); } /** * Choose the specific columns we want to display * * @param array $columns * @return string * @since 0.9 */ function columns_filter ( $columns ) { $columns = array ( "cb" => "", "title" => "FAQ Title", "faq_content" => "Details", "date" => "Date" ); return $columns; } /** * Filter the data that shows up in the columns we defined above * * @global type $post * @param type $column * @since 0.9 */ function column_data( $column ) { global $post; switch( $column ) { case "faq_content": the_excerpt(); break; default: break; } } /** * Register the javascript */ function register_script() { if( file_exists( get_stylesheet_directory() . "/arconix-faq.js" ) ) { wp_register_script( 'arconix-faq-js', get_stylesheet_directory_uri() . '/arconix-faq.js', array( 'jquery' ), ACF_VERSION, true ); } elseif( file_exists( get_template_directory() . "/arconix-faq.js" ) ) { wp_register_script( 'arconix-faq-js', get_template_directory_uri() . '/arconix-faq.js', array( 'jquery' ), ACF_VERSION, true ); } else { wp_register_script( 'arconix-faq-js', ACF_URL . 'includes/faq.js', array( 'jquery' ), ACF_VERSION, true ); } } /** * Load the javascript on a page where the FAQ shortcode is used * @return type */ function print_script() { if( ! self::$load_js ) return; wp_print_scripts( 'arconix-faq-js' ); } /** * Load the plugin's stylesheet */ function enqueue_css() { if( file_exists( get_stylesheet_directory() . "/arconix-faq.css" ) ) { wp_enqueue_style( 'arconix-faq', get_stylesheet_directory_uri() . '/arconix-faq.css', array(), ACF_VERSION ); } elseif( file_exists( get_template_directory() . "/arconix-faq.css" ) ) { wp_enqueue_style( 'arconix-faq', get_template_directory_uri() . '/arconix-faq.css', array(), ACF_VERSION ); } else { wp_enqueue_style( 'arconix-faq', ACF_URL . 'includes/faq.css', array(), ACF_VERSION ); } } /** * Display FAQs * * @param type $atts * @param type $content * @since 0.9 * @version 1.0.3 */ function faq_shortcode( $atts ) { // Set the js flag self::$load_js = true; $defaults = apply_filters( 'arconix_faq_shortcode_query_args', array( 'post_type' => 'faq', 'showposts' => 'all', 'order' => 'ASC', 'orderby' => 'title' ) ); extract( shortcode_atts( $defaults, $atts ) ); /** Translate 'all' to -1 for query terms */ if( $showposts == "all" ) $showposts = "-1"; /** Create a new query bsaed on our own arguments */ $faq_query = new WP_Query( array( 'post_type' => $post_type, 'order' => $order, 'orderby' => $orderby, 'posts_per_page' => $showposts ) ); if( $faq_query->have_posts() ) : while ( $faq_query->have_posts() ) : $faq_query->the_post(); //echo '