__( 'Visitor Note (example)', 'acme-calendarwp-note' ), 'description' => __( 'Public notes on event cards and in event knowledge.', 'acme-calendarwp-note' ), 'default' => '0', 'plugin_file' => 'acme-calendarwp-note/acme-calendarwp-note.php', 'admin_url' => admin_url( 'edit.php?post_type=' . RHC_EVENT_POST_TYPE ), 'admin_label' => __( 'Edit events', 'acme-calendarwp-note' ), ); return $addons; } function acme_cwp_note_box() { add_meta_box( 'acme-cwp-note', __( 'Public visitor note', 'acme-calendarwp-note' ), 'acme_cwp_note_box_html', RHC_EVENT_POST_TYPE, 'normal', 'default' ); } function acme_cwp_note_box_html( $post ) { wp_nonce_field( 'acme_cwp_note_save', 'acme_cwp_note_nonce' ); echo '

'; echo ''; } function acme_cwp_note_save( $post_id ) { if ( wp_is_post_revision( $post_id ) || wp_is_post_autosave( $post_id ) || ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ! current_user_can( 'edit_post', $post_id ) || ! isset( $_POST['acme_cwp_note_nonce'], $_POST['acme_cwp_public_note'] ) || ! is_string( $_POST['acme_cwp_note_nonce'] ) || ! is_string( $_POST['acme_cwp_public_note'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['acme_cwp_note_nonce'] ) ), 'acme_cwp_note_save' ) ) { return; } $note = sanitize_textarea_field( wp_unslash( $_POST['acme_cwp_public_note'] ) ); $note = function_exists( 'mb_substr' ) ? mb_substr( $note, 0, 600 ) : substr( $note, 0, 600 ); update_post_meta( $post_id, '_acme_cwp_public_note', $note ); } function acme_cwp_note_text( $post_id ) { $note = get_post_meta( $post_id, '_acme_cwp_public_note', true ); return is_string( $note ) ? trim( $note ) : ''; } function acme_cwp_note_card( $meta, $event_id ) { $note = acme_cwp_note_text( $event_id ); if ( is_array( $meta ) && '' !== $note ) { $meta[] = '' . esc_html( $note ) . ''; } return $meta; } function acme_cwp_note_knowledge( $sections, $event_id ) { $note = acme_cwp_note_text( $event_id ); if ( is_array( $sections ) && '' !== $note ) { $sections['acme-public-note'] = array( 'title' => __( 'Visitor note', 'acme-calendarwp-note' ), 'text' => wp_strip_all_tags( $note ), ); } return $sections; }