__( 'FAQ', ANFAQ_TEXT_DOMAIN ), 'singular_name' => __( 'Question', ANFAQ_TEXT_DOMAIN ), 'add_new' => __( 'Add New', ANFAQ_TEXT_DOMAIN ), 'add_new_item' => __( 'Add New Question', ANFAQ_TEXT_DOMAIN ), 'edit_item' => __( 'Edit Question', ANFAQ_TEXT_DOMAIN ), 'new_item' => __( 'New Question', ANFAQ_TEXT_DOMAIN ), 'view_item' => __( 'View Question', ANFAQ_TEXT_DOMAIN ), 'view_items' => __( 'View Questions', ANFAQ_TEXT_DOMAIN ), 'search_items' => __( 'Search Questions', ANFAQ_TEXT_DOMAIN ), 'not_found' => __( 'No questions found.', ANFAQ_TEXT_DOMAIN ), 'not_found_in_trash' => __( 'No questions found in Trash.', ANFAQ_TEXT_DOMAIN ), 'all_items' => __( 'All Questions', ANFAQ_TEXT_DOMAIN ), 'archives' => __( 'Question Archives', ANFAQ_TEXT_DOMAIN ), 'attributes' => __( 'Question Attributes', ANFAQ_TEXT_DOMAIN ), 'insert_into_item' => __( /** @lang text */ 'Insert into Question', ANFAQ_TEXT_DOMAIN ), 'uploaded_to_this_item' => __( 'Uploaded to this question', ANFAQ_TEXT_DOMAIN ), 'featured_image' => __( 'Featured Image', ANFAQ_TEXT_DOMAIN ), 'set_featured_image' => __( 'Set featured image', ANFAQ_TEXT_DOMAIN ), 'remove_featured_image' => __( 'Remove featured image', ANFAQ_TEXT_DOMAIN ), 'use_featured_image' => __( 'Use as featured image', ANFAQ_TEXT_DOMAIN ), 'filter_items_list' => __( 'Filter questions list', ANFAQ_TEXT_DOMAIN ), 'items_list_navigation' => __( 'Questions list navigation', ANFAQ_TEXT_DOMAIN ), 'items_list' => __( 'Questions list', ANFAQ_TEXT_DOMAIN ), ]; register_post_type( ANFAQ_POST_TYPE, [ 'labels' => $labels, 'public' => false, 'hierarchical' => false, 'show_ui' => true, 'menu_icon' => 'dashicons-editor-help', 'capability_type' => 'post', 'supports' => [ 'title', 'editor', 'revisions', 'page-attributes' ], ] ); } add_action( 'init', 'anfaq_register_post_type' ); // --------------------------------------------------------------------------------------------------------------------- // REGISTER POST TYPE (END) // --------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------- // INTERNATIONALIZATION (BEGIN) // --------------------------------------------------------------------------------------------------------------------- function anfaq_textdomain() { $plugin_rel_path = basename( dirname( __FILE__ ) ) . '/languages/'; load_plugin_textdomain( ANFAQ_TEXT_DOMAIN, false, $plugin_rel_path ); } add_action( 'plugins_loaded', 'anfaq_textdomain' ); // --------------------------------------------------------------------------------------------------------------------- // INTERNATIONALIZATION (END) // --------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------- // ADMIN QUESTIONS LIST (BEGIN) // --------------------------------------------------------------------------------------------------------------------- function anfaq_questions_columns( $columns ) { $last_value = end( $columns ); $last_key = key( $columns ); unset( $columns[$last_key] ); $columns['menu_order'] = __( 'Order', ANFAQ_POST_TYPE ); $columns[$last_key] = $last_value; return $columns; } add_filter( 'manage_' . ANFAQ_POST_TYPE . '_posts_columns', 'anfaq_questions_columns' ); // add custom column function anfaq_questions_sortable_columns( $columns ) { $columns['menu_order'] = 'menu_order'; return $columns; } add_filter( 'manage_edit-' . ANFAQ_POST_TYPE . '_sortable_columns', 'anfaq_questions_sortable_columns' ); // mark custom column as sorted function anfaq_questions_columns_values( $column ) { global $post; switch ( $column ) { case 'menu_order': echo $post->menu_order; break; } } add_action( 'manage_' . ANFAQ_POST_TYPE . '_posts_custom_column' , 'anfaq_questions_columns_values' ); // output custom column value function anfaq_orderby( WP_Query $query ) { if( ! $query->is_main_query() || ANFAQ_POST_TYPE != $query->get( 'post_type' ) ) { return; // Nothing to do } $orderby = strtolower( $query->get( 'orderby') ); if ( '' === $orderby) { $query->set( 'orderby', 'menu_order' ); $query->set( 'order', 'ASC' ); } } add_action( 'pre_get_posts', 'anfaq_orderby' ); // change default order // --------------------------------------------------------------------------------------------------------------------- // ADMIN QUESTIONS LIST (END) // --------------------------------------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------------------------------------- // POPUP (BEGIN) // --------------------------------------------------------------------------------------------------------------------- function anfaq_popup() { $query = new WP_Query( [ 'post_type' => ANFAQ_POST_TYPE, 'posts_per_page' => -1, 'order' => 'ASC', 'orderby' => 'menu_order', ] ); if ( $query->have_posts() ) { echo ''; wp_reset_postdata(); } } add_action( 'wp_footer', 'anfaq_popup' ); // --------------------------------------------------------------------------------------------------------------------- // POPUP (BEGIN) // ---------------------------------------------------------------------------------------------------------------------