Skip to content

Commit

Permalink
Merge branch 'main' into tweak/ED-9706
Browse files Browse the repository at this point in the history
  • Loading branch information
nuritsha authored Aug 4, 2024
2 parents 96e8186 + 48ebf10 commit 6c85d33
Show file tree
Hide file tree
Showing 57 changed files with 2,281 additions and 128 deletions.
2 changes: 1 addition & 1 deletion .github/scripts/run-lighthouse-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ for TEMPLATE_FILE_NAME in $TEMPLATES_FILE_NAMES
do
TEMPLATE_NAME=$(basename "$TEMPLATE_FILE_NAME" .json)
export TEMPLATE_NAME=${TEMPLATE_NAME}
npx lhci collect --url="http://localhost:8888/${TEMPLATE_NAME}/"
npx lhci collect --url="http://localhost:8889/${TEMPLATE_NAME}/"
npx lhci assert
set_max_exit
npx lhci upload --outputDir="${GITHUB_WORKSPACE}/.lighthouseci/reports/${TEMPLATE_NAME}/"
Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/save-lighthouse-pages-html-dumps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ mkdir -p .lighthouseci/dumps
for TEMPLATE_FILE_NAME in $TEMPLATES_FILE_NAMES
do
TEMPLATE_NAME=$(basename "$TEMPLATE_FILE_NAME" .json)
wget --directory-prefix=.lighthouseci/dumps/${TEMPLATE_NAME} --mirror --convert-links --adjust-extension --page-requisites --no-parent --no-host-directories --restrict-file-names=windows http://localhost:8888/${TEMPLATE_NAME}/
wget --directory-prefix=.lighthouseci/dumps/${TEMPLATE_NAME} --mirror --convert-links --adjust-extension --page-requisites --no-parent --no-host-directories --restrict-file-names=windows http://localhost:8889/${TEMPLATE_NAME}/
done
76 changes: 35 additions & 41 deletions .github/workflows/lighthouse.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,83 +11,76 @@ concurrency:

jobs:
build-plugin-lh:
name: Build plugin
uses: ./.github/workflows/build.yml

lighthouse_test:
name: Lighthouse test - WP ${{ matrix.wpCoreVersion }} on PHP ${{ matrix.phpVersion }}
name: Lighthouse test - WP latest on PHP 7.4
runs-on: ubuntu-latest
needs: [build-plugin-lh]
if: ${{ github.event.pull_request.title == null || needs.build-plugin-lh.outputs.changelog_diff }}
strategy:
matrix:
include:
- phpVersion: '8.0'
wpCoreVersion: 'master'
- phpVersion: '7.4'
wpCoreVersion: 'latest'
steps:
- name: Checkout source code
if: matrix.wpCoreVersion != 'master'
uses: actions/checkout@v4

- name: Install Node.js 20.x
if: matrix.wpCoreVersion != 'master'
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: 'npm'

- name: Download build artifact
uses: actions/download-artifact@v4
with:
name: ${{ needs.build-plugin-lh.outputs.artifact_name }}
path: ./build
- name: Install node modules
if: matrix.wpCoreVersion != 'master'
run: npm ci
- name: Run wp-env
if: matrix.wpCoreVersion != 'master'
run: |
npm run start-local-server
npm run test:setup:playwright
path: ./elementor

- name: Setup wp-env
uses: elementor/elementor-editor-github-actions/actions/setup-wp-env@master
with:
php: '7.4'
active-theme: 'hello-elementor'
plugins: |-
./elementor
themes: |-
https://downloads.wordpress.org/theme/hello-elementor.zip
mappings: |-
elementor-templates:./tests/playwright/templates
- name: Import Templates
uses: elementor/elementor-editor-github-actions/actions/setup-elementor-env@master
with:
env: 'testing'
templates: |-
elementor-templates
- name: Install lhci
if: matrix.wpCoreVersion != 'master'
run: |
npm ci
npm install --no-package-lock --no-save @lhci/[email protected]
- name: WordPress debug information
if: matrix.wpCoreVersion != 'master'
run: |
npx wp-env run cli wp core version
npx wp-env run cli wp --info
run: npm install --no-package-lock --no-save @lhci/[email protected]

- name: Run Lighthouse tests
if: matrix.wpCoreVersion != 'master'
run: |
bash "${GITHUB_WORKSPACE}/.github/scripts/run-lighthouse-tests.sh"
- name: Save HTML dumps on failure
if: failure() || matrix.wpCoreVersion != 'master'
if: failure()
run: |
bash "${GITHUB_WORKSPACE}/.github/scripts/save-lighthouse-pages-html-dumps.sh"
- name: Upload Lighthouse reports on failure
if: failure() || matrix.wpCoreVersion != 'master'
if: failure()
uses: actions/upload-artifact@v3
with:
name: lighthouseci-reports
path: ${{ github.workspace }}/.lighthouseci/reports/**/*
retention-days: 7

- name: Upload Lighthouse HTML dumps on failure
if: failure() || matrix.wpCoreVersion != 'master'
if: failure()
uses: actions/upload-artifact@v3
with:
name: lighthouseci-htmls
path: ${{ github.workspace }}/.lighthouseci/dumps/**/*
retention-days: 7
- name: Notify slack on failure
if: failure() && github.event_name == 'schedule'
env:
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
SLACK_CHANNEL: ${{ secrets.SLACK_LIGHTHOUSE_CHANNEL }}
SLACK_BOT_NAME: ElementorBot
run: |
MESSAGE_TEXT="@channel Repo: *$GITHUB_REPOSITORY* Workflow: *$GITHUB_WORKFLOW* is FAILED - <$GITHUB_SERVER_URL/$GITHUB_REPOSITORY/actions/runs/$GITHUB_RUN_ID|link>"
curl -X POST "https://slack.com/api/chat.postMessage" -d "username=${SLACK_BOT_NAME}&token=${SLACK_TOKEN}&channel=${SLACK_CHANNEL}&text=${MESSAGE_TEXT}&link_names=true"

lighthouse:
needs: lighthouse_test
Expand All @@ -97,6 +90,7 @@ jobs:
steps:
- name: Test status
run: echo "Test status is - ${{ needs.lighthouse_test.result }}"

- name: Check lighthouse_test matrix status
if: ${{ needs.lighthouse_test.result != 'success' && needs.lighthouse_test.result != 'skipped' }}
run: exit 1
1 change: 1 addition & 0 deletions .grunt-config/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ const entry = {
'nested-tabs': path.resolve( __dirname, '../modules/nested-tabs/assets/js/editor/index.js' ),
'nested-accordion': path.resolve( __dirname, '../modules/nested-accordion/assets/js/editor/index.js' ),
'container-converter': path.resolve( __dirname, '../modules/container-converter/assets/js/editor/module.js' ),
'atomic-widgets-editor': path.resolve( __dirname, '../modules/atomic-widgets/assets/js/editor/module.js' ),
'notes': path.resolve( __dirname, '../modules/notes/assets/js/notes.js' ),
'web-cli': path.resolve( __dirname, '../modules/web-cli/assets/js/index.js' ),
'import-export-admin': path.resolve( __dirname, '../app/modules/import-export/assets/js/admin.js' ),
Expand Down
Binary file added .wporg-assets/banner-1544x500.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed .wporg-assets/banner-1544x500.png
Binary file not shown.
Binary file added .wporg-assets/banner-772x250.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed .wporg-assets/banner-772x250.png
Binary file not shown.
10 changes: 10 additions & 0 deletions core/base/providers/social-network-provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ public static function get_name_mapping( string $platform ): string {
return '';
}

public static function get_text_mapping( string $platform ): string {
static::init_social_networks_array_if_empty();

if ( isset( self::$social_networks[ $platform ]['text'] ) ) {
return self::$social_networks[ $platform ]['text'];
}

return '';
}

public static function get_social_networks_text( $providers = [] ): array {
static::init_social_networks_array_if_empty();

Expand Down
2 changes: 1 addition & 1 deletion core/common/modules/connect/apps/base-app.php
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ protected function http_request( $method, $endpoint, $args = [], $options = [] )
$args
);

if ( is_wp_error( $response ) ) {
if ( is_wp_error( $response ) && empty( $options['with_error_data'] ) ) {
// PHPCS - the variable $response does not contain a user input value.
wp_die( $response, [ 'back_link' => true ] ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
Expand Down
10 changes: 10 additions & 0 deletions core/common/modules/finder/categories/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,21 @@ public function get_category_items( array $options = [] ) {
'url' => ElementorSettings::get_settings_tab_url( 'general' ),
'keywords' => [ 'general', 'settings', 'elementor' ],
],
'integrations' => [
'title' => esc_html__( 'Integrations', 'elementor' ),
'url' => ElementorSettings::get_settings_tab_url( 'integrations' ),
'keywords' => [ 'integrations', 'settings', 'elementor' ],
],
'advanced' => [
'title' => esc_html__( 'Advanced', 'elementor' ),
'url' => ElementorSettings::get_settings_tab_url( 'advanced' ),
'keywords' => [ 'advanced', 'settings', 'elementor' ],
],
'performance' => [
'title' => esc_html__( 'Performance', 'elementor' ),
'url' => ElementorSettings::get_settings_tab_url( 'performance' ),
'keywords' => [ 'performance', 'settings', 'elementor' ],
],
'experiments' => [
'title' => esc_html__( 'Experiments', 'elementor' ),
'url' => ElementorSettings::get_settings_tab_url( 'experiments' ),
Expand Down
2 changes: 1 addition & 1 deletion core/kits/documents/tabs/tab-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ protected function add_default_globals_notice() {
'content' => sprintf(
/* translators: 1: Link open tag, 2: Link close tag. */
esc_html__( 'In order for Theme Style to affect all relevant Elementor elements, please disable Default Colors and Fonts from the %1$sSettings Page%2$s.', 'elementor' ),
'<a href="' . esc_url( Settings::get_url() ) . '" target="_blank">',
'<a href="' . Settings::get_settings_tab_url( 'general' ) . '" target="_blank">',
'</a>'
),
'render_type' => 'ui',
Expand Down
20 changes: 19 additions & 1 deletion includes/base/element-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ protected function should_render_shortcode() {

$is_dynamic_content = apply_filters( 'elementor/element/is_dynamic_content', false, $raw_data, $this );

$has_dynamic_tag = ! empty( $raw_data['settings']['__dynamic__'] );
$has_dynamic_tag = $this->has_element_dynamic_tag( $raw_data['settings'] );

if ( $is_dynamic_content || $has_dynamic_tag ) {
return true;
Expand All @@ -572,6 +572,24 @@ protected function should_render_shortcode() {
return false;
}

private function has_element_dynamic_tag( $element_settings ): bool {
if ( is_array( $element_settings ) ) {
if ( ! empty( $element_settings['__dynamic__'] ) ) {
return true;
}

foreach ( $element_settings as $value ) {
$has_dynamic = $this->has_element_dynamic_tag( $value );

if ( $has_dynamic ) {
return true;
}
}
}

return false;
}

/**
* Get the element raw data.
*
Expand Down
18 changes: 18 additions & 0 deletions includes/base/widget-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -1225,6 +1225,24 @@ private function get_widget_css() {

}

/**
* Widgets styles loading strategy.
*
* Which loading strategy to apply, either loading the widgets styles
* in the `<head>` or in the `<body>`.
*
* Currently, it's based on the optimized CSS loading experiment. In
* the future, will be replaced with a setting in the performance tab.
*
* @since 3.23.4
* @access public
*
* @return bool Whether to load widgets styles in the `<head>`.
*/
public function load_widgets_styles_in_head(): bool {
return ! $this->is_inline_css_mode();
}

private function is_inline_css_mode() {
static $is_active;

Expand Down
16 changes: 15 additions & 1 deletion includes/settings/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,13 @@ protected function create_tabs() {
'label' => esc_html__( 'General', 'elementor' ),
'sections' => [
'general' => [
'label' => esc_html__( 'General', 'elementor' ),
'callback' => function() {
printf(
'<p>%s</p><br><hr><br>',
esc_html__( 'Tailor how Elementor enhances your site, from post types to other functions.', 'elementor' )
);
},
'fields' => [
self::UPDATE_TIME_FIELD => [
'full_field_id' => self::UPDATE_TIME_FIELD,
Expand Down Expand Up @@ -322,6 +329,13 @@ protected function create_tabs() {
'label' => esc_html__( 'Advanced', 'elementor' ),
'sections' => [
'advanced' => [
'label' => esc_html__( 'Advanced', 'elementor' ),
'callback' => function() {
printf(
'<p>%s</p><br><hr><br>',
esc_html__( 'Personalize the way Elementor works on your website by choosing the advanced features and how they operate.', 'elementor' )
);
},
'fields' => [
'editor_break_lines' => [
'label' => esc_html__( 'Switch Editor Loader Method', 'elementor' ),
Expand Down Expand Up @@ -390,7 +404,7 @@ protected function create_tabs() {
'callback' => function() {
printf(
'<p>%s</p><br><hr><br>',
esc_html__( 'Improve loading times on your site by selecting the optimization tools that best fit your requirements. ', 'elementor' )
esc_html__( 'Improve loading times on your site by selecting the optimization tools that best fit your requirements.', 'elementor' )
);
},
'fields' => [
Expand Down
2 changes: 2 additions & 0 deletions modules/ai/assets/js/editor/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export const getUserInformation = ( immediately ) => request( 'ai_get_user_infor

export const getRemoteConfig = () => request( 'ai_get_remote_config' );

export const getRemoteFrontendConfig = ( payload, immediately ) => request( 'ai_get_remote_frontend_config', { payload }, immediately );

export const getCompletionText = ( payload ) => request( 'ai_get_completion_text', { payload } );

export const getExcerpt = ( payload ) => request( 'ai_get_excerpt', { payload } );
Expand Down
33 changes: 33 additions & 0 deletions modules/ai/assets/js/editor/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,39 @@ import ReactUtils from 'elementor-utils/react';
import LayoutAppWrapper from './layout-app-wrapper';
import { AiGetStartedConnect } from './ai-get-started-connect';
import { getUiConfig } from './utils/editor-integration';
import { getRemoteFrontendConfig } from './api';
import { getUniqueId } from './context/requests-ids';

setTimeout( async () => {
if ( '1' !== window.ElementorAiConfig?.is_get_started ) {
return;
}

window.EDITOR_SESSION_ID = window.EDITOR_SESSION_ID || getUniqueId( 'elementor-editor-session' );

try {
const config = await getRemoteFrontendConfig( {
client_name: 'elementor-editor-loading',
client_version: elementorCommon.config.version,
client_session_id: window.EDITOR_SESSION_ID,
},
true,
);

window.ElementorAIRemoteConfigData = config;

if ( config?.remoteIntegrationUrl ) {
// Add a script tag to the head of the document
const script = document.createElement( 'script' );
script.type = 'module';
script.src = config.remoteIntegrationUrl;
document.head.appendChild( script );
}
} catch ( e ) {
// eslint-disable-next-line no-console
console.error( 'Elementor AI Integration Loader', e );
}
}, 0 );

export default class Module extends elementorModules.editor.utils.Module {
onElementorInit() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const StyledDialog = styled( PromptDialog )( () => ( {
},
'& .MuiPaper-root': {
margin: 0,
maxHeight: '55vh',
maxHeight: '80vh',
},
} ) );

Expand Down
3 changes: 2 additions & 1 deletion modules/ai/assets/js/gutenberg/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import GenerateFeaturedImageWithAI from './featured-image';
import { GenerateTextWithAi } from './text-with-ai';
import React from 'react';
import { EditTextWithAi } from './edit-text-with-ai';
import { getUniqueId } from '../editor/context/requests-ids';

( function() {
'use strict';

window.EDITOR_SESSION_ID = getUniqueId( 'wp-gutenberg-session' );
// Wait for the Gutenberg editor to initialize
wp.domReady( () => {
// Define a function to add the custom link to the excerpt panel
Expand Down
2 changes: 2 additions & 0 deletions modules/ai/assets/js/media-library/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import AIMediaGenerateAppWrapper from './generate';
import { createRoot } from '@wordpress/element';
import AIMediaEditAppButtonWrapper from './edit-button';
import AIMediaEditAppLinkWrapper from './edit-link';
import { getUniqueId } from '../editor/context/requests-ids';

const isMediaLibrary = () => window.location.href.includes( '/upload.php' );

Expand Down Expand Up @@ -41,6 +42,7 @@ const addEventListener = ( eventName, containerId, Component ) => {

( function() {
if ( isMediaLibrary() ) {
window.EDITOR_SESSION_ID = getUniqueId( 'wp-media-lib-session' );
const mediaLibrary = document.querySelector( '.page-title-action' );

if ( mediaLibrary ) {
Expand Down
Loading

0 comments on commit 6c85d33

Please sign in to comment.