| @@ -15,8 +15,9 @@ | ||
| 15 | 15 | public static string $library; |
| 16 | 16 | public static array $lightbox_replacements; |
| 17 | 17 | public static array $safe_tags; |
| 18 | 18 | public static array $safe_title_tags; |
| 19 | + public static array $safe_description_tags; | |
| 19 | 20 | |
| 20 | 21 | public function __construct() { |
| 21 | 22 | // $start = microtime(true); |
| 22 | 23 | global $photonic_options; |
| @@ -24,8 +25,9 @@ | ||
| 24 | 25 | self::$lightbox_replacements = [ |
| 25 | 26 | 'fancybox' => 'fancybox3', |
| 26 | 27 | 'magnific' => 'venobox', |
| 27 | 28 | 'prettyphoto' => 'spotlight', |
| 29 | + 'strip' => 'venobox', | |
| 28 | 30 | ]; |
| 29 | 31 | |
| 30 | 32 | self::$safe_tags = array_merge_recursive( |
| 31 | 33 | [ |
| @@ -69,9 +71,10 @@ | ||
| 69 | 71 | // Slideshow |
| 70 | 72 | 'data-splide' => true, |
| 71 | 73 | ], |
| 72 | 74 | |
| 73 | -/* 'ul' => [ | |
| 75 | + /* | |
| 76 | + 'ul' => [ | |
| 74 | 77 | // Slideshows |
| 75 | 78 | 'data-photonic-columns' => true, |
| 76 | 79 | 'data-photonic-controls' => true, |
| 77 | 80 | 'data-photonic-fx' => true, |
| @@ -79,9 +82,10 @@ | ||
| 79 | 82 | 'data-photonic-pause' => true, |
| 80 | 83 | 'data-photonic-speed' => true, |
| 81 | 84 | 'data-photonic-strip-style' => true, |
| 82 | 85 | 'data-photonic-timeout' => true, |
| 83 | - ],*/ | |
| 86 | + ], | |
| 87 | + */ | |
| 84 | 88 | |
| 85 | 89 | 'img' => [ |
| 86 | 90 | // Lazy loading |
| 87 | 91 | 'data-src' => true, |
| @@ -174,8 +178,17 @@ | ||
| 174 | 178 | self::$safe_title_tags = [ |
| 175 | 179 | 'h4' => [], |
| 176 | 180 | ]; |
| 177 | 181 | |
| 182 | + self::$safe_description_tags = [ | |
| 183 | + 'strong' => [], | |
| 184 | + 'em' => [], | |
| 185 | + 'b' => [], | |
| 186 | + 'i' => [], | |
| 187 | + 'br' => [], | |
| 188 | + 'p' => [], | |
| 189 | + ]; | |
| 190 | + | |
| 178 | 191 | require_once PHOTONIC_PATH . "/Options/Options.php"; |
| 179 | 192 | add_action('admin_init', [Options::get_instance(), 'prepare_options'], 20); // Setting to 20 so that CPTs can be picked up - Utilities are loaded with a priority 10 |
| 180 | 193 | |
| 181 | 194 | $this->localized = false; |
| @@ -261,15 +274,15 @@ | ||
| 261 | 274 | */ |
| 262 | 275 | // The above code was commented out in March 2023, Photonic v 2.85, to prevent running the cron for Instagram. |
| 263 | 276 | // The code below was added to clean out any previously scheduled cron jobs. |
| 264 | 277 | // This will be removed not before March 2024, to give users the opportunity to install the plugin and have it un-schedule their jobs. |
| 265 | - $photonic_token_monitor_timestamp = wp_next_scheduled('photonic_token_monitor'); | |
| 266 | - wp_unschedule_event($photonic_token_monitor_timestamp, 'photonic_token_monitor'); | |
| 278 | + // $photonic_token_monitor_timestamp = wp_next_scheduled('photonic_token_monitor'); | |
| 279 | + // wp_unschedule_event($photonic_token_monitor_timestamp, 'photonic_token_monitor'); | |
| 267 | 280 | |
| 268 | 281 | $this->add_extensions(); |
| 269 | 282 | $this->add_gutenberg_support(); |
| 270 | 283 | |
| 271 | - add_action('http_api_curl', [&$this, 'curl_timeout'], 100, 1); | |
| 284 | + add_action('http_api_curl', [&$this, 'curl_timeout'], 100); | |
| 272 | 285 | |
| 273 | 286 | add_action('plugins_loaded', [&$this, 'enable_translations']); |
| 274 | 287 | |
| 275 | 288 | add_filter('body_class', [&$this, 'body_class']); |
| @@ -292,8 +305,11 @@ | ||
| 292 | 305 | * |
| 293 | 306 | * @return void |
| 294 | 307 | */ |
| 295 | 308 | public function add_admin_menu() { |
| 309 | + require_once PHOTONIC_PATH . "/Admin/Admin_Menu.php"; | |
| 310 | + $this->admin_menu = new Admin_Menu(__FILE__, $this); | |
| 311 | + | |
| 296 | 312 | if (current_user_can('edit_theme_options')) { |
| 297 | 313 | $parent_slug = 'photonic-options-manager'; |
| 298 | 314 | } |
| 299 | 315 | elseif (current_user_can('edit_posts')) { |
| @@ -521,9 +537,9 @@ | ||
| 521 | 537 | * |
| 522 | 538 | * @param bool $header |
| 523 | 539 | * @return string |
| 524 | 540 | */ |
| 525 | - public function generate_css($header = true): string { | |
| 541 | + public function generate_css(bool $header = true): string { | |
| 526 | 542 | global $photonic_tile_spacing, $photonic_masonry_tile_spacing, $photonic_mosaic_tile_spacing; |
| 527 | 543 | |
| 528 | 544 | $css = ''; |
| 529 | 545 | $saved_css = get_option('photonic_css'); |
| @@ -556,14 +572,8 @@ | ||
| 556 | 572 | } |
| 557 | 573 | |
| 558 | 574 | public function admin_init(): void { |
| 559 | 575 | require_once PHOTONIC_PATH . "/Admin/Admin.php"; |
| 560 | - | |
| 561 | - if (!empty($_REQUEST['page']) && // phpcs:ignore WordPress.Security.NonceVerification | |
| 562 | - in_array($_REQUEST['page'], ['photonic-options-manager', 'photonic-options', 'photonic-helpers', 'photonic-getting-started', 'photonic-auth', 'photonic-shortcode-replace'], true)) { // phpcs:ignore WordPress.Security.NonceVerification | |
| 563 | - require_once PHOTONIC_PATH . "/Admin/Admin_Menu.php"; | |
| 564 | - $this->admin_menu = new Admin_Menu(__FILE__, $this); | |
| 565 | - } | |
| 566 | 576 | } |
| 567 | 577 | |
| 568 | 578 | public function add_extensions() { |
| 569 | 579 | require_once "Gallery.php"; |
| @@ -574,9 +584,9 @@ | ||
| 574 | 584 | /** |
| 575 | 585 | * Overrides the native gallery short code, and does a lot more. |
| 576 | 586 | * |
| 577 | 587 | * @param $content |
| 578 | - * @param array $attr | |
| 588 | + * @param array|string $attr | |
| 579 | 589 | * @return string |
| 580 | 590 | */ |
| 581 | 591 | public function modify_gallery($content, $attr = []) { |
| 582 | 592 | global $photonic_disable_on_home_page, $photonic_disable_on_archives; |
| @@ -597,13 +607,9 @@ | ||
| 597 | 607 | |
| 598 | 608 | $this->conditionally_add_scripts(); |
| 599 | 609 | $images = $this->get_gallery_images($attr); |
| 600 | 610 | |
| 601 | - if (!is_array($images)) { | |
| 602 | - return wp_kses($images, self::$safe_tags); | |
| 603 | - } | |
| 604 | - | |
| 605 | - return wp_kses($content, self::$safe_tags); | |
| 611 | + return wp_kses($images, self::$safe_tags); | |
| 606 | 612 | } |
| 607 | 613 | |
| 608 | 614 | /** |
| 609 | 615 | * Adds Photonic attributes to the native WP galleries. This cannot be called in <code>Photonic_Plugin\Platforms\Native</code> because |
| @@ -644,9 +650,9 @@ | ||
| 644 | 650 | /** |
| 645 | 651 | * @param array $attr |
| 646 | 652 | * @return string |
| 647 | 653 | */ |
| 648 | - public function helper_shortcode($attr = []): string { | |
| 654 | + public function helper_shortcode(array $attr = []): string { | |
| 649 | 655 | if (empty($attr)) { |
| 650 | 656 | $attr = []; |
| 651 | 657 | } |
| 652 | 658 | |
| @@ -672,19 +678,19 @@ | ||
| 672 | 678 | /** |
| 673 | 679 | * Make an HTTP request |
| 674 | 680 | * |
| 675 | 681 | * @static |
| 676 | - * @param $url | |
| 677 | - * @param string $method GET | POST | DELETE. | |
| 678 | - * @param null $post_fields | |
| 679 | - * @param string $user_agent | |
| 680 | - * @param int $timeout | |
| 681 | - * @param bool $ssl_verify_peer | |
| 682 | - * @param array $headers | |
| 683 | - * @param array $cookies | |
| 682 | + * @param string $url | |
| 683 | + * @param string $method GET | POST. | |
| 684 | + * @param array|null $post_fields | |
| 685 | + * @param string|null $user_agent | |
| 686 | + * @param int $timeout | |
| 687 | + * @param bool $ssl_verify_peer | |
| 688 | + * @param array $headers | |
| 689 | + * @param array $cookies | |
| 684 | 690 | * @return array|WP_Error |
| 685 | 691 | */ |
| 686 | - public static function http($url, $method = 'POST', $post_fields = null, $user_agent = null, $timeout = 90, $ssl_verify_peer = false, $headers = [], $cookies = []) { | |
| 692 | + public static function http(string $url, string $method = 'POST', ?array $post_fields = null, ?string $user_agent = null, int $timeout = 90, bool $ssl_verify_peer = false, array $headers = [], array $cookies = []) { | |
| 687 | 693 | $curl_args = [ |
| 688 | 694 | 'user-agent' => $user_agent, |
| 689 | 695 | 'timeout' => $timeout, |
| 690 | 696 | 'sslverify' => $ssl_verify_peer, |
| @@ -693,21 +699,13 @@ | ||
| 693 | 699 | 'body' => $post_fields, |
| 694 | 700 | 'cookies' => $cookies, |
| 695 | 701 | ]; |
| 696 | 702 | |
| 697 | - switch ($method) { | |
| 698 | - case 'DELETE': | |
| 699 | - if (!empty($post_fields)) { | |
| 700 | - $url = "{$url}?{$post_fields}"; | |
| 701 | - } | |
| 702 | - break; | |
| 703 | - } | |
| 704 | - | |
| 705 | 703 | return wp_remote_request($url, $curl_args); |
| 706 | 704 | } |
| 707 | 705 | |
| 708 | 706 | public function enable_translations() { |
| 709 | - load_plugin_textdomain('photonic', false, false); | |
| 707 | + load_plugin_textdomain('photonic'); | |
| 710 | 708 | } |
| 711 | 709 | |
| 712 | 710 | /** |
| 713 | 711 | * @param string|array $classes |
| @@ -731,12 +729,12 @@ | ||
| 731 | 729 | if (!empty($attributes['shortcode'])) { |
| 732 | 730 | $shortcode = (array) (json_decode($attributes['shortcode'])); |
| 733 | 731 | |
| 734 | 732 | if (!empty($attributes['align'])) { |
| 735 | - $shortcode['alignment'] = $attributes['align']; | |
| 733 | + $shortcode['alignment'] = esc_attr($attributes['align']); | |
| 736 | 734 | } |
| 737 | 735 | if (!empty($attributes['className'])) { |
| 738 | - $shortcode['custom_classes'] = $attributes['className']; | |
| 736 | + $shortcode['custom_classes'] = esc_attr($attributes['className']); | |
| 739 | 737 | } |
| 740 | 738 | |
| 741 | 739 | $this->conditionally_add_scripts(); |
| 742 | 740 | return $this->get_gallery_images($shortcode); |
| @@ -762,9 +760,9 @@ | ||
| 762 | 760 | |
| 763 | 761 | public function curl_timeout($handle) { |
| 764 | 762 | // Forcing phpcs:ignore here, since the explicit purpose is to change cURL's timeout. |
| 765 | 763 | curl_setopt($handle, CURLOPT_CONNECTTIMEOUT, PHOTONIC_CURL_TIMEOUT); // phpcs:ignore WordPress.WP.AlternativeFunctions |
| 766 | - curl_setopt($handle, CURLOPT_TIMEOUT, PHOTONIC_CURL_TIMEOUT < 30 ? 30 : PHOTONIC_CURL_TIMEOUT); // phpcs:ignore WordPress.WP.AlternativeFunctions | |
| 764 | + curl_setopt($handle, CURLOPT_TIMEOUT, max(PHOTONIC_CURL_TIMEOUT, 30)); // phpcs:ignore WordPress.WP.AlternativeFunctions | |
| 767 | 765 | } |
| 768 | 766 | |
| 769 | 767 | public static function log($element) { |
| 770 | 768 | if (PHOTONIC_DEBUG) { |