Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ assets/js/
**/*.min.js
**/node_modules/**
**/vendor/**
**/vendor_prefixed/**
build/**
packages/**/*
tests/qunit/setup/tinymce.js
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ on:
pull_request:
workflow_call:
outputs:
artifact_name:
artifact_name:
value: ${{ jobs.build-plugin.outputs.artifact_name }}
changelog_diff:
changelog_diff:
value: ${{ jobs.build-plugin.outputs.changelog_diff }}
push:
branches:
Expand Down Expand Up @@ -60,6 +60,9 @@ jobs:
| tr -d '[[:space:]]')
export PLUGIN_FOLDER_FILENAME="elementor-${PACKAGE_VERSION}-${PLUGIN_VERSION}"
export PLUGIN_ZIP_FILENAME="${PLUGIN_FOLDER_FILENAME}.zip"
composer install --optimize-autoloader --prefer-dist
composer install --no-scripts --no-dev
composer dump-autoload
npx grunt build
sed -i -E "s/Version: (.*?)/Version: ${PACKAGE_VERSION}-${PLUGIN_VERSION}/g" build/elementor.php
sed -i -E "s/ELEMENTOR_VERSION', '(.*?)'/ELEMENTOR_VERSION', '${PACKAGE_VERSION}-${PLUGIN_VERSION}'/g" build/elementor.php
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:
run: |
export PATH=$HOME/.composer/vendor/bin:$PATH
php -v
php vendor/bin/parallel-lint --blame --exclude node_modules --exclude vendor .
php vendor/bin/parallel-lint --blame --exclude node_modules --exclude vendor --exclude vendor_prefixed .
- name: Setup PHP 8.0 # not included in ubuntu 22.04
uses: shivammathur/setup-php@v2
with:
Expand All @@ -100,7 +100,7 @@ jobs:
run: |
export PATH=$HOME/.composer/vendor/bin:$PATH
php -v
php vendor/bin/parallel-lint --blame --exclude node_modules --exclude vendor .
php vendor/bin/parallel-lint --blame --exclude node_modules --exclude vendor --exclude vendor_prefixed .
- name: Setup PHP 8.1 # not included in ubuntu 22.04
uses: shivammathur/setup-php@v2
with:
Expand All @@ -109,4 +109,4 @@ jobs:
run: |
export PATH=$HOME/.composer/vendor/bin:$PATH
php -v
php vendor/bin/parallel-lint --blame --exclude node_modules --exclude vendor .
php vendor/bin/parallel-lint --blame --exclude node_modules --exclude vendor --exclude vendor_prefixed .
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ node_modules/
.sass-cache/
log/
vendor/
/vendor_prefixed
local-site/
tmp/

Expand Down Expand Up @@ -40,3 +41,4 @@ tests/playwright/blob-report
**/allure-results
playwright-test-results
**/.env

