Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP Lint fixes #238

Merged
merged 13 commits into from
May 25, 2023
2 changes: 1 addition & 1 deletion includes/Data/Brands.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public static function get_brands() {
/**
* Sets the hosting brand for which Onboarding is active.
*
* @param array $container The brand plugin container.
* @param object $container The brand plugin container.
* @return void
*/
public static function set_current_brand( $container ) {
Expand Down
29 changes: 19 additions & 10 deletions includes/Data/Events.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
<?php
namespace NewfoldLabs\WP\Module\Onboarding\Data;


/**
* List of Onboarding events.
*/
final class Events {

// Contains a list of events with the key being the event slug.
protected static $events = array(
'nfd-module-onboarding-event-pageview' => array(
'category' => 'Admin',
'action' => 'pageview',
/**
* Contains a list of events with the key being the event slug.
*
* @var array
*/
protected static $events = array(
'nfd-module-onboarding-event-pageview' => array(
'category' => 'Admin',
'action' => 'pageview',
),
);
);

public static function get_event( $event_slug ) {
return self::$events[ $event_slug ] ? self::$events[ $event_slug ] : false;
}
/**
* Retrieves the active theme color variations.
*
* @param array $event_slug Event data.
* @return array|boolean
*/
public static function get_event( $event_slug ) {
return self::$events[ $event_slug ] ? self::$events[ $event_slug ] : false;
}
}
2 changes: 1 addition & 1 deletion includes/Data/Flows.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public static function get_default_flow() {
}

/**
* Retrive all the known onboarding flows.
* Retrieve all the known onboarding flows.
*
* @return array A value of true for each key indicates that the flow has been approved
* and a value of null indicates the flow has not been approved (or) has been temporarily disabled.
Expand Down
2 changes: 0 additions & 2 deletions includes/Data/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ final class Options {
*
* @var string
*/

protected static $prefix = 'nfd_module_onboarding_';

/**
* List of all the options.
*
* @var array
*/

protected static $options = array(
'redirect' => 'redirect',
'redirect_param' => 'redirect_param',
Expand Down
4 changes: 2 additions & 2 deletions includes/Data/Themes/Colors.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class Colors {
*/
protected static $theme_colors = array(
'yith-wonder' => array(
'tailored' => array(
'tailored' => array(
'calm' => array(
'header-background' => '#1A4733',
'header-foreground' => '#FFFFFF',
Expand Down Expand Up @@ -137,7 +137,7 @@ final class Colors {
'base' => '#FFFFFF',
),
),
'custom-picker-grouping' => array(
'custom-picker-grouping' => array(
'base' => array(
'header-foreground',
'header-titles',
Expand Down
3 changes: 3 additions & 0 deletions includes/Data/Themes/Fonts.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

namespace NewfoldLabs\WP\Module\Onboarding\Data\Themes;

/**
* Contains custom font palettes for a given theme.
*/
final class Fonts {

/**
Expand Down
2 changes: 1 addition & 1 deletion includes/LoginRedirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static function sso( $original_redirect ) {
*/
public static function wplogin( $original_redirect, $requested_original_redirect, $user ) {
// wp-login.php runs this filter on load and login failures
// We should only do a redirect with a succesful user login
// We should only do a redirect with a successful user login
if ( ! ( $user instanceof \WP_User ) ) {
return $original_redirect;
}
Expand Down
5 changes: 2 additions & 3 deletions includes/Models/PriorityQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
class PriorityQueue extends \SplPriorityQueue {

/**
* @param mixed $priority1
* @param mixed $priority2
*
* Defines the logic to use when comparing two priorities.
*
* @param mixed $priority1 First Priority Queue
* @param mixed $priority2 Second Priority Queue
* @return int
*/
public function compare( $priority1, $priority2 ) {
Expand Down
46 changes: 38 additions & 8 deletions includes/Models/Theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,68 +7,98 @@
*/
class Theme implements \JsonSerializable {

/**
* Name of the Theme.
*
* @var string
*/
private $theme_name;

/**
* Theme image Path.
*
* @var string
*/
private $theme_image;

/**
* Status of a theme being a Newfold Theme.
*
* @var boolean
*/
private $is_newfold_theme;

/**
* @param string $theme_name
* Theme constructor.
*
* @param string $theme_name Theme Name.
*/
public function __construct( $theme_name ) {
$this->theme_name = $theme_name;
$this->is_newfold_theme = false;
}

/**
* @param string $theme_name
* Sets the Theme Name
*
* @param string $theme_name name of the theme.
* @return void
*/
public function set_theme_name( $theme_name ) {
$this->theme_name = $theme_name;
}

/**
* @return string $theme_name
* Retrieve the Theme Name
*
* @return string
*/
public function get_theme_name() {
return $this->theme_name;
}

/**
* @param string $theme_image Path to theme screenshot image.
* Sets the Theme image path
*
* @param string $theme_image Path to theme screenshot image.
* @return void
*/
public function set_theme_image( $theme_image ) {
$this->theme_image = $theme_image;
}

/**
* @return $theme_image Path to theme screenshot image.
* Retrieve the path to theme screenshot image
*
* @return string
*/
public function get_theme_image() {
return $this->theme_image;
}

/**
* @param boolean $is_newfold_theme
* Sets the status of a theme as a Newfold theme.
*
* @param boolean $is_newfold_theme Determines if there is a Newfold theme
* @return void
*/
public function set_is_newfold_theme( $is_newfold_theme ) {
$this->is_newfold_theme = $is_newfold_theme;
}

/**
* @return boolean $is_newfold_theme true if the theme author is Newfold Digital.
* Retrieve is_newfold_theme status - true if the theme author is Newfold Digital.
*
* @return boolean
*/
public function get_is_newfold_theme() {
return $this->is_newfold_theme;
}

/**
* @return array JSON Serialize the data
* To JSON Serialize the Theme data
*
* @return array
*/
public function jsonSerialize() {
return array(
Expand Down
2 changes: 1 addition & 1 deletion includes/ModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static function module_switcher() {

$enable_onboarding = self::verify_onboarding_criteria( $customer_data );

// Check if he is a Non-Ecom Cust and Disable Redirect and Module
// Check if he is a Non-Ecommerce Customer and Disable Redirect and Module
if ( ! $enable_onboarding ) {

// Check if the Module Does Exist
Expand Down
19 changes: 14 additions & 5 deletions includes/Mustache/Mustache.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@
*/
class Mustache {

/**
* Mustache Engine.
*
* @var array
*/
protected $mustache_engine;

function __construct() {
/**
* Setup mustache engine.
*/
public function __construct() {
$this->mustache_engine = new \Mustache_Engine(
array(
'loader' => new \Mustache_Loader_FilesystemLoader( dirname( __FILE__ ) . '/Templates' ),
Expand All @@ -17,12 +25,13 @@ function __construct() {
}

/**
* @param string $template_name
* @param array $data
*
* Render respective template data.
*
* @param string $template_name Template Name
* @param array $data Data
* @return string
*/
public function render_template( $template_name, $data ) {
return $this->mustache_engine->loadTemplate( $template_name )->render( $data );
return $this->mustache_engine->loadTemplate( $template_name )->render( $data );
}
}
27 changes: 21 additions & 6 deletions includes/Permissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,23 @@ final class Permissions {
const INSTALL_THEMES = 'install_themes';
const EDIT_THEMES = 'edit_themes';

/**
* Retrieve Plugin Install Hash Value.
*
* @return string
*/
public static function rest_get_plugin_install_hash() {
return 'NFD_ONBOARDING_' . hash( 'sha256', NFD_ONBOARDING_VERSION . wp_salt( 'nonce' ) . site_url() );
}

/**
* Verify Plugin Install Hash Value.
*
* @param string $hash Hash Value.
* @return boolean
*/
public static function rest_verify_plugin_install_hash( $hash ) {
return $hash === self::rest_get_plugin_install_hash();
return self::rest_get_plugin_install_hash() === $hash;
}

/**
Expand All @@ -27,7 +38,7 @@ public static function rest_verify_plugin_install_hash( $hash ) {
* @return boolean
*/
public static function rest_is_authorized_admin() {
return \is_user_logged_in() && \current_user_can( Permissions::ADMIN );
return \is_user_logged_in() && \current_user_can( self::ADMIN );
}

/**
Expand All @@ -39,10 +50,15 @@ public static function is_authorized_admin() {
return \is_admin() && self::rest_is_authorized_admin();
}

/**
* Confirm logged-in user can manage themes.
*
* @return boolean
*/
public static function rest_can_manage_themes() {
return \is_user_logged_in() &&
\current_user_can( Permissions::INSTALL_THEMES ) &&
\current_user_can( Permissions::EDIT_THEMES );
\current_user_can( self::INSTALL_THEMES ) &&
\current_user_can( self::EDIT_THEMES );
}

/**
Expand All @@ -51,8 +67,7 @@ public static function rest_can_manage_themes() {
* @return boolean
*/
public static function custom_post_authorized_admin() {
return \current_user_can('edit_posts') && \current_user_can(Permissions::ADMIN);
return \current_user_can( 'edit_posts' ) && \current_user_can( self::ADMIN );
}

} // END \NewfoldLabs\WP\Module\Onboarding\Permissions()

12 changes: 9 additions & 3 deletions includes/RestApi/BaseHiiveController.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@
abstract class BaseHiiveController extends \WP_REST_Controller {

/**
* Hiive Base URL
*
* @var string
*/
protected $url;

/**
* BaseHiiveController constructor.
*/
public function __construct() {

if ( ! defined( 'NFD_HIIVE_BASE_URL' ) ) {
Expand All @@ -21,10 +26,11 @@ public function __construct() {
}

/**
* @param string $endpoint
* @param array $args
* Get data from the endpoint containing the specific Hiive response.
*
* @return \WP_Error|string containing the Hiive response.
* @param string $endpoint Endpoint request to get specific response
* @param array $args Arguments determining response
* @return \WP_Error|string
*/
protected function get( $endpoint, $args = array() ) {
$request = $this->url . $endpoint . '?' . http_build_query( $args );
Expand Down
Loading