plugin_name = $plugin_name; $this->version = $version; } /** * Add the Additional Columns For the faq_category Taxonomy * * @param array $columns * @return array */ public function manage_edit_faq_category_columns( $columns ) { $new_columns['cb'] = $columns['cb']; $new_columns['name'] = $columns['name']; $new_columns['shortcode'] = __("Shortcode",'faq-creator'); $new_columns['slug'] = $columns['slug']; $new_columns['posts'] = $columns['posts']; return $new_columns; } /** * * Rename the Columns for the faq post type and adding new Columns * * @param array $columns * @return array */ public function manage_edit_faq_columns( $columns ) { $new_columns['cb'] = $columns['cb']; $new_columns['title'] = __('Question','faq-creator'); $new_columns['category'] = __('Category','faq-creator'); $new_columns['date'] = $columns['date']; return $new_columns; } /** * * Add the Additional column Values for the faq_category Taxonomy * * @param string $out * @param string $column * @param int $term_id * @return string */ public function manage_faq_category_custom_column( $out, $column, $term_id ) { switch( $column ) { case 'shortcode': $temp = '[pafa_faq category=' . $term_id . ']'; return $temp; break; } } /** * * Add the Additional column Values for the faq Post Type * * @global type $post * @param string $column */ public function manage_faq_custom_column( $column ) { global $post; switch( $column ) { case 'category': $terms = wp_get_object_terms($post->ID ,'faq_category'); foreach($terms as $term){ $temp = " term_id . '&post_type=faq' ) ) . "\" "; $temp .= " class=\"row-title\">{$term->name}
"; echo $temp; } break; } } /** * Category Based Filtering options * * @global string $typenow */ function restrict_manage_posts() { global $typenow; if ( $typenow == 'accordion' ) { ?> [pafa_faq category=] update( $wpdb->posts, array('menu_order' => $listing_counter), array('ID' => $post_id) ); $listing_counter++; } die(); } public function order_save_taxonomies_order() { global $wpdb; $action = $_POST['action']; $tags_array = $_POST['tag']; $listing_counter = 1; foreach ($tags_array as $tag_id) { $wpdb->update( $wpdb->terms, array('term_group' => $listing_counter), array('term_id' => $tag_id) ); $listing_counter++; } die(); } public function order_reorder_taxonomies_list( $orderby, $args ) { $orderby = "t.term_group"; return $orderby; } public function order_reorder_list( $query ) { $query->set( 'orderby', 'menu_order' ); $query->set( 'order', 'ASC' ); return $query; } /** * Register FAQ Custom Post Type */ public function register_cpt() { register_post_type( 'accordion',array( 'description' => __('Accordion Articles','faq-creator'), 'labels' => array( 'name' => __('Accordion' ,'faq-creator'), 'all_items' => __('All Accordions' ,'faq-creator'), 'singular_name' => __('Accordion' ,'faq-creator'), 'add_new' => __('Add New' ,'faq-creator'), 'add_new_item' => __('Add New Accordion' ,'faq-creator'), 'edit_item' => __('Edit Accordion' ,'faq-creator'), 'new_item' => __('New Accordion' ,'faq-creator'), 'view_item' => __('View Accordion' ,'faq-creator'), 'search_items' => __('Search Accordion' ,'faq-creator'), 'not_found' => __('No Accordion found' ,'faq-creator'), 'not_found_in_trash' => __('No Accordion found in Trash' ,'faq-creator'), ), 'public' => true, 'menu_position' => 5, 'rewrite' => array( 'slug' => 'accordion' ), 'supports' => array( 'title', 'editor' /*,'page-attributes' */), 'public' => true, 'show_ui' => true, 'publicly_queryable' => true, 'exclude_from_search' => false, 'menu_icon' => 'dashicons-editor-help', )); } /** * Register faq custom taxonomy */ public function register_taxonomy() { register_taxonomy( 'accordion_category',array( 'accordion' ),array( 'hierarchical' => false, 'labels' => array( 'name' => __( 'Categories' ,'faq-creator'), 'singular_name' => __( 'Category' ,'faq-creator'), 'search_items' => __( 'Search Categories' ,'faq-creator'), 'all_items' => __( 'All Categories' ,'faq-creator'), 'parent_item' => __( 'Parent Category' ,'faq-creator'), 'parent_item_colon' => __( 'Parent Category:' ,'faq-creator'), 'edit_item' => __( 'Edit Category' ,'faq-creator'), 'update_item' => __( 'Update Category' ,'faq-creator'), 'add_new_item' => __( 'Add New Category' ,'faq-creator'), 'new_item_name' => __( 'New Category Name' ,'faq-creator'), 'popular_items' => NULL, 'menu_name' => __( 'Categories' ,'faq-creator'), ), 'show_ui' => true, 'public' => true, 'query_var' => true, 'hierarchical' => true, 'rewrite' => array( 'slug' => 'accordion_category' ), )); } public function help_tab() { $screen = get_current_screen(); if( in_array( $screen->id, array( 'edit-faq_category', 'accordion', 'edit-faq') ) ) { $screen->add_help_tab( array ( 'id' => 'dickensosfaq_shortcode', 'title' => __( 'Faq Shortcodes', 'faq-creator' ), 'content' => '

' . __('

Faq Shortcodes

','faq-creator') . '

' . '

' . __( 'You can use [pafa_faq] shortcode to include the Faqs on any page, post or custom post type.', 'faq-creator' ) . '

' . '

' . __( 'The shortcode accepts two optional attributes:', 'faq-creator' ) . '

' . '

' . __( '(1) category = -1 | {any faq category id}', 'faq-creator' ) . '

' . '

' . __( '(2) template = accordion | {any custom/existing template}', 'faq-creator' ) . '

' . '

' . __( 'Examples', 'faq-creator' ) . '

' . '

' . __( '1. [pafa_faq]', 'faq-creator' ) . '

' . '

' . sprintf(__( '2. [pafa_faq category={category_id}] {category_id} you will find it here under shortcode column', 'faq-creator' ),admin_url('edit-tags.php?taxonomy=faq_category&post_type=faq') ). '

' . '

' . __( '3. [pafa_faq category={category_id} template=\'accordion\']', 'faq-creator' ) . '

' )); } } public function order_load_scripts() { wp_enqueue_script( 'jquery-ui-sortable' ); wp_enqueue_script( $this->plugin_name . '_order-update-post-order' ); wp_enqueue_style( $this->plugin_name ); } public function order_load_scripts_taxonomies() { wp_enqueue_script( 'jquery-ui-sortable' ); wp_enqueue_script( $this->plugin_name . '_order-update-taxonomy-order' ); wp_enqueue_style( $this->plugin_name ); } /** * Register the stylesheets for the admin area. * * @since 1.0.0 */ public function enqueue_styles() { wp_register_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/faq-creator-admin.css', array(), $this->version, 'all' ); } /** * Register the JavaScript for the admin area. * * @since 1.0.0 */ public function enqueue_scripts() { wp_register_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/faq-creator-admin.js', array( 'jquery' ), $this->version, false ); wp_register_script( $this->plugin_name . '_order-update-post-order', plugin_dir_url( __FILE__ ) . 'js/faq-creator-order-posts.js', array( 'jquery' ), $this->version, false ); wp_register_script( $this->plugin_name . '_order-update-taxonomy-order', plugin_dir_url( __FILE__ ) . 'js/faq-creator-order-taxonomies.js', array( 'jquery' ), $this->version, false ); } /** * Adds a link to the plugin settings page */ public function settings_link( $links ) { $settings_link = sprintf( '%s', admin_url( 'admin.php?page=' . $this->plugin_name ), __( 'Settings', 'faq-creator' ) ); array_unshift( $links, $settings_link ); return $links; } /** * Adds links to the plugin links row */ public function row_links_f( $linkss, $file ) { if ( strpos( $file, $this->plugin_name . '.php' ) !== false ) { $link2 = '' . __( 'Help', 'faq-creator' ) . ''; array_push( $linkss, $link2 ); } return $linkss; } }