| @@ -271,25 +271,14 @@ | ||
| 271 | 271 | $this->elementIdColumn = 'ID'; |
| 272 | 272 | |
| 273 | 273 | parent::prepareListing(); |
| 274 | 274 | |
| 275 | + //if a category is selected | |
| 275 | 276 | if (!empty($this->pageInfo->filter_cat)) { |
| 276 | 277 | $this->query .= 'JOIN #__term_relationships AS cat ON post.ID = cat.object_id'; |
| 277 | 278 | $this->filters[] = 'cat.term_taxonomy_id = '.intval($this->pageInfo->filter_cat); |
| 278 | 279 | } |
| 279 | 280 | |
| 280 | - $rows = $this->getElements(); | |
| 281 | - foreach ($rows as $i => $row) { | |
| 282 | - if (str_replace(['wp:core-embed', 'wp:shortcode'], '', $row->post_content) !== $row->post_content) { | |
| 283 | - $rows[$i]->post_title = acym_tooltip( | |
| 284 | - [ | |
| 285 | - 'hoveredText' => '<i class="acymicon-exclamation-triangle"></i>', | |
| 286 | - 'textShownInTooltip' => acym_translation('ACYM_SPECIAL_CONTENT_WARNING'), | |
| 287 | - ] | |
| 288 | - ).$rows[$i]->post_title; | |
| 289 | - } | |
| 290 | - } | |
| 291 | - | |
| 292 | 281 | $listingOptions = [ |
| 293 | 282 | 'header' => [ |
| 294 | 283 | 'post_title' => [ |
| 295 | 284 | 'label' => 'ACYM_TITLE', |
| @@ -306,9 +295,9 @@ | ||
| 306 | 295 | 'class' => 'text-center', |
| 307 | 296 | ], |
| 308 | 297 | ], |
| 309 | 298 | 'id' => 'ID', |
| 310 | - 'rows' => $rows, | |
| 299 | + 'rows' => $this->getElements(), | |
| 311 | 300 | ]; |
| 312 | 301 | |
| 313 | 302 | return $this->getElementsListing($listingOptions); |
| 314 | 303 | } |
| @@ -468,9 +457,9 @@ | ||
| 468 | 457 | acym_translation('ACYM_CATEGORIES'), |
| 469 | 458 | ]; |
| 470 | 459 | } |
| 471 | 460 | |
| 472 | - $varFields['{readmore}'] = '<a class="acymailing_readmore_link" style="text-decoration:none;" target="_blank" href="'.$link.'"><span class="acymailing_readmore">'.acym_escape( | |
| 461 | + $varFields['{readmore}'] = '<a class="acymailing_readmore_link" style="text-decoration:none;" target="_blank" href="'.$link.'"><span class="acymailing_readmore">'.esc_html( | |
| 473 | 462 | acym_translation('ACYM_READ_MORE') |
| 474 | 463 | ).'</span></a>'; |
| 475 | 464 | if (in_array('readmore', $tag->display)) { |
| 476 | 465 | $afterArticle .= $varFields['{readmore}']; |
| @@ -529,8 +518,16 @@ | ||
| 529 | 518 | |
| 530 | 519 | return $categoryTitle.$this->finalizeElementFormat($result, $tag, $varFields); |
| 531 | 520 | } |
| 532 | 521 | |
| 522 | + /** | |
| 523 | + * Used in Gutenberg block and elementor | |
| 524 | + * | |
| 525 | + * @param bool $ajax | |
| 526 | + * @param int $postPerPage | |
| 527 | + * | |
| 528 | + * @return array|array[]|void | |
| 529 | + */ | |
| 533 | 530 | public function getPosts(bool $ajax = true, int $postPerPage = 20) |
| 534 | 531 | { |
| 535 | 532 | $return = $ajax ? [] : [0 => [0, acym_translation('ACYM_SELECT_AN_ARTICLE')]]; |
| 536 | 533 | |
| @@ -568,8 +565,9 @@ | ||
| 568 | 565 | $languageCode = $this->config->get('multilingual_default', ACYM_DEFAULT_LANGUAGE); |
| 569 | 566 | } else { |
| 570 | 567 | $idDefaultLanguage = $this->getTranslationId($elementId, $translationTool, true); |
| 571 | 568 | |
| 569 | + // We only translate inserted articles of the default language | |
| 572 | 570 | if ($idDefaultLanguage !== $elementId) { |
| 573 | 571 | return $elementId; |
| 574 | 572 | } |
| 575 | 573 | } |
| @@ -582,8 +580,9 @@ | ||
| 582 | 580 | if (!empty($translationId)) $elementId = $translationId; |
| 583 | 581 | } |
| 584 | 582 | } elseif ($translationTool === 'wpml') { |
| 585 | 583 | if (acym_isExtensionActive('sitepress-multilingual-cms/sitepress.php')) { |
| 584 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound -- WPML hook for integration. | |
| 586 | 585 | $elementId = apply_filters('wpml_object_id', $elementId, 'post', true, $languageCode); |
| 587 | 586 | } |
| 588 | 587 | } |
| 589 | 588 | |
| @@ -619,11 +618,9 @@ | ||
| 619 | 618 | } elseif ($field['type'] === 'image') { |
| 620 | 619 | if (empty($value['link'])) { |
| 621 | 620 | $value = ''; |
| 622 | 621 | } else { |
| 623 | - $alt = acym_escape($value['alt']); | |
| 624 | - | |
| 625 | - $value = '<img alt="'.$alt.'" src="'.$value['link'].'" />'; | |
| 622 | + $value = '<img alt="'.esc_attr($value['alt']).'" src="'.esc_url($value['link']).'" />'; | |
| 626 | 623 | } |
| 627 | 624 | } elseif (in_array($field['type'], ['checkbox', 'select'])) { |
| 628 | 625 | if (is_array($value)) { |
| 629 | 626 | $value = implode(', ', $value); |
| @@ -633,9 +630,9 @@ | ||
| 633 | 630 | } elseif ($field['type'] === 'file') { |
| 634 | 631 | if (empty($value['link'])) { |
| 635 | 632 | $value = ''; |
| 636 | 633 | } else { |
| 637 | - $value = '<a href="'.$value['link'].'" target="_blank">'.acym_escape( | |
| 634 | + $value = '<a href="'.$value['link'].'" target="_blank">'.esc_html( | |
| 638 | 635 | $value['filename'] |
| 639 | 636 | ).'</a>'; |
| 640 | 637 | } |
| 641 | 638 | } elseif ($field['type'] === 'textarea') { |
| @@ -641,12 +638,12 @@ | ||
| 641 | 638 | } elseif ($field['type'] === 'textarea') { |
| 642 | 639 | $value = nl2br($value); |
| 643 | 640 | } elseif (in_array($field['type'], ['time_picker', 'date_picker', 'date_time_picker'])) { |
| 644 | 641 | if ($field['display_format'] !== $field['return_format']) { |
| 645 | - $value = date($field['display_format'], strtotime($value)); | |
| 642 | + $value = gmdate($field['display_format'], strtotime($value)); | |
| 646 | 643 | } |
| 647 | 644 | } else { |
| 648 | - $value = acym_escape($value); | |
| 645 | + $value = esc_html($value); | |
| 649 | 646 | } |
| 650 | 647 | |
| 651 | 648 | return $value; |
| 652 | 649 | } |