Skip to content

Commit

Permalink
issue-3, fix phpcs and eslint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
dhavalparekhrtcamp committed Apr 19, 2019
1 parent 80a1646 commit 08eca44
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 21 deletions.
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
assets/webpack.mix.js
assets/build
8 changes: 4 additions & 4 deletions assets/src/js/login.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* JS for Login and Register page.
*/
const wpGoogleLogin = {

/**
Expand Down Expand Up @@ -27,10 +30,7 @@ const wpGoogleLogin = {
this.googleLoginButton = this.form.querySelector( '.wp_google_login' ).cloneNode( true );
this.googleLoginButton.classList.remove( 'hidden' );

// if ( 'registerform' === this.form.getAttribute( 'id' ) ) {
// this.googleLoginButton.querySelector('.wp_google_login__button').innerText = 'Signup with Google';
// }

// HTML is cloned from existing HTML node.
this.form.append( this.googleLoginButton );
}

Expand Down
7 changes: 6 additions & 1 deletion autoloader.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<?php
/**
* To Register autoloader
*
* @package wp-google-login
*/

spl_autoload_register( function ( $resource = '' ) {

$resource_path = false;
Expand Down Expand Up @@ -60,6 +63,8 @@
}

if ( file_exists( $resource_path ) && 0 === validate_file( $resource_path ) ) {
require_once( $resource_path );
// We already making sure that file is exists and valid.
require_once( $resource_path ); // phpcs:ignore
}

} );
10 changes: 6 additions & 4 deletions inc/classes/class-helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,23 @@ public static function render_template( $template_path, $variables = [], $echo =
}

if ( ! empty( $variables ) ) {
// This will needed for provide variables to the template.
// Will skips those variables, those already defined.
extract( $variables, EXTR_SKIP );
extract( $variables, EXTR_SKIP ); // phpcs:ignore
}


if ( true === $echo ) {

// Load template and output the data.
require $template_path;
require $template_path; // phpcs:ignore

return ''; // Job done, bail out.
}

ob_start();
require $template_path; // Load template output in buffer.

// Load template output in buffer.
require $template_path; // phpcs:ignore

return ob_get_clean();

Expand Down
22 changes: 12 additions & 10 deletions inc/traits/trait-singleton.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,14 @@
* another method has done, then you should implement this trait in that class.
*
* If you specifically need multiple objects, then use a normal class.
*
* @package wp-google-login
*/

namespace WP_Google_Login\Inc\Traits;

trait Singleton {

/**
* Collection of instance.
*
* @var Array
*/
protected static $_instance = array();

/**
* Protected class constructor to prevent direct object creation
*
Expand All @@ -59,6 +54,13 @@ final protected function __clone() {
*/
final public static function get_instance() {

/**
* Collection of instance.
*
* @var array
*/
static $instance = [];

/**
* If this trait is implemented in a class which has multiple
* sub-classes then static::$_instance will be overwritten with the most recent
Expand All @@ -69,9 +71,9 @@ final public static function get_instance() {
*/
$called_class = get_called_class();

if ( ! isset( static::$_instance[ $called_class ] ) ) {
if ( ! isset( $instance[ $called_class ] ) ) {

static::$_instance[ $called_class ] = new $called_class();
$instance[ $called_class ] = new $called_class();

/**
* Dependent items can use the `wp_google_login_extend_singleton_init_{$called_class}` hook to execute code
Expand All @@ -80,7 +82,7 @@ final public static function get_instance() {

}

return static::$_instance[ $called_class ];
return $instance[ $called_class ];

}

Expand Down
7 changes: 5 additions & 2 deletions wp-google-login.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
* License: GPL2
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: wp-google-login
*
* @package wp-google-login
*/

define( 'WP_GOOGLE_LOGIN_PATH', untrailingslashit( plugin_dir_path( __FILE__ ) ) );
Expand All @@ -22,8 +24,9 @@
return;
}

require_once( $vendor_autoload );
require_once( sprintf( '%s/autoloader.php', WP_GOOGLE_LOGIN_PATH ) );
// We already making sure that file is exists and valid.
require_once( $vendor_autoload ); // phpcs:ignore
require_once( sprintf( '%s/autoloader.php', WP_GOOGLE_LOGIN_PATH ) ); // phpcs:ignore

\WP_Google_Login\Inc\Plugin::get_instance();

0 comments on commit 08eca44

Please sign in to comment.