Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
nextgenthemes committed Dec 24, 2024
1 parent 968095c commit 7bf90cc
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 47 deletions.
29 changes: 4 additions & 25 deletions vendor/nextgenthemes/wp-shared/includes/WP/Admin/Notices.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php declare(strict_types=1);
<?php

declare(strict_types = 1);

namespace Nextgenthemes\WP\Admin;

/**
Expand Down Expand Up @@ -76,7 +79,6 @@ public static function instance(): object {
}

return self::$instance;

}

/**
Expand Down Expand Up @@ -114,7 +116,6 @@ private function init(): void {

add_action( 'admin_notices', array( self::$instance, 'display' ) );
add_action( 'wp_ajax_dnh_dismiss_notice', array( self::$instance, 'dismiss_notice_ajax' ) );

}

/**
Expand All @@ -129,7 +130,6 @@ private function is_wp_compatible(): bool {
}

return true;

}

/**
Expand All @@ -144,7 +144,6 @@ private function is_php_compatible(): bool {
}

return true;

}

/**
Expand Down Expand Up @@ -187,7 +186,6 @@ public function display(): void {
);

}

}

/**
Expand Down Expand Up @@ -221,7 +219,6 @@ public function get_id( string $id ): string {
* Get available notice types
*
* @since 1.0
* @return array
*/
public function get_types(): array {

Expand All @@ -236,14 +233,12 @@ public function get_types(): array {
);

return apply_filters( 'dnh_notice_types', $types );

}

/**
* Get the default arguments for a notice
*
* @since 1.0
* @return array
*/
private function default_args(): array {

Expand All @@ -255,7 +250,6 @@ private function default_args(): array {
);

return apply_filters( 'dnh_default_args', $args );

}

/**
Expand Down Expand Up @@ -304,7 +298,6 @@ public function register_notice( string $id, string $type, string $content, arra
self::$instance->notices[ $id ] = $notice;

return true;

}

/**
Expand Down Expand Up @@ -353,7 +346,6 @@ public function dismiss_notice( string $id ): bool {
}

return 'user' === $notice['scope'] ? self::$instance->dismiss_user( $id ) : self::$instance->dismiss_global( $id );

}

/**
Expand All @@ -376,7 +368,6 @@ private function dismiss_user( string $id ) {
array_push( $dismissed, $id );

return update_user_meta( get_current_user_id(), 'dnh_dismissed_notices', $dismissed );

}

/**
Expand All @@ -398,7 +389,6 @@ private function dismiss_global( string $id ): bool {
array_push( $dismissed, $id );

return update_option( 'dnh_dismissed_notices', $dismissed );

}

/**
Expand All @@ -419,7 +409,6 @@ public function restore_notice( string $id ): bool {
}

return 'user' === $notice['scope'] ? self::$instance->restore_user( $id ) : self::$instance->restore_global( $id );

}

/**
Expand Down Expand Up @@ -451,7 +440,6 @@ private function restore_user( string $id ): bool {
unset( $dismissed[ $key ] );

return update_user_meta( get_current_user_id(), 'dnh_dismissed_notices', $dismissed );

}

/**
Expand Down Expand Up @@ -483,7 +471,6 @@ private function restore_global( string $id ): bool {
unset( $dismissed[ $key ] );

return update_option( 'dnh_dismissed_notices', $dismissed );

}

/**
Expand All @@ -492,22 +479,19 @@ private function restore_global( string $id ): bool {
* This includes notices dismissed globally or per user.
*
* @since 1.0
* @return array
*/
public function dismissed_notices(): array {

$user = self::$instance->dismissed_user();
$global = self::$instance->dismissed_global();

return array_merge( $user, $global );

}

/**
* Get user dismissed notices
*
* @since 1.0
* @return array
*/
private function dismissed_user(): array {

Expand All @@ -518,14 +502,12 @@ private function dismissed_user(): array {
}

return $dismissed;

}

/**
* Get globally dismissed notices
*
* @since 1.0
* @return array
*/
private function dismissed_global(): array {
return get_option( 'dnh_dismissed_notices', array() );
Expand All @@ -548,7 +530,6 @@ public function is_dismissed( string $id ): bool {
}

return true;

}

