Пример #1
0
/**
 * Display custom venue submit meta box.
 *
 * @since 1.0.0
 *
 * @param WP_Post $post Venue post object.
 */
function audiotheme_venue_submit_meta_box($post)
{
    $post = empty($post) ? get_default_post_to_edit('audiotheme_venue') : $post;
    $post_type = $post->post_type;
    $post_type_object = get_post_type_object($post_type);
    $can_publish = current_user_can($post_type_object->cap->publish_posts);
    ?>
	<div class="submitbox" id="submitpost">

		<div id="major-publishing-actions">

			<?php 
    if ('auto-draft' !== $post->post_status && 'draft' !== $post->post_status) {
        ?>
				<div id="delete-action">
					<?php 
        if (current_user_can($post_type_object->cap->delete_post, $post->ID)) {
            $delete_args['action'] = 'delete';
            $delete_args['venue_id'] = $post->ID;
            $delete_url = get_audiotheme_venues_admin_url($delete_args);
            $delete_url_onclick = " onclick=\"return confirm('" . esc_js(sprintf(__('Are you sure you want to delete this %s?', 'audiotheme'), strtolower($post_type_object->labels->singular_name))) . "');\"";
            echo sprintf('<a href="%s" class="submitdelete deletion"%s>%s</a>', wp_nonce_url($delete_url, 'delete-venue_' . $post->ID), $delete_url_onclick, esc_html(__('Delete Permanently', 'audiotheme')));
        }
        ?>
				</div>
			<?php 
    }
    ?>

			<div id="publishing-action">
				<?php 
    audiotheme_admin_spinner(array('id' => 'ajax-loading'));
    ?>
				<?php 
    if (!in_array($post->post_status, array('publish', 'future', 'private')) || 0 === $post->ID) {
        ?>
					<input type="hidden" name="original_publish" id="original_publish" value="<?php 
        esc_attr_e('Publish', 'audiotheme');
        ?>
">
					<?php 
        submit_button($post_type_object->labels->add_new_item, 'primary', 'publish', false, array('accesskey' => 'p'));
    } else {
        ?>
					<input type="hidden" name="original_publish" id="original_publish" value="<?php 
        esc_attr_e('Update', 'audiotheme');
        ?>
">
					<input type="submit" name="save" id="publish" class="button-primary" accesskey="p" value="<?php 
        esc_attr_e('Update', 'audiotheme');
        ?>
">
				<?php 
    }
    ?>
			</div><!--end div#publishing-action-->

			<div class="clear"></div>
		</div><!--end div#major-publishing-actions-->
	</div><!--end div#submitpost-->

	<script type="text/javascript">
	jQuery(function($) {
		$('input[type="submit"], a.submitdelete').click(function(){
			window.onbeforeunload = null;
			$(':button, :submit', '#submitpost').each(function(){
				var t = $(this);
				if ( t.hasClass('button-primary') )
					t.addClass('button-primary-disabled');
				else
					t.addClass('button-disabled');
			});

			if ( $(this).attr('id') == 'publish' )
				$('#major-publishing-actions .spinner').show();
		});
	});
	</script>
	<?php 
}
 /**
  * Display the venue name column along with any row actions.
  *
  * @since 1.0.0
  *
  * @param WP_Post $item Venue post object.
  * @return string Column value.
  */
 function column_name($item)
 {
     $post_type_object = get_post_type_object('audiotheme_venue');
     $output = sprintf('<strong><a href="%s" class="row-title">%s</a></strong><br>', esc_url(get_edit_post_link($item->ID)), $item->name);
     $actions['edit'] = sprintf('<a href="%s">Edit</a>', get_edit_post_link($item->ID));
     $delete_args['action'] = 'delete';
     $delete_args['venue_id'] = $item->ID;
     $delete_url = get_audiotheme_venues_admin_url($delete_args);
     $delete_url_onclick = " onclick=\"return confirm('" . esc_js(sprintf(__('Are you sure you want to delete this %s?', 'audiotheme'), strtolower($post_type_object->labels->singular_name))) . "');\"";
     $actions['delete'] = sprintf('<a href="%s"%s>%s</a>', wp_nonce_url($delete_url, 'delete-venue_' . $item->ID), $delete_url_onclick, __('Delete', 'audiotheme'));
     $output .= $this->row_actions($actions);
     return $output;
 }