Changeset 2926915
- Timestamp:
- 06/16/2023 06:45:43 AM (3 years ago)
- Location:
- agb-free/trunk
- Files:
-
- 22 edited
-
agb-free.php (modified) (1 diff)
-
dyg-form/includes/class-dyg-form.php (modified) (42 diffs)
-
dyg-form/includes/dyg-form-functions.php (modified) (11 diffs)
-
dyg-grid/addons/free/dygpg-meta.php (modified) (3 diffs)
-
dyg-grid/addons/free/dygpg_go_pro.php (modified) (10 diffs)
-
dyg-grid/addons/free/dygpg_grid_sizing.php (modified) (5 diffs)
-
dyg-grid/addons/free/dygpg_styles_css.php (modified) (5 diffs)
-
dyg-grid/addons/free/dygpg_styles_free.php (modified) (4 diffs)
-
dyg-grid/addons/free/dygpg_transitions_free.css (modified) (7 diffs)
-
dyg-grid/css/dyg-post-grid-templates.css (modified) (2 diffs)
-
dyg-grid/css/dyg-post-grid.css (modified) (2 diffs)
-
dyg-grid/css/dygpg-form.css (modified) (1 diff)
-
dyg-grid/dyg-post-grid.php (modified) (3 diffs)
-
dyg-grid/forms/dygpg-form.php (modified) (3 diffs)
-
dyg-grid/includes/class-dygpg-form.php (modified) (5 diffs)
-
dyg-grid/includes/class-dygpg-postgrid.php (modified) (69 diffs)
-
dyg-grid/js/dyg-resize.js (modified) (2 diffs)
-
dyg-grid/js/dygpg-ajax-load-more.js (modified) (1 diff)
-
dyg-grid/js/dygpg-edit-ajax.js (modified) (6 diffs)
-
dyg-grid/js/dygpg-misc.js (modified) (2 diffs)
-
dyg-theme/includes/dyg-toolkit.php (modified) (2 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
agb-free/trunk/agb-free.php
r2926896 r2926915 7 7 * 8 8 * @wordpress-plugin 9 * Plugin Name: A dvanced Grid Builder9 * Plugin Name: AGB Free 10 10 * Plugin URI: https://www.advancedgridbuilder.com 11 11 * Description: The ultimate grid and list generator for all Wordpress content types 12 * Version: 4. 5.012 * Version: 4.1.0 13 13 * License: GPL-2.0+ 14 14 * License URI: http://www.gnu.org/licenses/gpl-2.0.txt -
agb-free/trunk/dyg-form/includes/class-dyg-form.php
r2926907 r2926915 5 5 */ 6 6 7 require_once ABSPATH . 'wp-includes/pluggable.php';7 require_once( ABSPATH . 'wp-includes/pluggable.php' ); 8 8 9 9 class dyg_form { … … 20 20 $this->form_name = $form_name; 21 21 22 $this->prefill_values = ($this->form_data->settings->prefill ?? 'false') == 'true'; 23 $this->prefill_values = current_user_can('manage_options') ? $this->prefill_values : FALSE; //for safety, never load prefills for non admin 24 if (!isset($this->form_data->settings)) { 25 $this->form_data->settings = new stdClass(); 26 } 27 22 $this->prefill_values = ($this->form_data->settings->prefill ?? 'false' ) == 'true'; 23 $this->prefill_values = current_user_can('manage_options') ? $this->prefill_values : FALSE; //for safety, never load prefills for non admin 24 if (!isset($this->form_data->settings)) 25 $this->form_data->settings = new stdClass(); 28 26 $this->form_data->settings->store = $this->prefill_values ? TRUE : ($this->form_data->settings->store ?? 'true') == 'true'; //force storing the form to true if prefilling 29 27 $this->message_element = false; //flags if the form contains the location of the message div 30 28 $this->instance = empty($instance) ? '' : "-$instance"; 31 29 $this->form_data = apply_filters("dygform-filter-data-{$this->form_name}", $this->form_data); 32 if (property_exists($this->form_data, '__queue')) { 33 $queueContents = json_encode($this->form_data->__queue, JSON_PRETTY_PRINT); 34 die("<p>Error: Queue still exists after processing dygform insert elements. Queue contents:</p><pre>$queueContents</pre>"); 35 } 36 $this->form_data = apply_filters("dygform-json-load-{$this->form_name}", $this->form_data); 37 $this->form_data = apply_filters("dygform-json-load-{$this->form_name}-$instance", $this->form_data); 38 $this->name = ""; 39 $this->path = $path; 40 $this->URI = $URI; 30 $this->form_data = apply_filters("dygform-json-load-{$this->form_name}", $this->form_data); 31 $this->form_data = apply_filters("dygform-json-load-{$this->form_name}-$instance", $this->form_data); 32 $this->name = ""; 33 $this->path = $path; 34 $this->URI = $URI; 41 35 42 36 //used to create unique element ids … … 56 50 $this->process_settings(); 57 51 } 52 53 58 54 59 55 function enqueue_scripts() { … … 82 78 } 83 79 80 81 84 82 function process_settings() { 85 83 $this->form_class = $this->form_data->settings->form_class ?? ''; … … 89 87 90 88 //add a nonce based on the form name 91 $this->add_hidden_input('nonce', wp_create_nonce("dyg-form-nonce- {$this->form_name}{$this->instance}"));89 $this->add_hidden_input('nonce', wp_create_nonce("dyg-form-nonce-$this->form_name$this->instance")); 92 90 93 91 //if help icons are in use, has a base directory been set? … … 105 103 } 106 104 } 105 106 107 107 108 108 //appends a hidden input field to the form so that it will be passed through to AJAX for later processing … … 115 115 } 116 116 117 118 117 119 // handle settings relating to form emails 118 120 function settings_email($data) { 119 121 $defaults = [ 120 122 'to' => "", 121 "from" => '' ,123 "from" => '' 122 124 ]; 123 $data = shortcode_atts($defaults, $data); 124 } 125 126 //returns the form html back to the shortcode 125 $data = shortcode_atts($defaults, $data); 126 } 127 128 129 130 //returns the form html back to the shortcode 127 131 public function shortcode() { 128 //get the last submission form the database if requested to use as a value 132 //get the last submission form the database if requested to use as a value 129 133 if ($this->prefill_values AND class_exists('dyg_form_storage')) { 130 134 global $dyg_form_storage; … … 152 156 return apply_filters("dygform-filter-shortcode-{$this->form_name}$this->instance", "$stripe_key {$element['contains']}"); 153 157 } 158 159 154 160 155 161 //recursively walks the form data elements … … 179 185 if (!empty($element['type'])) { 180 186 if (!method_exists($this, "element_{$element['type']}")) { 181 $x = 1; //breakpoint for debugging187 $x = 1; //breakpoint for debugging 182 188 } 183 189 $output .= call_user_func([$this, "element_{$element['type']}"], $element); … … 191 197 return $output; 192 198 } 199 200 193 201 194 202 //filters the name field prior to walking … … 201 209 //note the $element->type component of the name is used in ajax post processing, so don't change this without considering the consequences 202 210 if (empty($element['name'])) { 203 $this->name = $element['name'] = "$id";211 $this->name = $element['name'] = "$id"; 204 212 } 205 213 206 214 return $element; 207 215 } 216 217 208 218 209 219 //filters the id field prior to walking … … 214 224 } 215 225 $this->id = $id; 216 $this->element_id = "dygform- {$this->form_name}{$this->instance}-element-$id";226 $this->element_id = "dygform-$this->form_name$this->instance-element-$id"; 217 227 return $id; 218 228 } 229 230 219 231 220 232 //returns the class, data, style etc parameters for an element … … 227 239 228 240 if (isset($element['value'])) { 229 $value = esc_html($element['value']); //encode any special charactes in VALUE so they are not interpreted as html markup241 $value = esc_html($element['value']); //encode any special charactes in VALUE so they are not interpreted as html markup 230 242 $parameters .= "value='{$value}' "; 231 243 } … … 309 321 } 310 322 323 324 311 325 /* markup for a generic label 312 326 */ 313 327 314 328 public function get_label($element) { 315 if (empty($element['label'])) {329 if (empty($element['label'])) 316 330 return ''; 317 }318 331 319 332 return strtr("<label class='dygform-label dygform-label-%type%required'>%label%help</label>", [ … … 325 338 } 326 339 340 341 327 342 /* markup for a help icon 328 343 */ 329 344 330 345 public function get_help($element) { 331 if (!array_key_exists('help', $element)) {346 if (!array_key_exists('help', $element)) 332 347 return ''; 333 }334 335 348 $slug = ($element['help'] != '' ? $element['help'] : str_replace('_', '-', $this->id)); 336 349 … … 340 353 } 341 354 355 356 342 357 /* markup for a required message 343 358 */ 344 359 345 360 public function get_required($element) { 346 if (empty($element['required-message'])) {361 if (empty($element['required-message'])) 347 362 return ''; 348 }349 363 350 364 return strtr("<label class='dygform-message-required'>%required</label>", [ 351 '%required' => esc_attr($element['required-message']), 352 ]); 353 } 365 '%required' => esc_attr($element['required-message']) 366 ]); 367 } 368 369 354 370 355 371 /* markup for a generic container style … … 360 376 } 361 377 378 379 362 380 /* markup for a generic container class 363 381 */ … … 366 384 return !empty($element['container-class']) ? dygpg_toolbox::sanitize_classes($element['container-class']) : ""; 367 385 } 386 387 368 388 369 389 /* surround the supplied html in a container … … 384 404 } 385 405 406 407 386 408 /* markup for a button element 387 409 * 'label' is the content inside the button … … 394 416 ]); 395 417 } 418 419 396 420 397 421 /* markup for an input tag … … 409 433 } 410 434 435 436 411 437 /* markup for a select list list li element 412 438 */ … … 419 445 } 420 446 447 448 421 449 /* markup for a jquery ui sortable/dragable set of lists 422 450 */ … … 425 453 426 454 $input = strtr("<input type='hidden' %parameters>" 427 . "<div class='dygform-select-list-wrapper'>%label%placeholder<ul class='dygform-included-list'></ul>"428 . "<ul class = 'dygform-source-list'>%list</ul></div>%required", [429 '%required' => $this->get_required($element),430 '%label' => $this->get_label($element),431 '%placeholder' => $this->get_placeholder_label($element),432 '%parameters' => $this->get_parameters($element, "dygform-input"),433 '%list' => $this->walk_elements($element['list']),434 ]);455 . "<div class='dygform-select-list-wrapper'>%label%placeholder<ul class='dygform-included-list'></ul>" 456 . "<ul class = 'dygform-source-list'>%list</ul></div>%required", [ 457 '%required' => $this->get_required($element), 458 '%label' => $this->get_label($element), 459 '%placeholder' => $this->get_placeholder_label($element), 460 '%parameters' => $this->get_parameters($element, "dygform-input"), 461 '%list' => $this->walk_elements($element['list']), 462 ]); 435 463 return $this->add_container($element, $input, 'dygform-select-list'); 436 464 } 437 465 466 467 438 468 /* markup for an textarea tag 439 469 */ 440 470 441 471 public function element_textarea($element) { 442 $placeholder_label = $textarea = strtr("%label%placeholder<textarea %parameters>%contains</textarea>%required", [472 $placeholder_label = $textarea = strtr("%label%placeholder<textarea %parameters>%contains</textarea>%required", [ 443 473 '%required' => $this->get_required($element), 444 474 '%parameters' => $this->get_parameters($element, "dygform-textarea"), … … 451 481 } 452 482 483 484 453 485 /* markup for a div 454 486 */ … … 461 493 } 462 494 495 496 463 497 /* markup for a field group 464 498 * 'label' is the text label at the top of the div … … 471 505 return "<div $parameters>{$label}{$element['contains']}</div>"; 472 506 } 507 508 473 509 474 510 /* markup for a select group of radio buttons or checkboxes … … 484 520 return "<div $parameters>{$label}{$options}{$required}</div>"; 485 521 } 522 523 486 524 487 525 /* markup for a select/option dropdown … … 498 536 } 499 537 538 539 500 540 /* markup for a select option group (drop down combo) 501 541 * 'label' is the text label at the top of the div … … 517 557 $e = new stdClass(); 518 558 $e_id = "{$element['id']}-input"; 519 @$e->{$e_id} = new stdClass();520 @$e->{$e_id}->type = 'input';521 @$e->{$e_id}->{'element-type'} = 'text';559 @$e->{$e_id} = new stdClass(); 560 @$e->{$e_id}->type = 'input'; 561 @$e->{$e_id}->{'element-type'} = 'text'; 522 562 $e->{$e_id}->placeholder = $element['placeholder'] ?? ''; 523 563 $e->{$e_id}->{'data-link'} = $element['data-link'] ?? ''; … … 530 570 } 531 571 572 573 532 574 /* markup for a select option 533 575 */ … … 540 582 return "<option $parameters>{$element['contains']}</option>"; 541 583 } 584 585 542 586 543 587 /* markup for a form … … 552 596 $stripe_key = !empty($this->form_data->credit_card) ? dyg_get_publishable_stripe_code() : ''; 553 597 554 return "$stripe_key<form $parameters data-form-name='{$this->form_name}{$this->instance}' data-instance='$this->instance'>{$element['contains']} $message</form>"; 555 } 598 return "$stripe_key<form $parameters data-form-name='$this->form_name$this->instance' data-instance='$this->instance'>{$element['contains']} $message</form>"; 599 } 600 601 556 602 557 603 /* outputs the message box … … 563 609 } 564 610 611 612 565 613 /* markup to support google recaptchav2. requires the api script to be enqueued 566 614 */ … … 574 622 return $output; 575 623 } 624 625 576 626 577 627 /* markup to support google recaptchav3. requires the api script to be enqueued. … … 590 640 } 591 641 642 643 592 644 /* 593 645 * markup for select label content to add extra formatting when the label contains sub content … … 605 657 ]); 606 658 } 659 660 607 661 608 662 /* markup for a checkboxes. Note, doubles up for markup of radio buttons as well … … 629 683 } 630 684 685 686 631 687 /* markup for a radio button 632 688 */ … … 635 691 return $this->element_checkbox($element, 'radio'); 636 692 } 693 694 637 695 638 696 /* markup for a credit card. note that is uses the card.js library … … 652 710 653 711 $cc = strtr("" 654 . "<div class='dygform-card-wrapper' %parameters>%label"655 . "<input autocomplete='cc-number' class='dygform-input dygform-cc-number dygform-no-post' placeholder='Card number' type='tel' name='number' value='%cc'>"656 . "<input autocomplete='cc-name'class='dygform-input dygform-cc-name' placeholder='Full name' type='text' name='name' value='%name'>"657 . "<input placeholder='MMYY' autocomplete='cc-exp' class='dygform-input dygform-cc-date dygform-no-post' placeholder='MM/YY' type='tel' name='expiry' value='%ex'>"658 . "<input autocomplete='cc-csc' class='dygform-input dygform-cc-cvc dygform-no-post' placeholder='CVC' type='number' name='cvc' value='%cvc'>"659 . "%required</div>"660 . "<div class='dygform-card-container'>"661 . "</div>"662 . "<script> new Card({form: document.querySelector('div'),container: '.dygform-card-container'});</script>",663 [664 '%parameters' => $this->get_parameters($element, "dygform-cc"),665 '%label' => $this->get_label($element),666 '%required' => $this->get_required($element),667 '%name' => $prefills['name'],668 '%cc' => $prefills['cc'],669 '%cvc' => $prefills['cvc'],670 '%ex' => $prefills['ex'],671 ]712 . "<div class='dygform-card-wrapper' %parameters>%label" 713 . "<input autocomplete='cc-number' class='dygform-input dygform-cc-number dygform-no-post' placeholder='Card number' type='tel' name='number' value='%cc'>" 714 . "<input autocomplete='cc-name'class='dygform-input dygform-cc-name' placeholder='Full name' type='text' name='name' value='%name'>" 715 . "<input placeholder='MMYY' autocomplete='cc-exp' class='dygform-input dygform-cc-date dygform-no-post' placeholder='MM/YY' type='tel' name='expiry' value='%ex'>" 716 . "<input autocomplete='cc-csc' class='dygform-input dygform-cc-cvc dygform-no-post' placeholder='CVC' type='number' name='cvc' value='%cvc'>" 717 . "%required</div>" 718 . "<div class='dygform-card-container'>" 719 . "</div>" 720 . "<script> new Card({form: document.querySelector('div'),container: '.dygform-card-container'});</script>", 721 [ 722 '%parameters' => $this->get_parameters($element, "dygform-cc"), 723 '%label' => $this->get_label($element), 724 '%required' => $this->get_required($element), 725 '%name' => $prefills['name'], 726 '%cc' => $prefills['cc'], 727 '%cvc' => $prefills['cvc'], 728 '%ex' => $prefills['ex'], 729 ] 672 730 ); 673 731 674 732 return $this->add_container($element, $cc); 675 733 } 734 735 676 736 677 737 public function prefill_element($element) { … … 702 762 } 703 763 764 765 704 766 // attempt to prefill the element value from a linked data field by applying the dygform-data-link-xxx filter 705 767 public function get_linked_value($element) { … … 742 804 } 743 805 806 807 744 808 /** 745 * returns a placeholder label element 809 * returns a placeholder label element 746 810 * @param type $element 747 811 */ 748 812 public function get_placeholder_label($element) { 749 if (!empty($element['label']) || empty($element['placeholder'])) {813 if (!empty($element['label']) || empty($element['placeholder'])) 750 814 return ''; 751 }752 815 753 816 return strtr("<div class='placeholder-label dygpg-placeholder-initial %required'>{$element['placeholder']}%help</div>", [ … … 757 820 } 758 821 822 823 759 824 } -
agb-free/trunk/dyg-form/includes/dyg-form-functions.php
r2926907 r2926915 9 9 /** 10 10 * ads additional select options to an existing select option group 11 * 12 * @param array $element- the select-option-group level element13 * @param array $options - an array of options to be included as both label and value14 * @param string $selected - the option to mark as selected15 */ 16 17 function dygform_add_options($element, $options, $selected) {18 if (!property_exists($element, 'options')) {11 * 12 * @param array $element - the select-option-group level element 13 * @param array $options - an array of options to be included as both label and value 14 * @param string $selected - the option to mark as selected 15 */ 16 17 function dygform_add_options($element, $options, $selected) { 18 if (!property_exists($element, 'options')) 19 19 return $element; 20 } 21 20 22 21 $add = (array) $element->options; 23 22 foreach ($options as $option) { 24 23 $add[] = (object) [ 25 "type" => 'option',26 "value" => $option,27 "parameter" => $option === $selected ? 'selected' : '',28 "contains" => $option,24 "type" => 'option', 25 "value" => $option, 26 "parameter" => $option === $selected ? 'selected' : '', 27 "contains" => $option 29 28 ]; 30 29 } … … 35 34 /** 36 35 * ads additional select options to an existing select option group 37 * 38 * @param type $element - the select-option-group level element39 * @param type $options - an array of options to be included as both label and value40 * @param type $selected - the option to mark as selected36 * 37 * @param type $element - the select-option-group level element 38 * @param type $options - an array of options to be included as both label and value 39 * @param type $selected - the option to mark as selected 41 40 */ 42 41 function dygform_add_options_array($element, $options, $selected) { … … 44 43 foreach ($options as $option) { 45 44 $add[] = (object) [ 46 "type" => 'option',47 "value" => $option['value'],48 "parameter" => $option['value'] === $selected ? 'selected' : '',49 "contains" => $option['contains'] ?? '',45 "type" => 'option', 46 "value" => $option['value'], 47 "parameter" => $option['value'] === $selected ? 'selected' : '', 48 "contains" => $option['contains'] ?? '' 50 49 ]; 51 50 } … … 54 53 } 55 54 55 56 56 /** 57 57 * ads li items for a list select group 58 * 59 * @param type $element - the select-option-group level element60 * @param type $options - an array of options to be included as both label and value61 * @param type $selected - the option to mark as selected58 * 59 * @param type $element - the select-option-group level element 60 * @param type $options - an array of options to be included as both label and value 61 * @param type $selected - the option to mark as selected 62 62 */ 63 63 function dygform_add_list($element, $options) { … … 69 69 70 70 $add[] = (object) [ 71 "type" => 'li',72 "value" => $value,73 "contains" => $contains,74 "class" => $class,71 "type" => 'li', 72 "value" => $value, 73 "contains" => $contains, 74 "class" => $class, 75 75 ]; 76 76 } … … 79 79 } 80 80 81 82 81 83 /** 82 84 * sets the radio/checkbox option with value = $value to checked 83 * 84 * @param type $element - the select group element. Must be passed by reference85 * @param type $value - the label value to match85 * 86 * @param type $element - the select group element. Must be passed by reference 87 * @param type $value - the label value to match 86 88 */ 87 89 function dygform_set_option(&$element, $value) { … … 93 95 } 94 96 97 98 99 /** 100 * walks through the data array looking for the $property element 101 * @param type $data - the form data 102 * @param type $property - the property element to find 103 * @param return = false if not found, or the element by reference 104 */ 105 function dygform_find_element(&$data, $property) { 106 $found = false; 107 foreach ($data as $key => &$element) { 108 if ($key === $property) { 109 return $element; 110 } 111 //walk deeper into the array if there is a contains property 112 if (is_object($element) && property_exists($element, 'contains') && is_object($element->contains)) { 113 $found = dygform_find_element($element->contains, $property); 114 } 115 //walk deeper into the array if there is an options property 116 if (is_object($element) && property_exists($element, 'options') && is_object($element->options)) { 117 $found = dygform_find_element($element->options, $property); 118 } 119 120 if ($found !== false) { 121 break; 122 } 123 } 124 return $found; 125 } 126 127 128 95 129 /** 96 130 * walks through the data structure and sets values from the array based on element type 97 * @param type $data - the form data131 * @param type $data - the form data 98 132 * @param type $values - an array of id => value pairs. 99 133 */ … … 127 161 } 128 162 163 164 129 165 /** 130 166 * converts the form fields into a list of args based on the data-link values. 131 * @param array$form167 * @param array $form 132 168 * @return array 133 169 */ … … 148 184 } 149 185 186 187 150 188 /** 151 189 * walks through the data structure and sets values from the array based on element type 152 * @param type $data - the form data190 * @param type $data - the form data 153 191 * @param type $properties - an array of id => value pairs. 154 192 */ … … 171 209 } 172 210 173 /** 174 * walks through the data array looking for the $property element 175 * @param type $data - the form data 176 * @param type $property - the property element to find 177 * @param return = false if not found, or the element by reference 178 */ 179 function dygform_find_element(&$data, $property) { 180 $found = false; 181 foreach ($data as $key => &$element) { 182 if ($key === $property) { 183 return $element; 184 } 185 //walk deeper into the array if there is a contains property 186 if (is_object($element) && property_exists($element, 'contains') && is_object($element->contains)) { 187 $found = dygform_find_element($element->contains, $property); 188 } 189 //walk deeper into the array if there is an options property 190 if (is_object($element) && property_exists($element, 'options') && is_object($element->options)) { 191 $found = dygform_find_element($element->options, $property); 192 } 193 194 if ($found !== false) { 195 break; 196 } 197 } 198 return $found; 199 } 200 201 // ---------------------------------------------------- 202 203 /** 204 * Attempts to insert a new element into a data object. 205 * If it cannot insert, it adds the element into a queue for later processing. 206 * 207 * 208 * @param object &$data - The data object to insert the element into. 209 * @param mixed $id - The ID of the property to insert the new element around. 210 * @param mixed $new_element - The new element to be inserted. 211 * @param bool $insert_before - If true, the new element is inserted before the specified property. 212 * @return bool - Returns true if the new element was successfully inserted, false otherwise. 213 */ 214 function dygform_insert_element(&$data, $id, $new_element, $insert_before = false) { 215 $result = dygform_find_add_element($data, $id, $new_element, $insert_before); 216 217 // if element was not added, add to queue 218 if (!$result) { 219 // check if queue exists, if not, initialize 220 if (!property_exists($data, '__queue')) { 221 $data->__queue = []; 222 } 223 // add the element, id and insert_before to queue 224 $data->__queue[] = ['id' => $id, 'new_element' => $new_element, 'insert_before' => $insert_before]; 225 } else { 226 dygform_process_queue($data); 227 } 228 return $result; 229 } 230 231 /** 232 * Processes the queue of elements that need to be added. 233 * It goes through each item in the queue and tries to add it. 234 * If the item is added successfully, it is removed from the queue. 235 * If the queue is empty after all items have been processed, it removes the __queue property. 236 * 237 * @param object &$data - The data object where elements are to be added. 238 */ 239 function dygform_process_queue(&$data) { 240 if (!property_exists($data, '__queue')) { 241 return; 242 } 243 244 $has_inserted = false; 245 // process each item in queue 246 foreach ($data->__queue as $key => $item) { 247 $item = json_decode(json_encode($item), true); 248 $result = dygform_find_add_element($data, $item['id'], $item['new_element'], $item['insert_before']); 249 250 // if element was added, remove from queue and set flag to true 251 if ($result) { 252 unset($data->__queue[$key]); 253 $has_inserted = true; 254 } 255 } 256 // if queue is empty, remove the __queue property 257 if (count($data->__queue) == 0) { 258 unset($data->__queue); 259 } else if ($has_inserted) { 260 // If an item was inserted, call the function again 261 dygform_process_queue($data); 262 } 263 } 264 265 /** 266 * Inserts a new element into a given data object either before or after a specific property. 267 * It searches recursively through the data object and its properties to find the specified property (ID) to insert the new element around. 268 * The function will first attempt to directly locate the property within the data object. 269 * If it doesn't find it at the top level, it will then walk deeper into each property of the data object, 270 * treating each property as a potential data object itself. 271 * 272 * If false or omitted, it is inserted after. 273 * 274 * @param object $data - The object into which the new element is to be inserted. 275 * @param mixed $id - The ID of the property to insert the new element around. 276 * @param array $new_element - The new element to be inserted. 277 * @param bool $insert_before- If true, the new element is inserted before the specified property. 278 * @return bool - Returns true if the new element was successfully inserted, false otherwise. 279 */ 280 281 function dygform_find_add_element(&$data, $id, $new_element, $insert_before = false) { 211 212 213 /** 214 * walks through the data structure and inserts $element after $id 215 * @param type $data - the form data 216 * @param type $key - the array key to insert after 217 */ 218 function dygform_insert_element(&$data, $id, $new_element) { 282 219 $found = false; 283 220 if (property_exists($data, $id)) { 284 $data_new = (object) dyg form_array_insert((array) $data, $id, $new_element, $insert_before);221 $data_new = (object) dyg_array_insert_after((array) $data, $id, $new_element); 285 222 $data = json_decode(json_encode($data_new)); 286 223 return true; 287 224 } 288 225 foreach ($data as &$element) { 226 //walk deeper into the array if there is a contains property 289 227 if (is_object($element)) { 290 $found = dygform_ find_add_element($element, $id, $new_element, $insert_before);228 $found = dygform_insert_element($element, $id, $new_element); 291 229 } 292 230 if ($found === true) { … … 297 235 } 298 236 299 /** 300 * Insert a value or key/value pair before or after a specific key in an array. 301 * If key doesn't exist, value is appended to the end of the array unless the append flag is false 302 * 303 * @param array $array - the original array 304 * @param string $key - the key to insert around 305 * @param array $new - the array to insert 306 * @param boolean $insertBefore - if true, insert before the key, else insert after 307 * @param boolean $append - if true and the key is not found, the new array is appended at the end 308 * @return array 309 */ 310 function dygform_array_insert(array $array, $key, array $new, $insertBefore = true, $append = true) { 311 $keys = array_keys($array); 312 $index = array_search($key, $keys); 313 314 if ($index === FALSE and !$append) { 315 return $array; 316 } 317 318 $pos = false === $index ? count($array) : ($insertBefore ? $index : $index + 1); 319 320 return array_merge(array_slice($array, 0, $pos), $new, array_slice($array, $pos)); 321 } 237 238 239 /** 240 * walks through the data structure and inserts $element before $id 241 * @param type $data - the form data 242 * @param type $key - the array key to insert after 243 */ 244 function dygform_insert_before_element(&$data, $id, $new_element) { 245 $found = false; 246 if (property_exists($data, $id)) { 247 $data_new = (object) dyg_array_insert_before((array) $data, $id, $new_element); 248 $data = json_decode(json_encode($data_new)); 249 return true; 250 } 251 foreach ($data as &$element) { 252 //walk deeper into the array if there is a contains property 253 if (is_object($element)) { 254 $found = dygform_insert_before_element($element, $id, $new_element); 255 } 256 if ($found === true) { 257 break; 258 } 259 } 260 return $found; 261 } 262 263 -
agb-free/trunk/dyg-grid/addons/free/dygpg-meta.php
r2926907 r2926915 2 2 3 3 /* 4 * adds post meta field shortcodes and processing. These fields control the formatting and 5 * separation of the post meta fields in the grid content area 4 * adds post meta fields into the grid content area 6 5 */ 7 6 8 new DygpgMeta();7 $dygpg_meta = new DygpgMeta(); 9 8 10 9 class DygpgMeta { … … 12 11 public function __construct() { 13 12 add_filter('dygpg-shortcode-array', [$this, 'shortcode_array']); 13 add_filter("dygform-filter-data-dygpg-form", [$this, 'modify_data'], 5, 1); 14 14 add_filter('dygpg-modify-style-array', [$this, 'modify_style_array'], 10, 2); 15 15 add_filter('dygpg-pattern-class', [$this, 'modify_pattern_class'], 10, 3); 16 16 17 } 18 19 /** 20 * adds an additional parameter to the shortcode array 21 * @param array $shortcode - array of shortcode elements 22 * @return string - modified shortcode array 23 */ 24 public function shortcode_array($shortcode) { 25 $shortcode['show_meta_icons'] = ''; 26 $shortcode['inline_separator'] = '|'; 27 $shortcode['inline_padding'] = '0em 0.2em'; 28 $shortcode['term_separator'] = ','; 29 $shortcode['term_padding'] = '0em 0.2em'; 30 $shortcode['title-tag'] = 'h3'; 31 $shortcode['button'] = 'More'; 32 return $shortcode; 17 $this->elements = apply_filters('dygpg-meta-elements', [ 18 'meta_wrapper' => [ 19 'type' => 'div', 20 'style' => 'display:none', 21 'contains' => [ 22 'inline_separator' => [ 23 'container-style' => '', 24 'container-class' => 'fourth-width', 25 'data-link' => 'inline_separator', 26 'type' => 'input', 27 'default' => '|', 28 'placeholder' => 'Inline Separator', 29 'parameter' => 'maxlength="1"', 30 'options' => [ 31 ], 32 ], 33 'inline_padding' => [ 34 'container-style' => '', 35 'container-class' => 'fourth-width', 36 'data-link' => 'inline_padding', 37 'type' => 'input', 38 'default' => '0em 0.2em', 39 'placeholder' => 'Inline Padding', 40 'options' => [ 41 ], 42 ], 43 'term_separator' => [ 44 'container-style' => '', 45 'container-class' => 'fourth-width', 46 'data-link' => 'term_separator', 47 'type' => 'input', 48 'default' => ',', 49 'placeholder' => 'Term Separator', 50 'parameter' => 'maxlength="1"', 51 'options' => [ 52 ], 53 ], 54 'term_padding' => [ 55 'container-style' => '', 56 'container-class' => 'fourth-width end', 57 'data-link' => 'term_padding', 58 'type' => 'input', 59 'default' => '0em 0.2em', 60 'placeholder' => 'Term Padding', 61 'options' => [ 62 ], 63 ], 64 'title_tag' => [ 65 'container-style' => '', 66 'container-class' => 'fourth-width', 67 'data-link' => 'title-tag', 68 'type' => 'dropdown_group', 69 'placeholder' => 'Title tag', 70 'default' => 'h3', 71 'options' => [ 72 ], 73 ], 74 'button_text' => [ 75 'type' => 'input', 76 'element-type' => 'text', 77 'placeholder' => 'Button text', 78 'container-class' => 'fourth-width end', 79 'data-link' => 'button', 80 ], 81 ], 82 ], 83 ]); 33 84 } 34 85 … … 56 107 } 57 108 109 /** 110 * adds an additional parameter to the shortcode array 111 * @param array $shortcode - array of shortcode elements 112 * @return string - modified shortcode array 113 */ 114 public function shortcode_array($shortcode) { 115 foreach ($this->elements['meta_wrapper']['contains'] as $element) { 116 $shortcode[$element['data-link']] = $element['default'] ?? ''; 117 } 118 $shortcode['show_meta_icons'] = ''; 119 return $shortcode; 120 } 121 122 /** 123 * adds additional post grid form editor elements to provide and interface for the new shortcode values 124 * @param type $data - array of form elements 125 */ 126 public function modify_data($data) { 127 dygform_insert_element($data, 'pattern', $this->elements); 128 $element = [ 129 'show_meta_icons' => [ 130 'type' => 'checkbox', 131 'data-link' => 'show_meta_icons', 132 'data-link-val' => 'Y', 133 'container-class' => '', 134 'label' => 'Show Meta Icons', 135 ], 136 ]; 137 dygform_insert_element($data, 'show_content', $element); 138 139 return $data; 140 } 141 58 142 } -
agb-free/trunk/dyg-grid/addons/free/dygpg_go_pro.php
r2926907 r2926915 14 14 15 15 //only proceed if pro addons are not present 16 if ( !is_agb_free()) {16 if (is_agb_pro()) { 17 17 return; 18 18 } … … 77 77 $output .= "<a target = '_blank' href='https://www.advancedgridbuilder.com/pricing'>Pricing</a>"; 78 78 $output .= "<a target = '_blank' href='https://www.advancedgridbuilder.com/#agb-demo'>Demo</a>"; 79 $output .= "<a target = '_blank' href='https://www.advancedgridbuilder.com/#introduction-video'>Video</a>"; 79 80 $output .= "</div>"; 80 81 $output .= self::generate_features_table(); … … 120 121 ]; 121 122 $f[] = [ 122 'label' => "Equalised Cell, Content and Title Heights",123 'span' => "dynamically with javascript",124 ];125 $f[] = [126 123 'label' => "Responsive Grid Layouts", 127 124 'span' => "customisable flex columns, horizontal fill, vertical fill, fixed width cells, responsive controls, custom gaps, custom breakpoints", … … 133 130 $f[] = [ 134 131 'label' => "Responsive Featured Image Control", 135 'span' => "srcset configuration or specific thumbnail sizes",132 'span' => "srcset configuration or specific thumbnail sizes", 136 133 ]; 137 134 $f[] = [ … … 142 139 'label' => "Theme Support", 143 140 'span' => 'All themes including Divi, Elementor, Astra, Blogus, Neve, OceanWP and Wordpress native themes', 144 ];145 $f[] = [146 'label' => "Access control",147 'span' => 'Specify the minimum user role required to access grid editing features',148 141 ]; 149 142 $f[] = [ … … 153 146 ]; 154 147 $f[] = [ 155 'label' => "Grid Types",156 'free' => 'Grids, lists',157 'pro' => '+ accordions, slideshows,',158 ];159 $f[] = [160 148 'label' => "Styling Themes", 161 'free' => "4 theme presets",162 'pro' => "+ lots more",149 'free' => '4 theme presets', 150 'pro' => 'lots of theme presets!!', 163 151 ]; 164 152 $f[] = [ … … 179 167 ]; 180 168 $f[] = [ 181 'label' => "Cell Click Action Control", 169 'label' => "Cell Click Action Control", 182 170 'free' => "link to post", 183 'pro' => "+ gallery lightbox, link buttons, custom link or disabled , Anchor/Page Scroll Links",171 'pro' => "+ gallery lightbox, link buttons, custom link or disabled", 184 172 ]; 185 173 $f[] = [ … … 235 223 'pro' => "click to open a lightbox gallery of post featured images", 236 224 ]; 225 226 $f[] = [ 227 'label' => "Equalised Cell and Title Heights", 228 'free' => $no, 229 'pro' => "dynamically with javascript", 230 ]; 237 231 $f[] = [ 238 232 'label' => "CSS Styling Matrix", … … 245 239 'pro' => "Inject freeform CSS using pre-populated or custom selectors", 246 240 ]; 241 242 247 243 248 244 return $f; … … 258 254 */ 259 255 public function add_form_elements($data) { 260 if (is_agb_free()) { 261 dygform_insert_element($data, 'style-presets-wrapper', $this->elements); 262 } else { 263 dygform_insert_element($data, 'image_wrapper', $this->elements); 264 } 265 256 dygform_insert_element($data, 'image_wrapper', $this->elements); 266 257 if (!is_agb_pro()) { 267 258 dygform_insert_element($data, 'show_wrapper', $this->elements2); -
agb-free/trunk/dyg-grid/addons/free/dygpg_grid_sizing.php
r2926907 r2926915 2 2 3 3 /* 4 grid sizing accordion extensions4 grid sizing accordion extensions 5 5 */ 6 6 7 7 8 new dygpg_grid_sizing(); … … 13 14 add_filter('dygpg-shortcode-array', [$this, 'shortcode_array']); 14 15 add_filter('dygpg-modify-style-array', [$this, 'modify_style_array'], 10, 2); 15 add_filter("dygpg-load-form", [$this, 'load_form'], 10, 2);16 add_filter('dygpg-class', [$this, 'filter_class'], 10, 2);17 16 } 18 17 19 /**20 * filters the dygpg-wrapper classes21 * adds classes to the grid wrapper to trigger row level element equalisation22 *23 * @param string $class - the current classes for the grid wrapper24 * @param DygPostGrid $obj - the current DygPostGrid object25 * @return string - the modified classes for the grid wrapper26 */27 public function filter_class($class, $obj) {28 if ($obj->args['equal-grid-heights'] === 'R') {29 $class .= ' dygpg-wrapper-equalise-grid-rows';30 }31 if ($obj->args['grid-justification'] === 'L') {32 $class .= ' dygpg-justification-left';33 }34 if ($obj->args['grid-justification'] === 'R') {35 $class .= ' dygpg-justification-right';36 }37 return $class;38 }39 18 40 /**41 * modifies the form data after fully loaded42 * adds the options for the equal cell heights option43 *44 * @param [array] $data45 * @param [type] $args46 * @return void47 */48 public function load_form($data, $args) {49 $styles = [];50 $styles[] = [51 'contains' => 'Same Row',52 'value' => 'R',53 ];54 $styles[] = [55 'contains' => 'All Cells',56 'value' => 'Y',57 ];58 $styles[] = [59 'contains' => 'Off',60 'value' => 'N',61 ];62 $e = dygform_find_element($data, 'equal_cell_heights_option');63 $e = dygform_add_options_array($e, $styles, $args['equal-grid-heights'] ?? 'N');64 65 $e = dygform_find_element($data, 'equal_content_heights_option');66 $e = dygform_add_options_array($e, $styles, $args['equal-content-heights'] ?? 'N');67 68 $e = dygform_find_element($data, 'equal_title_heights_option');69 $e = dygform_add_options_array($e, $styles, $args['equal-title-heights'] ?? 'N');70 return $data;71 }72 19 73 20 /** 74 21 * filters the inline style attribute of the main cell element 75 * @param string $style - css style22 * @param string $style - css style 76 23 * @param DygPostGrid object $obj 77 24 */ 78 25 public function modify_style_array($css, $obj) { 79 if ($obj->args['use-columns'] !== 'W') {26 if ($obj->args['use-columns'] !== 'W') 80 27 return $css; 81 }82 28 83 29 $css['cell']['statements'][] = "width: " . esc_attr($obj->args['width']); … … 87 33 } 88 34 35 36 89 37 /** 90 38 * adds an additional parameter to the shortcode array 91 * @param array$shortcode - array of shortcode elements39 * @param array $shortcode - array of shortcode elements 92 40 * @return string - modified shortcode array 93 41 */ 94 42 public function shortcode_array($shortcode) { 95 43 $shortcode['cell-margins'] = '10px'; 96 $shortcode['grid-justification'] = 'C';97 44 return $shortcode; 98 45 } 46 47 99 48 100 49 public function add_form_elements($data) { … … 180 129 ], 181 130 ], 182 'grid-justification-wrapper' => [ 183 'label' => 'Grid justification', 184 'type' => 'select_group', 185 'help' => 'cell-justification', 186 'options' => [ 187 'justification-left' => [ 188 'type' => 'radio', 189 'data-link' => 'grid-justification', 190 'data-link-val' => 'L', 191 'checked' => '', 192 'label' => 'Left', 193 ], 194 'justification-center' => [ 195 'type' => 'radio', 196 'data-link' => 'grid-justification', 197 'data-link-val' => 'C', 198 'checked' => '', 199 'label' => 'Center', 200 ], 201 'justification-right' => [ 202 'type' => 'radio', 203 'data-link' => 'grid-justification', 204 'data-link-val' => 'R', 205 'checked' => '', 206 'label' => 'Right', 207 ], 208 ], 209 ], 210 'equalise_heights' => [ 211 'label' => 'Equalise heights', 131 'cell_heights' => [ 132 'label' => 'Cell heights', 212 133 'type' => 'div', 213 'style' => ' ', 214 'help' => 'equalise-heights', 134 'help' => 'cell-heights', 215 135 'container-style' => 'width: 100%;', 216 136 'contains' => [ 217 'equal_title_heights_option' => [ 218 'type' => 'dropdown_group', 219 'data-link' => 'equal-title-heights', 137 'equal_cell_heights_option ' => [ 138 'type' => 'checkbox', 139 'data-link' => 'equal-grid-heights', 140 'data-link-val' => 'Y', 141 'container-class' => 'dygform-valign-select-input', 142 'checked' => 'checked', 143 'label' => 'Equalise', 144 ], 145 'cell_aspect_ratio' => [ 220 146 'container-class' => 'third-width', 221 'placeholder' => 'Title heights',222 'options' => [],223 ],224 'equal_content_heights_option' => [225 'type' => 'dropdown_group',226 'data-link' => 'equal-content-heights',227 'container-class' => 'third-width',228 'placeholder' => 'Content heights',229 'options' => [],230 ],231 'equal_cell_heights_option' => [232 'type' => 'dropdown_group',233 'data-link' => 'equal-grid-heights',234 'container-class' => 'third-width end',235 'placeholder' => 'Cell heights',236 'options' => [],237 ],238 ],239 ],240 'aspect_ratios' => [241 'label' => 'Aspect ratios',242 'type' => 'div',243 'help' => 'aspect-ratios',244 'container-style' => 'width: 100%;',245 'contains' => [246 'iclass_aspect_ratio' => [247 'container-class' => 'third-width',248 'container-style' => '',249 'type' => 'select_option_group',250 'data-link' => 'iclass-aspect-ratio',251 'placeholder' => 'Image aspect ratio',252 'options' => [253 0 => [254 'value' => '1:1',255 'type' => 'option',256 'contains' => '1:1',257 ],258 1 => [259 'value' => '4:3',260 'type' => 'option',261 'contains' => '4:3',262 ],263 2 => [264 'value' => '16:9',265 'type' => 'option',266 'contains' => '16:9',267 ],268 3 => [269 'value' => 'match_image',270 'type' => 'option',271 'contains' => 'match_image',272 ],273 ],274 ],275 'content_aspect_ratio' => [276 'container-class' => 'third-width',277 'container-style' => '',278 'type' => 'select_option_group',279 'data-link' => 'content-aspect-ratio',280 'placeholder' => 'Content aspect ratio',281 'parameter' => 'required',282 'options' => [283 0 => [284 'value' => '1:1',285 'type' => 'option',286 'contains' => '1:1',287 ],288 1 => [289 'value' => '4:3',290 'type' => 'option',291 'contains' => '4:3',292 ],293 2 => [294 'value' => '16:9',295 'type' => 'option',296 'contains' => '16:9',297 ],298 3 => [299 'value' => 'match_image',300 'type' => 'option',301 'contains' => 'match_image',302 ],303 ],304 ],305 'cell_aspect_ratio' => [306 'container-class' => 'third-width end',307 147 'container-style' => '', 308 148 'type' => 'select_option_group', … … 343 183 } 344 184 185 186 345 187 } -
agb-free/trunk/dyg-grid/addons/free/dygpg_styles_css.php
r2926907 r2926915 2 2 3 3 /* 4 * adds logic and processing for css matrix panel fields4 * adds input fields for CSS attribute values to the CSS / Classes panel 5 5 */ 6 6 7 $dygpg_styles_css =new dygpg_styles_css();7 new dygpg_styles_css(); 8 8 9 9 class dygpg_styles_css { … … 11 11 public function __construct() { 12 12 add_filter('dygpg-shortcode-array', [$this, 'shortcode_array']); 13 add_filter("dygform-filter-data-dygpg-form", [$this, 'modify_form'], 10, 1); 13 14 add_filter('dygpg-modify-style-array', [$this, 'modify_style_array'], 10, 2); 14 15 $this->defaults = [];16 $this->elements = ['cell', 'content', 'image', 'title'];17 $this->attributes = ['background-color', 'border-radius', 'border', 'padding', 'margin', 'text-align', 'color', 'font-size', 'line-height', 'text-transform', 'position', 'top', 'left', 'opacity', 'z-index'];15 16 $this->defaults = []; 17 $this->elements = ['cell', 'content', 'image', 'title' ]; 18 $this->attributes = ['background-color', 'border-radius', 'border', 'padding', 'margin','text-align', 'color', 'font-size', 'line-height', 'text-transform']; 18 19 $this->defaults['attribute_padding_content'] = '10px 0px 0px 0px'; 19 20 20 21 $this->shortcodes = []; 21 22 } 22 23 24 25 23 26 /** 24 27 * filters the inline style attribute of the main cell element 25 * @param string $style - css style28 * @param string $style - css style 26 29 * @param DygPostGrid object $obj 27 30 */ … … 42 45 $css["attribute_border-radius_cell_before"]['statements'][] = "border-radius: " . esc_attr($obj->args["attribute_border-radius_cell"]); 43 46 } 44 47 45 48 //special case to apply image centering to pattern 46 49 if (!empty($obj->args["attribute_text-align_image"])) { … … 53 56 54 57 58 59 /** 60 * adds additional post grid form editor elements to provide and interface for the new shortcode values 61 * @param type $data - array of form elements 62 */ 63 public function modify_form($data) { 64 $fields = []; 65 $column_count = count($this->elements); 66 $columns = $column_count; 67 68 //column headers 69 foreach ($this->elements as $element) { 70 $x = ($column_count - 1) * 20; 71 $columns--; 72 $fields["attribute_header_{$element}"] = [ 73 "type" => "div", 74 "container-class" => $columns === 0 ? 'half-width end' : 'half-width', 75 "container-style" => "text-align: center;width: calc(calc(100% - {$x}px) / $column_count);", 76 "contains" => $element, 77 ]; 78 } 79 80 //attribute fields 81 foreach ($this->attributes as $attribute) { 82 83 $columns = $column_count; 84 foreach ($this->elements as $element) { 85 $x = ($column_count - 1) * 20; 86 $columns--; 87 $this->shortcodes[] = "attribute_{$attribute}_{$element}"; 88 $fields["attribute_{$attribute}_{$element}"] = [ 89 "type" => "input", 90 "element-type" => "text", 91 "container-class" => $columns === 0 ? 'half-width end' : 'half-width', 92 "container-style" => "width: calc(calc(100% - {$x}px) / $column_count);", 93 "placeholder" => $attribute, 94 "data-link" => "attribute_{$attribute}_{$element}", 95 ]; 96 } 97 } 98 99 $set = [ 100 'css_attributes_wrapper' => [ 101 'label' => 'CSS Attributes', 102 'type' => 'div', 103 'container-class' => 'dygform-accordion', 104 'help' => 'panel/dynamic-sorting-filtering', 105 'style' => 'display:none;', 106 'contains' => 107 $fields 108 ], 109 ]; 110 dygform_insert_element($data, 'widget_wrapper', $set); 111 return $data; 112 } 113 114 115 55 116 /** 56 117 * adds an additional parameter to the shortcode array 57 * @param array$shortcode - array of shortcode elements118 * @param array $shortcode - array of shortcode elements 58 119 * @return string - modified shortcode array 59 120 */ … … 67 128 } 68 129 130 131 69 132 } -
agb-free/trunk/dyg-grid/addons/free/dygpg_styles_free.php
r2926907 r2926915 25 25 'container-style' => 'width: 100%;', 26 26 'contains' => [ 27 28 'style-preset-options-header' => [29 'type' => 'div',30 'label' => 'Basic styles',31 'help' => 'basic-styles',32 'contains' => '',33 ],34 27 'style-reset' => [ 35 28 'type' => 'checkbox', … … 42 35 'style' => 'font-size: 200%;', 43 36 'hide' => '', 37 ], 38 'style-preset-options-header' => [ 39 'type' => 'div', 40 'label' => 'Basic styles', 41 'help' => 'basic-styles', 42 'contains' => '', 44 43 ], 45 44 'style-preset-options' => [ … … 193 192 $styles = []; 194 193 $styles[] = [ 195 'contains' => ' Enhanced Blog Index',194 'contains' => 'Blog', 196 195 'value' => 'dygpg-blog', 197 196 ]; … … 237 236 public function style_selected($args, $class) { 238 237 if ($class === 'dygpg-blog') { 239 $args['attribute_border_cell'] = '1px solid lightblue'; 238 $args['button'] = 'More'; 239 $args['columns'] = '3,3,2,1'; 240 $args['equal-grid-heights'] = 'Y'; 241 $args['equal-title-heights'] = is_agb_pro() ? 'Y' : ''; 242 $args['link-titles'] = 'Y'; 243 $args['pattern'] = '%image%,%<,%title%,%category%,%excerpt%,%button%,%>'; 244 $args['attribute_border_cell'] = '1px solid lightblue'; 240 245 $args['attribute_padding_content'] = '17px'; 241 $args['button'] = 'More';242 $args['columns'] = '3,3,2,1';243 $args['equal-content-heights'] = '';244 $args['equal-grid-heights'] = 'Y';245 $args['equal-title-heights'] = 'Y';246 $args['link-titles'] = 'Y';247 $args['load-more-button-label'] = '';248 $args['order'] = 'ASC';249 $args['orderby'] = 'ID';250 $args['pagesize'] = '3';251 $args['pattern'] = '%image%,%<,%date%,%author%,%category%,%title%,%excerpt%,%button%,%>';252 $args['pattern-direction'] = '%facebook_share%,%twitter_share%,%linkedin_share%,%date%,%author%,%category%,%download_image%';253 $args['preset'] = 'dygpg-blog';254 $args['show_meta_icons'] = 'Y';255 $args['tax-operator'] = 'IN';256 $args['transition'] = 'none';257 $args['use-ajax'] = '';258 259 246 } 260 247 if ($class === 'dygpg-blog-fade') { 261 $args['attribute_border_cell'] = '1px solid lightblue'; 262 $args['attribute_padding_cell'] = '20px'; 263 $args['attribute_padding_content'] = '20px'; 264 $args['columns'] = '3,3,2,1'; 265 $args['equal-content-heights'] = 'Y'; 266 $args['equal-grid-heights'] = 'R'; 267 $args['iclass-aspect-ratio'] = ''; 268 $args['pattern'] = '%<,%excerpt%,%>,%date%,%category%,%author%,%title%'; 269 $args['pattern-direction'] = '%date%,%category%,%author%'; 270 $args['preset'] = 'dygpg-blog-fade'; 248 $args['columns'] = '3,3,2,1'; 249 $args['equal-grid-heights'] = 'Y'; 250 $args['equal-title-heights'] = ''; 251 $args['pattern'] = '%<,%excerpt%,%>,%date%,%category%,%author%,%title%'; 252 $args['pattern-direction'] = '%date%,%category%,%author%'; 253 $args['transition'] = 'fade'; 254 $args['attribute_border_cell'] = '1px solid lightblue'; 255 $args['attribute_padding_cell'] = '20px'; 256 $args['attribute_padding_content'] = '20px'; 271 257 $args['style-center-content-horizontal'] = 'Y'; 272 $args['style-center-content-vertical'] = 'Y'; 273 $args['transition'] = 'fade'; 258 $args['style-center-content-vertical'] = 'Y'; 274 259 } 275 260 if ($class === 'dygpg-list') { -
agb-free/trunk/dyg-grid/addons/free/dygpg_transitions_free.css
r2926907 r2926915 4 4 height: 100%; 5 5 object-fit: cover; 6 left: 0px;7 top: 0px;8 6 } 9 7 .dygpg-transition-wrapper { … … 17 15 /*flipy start*/ 18 16 19 .dygpg-transition-wrapper.dygpg-transition-flipy .dygpg-transition-link,20 17 .dygpg-transition-wrapper.dygpg-transition-flipy .dygpg-transition-image { 21 18 z-index: 2; /* back side, placed above front */ … … 35 32 } 36 33 .dygpg-transition-wrapper.dygpg-transition-flipy .dygpg-content, 37 .dygpg-transition-wrapper.dygpg-transition-flipy .dygpg-transition-link,38 34 .dygpg-transition-wrapper.dygpg-transition-flipy .dygpg-transition-image 39 35 { … … 52 48 } 53 49 54 .dygpg-transition-wrapper.dygpg-transition-flipx .dygpg-transition-link,55 50 .dygpg-transition-wrapper.dygpg-transition-flipx .dygpg-transition-image { 56 51 z-index: 2; /* back side, placed above front */ … … 66 61 } 67 62 .dygpg-transition-wrapper.dygpg-transition-flipx .dygpg-content, 68 .dygpg-transition-wrapper.dygpg-transition-flipx .dygpg-transition-image, 69 .dygpg-transition-wrapper.dygpg-transition-flipx .dygpg-transition-link 63 .dygpg-transition-wrapper.dygpg-transition-flipx .dygpg-transition-image 70 64 { 71 65 backface-visibility: hidden; … … 84 78 } 85 79 86 .dygpg-transition-wrapper.dygpg-transition-flip-side .dygpg-transition-link,87 80 .dygpg-transition-wrapper.dygpg-transition-flip-side .dygpg-transition-image { 88 81 z-index: 2; /* back side, placed above front */ … … 99 92 } 100 93 .dygpg-transition-wrapper.dygpg-transition-flip-side .dygpg-content, 101 .dygpg-transition-wrapper.dygpg-transition-flip-side .dygpg-transition-link,102 94 .dygpg-transition-wrapper.dygpg-transition-flip-side .dygpg-transition-image 103 95 { -
agb-free/trunk/dyg-grid/css/dyg-post-grid-templates.css
r2926907 r2926915 5 5 justify-content: center; 6 6 position: relative; 7 }8 .dygpg-justification-left {9 justify-content: flex-start;10 }11 .dygpg-justification-right {12 justify-content: flex-end;13 7 } 14 8 … … 201 195 202 196 .dygpg-center-text .dygpg-content, 203 .dygpg-center-text .dygpg-pattern-button,204 197 .dygpg-center-text .dygpg-text { 205 198 text-align: center; -
agb-free/trunk/dyg-grid/css/dyg-post-grid.css
r2926907 r2926915 129 129 border: 1px solid darkred; 130 130 transform: scale(1); 131 z-index: 999 99;131 z-index: 999; 132 132 } 133 133 … … 348 348 } 349 349 350 .dygpg-pattern-show_woo_sold_badge {351 padding: 0px!important;352 }353 354 350 .dyg-post-grid-wrapper.dygpg-fonts .dygpg-pattern div { 355 351 font-weight: 400; -
agb-free/trunk/dyg-grid/css/dygpg-form.css
r2926907 r2926915 181 181 padding-top: 30px; 182 182 border: 4px solid #e3ebf6; 183 z-index: 9999 99;183 z-index: 9999; 184 184 } 185 185 -
agb-free/trunk/dyg-grid/dyg-post-grid.php
r2926907 r2926915 11 11 $dygpg_state = []; 12 12 13 define('AGB_VERSION', '4. 5.0');13 define('AGB_VERSION', '4.1.0'); 14 14 15 15 include_once DYG_STYLESHEET_DIRECTORY . '/dyg-grid/includes/class-dygpg-db.php'; … … 25 25 function __construct() { 26 26 //include all addons 27 foreach (glob(DYG_STYLESHEET_DIRECTORY . "/dyg-grid/addons/ free/*.php") as $filename) {27 foreach (glob(DYG_STYLESHEET_DIRECTORY . "/dyg-grid/addons/pro/*.php") as $filename) { 28 28 include_once $filename; 29 29 } 30 foreach (glob(DYG_STYLESHEET_DIRECTORY . "/dyg-grid/addons/ pro/*.php") as $filename) {30 foreach (glob(DYG_STYLESHEET_DIRECTORY . "/dyg-grid/addons/free/*.php") as $filename) { 31 31 include_once $filename; 32 32 } … … 52 52 53 53 $result = $pg->dyg_post_grid($shortcode_atts, $inner); 54 55 54 return $result; 56 55 } -
agb-free/trunk/dyg-grid/forms/dygpg-form.php
r2926907 r2926915 1 1 <?php 2 2 3 3 4 return [ 4 'settings' => [5 'form_class' => 'dygpg-draggable',5 'settings' => [ 6 'form_class' => 'dygpg-draggable', 6 7 'ignore_recaptcha' => 'false', 7 'store' => 'false',8 'help_base' => 'https://www.advancedgridbuilder.com/',9 ], 10 'nav' => [11 'type' => 'div',12 'help' => 'navigation-icons',8 'store' => 'false', 9 'help_base' => 'https://www.advancedgridbuilder.com/', 10 ], 11 'nav' => [ 12 'type' => 'div', 13 'help' => 'navigation-icons', 13 14 'required-message' => '', 14 'hidden' => '',15 'element-type' => '',16 'autocomplete' => '',17 'name' => '',18 'label' => ' ',19 'placeholder' => '',20 'value' => '',21 'parameters' => '',22 'readonly' => '',23 'class' => '',24 'container-class' => 'dygpg-nav',25 'style' => '',26 'container-style' => '',27 'data-link' => '',28 'data-link-val' => '',29 'show' => '',30 'hide' => '',31 'rows' => '',32 'contains' => ""15 'hidden' => '', 16 'element-type' => '', 17 'autocomplete' => '', 18 'name' => '', 19 'label' => ' ', 20 'placeholder' => '', 21 'value' => '', 22 'parameters' => '', 23 'readonly' => '', 24 'class' => '', 25 'container-class' => 'dygpg-nav', 26 'style' => '', 27 'container-style' => '', 28 'data-link' => '', 29 'data-link-val' => '', 30 'show' => '', 31 'hide' => '', 32 'rows' => '', 33 'contains' => "" 33 34 . "<div class='dygpg-undo'><div>%undo%</div><i title='undo delete' class='fas fa-undo dygpg-undo'></i></div>" 34 35 . "<div class='dygpg-undo dygpg-redo'><div>%redo%</div><i title='undo delete' class='fas fa-redo dygpg-redo'></i></div>" … … 39 40 . "<div class='dygpg-version'>AGB " . (is_agb_theme() ? 'Theme v' : (is_agb_pro() ? 'Pro v' : 'Free v')) . AGB_VERSION . "</div>", 40 41 ], 41 'id' => [42 'type' => 'input',42 'id' => [ 43 'type' => 'input', 43 44 'container-style' => '', 44 'hidden' => 'hidden',45 'name' => 'id',46 ], 47 'version' => [48 'type' => 'input',45 'hidden' => 'hidden', 46 'name' => 'id', 47 ], 48 'version' => [ 49 'type' => 'input', 49 50 'container-style' => '', 50 'hidden' => 'hidden',51 'name' => 'id',52 'data-link' => 'version',53 ], 54 'demo_id' => [55 'type' => 'input',51 'hidden' => 'hidden', 52 'name' => 'id', 53 'data-link' => 'version', 54 ], 55 'demo_id' => [ 56 'type' => 'input', 56 57 'container-style' => '', 57 'hidden' => 'hidden',58 'name' => 'demo-id',59 'data-link' => 'demo-id',60 'data-link-val' => '',61 ], 62 'undo' => [63 'type' => 'input',58 'hidden' => 'hidden', 59 'name' => 'demo-id', 60 'data-link' => 'demo-id', 61 'data-link-val' => '', 62 ], 63 'undo' => [ 64 'type' => 'input', 64 65 'container-style' => '', 65 'hidden' => 'hidden',66 'name' => 'undo',67 'data-link' => 'undo',68 'value' => '',69 ], 70 'revised_id' => [71 'type' => 'input',66 'hidden' => 'hidden', 67 'name' => 'undo', 68 'data-link' => 'undo', 69 'value' => '', 70 ], 71 'revised_id' => [ 72 'type' => 'input', 72 73 'container-style' => 'width: calc(100% - 260px);', 73 'style' => 'font-weight: 600;',74 'data-link' => 'id',75 'parameter' => 'disabled',76 'placeholder' => 'Postgrid ID',77 ], 78 'index' => [79 'type' => 'input',80 'hidden' => 'hidden', 81 'name' => 'id',74 'style' => 'font-weight: 600;', 75 'data-link' => 'id', 76 'parameter' => 'disabled', 77 'placeholder' => 'Postgrid ID', 78 ], 79 'index' => [ 80 'type' => 'input', 81 'hidden' => 'hidden', 82 'name' => 'id', 82 83 ], 83 84 'content_wrapper' => [ 84 'type' => 'div',85 'label' => 'Content source',86 'help' => 'panel/content-source',85 'type' => 'div', 86 'label' => 'Content source', 87 'help' => 'panel/content-source', 87 88 'container-class' => 'dygform-accordion', 88 'contains' => [ 89 'content_type' => [ 90 'label' => 'Query source', 91 'type' => 'select_group', 92 'help' => 'query-source', 89 'contains' => [ 90 'content_type' => [ 91 'label' => 'Query source', 92 'type' => 'select_group', 93 93 'options' => [ 94 94 'type_post' => [ 95 'type' => 'radio', 96 'label' => 'Post Type', 97 'data-link' => 'content', 95 'type' => 'radio', 96 'label' => 'Post Type', 97 'data-link' => 'content', 98 'help' => 'post-type', 98 99 'data-link-val' => 'POST', 99 'show' => '.dygform-container-post_type,.dygform-container-filter_term,.dygform-container-filter_taxonomy,.dygform-container-filter_operator', 100 ], 101 ], 102 ], 103 'post_type' => [ 100 'help' => 'post-type', 101 'show' => '.dygform-container-post_type,.dygform-container-filter_term,.dygform-container-filter_taxonomy,.dygform-container-filter_operator', 102 ], 103 ], 104 ], 105 'post_type' => [ 104 106 'container-class' => 'dygform-hidden', 105 'type' => 'dropdown_group',106 'hidden' => 'hidden',107 'type' => 'dropdown_group', 108 'hidden' => 'hidden', 107 109 'container-style' => 'display:none;', 108 'placeholder' => 'Post type',109 'data-link' => 'posttype',110 'options' => [111 ], 112 ], 113 'filter_taxonomy' => [110 'placeholder' => 'Post type', 111 'data-link' => 'posttype', 112 'options' => [ 113 ], 114 ], 115 'filter_taxonomy' => [ 114 116 'container-class' => 'dygform-hidden third-width', 115 117 'container-style' => '', 116 'type' => 'select_option_group',117 'data-link' => 'taxonomy',118 'placeholder' => 'Taxonomy filter',119 'parameter' => 'required',120 'options' => [121 ], 122 ], 123 'filter_operator' => [118 'type' => 'select_option_group', 119 'data-link' => 'taxonomy', 120 'placeholder' => 'Taxonomy filter', 121 'parameter' => 'required', 122 'options' => [ 123 ], 124 ], 125 'filter_operator' => [ 124 126 'container-class' => 'dygform-hidden third-width', 125 127 'container-style' => '', 126 'type' => 'dropdown_group',127 'data-link' => 'tax-operator',128 'placeholder' => 'Filter operator',129 'options' => [130 ], 131 ], 132 'filter_term' => [133 'placeholder' => 'Filter term slug',128 'type' => 'select_option_group', 129 'data-link' => 'tax-operator', 130 'placeholder' => 'Filter operator', 131 'options' => [ 132 ], 133 ], 134 'filter_term' => [ 135 'placeholder' => 'Filter term slug', 134 136 'container-class' => 'dygform-hidden third-width end', 135 137 'container-style' => '', 136 'type' => 'select_option_group',137 'data-link' => 'tax-terms',138 'element-type' => 'text',139 'options' => [140 ], 141 ], 142 'term' => [143 'placeholder' => 'Taxonomy',138 'type' => 'select_option_group', 139 'data-link' => 'tax-terms', 140 'element-type' => 'text', 141 'options' => [ 142 ], 143 ], 144 'term' => [ 145 'placeholder' => 'Taxonomy', 144 146 'container-class' => 'dygform-hidden third-width', 145 147 'container-style' => '', 146 'type' => 'select_option_group',147 'data-link' => 'term',148 'element-type' => 'text',149 'options' => [148 'type' => 'select_option_group', 149 'data-link' => 'term', 150 'element-type' => 'text', 151 'options' => [ 150 152 ], 151 153 ], 152 154 'attached_taxonomies' => [ 153 'type' => 'checkbox',154 'data-link' => 'attached-taxonomies',155 'data-link-val' => 'Y',156 'value' => '',157 'checked' => 'checked',155 'type' => 'checkbox', 156 'data-link' => 'attached-taxonomies', 157 'data-link-val' => 'Y', 158 'value' => '', 159 'checked' => 'checked', 158 160 'container-class' => 'dygform-hidden dygform-valign-select-input', 159 161 'container-style' => '', 160 'label' => 'Only terms attached to the current post',161 ], 162 'number-of-posts' => [163 'label' => 'Number of posts',164 'type' => 'div',165 'style' => ' ',166 'help' => 'number-of-posts',162 'label' => 'Only terms attached to the current post', 163 ], 164 'number-of-posts' => [ 165 'label' => 'Number of posts', 166 'type' => 'div', 167 'style' => ' ', 168 'help' => 'number-of-posts', 167 169 'container-style' => 'width: 100%;', 168 'contains' => [170 'contains' => [ 169 171 'num_posts' => [ 170 172 'container-class' => 'third-width', 171 'data-link' => 'numposts',172 'type' => 'input',173 'element-type' => 'number',174 'placeholder' => 'Max posts',173 'data-link' => 'numposts', 174 'type' => 'input', 175 'element-type' => 'number', 176 'placeholder' => 'Max posts', 175 177 ], 176 178 'page-size' => [ 177 'data-link' => 'pagesize',179 'data-link' => 'pagesize', 178 180 'container-class' => 'third-width', 179 'element-type' => 'number',180 'type' => 'input',181 'placeholder' => 'Page size',182 ], 183 ], 184 ], 185 'sort_wrapper' => [186 'label' => 'Sort order',187 'type' => 'div',188 'style' => ' ',189 'help' => 'sort-order',181 'element-type' => 'number', 182 'type' => 'input', 183 'placeholder' => 'Page size', 184 ], 185 ], 186 ], 187 'sort_wrapper' => [ 188 'label' => 'Sort order', 189 'type' => 'div', 190 'style' => ' ', 191 'help' => 'sort-order', 190 192 'container-style' => 'width: 100%; ', 191 'contains' => [193 'contains' => [ 192 194 'order_by' => [ 193 195 'container-class' => 'third-width', 194 'data-link' => 'orderby',195 'type' => 'select_option_group',196 'placeholder' => 'Order by',197 'options' => [196 'data-link' => 'orderby', 197 'type' => 'select_option_group', 198 'placeholder' => 'Order by', 199 'options' => [ 198 200 ], 199 201 ], 200 202 'meta_key' => [ 201 'data-link' => 'meta-key',203 'data-link' => 'meta-key', 202 204 'container-class' => 'third-width', 203 'type' => 'input',204 'placeholder' => 'Meta key',205 ], 206 'order' => [205 'type' => 'input', 206 'placeholder' => 'Meta key', 207 ], 208 'order' => [ 207 209 'container-class' => 'third-width end', 208 'data-link' => 'order',209 'type' => 'dropdown_group',210 'placeholder' => 'Order',211 'options' => [210 'data-link' => 'order', 211 'type' => 'dropdown_group', 212 'placeholder' => 'Order', 213 'options' => [ 212 214 ], 213 215 ], … … 216 218 ], 217 219 ], 218 'show_wrapper' => [219 'label' => 'Show elements',220 'type' => 'div',221 'style' => 'display:none;',220 'show_wrapper' => [ 221 'label' => 'Show elements', 222 'type' => 'div', 223 'style' => 'display:none;', 222 224 'container-class' => 'dygform-accordion', 223 'help' => 'panel/show-elements',225 'help' => 'panel/show-elements', 224 226 'container-style' => 'width: 100%;', 225 'contains' => [226 'show_elements' => [227 'label' => 'Show Elements',228 'help' => 'show-elements',229 'type' => 'select_group',227 'contains' => [ 228 'show_elements' => [ 229 'label' => 'Show Elements', 230 'help' => 'show-elements', 231 'type' => 'select_group', 230 232 'options' => [ 231 233 'show_content' => [ 232 'type' => 'checkbox',233 'data-link' => 'show-content',234 'type' => 'checkbox', 235 'data-link' => 'show-content', 234 236 'data-link-val' => 'Y', 235 'checked' => 'checked',236 'show' => '#dygform-dygpg-form-brandnew-element-equal_heights',237 'label' => 'Content wrapper',238 ], 239 ], 240 ], 241 'pattern_wrapper' => [242 'type' => 'div',237 'checked' => 'checked', 238 'show' => '#dygform-dygpg-form-brandnew-element-equal_heights', 239 'label' => 'Content wrapper', 240 ], 241 ], 242 ], 243 'pattern_wrapper' => [ 244 'type' => 'div', 243 245 'contains' => [ 244 246 'pattern-direction' => [ 245 247 'data-link' => 'pattern-direction', 246 'type' => 'input',247 'hidden' => 'hidden',248 'flags' => 'complex',249 ], 250 'pattern' => [248 'type' => 'input', 249 'hidden' => 'hidden', 250 'flags' => 'complex', 251 ], 252 'pattern' => [ 251 253 'container-style' => '', 252 254 'container-class' => '', 253 'data-link' => 'pattern', 254 'label' => 'Elements Pattern', 255 'help' => 'elements-pattern', 256 'type' => 'select_list', 257 'placeholder' => 'Elements Pattern', 258 'list' => [ 255 'data-link' => 'pattern', 256 'type' => 'select_list', 257 'placeholder' => 'Elements Pattern', 258 'list' => [ 259 259 ], 260 260 ], 261 261 ], 262 262 ], 263 'equal_title_heights' => [ 264 'label' => 'Equalise heights', 265 'type' => 'div', 266 'style' => ' ', 267 'help' => 'equalise-title-heights', 268 'container-style' => 'width: 100%;', 269 'contains' => [ 270 'equal_title_heights_option' => [ 271 'type' => 'checkbox', 272 'data-link' => 'equal-title-heights', 273 'data-link-val' => 'Y', 274 'container-class' => 'dygform-valign-select-input', 275 'checked' => 'checked', 276 'label' => 'Titles', 277 ], 278 'equal_content_heights_option' => [ 279 'type' => 'checkbox', 280 'data-link' => 'equal-content-heights', 281 'data-link-val' => 'Y', 282 'container-class' => 'dygform-valign-select-input', 283 'checked' => 'checked', 284 'label' => 'Content wrapper', 285 ], 286 'content_aspect_ratio' => [ 287 'container-class' => 'third-width', 288 'container-style' => '', 289 'type' => 'select_option_group', 290 'data-link' => 'content-aspect-ratio', 291 'placeholder' => 'Content aspect ratio', 292 'parameter' => 'required', 293 'options' => [ 294 0 => [ 295 'value' => '1:1', 296 'type' => 'option', 297 'contains' => '1:1', 298 ], 299 1 => [ 300 'value' => '4:3', 301 'type' => 'option', 302 'contains' => '4:3', 303 ], 304 2 => [ 305 'value' => '16:9', 306 'type' => 'option', 307 'contains' => '16:9', 308 ], 309 3 => [ 310 'value' => 'match_image', 311 'type' => 'option', 312 'contains' => 'match_image', 313 ], 314 ], 315 ], 316 ], 317 ], 263 318 ], 264 319 ], 265 266 'submit' => [ 267 'type' => 'button', 320 'image_wrapper' => [ 321 'type' => 'div', 322 'label' => 'Image settings', 323 'container-class' => 'dygform-accordion', 324 'help' => 'panel/image-settings', 325 'style' => 'display:none;', 326 'contains' => [ 327 'image_location' => [ 328 'type' => 'select_group', 329 'label' => 'Image location', 330 'help' => 'image-location', 331 'options' => [ 332 0 => [ 333 'type' => 'radio', 334 'label' => 'Background', 335 'checked' => '', 336 'value' => '', 337 'contains' => '', 338 'data-link' => 'image', 339 'data-link-val' => 'B', 340 'show' => '', 341 'hide' => '.dygform-container-iclass_aspect_ratio', 342 ], 343 1 => [ 344 'type' => 'radio', 345 'label' => 'Content', 346 'checked' => '', 347 'value' => '', 348 'contains' => '', 349 'data-link' => 'image', 350 'data-link-val' => 'Y', 351 'show' => '.dygform-container-iclass_aspect_ratio', 352 'hide' => '', 353 ], 354 2 => [ 355 'type' => 'radio', 356 'label' => 'Hidden', 357 'checked' => '', 358 'value' => '', 359 'contains' => '', 360 'data-link' => 'image', 361 'data-link-val' => 'H', 362 'show' => '', 363 'hide' => '.dygform-container-iclass_aspect_ratio', 364 ], 365 ], 366 ], 367 'iclass_aspect_ratio' => [ 368 'container-class' => 'third-width', 369 'container-style' => '', 370 'type' => 'select_option_group', 371 'data-link' => 'iclass-aspect-ratio', 372 'placeholder' => 'Image aspect ratio', 373 'parameter' => 'required', 374 'options' => [ 375 0 => [ 376 'value' => '1:1', 377 'type' => 'option', 378 'contains' => '1:1', 379 ], 380 1 => [ 381 'value' => '4:3', 382 'type' => 'option', 383 'contains' => '4:3', 384 ], 385 2 => [ 386 'value' => '16:9', 387 'type' => 'option', 388 'contains' => '16:9', 389 ], 390 3 => [ 391 'value' => 'match_image', 392 'type' => 'option', 393 'contains' => 'match_image', 394 ], 395 ], 396 ], 397 'image_thumbnail_wrapper' => [ 398 'label' => 'Image file resolution', 399 'type' => 'div', 400 'help' => 'image-file-resolution', 401 'container-style' => 'width: 100%;', 402 'contains' => [ 403 'use_srcset' => [ 404 'type' => 'radio', 405 'data-link' => 'use_srcset', 406 'data-link-val' => 'Y', 407 'checked' => 'checked', 408 'container-style' => '', 409 'hide' => '.dygform-container-size', 410 'show' => '.dygform-container-resolutions', 411 'label' => 'Use srcset', 412 ], 413 'use_thumbnail' => [ 414 'label' => 'Use thumbnail', 415 'type' => 'radio', 416 'data-link' => 'use_srcset', 417 'data-link-val' => '', 418 'checked' => 'checked', 419 'container-style' => '', 420 'hide' => '.dygform-container-resolutions', 421 'show' => '.dygform-container-size', 422 ], 423 'size' => [ 424 'container-class' => '', 425 'data-link' => 'size', 426 'type' => 'select_option_group', 427 'placeholder' => 'Thumnbnail size', 428 'options' => [], 429 ], 430 'resolutions' => [ 431 'container-class' => '', 432 'type' => 'input', 433 'placeholder' => 'Srcset requested resolutions', 434 'data-link' => 'resolutions', 435 ], 436 ], 437 ], 438 ], 439 ], 440 'submit' => [ 441 'type' => 'button', 268 442 'container-class' => 'dygform-hidden', 269 'contains' => 'Update',270 'style' => 'float:left;',271 'class' => 'dygform-submit-button',272 ], 273 'params' => [274 'type' => 'input',275 'hidden' => 'hidden',443 'contains' => 'Update', 444 'style' => 'float:left;', 445 'class' => 'dygform-submit-button', 446 ], 447 'params' => [ 448 'type' => 'input', 449 'hidden' => 'hidden', 276 450 'data-link' => 'params', 277 'name' => 'params',451 'name' => 'params', 278 452 ], 279 453 ]; -
agb-free/trunk/dyg-grid/includes/class-dygpg-form.php
r2926907 r2926915 69 69 if ($element['data-link'] === 'params') { 70 70 $this->args['params']['get_the_ID'] = get_the_ID(); 71 $val = dyg_encryption::encode_data($this->args );71 $val = dyg_encryption::encode_data($this->args['params']); 72 72 return $val; 73 73 } … … 154 154 //prefill the post types 155 155 $x = @$data->content_wrapper->contains; 156 $x->filter_taxonomy = dygform_add_options($x->filter_taxonomy, apply_filters('dygpg_filter_options', get_taxonomies(['public' => true])), $args['taxonomy'] ?? '');156 $x->filter_taxonomy = dygform_add_options($x->filter_taxonomy, get_taxonomies(['public' => true]), $args['taxonomy'] ?? ''); 157 157 $x->term = dygform_add_options($x->term, array_merge(get_taxonomies(['public' => true]), dygpg_form::magic_fields), $args['term'] ?? ''); 158 158 $x->filter_term = dygform_add_options($x->filter_term, dygpg_form::magic_fields, $args['tax-terms'] ?? ''); 159 $x->filter_operator = dygform_add_options($x->filter_operator, ["IN", "NOT IN" ], $args['tax-operator'] ?? '');159 $x->filter_operator = dygform_add_options($x->filter_operator, ["IN", "NOT IN", "EXISTS", "NOT EXISTS"], $args['tax-operator'] ?? ''); 160 160 161 161 $x = @$data->content_wrapper->contains->sort_wrapper->contains; … … 199 199 } 200 200 201 /**202 * Takes the original args and the posted args and merges them together so that any that do203 * not have a corresponding input field in the editor are preserved204 * Note the naming of the input field as params is legacy and should be changed at some point205 * to a more meaningful name such as original_args206 *207 * @param array $args208 * @return array209 */210 function decrypt_and_reconcile_args($args) {211 $reconciled_array = (array) dyg_encryption::decode_data($args['params']);212 unset($args['params']);213 foreach($args as $key => $value) {214 $reconciled_array[$key] = $value;215 }216 return $reconciled_array;217 }218 201 219 202 … … 245 228 246 229 //decode the query_var parameters from the hidden field so that any loop parameters are used to update the grid 247 $args = $this->decrypt_and_reconcile_args($args); 248 $params = $args['params']; 249 230 $params = (array) dyg_encryption::decode_data($args['params']); 250 231 if (!empty($args['order'])) { 251 232 $params['orderby'] = $args['orderby']; … … 334 315 unset($args['term_args']); 335 316 unset($existing_args['params']); 336 $args['params'] = dyg_encryption::encode_data($args);;317 unset($args['params']); 337 318 $existing_args['undo'] = 'Y'; 338 319 $args['undo'] = ''; //the undo hidden field will trigger a redo/undo on submit, so make sure it is cleared -
agb-free/trunk/dyg-grid/includes/class-dygpg-postgrid.php
r2926907 r2926915 4 4 5 5 protected const Filler = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTA4MCIgaGVpZ2h0PSI1NDAiIHZpZXdCb3g9IjAgMCAxMDgwIDU0MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICAgIDxnIGZpbGw9Im5vbmUiIGZpbGwtcnVsZT0iZXZlbm9kZCI+CiAgICAgICAgPHBhdGggZmlsbD0iI0VCRUJFQiIgZD0iTTAgMGgxMDgwdjU0MEgweiIvPgogICAgICAgIDxwYXRoIGQ9Ik00NDUuNjQ5IDU0MGgtOTguOTk1TDE0NC42NDkgMzM3Ljk5NSAwIDQ4Mi42NDR2LTk4Ljk5NWwxMTYuMzY1LTExNi4zNjVjMTUuNjItMTUuNjIgNDAuOTQ3LTE1LjYyIDU2LjU2OCAwTDQ0NS42NSA1NDB6IiBmaWxsLW9wYWNpdHk9Ii4xIiBmaWxsPSIjMDAwIiBmaWxsLXJ1bGU9Im5vbnplcm8iLz4KICAgICAgICA8Y2lyY2xlIGZpbGwtb3BhY2l0eT0iLjA1IiBmaWxsPSIjMDAwIiBjeD0iMzMxIiBjeT0iMTQ4IiByPSI3MCIvPgogICAgICAgIDxwYXRoIGQ9Ik0xMDgwIDM3OXYxMTMuMTM3TDcyOC4xNjIgMTQwLjMgMzI4LjQ2MiA1NDBIMjE1LjMyNEw2OTkuODc4IDU1LjQ0NmMxNS42Mi0xNS42MiA0MC45NDgtMTUuNjIgNTYuNTY4IDBMMTA4MCAzNzl6IiBmaWxsLW9wYWNpdHk9Ii4yIiBmaWxsPSIjMDAwIiBmaWxsLXJ1bGU9Im5vbnplcm8iLz4KICAgIDwvZz4KPC9zdmc+Cg=="; 6 public $args = [];6 public $args = []; 7 7 public $query, $qtotal, $qindex, $end_index, $qterm, $qstart_index, $qalt, $qsrc, $qexcerpt, $atts, $css, $qaspect_ratio, $qtitle; 8 8 9 9 10 function __construct() { … … 11 12 // $dygpg_db->delete_all(); 12 13 } 14 15 13 16 14 17 function handle_preset($atts) { … … 19 22 } 20 23 24 25 21 26 public static function retrieve_atts($id) { 22 27 global $dygpg_db; … … 24 29 } 25 30 31 32 26 33 public static function update_atts($id, $args) { 27 34 global $dygpg_db; 28 return $dygpg_db->db_insert($id, $args); 29 } 35 return $dygpg_db->db_insert($id, $args); 36 } 37 38 30 39 31 40 public static function undo_atts($id) { … … 34 43 } 35 44 45 46 36 47 public static function redo_atts($id) { 37 48 global $dygpg_db; … … 39 50 } 40 51 41 // if the id attribute is supplied, shortcode atts should be retrieved via database options and editing on the frontend should be handled through dyg_form 52 53 54 // if the id attribute is supplied, shortcode atts should be retrieved via database options and editing on the frontend should be handled through dyg_form 42 55 function handle_id($id) { 43 56 //if no id is set, use the post-id … … 60 73 $this->args['version'] = '0'; 61 74 unset($this->args['post-id']); 62 $this->args = self::handle_legacy_atts($this->args); 63 } 64 } 75 $this->args = self::handle_legacy_atts($this->args); 76 } 77 } 78 79 65 80 66 81 public static function unset_pattern($key, &$atts) { 67 82 $index = array_search("%$key%", $atts['pattern']); 68 if ($index === FALSE) {83 if ($index === FALSE) 69 84 return; 70 }71 85 72 86 unset($atts['pattern'][$index]); 73 87 } 88 89 74 90 75 91 /** … … 86 102 $atts['pattern'] = array_filter(explode(',', $atts['pattern'] ?? '')); 87 103 } 88 if (($atts['show-post-content'] ?? '') === 'Y') {104 if (($atts['show-post-content'] ?? '') === 'Y') 89 105 self::unset_pattern('content', $atts); 90 } 91 92 if (($atts['use_button'] ?? '') !== 'Y') { 106 107 if (($atts['use_button'] ?? '') !== 'Y') 93 108 self::unset_pattern('button', $atts); 94 } 95 96 if (($atts['title'] ?? '') !== 'Y') { 109 110 if (($atts['title'] ?? '') !== 'Y') 97 111 self::unset_pattern('title', $atts); 98 } 99 100 if (($atts['image'] ?? '') !== 'Y') { 112 113 if (($atts['image'] ?? '') !== 'Y') 101 114 self::unset_pattern('image', $atts); 102 } 103 104 if (($atts['excerpt'] ?? '') !== 'Y') { 115 116 if (($atts['excerpt'] ?? '') !== 'Y') 105 117 self::unset_pattern('excerpt', $atts); 106 }107 118 108 119 $atts['pattern'] = implode(',', $atts['pattern']); … … 128 139 129 140 if (version_compare($atts['version'] ?? '0.0.0', '1.2.3', '<')) { 130 if (($atts['use-columns'] ?? '-') === '') {141 if (($atts['use-columns'] ?? '-') === '') 131 142 $atts['use-columns'] = 'W'; 132 }133 134 143 } 135 144 if (version_compare($atts['version'] ?? '0.0.0', '1.3.0', '<')) { 136 if ($atts['show_woo_price'] ?? '' === 'Y' AND array_key_exists('pattern', $atts)) {145 if ($atts['show_woo_price'] ?? '' === 'Y' AND array_key_exists('pattern', $atts)) 137 146 $atts['pattern'] = str_replace('%title%,', "%title%,%woo_price%,", $atts['pattern']); 138 } 139 140 if (array_key_exists('pattern', $atts)) { 147 148 if (array_key_exists('pattern', $atts)) 141 149 $atts['pattern'] = strtr($atts['pattern'], ['%meta%' => $atts['meta_pattern'] ?? '' . ","]); 142 }143 150 144 151 unset($atts['show_woo_price']); … … 147 154 $atts['style-fonts'] = ''; 148 155 } 149 if (version_compare($atts['version'] ?? '0.0.0', '4.4.0', '<')) {150 $atts['equal-content-heights'] = ($atts['equal-content-heights'] ?? '') === '' ? 'N' : $atts['equal-content-heights'];151 $atts['equal-title-heights'] = ($atts['equal-title-heights'] ?? '') === '' ? 'N' : $atts['equal-title-heights'];152 $atts['equal-grid-heights'] = ($atts['equal-grid-heights'] ?? '') === '' ? 'N' : $atts['equal-grid-heights'];153 $atts['image'] = ($atts['image'] ?? '') === 'Y' ? '' : $atts['image'];154 unset($atts['sizes']);155 unset($atts['title']);156 }157 156 $atts['version'] = AGB_VERSION; 158 157 return $atts; 159 158 } 160 159 160 161 161 162 //main post grid shortcode function 162 163 163 164 /** 164 * 165 * 166 * @param array $shortcode_atts = array of attributes 167 * @param string $content = the shortcode content. CSS code expected 168 * @param string $tag = the shortcode tag passed by the callback. not used. 169 * @param boolean $inner = a flag to request only the inner portion of the html. Used by the form editor 165 170 * @retur shortcode markup 166 * @param array $shortcode_atts = array of attributes167 * @param string $content = the shortcode content. CSS code expected168 * @param string $tag = the shortcode tag passed by the callback. not used.169 * @param boolean $inner = a flag to request only the inner portion of the html. Used by the form editor170 171 */ 171 172 public function dyg_post_grid($shortcode_atts = [], $inner = false) { … … 176 177 $this->doing_full_wrapper = TRUE; // this will not be set during load more. used to check if filter widgets etc are required 177 178 //dont continue if no shortcode is provided 178 if (empty($shortcode_atts['id'] ?? '') && empty($shortcode_atts['post-id'] ?? '')) {179 if (empty($shortcode_atts['id'] ?? '') && empty($shortcode_atts['post-id'] ?? '')) 179 180 return "<div>Your agb shortcode is missing 'id=put-id-here'</div>"; 180 }181 181 182 182 $this->handle_id($shortcode_atts['id'] ?? ''); 183 183 184 if ($inner) {184 if ($inner) 185 185 return $this->get_inner_agb(); 186 }187 186 188 187 return strtr("<div class='dyg-post-grid-wrapper-outer dyg-post-grid-wrapper-outer-%id'>%editor%inner</div>", [ … … 192 191 ]); 193 192 } 193 194 194 195 195 196 /** … … 207 208 } 208 209 210 211 209 212 /** 210 213 * sets the array of selectors to be included in the css field and output to the agb head … … 215 218 'wrapper', 216 219 'cell', 217 'transition-wrapper',218 220 'content', 219 221 'image', … … 228 230 foreach ($selectors as $selector) { 229 231 $css[$selector] = [ 230 'selector' => ".dygpg-$selector -$id.dygpg-$selector",232 'selector' => ".dygpg-$selector.dygpg-$selector-" . $id, 231 233 'statements' => [], 232 234 ]; … … 234 236 return $css; 235 237 } 238 239 236 240 237 241 /** … … 247 251 } 248 252 253 254 249 255 public static function get_shortcode_defaults($id) { 250 256 return apply_filters('dygpg-shortcode-array', [ 251 'id' => '', //indicates this shortcode is stored in the options table as dygpg-xyz, where xyz is any identifier. Also triggers the form based editor252 'version' => AGB_VERSION, // since 1.2.1 adds a version to each set of args257 'id' => '', //indicates this shortcode is stored in the options table as dygpg-xyz, where xyz is any identifier. Also triggers the form based editor 258 'version' => AGB_VERSION, // since 1.2.1 adds a version to each set of args 253 259 'css' => self::get_css_template($id), // used by the form editor to populate the css field 254 'content' => 'POST', // see comments as part of processing further down 255 'use-columns' => 'Y', // should the columns field be used to set media queries, or does the cell have a width defined elsewhere 256 'columns' => '4,3,2,1', // how many columns in desktop, tablet, mobile - extra can be added but columns, column-gap must have one more element than breakpoint 257 'column-gap' => '10px,10px,10px,10px', // column gap for desktop, tablet, mobile - extra can be added but columns, column-gap must have one more element than breakpoint 258 'breakpoints' => '1080,768,479', // breakpoints for desktop, tablet, mobile - extra can be added but columns, column-gap must have one more element than breakpoint 259 'pattern' => "%image%,%<,%title%,%>", // should the description be populated with the_content or the_excerpt; 260 'pattern-direction' => "", // list of pattern elements that should be inline-block 261 'preset' => "", // currectly selected style preset class 262 'meta_pattern' => "", // pattern for taxonomy etc meta fields 263 'posttype' => 'post', // set to the slug name of the past type 264 'postparent' => '', // expects a post id. if specified, uses get_children to find images attached to the post 265 'size' => 'medium', //which thumbnail size to select. somewhat obsolete now that srcset is in use, but does influence the value of the original src attribute 266 'resolutions' => '350px,350px,350px', // replaces the sizes below as this is not converted on first load into media queries 267 'sizes-string' => '(min-width: 0px) and (max-width: 480px) %s, (min-width: 481px) and (max-width: 980px) %s, (min-width: 981px) %s', // default template for the sizes attribute 268 'link' => 'Y', // what should the href point to 269 'link-images' => 'Y', // should the <a> link to another page our to '#' 270 'cell-element' => 'div', //what element tag to use for the main cell. default to an <a> tag, but change to a <div> if the cell should not be a links 271 'loop' => 'N', // should the <a> link to another page our to '#' 272 'title-tag' => 'h3', // what tag to wrap around title elements 273 'width' => '200px', 274 'show-content' => 'Y', //show or hide the content wrapper div. Adds class=dygpg-no-content 275 'filter-term' => '', //if set, a filter widget will be added using this term to filter the grid 260 'content' => 'POST', // see comments as part of processing further down 261 'use-columns' => 'Y', // should the columns field be used to set media queries, or does the cell have a width defined elsewhere 262 'columns' => '4,3,2,1', // how many columns in desktop, tablet, mobile - extra can be added but columns, column-gap must have one more element than breakpoint 263 'column-gap' => '10px,10px,10px,10px', // column gap for desktop, tablet, mobile - extra can be added but columns, column-gap must have one more element than breakpoint 264 'breakpoints' => '1080,768,479', // breakpoints for desktop, tablet, mobile - extra can be added but columns, column-gap must have one more element than breakpoint 265 'pattern' => "%image%,%<,%title%,%>", // should the description be populated with the_content or the_excerpt; 266 'pattern-direction' => "", // list of pattern elements that should be inline-block 267 'preset' => "", // currectly selected style preset class 268 'meta_pattern' => "", // pattern for taxonomy etc meta fields 269 'button' => 'More', //should a button linking to the post be added to %button% if not empty. The value of this field will be used as the label 270 'posttype' => 'post', // set to the slug name of the past type 271 'postparent' => '', // expects a post id. if specified, uses get_children to find images attached to the post 272 'size' => 'medium', //which thumbnail size to select. somewhat obsolete now that srcset is in use, but does influence the value of the original src attribute 273 'resolutions' => '350px,350px,350px', // replaces the sizes below as this is not converted on first load into media queries 274 'sizes' => '350px,350px,350px', // desktop, tablet, mobile. substitutes into the sizes attribute. 275 'sizes-string' => '(min-width: 0px) and (max-width: 480px) %s, (min-width: 481px) and (max-width: 980px) %s, (min-width: 981px) %s', // default template for the sizes attribute 276 'link' => 'Y', // what should the href point to 277 'link-images' => 'Y', // should the <a> link to another page our to '#' 278 'cell-element' => 'div', //what element tag to use for the main cell. default to an <a> tag, but change to a <div> if the cell should not be a links 279 'loop' => 'N', // should the <a> link to another page our to '#' 280 'title-tag' => 'h3', // what tag to wrap around title elements 281 'width' => '200px', 282 'show-content' => 'Y', //show or hide the content wrapper div. Adds class=dygpg-no-content 283 'filter-term' => '', //if set, a filter widget will be added using this term to filter the grid 276 284 'use-dynamic-filter-links' => '', //if 'Y', the filter widget will link to category pages rather than filter the post grid dynamically 277 'term' => '', //if not black then the loop is based on get_terms instead of wp_query278 'class' => '', //enter additional css classes separated by spaces279 'lightbox' => 'N', //opens the image in a divi lightbox. Must set class='lightbox-group=xxx' and aclass="et_pb_lightbox_image"280 'use-button' => '',281 'aclass' => '', //enter additional css classes for the <a> object. for example ad dyg-aspect-ratio282 'iclass' => '', //enter additional css classes for the <i> object. for example ad dyg-aspect-ratio285 'term' => '', //if not black then the loop is based on get_terms instead of wp_query 286 'class' => '', //enter additional css classes separated by spaces 287 'lightbox' => 'N', //opens the image in a divi lightbox. Must set class='lightbox-group=xxx' and aclass="et_pb_lightbox_image" 288 'use-button' => '', 289 'aclass' => '', //enter additional css classes for the <a> object. for example ad dyg-aspect-ratio 290 'iclass' => '', //enter additional css classes for the <i> object. for example ad dyg-aspect-ratio 283 291 'iclass-aspect-ratio' => '4-3', //used by form editor to flag that aspect ratio classes should be added to the image 284 'aclass-aspect-ratio' => '', //used by form editor to flag that aspect ratio classes should be added to the cell 285 'content-aspect-ratio' => '', //used by form editor to flag that aspect ratio classes should be added to the cell 286 'show-post-content' => '', //show the_content 287 'numposts' => '999999', //only output first x results 288 'pagesize' => '8', //numer of posts per page before ajax load more 289 'use-ajax' => '', //use ajax to load more. if not, use a button. NOT YET IMPLEMENTED 290 'orderby' => '', //meta_value (string) or meta_value_num (number) for a custom field, then enter the meta-key 291 'meta-key' => '', //use this field value as a key if orderby has a metavalue 292 'order' => '', 293 'use_srcset' => 'Y', 294 'projectcategory' => '', 295 'taxonomy' => '', //if this arg is set the posts will be filtered by the specified taxonomy and the tax_query parameters will be used 296 'equal-title-heights' => 'N', 297 'equal-grid-heights' => 'N', 298 'equal-content-heights' => 'N', 299 'tax-field' => 'slug', //this tells the taxonomy search that the 'terms' argument is the 'slug' and not the name 300 'tax-terms' => '', 301 'tax-operator' => '', 302 'category' => '', //use the slug 303 'shortcode' => '', //form editor storage for the original shortcode 292 'aclass-aspect-ratio' => '', //used by form editor to flag that aspect ratio classes should be added to the cell 293 'content-aspect-ratio' => '', //used by form editor to flag that aspect ratio classes should be added to the cell 294 'image' => 'Y', // 'Y' for separate <img> object. 'B' for background of the <a> object - only implemented for term so far 295 'show-post-content' => '', //show the_content 296 'numposts' => '999999', //only output first x results 297 'pagesize' => '8', //numer of posts per page before ajax load more 298 'use-ajax' => '', //use ajax to load more. if not, use a button. NOT YET IMPLEMENTED 299 'orderby' => '', //meta_value (string) or meta_value_num (number) for a custom field, then enter the meta-key 300 'meta-key' => '', //use this field value as a key if orderby has a metavalue 301 'order' => '', 302 'use_srcset' => 'Y', 303 'projectcategory' => '', 304 'taxonomy' => '', //if this arg is set the posts will be filtered by the specified taxonomy and the tax_query parameters will be used 305 'equal-title-heights' => 'N', 306 'equal-grid-heights' => 'N', 307 'equal-content-heights' => 'N', 308 'tax-field' => 'slug', //this tells the taxonomy search that the 'terms' argument is the 'slug' and not the name 309 'tax-terms' => '', 310 'post_mime_type' => '', 311 'post_status' => '', //is set to inherit for media library items 312 'tax-operator' => '', 313 'category' => '', //use the slug 314 'shortcode' => '', //form editor storage for the original shortcode 304 315 'start-index' => 1, 305 'notcat' => '',316 'notcat' => '' 306 317 ]); 307 318 } 319 320 308 321 309 322 function validate_shortcode_atts($atts) { … … 322 335 $this->args['link'] = $this->args['lightbox'] === 'Y' ? 'L' : $this->args['link'] ?? ''; 323 336 $this->args['use-columns'] = $this->args['columns'] === 'Y' ? '' : $this->args['use-columns'] ?? ''; 324 $this->args['class'] .= $this->args['show-content'] === 'Y' ? '' : " dygpg-no-content";325 $this->args['class'] .= is_agb_pro() && $this->args['link'] === 'L' ? ' dygpg-lightbox-wrapper' : " ";326 $this->args['content'] = $this->args['loop'] !== 'Y' ? $this->args['content'] : 'LOOP';327 $this->args['content'] = in_array(strtolower($this->args['content']), ['media-library', 'media_library']) ? 'MEDIA-LIBRARY' : $this->args['content'];337 $this->args['class'] .= $this->args['show-content'] === 'Y' ? '' : " dygpg-no-content"; 338 $this->args['class'] .= is_agb_pro() && $this->args['link'] === 'L' ? ' dygpg-lightbox-wrapper' : " "; 339 $this->args['content'] = $this->args['loop'] !== 'Y' ? $this->args['content'] : 'LOOP'; 340 $this->args['content'] = in_array(strtolower($this->args['content']), ['media-library', 'media_library']) ? 'MEDIA-LIBRARY' : $this->args['content']; 328 341 if (!empty($this->args['category'])) { 329 342 $this->args['taxonomy'] = 'category'; … … 334 347 unset($this->args['loop']); 335 348 349 // setup wp_query for certain content types 350 if ($this->args['content'] == "MEDIA-LIBRARY") { 351 $this->args['posttype'] = "attachment"; 352 $this->args['post_status'] = "inherit"; 353 } 354 336 355 //prepare the sizes attribute for use with srcset 337 356 $sizes = explode(',', $this->args['resolutions']); 338 357 $sizes[0] = $sizes[0] ?? '350px'; 339 $this-> srcset_sizes= sprintf($this->args['sizes-string'], $sizes[2] ?? $sizes[0], $sizes[1] ?? $sizes[0], $sizes[0]);358 $this->args['sizes'] = sprintf($this->args['sizes-string'], $sizes[2] ?? $sizes[0], $sizes[1] ?? $sizes[0], $sizes[0]); 340 359 341 360 // determine what content type has been requested … … 359 378 } 360 379 380 361 381 //cast strings to integers 362 382 foreach (['numposts', 'pagesize'] as $key) { … … 367 387 $params = [ 368 388 'post_type' => $this->args['posttype'], 369 'post_status' => ['inherit', 'publish'], 389 'post_mime_type' => $this->args['post_mime_type'], 390 'post_status' => $this->args['post_status'], 370 391 'category_name' => $this->args['category'], 371 392 'project_category' => $this->args['projectcategory'], 372 393 'post_parent' => $this->args['postparent'], 373 394 'orderby' => empty($this->args['orderby']) ? 'ID' : $this->args['orderby'], //empty sort order causes issues with paging 374 'order' => empty($this->args['order']) ? 'ASC' : $this->args['order'],395 'order' => empty($this->args['order']) ? 'ASC' : $this->args['order'], 375 396 'meta_key' => $this->args['meta-key'], 376 397 'posts_per_page' => $this->args['pagesize'], 377 'get_the_ID' => isset($this->atts['params']['get_the_ID']) ? $this->atts['params']['get_the_ID'] : get_the_ID() ,398 'get_the_ID' => isset($this->atts['params']['get_the_ID']) ? $this->atts['params']['get_the_ID'] : get_the_ID() 378 399 ]; 379 400 380 401 // should the wp_query be filtered by taxonomy? If so add these parameters to the args 381 402 if ($this->args['taxonomy'] != "") { 382 $params_tax = [403 $params_tax = [ 383 404 'tax_query' => [ 384 405 [ … … 386 407 'field' => $this->args['tax-field'], 387 408 'terms' => strpos($this->args['tax-terms'], ',') === FALSE ? $this->args['tax-terms'] : explode(',', $this->args['tax-terms']), // exclude items media items in the news-cat custom taxonomy 388 'operator' => $this->args['tax-operator']] ,389 ] ,409 'operator' => $this->args['tax-operator']] 410 ] 390 411 ]; 391 412 $params_tax['tax_query'][0]['terms'] = $this->convert_magic_field($params_tax['tax_query'][0]['terms'], $params); … … 402 423 // append the meta-key arguments if a meta-key is defined 403 424 if ($this->args['meta-key'] != '') { 404 $term_args_append = [425 $term_args_append = [ 405 426 'meta_query' => [[ 406 'key' => $this->args['meta-key'],407 'type' => 'NUMERIC',408 ]],427 'key' => $this->args['meta-key'], 428 'type' => 'NUMERIC', 429 ]] 409 430 ]; 410 431 $this->args['term_args'] = array_merge($this->args['term_args'], $term_args_append); … … 426 447 } 427 448 $params = $loop_params; 428 $params['posts_per_page'] = 9999999; 449 $params['posts_per_page'] = 9999999; 429 450 } 430 451 $params = apply_filters('dygpg-params', $params, $this); … … 435 456 } 436 457 458 459 437 460 public function convert_magic_field($field, $params) { 438 if (is_array($field)) {461 if (is_array($field)) 439 462 return $field; 440 } 441 442 if (strpos($field, '%post_slug%') !== false) { 463 464 if (strpos($field, '%post_slug%') !== false) 443 465 return str_replace("%post_slug%", get_post_field('post_name', $params['get_the_ID']), $field); 444 } 445 446 if (strpos($field, '%post_title%') !== false) { 466 467 if (strpos($field, '%post_title%') !== false) 447 468 return str_replace("%post_title%", get_post_field('post_name', $params['get_the_ID']), $field); 448 } 469 449 470 450 471 if (strpos($field, '%attached_terms%') !== false) { 451 472 $terms = get_the_terms($params['get_the_ID'], $this->args['taxonomy']); 452 if (!is_array($terms)) {473 if (!is_array($terms)) 453 474 return ''; 454 }455 456 475 $field = []; 457 476 foreach ($terms as $term) { … … 464 483 } 465 484 485 486 466 487 /** 467 488 * converts the $this->css array into css statements 468 * 489 * 469 490 */ 470 491 function generate_inline_css() { … … 483 504 } 484 505 506 507 485 508 /** 486 509 * adds the predefined css as well as ::root variables ahead of the post grid to set columns widths and gap 487 * @param string$index510 * @param string $index 488 511 * @return string 489 512 */ … … 494 517 495 518 return strtr("<style>%media %css</style>", 496 [497 '%media' => dygpg_toolbox::escape_css($this->get_media_queries($index)),498 '%css' => dygpg_toolbox::escape_css($this->generate_inline_css() . $this->args['css'] ?? ''),499 ]519 [ 520 '%media' => dygpg_toolbox::escape_css($this->get_media_queries($index)), 521 '%css' => dygpg_toolbox::escape_css($this->generate_inline_css() . $this->args['css'] ?? ''), 522 ] 500 523 ); 501 524 } 525 526 502 527 503 528 function get_media_queries($index) { … … 506 531 $breakpoints = explode(',', $this->args['breakpoints']); 507 532 508 if (empty($breakpoints)) {533 if (empty($breakpoints)) 509 534 $breakpoints[] = '1080'; 510 } 511 512 if (empty($gap)) { 535 536 if (empty($gap)) 513 537 $gap[] = '0px'; 514 }515 538 516 539 $root = ''; 517 540 $len = count($column); 518 541 for ($i = 0; 519 $i < $len; $i++) {542 $i < $len; $i++) { 520 543 $gap[$i] = $gap[$i] ?? end($gap); 521 544 … … 559 582 @media only screen and $min $max { 560 583 .dyg-post-grid-wrapper-$index .dygpg-cell { 561 width: calc( 100% / {$column[$i]} - 2 * {$margin});584 width: calc(calc(100% - calc(calc(calc({$column[$i]}-1)*2)*{$margin}))/{$column[$i]}); 562 585 margin: {$margin}; 563 586 } … … 576 599 } 577 600 601 602 578 603 public static function buildArgs($array) { 579 604 if (empty($array)) { … … 582 607 $ret = ''; 583 608 foreach ($array as $key => $value) { 584 $q = strpos($value, ' ') !== false ? "'" : '';609 $q = strpos($value, ' ') !== false ? "'" : ''; 585 610 $ret .= " $key={$q}$value{$q}"; 586 611 } 587 612 return trim($ret); 588 613 } 614 615 589 616 590 617 function public_edit_id() { … … 592 619 593 620 return strtr("<div class='dygpg-edit-wrapper dygpg-edit-wrapper-%id dygpg-edit-wrapper-id'>%form</div>" 594 . "<i onclick='dygpgEditIconClick(\"%id\",this)' class='fas fa-cog dygpg-edit-icon dygpg-edit-icon-%id'></i>",595 [596 '%form' => $form->get_form(),597 '%id' => esc_attr($this->args['id']),598 ]621 . "<i onclick='dygpgEditIconClick(\"%id\",this)' class='fas fa-cog dygpg-edit-icon dygpg-edit-icon-%id'></i>", 622 [ 623 '%form' => $form->get_form(), 624 '%id' => esc_attr($this->args['id']) 625 ] 599 626 ); 600 627 } 628 629 601 630 602 631 function get_frontend_editor() { … … 611 640 $allow_editing &= !isset($_POST['is_fb_preview']); 612 641 $allow_editing &= is_user_logged_in(); 613 $allow_editing &= current_user_can( apply_filters('dygpg-editing-capability', ''));642 $allow_editing &= current_user_can('administrator'); 614 643 615 644 return apply_filters('dygpg-allow-edit', $allow_editing, $this) === TRUE ? $this->public_edit_id() : ''; 616 645 617 646 } 647 648 618 649 619 650 /* … … 629 660 630 661 //documents will not have a srcset 631 if (!str_contains(get_post_mime_type($id), 'image')) {662 if (!str_contains(get_post_mime_type($id), 'image')) 632 663 return ""; 633 }634 664 635 665 $this->qaspect_ratio = round($image_meta['width'] / $image_meta['height'], 2); … … 643 673 foreach ($image_meta['sizes'] as $image) { 644 674 //only add the image if it has the same aspect ratio, i.e. is not cropped 645 if (!($image['height'] ?? 0 > 0)) {675 if (!($image['height'] ?? 0 > 0)) 646 676 continue; 647 }648 649 677 if ($this->qaspect_ratio === round($image['width'] / $image['height'], 2)) { 650 678 $srcset .= "$image_baseurl{$image['file']} {$image['width']}w,"; … … 661 689 } 662 690 691 692 693 // handles the loop for post attachments 694 function grid_query_attachment() { 695 if (!isset($this->query)) { 696 $this->args['params']['posts_per_page'] = -1; 697 $this->build_filter(); 698 $args = [ 699 'tax_query' => $this->args['params']['tax_query'] ?? [], 700 // 'post_mime_type' => ['application/doc','application/pdf', 'text/plain', 'image'], 701 'post_parent' => '', 702 'post_type' => 'attachment', 703 'orderby' => $this->args['orderby'], 704 'order' => $this->args['order'], 705 'meta_key' => $this->args['meta-key'], 706 ]; 707 $post_array = get_children($args); 708 // $post_array = get_children($this->args['params']); 709 $this->query = []; 710 foreach ($post_array as $post) { 711 $this->query[] = $post->ID; 712 } 713 $this->qtotal = count($this->query); 714 if (isset($this->qstart_index)) { 715 $this->qindex = $this->qstart_index - 1; 716 } else { 717 $this->qindex = 0; 718 } 719 } 720 if ($this->qindex < ($this->qtotal)) { 721 $this->qtitle = get_the_title($this->query[$this->qindex]); 722 $this->qexcerpt = get_the_excerpt($this->query[$this->qindex]); 723 $this->qcontent = get_the_content(null, false, $this->query[$this->qindex]); 724 $this->qpid = $this->query[$this->qindex]; 725 $this->qid = $this->query[$this->qindex]; 726 $this->qpermalink = get_the_permalink($this->query[$this->qindex]); 727 $this->qsrc = wp_get_attachment_image_src($this->query[$this->qindex], $this->args['size'])[0] ?? ''; 728 $this->qsrcfull = wp_get_attachment_image_src($this->query[$this->qindex], 'full')[0] ?? ''; 729 $this->qsrcset = $this->dyg_get_attachment_image_srcset($this->query[$this->qindex], 'full'); 730 $this->qalt = get_post_meta($this->query[$this->qindex], '_wp_attachment_image_alt', true); 731 $this->qsizes = $this->args['sizes']; //this needs more work. The WP function that returns the srcset sizes is not adequate 732 $this->qindex++; 733 return true; 734 } else { 735 unset($this->query); 736 return false; 737 } 738 } 739 740 741 663 742 // handles the loop data for a term query 664 743 function grid_query_term() { … … 670 749 $this->query = get_the_terms($this->args['params']['get_the_ID'], $this->args['term_args']['taxonomy']); 671 750 672 //if not then get all terms in the taxonomy 751 //if not then get all terms in the taxonomy 673 752 } else { 674 753 $this->query = get_terms($this->args['term_args']); … … 685 764 if ($this->qindex < ($this->qtotal)) { 686 765 $this->qterm = $this->query[$this->qindex]; 687 $this->qid = "{$this->qterm->taxonomy}-{$this->qterm->term_id}";688 689 //plugin:Category and Taxonomy Image 766 $this->qid = ''; 767 768 //plugin:Category and Taxonomy Image 690 769 if (function_exists('get_wp_term_image')) { 691 770 $this->qsrc = get_wp_term_image($this->qterm->term_id); … … 699 778 //for acf 700 779 } else if (function_exists('get_field')) { 701 $this->qsrc = get_field("taxonomy_image", "{$this->args['term_args']['taxonomy']}_{$this->qterm->term_id}"); //nb acf requires this specific sytax - refer to their docs780 $this->qsrc = get_field("taxonomy_image", "{$this->args['term_args']['taxonomy']}_{$this->qterm->term_id}"); //nb acf requires this specific sytax - refer to their docs 702 781 $this->qpid = attachment_url_to_postid($this->qsrc); 703 782 $this->qsrcset = $this->dyg_get_attachment_image_srcset($this->qpid, 'full'); … … 710 789 $this->qsrcset = $this->dyg_get_attachment_image_srcset($this->qpid, 'full'); 711 790 } 712 $this->qsizes = $this-> srcset_sizes;791 $this->qsizes = $this->args['sizes']; 713 792 $this->qalt = $this->qterm->name; 714 793 $this->qtitle = $this->qterm->name; … … 723 802 } 724 803 725 /** 726 * this function used to handle media library queries using get_children, but not passes 727 * procesing to the grid_query_post as an attachment as it had more advanced page handling 728 * 729 * @return void 730 */ 731 function grid_query_attachment() { 732 return $this->grid_query_post(); 733 } 734 735 // handles the loop for posts 804 805 806 // handles the loop for posts 736 807 function grid_query_post() { 737 808 if (!isset($this->query)) { … … 739 810 $this->qindex = $this->qstart_index - 1; 740 811 $this->args['params']['offset'] = $this->qindex; 741 $this->args['params'] = apply_filters('dygpg_query_post_params', $this->args['params'], $this);742 812 $this->query = apply_filters('dygpg_grid_query_post', new WP_Query($this->args['params']), $this); 743 813 $this->qtotal = $this->query->found_posts; … … 745 815 if ($this->query->have_posts()) { 746 816 $this->query->the_post(); 747 $this->qid = $this->query->post->ID;817 $this->qid = $this->query->post->ID; 748 818 $this->qindex++; 749 $this->qpermalink = get_the_permalink();750 $this->qtitle = get_the_title();819 $this->qpermalink = get_the_permalink(); 820 $this->qtitle = get_the_title(); 751 821 //if divi is in use make sure builder shortcodes are not returend. 752 $this->qpgexcerpt = function_exists('get_field') ? get_field('post_grid_excerpt') : '';822 $this->qpgexcerpt = function_exists('get_field') ? get_field('post_grid_excerpt') : ''; 753 823 // the et_builder_get_the_term_list function is not loaded when the post_grid is generated via ajax 754 $this->qdate = get_the_date();755 $this->qcontent = strpos($this->args['pattern'], '%content%') !== false ? do_shortcode(get_the_content()) : ''; //filter will render divi content756 $this->qexcerpt = strpos($this->args['pattern'], '%excerpt%') !== false ? apply_filters('the_excerpt', get_the_excerpt()) : '';824 $this->qdate = get_the_date(); 825 $this->qcontent = strpos($this->args['pattern'], '%content%') !== false ? do_shortcode(get_the_content()) : ''; //filter will render divi content 826 $this->qexcerpt = strpos($this->args['pattern'], '%excerpt%') !== false ? apply_filters('the_excerpt', get_the_excerpt()) : ''; 757 827 //if qpid is zero, it's probably a media library loop so the attachment is the same as the post; 758 828 $this->qpid = get_post_thumbnail_id() === 0 ? $this->qid : get_post_thumbnail_id(); … … 761 831 $this->qsrcset = $this->dyg_get_attachment_image_srcset($this->qpid, 'medium'); 762 832 $this->qalt = get_post_meta($this->qpid, '_wp_attachment_image_alt', true); 763 $this->qsizes = $this-> srcset_sizes;833 $this->qsizes = $this->args['sizes']; 764 834 $this->filter_class = $this->get_filter_classes(); 765 835 return true; … … 770 840 } 771 841 842 843 772 844 function build_filter() { 773 845 unset($this->filter); … … 784 856 'post_type' => $this->args['content'] === 'LOOP' ? get_post_type() : $this->args['params']['post_type'], 785 857 'orderby' => $this->args['orderby'], 786 'order' => $this->args['order'] ,858 'order' => $this->args['order'] 787 859 ]; 788 860 } else { 789 861 $query_args = $this->args['params']; 790 862 } 791 $query_args['nopaging'] = true; //make sure all posts are returned863 $query_args['nopaging'] = true; //make sure all posts are returned 792 864 793 865 $query = new WP_Query($query_args); … … 827 899 } 828 900 901 902 829 903 function get_filter_classes() { 830 904 if (!isset($this->filter_taxonomy)) { … … 848 922 return $filter_classes; 849 923 } 924 925 850 926 851 927 // determine which content loop function to call unless the current page size is reached … … 857 933 } 858 934 } 935 936 859 937 860 938 /** … … 881 959 } 882 960 961 962 883 963 /** 884 964 * returns the href to use for click navigation in the main loop 885 965 */ 886 966 function get_href() { 887 if ($this->args['link'] == 'N' || $this->args['link'] == '') {967 if ($this->args['link'] == 'N' || $this->args['link'] == '') 888 968 apply_filters('dygpg-href', '', $this); 889 }890 969 891 970 $this->href = apply_filters('dygpg-href', $this->qpermalink, $this); … … 893 972 } 894 973 974 975 895 976 /** 896 977 * returns the lightbox data element for for use with magnific popup 897 978 */ 898 979 function get_lightbox() { 899 if ($this->args['link'] !== 'L') {980 if ($this->args['link'] !== 'L') 900 981 return ''; 901 }902 982 903 983 return strtr("data-mfp-src='%src'", [ … … 905 985 ]); 906 986 } 987 988 907 989 908 990 /** … … 914 996 ]); 915 997 return self::get_pattern_field_wrapper_static( 916 'excerpt',917 $excerpt,918 $this->args['pattern-direction'],919 ''998 'excerpt', 999 $excerpt, 1000 $this->args['pattern-direction'], 1001 '' 920 1002 ); 921 1003 } 1004 1005 922 1006 923 1007 /** … … 929 1013 ]); 930 1014 return self::get_pattern_field_wrapper_static( 931 'content',932 $content,933 $this->args['pattern-direction'],934 ''1015 'content', 1016 $content, 1017 $this->args['pattern-direction'], 1018 '' 935 1019 ); 936 1020 } 937 1021 1022 1023 938 1024 /** 939 1025 * returns the titles to use in the main loop 940 * @param string $href - the href to include in the title for click navigation1026 * @param string $href - the href to include in the title for click navigation 941 1027 * @return string - title markup 942 1028 */ … … 950 1036 951 1037 return self::get_pattern_field_wrapper_static( 952 'title',953 apply_filters('dygpg-title', $title, $this, $href),954 $this->args['pattern-direction'],955 ''1038 'title', 1039 apply_filters('dygpg-title', $title, $this, $href), 1040 $this->args['pattern-direction'], 1041 '' 956 1042 ); 957 1043 } 958 1044 959 960 /** 961 * 1045 1046 1047 /** 1048 * 1049 * @return string - the css styles to include in the main loop cell attribute wrapped in style='' 1050 */ 1051 function get_style() { 1052 $style = ''; 1053 if ($this->args['image'] === "B") { 1054 $style .= "background-image:url(\"$this->qsrc\");"; 1055 } 1056 return apply_filters('dygpg-filter-cell-inline-style', $style, $this); 1057 } 1058 1059 1060 1061 /** 1062 * 962 1063 * get the image element for use in the main loop 963 1064 * @param string $href -the href url for navigation when an image is clicked. … … 965 1066 function get_image($href) { 966 1067 $image = strtr("<img class='dygpg-image dygpg-image-{$this->args['id']} %iclass' %aspect src='%src' srcset='%srcset' sizes='%sizes' alt='%alt' title='%title'/>", 967 [968 '%href' => esc_url($href),969 '%iclass' => dygpg_toolbox::sanitize_classes($this->args['iclass']),970 '%aspect' => $this->get_aspect_parameters($this->args['iclass-aspect-ratio']),971 '%srcset' => $this->qsrcset ?? '',972 '%sizes' => $this->qsizes ?? '',973 '%src' => empty($this->qsrcset) ? $this->qsrc : '',974 '%alt' => esc_html($this->qalt),975 '%title' => apply_filters('dygpg-tooltip', esc_attr(apply_filters('dygpg-qtitle', $this->qtitle, $this)), $this),976 ]1068 [ 1069 '%href' => esc_url($href), 1070 '%iclass' => dygpg_toolbox::sanitize_classes($this->args['iclass']), 1071 '%aspect' => $this->get_aspect_parameters($this->args['iclass-aspect-ratio']), 1072 '%srcset' => $this->qsrcset ?? '', 1073 '%sizes' => $this->qsizes ?? '', 1074 '%src' => empty($this->qsrcset) ? $this->qsrc : '', 1075 '%alt' => esc_html($this->qalt), 1076 '%title' => apply_filters('dygpg-tooltip', esc_attr(apply_filters('dygpg-qtitle', $this->qtitle, $this)), $this), 1077 ] 977 1078 ); 978 1079 … … 984 1085 } 985 1086 $image = self::get_pattern_field_wrapper_static( 986 'image',987 $image,988 $this->args['pattern-direction'],989 ''1087 'image', 1088 $image, 1089 $this->args['pattern-direction'], 1090 '' 990 1091 ); 991 1092 return apply_filters('dygpg_image', $image, $this); 992 1093 } 993 1094 1095 1096 994 1097 /** 995 1098 * return markup for the load more button … … 998 1101 function get_button($href) { 999 1102 $html = strtr("<a class='dygpg-button dygpg-button-{$this->args['id']}' href='%href'><button>%button</button></a>", 1000 [1001 '%href' => esc_url($href),1002 '%button' => esc_html($this->args['button']),1003 ]1103 [ 1104 '%href' => esc_url($href), 1105 '%button' => esc_html($this->args['button']), 1106 ] 1004 1107 ); 1005 1108 return self::get_pattern_field_wrapper_static( 1006 'button',1007 $html,1008 $this->args['pattern-direction'],1009 ''1109 'button', 1110 $html, 1111 $this->args['pattern-direction'], 1112 '' 1010 1113 ); 1011 1114 } 1115 1116 1012 1117 1013 1118 /** … … 1017 1122 function get_date($href) { 1018 1123 return self::get_pattern_field_wrapper_static( 1019 'date',1020 get_the_date('M d, Y'),1021 $this->args['pattern-direction'],1022 "dygpg-text dygpg-text-{$this->args['id']}"1124 'date', 1125 get_the_date('M d, Y'), 1126 $this->args['pattern-direction'], 1127 "dygpg-text dygpg-text-{$this->args['id']}" 1023 1128 ); 1024 1129 } 1130 1131 1025 1132 1026 1133 /** … … 1030 1137 function get_author($href) { 1031 1138 return self::get_pattern_field_wrapper_static( 1032 'author',1033 get_the_author(),1034 $this->args['pattern-direction'],1035 "dygpg-text dygpg-text-{$this->args['id']}"1139 'author', 1140 get_the_author(), 1141 $this->args['pattern-direction'], 1142 "dygpg-text dygpg-text-{$this->args['id']}" 1036 1143 ); 1037 1144 } 1038 1145 1146 1147 1039 1148 /** 1040 1149 * adds a wrapper class with either span or div depending on the corresponding pattern direction 1041 * @param string $field- pattern field without surrounding %1042 * @param string $html1043 * @param string $pattern_direction1044 * @param string $class1150 * @param string $field - pattern field without surrounding % 1151 * @param string $html 1152 * @param string $pattern_direction 1153 * @param string $class 1045 1154 * @return string - html with new wrapper 1046 1155 */ … … 1048 1157 $el = 'block'; 1049 1158 1050 if (strpos($pattern_direction, "%$field%") !== false) {1159 if (strpos($pattern_direction, "%$field%") !== false) 1051 1160 $el = 'inline'; 1052 }1053 1161 1054 1162 return strtr("<div class='dygpg-pattern dygpg-pattern-%field%class dygpg-pattern-%el %filter_class'>%html</div>", [ 1055 '%el' => $el,1056 '%field' => $field,1057 '%html' => $html,1058 '%filter_class' => apply_filters('dygpg-pattern-class', '', $field, $this),1059 '%class' => empty($class) ? '' : " $class",1163 '%el' => $el, 1164 '%field' => $field, 1165 '%html' => $html, 1166 '%filter_class' => apply_filters('dygpg-pattern-class', '', $field, $this), 1167 '%class' => empty($class) ? '' : " $class", 1060 1168 ]); 1061 1169 } 1062 1170 1171 1172 1063 1173 /** 1064 1174 * handle the pattern argument so that elements can be re-ordered or extra html inserted 1065 * @param string $href - url for click navigation1175 * @param string $href - url for click navigation 1066 1176 * @return string - html markup for the grids content 1067 1177 */ … … 1073 1183 $field = trim($field, '% ,'); 1074 1184 switch ($field) { 1075 case "" :1185 case "" : 1076 1186 break; 1077 case "title" :1187 case "title" : 1078 1188 $output[] = $this->get_titles($href); 1079 1189 break; 1080 case "<" :1190 case "<" : 1081 1191 $output[] = apply_filters('dygpg-content-open', 1082 strtr("<div %aspect class='dygpg-content dygpg-content-%id%equalise' style='%style'>", [ 1083 '%id' => $this->args['id'], 1084 '%equalise' => $this->args['equal-content-heights'] === 'Y' ? " dyg-equal-height-content-{$this->args['id']}" : '', 1085 '%aspect' => $this->get_aspect_parameters($this->args['content-aspect-ratio'] ?? ''), 1086 '%style' => apply_filters('dygpg-content-inline-style', '', $this), 1087 ]), 1088 $this); 1192 strtr("<div %aspect class='dygpg-content dygpg-content-%id%equalise'>", [ 1193 '%id' => $this->args['id'], 1194 '%equalise' => $this->args['equal-content-heights'] === 'Y' ? " dyg-equal-height-content-{$this->args['id']}" : '', 1195 '%aspect' => $this->get_aspect_parameters($this->args['content-aspect-ratio'] ?? ''), 1196 ]), 1197 $this); 1089 1198 break; 1090 case ">" :1199 case ">" : 1091 1200 $output[] = apply_filters('dygpg-content-close', "</div>"); 1092 1201 break; 1093 case "button" :1202 case "button" : 1094 1203 $output[] = $this->get_button($href); 1095 1204 break; 1096 case "image" :1205 case "image" : 1097 1206 $output[] = $this->get_image($href); 1098 1207 break; 1099 case "excerpt" :1208 case "excerpt" : 1100 1209 $output[] = $this->get_excerpt(); 1101 1210 break; 1102 case "content" :1211 case "content" : 1103 1212 $output[] = $this->get_the_content(); 1104 1213 break; 1105 case "date" :1214 case "date" : 1106 1215 $output[] = $this->get_date($href); 1107 1216 break; 1108 case "author" :1217 case "author" : 1109 1218 $output[] = $this->get_author($href); 1110 1219 break; 1111 1220 default: 1112 $pattern_element = apply_filters('dygpg-get-pattern-element', $field, $this);1113 if (empty($pattern_element)) {1114 break;1115 }1116 1117 1221 $output[] = self::get_pattern_field_wrapper_static( 1118 $field,1119 $pattern_element,1120 $this->args['pattern-direction'],1121 'dygpg-text'1222 $field, 1223 apply_filters('dygpg-get-pattern-element', $field, $this), 1224 $this->args['pattern-direction'], 1225 'dygpg-text' 1122 1226 ); 1123 1227 } … … 1127 1231 } 1128 1232 1233 1234 1129 1235 /** 1130 1236 * outputs a page of the grid based on post types. NB this function is also called via ajax to load more content inside the wrapper … … 1132 1238 function get_main_loop() { 1133 1239 1240 1241 1134 1242 $this->qstart_index = $this->args['start-index']; 1135 $this->end_index = $this->qstart_index + min($this->args ['pagesize'], $this->args['numposts']) - 1;1243 $this->end_index = $this->qstart_index + min($this->args ['pagesize'], $this->args['numposts']) - 1; 1136 1244 $this->qindex = 0; 1137 1245 $grid_content = ''; … … 1139 1247 // main content loop 1140 1248 while ($this->grid_query()) { 1141 if ($this->qtotal == 0) {1249 if ($this->qtotal == 0) 1142 1250 continue; 1143 }1144 $this->args = apply_filters('dygpg-main-loop-args', $this);1145 1251 1146 1252 // add a default image if none is attached … … 1149 1255 $href = $this->get_href(); 1150 1256 1151 $grid_content .= strtr("<%el id='dygpg-%id-%post_id' %aspect %lightbox class = 'dygpg-cell dygpg-cell-%id %aclass %heights %filters' style = '%style' href = '%href'>%insert</%el>", 1152 [ 1153 '%el' => $this->args['cell-element'], 1154 '%aspect' => $this->get_aspect_parameters($this->args['aclass-aspect-ratio']), 1155 '%aclass' => dygpg_toolbox::sanitize_classes(apply_filters('dygpg-aclass', $this->args['aclass'], $this)), 1156 '%heights' => $this->args['equal-grid-heights'] === "Y" ? "dyg-equal-height-{$this->args['id']}" : '', 1157 '%filters' => dygpg_toolbox::sanitize_classes($this->get_filter_classes()), 1158 '%style' => apply_filters('dygpg-cell-inline-style', '', $this, $this), 1159 '%href' => esc_url($href), 1160 '%id' => $this->args['id'], 1161 '%post_id' => $this->qid, 1162 '%insert' => apply_filters('dygpg-cell-content', $this->get_content($href), $this, $href), 1163 '%lightbox' => $this->get_lightbox(), 1164 ] 1257 $grid_content .= strtr("<%el %aspect %lightbox class = 'dygpg-cell dygpg-cell-{$this->args['id']} %aclass %heights %filters' style = '%style' href = '%href'>%insert</%el>", 1258 [ 1259 '%el' => $this->args['cell-element'], 1260 '%aspect' => $this->get_aspect_parameters($this->args['aclass-aspect-ratio']), 1261 '%aclass' => dygpg_toolbox::sanitize_classes(apply_filters('dygpg-aclass', $this->args['aclass'], $this)), 1262 '%heights' => $this->args['equal-grid-heights'] === "Y" ? "dyg-equal-height-{$this->args['id']}" : '', 1263 '%filters' => dygpg_toolbox::sanitize_classes($this->get_filter_classes()), 1264 '%style' => $this->get_style(), 1265 '%href' => esc_url($href), 1266 '%insert' => apply_filters('dygpg-cell-content', $this->get_content($href), $this, $href), 1267 '%lightbox' => $this->get_lightbox(), 1268 ] 1165 1269 ); 1166 1270 } 1271 1167 1272 1168 1273 // add a load_more button if required … … 1173 1278 return $grid_content; 1174 1279 } 1280 1281 1175 1282 1176 1283 /** … … 1194 1301 $this->args['start-index'] += $this->args['pagesize']; 1195 1302 return strtr("<div class = 'dyg-load-more-wrapper'>" 1196 . "<button id = 'dyg-post-grid-%id' class = 'dyg-load-more %ajax' onclick = \"dygLoadMore('%id','%start','%param')\">"1197 . "%text</button></div>",1198 [1199 '%ajax' => !empty($this->args['use-ajax']) ? 'dyg-load-more-ajax' : '',1200 '%start' => $this->args['start-index'],1201 '%id' => $this->args['id'],1202 '%param' => dyg_encryption::encode_data($this->args['params']),1203 '%text' => esc_html(apply_filters('dygpg-load-more-button', "+", $this)),1204 ]1303 . "<button id = 'dyg-post-grid-%id' class = 'dyg-load-more %ajax' onclick = \"dygLoadMore('%id','%start','%param')\">" 1304 . "%text</button></div>", 1305 [ 1306 '%ajax' => !empty($this->args['use-ajax']) ? 'dyg-load-more-ajax' : '', 1307 '%start' => $this->args['start-index'], 1308 '%id' => $this->args['id'], 1309 '%param' => dyg_encryption::encode_data($this->args['params']), 1310 '%text' => esc_html(apply_filters('dygpg-load-more-button', "+", $this)), 1311 ] 1205 1312 ); 1206 1313 } 1207 1314 1315 1316 1208 1317 } -
agb-free/trunk/dyg-grid/js/dyg-resize.js
r2926907 r2926915 1 1 jQuery(document).ready(function () { 2 dygpgEqualiseFunctions() 2 aspect_ratio(); 3 equal_height(); 3 4 }); 4 5 5 6 window.onresize = function () { 6 dygpgEqualiseFunctions() 7 } 8 9 function dygpgEqualiseFunctions() { 10 equalizeAllRowHeights(); 7 aspect_ratio(); 11 8 equal_height(); 12 aspect_ratio();13 9 } 14 10 //synchronises the height and width of all elements in the class … … 82 78 } 83 79 84 function equalizeRowHeights($wrapper, $class) {85 var $cells = $wrapper.find($class);86 var rowStartIndex = 0;87 var maxHeight = 0;88 var currentRowTopPosition = $cells.first().position().top;89 90 $cells.each(function (index) {91 var $cell = jQuery(this);92 $cell.css('height', '');93 var targetElement = $cell.hasClass('.dygpg-cell') ? $cell : $cell.closest('.dygpg-cell');94 var cellTopPosition = Math.round(targetElement.position().top);95 96 if (cellTopPosition === currentRowTopPosition) {97 maxHeight = Math.max(maxHeight, $cell.outerHeight());98 } else {99 for (var i = rowStartIndex; i < index; i++) {100 jQuery($cells[i]).outerHeight(maxHeight);101 }102 rowStartIndex = index;103 maxHeight = $cell.outerHeight();104 currentRowTopPosition = cellTopPosition;105 }106 107 if (index === $cells.length - 1) {108 for (var i = rowStartIndex; i <= index; i++) {109 jQuery($cells[i]).outerHeight(maxHeight);110 }111 }112 });113 }114 115 function equalizeAllRowHeights() {116 jQuery('.dygpg-wrapper-equalise-title-rows').each(function () {117 equalizeRowHeights(jQuery(this), '.dygpg-pattern-title');118 });119 jQuery('.dygpg-wrapper-equalise-content-rows').each(function () {120 equalizeRowHeights(jQuery(this), '.dygpg-content');121 });122 jQuery('.dygpg-wrapper-equalise-grid-rows').each(function () {123 equalizeRowHeights(jQuery(this), '.dygpg-cell');124 });125 } -
agb-free/trunk/dyg-grid/js/dygpg-ajax-load-more.js
r2926907 r2926915 21 21 jQuery('.dyg-post-grid-wrapper-' + index).append(data); 22 22 scrollEventHandler(); 23 dygpgEqualiseFunctions(); 23 aspect_ratio(); 24 equal_height(); 24 25 dygpgReapplyFilters(index); 25 26 dygformReady(); -
agb-free/trunk/dyg-grid/js/dygpg-edit-ajax.js
r2926907 r2926915 4 4 * and open the template in the editor. 5 5 */ 6 6 7 7 8 … … 17 18 jQuery(el).val(data.fields[field].val); 18 19 } else 19 if (data.fields[field].val && data.fields[field].type === 'checkbox') {20 jQuery(el).prop('checked', true);21 } else22 if (!data.fields[field].val && data.fields[field].type === 'checkbox') {23 jQuery(el).prop('checked', false);24 } else25 if (data.fields[field].type === 'radio') {26 var name = jQuery(el).attr('name');27 jQuery(parent).find(`input[name='${name}']`).prop('checked', false);28 jQuery(parent).find(`input[name='${name}'][data-link-val='${data.fields[field].val}']`).prop('checked', true);29 }20 if (data.fields[field].val && data.fields[field].type === 'checkbox') { 21 jQuery(el).prop('checked', true); 22 } else 23 if (!data.fields[field].val && data.fields[field].type === 'checkbox') { 24 jQuery(el).prop('checked', false); 25 } else 26 if (data.fields[field].type === 'radio') { 27 var name = jQuery(el).attr('name'); 28 jQuery(parent).find(`input[name='${name}']`).prop('checked', false); 29 jQuery(parent).find(`input[name='${name}'][data-link-val='${data.fields[field].val}']`).prop('checked', true); 30 } 30 31 } 31 32 jQuery(`.dyg-post-grid-wrapper-outer-${data.index} .dyg-post-grid-wrapper`).remove(); … … 38 39 jQuery(`.dygform-dygpg-form .dygform-message`).hide(); 39 40 } 40 dygpgEqualiseFunctions() 41 aspect_ratio(); 42 equal_height(); 41 43 dygpgAdminAjaxReadyFunctions(); 42 44 scrollEventHandler(); … … 66 68 67 69 //clear the separator character after the last consecutive span in content elements 68 jQuery('.dygpg-pattern-inline').each(function () { 69 if (!jQuery(this).next().hasClass('dygpg-pattern-inline')) { 70 jQuery(this).addClass('dygpg-pattern-last'); 71 } 72 }); 73 70 jQuery('div.dygpg-pattern-block').prev('div.dygpg-pattern-inline').addClass('dygpg-pattern-last'); 71 jQuery('div.dygpg-pattern-block').prev('div.dygpg-pattern-inline').addClass('dygpg-pattern-last'); 72 jQuery('.dygpg-content > div.dygpg-pattern-inline:last-child').addClass('dygpg-pattern-last'); 73 jQuery('.dygpg-cell > div.dygpg-pattern-inline:last-child').addClass('dygpg-pattern-last'); 74 74 75 //initialise the inline/block pattern arrows based on the value of the hidden input field 75 76 jQuery('[data-link="pattern-direction"]').each(function () { … … 110 111 jQuery('.dygpg-accordion .dygpg-pattern-title').off('click').on('click', function () { 111 112 jQuery(this).parent().find('.dygpg-content').toggle('blind', 112 function () { 113 dygpgEqualiseFunctions(); 114 } 113 function () { 114 aspect_ratio(); 115 equal_height(); 116 } 115 117 ); 116 118 }); … … 128 130 }); 129 131 130 // mousedown(handle_mousedown);132 // mousedown(handle_mousedown); 131 133 jQuery(".dygpg-close-edit").off("click").on("click", function () { 132 134 jQuery(this).closest('.dygpg-edit-wrapper').toggleClass('dygpg-edit-wrapper-open'); -
agb-free/trunk/dyg-grid/js/dygpg-misc.js
r2926907 r2926915 4 4 * and open the template in the editor. 5 5 */ 6 6 7 7 8 8 function dygpgFilter(elem, dygclass, index) { … … 17 17 jQuery(elem).toggleClass('dygpg-filter-disabled'); 18 18 scrollEventHandler(); 19 dygpgEqualiseFunctions() 19 aspect_ratio(); 20 equal_height(); 20 21 } 21 22 22 23 function dygpgReapplyFilters(id) { 23 jQuery(`.dyg-post-grid-wrapper-${id} .dygpg-filter-a:not(.dygpg-filter-disabled):not(.dygpg-filter-links)`).each(function () {24 jQuery(this).trigger('click'); 24 jQuery(`.dyg-post-grid-wrapper-${id} .dygpg-filter-a:not(.dygpg-filter-disabled):not(.dygpg-filter-links)`).each(function (){ 25 jQuery(this).trigger('click'); 25 26 }); 26 27 } -
agb-free/trunk/dyg-theme/includes/dyg-toolkit.php
r2926907 r2926915 2 2 3 3 function is_agb_theme() { 4 $test = class_exists('dyg_theme_updater') || function_exists('dyg_get_theme_colours'); 5 return $test; 4 return class_exists('dyg_theme_updater') || function_exists('dyg_get_theme_colours'); 6 5 } 7 6 8 7 function is_agb_pro() { 9 $test = class_exists('DygpgAjaxLoadMore'); 10 return $test; 8 return class_exists('DygpgAjaxLoadMore'); 11 9 } 12 10 … … 64 62 function dyg_array_insert_before(array $array, $key, array $new, $append = TRUE) { 65 63 $keys = array_keys($array); 66 $index = array_search($key, $ keys);64 $index = array_search($key, $array); 67 65 if ($index === FALSE and !$append) { 68 66 return $array; -
agb-free/trunk/readme.txt
r2926907 r2926915 1 # Advanced Grid Builder (AGB) 2 Tags: post grid, content grid, grid, grid generator, accordion,image gallery, lightbox, slideshow, blog, list generator, menu generator1 === AGB === 2 Tags: post grid, content grid, grid, grid generator, image gallery, lightbox, slideshow, blog, list generator, menu generator 3 3 Requires at least: 3.6 4 4 Contributors: AGB 5 5 Requires PHP: 7.4 6 6 Tested up to: 6.2 7 Stable tag: 4. 5.07 Stable tag: 4.1.0 8 8 License: GPLv2 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html=== 10 10 11 Unleash the power of your content with AGB, the ultimate grid builder plugin for WordPress. 11 Generate grids, lists, galleries and more with a simple WYSIWYG front end editor 12 12 13 ## Description 13 == Description == 14 14 15 ## # Create Dynamic, Beautiful Content Grids, Galleries, Lists, Menus, and More15 ## Turn your posts into grids, lists, galleries and more 16 16 17 AGB is not just another grid builder plugin. It's a powerful, user-friendly tool that transforms your WordPress content into dynamic, beautiful grids, lists, galleries, and more. 17 [Live Demo](https://advancedgridbuilder.com/) | [Documentation](https://advancedgridbuilder.com/documentation/) | [Buy Pro](https://advancedgridbuilder.com/pricing/) 18 18 19 [Live Demo](https://advancedgridbuilder.com/) | [Documentation](https://advancedgridbuilder.com/documentation/) | [Buy Pro](https://advancedgridbuilder.com/pricing/)20 19 21 With AGB, you can: 20 * Simple front end WYSIWYG editor 21 * Blogs, content grids, lists, menus, galleries 22 * Query builder 23 * Use theme presets, or build your own design 24 * Integrated help system 25 * Integrated support (Pro version) 26 * [Full features table](https://advancedgridbuilder.com/#features-table) 22 27 23 - Create stunning content grids, accordions, lists, menus, galleries, and more with a simple front-end WYSIWYG editor24 - Use our query builder to filter and sort your content25 - Choose from our theme presets or build your own unique design26 - Get help when you need it with our integrated help system27 - Enjoy premium support with our Pro version28 - [Explore our full features table](https://advancedgridbuilder.com/#features-table)29 28 30 ## #How to use29 ## How to use 31 30 32 1 .Edit a page or post.33 2 .Place the shortcode `[AGB id='unique_identifier']` where you would like the grid to appear.34 3 .Save, and then view the page on the front end.35 4 .Edit your grid using the blue gear icon which will appear for logged in administrators.31 1) Edit a page or post. 32 2) Place the shortcode `[AGB id='unique_identifier']` where you would like the grid to appear. 33 3) Save, and then view the page on the front end. 34 4) Edit your grid using the blue gear icon which will appear for logged in administrators. 36 35 37 ### Learn more38 36 39 Discover the limitless possibilities of AGB with our extensive collection of styles, examples, and demos on [our website](https://advancedgridbuilder.com/) 37 ## Learn more 40 38 41 ## Installation 39 See loads of styles, examples, videos and demos on [our website](https://advancedgridbuilder.com/) 42 40 43 1. Edit a page or post. 44 2. Place the shortcode `[AGB id='unique_identifier']` where you would like the grid to appear. 45 3. Save, and then view the page on the front end. 46 4. A blue gear cog will appear near the grid content providing access to the grids edit menu. 41 == Installation == 47 42 48 ## Frequently Asked Questions 43 1) Edit a page or post. 44 2) Place the shortcode `[AGB id='unique_identifier']` where you would like the grid to appear. 45 3) Save, and then view the page on the front end. 46 4) A blue gear cog will appear near the grid content providing access to the grids edit menu. 49 47 50 Have questions? We've got answers. Visit [our website](https://advancedgridbuilder.com/) for a comprehensive FAQ.51 48 52 ## Support 49 == Frequently Asked Questions == 53 50 54 Need help? We've got you covered. For support with the free AGB, visit the [support pages](https://wordpress.com/plugins/agb-free) on the Wordpress repository. 55 56 AGB Pro includes a convenient support request tool right inside the editor. To submit a request, simply enter a message in the provided text box and press the update button. Replies are emailed to the address used to register the plugin when purchased. If that address has changed or you can’t remember it, please submit an account support request [here](https://www.advancedgridbuilder.com/support/). 57 58 ## Presets 59 60 Get started quickly with our "Style Presets". These collections help you quickly achieve some of the most common configurations. The blog preset, for example, was designed specifically for your blog/news posts and includes all the usual fields you would expect to find, including hyperlinked meta fields. Check out more presets [here](https://www.advancedgridbuilder.com/presets/). 51 Get answers to all your questions on [our website](https://advancedgridbuilder.com/)
Note: See TracChangeset
for help on using the changeset viewer.