Browse Source

Remove content types from theme

develop
Chris Wiegman 2 years ago
parent
commit
2ecf85d71e
20 changed files with 0 additions and 887 deletions
  1. +0
    -7
      Gruntfile.js
  2. +0
    -28
      assets/css/sass/admin-speaking.scss
  3. BIN
      assets/css/vendor/images/ui-bg_flat_0_aaaaaa_40x100.png
  4. BIN
      assets/css/vendor/images/ui-bg_flat_75_ffffff_40x100.png
  5. BIN
      assets/css/vendor/images/ui-bg_glass_55_fbf9ee_1x400.png
  6. BIN
      assets/css/vendor/images/ui-bg_glass_65_ffffff_1x400.png
  7. BIN
      assets/css/vendor/images/ui-bg_glass_75_dadada_1x400.png
  8. BIN
      assets/css/vendor/images/ui-bg_glass_75_e6e6e6_1x400.png
  9. BIN
      assets/css/vendor/images/ui-bg_glass_95_fef1ec_1x400.png
  10. BIN
      assets/css/vendor/images/ui-bg_highlight-soft_75_cccccc_1x100.png
  11. BIN
      assets/css/vendor/images/ui-icons_222222_256x240.png
  12. BIN
      assets/css/vendor/images/ui-icons_2e83ff_256x240.png
  13. BIN
      assets/css/vendor/images/ui-icons_454545_256x240.png
  14. BIN
      assets/css/vendor/images/ui-icons_888888_256x240.png
  15. BIN
      assets/css/vendor/images/ui-icons_cd0a0a_256x240.png
  16. +0
    -7
      assets/css/vendor/jquery-ui.min.css
  17. +0
    -44
      assets/js/src/admin-speaking.js
  18. +0
    -6
      functions.php
  19. +0
    -248
      includes/classes/post-types/class-project.php
  20. +0
    -547
      includes/classes/post-types/class-speaking.php

+ 0
- 7
Gruntfile.js View File

@ -78,7 +78,6 @@ module.exports = function (grunt) {
},
files: {
'assets/css/admin-speaking.css': 'assets/css/sass/admin-speaking.scss',
'assets/css/master.css': 'assets/css/sass/master.scss',
'assets/css/editor.css': 'assets/css/sass/editor.scss'
}
@ -106,9 +105,6 @@ module.exports = function (grunt) {
'assets/js/src/progress.js',
'assets/js/src/skip-link-focus-fix.js',
'assets/js/src/scripts.js'
],
'assets/js/admin-speaking.min.js': [
'assets/js/src/admin-speaking.js'
]
}
},
@ -129,9 +125,6 @@ module.exports = function (grunt) {
'assets/js/src/progress.js',
'assets/js/src/skip-link-focus-fix.js',
'assets/js/src/scripts.js'
],
'assets/js/admin-speaking.js': [
'assets/js/src/admin-speaking.js'
]
}
}

+ 0
- 28
assets/css/sass/admin-speaking.scss View File

@ -1,28 +0,0 @@
.speaking-fields {
width: 100%;
td.header {
background-color: #f5f5f5;
border-bottom: 1px solid #ccc;
padding: 2px;
a {
float: right;
text-decoration: none;
border: none;
}
}
}
.form-table {
margin: 0 10%;
width: 80%;
border: 1px solid #ccc;
th {
padding-left: 10px;
}
}

BIN
assets/css/vendor/images/ui-bg_flat_0_aaaaaa_40x100.png View File

Before After
Width: 40  |  Height: 100  |  Size: 212 B

BIN
assets/css/vendor/images/ui-bg_flat_75_ffffff_40x100.png View File

Before After
Width: 40  |  Height: 100  |  Size: 208 B

BIN
assets/css/vendor/images/ui-bg_glass_55_fbf9ee_1x400.png View File

Before After
Width: 1  |  Height: 400  |  Size: 335 B

