コード例 #1
0
function wpv_admin_menu_content_templates_listing_page() {
	?>
	<div class="wrap toolset-views">
		<div class="wpv-views-listing-page">
			<?php
				wp_nonce_field( 'work_view_template', 'work_view_template' );
				$search_term = isset( $_GET["s"] ) ? urldecode( sanitize_text_field($_GET["s"]) ) : '';
			?>
			<div id="icon-views" class="icon32"></div>
			<h2><!-- classname wpv-page-title removed -->
				<?php
					_e( 'Content Templates', 'wpv-views' );

					printf(
							' <a href="#" class="add-new-h2 page-title-action js-add-new-content-template" data-target="%s">%s</a>',
							esc_url( add_query_arg( array( 'action' => 'wpv_ct_create_new' ), admin_url( 'admin-ajax.php' ) ) ),
							__( 'Add new Content Template', 'wpv-views' ) );

					if ( !empty( $search_term ) ) {
						$search_message = __('Search results for "%s"','wpv-views');
						if ( isset( $_GET["status"] ) && 'trash' == sanitize_text_field( $_GET["status"] ) ) {
							$search_message = __('Search results for "%s" in trashed Content Templates', 'wpv-views');
						}
						?>
							<span class="subtitle">
								<?php echo sprintf( $search_message, $search_term ); ?>
							</span>
						<?php
					}
				?>
			</h2>

			<?php

				// Messages: trashed, untrashed, deleted
				add_filter( 'wpv_maybe_show_listing_message_undo', 'wpv_admin_ct_listing_message_undo', 10, 3 );

				wpv_maybe_show_listing_message(
						'trashed', __( 'Content Template moved to the Trash.', 'wpv-views' ),
						__( '%d Content Templates moved to the Trash.', 'wpv-views' ), true );
				wpv_maybe_show_listing_message(
						'untrashed', __( 'Content Template restored from the Trash.', 'wpv-views' ),
						__( '%d Content Templates restored from the Trash.', 'wpv-views' ) );
				wpv_maybe_show_listing_message(
						'deleted', __( 'Content Template permanently deleted.', 'wpv-views' ),
						__( '%d Content Templates permanently deleted.', 'wpv-views' ) );

				// Determine how should we arrange the items (what should be displayed)
				if ( isset( $_GET["arrangeby"] ) && sanitize_text_field( $_GET["arrangeby"] ) == 'usage' ) {
					$arrange_by = 'single';
					if ( isset( $_GET["usage"] ) ) {
						$arrange_by = sanitize_text_field($_GET["usage"]);
					}
				} else {
					$arrange_by = 'name';
				}
					
				// "Arrange by" tabs
				?>
					<div class="wpv-admin-tabs">
						<ul class="wpv-admin-tabs-links">
							<?php
								$tabs = array(
										'name' => __( 'Name','wpv-views' ),
										'single' => __( 'Usage for single page', 'wpv-views' ),
										'post-archives' => __( 'Usage for custom post archives', 'wpv-views' ),
										'taxonomy-archives' => __( 'Usage for taxonomy archives', 'wpv-views' ) );
										
								foreach( $tabs as $tab_slug => $tab_label ) {
									printf(
										'<li><a href="%s" %s>%s</a></li>',
										esc_url( add_query_arg(
											array(
													'page' => 'view-templates',
													'arrangeby' => ( 'name' == $tab_slug ) ? 'name' : 'usage',
													'usage' => $tab_slug ),
											admin_url( 'admin.php' ) ) ),
										wpv_current_class( $arrange_by, $tab_slug, false ),
										$tab_label );
								}
							?> 
						</ul>
					</div>				
				<?php

				// Render the actual listing
				if ( 'name' == $arrange_by ) {
					wpv_admin_content_template_listing_name();
				} else {
					wpv_admin_content_template_listing_usage( $arrange_by );
				}
				
			?>
		</div> <!-- .wpv-views-listing-page -->
	</div> <!-- .toolset-views -->
	<?php
}
function wpv_admin_menu_content_templates_listing_page()
{
    ?>
	<div class="wrap toolset-views">
		<div class="wpv-views-listing-page">
			<?php 
    wp_nonce_field('work_view_template', 'work_view_template');
    $search_term = isset($_GET["search"]) ? urldecode(sanitize_text_field($_GET["search"])) : '';
    ?>
			<div id="icon-views" class="icon32"></div>
			<h2><!-- classname wpv-page-title removed -->
				<?php 
    _e('Content Templates', 'wpv-views');
    ?>
				<?php 
    if (!empty($search_term)) {
        $search_message = __('Search results for "%s"', 'wpv-views');
        if (isset($_GET["status"]) && 'trash' == sanitize_text_field($_GET["status"])) {
            $search_message = __('Search results for "%s" in trashed Content Templates', 'wpv-views');
        }
        ?>
				<span class="subtitle">
					<?php 
        echo sprintf($search_message, $search_term);
        ?>
				</span>
				<?php 
    }
    ?>
			</h2>
			
			<?php 
    // Messages: trashed, untrashed, deleted
    if (isset($_GET['trashed']) && is_numeric($_GET['trashed'])) {
        ?>
				<div id="message" class="updated below-h2">
					<p>
						<?php 
        _e('Content Template moved to the Trash', 'wpv-views');
        ?>
. <a href="<?php 
        echo admin_url();
        ?>
admin.php?page=view-templates&amp;untrashed=1" class="js-wpv-untrash" data-id="<?php 
        echo $_GET['trashed'];
        ?>
" data-nonce="<?php 
        echo wp_create_nonce('wpv_view_listing_actions_nonce');
        ?>
"><?php 
        _e('Undo', 'wpv-views');
        ?>
</a>
					</p>
				</div>
			<?php 
    }
    if (isset($_GET['untrashed']) && is_numeric($_GET['untrashed']) && (int) $_GET['untrashed'] == 1) {
        ?>
				<div id="message" class="updated below-h2">
					<p>
						<?php 
        _e('Content Template restored from the Trash', 'wpv-views');
        ?>
					</p>
				</div>
			<?php 
    }
    if (isset($_GET['deleted']) && is_numeric($_GET['deleted']) && (int) $_GET['deleted'] == 1) {
        ?>
				<div id="message" class="updated below-h2">
					<p>
						<?php 
        _e('Content Template permanently deleted', 'wpv-views');
        ?>
					</p>
				</div>
			<?php 
    }
    ?>
			<?php 
    if (isset($_GET["arrangeby"]) && sanitize_text_field($_GET["arrangeby"]) == 'usage') {
        $usage = 'single';
        if (isset($_GET["usage"])) {
            $usage = sanitize_text_field($_GET["usage"]);
        }
        wpv_admin_content_template_listing_usage($usage);
    } else {
        wpv_admin_content_template_listing_name();
    }
    ?>

		</div> <!-- .wpv-views-listing-page -->

	</div> <!-- .toolset-views -->
<?php 
}