generated from bisco/codex-bootstrap
fix: expose show card description field
This commit is contained in:
@@ -58,6 +58,11 @@ function azionelab_show_meta_box( WP_Post $post ): void {
|
||||
$year = get_post_meta( $post->ID, 'azl_show_year', true );
|
||||
$location = get_post_meta( $post->ID, 'azl_show_location', true );
|
||||
?>
|
||||
<p>
|
||||
<label for="azl_show_excerpt"><strong>Descrizione breve</strong></label><br>
|
||||
<textarea id="azl_show_excerpt" name="azl_show_excerpt" class="widefat" rows="4"><?php echo esc_textarea( $post->post_excerpt ); ?></textarea>
|
||||
<span class="description">Questo testo appare nella card dello spettacolo in homepage.</span>
|
||||
</p>
|
||||
<p><label for="azl_show_year"><strong>Anno</strong></label><br><input id="azl_show_year" name="azl_show_year" type="number" min="1900" max="2100" value="<?php echo esc_attr( $year ); ?>"></p>
|
||||
<p><label for="azl_show_location"><strong>Luogo</strong></label><br><input id="azl_show_location" name="azl_show_location" type="text" class="widefat" value="<?php echo esc_attr( $location ); ?>"></p>
|
||||
<?php
|
||||
@@ -90,10 +95,19 @@ function azionelab_save_meta( int $post_id ): void {
|
||||
|
||||
$post_type = get_post_type( $post_id );
|
||||
if ( 'azl_show' === $post_type ) {
|
||||
$excerpt = isset( $_POST['azl_show_excerpt'] ) ? sanitize_textarea_field( wp_unslash( $_POST['azl_show_excerpt'] ) ) : '';
|
||||
$year = isset( $_POST['azl_show_year'] ) ? absint( $_POST['azl_show_year'] ) : 0;
|
||||
$location = isset( $_POST['azl_show_location'] ) ? sanitize_text_field( wp_unslash( $_POST['azl_show_location'] ) ) : '';
|
||||
update_post_meta( $post_id, 'azl_show_year', $year );
|
||||
update_post_meta( $post_id, 'azl_show_location', $location );
|
||||
remove_action( 'save_post', 'azionelab_save_meta' );
|
||||
wp_update_post(
|
||||
array(
|
||||
'ID' => $post_id,
|
||||
'post_excerpt' => $excerpt,
|
||||
)
|
||||
);
|
||||
add_action( 'save_post', 'azionelab_save_meta' );
|
||||
} elseif ( 'azl_gallery' === $post_type ) {
|
||||
$allowed = array( 'Lezioni', 'Backstage', 'Spettacoli', 'Gruppo' );
|
||||
$category = isset( $_POST['azl_gallery_category'] ) ? sanitize_text_field( wp_unslash( $_POST['azl_gallery_category'] ) ) : '';
|
||||
|
||||
Reference in New Issue
Block a user