/**
Expand Down Expand Up @@ -579,9 +560,7 @@ public function get_notice( string $id ) {
}

return self::$instance->notices[ $id ];

}

}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php declare(strict_types=1);
<?php

declare(strict_types = 1);

namespace Nextgenthemes\WP\Admin;

use Nextgenthemes\WP\Admin\EDD\PluginUpdater;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php declare(strict_types=1);
<?php

declare(strict_types = 1);

namespace Nextgenthemes\WP;

if ( function_exists( '\is_admin' ) && \is_admin() ) {
Expand Down
30 changes: 15 additions & 15 deletions vendor/nextgenthemes/wp-shared/includes/WP/Asset.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php declare(strict_types=1);
namespace Nextgenthemes\WP;
<?php

declare(strict_types = 1);

use Exception;
namespace Nextgenthemes\WP;

class Asset {

Expand Down Expand Up @@ -63,7 +64,7 @@ class Asset {
public function __construct( array $args ) {

if ( empty( $args['src'] ) ) {
wp_trigger_error(__METHOD__, 'empty src is not supported yet');
wp_trigger_error( __METHOD__, 'empty src is not supported yet' );
return;
}

Expand All @@ -74,24 +75,24 @@ public function __construct( array $args ) {
return;
}

switch ($arg_name) {
switch ( $arg_name ) {
case 'ver':
if ( ! $this->validate_ver($value) ) {
if ( ! $this->validate_ver( $value ) ) {
return;
}
break;
case 'inline_script_before':
case 'inline_script_after':
if ( ! $this->validate_inline_script($value) ) {
if ( ! $this->validate_inline_script( $value ) ) {
return;
}
break;
default:
$property_type = ( new \ReflectionProperty(__CLASS__, $arg_name) )->getType()->getName();
$property_type = ( new \ReflectionProperty( __CLASS__, $arg_name ) )->getType()->getName();
$property_type = str_replace( 'bool', 'boolean', $property_type );

if ( $property_type !== gettype($value) ) {
wp_trigger_error(__METHOD__, "trying to set property <code>$arg_name</code>, with wrong type");
if ( $property_type !== gettype( $value ) ) {
wp_trigger_error( __METHOD__, "trying to set property <code>$arg_name</code>, with wrong type" );
return;
}
break;
Expand Down Expand Up @@ -175,15 +176,15 @@ private function run(): void {
if ( $this->inline_script_before ) {
wp_add_inline_script(
$this->handle,
static::inline_script($this->inline_script_before, $this->handle, 'before'),
static::inline_script( $this->inline_script_before, $this->handle, 'before' ),
'before'
);
}

if ( $this->inline_script_after ) {
wp_add_inline_script(
$this->handle,
static::inline_script($this->inline_script_after, $this->handle, 'after'),
static::inline_script( $this->inline_script_after, $this->handle, 'after' ),
'after'
);
}
Expand Down Expand Up @@ -254,9 +255,9 @@ public static function deps_and_ver( string $path ): array {
*/
public static function inline_script( $script, string $handle, string $position ): string {

if ( ! is_string($script) ) {
if ( ! is_string( $script ) ) {
// dash-ed-string to CamelCaseString
$js_var_name = str_replace('-', '', ucwords("{$handle}-js-{$position}", '-'));
$js_var_name = str_replace( '-', '', ucwords( "{$handle}-js-{$position}", '-' ) );

return "var $js_var_name = " . \wp_json_encode( $script ) . ';';
}
Expand All @@ -277,4 +278,3 @@ public static function add_dep_to_asset( \_WP_Dependency $asset, string $dep ):
return true;
}
}

Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php declare(strict_types=1);
<?php

declare(strict_types = 1);

namespace Nextgenthemes\WP;

require_once __DIR__ . '/Asset.php';
Expand Down
11 changes: 7 additions & 4 deletions vendor/nextgenthemes/wp-shared/includes/WP/fn-remote-get.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php declare(strict_types=1);
<?php

declare(strict_types = 1);

namespace Nextgenthemes\WP;

/**
Expand Down Expand Up @@ -194,12 +197,12 @@ function shorten_transient_name( string $transient_name ): string {

$transient_name = str_replace( 'https://', '', $transient_name );

if ( strlen($transient_name) > 172 ) {
if ( strlen( $transient_name ) > 172 ) {
$transient_name = preg_replace( '/[^a-zA-Z0-9_]/', '', $transient_name );
}

if ( strlen($transient_name) > 172 ) {
$transient_name = substr($transient_name, 0, 107) . '_' . hash( 'sha256', $transient_name ); // 107 + 1 + 64
if ( strlen( $transient_name ) > 172 ) {
$transient_name = substr( $transient_name, 0, 107 ) . '_' . hash( 'sha256', $transient_name ); // 107 + 1 + 64
}

return $transient_name;
Expand Down

0 comments on commit 7bf90cc

Please sign in to comment.