Skip to content

Commit

Permalink
fix coding styles
Browse files Browse the repository at this point in the history
  • Loading branch information
ricvillagrana committed Dec 8, 2023
1 parent 846b6f1 commit eae0fdf
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 21 deletions.
4 changes: 3 additions & 1 deletion hellotext/Adapters/OrderAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ public function __construct ($order, $products = []) {
}

public function get () {
if (is_null($this->order)) { return; }
if (is_null($this->order)) {
return;
}

return array(
'reference' => $this->order->get_id(),
Expand Down
4 changes: 3 additions & 1 deletion hellotext/Events/AppInstalled.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

function hellotext_activate () {
$hellotext_business_id = get_option('hellotext_business_id');
if (!$hellotext_business_id) { return; }
if (!$hellotext_business_id) {
return;
}

do_action('hellotext_create_profile');
do_action('hellotext_create_integration', $hellotext_business_id);
Expand Down
4 changes: 3 additions & 1 deletion hellotext/Events/AppRemoved.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

function hellotext_deactivate () {
$hellotext_business_id = get_option('hellotext_business_id');
if (!$hellotext_business_id) { return; }
if (!$hellotext_business_id) {
return;
}

do_action('hellotext_remove_integration', $hellotext_business_id);

Expand Down
4 changes: 3 additions & 1 deletion hellotext/Events/CartUpdates.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ function hellotext_cart_updated () {

// Trigger events, one for added and one for removed items
foreach ($changes as $event => $items) {
if (0 == count($changes[$event])) { continue; }
if (0 == count($changes[$event])) {
continue;
}

( new Event() )->track("cart.{$event}", array(
'products' => $items
Expand Down
2 changes: 1 addition & 1 deletion hellotext/Events/OrderPlaced.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function hellotext_order_placed ( $order ) {
$event = new Event();
$parsedOrder = ( new OrderAdapter($order) )->get();

$session = isset($_COOKIE['hellotext_session'])
$session = isset($_COOKIE['hello_session'])
? sanitize_text_field($_COOKIE['hello_session'])
: null;
$encrypted_session = Session::encrypt($session);
Expand Down
2 changes: 1 addition & 1 deletion hellotext/Misc/Scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function hellotext_script () {
window.Hellotext.__apiURL = 'http://api.lvh.me:4000/v1/';
<?php } ?>

window.Hellotext.initialize('<?php echo esc_html(get_option('hellotext_business_id')) ?>');
window.Hellotext.initialize('<?php echo esc_html(get_option('hellotext_business_id')); ?>');
</script>
<?php
}
Expand Down
20 changes: 10 additions & 10 deletions hellotext/Misc/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
add_action( 'admin_init', 'hellotext_settings_init' );
function hellotext_settings_init() {

add_settings_section(
'hellotext_setting_section',
__( 'Settings', 'hellotext_settings' ),
'hellotext_description_section_callback',
'hellotext-form'
);
add_settings_section(
'hellotext_setting_section',
__( 'Settings', 'hellotext_settings' ),
'hellotext_description_section_callback',
'hellotext-form'
);

// Hellotext business ID
add_settings_field(
Expand All @@ -17,16 +17,16 @@ function hellotext_settings_init() {
'hellotext_business_id_field',
'hellotext-form',
'hellotext_setting_section'
);
);

// Helloteext Access Token
// Helloteext Access Token
add_settings_field(
'hellotext_access_token',
__( 'Access Token', 'hellotext_access_token' ),
'hellotext_access_token_field',
'hellotext-form',
'hellotext_setting_section'
);
);

register_setting( 'hellotext-form', 'hellotext_business_id' );
register_setting( 'hellotext-form', 'hellotext_access_token' );
Expand All @@ -47,7 +47,7 @@ function hellotext_business_id_field () {

function hellotext_access_token_field () {
?>
<textarea id="hellotext_access_token" name="hellotext_access_token" style="width: 400px;" rows="5"><?php echo esc_html(get_option('hellotext_access_token')) ?></textarea>
<textarea id="hellotext_access_token" name="hellotext_access_token" style="width: 400px;" rows="5"><?php echo esc_html(get_option('hellotext_access_token')); ?></textarea>
<?php
}

Expand Down
16 changes: 11 additions & 5 deletions hellotext/Services/CreateProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@ class CreateProfile {

public $user_id;
public $session;
public function __construct($user_id)
{

public function __construct($user_id) {
$this->user_id = $user_id;
$this->session = isset($_COOKIE['hello_session']) ? sanitize_text_field($_COOKIE['hello_session']) : null;
$this->client = Client::class;
}

public function process () {
if (! $this->user_id) { return; }
if (! $this->user_id) {
return;
}

if (! $this->verify_if_profile_exists()) {
$this->get_user();
Expand Down Expand Up @@ -72,13 +74,17 @@ private function attach_profile_to_session () {
}

add_action('hellotext_create_profile', function ($user_id = null) {
if (!is_user_logged_in() && !isset($user_id)) { return; }
if (!is_user_logged_in() && !isset($user_id)) {
return;
}

$user = ( null != $user_id )
? get_user_by('id', $user_id)
: wp_get_current_user();

if (!$user) { return; }
if (!$user) {
return;
}

( new CreateProfile($user->ID) )->process();
}, 10, 1);

0 comments on commit eae0fdf

Please sign in to comment.