BIN
assets/css/vendor/images/ui-bg_glass_65_ffffff_1x400.png View File

Before After
Width: 1  |  Height: 400  |  Size: 207 B

BIN
assets/css/vendor/images/ui-bg_glass_75_dadada_1x400.png View File

Before After
Width: 1  |  Height: 400  |  Size: 262 B

BIN
assets/css/vendor/images/ui-bg_glass_75_e6e6e6_1x400.png View File

Before After
Width: 1  |  Height: 400  |  Size: 262 B

BIN
assets/css/vendor/images/ui-bg_glass_95_fef1ec_1x400.png View File

Before After
Width: 1  |  Height: 400  |  Size: 332 B

BIN
assets/css/vendor/images/ui-bg_highlight-soft_75_cccccc_1x100.png View File

Before After
Width: 1  |  Height: 100  |  Size: 280 B

BIN
assets/css/vendor/images/ui-icons_222222_256x240.png View File

Before After
Width: 256  |  Height: 240  |  Size: 6.8 KiB

BIN
assets/css/vendor/images/ui-icons_2e83ff_256x240.png View File

Before After
Width: 256  |  Height: 240  |  Size: 4.4 KiB

BIN
assets/css/vendor/images/ui-icons_454545_256x240.png View File

Before After
Width: 256  |  Height: 240  |  Size: 6.8 KiB

BIN
assets/css/vendor/images/ui-icons_888888_256x240.png View File

Before After
Width: 256  |  Height: 240  |  Size: 6.8 KiB

BIN
assets/css/vendor/images/ui-icons_cd0a0a_256x240.png View File

Before After
Width: 256  |  Height: 240  |  Size: 4.4 KiB

+ 0
- 7
assets/css/vendor/jquery-ui.min.css
File diff suppressed because it is too large
View File


+ 0
- 44
assets/js/src/admin-speaking.js View File

@ -1,44 +0,0 @@
jQuery(document).ready(function ($) {
function handleMulti() {
// Setup repeating form field add handler.
$(document.getElementById('add-row')).on('click', function () {
var row = $('.empty-row.screen-reader-text').clone(true);
row.removeClass('empty-row screen-reader-text');
row.insertBefore('#repeatable-fieldset tbody>tr.main:last');
$('.date-field').each(function () {
if (0 === $(this).closest('.empty-row').length) {
$(this).datepicker('destroy');
$(this).datepicker();
}
});
return false;
});
}
handleMulti();
// Setup repeating form field remove handler
$('.remove-row').on('click', function () {
$(this).closest('tr.main').remove();
return false;
});
$('.date-field').each(function () {
$(this).datepicker();
});
});

+ 0
- 6
functions.php View File