3 changes: 3 additions & 0 deletions .grunt-config/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,15 @@ const getBuildFiles = [
'!test-results/',
'!tmp/**',
'!vendor/**',
'!php-scoper/**',
'!yarn.lock',
'!*~',
'!commitlint.config.js',

// Conflict with above rule.
'core/files/assets/**',
'vendor/autoload.php',
'vendor/composer/**',
];
/**
* @type {{main: {src: string[], expand: boolean, dest: string}, secondary: {src: string[], expand: boolean, dest: string}}}
Expand Down
16 changes: 16 additions & 0 deletions assets/dev/js/admin/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,22 @@ import FloatingButtonsHandler from 'elementor/modules/floating-buttons/assets/js
} );
} );

$( '.e-notice--cta.e-notice--dismissible[data-notice_id="plugin_image_optimization"] a.e-button--cta' ).on( 'click', function() {
elementorCommon.ajax.addRequest( 'elementor_image_optimization_campaign', {
data: {
source: 'io-wp-media-library-install',
},
} );
} );

$( '.e-a-apps .e-a-item[data-plugin="image-optimization/image-optimization.php"] a.e-btn' ).on( 'click', function() {
elementorCommon.ajax.addRequest( 'elementor_image_optimization_campaign', {
data: {
source: 'io-esetting-addons-install',
},
} );
} );

$( '#elementor-clear-cache-button' ).on( 'click', function( event ) {
event.preventDefault();
var $thisButton = $( this );
Expand Down
1 change: 1 addition & 0 deletions assets/dev/js/admin/hints/media.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
dismissId: event.target.closest( '.e-hint__container' ).dataset.event,
},
} );

this.hideHint( event );
},

Expand Down
7 changes: 7 additions & 0 deletions assets/dev/js/editor/controls/gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,13 @@ ControlMediaItemView = ControlBaseDataView.extend( {
if ( actionURL ) {
window.open( actionURL, '_blank' );
}

elementorCommon.ajax.addRequest( 'elementor_image_optimization_campaign', {
data: {
source: 'io-editor-gallery-install',
},
} );

this.hidePromotion();
},

Expand Down
7 changes: 7 additions & 0 deletions assets/dev/js/editor/controls/media.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,13 @@ ControlMediaItemView = ControlMultipleBaseItemView.extend( {
if ( ! eventName ) {
eventName = this.getDismissPromotionEventName();
}

elementorCommon.ajax.addRequest( 'elementor_image_optimization_campaign', {
data: {
source: 'io-editor-image-install',
},
} );

// Prevent opening the same promotion again in current editor session.
elementor.config.user.dismissed_editor_notices.push( eventName );
},
Expand Down
10 changes: 9 additions & 1 deletion assets/dev/js/editor/elements/views/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,14 @@ BaseElementView = BaseContainer.extend( {
getTitleWithAdvancedValues( settings, text ) {
const { attributes, _previousAttributes: previousAttributes } = settings;

if ( this.compareSettings( attributes, previousAttributes, 'fallback' ) ) {
text = text.replace( new RegExp( previousAttributes.fallback ), '' );
}

if ( ! text || attributes.fallback === text ) {
return attributes.fallback || '';
}

if ( this.compareSettings( attributes, previousAttributes, 'before' ) ) {
text = text.replace( previousAttributes.before, '' );
}
Expand All @@ -1167,7 +1175,7 @@ BaseElementView = BaseContainer.extend( {
}

if ( ! text ) {
return settings.fallback || '';
return attributes.fallback || '';
}

const newBefore = this.getNewSettingsValue( attributes, previousAttributes, 'before' ),
Expand Down
8 changes: 7 additions & 1 deletion assets/dev/js/editor/utils/helpers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import ColorPicker from './color-picker';
import DocumentHelper from 'elementor-editor/document/helper-bc';
import ContainerHelper from 'elementor-editor-utils/container-helper';
import DOMPurify from 'dompurify';
import DOMPurify, { isValidAttribute } from 'dompurify';

const allowedHTMLWrapperTags = [
'article',
Expand Down Expand Up @@ -704,4 +704,10 @@ module.exports = {
sanitize( value, options ) {
return DOMPurify.sanitize( value, options );
},

sanitizeUrl( url ) {
const isValidUrl = !! url ? isValidAttribute( 'a', 'href', url ) : false;

return isValidUrl ? url : '';
},
};
34 changes: 27 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
"require": {
"php": ">=7.4"
},
"autoload": {
"classmap": [
"vendor_prefixed/"
]
},
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.1",
"elementor/elementor-editor-testing": "0.0.3",
Expand All @@ -15,15 +20,30 @@
"squizlabs/php_codesniffer": "^3.6",
"wp-coding-standards/wpcs": "^2.3",
"yoast/phpunit-polyfills": "^1.0",
"thor-juhasz/phpunit-coverage-check": "^0.3.0"
"thor-juhasz/phpunit-coverage-check": "^0.3.0",
"humbug/php-scoper": "0.17.5",
"php-di/php-di": "6.4.0"
},
"scripts": {
"lint": "phpcs --standard=ruleset.xml",
"test": "phpunit",
"test:install": "bash ./bin/install-wp-tests-local.sh",
"coverage": "composer run coverage:test && composer run coverage:check",
"coverage:test": "phpdbg -qrr vendor/phpunit/phpunit/phpunit --coverage-clover coverage-report/clover.xml",
"coverage:check": "phpunit-coverage-check -t 65 coverage-report/clover.xml"
"lint": "phpcs --standard=ruleset.xml",
"test": "phpunit",
"test:install": "bash ./bin/install-wp-tests-local.sh",
"coverage": "composer run coverage:test && composer run coverage:check",
"coverage:test": "phpdbg -qrr vendor/phpunit/phpunit/phpunit --coverage-clover coverage-report/clover.xml",
"coverage:check": "phpunit-coverage-check -t 65 coverage-report/clover.xml",
"post-install-cmd": [
"@php -r \"if (!file_exists('vendor_prefixed')) { mkdir('vendor_prefixed', 0755, true); }\"",
"@php ./vendor/bin/php-scoper add-prefix --output-dir=./vendor_prefixed --config=php-scoper/dependency-injection.inc.php --force",
"@php composer dump-autoload"
],
"pre-autoload-dump": [
"@php -r \"if (!file_exists('vendor_prefixed')) { mkdir('vendor_prefixed', 0755, true); }\""
],
"post-update-cmd": [
"@php -r \"if (!file_exists('vendor_prefixed')) { mkdir('vendor_prefixed', 0755, true); }\"",
"@php ./vendor/bin/php-scoper add-prefix --output-dir=./vendor_prefixed --config=php-scoper/dependency-injection.inc.php --force",
"@php composer dump-autoload"
]
},
"config": {
"allow-plugins": {
Expand Down
Loading