diff --git a/.wordpress-org/icon.svg b/.wordpress-org/icon.svg deleted file mode 100644 index c12a9ebc..00000000 --- a/.wordpress-org/icon.svg +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Modula.php b/Modula.php index dad40f64..be6a32cf 100644 --- a/Modula.php +++ b/Modula.php @@ -4,7 +4,7 @@ * Plugin URI: https://wp-modula.com/ * Description: Modula is the most powerful, user-friendly WordPress gallery plugin. Add galleries, masonry grids and more in a few clicks. * Author: WPChill -* Version: 2.11.2 +* Version: 2.11.3 * Author URI: https://www.wpchill.com/ * License: GPLv3 or later * License URI: http://www.gnu.org/licenses/gpl-3.0.html @@ -47,7 +47,7 @@ * @since 2.0.2 */ -define( 'MODULA_LITE_VERSION', '2.11.2' ); +define( 'MODULA_LITE_VERSION', '2.11.3' ); define( 'MODULA_PATH', plugin_dir_path( __FILE__ ) ); define( 'MODULA_URL', plugin_dir_url( __FILE__ ) ); defined( 'MODULA_PRO_STORE_URL' ) || define( 'MODULA_PRO_STORE_URL', 'https://wp-modula.com' ); diff --git a/apps/notification-system/notification/notification-actions.jsx b/apps/notification-system/notification/notification-actions.jsx index 2de17cdb..ef568325 100644 --- a/apps/notification-system/notification/notification-actions.jsx +++ b/apps/notification-system/notification/notification-actions.jsx @@ -3,7 +3,6 @@ import { Button } from '@wordpress/components'; import he from 'he'; export function NotificationActions( { actions, id, onDismiss } ) { - const handleClick = (action, id) => { if (action.callback && typeof window[action.callback] === 'function') { window[action.callback](action, id); @@ -20,7 +19,7 @@ export function NotificationActions( { actions, id, onDismiss } ) { ',main:''},Thumbs:Object.assign(e.Thumbs,{type:"classic",Carousel:{axis:"y"},parentEl:function(o){var e=o.instance.container.querySelector(".fancybox__sidebar");return e||((e=document.createElement("div")).className="fancybox__sidebar "+t,o.instance.container.appendChild(e)),e}})}),modulaFancybox.open(o,e,n)}});var modulaFancybox={open:function(o,e,n){return o.forEach((function(e,n){void 0!==e.opts.caption&&(o[n].caption=DOMPurify.sanitize(e.opts.caption)),void 0!==e.opts.thumb&&(o[n].thumb=e.opts.thumb)})),e.startIndex=n,void 0!==e.Slideshow&&(e.Slideshow.progressParentEl=function(o){return o.instance.container}),void 0!==e.Toolbar&&void 0!==e.Toolbar.items&&void 0!==e.Toolbar.items.share&&(e.Toolbar.items.share.click=function(){ModulaOpenShare()}),e.on={},e.on["*"]=function(o,e){jQuery(document).trigger("modula_fancybox_"+e.replace(/\./g,"_"),[o,this])},e.on["Carousel.ready Carousel.change"]=function(o,e){var n=o.options,t=void 0!==n.Slideshow&&void 0!==n.Slideshow.pauseOnHover&&n.Slideshow.pauseOnHover,a=o.plugins.Slideshow.ref,i=!1;"1"==t&&(document.querySelector(".modula-fancybox-container .fancybox__slide .fancybox__content").addEventListener("mouseover",(function(o){"play"==a.state&&(i=!0,a.stop())})),document.querySelector(".modula-fancybox-container .fancybox__slide .fancybox__content").addEventListener("mouseout",(function(o){"ready"==a.state&&i&&(i=!1,a.start())})))},e.on.init=function(o){jQuery(document).trigger("modula_fancybox_lightbox_on_init",[o,this])},new ModulaFancybox(o,e)},getInstance:function(){return this}};function escapeHtml(o){var e={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};return String(o).replace(/[&<>"'`=\/]/g,(function(o){return e[o]}))}function ModulaOpenShare(){var o=ModulaFancybox.getInstance(),e=ModulaFancybox.getSlide(),n=void 0!==e.opts.image_src?e.opts.image_src:e.src,t="

