Changeset 2255953
- Timestamp:
- 03/07/2020 02:16:21 AM (6 years ago)
- Location:
- sheetdb/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (2 diffs)
-
sheetdb.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
sheetdb/trunk/readme.txt
r2253923 r2255953 4 4 Tags: google spreadsheet, google sheets, sheetdb, sheet-db, google api, api 5 5 Requires at least: 4.0 6 Tested up to: 5. 2.46 Tested up to: 5.4.0 7 7 Requires PHP: 5.4 8 Stable tag: 1.0. 28 Stable tag: 1.0.3 9 9 License: GPLv2 or later 10 10 … … 36 36 Add SheetDB plugin to your site, activate it, then all you need to do is use the [sheetdb] shortcode wherever you want. 37 37 38 == Re-use == 39 40 If 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 42 Example: 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 48 That 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 38 50 == Screenshots == 39 51 -
sheetdb/trunk/sheetdb.php
r2245602 r2255953 6 6 Plugin name: SheetDB 7 7 Description: The SheetDB wordpress plugin allows you to easily add content from Google Spreadsheet to your wordpress site. 8 Version: 1.0. 28 Version: 1.0.3 9 9 Author: SheetDB 10 10 Author URI: https://sheetdb.io/ … … 36 36 public function __construct() { 37 37 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__) ); 39 40 } 40 41 … … 43 44 isset($atts['element']) ? $element = $atts['element'] : $element = "div"; 44 45 46 isset($atts['save']) ? $save = $atts['save'] : $save = null; 45 47 isset($atts['sheet']) ? $sheet = $atts['sheet'] : $sheet = null; 46 48 isset($atts['limit']) ? $limit = $atts['limit'] : $limit = null; … … 53 55 if (!$url) return 'Use URL attribute with the SheetDB shortcode.'; 54 56 55 $additionalCode = $this->makeAdditionalCode($sheet, $limit, $offset, $search, $sortBy, $sortOrder, $sortMethod );57 $additionalCode = $this->makeAdditionalCode($sheet, $limit, $offset, $search, $sortBy, $sortOrder, $sortMethod, $save); 56 58 57 59 return "<{$element} data-sheetdb-url=\"{$url}\"{$additionalCode}>{$content}</{$element}>"; 58 60 } 59 61 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) { 61 70 $additionalCode = ''; 62 71 if ($sheet) { … … 81 90 $additionalCode .= ' data-sheetdb-sort-method="' . $sortMethod . '"'; 82 91 } 92 if ($save) { 93 $additionalCode .= ' data-sheetdb-save="' . $save . '"'; 94 } 83 95 84 96 return $additionalCode;
Note: See TracChangeset
for help on using the changeset viewer.