/** * Render shortcode hint in the Publish metabox * * @access public * @param object $post * @return void */ function render_shortcode_hint() { global $post; // Only show this on GravityView post types. if (false === gravityview_is_admin_page()) { return; } // If the View hasn't been configured yet, don't show embed shortcode if (!gravityview_get_directory_fields($post->ID)) { return; } include self::$metaboxes_dir . 'views/shortcode-hint.php'; }
/** * Render the Template Active Areas and configured active fields for a given template id and post id * * @access public * @param string $template_id (default: '') * @param string $post_id (default: '') * @param string $context (default: 'single') * @return string HTML of the active areas */ function render_directory_active_areas($template_id = '', $context = 'single', $post_id = '', $echo = false) { if (empty($template_id)) { do_action('gravityview_log_debug', '[render_directory_active_areas] $template_id is empty'); return; } $template_areas = apply_filters('gravityview_template_active_areas', array(), $template_id, $context); if (empty($template_areas)) { do_action('gravityview_log_debug', '[render_directory_active_areas] No areas defined. Maybe template %s is disabled.', $template_id); $output = '<div>'; $output .= '<h2 class="description" style="font-size: 16px; margin:0">' . sprintf(esc_html__('This View is configured using the %s View type, which is disabled.', 'gravityview'), '<em>' . $template_id . '</em>') . '</h2>'; $output .= '<p class="description" style="font-size: 14px; margin:0 0 1em 0;padding:0">' . esc_html__('The data is not lost; re-activate the associated plugin and the configuration will re-appear.', 'gravityview') . '</p>'; $output .= '</div>'; } else { $fields = ''; if (!empty($post_id)) { $fields = gravityview_get_directory_fields($post_id); } ob_start(); $this->render_active_areas($template_id, 'field', $context, $template_areas, $fields); $output = ob_get_clean(); } if ($echo) { echo $output; } return $output; }
/** * Render the Template Active Areas and configured active fields for a given template id and post id * * @access public * @param string $template_id (default: '') Template ID, like `default_list`, `default_table`, `preset_business_data`, etc. {@see GravityView_Template::__construct()} * @param string $post_id (default: '') * @param string $context (default: 'single') * @return string HTML of the active areas */ function render_directory_active_areas($template_id = '', $context = 'single', $post_id = '', $echo = false) { if (empty($template_id)) { do_action('gravityview_log_debug', '[render_directory_active_areas] $template_id is empty'); return; } /** * @filter `gravityview_template_active_areas` * @see GravityView_Template::assign_active_areas() * @param array $template_areas Empty array, to be filled in by the template class * @param string $template_id Template ID, like `default_list`, `default_table`, `preset_business_data`, etc. {@see GravityView_Template::__construct()} * @param string $context Current View context: `directory`, `single`, or `edit` (default: 'single') */ $template_areas = apply_filters('gravityview_template_active_areas', array(), $template_id, $context); if (empty($template_areas)) { do_action('gravityview_log_debug', '[render_directory_active_areas] No areas defined. Maybe template %s is disabled.', $template_id); $output = '<div>'; $output .= '<h2 class="description" style="font-size: 16px; margin:0">' . sprintf(esc_html__('This View is configured using the %s View type, which is disabled.', 'gravityview'), '<em>' . $template_id . '</em>') . '</h2>'; $output .= '<p class="description" style="font-size: 14px; margin:0 0 1em 0;padding:0">' . esc_html__('The data is not lost; re-activate the associated plugin and the configuration will re-appear.', 'gravityview') . '</p>'; $output .= '</div>'; } else { $fields = ''; if (!empty($post_id)) { $fields = gravityview_get_directory_fields($post_id); } ob_start(); $this->render_active_areas($template_id, 'field', $context, $template_areas, $fields); $output = ob_get_clean(); } if ($echo) { echo $output; } return $output; }
/** * Get the visible fields for a View * @uses gravityview_get_directory_fields() Fetch the configured fields for a View * @uses GravityView_View_Data::filter_fields() Only show visible fields * @param int $view_id View ID * @return array Array of fields as passed by `gravityview_get_directory_fields()` */ function get_fields($view_id) { $dir_fields = gravityview_get_directory_fields($view_id); do_action('gravityview_log_debug', '[render_view] Fields: ', $dir_fields); // remove fields according to visitor visibility permissions (if logged-in) $dir_fields = $this->filter_fields($dir_fields); do_action('gravityview_log_debug', '[render_view] Fields after visibility filter: ', $dir_fields); return $dir_fields; }