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
8 changes: 4 additions & 4 deletions includes/Data/Brands.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ final class Brands {
*/
public static function get_default_brand() {
$default_brand_data = array(
'brand' => 'wordpress',
'name' => __( 'your web host', 'wp-module-onboarding' ),
'pluginDashboardPage' => \admin_url(),
'hireExpertsInfo' => array(
'brand' => 'wordpress',
'name' => __( 'your web host', 'wp-module-onboarding' ),
'pluginDashboardPage' => \admin_url(),
'hireExpertsInfo' => array(
'defaultLink' => 'https://www.bluehost.com/wp-live',
'queryParameters' => array(
'page' => 'bluehost',
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: 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
24 changes: 24 additions & 0 deletions includes/Data/Preview.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,26 @@
use NewfoldLabs\WP\Module\Onboarding\Services\PluginInstaller;
use NewfoldLabs\WP\Module\Onboarding\Services\ThemeInstaller;

/**
* Class Preview.
*/
final class Preview {

/**
* Sets theme status.
*
* @param boolean $boolean Theme Active Status.
* @return string
*/
private static function boolean_to_status( $boolean ) {
return $boolean ? 'activated' : 'init';
}

/**
* Get Pre-requisites Plugin and Theme Data based on the flow type.
*
* @return array
*/
private static function pre_requisites() {
$theme_map = Themes::get();
return array(
Expand All @@ -30,11 +44,21 @@ private static function pre_requisites() {
);
}

/**
* Retrieve Pre-requisites for the respective flow type.
*
* @return string|array
*/
public static function get_pre_requisites() {
$pre_requisites = self::pre_requisites();
return isset( $pre_requisites[ Data::current_flow() ] ) ? $pre_requisites[ Data::current_flow() ] : array();
}

/**
* Retrieve Settings, GlobalStyles and Pre-requisites for thw flow type.
*
* @return array
*/
public static function get_settings() {
$block_editor_context = new \WP_Block_Editor_Context( array( 'name' => 'core/edit-site' ) );
$custom_settings = array(
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
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 Theme Name
* @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 Serialise the Theme data
*
* @return array
*/
public function jsonSerialize() {
return array(
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