Skip to content

Commit

Permalink
Fix phpcs
Browse files Browse the repository at this point in the history
  • Loading branch information
sumaisa-mou committed Sep 24, 2024
1 parent 33cef37 commit cf39061
Show file tree
Hide file tree
Showing 124 changed files with 1,361 additions and 1,405 deletions.
1 change: 0 additions & 1 deletion includes/Admin/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,4 @@ public function redirect_after_activation() {
wp_safe_redirect( admin_url( 'admin.php?page=wemail' ) );
exit;
}

}
32 changes: 16 additions & 16 deletions includes/Admin/Elementor/FormAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ public function run( $record, $ajax_handler ) {
return;
}

$data = [
$data = array(
'source' => 'elementor',
'list_id' => $settings['wemail_list'],
];
);

$field_maps = array_column( $settings['wemail_field_maps'], 'form_field_id', 'wemail_field' );
$raw_fields = $record->get( 'fields' );
Expand Down Expand Up @@ -76,31 +76,31 @@ public function run( $record, $ajax_handler ) {
public function register_settings_section( $widget ) {
$widget->start_controls_section(
'section_wemail',
[
array(
'label' => $this->get_label(),
'condition' => [
'condition' => array(
'submit_actions' => $this->get_name(),
],
]
),
)
);

$widget->add_control(
'wemail_list',
[
array(
'label' => __( 'weMail List ID', 'wemail' ),
'type' => Controls_Manager::TEXT,
]
)
);

$repeater = new Repeater();

$repeater->add_control(
'wemail_field',
[
array(
'label' => __( 'weMail Field', 'wemail' ),
'type' => Controls_Manager::SELECT,
'default' => 'email',
'options' => [
'options' => array(
'address1' => __( 'Address 1', 'wemail' ),
'address2' => __( 'Address 2', 'wemail' ),
'city' => __( 'City', 'wemail' ),
Expand All @@ -115,28 +115,28 @@ public function register_settings_section( $widget ) {
'state' => __( 'State', 'wemail' ),
'timezone' => __( 'Timezone', 'wemail' ),
'zip' => __( 'Zip', 'wemail' ),
],
),
'description' => __( 'Select column of subscriber of weMail', 'wemail' ),
]
)
);

$repeater->add_control(
'form_field_id', [
'form_field_id', array(
'label' => __( 'Form Field ID', 'wemail' ),
'type' => Controls_Manager::TEXT,
'default' => 'email',
'description' => __( 'Form Fields > {Form Field} > Advanced > ID', 'wemail' ),
]
)
);

$widget->add_control(
'wemail_field_maps',
[
array(
'label' => __( 'Map Fields with weMail', 'wemail' ),
'type' => Controls_Manager::REPEATER,
'fields' => $repeater->get_controls(),
'title_field' => '{{{ wemail_field.split(\'_\').map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ") }}}',
]
)
);

$widget->end_controls_section();
Expand Down
2 changes: 1 addition & 1 deletion includes/Admin/FormPreview.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function render_form_component() {
</head>
<body>
<div>
<?php echo sprintf( '<div id="preview-wemail-form" data-form-type="%s"><wemail-form-preview id="%s"/></div>', $form['type'], $this->form_id ); ?>
<?php printf( '<div id="preview-wemail-form" data-form-type="%s"><wemail-form-preview id="%s"/></div>', $form['type'], $this->form_id ); ?>
</div>

<script src="<?php /** phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedScript */ echo get_site_url() . $wp_scripts->registered['jquery-core']->src; ?>"></script>
Expand Down
23 changes: 12 additions & 11 deletions includes/Admin/GutenbergBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
use WeDevs\WeMail\Traits\Singleton;

class GutenbergBlock {
use Singleton, Hooker;
use Singleton;
use Hooker;

public function boot() {
$this->add_action( 'init', 'register' );
Expand All @@ -16,33 +17,33 @@ public function boot() {
public function register() {
$block_meta = require_once WEMAIL_PATH . '/assets/js/block/index.asset.php';

wp_register_style( 'wemail-block-style', WEMAIL_ASSETS . '/css/gutenberg.css', [], WEMAIL_VERSION );
wp_register_style( 'wemail-block-style', WEMAIL_ASSETS . '/css/gutenberg.css', array(), WEMAIL_VERSION );
wp_register_script( 'wemail-block-script', WEMAIL_ASSETS . '/js/block/index.js', $block_meta['dependencies'], $block_meta['version'] );

register_block_type(
'wemail/forms',
[
array(
'editor_script' => 'wemail-block-script',
'editor_style' => 'wemail-block-style',
]
)
);
}

public function export_forms() {
$forms = wemail()->form->get_forms(
[
'type' => [ 'modal', 'inline' ],
'select' => [ 'id', 'name' ],
]
array(
'type' => array( 'modal', 'inline' ),
'select' => array( 'id', 'name' ),
)
);

wp_localize_script(
'wemail-block-script',
'weMailData',
[
'forms' => $forms ? $forms : [],
array(
'forms' => $forms ? $forms : array(),
'siteUrl' => get_site_url(),
]
)
);
}
}
4 changes: 2 additions & 2 deletions includes/Admin/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ public function register_admin_menu() {
*/
$menu_position = apply_filters( 'wemail_main_menu_position', 56 );

$wemail = add_menu_page( __( 'weMail', 'wemail' ), __( 'weMail', 'wemail' ), $capability, 'wemail', [ $this, 'admin_view' ], 'data:image/svg+xml;base64,' . base64_encode( '<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><g fill="none"><path d="M10.002 13.806l-8.393-4.7a.407.407 0 00-.402.006.421.421 0 00-.207.351v7.721C1 18.187 1.799 19 2.784 19h14.432c.473 0 .927-.191 1.261-.532.335-.34.523-.802.523-1.284V9.408a.421.421 0 00-.208-.353.407.407 0 00-.405-.002l-8.385 4.753z"/><path d="M10.035 12l7.752-4.263a.404.404 0 00.071-.664c-1.804-1.545-4.937-4.167-6.61-5.618a1.888 1.888 0 00-2.434-.021c-1.75 1.464-4.84 4.145-6.671 5.694a.404.404 0 00.07.664L10.035 12z"/></g></svg>' ), $menu_position );
$wemail = add_menu_page( __( 'weMail', 'wemail' ), __( 'weMail', 'wemail' ), $capability, 'wemail', array( $this, 'admin_view' ), 'data:image/svg+xml;base64,' . base64_encode( '<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><g fill="none"><path d="M10.002 13.806l-8.393-4.7a.407.407 0 00-.402.006.421.421 0 00-.207.351v7.721C1 18.187 1.799 19 2.784 19h14.432c.473 0 .927-.191 1.261-.532.335-.34.523-.802.523-1.284V9.408a.421.421 0 00-.208-.353.407.407 0 00-.405-.002l-8.385 4.753z"/><path d="M10.035 12l7.752-4.263a.404.404 0 00.071-.664c-1.804-1.545-4.937-4.167-6.61-5.618a1.888 1.888 0 00-2.434-.021c-1.75 1.464-4.84 4.145-6.671 5.694a.404.404 0 00.07.664L10.035 12z"/></g></svg>' ), $menu_position );

Check warning on line 49 in includes/Admin/Menu.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

base64_encode() can be used to obfuscate code which is strongly discouraged. Please verify that the function is used for benign reasons.

// phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
$submenu['wemail'] = apply_filters( 'wemail_admin_submenu', [], $capability );
$submenu['wemail'] = apply_filters( 'wemail_admin_submenu', array(), $capability );

$this->add_action( 'admin_print_styles-' . $wemail, 'enqueue_styles' );
$this->add_action( 'admin_print_scripts-' . $wemail, 'enqueue_scripts' );
Expand Down
7 changes: 3 additions & 4 deletions includes/Admin/Notice.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public static function instance() {
* Boot the notice
*/
private function boot() {
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_assets' ] );
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) );
}

public function enqueue_assets() {
wp_register_style( 'wemail-admin-notice-style', WEMAIL_ASSETS . '/css/notice.css', false, filemtime( WEMAIL_PATH . '/assets/css/notice.css' ) );
wp_register_script( 'wemail-admin-notice-script', WEMAIL_ASSETS . '/js/admin-notice.js', [ 'jquery' ], filemtime( WEMAIL_PATH . '/assets/js/admin-notice.js' ), true );
wp_register_script( 'wemail-admin-notice-script', WEMAIL_ASSETS . '/js/admin-notice.js', array( 'jquery' ), filemtime( WEMAIL_PATH . '/assets/js/admin-notice.js' ), true );

wp_enqueue_style( 'wemail-admin-notice-style' );
wp_enqueue_script( 'wemail-admin-notice-script' );
Expand Down Expand Up @@ -72,9 +72,8 @@ public function connect_notice() {
}
}
if ( ! get_user_meta( get_current_user_id(), 'wemail_api_key', true ) && (int) get_option( 'wemail_site_connection_notice' ) !== 1 && ! ( isset( $_GET['page'] ) && $_GET['page'] === 'wemail' ) ) {
add_action( 'admin_notices', [ $this, 'connect_notice_html' ] );
add_action( 'admin_notices', array( $this, 'connect_notice_html' ) );
}
}

}

17 changes: 9 additions & 8 deletions includes/Admin/ReviewNotice.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,21 @@ class ReviewNotice {
* Boot the notice
*/
private function boot() {
add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_assets' ] );
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_assets' ) );
}

public function enqueue_assets() {
wp_enqueue_style( 'wemail-review-notice-style', WEMAIL_ASSETS . '/css/review-notice.css', false, WEMAIL_VERSION );
wp_enqueue_script( 'wemail-review-notice-script', WEMAIL_ASSETS . '/js/admin-review-notice.js', [ 'jquery' ], WEMAIL_VERSION, true );
wp_enqueue_script( 'wemail-review-notice-script', WEMAIL_ASSETS . '/js/admin-review-notice.js', array( 'jquery' ), WEMAIL_VERSION, true );
}

/**
* Notice markup to notify to connect site in weMail
*
* @return void
*/
public function connect_review_notice_html() { ?>
public function connect_review_notice_html() {
?>
<div class="notice wemail-review-notice-flex-container is-dismissible review-time-background-image" data-nonce="<?php echo wp_create_nonce( '_review_nonce' ); ?>" >
<div class="wemail-connect-notice-content">
<div class="wemail-connect-notice-content">
Expand Down Expand Up @@ -113,7 +114,7 @@ public function connect_review_notice() {
$this->campaign_count = $sent_campaigns;

if ( $this->time_based_review || $sent_campaigns >= 3 ) {
add_action( 'admin_notices', [ $this, 'connect_review_notice_html' ] );
add_action( 'admin_notices', array( $this, 'connect_review_notice_html' ) );
}
}

Expand All @@ -131,9 +132,9 @@ public function check_campaign() {
}

$response = wemail()->api->campaigns()->query(
[
'statuses' => [ 'completed' ],
]
array(
'statuses' => array( 'completed' ),
)
)->get();

if ( is_wp_error( $response ) || ! isset( $response['meta'] ) ) {
Expand All @@ -156,7 +157,7 @@ public function handle_review_response() {

if ( isset( $_POST['submit'] ) && ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['review_nonce'] ) ), '_review_nonce' ) ) {
wp_die( __( 'Security check', 'wemail' ) );
};
}

if ( isset( $_POST['review_reposnse_yes'] ) ) {
$this->review_response( 'yes' );
Expand Down
Loading

0 comments on commit cf39061

Please sign in to comment.