';
echo ' ';
echo '
';
echo '
' . __( 'The hex color of the region title.', 'text_domain' ) . '
';
echo '';
echo '';
echo '';
}
public function edit_screen_fields( $term, $taxonomy ) {
// Retrieve an existing value from the database.
$region_title_color = get_term_meta( $term->term_id, 'region_title_color', true );
$region_title_tag = get_term_meta( $term->term_id, 'region_title_tag', true );
$region_video = get_term_meta( $term->term_id, 'region_video', true );
// Set default values.
if( empty( $region_title_color ) ) $region_title_color = '';
if( empty( $region_title_tag ) ) $region_title_tag = '';
if( empty( $region_video ) ) $region_video = '';
// Form fields.
echo '';
echo '';
echo ' ';
echo ' | ';
echo '';
echo ' ';
echo ' ' . __( 'The hex color of the region title.', 'text_domain' ) . ' ';
echo ' | ';
echo '
';
echo '';
echo '';
echo ' ';
echo ' | ';
echo '';
echo ' ';
echo ' ' . __( 'The HTML tag used to show the title.', 'text_domain' ) . ' ';
echo ' | ';
echo '
';
echo '';
echo '';
echo ' ';
echo ' | ';
echo '';
echo ' ';
echo wp_oembed_get( $region_video );
echo ' ' . __( 'Region descriptive video.', 'text_domain' ) . ' ';
echo ' | ';
echo '
';
}
public function save_data( $term_id ) {
// Sanitize user input.
$region_new_title_color = isset( $_POST[ 'region_title_color' ] ) ? sanitize_hex_color( $_POST[ 'region_title_color' ] ) : '';
$region_new_title_tag = isset( $_POST[ 'region_title_tag' ] ) ? $_POST[ 'region_title_tag' ] : '';
$region_new_video = isset( $_POST[ 'region_video' ] ) ? esc_url( $_POST[ 'region_video' ] ) : '';
// Update the meta field in the database.
update_term_meta( $term_id, 'region_title_color', $region_new_title_color );
update_term_meta( $term_id, 'region_title_tag', $region_new_title_tag );
update_term_meta( $term_id, 'region_video', $region_new_video );
}
public function load_scripts_styles() {
// Color picker
wp_enqueue_script( 'wp-color-picker' );
wp_enqueue_style( 'wp-color-picker' );
}
public function add_admin_js() {
// Print js only once per page
if ( did_action( 'Region_Term_Meta_js' ) >= 1 ) {
return;
}
?>