register_post_type(); $this->taxonomies(); // Creating Admin menu add_action( 'admin_menu',array( $this, 'admin_pages')); // Adding Scripts for admin menu add_action( 'admin_enqueue_scripts',array( $this, 'admin_scripts' )); add_action( 'wp_ajax_save_sort',array( $this, 'save_sort')); } /** * This is our post type register function * * @return FAQ_Post_Type */ public function register_post_type() { $labels = array( 'name' => 'FAQs', 'singular_name' => 'FAQ', 'add_new' => 'Add New FAQ', 'add_new_item' => 'Add New FAQ', 'edit_item' => 'Edit FAQ', 'new_item' => 'New FAQ', 'all_items' => 'All FAQs', 'view_item' => 'View FAQ', 'search_items' => 'Search FAQs', 'not_found' => 'No FAQs found', 'not_found_in_trash' => 'No FAQ found in Trash', 'parent_item_colon' => '', 'menu_name' => 'FAQs' ); $args = array( 'labels' => $labels, 'public' => true, 'publicly_queryable' => true, 'show_ui' => true, 'show_in_menu' => true, 'query_var' => true, 'rewrite' => array( 'slug' => 'asp_faq/' ), 'capability_type' => 'post', 'has_archive' => true, 'hierarchical' => true, 'menu_icon' => plugins_url( '/plugin_images/faq_menu.png', __FILE__ ), 'menu_position' => null, 'supports' => array( 'title', 'editor', 'excerpt'), //'taxonomies' => array('post_tag'), 'can_export' => true ); // registering post type of faq register_post_type( 'asp_faq', $args ); } /** * This is our taxonomy register function * * @return FAQ_Post_Type */ public function taxonomies() { $taxanomies = array(); $taxanomies['asp_cat']=array( 'hierarchical' => true, 'query_var' => 'asp_faq_cat', 'show_admin_column' => true, 'show_in_nav_menus' => false, 'rewrite' => array( 'slug' => 'asp_faq/asp_cat', ), $labels = array( 'name' => 'FAQs Categories', 'singular_name' => 'FAQ Category', 'edit_item' => 'Edit FAQ Category', 'update_item' => 'Update FAQ Category', 'add_new_item' => 'New FAQ Category', 'all_items' => 'All FAQs', 'new_item_name' => 'Add New FAQ Category', 'search_items' => 'Search FAQ Category', 'popular_items' => 'Popular FAQ Category', 'search_item_with_comments' => ' Seprate FAQ Category with comments', 'add_or_remove_items' => 'Add or remove FAQ Category', 'choose_from_most_used' => 'Choose from most used FAQ Category' ), ); $taxanomies['asp_tag']=array( 'hierarchical' => false, 'query_var' => 'asp_faq_tag', 'show_admin_column' => true, 'show_in_nav_menus' => false, 'rewrite' => array( 'slug' => 'asp_faq/asp_tag', ), $labels = array( 'name' => 'FAQs TAGs', 'singular_name' => 'FAQ TAGs', 'edit_item' => 'Edit FAQ TAGs', 'update_item' => 'Update FAQ TAGs', 'add_new_item' => 'New FAQ TAGs', 'all_items' => 'All TAGs', 'new_item_name' => 'Add New FAQ TAGs', 'search_items' => 'Search FAQ TAGs', 'popular_items' => 'Popular FAQ TAGs', 'search_item_with_comments' => ' Seprate FAQ TAGs with comments', 'add_or_remove_items' => 'Add or remove TAGs Category', 'choose_from_most_used' => 'Choose from most used FAQ TAGs' ), ); //parsing array to the function register_all_taxanomies $this->register_all_taxanomies($taxanomies); } /** *registering all taxonomies * * @return FAQ_Post_Type */ public function register_all_taxanomies($taxanomies) { foreach($taxanomies as $name => $arr) { register_taxonomy($name,array('asp_faq'),$arr); } } /** * Call admin pages * * @return FAQ_Post_Type */ public function admin_pages() { add_submenu_page('edit.php?post_type=asp_faq', __('Sort FAQs', ''), __('Sort FAQs', 'wp_multifaq'), apply_filters( 'asp_faq', 'manage_options', 'asp_faqsort' ), 'asp_faq-sort', array( &$this, 'sort_asp_faq' )); add_submenu_page('edit.php?post_type=asp_faq', __('Settings', ''), __('Settings', 'wp_multifaq'), apply_filters( 'asp_faq', 'manage_options', 'settings' ), 'asp_faq-options', array( &$this, 'settings_asp_faq' )); add_submenu_page('edit.php?post_type=asp_faq', __('Instructions', ''), __('Instructions', 'wp_multifaq'), apply_filters( 'asp_faq', 'manage_options', 'instructions' ), 'asp_faq-instructions', array( &$this, 'instructions_asp_faq' )); } /** * Admin scripts and styles * * @return FAQ_Post_Type */ public function admin_scripts($hook) { $screen = get_current_screen(); if ( is_object($screen) && 'asp_faq' == $screen->post_type ) : wp_enqueue_style( 'asp_faq-admin', plugins_url('/inc/css/faq-admin.css', __FILE__), array(), FAQ_VER, 'all' ); endif; wp_enqueue_style( 'faq-admin', plugins_url('/inc/css/faq-admin.css', __FILE__), array(), FAQ_VER, 'all' ); wp_enqueue_script('jquery-ui-sortable'); wp_enqueue_script( 'faq-admin', plugins_url('/inc/js/faq.admin.init.js', __FILE__) , array('jquery'), FAQ_VER, true ); } /** * Save main options page structure * * @return FAQ_Post_Type */ public function save_options($option){ global $wpdb; $table_options = $wpdb->prefix . "options"; if($option!='') { if($option['css'] == '') { $option['css'] = 'false';} if($option['expand'] == '') { $option['expand'] = 'false';} $myopt = get_option('multifaq_htype'); if($myopt != '') { update_option('multifaq_htype', $option['htype']); } else { add_option( 'multifaq_htype', $option['htype'], '', 'yes' ); } $myopt2 = get_option('multifaq_expand'); if($myopt != '') { update_option('multifaq_expand', $option['expand']); } else { add_option( 'multifaq_expand', $option['expand'], '', 'yes' ); } $myopt3 = get_option('multifaq_css'); if($myopt != '') { update_option('multifaq_css', $option['css']); } else { add_option( 'multifaq_css', $option['css'], '', 'yes' ); } $myopt4 = get_option('multifaq_color'); if($myopt != '') { update_option('multifaq_color', $option['color']); } else { add_option( 'multifaq_color', $option['color'], '', 'yes' ); } } } /** * Display main options page structure * * @return FAQ_Post_Type */ public function settings_asp_faq() { if (!current_user_can('manage_options') ) return; if(isset($_POST['save_mutli_faq_setting'])) { $options= array(); $options= $_POST; $option = $options['faq_options']; $this->save_options($option); } ?>
'. __('FAQ Manager settings updated successfully.', 'wp_multifaq').'
; ?>/images/loading.gif)
Note: This only affects the FAQs listed using the shortcode functions', 'wp_multifaq'); ?>