コード例 #1
0
 /**
  * Add the Data Source information
  *
  * @param null $column_name
  * @param $post_id
  *
  * @return void
  */
 public function add_custom_column_content($column_name = NULL, $post_id)
 {
     $output = '';
     switch ($column_name) {
         case 'gv_template':
             $template_id = gravityview_get_template_id($post_id);
             // All Views should have a connected form. If it doesn't, that's not right.
             if (empty($template_id)) {
                 do_action('gravityview_log_error', sprintf(__METHOD__ . ' View ID %s does not have a connected template.', $post_id));
                 break;
             }
             $templates = gravityview_get_registered_templates();
             $template = isset($templates[$template_id]) ? $templates[$template_id] : false;
             // Generate backup if label doesn't exist: `example_name` => `Example Name`
             $template_id_pretty = ucwords(implode(' ', explode('_', $template_id)));
             $output = $template ? $template['label'] : $template_id_pretty;
             break;
         case 'gv_connected_form':
             $form_id = gravityview_get_form_id($post_id);
             // All Views should have a connected form. If it doesn't, that's not right.
             if (empty($form_id)) {
                 do_action('gravityview_log_error', sprintf('[add_data_source_column_content] View ID %s does not have a connected GF form.', $post_id));
                 $output = __('Not connected.', 'gravityview');
                 break;
             }
             $form = gravityview_get_form($form_id);
             if (!$form) {
                 do_action('gravityview_log_error', sprintf('[add_data_source_column_content] Connected form not found: Form #%d', $form_id));
                 $output = __('The connected form can not be found; it may no longer exist.', 'gravityview');
             } else {
                 $output = self::get_connected_form_links($form);
             }
             break;
     }
     echo $output;
 }
コード例 #2
0
<?php

/**
 * @file select-template.php
 * @package GravityView
 * @subpackage Gravityview/admin/metaboxes/partials
 * @global WP_Post $post
 */
global $post;
// Use nonce for verification
wp_nonce_field('gravityview_select_template', 'gravityview_select_template_nonce');
//current value
$current_template = gravityview_get_template_id($post->ID);
$templates = gravityview_get_registered_templates();
// current input
?>
<input type="hidden" id="gravityview_directory_template" name="gravityview_directory_template" value="<?php 
echo esc_attr($current_template);
?>
" />

<?php 
// list all the available templates (type= fresh or custom )
?>
<div class="gv-grid">
	<?php 
foreach ($templates as $id => $template) {
    $selected = $id == $current_template ? ' gv-selected' : '';
    ?>

		<div class="gv-grid-col-1-3">