# wp-ultimate-post-grid/2.4.0/helpers/pagination.php

WP Ultimate Post Grid, version 2.4.0. 29 lines.

- Page: https://pluginprobe.com/plugins/wp-ultimate-post-grid/2.4.0/code/helpers/pagination.php
- Raw: https://pluginprobe.com/plugins/wp-ultimate-post-grid/2.4.0/raw/helpers/pagination.php
- Modified: 2017-04-20T07:39:56+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wp-ultimate-post-grid/2.4.0/code/helpers/pagination.php#L10-L20`.

```php
<?php

class WPUPG_Pagination {

    public function __construct()
    {
        add_action( 'wp_ajax_wpupg_get_page', array( $this, 'ajax_get_page' ) );
        add_action( 'wp_ajax_nopriv_wpupg_get_page', array( $this, 'ajax_get_page' ) );
    }

    public function ajax_get_page()
    {
        if( check_ajax_referer( 'wpupg_grid', 'security', false ) )
        {
            $grid = $_POST['grid'];
            $page = intval( $_POST['page'] );

            $post = get_page_by_path( $grid, OBJECT, WPUPG_POST_TYPE );

            if( !is_null( $post ) ) {
                $grid = new WPUPG_Grid($post);

                echo $grid->draw_posts( $page );
            }
        }

        die();
    }
}
```
