ID, 'matheson_custom_image', true );
$img_src = ( $slider_image ) ? '' : '';
// Use nonce for verification
wp_nonce_field( 'matheson_nonce', 'matheson_nonce' );
echo '
' . $img_src . '
'; echo ''; echo ''; echo '
' . __( 'Set a custom image for the header if you want to use something other than the featured image.', 'matheson' ) . '
'; } /** * Save post custom fields * * This function is attached to the 'pre_post_update' action hook. * * @since 1.0.0 */ public function pre_post_update( $post_id ) { if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return; // Check if quick edit if ( ! empty( $_POST['_inline_edit'] ) && wp_verify_nonce( $_POST['_inline_edit'], 'inlineeditnonce' ) ) return; if ( ! empty( $_POST['matheson_nonce'] ) && ! wp_verify_nonce( $_POST['matheson_nonce'], 'matheson_nonce' ) ) return; if ( ! empty( $_POST['post_type'] ) && 'page' == $_POST['post_type'] ) { if ( ! current_user_can( 'edit_page', $post_id ) ) return; } else { if ( ! current_user_can( 'edit_post', $post_id ) ) return; } // Sanitize $matheson_custom_image = ( isset( $_POST['matheson_custom_image'] ) ) ? esc_url_raw( $_POST['matheson_custom_image'] ) : ''; $this->save_meta_value( $post_id, 'matheson_custom_image', $matheson_custom_image ); } /** * Save meta helper function * * @param int $post_id The post id * @param string $name The custom field meta key * * @since 1.0.0 */ public function save_meta_value( $post_id, $name, $value ) { if ( $value ) update_post_meta( $post_id, $name, $value ); else delete_post_meta( $post_id, $name ); } } $bavotasan_custom_metaboxes = new Bavotasan_Custom_Metaboxes;