Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Register features CPT
- *
- * @package FireFlyMain
- */
- function ff_doc_init() {
- register_taxonomy( 'documentation_category',array( 'documentation'), array(
- 'hierarchical' => true,
- 'show_ui' => true,
- 'show_admin_column' => true,
- 'query_var' => true,
- ));
- $args = array(
- 'public' => true,
- 'label' => esc_html__( 'FF Documentation', 'ff-doc' ),
- 'menu_icon' => 'dashicons-media-document',
- 'has_archive' => true,
- 'hierarchical' => false,
- 'supports' => array(
- 'title',
- 'editor',
- 'excerpt',
- 'thumbnail',
- 'page-attributes',
- ),
- 'taxonomies' => array( 'documentation_category'),
- );
- register_post_type( 'documentation', $args );
- }
- add_action( 'init', 'ff_doc_init' );
- function ff_doc_documentation_category_taxonomy_custom_fields( $term ) {
- // put the term ID into a variable
- $t_id = $term->term_id;
- $ff_doc_menu_order = get_term_meta( $t_id, 'ff_doc_menu_order', true );
- ?>
- <tr class="form-field">
- <th scope="row" valign="top">
- <label for="menu_order">Menu Order</label>
- </th>
- <td>
- <input type="number" name="ff_doc_menu_order" id="ff_doc_menu_order" style="width:80px;" value="<?php echo $ff_doc_menu_order; ?>" />
- </td>
- </tr>
- <?php
- }
- add_action( 'documentation_category_edit_form_fields', 'ff_doc_documentation_category_taxonomy_custom_fields', 10, 2 );
- // A callback function to save our extra taxonomy field(s)
- function ff_doc_save_taxonomy_custom_fields( $term_id ) {
- if ( isset( $_POST['ff_doc_menu_order'] ) ) {
- update_term_meta( $term_id, 'ff_doc_menu_order', absint( $_POST['ff_doc_menu_order'] ) );
- }
- }
- add_action( 'edited_documentation_category', 'ff_doc_save_taxonomy_custom_fields' );
- add_action( 'create_documentation_category', 'ff_doc_save_taxonomy_custom_fields' );
- function ff_doc_add_menu_order_columns( $columns ) {
- $columns['menu_order'] = 'Menu Order';
- return $columns;
- }
- add_filter( 'manage_edit-documentation_category_columns', 'ff_doc_add_menu_order_columns' );
- function ff_doc_add_menu_order_column_content($content,$column_name,$term_id){
- $term= get_term( $term_id, 'documentation_category' );
- switch ($column_name) {
- case 'menu_order':
- //do your stuff here with $term or $term_id
- $content = get_term_meta( $term_id, 'ff_doc_menu_order', true );
- break;
- default:
- break;
- }
- return $content;
- }
- add_filter( 'manage_documentation_category_custom_column', 'ff_doc_add_menu_order_column_content',10,3 );
- add_action( 'quick_edit_custom_box', 'quick_edit_add', 10, 2 );
- /**
- * Add Headline news checkbox to quick edit screen
- *
- * @param string $column_name Custom column name, used to check
- * @param string $post_type
- *
- * @return void
- */
- function quick_edit_add( $column_name, $post_type ) {
- if ( 'edit-tags' !== $post_type || 'menu_order' !== $column_name ) {
- return;
- }
- // put the term ID into a variable
- $t_id = $term->term_id;
- $ff_doc_menu_order = get_term_meta( $t_id, 'ff_doc_menu_order', true );
- ?>
- <fieldset>
- <div class="inline-edit-col">
- <label>
- <span class="title">Menu Order</span>
- <span class="input-text-wrap"><input type="number" name="ff_doc_menu_order" id="ff_doc_menu_order" style="width:80px;" value="<?php echo $ff_doc_menu_order; ?>" /></span>
- </div>
- </fieldset>
- <?php
- }
Advertisement
Add Comment
Please, Sign In to add comment