From 1f64bda199046d5e0472c63eec3d5edb442bb4e6 Mon Sep 17 00:00:00 2001 From: John Janus <mail@johnzone.org> Date: Sun, 6 Mar 2016 22:57:33 +0100 Subject: [PATCH] started to add meta fields to add show needs to be saved and shown on page --- wp-presale-plugin.php | 13 +++++++++++++ wp-show-cpt.php | 15 ++------------- wp-show-metaboxes.php | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 13 deletions(-) create mode 100644 wp-presale-plugin.php create mode 100644 wp-show-metaboxes.php diff --git a/wp-presale-plugin.php b/wp-presale-plugin.php new file mode 100644 index 0000000..1ac819b --- /dev/null +++ b/wp-presale-plugin.php @@ -0,0 +1,13 @@ +<?php +/* + * Plugin Name: Theatre Pre-Sale + * Plugin URI: https://johnzone.org/vvk + * Description: Keep track of sold tickets + * Author: John Janus + * License: GPL3 + * License URI: https://gnu.org/licenses/gpl3 + */ +defined ( 'ABSPATH' ) or die ( 'No script kiddies please!' ); + +require_once ( plugin_dir_path(__FILE__) . 'wp-show-cpt.php' ); +require_once ( plugin_dir_path(__FILE__) . 'wp-show-metaboxes.php' ); diff --git a/wp-show-cpt.php b/wp-show-cpt.php index 05bdfbb..9947122 100644 --- a/wp-show-cpt.php +++ b/wp-show-cpt.php @@ -1,13 +1,4 @@ <?php -/* - * Plugin Name: Theatre Pre-Sale - * Plugin URI: https://johnzone.org/vvk - * Description: Keep track of sold tickets - * Author: John Janus - * License: GPL3 - * License URI: https://gnu.org/licenses/gpl3 - */ -defined ( 'ABSPATH' ) or die ( 'No script kiddies please!' ); // custom post type for events @@ -53,10 +44,10 @@ function presale_create_post_type() { 'feeds' => true ), 'supports' => array ( - 'author', + #'author', 'editor', 'title', - 'custom-fields', + #'custom-fields', 'thumnails' ) ) ); @@ -95,5 +86,3 @@ function presale_register_taxonomy() { ) ) ); } - -?> diff --git a/wp-show-metaboxes.php b/wp-show-metaboxes.php new file mode 100644 index 0000000..170a6f0 --- /dev/null +++ b/wp-show-metaboxes.php @@ -0,0 +1,33 @@ +<?php + +function presale_add_custom_metabox() { + add_meta_box( + 'presale_meta', + __ ('Show Presale'), + 'presale_meta_callback', + 'presale_show', + 'normal', + 'high' + ); +} + +add_action( 'add_meta_boxes', 'presale_add_custom_metabox'); + +function presale_meta_callback( $post ) { + wp_nonce_field ( basename( __FILE__ ), 'presale_nonce'); + $presale_stored_data = get_post_meta( $post->ID); + ?> + <div> + <div class="meta-row"> + <div class="meta-th"><label for="presale-seats" class="show-title">Show ID</label></div> + <div class="meta-td"> + <input type="text" name="presale-seats" id="presale-seats" + value="<?php if (!empty ( $presale_stored_data['presal-seats'])) echo esc_attr( $presale_stored_data['presal-seats'][0] ) ?>"> + </input> + </div> + </div> + </div> + <?php +} + + -- 2.49.0