Skip to content

Commit

Permalink
fix: added fixes based on WP review for 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
affrncsp committed Apr 23, 2024
1 parent cd1ddc8 commit dfaa49b
Show file tree
Hide file tree
Showing 12 changed files with 661 additions and 645 deletions.
63 changes: 33 additions & 30 deletions Affinidi.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,16 @@ class Affinidi
public static $_instance = null;

protected $default_settings = [
'active' => 0,
'client_id' => '',
'backend' => '',
'redirect_user_origin' => 0,
'enable_ecommerce_support' => '',
'ecommerce_sync_address_info' => 'billing',
'ecommerce_show_al_button' => 'top_form',
'affinidi_login_loginform_header' => 'Log in passwordless with',
'affinidi_login_regform_header' => 'Sign up seamlessly with',
'redirect_to_dashboard'=> 0,
'login_only' => 0,
];

public function __construct()
{
add_action('init', [__CLASS__, 'includes']);
//add_action('init', [__CLASS__, 'custom_login']); // when activated, Affinidi Login will become the only login option
}

/**
Expand All @@ -50,43 +46,32 @@ public static function instance()
*/
public static function includes()
{
require_once(AFFINIDI_PLUGIN_DIR . '/includes/functions.php');
require_once(AFFINIDI_PLUGIN_DIR . '/includes/wp-affinidi-login-admin-options.php');
require_once(AFFINIDI_PLUGIN_DIR . '/includes/wp-affinidi-login-admin-settings.php');
require_once(AFFINIDI_PLUGIN_DIR . '/includes/wp-affinidi-login-rewrites.php');
require_once(AFFINIDI_PLUGIN_DIR . '/includes/wp-affinidi-login-idtoken.php');
require_once(AFFINIDI_PLUGIN_DIR . '/includes/wp-affinidi-login-wc.php');
require_once(AFFINIDI_PLUGIN_DIR . '/includes/functions.php');
}

/**
* Plugin Setup
*/
public function setup()
{
$options = get_option('affinidi_options');
if (!isset($options['backend'])) {
$admin_options = get_option('affinidi_options');

if (!isset($admin_options['backend'])) {
update_option('affinidi_options', $this->default_settings);
}
$this->install();
}

/**
* When wp-login.php was visited, redirect to the login page of affinidi
*
* @return void
*/
public static function custom_login()
{
global $pagenow;
$activated = absint(affinidi_get_option('active'));
if ('wp-login.php' == $pagenow && $_GET['action'] != 'logout' && $activated) {
$url = get_affinidi_login_url();
wp_redirect($url);
exit();
}
$this->install();
}

public function logout()
{
wp_redirect(home_url());
die();
exit();
}

/**
Expand All @@ -98,9 +83,27 @@ public function wp_enqueue()
{
// Registers the script if $src provided (does NOT overwrite), and enqueues it.
wp_enqueue_script('jquery-ui-accordion');
// Registers the style if source provided (does NOT overwrite) and enqueues.
wp_enqueue_style('affinidi_admin');
wp_enqueue_script('affinidi_admin');
}

/**
* Register and enqueue a custom stylesheet in the WordPress admin.
*/
public function affinidi_login_enqueue_admin_scripts() {
wp_register_style( 'affinidi_login_admin_css', plugins_url('/assets/css/admin.css', __FILE__), false, '1.0.0' );
wp_enqueue_style( 'affinidi_login_admin_css' );

wp_register_script( 'affinidi_login_admin_js', plugins_url('/assets/js/admin.js', __FILE__), false, '1.0.0', true );
wp_enqueue_script( 'affinidi_login_admin_js' );
}

public function affinidi_login_enqueue_fe_scripts()
{
// Register a CSS stylesheet.
wp_register_style('affinidi_login_fe_css', plugins_url('/assets/css/affinidi-login.css', __FILE__), false, '1.0.0');
wp_enqueue_style( 'affinidi_login_fe_css' );
// Register a new script.
wp_register_script('affinidi_login_fe_js', plugins_url('/assets/js/affinidi-login.js', __FILE__), array(), '1.0.0', true);
wp_enqueue_script( 'affinidi_login_fe_js' );
}

/**
Expand Down
6 changes: 6 additions & 0 deletions assets/css/affinidi-login.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ div.form-affinidi-login {
text-align: center;
}

div.form-affinidi-login div {
display: flex;
align-items: center;
justify-content: center;
}

div.form-affinidi-login a.affinidi-login {
margin: 0 auto;
}
Loading

0 comments on commit dfaa49b

Please sign in to comment.