Plugin Directory

Changeset 1954969


Ignore:
Timestamp:
10/11/2018 08:52:21 AM (7 years ago)
Author:
andrekelling
Message:

PAGINATION skip default 10 limit of fetching posts for rest api in google map and on php query for table template v1.5.1

Location:
mapple
Files:
5 edited
20 copied

Legend:

Unmodified
Added
Removed
  • mapple/tags/1.5.1/includes/class-mapple-shared.php

    r1933696 r1954969  
    137137        $args['orderby']                = $params['orderby'];
    138138        $args['order']                  = 'ASC';
    139         $args['posts_per_page']         = absint( $params['quantity'] );
     139        // @todo: insert option for shortcode to adjust qty when pagination feature is in
     140        //$args['posts_per_page']       = absint( $params['quantity'] );
    140141        $args['post_status']            = 'publish';
    141142        $args['post_type']              = 'clients';
     
    143144
    144145        unset( $params['orderby'] );
    145         unset( $params['quantity'] );
     146        //unset( $params['quantity'] );
    146147        unset( $params['listview'] );
    147148        unset( $params['singleview'] );
  • mapple/tags/1.5.1/mapple.php

    r1937361 r1954969  
    1717 * Plugin URI:        https://andrekelling.de/
    1818 * Description:       To show a google map with the locations of your clients. You can output additionally a sorted listing table of all your clients. Just with shortcodes.
    19  * Version:           1.5.0
     19 * Version:           1.5.1
    2020 * Author:            André Kelling
    2121 * Author URI:        https://andrekelling.de/about
     
    3636 * Rename this for your plugin and update it as you release new versions.
    3737 */
    38 define( 'MAPPLE_VERSION', '1.5.0' );
     38define( 'MAPPLE_VERSION', '1.5.1' );
    3939
    4040/**
  • mapple/tags/1.5.1/public/class-mapple-public.php

    r1937361 r1954969  
    160160        $defaults['loop-template']  = $this->plugin_name . '-loop-clients';
    161161        $defaults['orderby']        = 'title';
    162         $defaults['quantity']       = 0;
     162        // @todo: insert option for shortcode to adjust qty when pagination feature is in
     163        //$defaults['quantity']         = 0; // is 10
     164        $defaults['nopaging']         = true;
    163165
    164166        $shared                     = new Mapple_Shared( $this->plugin_name, $this->version );
  • mapple/tags/1.5.1/public/js/mapple-public.js

    r1937361 r1954969  
    4040
    4141        const theMap = new google.maps.Map(el, myMapOptions);
    42 
    43         plugin.loadJSON('clients', function(response) {
    44             for(let i = 0; i < response.length; i++) {
    45 
    46                 if (response[i].location){
    47                     plugin.setMarker(response[i], i, theMap);
    48                 }
    49 
    50             }
    51 
    52             //now fit the map to the newly inclusive bounds
    53             theMap.fitBounds(settings.bounds);
    54         });
     42        const perPage = 100;
     43
     44        plugin.loadJSON('clients/?per_page='+perPage, function(response, total, pages) {
     45            // first load get total count of pages
     46            for(let i = 0; i < pages; i++) {
     47                plugin.loadJSON('clients/?page='+(i+1)+'&per_page='+perPage, function(response) {
     48                    //console.log(response);
     49                    plugin.responseLoop(response, theMap);
     50                });
     51            }
     52
     53            plugin.responseLoop(response, theMap);
     54        });
     55    };
     56
     57    plugin.responseLoop = function(response, theMap) {
     58        for(let i = 0; i < response.length; i++) {
     59
     60            if (response[i].location){
     61                plugin.setMarker(response[i], i, theMap);
     62            }
     63
     64        }
     65
     66        //now fit the map to the newly inclusive bounds
     67        theMap.fitBounds(settings.bounds);
    5568    };
    5669
     
    114127            if (xobj.readyState == 4 && xobj.status == '200') {
    115128                // Required use of an anonymous callback as .open will NOT return a value but simply returns undefined in asynchronous mode
    116                 callback(JSON.parse(xobj.responseText));
     129                callback(JSON.parse(xobj.responseText), xobj.getResponseHeader("X-WP-Total"), xobj.getResponseHeader("X-WP-TotalPages"));
    117130            }
    118131        };
  • mapple/tags/1.5.1/readme.txt

    r1937361 r1954969  
    55Requires at least: 4.7
    66Tested up to: 4.9.5
    7 Stable tag: 1.5.0
     7Stable tag: 1.5.1
    88Requires PHP: 7.0
    99License: GPLv3.0 or later
     
    2626*   provides a new custom post type `clients`
    2727*   map functionality works over the REST_API
     28*   the limit of fetched `clients` posts is unset. Beware of the risk fetching too much!!! (proper limitation feature is planned)
    2829
    2930### Shortcodes
     
    6364== Changelog ==
    6465
     66= 1.5.1 =
     67* remove default 10 post entries limit from table and map
     68
    6569= 1.5.0 =
    6670* enable google maps marker image customisation
  • mapple/trunk/includes/class-mapple-shared.php

    r1933696 r1954969  
    137137        $args['orderby']                = $params['orderby'];
    138138        $args['order']                  = 'ASC';
    139         $args['posts_per_page']         = absint( $params['quantity'] );
     139        // @todo: insert option for shortcode to adjust qty when pagination feature is in
     140        //$args['posts_per_page']       = absint( $params['quantity'] );
    140141        $args['post_status']            = 'publish';
    141142        $args['post_type']              = 'clients';
     
    143144
    144145        unset( $params['orderby'] );
    145         unset( $params['quantity'] );
     146        //unset( $params['quantity'] );
    146147        unset( $params['listview'] );
    147148        unset( $params['singleview'] );
  • mapple/trunk/mapple.php

    r1937361 r1954969  
    1717 * Plugin URI:        https://andrekelling.de/
    1818 * Description:       To show a google map with the locations of your clients. You can output additionally a sorted listing table of all your clients. Just with shortcodes.
    19  * Version:           1.5.0
     19 * Version:           1.5.1
    2020 * Author:            André Kelling
    2121 * Author URI:        https://andrekelling.de/about
     
    3636 * Rename this for your plugin and update it as you release new versions.
    3737 */
    38 define( 'MAPPLE_VERSION', '1.5.0' );
     38define( 'MAPPLE_VERSION', '1.5.1' );
    3939
    4040/**
  • mapple/trunk/public/class-mapple-public.php

    r1937361 r1954969  
    160160        $defaults['loop-template']  = $this->plugin_name . '-loop-clients';
    161161        $defaults['orderby']        = 'title';
    162         $defaults['quantity']       = 0;
     162        // @todo: insert option for shortcode to adjust qty when pagination feature is in
     163        //$defaults['quantity']         = 0; // is 10
     164        $defaults['nopaging']         = true;
    163165
    164166        $shared                     = new Mapple_Shared( $this->plugin_name, $this->version );
  • mapple/trunk/public/js/mapple-public.js

    r1937361 r1954969  
    4040
    4141        const theMap = new google.maps.Map(el, myMapOptions);
    42 
    43         plugin.loadJSON('clients', function(response) {
    44             for(let i = 0; i < response.length; i++) {
    45 
    46                 if (response[i].location){
    47                     plugin.setMarker(response[i], i, theMap);
    48                 }
    49 
    50             }
    51 
    52             //now fit the map to the newly inclusive bounds
    53             theMap.fitBounds(settings.bounds);
    54         });
     42        const perPage = 100;
     43
     44        plugin.loadJSON('clients/?per_page='+perPage, function(response, total, pages) {
     45            // first load get total count of pages
     46            for(let i = 0; i < pages; i++) {
     47                plugin.loadJSON('clients/?page='+(i+1)+'&per_page='+perPage, function(response) {
     48                    //console.log(response);
     49                    plugin.responseLoop(response, theMap);
     50                });
     51            }
     52
     53            plugin.responseLoop(response, theMap);
     54        });
     55    };
     56
     57    plugin.responseLoop = function(response, theMap) {
     58        for(let i = 0; i < response.length; i++) {
     59
     60            if (response[i].location){
     61                plugin.setMarker(response[i], i, theMap);
     62            }
     63
     64        }
     65
     66        //now fit the map to the newly inclusive bounds
     67        theMap.fitBounds(settings.bounds);
    5568    };
    5669
     
    114127            if (xobj.readyState == 4 && xobj.status == '200') {
    115128                // Required use of an anonymous callback as .open will NOT return a value but simply returns undefined in asynchronous mode
    116                 callback(JSON.parse(xobj.responseText));
     129                callback(JSON.parse(xobj.responseText), xobj.getResponseHeader("X-WP-Total"), xobj.getResponseHeader("X-WP-TotalPages"));
    117130            }
    118131        };
  • mapple/trunk/readme.txt

    r1937361 r1954969  
    55Requires at least: 4.7
    66Tested up to: 4.9.5
    7 Stable tag: 1.5.0
     7Stable tag: 1.5.1
    88Requires PHP: 7.0
    99License: GPLv3.0 or later
     
    2626*   provides a new custom post type `clients`
    2727*   map functionality works over the REST_API
     28*   the limit of fetched `clients` posts is unset. Beware of the risk fetching too much!!! (proper limitation feature is planned)
    2829
    2930### Shortcodes
     
    6364== Changelog ==
    6465
     66= 1.5.1 =
     67* remove default 10 post entries limit from table and map
     68
    6569= 1.5.0 =
    6670* enable google maps marker image customisation
Note: See TracChangeset for help on using the changeset viewer.