"+o.options.l10n.SHARE+"

",a=JSON.parse(ModulaShareButtons);o.options.modulaShare.forEach((function(i,s){var r=(o.options.lightboxEmailMessage.length?o.options.lightboxEmailMessage:o.options.l10n.EMAIL).replace(/\%%gallery_link%%/g,window.location.href).replace(/\%%image_link%%/g,n),c=void 0!==e.opts.alt?e.opts.alt:"";""===c&&e.caption&&void 0!==e.caption&&(c=e.caption),t+=a[i].template({media:"image"===e.type?encodeURIComponent(n):"",modulaShareUrl:encodeURIComponent(n),descr:encodeURIComponent(c),subject:encodeURIComponent(o.options.lightboxEmailSubject),emailMessage:encodeURIComponent(r)})})),t=(t+="

").template({url_raw:escapeHtml(n)}),new ModulaFancybox([{src:t,type:"html",width:640,height:360}],{mainClass:"modula-fancybox-container"})}String.prototype.template=function(o){return this.replace(/\{([^\}]+)\}/g,(function(e,n){for(var t=o,a=n.split("|")[0].split("."),i=0;i',main:''},Thumbs:Object.assign(e.Thumbs,{type:"classic",Carousel:{axis:"y"},parentEl:function(o){var e=o.instance.container.querySelector(".fancybox__sidebar");return e||((e=document.createElement("div")).className="fancybox__sidebar "+a,o.instance.container.appendChild(e)),e}})}),modulaFancybox.open(o,e,n)}});var modulaFancybox={open:function(o,e,n){return o.forEach((function(e,n){void 0!==e.opts.caption&&(o[n].caption=DOMPurify.sanitize(e.opts.caption)),void 0!==e.opts.thumb&&(o[n].thumb=e.opts.thumb)})),e.startIndex=n,void 0!==e.Slideshow&&(e.Slideshow.progressParentEl=function(o){return o.instance.container}),void 0!==e.Toolbar&&void 0!==e.Toolbar.items&&void 0!==e.Toolbar.items.share&&(e.Toolbar.items.share.click=function(){ModulaOpenShare()}),e.on={},e.on["*"]=function(o,e){jQuery(document).trigger("modula_fancybox_"+e.replace(/\./g,"_"),[o,this]);var n=new CustomEvent("modula_fancybox_"+e.replace(/\./g,"_"),{detail:{fancybox:o,instance:this}});document.dispatchEvent(n)},e.on["Carousel.ready Carousel.change"]=function(o,e){var n=o.options,t=void 0!==n.Slideshow&&void 0!==n.Slideshow.pauseOnHover&&n.Slideshow.pauseOnHover,a=o.plugins.Slideshow.ref,i=!1;"1"==t&&(document.querySelector(".modula-fancybox-container .fancybox__slide .fancybox__content").addEventListener("mouseover",(function(o){"play"==a.state&&(i=!0,a.stop())})),document.querySelector(".modula-fancybox-container .fancybox__slide .fancybox__content").addEventListener("mouseout",(function(o){"ready"==a.state&&i&&(i=!1,a.start())})))},e.on.init=function(o){jQuery(document).trigger("modula_fancybox_lightbox_on_init",[o,this])},new ModulaFancybox(o,e)},getInstance:function(){return this}};function escapeHtml(o){var e={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};return String(o).replace(/[&<>"'`=\/]/g,(function(o){return e[o]}))}function ModulaOpenShare(){var o=ModulaFancybox.getInstance(),e=ModulaFancybox.getSlide(),n=void 0!==e.opts.image_src?e.opts.image_src:e.src,t="

"+o.options.l10n.SHARE+"

",a=JSON.parse(ModulaShareButtons);o.options.modulaShare.forEach((function(i,s){var c=(o.options.lightboxEmailMessage.length?o.options.lightboxEmailMessage:o.options.l10n.EMAIL).replace(/\%%gallery_link%%/g,window.location.href).replace(/\%%image_link%%/g,n),r=void 0!==e.opts.alt?e.opts.alt:"";""===r&&e.caption&&void 0!==e.caption&&(r=e.caption),t+=a[i].template({media:"image"===e.type?encodeURIComponent(n):"",modulaShareUrl:encodeURIComponent(n),descr:encodeURIComponent(r),subject:encodeURIComponent(o.options.lightboxEmailSubject),emailMessage:encodeURIComponent(c)})})),t=(t+="

