Skip to content

Commit

Permalink
Merge pull request #3 from eduardovillao/dev-v1.3
Browse files Browse the repository at this point in the history
v1.3
  • Loading branch information
eduardovillao authored Oct 17, 2023
2 parents bb5648f + 16d3674 commit 9099eeb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ Please, send to me: [[email protected]](mailto:[email protected])

## Changelog
```
= 1.3 =
Fix: do not workin on the latest versions of Elementor.
Changed: Compatibility with WordPress 6.3.
= 1.2.4 =
Changed: Compatibility with WordPress 6.2.
Expand Down
23 changes: 12 additions & 11 deletions add-class-to-elementor-image.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Description: Simple plugin to add custom CSS class to Elementor image.
* Author: EduardoVillao.me
* Author URI: https://eduardovillao.me/
* Version: 1.2.4
* Version: 1.3
* Requires at least: 5.4
* Requires PHP: 7.0
* Text Domain: add-class-to-elementor-image
Expand All @@ -29,7 +29,7 @@
*/

if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
exit;
}

/**
Expand Down Expand Up @@ -82,7 +82,7 @@ public static function instance() {
*/
public function __clone() {
// Cloning instances of the class is forbidden.
_doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'add-class-to-elementor-image' ), '1.2.4' );
_doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'add-class-to-elementor-image' ), '1.3' );
}

/**
Expand All @@ -93,7 +93,7 @@ public function __clone() {
*/
public function __wakeup() {
// Unserializing instances of the class is forbidden.
_doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'add-class-to-elementor-image' ), '1.2.4' );
_doing_it_wrong( __FUNCTION__, esc_html__( 'Something went wrong.', 'add-class-to-elementor-image' ), '1.3' );
}

/**
Expand Down Expand Up @@ -180,15 +180,16 @@ public function add_class_control( $image, $args) {
* @access public
*/
public function add_custom_class( $html, $settings, $image_size_key, $image_key ) {

if( isset( $settings['cei_image_custom_class'] ) && ! empty( $settings['cei_image_custom_class'] ) ) {

return preg_replace( '/class="(.*)"/', 'class="' . $settings['cei_image_custom_class'] . ' \1"', $html );
}
else {

if( ! isset( $settings['cei_image_custom_class'] ) && empty( $settings['cei_image_custom_class'] ) ) {
return $html;
}

$attrClass = strpos( $html, "class=" );
if ( $attrClass ) {
return preg_replace( '/class="(.*)"/', 'class="' . $settings['cei_image_custom_class'] . ' \1"', $html );
} else {
return preg_replace( '/src="(.*)"/', 'class="' . $settings['cei_image_custom_class'] . '" src="\1"', $html );
}
}
}

Expand Down
8 changes: 6 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ Contributors: EVCODE
Donate link: https://eduardovillao.me/
Tags: elementor, custom class, elementor pro, image class, lazy load
Requires at least: 5.4
Tested up to: 6.2
Stable tag: 1.2.4
Tested up to: 6.3
Stable tag: 1.3
Requires PHP: 7.0
License: GPLv2License
URI:https://www.gnu.org/licenses/gpl-2.0.html
Expand Down Expand Up @@ -43,6 +43,10 @@ Please, send to me: [[email protected]](mailto:[email protected])

== Changelog ==

= 1.3 =
Fix: do not workin on the latest versions of Elementor.
Changed: Compatibility with WordPress 6.3.

= 1.2.4 =
Changed: Compatibility with WordPress 6.2.

Expand Down

0 comments on commit 9099eeb

Please sign in to comment.