Plugin Directory

Changeset 2255953


Ignore:
Timestamp:
03/07/2020 02:16:21 AM (6 years ago)
Author:
sheetdb
Message:

1.0.3 - new version of js + slots feature

Location:
sheetdb/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sheetdb/trunk/readme.txt

    r2253923 r2255953  
    44Tags: google spreadsheet, google sheets, sheetdb, sheet-db, google api, api
    55Requires at least: 4.0
    6 Tested up to: 5.2.4
     6Tested up to: 5.4.0
    77Requires PHP: 5.4
    8 Stable tag: 1.0.2
     8Stable tag: 1.0.3
    99License: GPLv2 or later
    1010
     
    3636Add SheetDB plugin to your site, activate it, then all you need to do is use the [sheetdb] shortcode wherever you want.
    3737
     38== Re-use ==
     39
     40If you want to re-use the data, you can use the `save` attribute in your [sheetdb] elements. To re-use your data use [sheetdb-slot]. You can use the same data inside as in the parent
     41
     42Example:
     43
     44[sheetdb url="https://sheetdb.io/api/v1/58f61be4dda40" save="slot-name"]{{id}} - {{name}}[/sheetdb]
     45
     46[sheetdb-slot slot="slot-name"]{{ name }}[/sheetdb-slot]
     47
     48That way, you only use 1 request instead of 2. Slots have access to the same data as the parent. You can't change things like limit or search. You need the next request to do that.
     49
    3850== Screenshots ==
    3951
  • sheetdb/trunk/sheetdb.php

    r2245602 r2255953  
    66Plugin name: SheetDB
    77Description: The SheetDB wordpress plugin allows you to easily add content from Google Spreadsheet to your wordpress site.
    8 Version: 1.0.2
     8Version: 1.0.3
    99Author: SheetDB
    1010Author URI: https://sheetdb.io/
     
    3636        public function __construct() {
    3737            add_shortcode('sheetdb', [$this, 'sheetdb_shortcode']);
    38             wp_enqueue_script( 'sheetdb-js', plugins_url('assets/js/sheetdb-handlebars-1.0.6.js', __FILE__) );
     38            add_shortcode('sheetdb-slot', [$this, 'sheetdb_slot_shortcode']);
     39            wp_enqueue_script( 'sheetdb-js', plugins_url('assets/js/sheetdb-handlebars-1.1.0.js', __FILE__) );
    3940        }
    4041
     
    4344            isset($atts['element']) ? $element = $atts['element'] : $element = "div";
    4445
     46            isset($atts['save']) ? $save = $atts['save'] : $save = null;
    4547            isset($atts['sheet']) ? $sheet = $atts['sheet'] : $sheet = null;
    4648            isset($atts['limit']) ? $limit = $atts['limit'] : $limit = null;
     
    5355            if (!$url) return 'Use URL attribute with the SheetDB shortcode.';
    5456
    55             $additionalCode = $this->makeAdditionalCode($sheet, $limit, $offset, $search, $sortBy, $sortOrder, $sortMethod);
     57            $additionalCode = $this->makeAdditionalCode($sheet, $limit, $offset, $search, $sortBy, $sortOrder, $sortMethod, $save);
    5658
    5759            return "<{$element} data-sheetdb-url=\"{$url}\"{$additionalCode}>{$content}</{$element}>";
    5860        }
    5961
    60         private function makeAdditionalCode($sheet, $limit, $offset, $search, $sortBy, $sortOrder, $sortMethod) {
     62        public function sheetdb_slot_shortcode($atts, $content) {
     63            isset($atts['slot']) ? $slot = $atts['slot'] : $slot = null;
     64            isset($atts['element']) ? $element = $atts['element'] : $element = "div";
     65
     66            return "<{$element} data-sheetdb-slot=\"{$slot}\">{$content}</{$element}>";
     67        }
     68
     69        private function makeAdditionalCode($sheet, $limit, $offset, $search, $sortBy, $sortOrder, $sortMethod, $save) {
    6170            $additionalCode = '';
    6271            if ($sheet) {
     
    8190                $additionalCode .= ' data-sheetdb-sort-method="' . $sortMethod . '"';
    8291            }
     92            if ($save) {
     93                $additionalCode .= ' data-sheetdb-save="' . $save . '"';
     94            }
    8395
    8496            return $additionalCode;
Note: See TracChangeset for help on using the changeset viewer.