本文整理汇总了PHP中GravityView_View::render方法的典型用法代码示例。如果您正苦于以下问题:PHP GravityView_View::render方法的具体用法?PHP GravityView_View::render怎么用?PHP GravityView_View::render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GravityView_View
的用法示例。
在下文中一共展示了GravityView_View::render方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render_view
/**
* Core function to render a View based on a set of arguments
*
* @access public
* @static
* @param array $passed_args {
*
* Settings for rendering the View
*
* @type int $id View id
* @type int $page_size Number of entries to show per page
* @type string $sort_field Form field id to sort
* @type string $sort_direction Sorting direction ('ASC' or 'DESC')
* @type string $start_date - Ymd
* @type string $end_date - Ymd
* @type string $class - assign a html class to the view
* @type string $offset (optional) - This is the start point in the current data set (0 index based).
* }
*
* @return string|null HTML output of a View, NULL if View isn't found
*/
public function render_view($passed_args)
{
// validate attributes
if (empty($passed_args['id'])) {
do_action('gravityview_log_error', '[render_view] Returning; no ID defined.', $passed_args);
return null;
}
// Solve problem when loading content via admin-ajax.php
// @hack
if (!$this->getGvOutputData()) {
do_action('gravityview_log_error', '[render_view] gv_output_data not defined; parsing content.', $passed_args);
$this->parse_content();
}
// Make 100% sure that we're dealing with a properly called situation
if (!is_object($this->getGvOutputData()) || !is_callable(array($this->getGvOutputData(), 'get_view'))) {
do_action('gravityview_log_error', '[render_view] gv_output_data not an object or get_view not callable.', $this->getGvOutputData());
return null;
}
$view_id = $passed_args['id'];
$view_data = $this->getGvOutputData()->get_view($view_id, $passed_args);
do_action('gravityview_log_debug', '[render_view] View Data: ', $view_data);
do_action('gravityview_log_debug', '[render_view] Init View. Arguments: ', $passed_args);
// The passed args were always winning, even if they were NULL.
// This prevents that. Filters NULL, FALSE, and empty strings.
$passed_args = array_filter($passed_args, 'strlen');
//Override shortcode args over View template settings
$atts = wp_parse_args($passed_args, $view_data['atts']);
do_action('gravityview_log_debug', '[render_view] Arguments after merging with View settings: ', $atts);
// It's password protected and you need to log in.
if (post_password_required($view_id)) {
do_action('gravityview_log_error', sprintf('[render_view] Returning: View %d is password protected.', $view_id));
// If we're in an embed or on an archive page, show the password form
if (get_the_ID() !== $view_id) {
return get_the_password_form();
}
// Otherwise, just get outta here
return null;
}
/**
* Don't render View if user isn't allowed to see it
* @since 1.15
*/
if (is_user_logged_in() && false === GVCommon::has_cap('read_gravityview', $view_id)) {
return null;
}
if ($this->isGravityviewPostType()) {
/**
* @filter `gravityview_direct_access` Should Views be directly accessible, or only visible using the shortcode?
* @see https://codex.wordpress.org/Function_Reference/register_post_type#public
* @see GravityView_Post_Types::init_post_types
* @since 1.15.2
* @param[in,out] boolean `true`: allow Views to be accessible directly. `false`: Only allow Views to be embedded via shortcode. Default: `true`
* @param int $view_id The ID of the View currently being requested. `0` for general setting
*/
$direct_access = apply_filters('gravityview_direct_access', true, $view_id);
$embed_only = !empty($atts['embed_only']);
if (!$direct_access || $embed_only && !GVCommon::has_cap('read_private_gravityviews')) {
return __('You are not allowed to view this content.', 'gravityview');
}
}
ob_start();
/**
* Set globals for templating
* @deprecated 1.6.2
*/
global $gravityview_view;
$gravityview_view = new GravityView_View($view_data);
$post_id = !empty($atts['post_id']) ? intval($atts['post_id']) : $this->getPostId();
$gravityview_view->setPostId($post_id);
if (!$this->getSingleEntry()) {
// user requested Directory View
do_action('gravityview_log_debug', '[render_view] Executing Directory View');
//fetch template and slug
$view_slug = apply_filters('gravityview_template_slug_' . $view_data['template_id'], 'table', 'directory');
do_action('gravityview_log_debug', '[render_view] View template slug: ', $view_slug);
/**
* Disable fetching initial entries for views that don't need it (DataTables)
*/
$get_entries = apply_filters('gravityview_get_view_entries_' . $view_slug, true);
//.........这里部分代码省略.........