<?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); /** * @filter `gravityview_register_directory_template` Fetch available View templates * @param array $templates Templates to show */ $templates = apply_filters('gravityview_register_directory_template', array()); // 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) {
/** * 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; }
/** * Render html for 'View Configuration' metabox * * @access public * @param mixed $post * @return void */ function render_view_configuration_metabox($post) { // Use nonce for verification wp_nonce_field('gravityview_view_configuration', 'gravityview_view_configuration_nonce'); // Selected Form $curr_form = gravityview_get_form_id($post->ID); // Selected template $curr_template = gravityview_get_template_id($post->ID); echo self::render_merge_tags_scripts($curr_form); include self::$metaboxes_dir . 'views/view-configuration.php'; }
/** * * Add a view to the views array * * @param int|array $view_id View ID or array of View IDs * @param array|string $atts Combine other attributes (eg. from shortcode) with the view settings (optional) * @return type */ function add_view($view_id, $atts = NULL) { // Handle array of IDs if (is_array($view_id)) { foreach ($view_id as $id) { $this->add_view($id, $atts); } return $this->views; } // The view has been set already; returning stored view. if (!empty($this->views[$view_id])) { do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s already exists.', $view_id)); return $this->views[$view_id]; } if (!$this->view_exists($view_id)) { do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; View #%s does not exist.', $view_id)); return false; } $form_id = gravityview_get_form_id($view_id); if (empty($form_id)) { do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Returning; Post ID #%s does not have a connected form.', $view_id)); return false; } // Get the settings for the View ID $view_settings = gravityview_get_template_settings($view_id); do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] Settings pulled in from View #%s', $view_id), $view_settings); // Merge the view settings with the defaults $view_defaults = wp_parse_args($view_settings, self::get_default_args()); do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] View Defaults after merging View Settings with the default args.', $view_defaults); if (!empty($atts) && is_array($atts)) { do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts before merging with the $view_defaults', $atts); // Get the settings from the shortcode and merge them with defaults. $atts = shortcode_atts($view_defaults, $atts); do_action('gravityview_log_debug', 'GravityView_View_Data[add_view] $atts after merging with the $view_defaults', $atts); } else { // If there are no passed $atts, the defaults will be used. $atts = $view_defaults; } unset($atts['id'], $view_defaults, $view_settings); $data = array('id' => $view_id, 'view_id' => $view_id, 'form_id' => $form_id, 'template_id' => gravityview_get_template_id($view_id), 'atts' => $atts, 'fields' => $this->get_fields($view_id), 'widgets' => get_post_meta($view_id, '_gravityview_directory_widgets', true), 'form' => gravityview_get_form($form_id)); do_action('gravityview_log_debug', sprintf('GravityView_View_Data[add_view] View #%s being added.', $view_id), $data); $this->views[$view_id] = $data; return $this->views[$view_id]; }