public function render_frontend($widget_args, $content = '', $context = '')
 {
     $gravityview_view = GravityView_View::getInstance();
     if (!$this->pre_render_frontend()) {
         return;
     }
     $page_size = $gravityview_view->paging['page_size'];
     $total = $gravityview_view->total_entries;
     $atts = shortcode_atts(array('show_all' => !empty($this->settings['show_all']['default'])), $widget_args, 'gravityview_widget_page_links');
     // displaying info
     $curr_page = empty($_GET['pagenum']) ? 1 : intval($_GET['pagenum']);
     $page_link_args = array('base' => add_query_arg('pagenum', '%#%', gv_directory_link()), 'format' => '&pagenum=%#%', 'add_args' => array(), 'prev_text' => '«', 'next_text' => '»', 'type' => 'list', 'end_size' => 1, 'mid_size' => 2, 'total' => empty($page_size) ? 0 : ceil($total / $page_size), 'current' => $curr_page, 'show_all' => !empty($atts['show_all']));
     /**
      * @filter `gravityview_page_links_args` Filter the pagination options
      * @since 1.1.4
      * @param array  $page_link_args Array of arguments for the `paginate_links()` function. [Read more about `paginate_links()`](http://developer.wordpress.org/reference/functions/paginate_links/)
      */
     $page_link_args = apply_filters('gravityview_page_links_args', $page_link_args);
     $page_links = paginate_links($page_link_args);
     if (!empty($page_links)) {
         $class = !empty($widget_args['custom_class']) ? $widget_args['custom_class'] : '';
         $class = gravityview_sanitize_html_class($class);
         echo '<div class="gv-widget-page-links ' . $class . '">' . $page_links . '</div>';
     } else {
         do_action('gravityview_log_debug', 'GravityView_Widget_Page_Links[render_frontend] No page links; paginate_links() returned empty response.');
     }
 }
Ejemplo n.º 2
0
/**
 * Generate HTML for the back link from single entry view
 * @since 1.0.1
 * @return string|null      If no GV post exists, null. Otherwise, HTML string of back link.
 */
function gravityview_back_link()
{
    $href = gv_directory_link();
    if (empty($href)) {
        return NULL;
    }
    // calculate link label
    $gravityview_view = GravityView_View::getInstance();
    $label = $gravityview_view->getBackLinkLabel() ? $gravityview_view->getBackLinkLabel() : __('&larr; Go back', 'gravityview');
    /**
     * @filter `gravityview_go_back_label` Modify the back link text
     * @since 1.0.9
     * @param string $label Existing label text
     */
    $label = apply_filters('gravityview_go_back_label', $label);
    $link = gravityview_get_link($href, esc_html($label), array('data-viewid' => $gravityview_view->getViewId()));
    return $link;
}