Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function places_taxonomy_add_new_meta_fields() {
- ?>
- <div class="form-field">
- <label for="term_meta[place_url_title]"><?php _e('Place URL Title',''); ?></label>
- <input type="text" name="term_meta[place_url_title]" id="term_meta[place_url_title]" size="40" value="">
- <p><?php _e('Place URL Title'); ?></p>
- </div>
- <div class="form-field term-url-wrap">
- <label for="term_meta[place_url]"><?php _e('Place URL',''); ?></label>
- <input type="url" name="term_meta[place_url]" id="term_meta[place_url]" size="40" value="">
- <p><?php _e('Oficial Website'); ?></p>
- </div>
- <?php
- }
- // Edit term page
- function places_taxonomy_edit_meta_fields($term) {
- // put the term ID into a variable
- $t_id = $term->term_id;
- // retrieve the existing value(s) for this meta field. This returns an array
- $term_meta = get_option( "taxonomy_$t_id" ); ?>
- <tr class="form-field">
- <th scope="row" valign="top"><label for="term_meta[place_title]"><?php _e( 'Place Title','' ); ?></label></th>
- <td>
- <input type="text" name="term_meta[place_title]" id="term_meta[place_title]" value="<?php echo esc_attr( $term_meta['place_title'] ) ? esc_attr( $term_meta['place_title'] ) : ''; ?>">
- <p class="description"><?php _e( 'Enter a Oficial Website Title','' ); ?></p>
- </td>
- </tr>
- <tr class="form-field">
- <th scope="row" valign="top"><label for="term_meta[place_url]"><?php _e( 'Place URL','' ); ?></label></th>
- <td>
- <input type="url" name="term_meta[place_url]" id="term_meta[place_url]" value="<?php echo esc_attr( $term_meta['place_url'] ) ? esc_attr( $term_meta['place_url'] ) : ''; ?>">
- <p class="description"><?php _e( 'Enter a Oficial Website','' ); ?></p>
- </td>
- </tr>
- <?php
- }
- // Save extra taxonomy fields callback function.
- function save_taxonomy_custom_meta( $term_id ) {
- if ( isset( $_POST['term_meta'] ) ) {
- $t_id = $term_id;
- $term_meta = get_option( "taxonomy_$t_id" );
- $cat_keys = array_keys( $_POST['term_meta'] );
- foreach ( $cat_keys as $key ) {
- if ( isset ( $_POST['term_meta'][$key] ) ) {
- $term_meta[$key] = $_POST['term_meta'][$key];
- }
- }
- // Save the option array.
- update_option( "taxonomy_$t_id", $term_meta );
- }
- }
- add_action( 'places_taxonomy_add_form_fields', 'places_taxonomy_add_new_meta_fields', 10, 2 );
- add_action( 'places_taxonomy_edit_form_fields', 'places_taxonomy_edit_meta_fields', 10, 2 );
- add_action( 'edited_places_taxonomy', 'save_taxonomy_custom_meta', 10, 2 );
- add_action( 'create_places_taxonomy', 'save_taxonomy_custom_meta', 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement