Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into fix/TMZ-212
Browse files Browse the repository at this point in the history
  • Loading branch information
nuritsha committed Dec 4, 2024
2 parents 9c2e259 + b12d9ab commit 4a1fd89
Show file tree
Hide file tree
Showing 27 changed files with 310 additions and 269 deletions.
4 changes: 2 additions & 2 deletions hello-plus.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Description: Puts the PLUS in Elementor's Hello+ themes
* Plugin URI: https://elementor.com
* Author: Elementor.com
* Version: 0.0.5
* Version: 0.0.7
* License: GPL-3
* License URI: https://www.gnu.org/licenses/gpl-3.0.en.html
*
Expand All @@ -29,7 +29,7 @@
exit; // Exit if accessed directly.
}

define( 'HELLOPLUS_VERSION', '0.0.5' );
define( 'HELLOPLUS_VERSION', '0.0.7' );
define( 'HELLO_PLUS_VERSION', HELLOPLUS_VERSION );

define( 'HELLOPLUS__FILE__', __FILE__ );
Expand Down
23 changes: 10 additions & 13 deletions includes/utils.php
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
<?php

namespace HelloPlus\Includes;

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

use Elementor\Utils as ElementorUtils;

/**
* class Utils
**/
class Utils {

private static $elementor_installed = null;
private static ?bool $elementor_installed = null;

private static $elementor_active = null;
private static ?bool $elementor_active = null;

public static function elementor(): \Elementor\Plugin {
return \Elementor\Plugin::$instance;
}

public static function has_pro() {
public static function has_pro(): bool {
return defined( 'ELEMENTOR_PRO_VERSION' );
}

public static function has_hello_biz() {
public static function has_hello_biz(): bool {
return defined( 'EHP_THEME_SLUG' );
}

Expand All @@ -37,23 +34,23 @@ public static function is_elementor_active(): bool {
return self::$elementor_active;
}

public static function is_elementor_installed() {
public static function is_elementor_installed(): bool {
if ( null === self::$elementor_installed ) {
self::$elementor_installed = file_exists( WP_PLUGIN_DIR . '/elementor/elementor.php' );
}

return self::$elementor_installed;
}

public static function get_current_post_id() {
public static function get_current_post_id(): int {
if ( isset( self::elementor()->documents ) && self::elementor()->documents->get_current() ) {
return self::elementor()->documents->get_current()->get_main_id();
}

return get_the_ID();
}

public static function get_client_ip() {
public static function get_client_ip(): string {
$server_ip_keys = [
'HTTP_CLIENT_IP',
'HTTP_X_FORWARDED_FOR',
Expand All @@ -75,7 +72,7 @@ public static function get_client_ip() {
return '127.0.0.1';
}

public static function ends_with( $full_string, $end_string ) {
public static function ends_with( $full_string, $end_string ): bool {
$len = strlen( $end_string );
if ( 0 === $len ) {
return true;
Expand All @@ -92,9 +89,9 @@ public static function get_theme_slug(): string {
return 'hello-plus';
}

public static function is_preview_for_document( $post_id ) {
public static function is_preview_for_document( $post_id ): bool {
$preview_id = filter_input( INPUT_GET, 'preview_id', FILTER_VALIDATE_INT );
$preview = filter_input( INPUT_GET, 'preview', FILTER_UNSAFE_RAW );
$preview = filter_input( INPUT_GET, 'preview', FILTER_SANITIZE_FULL_SPECIAL_CHARS );

return 'true' === $preview && (int) $post_id === (int) $preview_id;
}
Expand Down
3 changes: 2 additions & 1 deletion modules/admin/assets/js/components/dialog/dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import DialogContentText from '@elementor/ui/DialogContentText';
import DialogHeader from '@elementor/ui/DialogHeader';
import DialogTitle from '@elementor/ui/DialogTitle';
import Button from '@elementor/ui/Button';
import Typography from '@elementor/ui/Typography';
import { __ } from '@wordpress/i18n';

export const DialogModal = (
Expand All @@ -27,7 +28,7 @@ export const DialogModal = (
sx={ { zIndex: 100001 } }
>
<DialogHeader onClose={ () => onClose() }>
<DialogTitle>{ title }</DialogTitle>
<DialogTitle><Typography sx={ { color: 'text.secondary' } }>{ title }</Typography></DialogTitle>
</DialogHeader>

<DialogContent >
Expand Down
9 changes: 7 additions & 2 deletions modules/admin/assets/js/components/onboarding/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { __ } from '@wordpress/i18n';
import Step from '@elementor/ui/Step';
import StepLabel from '@elementor/ui/StepLabel';
import Stepper from '@elementor/ui/Stepper';
import Typography from '@elementor/ui/Typography';
import { useAdminContext } from '../../hooks/use-admin-context';

export const Navigation = () => {
Expand All @@ -15,8 +16,12 @@ export const Navigation = () => {
<Stepper activeStep={ step }>
{ steps.map( ( label, index ) => {
return (
<Step key={ label } completed={ index < step } active={ index === step } >
<StepLabel >{ label }</StepLabel>
<Step key={ label } completed={ index < step } active={ index === step }>
<StepLabel>
<Typography>
{ label }
</Typography>
</StepLabel>
</Step>
);
} ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const GetStarted = ( { message, buttonText, onClick, severity, allowTrack
<Stack sx={ { maxWidth: 662 } } alignItems="center" justifyContent="center" gap={ 4 }>
<Navigation />
<Stack alignItems="center" justifyContent="center" gap={ 4 }>
<Typography variant="h4" align="center" px={ 2 }>
<Typography variant="h4" align="center" px={ 2 } sx={ { color: 'text.primary' } }>
{ __( 'Welcome! Let’s create your website.', 'hello-plus' ) }
</Typography>
<Typography variant="body1" align="center" px={ 2 } color="text.secondary">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const InstallKit = ( { message, kits = [], setPreviewKit, severity } ) =>
<Stack sx={ { maxWidth: 900 } } alignItems="center" justifyContent="center" gap={ 4 }>
<Navigation />
<Stack alignItems="center" justifyContent="center" gap={ 4 }>
<Typography variant="h4" align="center" px={ 2 }>
<Typography variant="h4" align="center" px={ 2 } sx={ { color: 'text.primary' } }>
{ __( 'Choose your website template kit', 'hello-plus' ) }
</Typography>
<Typography variant="body1" align="center" px={ 2 } color="text.secondary">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ export const Overview = ( { title, description, setIsLoading, setPreviewUrl, set
borderRight: '1px solid rgba(0, 0, 0, 0.12)',
} }
>
<Typography variant="h6">{ title }</Typography>
<Typography variant="h6" sx={ { color: 'text.primary' } }>{ title }</Typography>
<Image
src={ kit.thumbnail }
alt={ kit.title }
sx={ { borderRadius: 1, width: '100%', height: 'auto', mb: 3 } }
/>
<Typography variant="body1">{ description }</Typography>
<Typography variant="body1" sx={ { color: 'text.secondary' } }>{ description }</Typography>
</Stack>
<Box
sx={ {
Expand All @@ -35,7 +35,7 @@ export const Overview = ( { title, description, setIsLoading, setPreviewUrl, set
>
{ pages.length && (
<>
<Typography variant="h6" sx={ { mb: 2 } }>{ __( 'Pages', 'hello-plus' ) }</Typography>
<Typography variant="h6" sx={ { mb: 2, color: 'text.primary' } }>{ __( 'Pages', 'hello-plus' ) }</Typography>
<Grid container rowSpacing={ 3 } columnSpacing={ 5 }>
{ pages.map( ( [ id, data ] ) => (
<Grid key={ id } item xs={ 12 } sm={ 6 } md={ 2 }>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const ReadyToGo = ( { modalCloseRedirectUrl } ) => {
<Stack sx={ { maxWidth: 662 } } alignItems="center" justifyContent="center" gap={ 4 }>
<Navigation />
<Stack alignItems="center" justifyContent="center" gap={ 4 }>
<Typography variant="h4" align="center" px={ 2 }>
<Typography variant="h4" align="center" px={ 2 } sx={ { color: 'text.primary' } }>
{ __( 'Congratulations, you’ve created your website!', 'hello-plus' ) }
</Typography>
<Typography variant="body1" align="center" px={ 2 } color="text.secondary">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { __ } from '@wordpress/i18n';
export const PreviewWithImage = ( { title, thumbnail, onClick } ) => {
return (
<Stack direction="column" >
<Typography variant="body2" sx={ { height: 45 } }>{ title }</Typography>
<Typography variant="body2" sx={ { height: 45, color: 'text.secondary' } }>{ title }</Typography>
<Box sx={ {
position: 'relative',
cursor: 'pointer',
Expand Down Expand Up @@ -48,7 +48,7 @@ export const PreviewWithImage = ( { title, thumbnail, onClick } ) => {
onClick={ onClick }
>
<EyeIcon sx={ { mr: 1 } } />
<Typography variant="body2">{ __( 'View Demo', 'hello-plus' ) }</Typography>
<Typography variant="body2" sx={ { color: 'text.primary' } }>{ __( 'View Demo', 'hello-plus' ) }</Typography>
</Box>
</Box>
</Stack>
Expand Down
4 changes: 2 additions & 2 deletions modules/admin/assets/js/components/top-bar/top-bar-content.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ export const TopBarContent = ( { sx = {}, iconSize = 'medium', onClose } ) => {
<SvgIcon fontSize={ iconSize } color="secondary">
<ElementorNoticeIcon />
</SvgIcon>
<Typography variant="subtitle1">{ __( 'Hello+', 'hello-plus' ) }</Typography>
<Typography variant="subtitle1" sx={ { color: 'text.primary' } }>{ __( 'Hello+', 'hello-plus' ) }</Typography>
</Stack>
{ onClose && ( <XIcon onClick={ onClose } sx={ { cursor: 'pointer' } } /> ) }
{ onClose && ( <XIcon onClick={ onClose } sx={ { cursor: 'pointer', color: 'text.primary' } } /> ) }
</Stack>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const TobBarPreview = ( { onClickBack, onClickLeftButton, onClickRightBut
onClick={ onClickBack }
>
<ChevronRightIcon sx={ { transform: 'rotate(180deg)' } } color="action" />
<Typography variant="subtitle1" color="action">{ __( 'Back to Wizard', 'hello-plus' ) }</Typography>
<Typography variant="subtitle1" color="action" sx={ { color: 'text.secondary' } }>{ __( 'Back to Wizard', 'hello-plus' ) }</Typography>
</Stack>
<Stack direction="row" gap={ 1 }>
<Button variant="outlined" color="secondary" onClick={ onClickLeftButton }>
Expand Down
23 changes: 11 additions & 12 deletions modules/admin/assets/js/pages/onboarding-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,6 @@ import { InstallKit } from '../components/onboarding/screens/install-kit';
import { ReadyToGo } from '../components/onboarding/screens/ready-to-go';
import { Preview } from '../components/onboarding/screens/preview';

const style = {
position: 'fixed',
top: 0,
left: 0,
width: '100%',
height: '100%',
background: 'white',
boxShadow: 24,
p: 4,
};

export const OnboardingPage = () => {
const [ message, setMessage ] = useState( '' );
const [ severity, setSeverity ] = useState( 'info' );
Expand Down Expand Up @@ -94,7 +83,17 @@ export const OnboardingPage = () => {
return (
<ThemeProvider colorScheme="auto">
<Modal open sx={ { zIndex: 100000 } } >
<Box style={ { ...style, display: 'flex', flexDirection: 'column', py: 4 } }>
<Box sx={ {
backgroundColor: 'background.default',
position: 'fixed',
top: 0,
left: 0,
width: '100%',
height: '100%',
boxShadow: 24,
display: 'flex',
flexDirection: 'column',
} }>
{ ! previewKit && ( <TopBarContent onClose={ onClose } sx={ { borderBottom: '1px solid var(--divider-divider, rgba(0, 0, 0, 0.12))', mb: 4 } } iconSize="small" /> ) }
{ 0 === step && ! isLoading && ! previewKit && (
<GetStarted allowTracking={ allowTracking } setAllowTracking={ setAllowTracking } severity={ severity } message={ message } buttonText={ buttonText } onClick={ onClick } />
Expand Down
14 changes: 13 additions & 1 deletion modules/admin/classes/ajax/setup-wizard.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function __construct() {
public function ajax_setup_wizard() {
check_ajax_referer( 'updates', 'nonce' );

$step = filter_input( INPUT_POST, 'step', FILTER_UNSAFE_RAW );
$step = filter_input( INPUT_POST, 'step', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
$allow_tracking = filter_input( INPUT_POST, 'allowTracking', FILTER_VALIDATE_BOOLEAN );

if ( $allow_tracking ) {
Expand All @@ -26,6 +26,18 @@ public function ajax_setup_wizard() {
delete_option( 'elementor_allow_tracking' );
}

$campaign_data = [
'source' => 'ecore-ehp-install',
'campaign' => 'ec-plg',
'medium' => 'wp-dash',
];

set_transient(
'elementor_core_campaign',
$campaign_data,
30 * DAY_IN_SECONDS
);

switch ( $step ) {
case 'install-elementor':
$step = new Install_Elementor();
Expand Down
6 changes: 3 additions & 3 deletions modules/forms/classes/form-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ public function make_select_field( $item, $i ) {
foreach ( $options as $key => $option ) {
$option_id = esc_attr( $item['custom_id'] . $key );
$option_value = esc_attr( $option );
$option_label = esc_html( $option );
$option_label = $option;

if ( false !== strpos( $option, '|' ) ) {
list( $label, $value ) = explode( '|', $option );
$option_value = esc_attr( $value );
$option_label = esc_html( $label );
$option_label = $label;
}

$this->add_render_attribute( $option_id, 'value', $option_value );
Expand All @@ -141,7 +141,7 @@ public function make_select_field( $item, $i ) {
} ?>
<option <?php $this->print_render_attribute_string( $option_id ); ?>><?php
// PHPCS - $option_label is already escaped
echo $option_label; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></option>
echo esc_html( $option_label ); ?></option>
<?php } ?>
</select>
</div>
Expand Down
4 changes: 2 additions & 2 deletions modules/forms/classes/form-record.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,15 @@ public function get_form_meta( $meta_keys = [] ) {
break;

case 'page_title':
$referrer_title = filter_input( INPUT_POST, 'referer_title', FILTER_SANITIZE_STRING );
$referrer_title = filter_input( INPUT_POST, 'referer_title', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
$result['page_title'] = [
'title' => esc_html__( 'Page Title', 'hello-plus' ),
'value' => $referrer_title ? sanitize_text_field( wp_unslash( $referrer_title ) ) : '',
];
break;

case 'user_agent':
$user_agent = filter_input( INPUT_SERVER, 'HTTP_USER_AGENT', FILTER_SANITIZE_STRING );
$user_agent = filter_input( INPUT_SERVER, 'HTTP_USER_AGENT', FILTER_SANITIZE_FULL_SPECIAL_CHARS );
$result['user_agent'] = [
'title' => esc_html__( 'User Agent', 'hello-plus' ),
'value' => $user_agent ? sanitize_textarea_field( wp_unslash( $user_agent ) ) : '',
Expand Down
Loading

0 comments on commit 4a1fd89

Please sign in to comment.