@ -21,12 +21,6 @@ define( 'CW_THEME_INCLUDES', CW_THEME_PATH . 'includes/' );
require CW_THEME_INCLUDES . 'functions/core.php';
require CW_THEME_INCLUDES . 'functions/template-tags.php';
require CW_THEME_INCLUDES . 'classes/widgets/class-latest-tweets.php';
require CW_THEME_INCLUDES . 'classes/post-types/class-project.php';
require CW_THEME_INCLUDES . 'classes/post-types/class-speaking.php';
// Instantiate required classes.
new Post_Types\Project();
new Post_Types\Speaking();
// Use a CDN if properly defined.
if ( defined( 'CW_USE_CDN' ) && true === CW_USE_CDN ) {

+ 0
- 248
includes/classes/post-types/class-project.php View File

@ -1,248 +0,0 @@
<?php
/**
* Set up "Project" Custom Post Type
*
* Sets up a project Custom Post Type to save project data.
*
* @since 1.0.0
*
* @package ChrisWiegman
*/
namespace CW\Theme\Post_Types;
/**
* Class Project
*/
class Project {
/**
* Register functions
*
* Initializes CPTs and registers hooks.
*
* @since 1.0.0
*/
public function __construct() {
add_action( 'init', array( $this, 'project_taxonomy' ) );
add_action( 'init', array( $this, 'create_project_type' ) );
add_action( 'save_post', array( $this, 'project_save_meta' ), 10, 2 );
}
/**
* Adds meta box
*
* Adds the metabox for the Project CPT.
*
* @since 1.0.0
*/
public function add_project_metabox() {
add_meta_box(
'project',
__( 'Project URL', 'chriswiegman' ),
array( $this, 'project_metabox' ),
'project',
'normal',
'high'
);
}
/**
* Register the post type
*
* Registers the "project" CPT.
*
* @since 1.0.0
*/
public function create_project_type() {
register_post_type(
'project',
array(
'labels' => array(
'name' => esc_html_x( 'Projects', 'post type general name', 'chriswiegman' ),
'singular_name' => esc_html_x( 'Project', 'post type singular name', 'chriswiegman' ),
'menu_name' => esc_html_x( 'Projects', 'admin menu', 'chriswiegman' ),
'name_admin_bar' => esc_html_x( 'Project', 'add new on admin bar', 'chriswiegman' ),
'add_new' => esc_html_x( 'Add New', 'book', 'chriswiegman' ),
'add_new_item' => esc_html__( 'Add New Project', 'chriswiegman' ),
'new_item' => esc_html__( 'New Project', 'chriswiegman' ),
'edit_item' => esc_html__( 'Edit Project', 'chriswiegman' ),
'view_item' => esc_html__( 'View Project', 'chriswiegman' ),
'all_items' => esc_html__( 'All Projects', 'chriswiegman' ),
'search_items' => esc_html__( 'Search Projects', 'chriswiegman' ),
'parent_item_colon' => esc_html__( 'Parent Projects:', 'chriswiegman' ),
'not_found' => esc_html__( 'No projects found.', 'chriswiegman' ),
'not_found_in_trash' => esc_html__( 'No projects found in Trash.', 'chriswiegman' ),
),
'description' => esc_html__( 'A place to list ongoing and archived projects', 'chriswiegman' ),
'public' => true,
'has_archive' => false,
'exclude_form_search' => true,
'publicly_queryable' => false,
'rewrite' => false,
'capability_type' => 'post',
'supports' => array(
'title',
'editor',
),
'taxonomies' => array( 'project_type' ),
'register_meta_box_cb' => array( $this, 'add_project_metabox' ),
'menu_icon' => 'dashicons-welcome-view-site',
'menu_position' => 20,
)
);
}
/**
* Echo metabox content
*
* Echos the content of the metabox for this CPT.
*
* @since 1.0.0
*/
public function project_metabox() {
global $post;
// Create nonce.
echo '<input type="hidden" name="project_post_noncename" id="project_post_noncename" value="' . esc_attr( wp_create_nonce( plugin_basename( __FILE__ ) ) ) . '" />';
echo '<table class="form-table">';
// Get URL data.
$project_url = get_post_meta( $post->ID, '_project_url', true );
?>
<tr class="width_normal p_box">
<th scope="row"><label for="project_url"><?php esc_html_e( 'URL', 'chriswiegman' ); ?></label></th>
<td>
<input type="text" id="project_url" name="project_url" class="large-text" value="<?php echo esc_url( $project_url ); ?>">
</td>
</tr>
<?php
echo '</table>';
}
/**
* Save post data
*
* Saves the custom post data as meta information.
*
* @since 1.0.0
*
* @param int $post_id ID of the current post.
* @param \WP_POST $post The current post.
*
* @return int post ID on failure or void on success
*/
public function project_save_meta( $post_id, $post ) {
// @codingStandardsIgnoreStart
// Verify nonce.
if ( ! isset( $_POST['project_post_noncename'] ) || ! wp_verify_nonce( $_POST['project_post_noncename'], plugin_basename( __FILE__ ) ) ) {
return $post_id;
}
// Verify credentials.
if ( ! current_user_can( 'edit_post', $post->ID ) ) {
return $post_id;
}
$project_post_meta['_project_url'] = esc_url( $_POST['project_url'] );
// Add values as custom fields.
foreach ( $project_post_meta as $key => $value ) { // Cycle through the $quote_post_meta array.
$value = implode( ',', (array) $value ); // If $value is an array, make it a CSV (unlikely).
if ( get_post_meta( $post->ID, $key, false ) ) { // If the custom field already has a value.
update_post_meta( $post->ID, $key, $value );
} else { // If the custom field doesn't have a value.
add_post_meta( $post->ID, $key, $value );
}
if ( ! $value ) { // Delete if blank.
delete_post_meta( $post->ID, $key );
}
}
return null;
// @codingStandardsIgnoreEnd
}
/**
* Setup taxonomies
*
* Sets up and registers taxonomies for the project post type.
*
* @since 1.0.0
*/
public function project_taxonomy() {
// Type taxonomy.
$type_labels = array(
'name' => esc_html_x( 'Project Types', 'taxonomy general name' ),
'singular_name' => esc_html_x( 'Project Type', 'taxonomy singular name' ),
'search_items' => esc_html__( 'Search Project Types' ),
'all_items' => esc_html__( 'All Project Types' ),
'parent_item' => esc_html__( 'Parent Project Type' ),
'parent_item_colon' => esc_html__( 'Parent Project Type:' ),
'edit_item' => esc_html__( 'Edit Project Type' ),
'update_item' => esc_html__( 'Update Project Type' ),
'add_new_item' => esc_html__( 'Add New Project Type' ),
'new_item_name' => esc_html__( 'New Project Type Name' ),
'menu_name' => esc_html__( 'Type' ),
);
$type_args = array(
'hierarchical' => true,
'labels' => $type_labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
);
register_taxonomy( 'project-type', 'project', $type_args );
// Status Taxonomy.
$status_labels = array(
'name' => esc_html_x( 'Project Status', 'taxonomy general name' ),
'singular_name' => esc_html_x( 'Project Status', 'taxonomy singular name' ),
'search_items' => esc_html__( 'Search Project Statuses' ),
'all_items' => esc_html__( 'All Project Statuses' ),
'parent_item' => esc_html__( 'Parent Project Status' ),
'parent_item_colon' => esc_html__( 'Parent Project Status:' ),
'edit_item' => esc_html__( 'Edit Project Status' ),
'update_item' => esc_html__( 'Update Project Status' ),
'add_new_item' => esc_html__( 'Add New Project Status' ),
'new_item_name' => esc_html__( 'New Project Status Name' ),
'menu_name' => esc_html__( 'Status' ),
);
$status_args = array(
'hierarchical' => true,
'labels' => $status_labels,
'show_ui' => true,
'show_admin_column' => true,
'query_var' => true,
);
register_taxonomy( 'project-status', 'project', $status_args );
}
}

+ 0
- 547
includes/classes/post-types/class-speaking.php View File

@ -1,547 +0,0 @@
<?php
/**
* Set up "Speaking" Custom Post Type
*
* Sets up a speaking Custom Post Type to save speaking data.
*
* @since 1.0.0
*
* @package chriswiegman
*/
namespace CW\Theme\Post_Types;
/**
* Class Speaking
*/
class Speaking {
/**
* Register functions
*
* Initializes CPTs and registers hooks.
*
* @since 1.0.0
*/
public function __construct() {
add_action( 'init', array( $this, 'create_speaking_type' ) );
add_action( 'save_post', array( $this, 'speaking_save_meta' ), 10, 2 );
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
add_action( 'pre_get_posts', array( $this, 'action_pre_get_posts' ) );
add_filter( 'manage_speaking_posts_columns', array( $this, 'speaking_edit_columns' ) );
add_action( 'manage_speaking_posts_custom_column', array( $this, 'speaking_custom_columns' ), 10, 2 );
add_filter( 'manage_edit-speaking_sortable_columns', array( $this, 'speaking_sortable_columns' ) );
}
/**
* Action pre_get_posts
*
* Sort speaking gigs by the appropriate columns.
*
* @since 3.1.0
*
* @param \WP_Query $query The query object.
*/
public function action_pre_get_posts( $query ) {
/**
* We only want our code to run in the main WP query
* AND if an orderby query variable is designated.
*/
if ( $query->is_main_query() && ( $orderby = $query->get( 'orderby' ) ) ) {
switch ( $orderby ) {
case 'location':
$query->set( 'meta_key', '_conference_location' );
break;
case 'conference':
$query->set( 'meta_key', '_conference_name' );
break;
case 'conference_date':
$query->set( 'meta_key', '_presentation_date' );
break;
}
$query->set( 'orderby', 'meta_value' );
}
}
/**
* Adds meta box
*
* Adds the metabox for the Speaking CPT.
*
* @since 1.0.0
*/
public function add_speaking_metabox() {
add_meta_box(
'speaking',
esc_html__( 'Talk Information', 'chriswiegman' ),
array( $this, 'speaking_metabox' ),
'speaking',
'normal',
'high'
);
}
/**
* Add CSS and JS
*
* Adds CSS and JS for the speaking content type.
*
* @since 1.0.0
*/
public function admin_enqueue_scripts() {
if ( isset( get_current_screen()->id ) && false !== strpos( get_current_screen()->id, 'speaking' ) ) {
wp_register_style( 'cw-jquery-ui-css', CW_THEME_URL . '/assets/css/vendor/jquery-ui.min.css', array(), '1.11.4' );
wp_enqueue_style( 'cw-jquery-ui-css' );
wp_enqueue_script( 'jquery-ui-datepicker' );
$min = ( defined( 'SCRIPT_DEBUG' ) && true === SCRIPT_DEBUG ) ? '' : '.min';
wp_register_style( 'chriswiegman-speaking', CW_THEME_URL . '/assets/css/admin-speaking' . $min . '.css', array(), CW_THEME_VERSION );
wp_enqueue_style( 'chriswiegman-speaking' );
wp_register_script( 'chriswiegman-speaking', CW_THEME_URL . '/assets/js/admin-speaking' . $min . '.js', array( 'jquery-ui-datepicker' ), CW_THEME_VERSION );
wp_enqueue_script( 'chriswiegman-speaking' );
}
}
/**
* Register the post type
*
* Registers the "speaking" CPT.
*
* @since 1.0.0
*/
public function create_speaking_type() {
register_post_type(
'speaking',
array(
'labels' => array(
'name' => esc_html_x( 'Speaking Gigs', 'post type general name', 'chriswiegman' ),
'singular_name' => esc_html_x( 'Speaking Gig', 'post type singular name', 'chriswiegman' ),
'menu_name' => esc_html_x( 'Speaking Gigs', 'admin menu', 'chriswiegman' ),
'name_admin_bar' => esc_html_x( 'Speaking Gigs', 'add new on admin bar', 'chriswiegman' ),
'add_new' => esc_html_x( 'Add New', 'book', 'chriswiegman' ),
'add_new_item' => esc_html__( 'Add New Speaking Gig', 'chriswiegman' ),
'new_item' => esc_html__( 'New Speaking Gig', 'chriswiegman' ),
'edit_item' => esc_html__( 'Edit Speaking Gig', 'chriswiegman' ),
'view_item' => esc_html__( 'View Speaking Gig', 'chriswiegman' ),
'all_items' => esc_html__( 'All Speaking Gigs', 'chriswiegman' ),
'search_items' => esc_html__( 'Search Speaking Gigs', 'chriswiegman' ),
'parent_item_colon' => esc_html__( 'Parent Speaking Gigs:', 'chriswiegman' ),
'not_found' => esc_html__( 'No speaking gigs found.', 'chriswiegman' ),
'not_found_in_trash' => esc_html__( 'No speaking gigs found in Trash.', 'chriswiegman' ),
),
'description' => esc_html__( 'A place to list speaking gigs.', 'chriswiegman' ),
'public' => true,
'has_archive' => false,
'capability_type' => 'post',
'supports' => array(
'title',
'editor',
'thumbnail',
),
'exclude_form_search' => true,
'publicly_queryable' => false,
'rewrite' => false,
'register_meta_box_cb' => array( $this, 'add_speaking_metabox' ),
'menu_icon' => 'dashicons-megaphone',
'menu_position' => 20,
)
);
}
/**
* Output columns
*
* Outputs the speaking data columns.
*
* @since 2.2.0
*
* @param array $column array of column info.
* @param int $post_id The post ID.
*/
public function speaking_custom_columns( $column, $post_id ) {
switch ( $column ) {
case 'location':
$conference_location = get_post_meta( $post_id, '_conference_location', true );
echo esc_html( $conference_location );
break;
case 'conference_date':
$raw_presentation_date = get_post_meta( $post_id, '_presentation_date', true );
$presentation_date = empty( $raw_presentation_date ) ? '' : date( 'F Y', $raw_presentation_date );
echo esc_html( $presentation_date );
break;
case 'conference':
$conference_name = get_post_meta( $post_id, '_conference_name', true );
$conference_url = get_post_meta( get_the_ID(), '_conference_url', true );
if ( empty( $conference_url ) ) {
echo esc_html( $conference_name );
} else {
printf(
'<a href="%s" title="%s" target="_blank">%s</a>',
esc_url( $conference_url ),
esc_attr( $conference_name ),
esc_html( $conference_name )
);
}
break;
}
}
/**
* Set data columns
*
* Set columns on speaking table.
*
* @since 2.2.0
*
* @return array Array of columns
*/
public function speaking_edit_columns() {
$columns = array(
'cb' => 'input type="checkbox"',
'title' => 'Speaking Title',
'conference' => 'Conference',
'conference_date' => 'Conference Date',
'location' => 'Location',
);
return $columns;
}
/**
* Echo metabox content
*
* Echos the content of the metabox for this CPT.
*
* @since 1.0.0
*/
public function speaking_metabox() {
global $post;
// Create nonce.
echo '<input type="hidden" name="speaking_post_noncename" id="speaking_post_noncename" value="' . esc_attr( wp_create_nonce( plugin_basename( __FILE__ ) ) ) . '" />';
?>
<table id="repeatable-fieldset" class="speaking-fields">
<?php
// Get conference name.
$conference_names = get_post_meta( $post->ID, '_conference_name' );
$conference_urls = get_post_meta( $post->ID, '_conference_url' );
$slide_urls = get_post_meta( $post->ID, '_slide_url' );
$presentation_urls = get_post_meta( $post->ID, '_presentation_url' );
$raw_presentation_dates = get_post_meta( $post->ID, '_presentation_date' );
$conference_locations = get_post_meta( $post->ID, '_conference_location' );
foreach ( $conference_names as $index => $conference_name ) {
$conference_url = isset( $conference_urls[ $index ] ) ? $conference_urls[ $index ] : '';
$slide_url = isset( $slide_urls[ $index ] ) ? $slide_urls[ $index ] : '';
$presentation_url = isset( $presentation_urls[ $index ] ) ? $presentation_urls[ $index ] : '';
$raw_presentation_date = isset( $raw_presentation_dates[ $index ] ) ? $raw_presentation_dates[ $index ] : current_time( 'timestamp' );
$conference_location = isset( $conference_locations[ $index ] ) ? $conference_locations[ $index ] : '';
?>
<tr class="main">
<td>
<table class="form-table">
<tr>
<td class="header" colspan="2">
<a class="remove-row" title="<?php esc_html_e( 'Remove', 'chriswiegman' ); ?>" href="#"><span class="dashicons dashicons-no"></span></a>
</td>
</tr>
<tr class="width_normal p_box">
<th scope="row">
<label for="conference_name"><?php esc_html_e( 'Conference Name', 'chriswiegman' ); ?></label>
</th>
<td>
<input type="text" id="conference_name" name="conference_name[]" class="large-text" value="<?php echo esc_attr( $conference_name ); ?>">
</td>
</tr>
<tr class="width_normal p_box">
<th scope="row">
<label for="conference_url"><?php esc_html_e( 'Conference URL', 'chriswiegman' ); ?></label>
</th>
<td>
<input type="text" id="conference_url" name="conference_url[]" class="large-text" value="<?php echo esc_url( $conference_url ); ?>">
</td>
</tr>
<tr class="width_normal p_box">
<th scope="row">
<label for="slide_url"><?php esc_html_e( 'Slide URL', 'chriswiegman' ); ?></label>
</th>
<td>
<input type="text" id="slide_url" name="slide_url[]" class="large-text" value="<?php echo esc_url( $slide_url ); ?>">
</td>
</tr>
<tr class="width_normal p_box">
<th scope="row">
<label for="presentation_url"><?php esc_html_e( 'Presentation URL', 'chriswiegman' ); ?></label>
</th>
<td>
<input type="text" id="presentation_url" name="presentation_url[]" class="large-text" value="<?php echo esc_url( $presentation_url ); ?>">
</td>
</tr>
<?php $presentation_date = empty( $raw_presentation_date ) ? current_time( 'm/d/Y' ) : date( 'm/d/Y', $raw_presentation_date ); ?>
<tr class="width_normal p_box">
<th scope="row">
<label for="presentation_date"><?php esc_html_e( 'Presentation Date', 'chriswiegman' ); ?></label>
</th>
<td>
<input type="text" id="presentation_date" name="presentation_date[]" class="medium-text date-field" value="<?php echo esc_attr( $presentation_date ); ?>">
</td>
</tr>
<tr class="width_normal p_box">
<th scope="row">
<label for="conference_location"><?php esc_html_e( 'Conference Location', 'chriswiegman' ); ?></label>
</th>
<td>
<input type="text" id="conference_location" name="conference_location[]" class="medium-text" value="<?php echo esc_attr( $conference_location ); ?>">
</td>
</tr>
</table>
</td>
</tr>
<?php } ?>
<!-- empty hidden one for jQuery -->
<tr class="main empty-row screen-reader-text">
<td>
<table class="form-table">
<tr>
<td class="header" colspan="2">
<a class="remove-row" title="<?php esc_html_e( 'Remove', 'chriswiegman' ); ?>" href="#"><span class="dashicons dashicons-no"></span></a>
</td>
</tr>
<tr class="width_normal p_box">
<th scope="row">
<label for="conference_name"><?php esc_html_e( 'Conference Name', 'chriswiegman' ); ?></label>
</th>
<td>
<input type="text" id="conference_name" name="conference_name[]" class="large-text">
</td>
</tr>
<tr class="width_normal p_box">
<th scope="row">
<label for="conference_url"><?php esc_html_e( 'Conference URL', 'chriswiegman' ); ?></label>
</th>
<td>
<input type="text" id="conference_url" name="conference_url[]" class="large-text">
</td>
</tr>
<tr class="width_normal p_box">
<th scope="row">
<label for="slide_url"><?php esc_html_e( 'Slide URL', 'chriswiegman' ); ?></label>
</th>
<td>
<input type="text" id="slide_url" name="slide_url[]" class="large-text">
</td>
</tr>
<tr class="width_normal p_box">
<th scope="row">
<label for="presentation_url"><?php esc_html_e( 'Presentation URL', 'chriswiegman' ); ?></label>
</th>
<td>
<input type="text" id="presentation_url" name="presentation_url[]" class="large-text">
</td>
</tr>
<tr class="width_normal p_box">
<th scope="row">
<label for="presentation_date"><?php esc_html_e( 'Presentation Date', 'chriswiegman' ); ?></label>
</th>
<td>
<input type="text" id="presentation_date" name="presentation_date[]" class="medium-text date-field" value="<?php echo current_time( 'm/d/Y' ); ?>">
</td>
</tr>
<tr class="width_normal p_box">
<th scope="row">
<label for="conference_location"><?php esc_html_e( 'Conference Location', 'chriswiegman' ); ?></label>
</th>
<td>
<input type="text" id="conference_location" name="conference_location[]" class="medium-text">
</td>
</tr>
</table>
</td>
</tr>
</table>
<p>
<a id="add-row" class="button" href="#"><?php esc_html_e( 'Add Presentation', 'chriswiegman' ); ?></a>
</p>
<p class="description"><?php esc_html_e( 'Use the "Add Presentation" or "Remove" buttons to add one or more presentations of this talk.', 'chriswiegman' ); ?></p>
<?php
}
/**
* Save post data
*
* Saves the custom post data as meta information.
*
* @since 1.0.0
*
* @param int $post_id ID of the current post.
* @param \WP_POST $post The current post.
*
* @return int|void post ID on failure or void on success
*/
public function speaking_save_meta( $post_id, $post ) {
// @codingStandardsIgnoreStart
// Verify nonce.
if ( ! isset( $_POST['speaking_post_noncename'] ) || ! wp_verify_nonce( $_POST['speaking_post_noncename'], plugin_basename( __FILE__ ) ) ) {
return $post_id;
}
// Verify credentials.
if ( ! current_user_can( 'edit_post', $post->ID ) ) {
return $post_id;
}
// Sanitize all the talk meta.
$project_post_meta['_slide_url'] = array_map( function ( $slide_url ) {
return esc_url( $slide_url );
}, $_POST['slide_url'] );
$project_post_meta['_presentation_url'] = array_map( function ( $presentation_url ) {
return esc_url( $presentation_url );
}, $_POST['presentation_url'] );
$project_post_meta['_conference_url'] = array_map( function ( $conference_url ) {
return esc_url( $conference_url );
}, $_POST['conference_url'] );
$project_post_meta['_conference_name'] = array_map( function ( $conference_name ) {
return sanitize_text_field( $conference_name );
}, $_POST['conference_name'] );
$project_post_meta['_conference_location'] = array_map( function ( $conference_location ) {
return sanitize_text_field( $conference_location );
}, $_POST['conference_location'] );
$project_post_meta['_presentation_date'] = array_map( function ( $presentation_date ) {
return strtotime( $presentation_date );
}, $_POST['presentation_date'] );
// Ensure each is a valid conference and remove if it isn't
foreach ( $project_post_meta['_conference_name'] as $index => $conference ) {
if ( empty( $conference ) ) {
foreach ( $project_post_meta as $array_index => $array ) {
unset( $project_post_meta[ $array_index ][ $index ] );
}
}
}
// Add values as custom fields.
foreach ( $project_post_meta as $key => $value_array ) {
delete_post_meta( $post->ID, $key );
foreach ( $value_array as $value ) {
add_post_meta( $post->ID, $key, $value );
}
}
return null;
// @codingStandardsIgnoreEnd
}
/**
* Filter sortable table comments
*
* Adds time and conference to sortables.
*
* @since 3.1.0
*
* @param array $sortable_columns Array of sortable columns.
*
* @return array Filtered array of sortable columns.
*/
public function speaking_sortable_columns( $sortable_columns ) {
$sortable_columns['location'] = 'location';
$sortable_columns['conference_date'] = 'conference_date';
$sortable_columns['conference'] = 'conference';
return $sortable_columns;
}
}