").template({url_raw:escapeHtml(n)}),new ModulaFancybox([{src:t,type:"html",width:640,height:360}],{mainClass:"modula-fancybox-container"})}String.prototype.template=function(o){return this.replace(/\{([^\}]+)\}/g,(function(e,n){for(var t=o,a=n.split("|")[0].split("."),i=0;i { ], }); - jQuery.ajax({ - type: 'POST', - data: { - action: 'modula_get_gallery_meta', - id: id, - nonce: modulaVars.nonce, - }, - url: modulaVars.ajaxURL, - success: (result) => onGalleryLoaded(id, result), - }); + setAttributes({ id: id, images: res.modulaImages }); + if (idCheck != id || undefined == settings) { + getSettings(id); + } }); }; function escapeHtml(text) { @@ -94,16 +89,6 @@ export const ModulaEdit = (props) => { .replace('‘', "'"); } - const onGalleryLoaded = (id, result) => { - if (result.success === false) { - setAttributes({ id: id, status: 'ready' }); - return; - } - if (idCheck != id || undefined == settings) { - getSettings(id); - } - setAttributes({ id: id, images: result, status: 'ready' }); - }; const getSettings = (id) => { fetch(`${modulaVars.restURL}wp/v2/modula-gallery/${id}`) .then((res) => res.json()) @@ -377,6 +362,6 @@ const applyWithSelect = withSelect((select, props) => { }; }); -const applyWithFilters = wp.components.withFilters('modula.ModulaEdit'); +const applyWithFilters = withFilters('modula.ModulaEdit')(ModulaEdit); -export default compose(applyWithSelect, applyWithFilters)(ModulaEdit); +export default compose(applyWithSelect)(ModulaEdit); diff --git a/changelog.txt b/changelog.txt index 871eba1b..518e223e 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,9 @@ == Changelog == += 2.11.3 - 27.11.2024 = +Fixed: PHP Warning +Fixed: Gallery item has data-width and data-height on non-required gallery types +Fixed: Notification action URL encoding + = 2.11.2 - 20.11.2024 = Added: Increased functionality for sanitization of gallery settings. diff --git a/includes/admin/class-modula-rest-api.php b/includes/admin/class-modula-rest-api.php index 100c6274..6a7ed737 100644 --- a/includes/admin/class-modula-rest-api.php +++ b/includes/admin/class-modula-rest-api.php @@ -5,7 +5,7 @@ } class Modula_Rest_Api { - protected $namespace = 'modula-api/v1'; + protected $namespace = 'modula/v1'; public function __construct() { add_action( 'rest_api_init', array( $this, 'register_routes' ) ); @@ -17,7 +17,7 @@ public function register_routes() { '/notifications', array( 'methods' => 'GET', - 'callback' => array( $this, 'process_request' ), + 'callback' => array( $this, 'get_notifications' ), 'permission_callback' => array( $this, '_permissions_check' ), ) ); @@ -27,7 +27,7 @@ public function register_routes() { '/notifications', array( 'methods' => 'DELETE', - 'callback' => array( $this, 'process_request' ), + 'callback' => array( $this, 'delete_notifications' ), 'permission_callback' => array( $this, '_permissions_check' ), ) ); @@ -37,7 +37,7 @@ public function register_routes() { '/notifications/(?P[\w-]+)', array( 'methods' => 'DELETE', - 'callback' => array( $this, 'process_request' ), + 'callback' => array( $this, 'delete_notification' ), 'permission_callback' => array( $this, '_permissions_check' ), ) ); @@ -74,6 +74,41 @@ function ( $carry, $item ) { return rest_ensure_response( array() ); } + public function delete_notifications() { + $manager = Modula_Notifications::get_instance(); + $manager->clear_notifications(); + return rest_ensure_response( true ); + } + + public function delete_notification( $request ) { + $manager = Modula_Notifications::get_instance(); + $body = $request->get_json_params(); + $notification_id = $request->get_param( 'id' ); + + if ( ! $notification_id ) { + return rest_ensure_response( false ); + } + + $permanent = isset( $body['permanent'] ) ? $body['permanent'] : false; + $manager->clear_notification( $notification_id, $permanent ); + return rest_ensure_response( true ); + } + + public function get_notifications() { + $manager = Modula_Notifications::get_instance(); + $notifications = $manager->get_notifications(); + + $is_empty = array_reduce( + $notifications, + function ( $carry, $item ) { + return $carry && empty( $item ); + }, + true + ); + + return rest_ensure_response( $is_empty ? array() : $notifications ); + } + public function _permissions_check() { return current_user_can( 'manage_options' ); } diff --git a/includes/class-modula-backward-compatibility.php b/includes/class-modula-backward-compatibility.php index 581d3ee9..30b52935 100644 --- a/includes/class-modula-backward-compatibility.php +++ b/includes/class-modula-backward-compatibility.php @@ -339,7 +339,7 @@ public function backward_compatibility_backbone_thumb_size( $settings ) { public function modula_fancybox_5_settings_matcher( $options, $settings ) { - if ( ! isset( $options['mainClass'] ) ) { + if ( ! isset( $options['mainClass'] ) && isset( $settings['gallery_id'] ) ) { $options['mainClass'] = 'modula-fancybox-container modula-lightbox-' . $settings['gallery_id']; } diff --git a/includes/class-modula-gutenberg.php b/includes/class-modula-gutenberg.php index 9e6fae8f..c236185d 100644 --- a/includes/class-modula-gutenberg.php +++ b/includes/class-modula-gutenberg.php @@ -25,10 +25,12 @@ function __construct() { add_action( 'init', array( $this, 'register_block_type' ) ); add_action( 'init', array( $this, 'generate_js_vars' ) ); add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_block_assets' ), 1 ); - add_action( 'wp_ajax_modula_get_gallery_meta', array( $this, 'get_gallery_meta' ) ); add_action( 'wp_ajax_modula_get_gallery', array( $this, 'get_gallery' ) ); add_action( 'wp_ajax_modula_get_jsconfig', array( $this, 'get_jsconfig' ) ); add_action( 'wp_ajax_modula_check_hover_effect', array( $this, 'check_hover_effect' ) ); + // Filter the gallery data for the REST API. Used for the Gutenberg editor, to remove the + // image data-width and data-height attributes. + add_filter( 'rest_prepare_modula-gallery', array( $this, 'rest_api_filter_data' ), 15, 3 ); } /** @@ -145,65 +147,6 @@ public function render_modula_gallery( $atts ) { } } - /** - * Gallery meta ajax callback - * - * @since 2.5.0 - */ - public function get_gallery_meta() { - - $id = $_POST['id']; //phpcs:ignore - $nonce = $_POST['nonce']; //phpcs:ignore - - if ( ! wp_verify_nonce( $nonce, 'modula_nonce' ) ) { - wp_send_json_error( 'no nonce' ); - die(); - } - - $images = get_post_meta( $id, 'modula-images', true ); - - if ( ! is_array( $images ) || empty( $images ) ) { - wp_send_json_error( 'no images' ); - die(); - } - - foreach ( $images as $key => $value ) : - if ( ! isset( $value['video_template'] ) || '1' !== $value['video_template'] ) { - $image_obj = wp_get_attachment_image_src( $images[ $key ]['id'], 'large' ); - - if ( ! $image_obj ) { - continue; - } - - $images[ $key ]['src'] = $image_obj[0]; - $images[ $key ]['data-width'] = $images[ $key ]['width']; - $images[ $key ]['data-height'] = $images[ $key ]['height']; - $images[ $key ]['width'] = $image_obj[1]; - $images[ $key ]['height'] = $image_obj[2]; - } else { - $images[ $key ]['src'] = $value['video_thumbnail']; - $images[ $key ]['video_type'] = false; - if ( class_exists( 'Modula_Video' ) ) { - $images[ $key ]['src'] = Modula_Video::video_link_formatter( $value['video_url'] ); - if ( strpos( $value['video_url'], 'youtu' ) !== false || strpos( $value['video_url'], 'vimeo' ) !== false ) { - $images[ $key ]['video_type'] = 'iframe'; - } else { - $images[ $key ]['video_type'] = 'hosted'; - } - } - - $images[ $key ]['data-width'] = $value['video_width']; - $images[ $key ]['data-height'] = $value['video_height']; - $images[ $key ]['width'] = $value['video_width']; - $images[ $key ]['height'] = $value['video_height']; - } - endforeach; - - wp_send_json( $images ); - - die(); - } - /** * Get js config ajax callback * @@ -300,6 +243,54 @@ public function get_gallery() { wp_send_json( $suggestions ); } + + /** + * Filter the REST API response + * + * @param $settings + * + * @return array + * @since 2.11.3 + */ + public function rest_api_filter_data( $response, $post, $request ) { + $data = $response->get_data(); + $images = $data['modulaImages']; + + foreach ( $images as $key => $image ) { + if ( ! isset( $value['video_template'] ) || '1' !== $value['video_template'] ) { + $image_obj = wp_get_attachment_image_src( $images[ $key ]['id'], 'large' ); + + if ( ! $image_obj ) { + continue; + } + + $data['modulaImages'][ $key ]['src'] = $image_obj[0]; + $data['modulaImages'][ $key ]['data-width'] = $images[ $key ]['width']; + $data['modulaImages'][ $key ]['data-height'] = $images[ $key ]['height']; + $data['modulaImages'][ $key ]['width'] = $image_obj[1]; + $data['modulaImages'][ $key ]['height'] = $image_obj[2]; + } else { + $data['modulaImages'][ $key ]['src'] = $value['video_thumbnail']; + $data['modulaImages'][ $key ]['video_type'] = false; + if ( class_exists( 'Modula_Video' ) ) { + $data['modulaImages'][ $key ]['src'] = Modula_Video::video_link_formatter( $value['video_url'] ); + if ( strpos( $value['video_url'], 'youtu' ) !== false || strpos( $value['video_url'], 'vimeo' ) !== false ) { + $data['modulaImages'][ $key ]['video_type'] = 'iframe'; + } else { + $data['modulaImages'][ $key ]['video_type'] = 'hosted'; + } + } + + $data['modulaImages'][ $key ]['data-width'] = $value['video_width']; + $data['modulaImages'][ $key ]['data-height'] = $value['video_height']; + $data['modulaImages'][ $key ]['width'] = $value['video_width']; + $data['modulaImages'][ $key ]['height'] = $value['video_height']; + } + } + // Set the new data + $response->set_data( $data ); + return $response; + } } new Modula_Gutenberg(); diff --git a/package-lock.json b/package-lock.json index 08911c55..3c4ba564 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "modula-best-grid-gallery", - "version": "2.11.1", + "version": "2.11.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "modula-best-grid-gallery", - "version": "2.11.1", + "version": "2.11.3", "license": "GPL-2.0-or-later", "dependencies": { "@tanstack/react-query": "^5.52.0", diff --git a/package.json b/package.json index f10fda6b..bfec7795 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "modula-best-grid-gallery", - "version": "2.11.2", + "version": "2.11.3", "description": "Modula Image Gallery build tools", "author": "WPChill", "license": "GPL-2.0-or-later", diff --git a/readme.txt b/readme.txt index 142ad5f3..2af7eba1 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Tags: best gallery plugin, image gallery, video gallery, free gallery, wordpress Requires at least: 5.3 Tested up to: 6.7 Requires PHP: 5.6 -Stable tag: 2.11.2 +Stable tag: 2.11.3 License: GNU General Public License v3.0 or later The WordPress gallery plugin that's highly customizable & you can use to impress your clients. Create beautiful image galleries in minutes. @@ -158,6 +158,11 @@ Free support is included only with a PRO license: [Buy Modula PRO](https://wp-mo 4. Responsive galleries created with Modula == Changelog == += 2.11.3 - 27.11.2024 = +Fixed: Notification action URL encoding +Fixed: PHP Warning +Fixed: Gallery item has data-width and data-height on non-required gallery types + = 2.11.2 - 20.11.2024 = Added: Increased functionality for sanitization of gallery settings.