Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

custom sources rank

class Custom_Term_Meta {

	public function __construct() {

		if ( is_admin() ) {

			add_action( 'sources_add_form_fields',  array( $this, 'create_screen_fields'), 10, 1 );
			add_action( 'sources_edit_form_fields', array( $this, 'edit_screen_fields' ),  10, 2 );

			add_action( 'created_sources', array( $this, 'save_data' ), 10, 1 );
			add_action( 'edited_sources',  array( $this, 'save_data' ), 10, 1 );

		}

	}

	public function create_screen_fields( $taxonomy ) {

		// Set default values.
		$custom_sources-rank = '';

		// Form fields.
		echo '<div class="form-field term-custom_sources-rank-wrap">';
		echo '	<label for="custom_sources-rank">' . __( 'sources_rank', 'text_domain' ) . '</label>';
		echo '	<input type="number" id="custom_sources-rank" name="custom_sources-rank" placeholder="' . esc_attr__( 'rank', 'text_domain' ) . '" value="' . esc_attr( $custom_sources-rank ) . '">';
		echo '</div>';

	}

	public function edit_screen_fields( $term, $taxonomy ) {

		// Retrieve an existing value from the database.
		$custom_sources-rank = get_term_meta( $term->term_id, 'custom_sources-rank', true );

		// Set default values.
		if( empty( $custom_sources-rank ) ) $custom_sources-rank = '';

		// Form fields.
		echo '<tr class="form-field term-custom_sources-rank-wrap">';
		echo '<th scope="row">';
		echo '	<label for="custom_sources-rank">' . __( 'sources_rank', 'text_domain' ) . '</label>';
		echo '</th>';
		echo '<td>';
		echo '	<input type="number" id="custom_sources-rank" name="custom_sources-rank" placeholder="' . esc_attr__( 'rank', 'text_domain' ) . '" value="' . esc_attr( $custom_sources-rank ) . '">';
		echo '</td>';
		echo '</tr>';

	}

	public function save_data( $term_id ) {

		// Sanitize user input.
		$custom_new_sources-rank = isset( $_POST[ 'custom_sources-rank' ] ) ? floatval( $_POST[ 'custom_sources-rank' ] ) : '';

		// Update the meta field in the database.
		update_term_meta( $term_id, 'custom_sources-rank', $custom_new_sources-rank );

	}

}

new Custom_Term_Meta;