Skip to content

Commit

Permalink
Merge pull request #13 from thefrosty/feature/2.0.0
Browse files Browse the repository at this point in the history
Version 2.0 -- Namespace change, code updates for PHP >= 7.3
  • Loading branch information
thefrosty authored Sep 12, 2020
2 parents 46a44c4 + d6f077a commit f45c8ed
Show file tree
Hide file tree
Showing 27 changed files with 161 additions and 172 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
####################################################################################
# GitHub Action:
# Whenever creating a new release of the source code.
####################################################################################
# Steps to execute:
# - Checkout the source code
# - Run "composer install" for production (required dependencies are already under vendor/)
# - Create a .zip file, excluding:
# - All hidden files (.git, .gitignore, etc)
# - Rector file
# - All development files, ending in .dist
# - All composer files <= after installing dependencies, no need for them anymore
# - Markdown files concerning development
# - Folder build/ <= created only to store the .zip file
# - Folder dev-helpers/ <= not needed for the plugin
# - Upload the .zip file as an artifact to the action (this step is possibly optional)
# - Upload the .zip file as a release, for download
####################################################################################
name: Generate Installable Plugin and Upload as Release Asset
on:
release:
types: [published]
jobs:
build:
name: Build, Downgrade and Upload Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Build project for production
run: |
composer install --no-dev --optimize-autoloader
mkdir build
- name: Create artifact
uses: montudor/action-zip@v0.1.0
with:
args: zip -X -r build/wp-login-locker.zip . -x *.git* node_modules/\* .* "*/\.*" "*/\.xml" coverage** composer.* build**
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: wp-login-locker
path: build/wp-login-locker.zip
- name: Upload to release
uses: JasonEtco/upload-to-release@master
with:
args: build/wp-login-locker.zip application/zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
language: php

php:
- '7.2'
- '7.3'
- '7.4'

install: composer install

Expand Down
3 changes: 3 additions & 0 deletions CHANGELONG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## 2.0.0- 2020-09-12
-

## 1.3.1- 2020-04-21
- Update Symfony HTTP Foundation

Expand Down
13 changes: 6 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@
}
],
"require": {
"php": ">=7.2",
"php": ">=7.3",
"ext-openssl": "*",
"composer/installers": "~1.0",
"dwnload/wp-settings-api": "^3",
"dwnload/wp-settings-api": "^3.1",
"pimple/pimple": "~3.0",
"symfony/http-foundation": "^4.4.7|^5.0.7",
"thefrosty/wp-utilities": "^1.7"
"symfony/http-foundation": "^5.0.7",
"thefrosty/wp-utilities": "^2.0"
},
"require-dev": {
"10up/wp_mock": "0.4.2",
"phpunit/phpunit": "^7",
"roave/security-advisories": "dev-master",
"slevomat/coding-standard": "~4.0",
Expand All @@ -35,15 +34,15 @@
},
"autoload": {
"psr-4": {
"Dwnload\\WpLoginLocker\\": "src"
"TheFrosty\\WpLoginLocker\\": "src"
},
"files": [
"helpers.php"
]
},
"autoload-dev": {
"psr-4": {
"Dwnload\\WpLoginLocker\\Tests\\": "tests/unit"
"TheFrosty\\Tests\\WpLoginLocker\\": "tests/unit"
}
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion helpers.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types=1);

namespace Dwnload\WpLoginLocker\Helpers;
namespace TheFrosty\WpLoginLocker\Helpers;

/**
* Close the current session and terminate all scripts.
Expand Down
4 changes: 2 additions & 2 deletions src/AbstractLoginLocker.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types=1);

namespace Dwnload\WpLoginLocker;
namespace TheFrosty\WpLoginLocker;

use TheFrosty\WpUtilities\Plugin\AbstractHookProvider;
use TheFrosty\WpUtilities\Plugin\HooksTrait;
Expand All @@ -13,7 +13,7 @@
/**
* Class AbstractLoginLocker
*
* @package Dwnload\WpLoginLocker
* @package TheFrosty\WpLoginLocker
*/
abstract class AbstractLoginLocker extends AbstractHookProvider implements
HttpFoundationRequestInterface,
Expand Down
28 changes: 10 additions & 18 deletions src/Actions/Login.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
<?php
<?php declare(strict_types=1);

namespace Dwnload\WpLoginLocker\Actions;
namespace TheFrosty\WpLoginLocker\Actions;

use Dwnload\WpLoginLocker\AbstractLoginLocker;
use Dwnload\WpLoginLocker\Login\WpLogin;
use Dwnload\WpLoginLocker\LoginLocker;
use Dwnload\WpLoginLocker\Settings\Settings;
use Dwnload\WpLoginLocker\Utilities\GeoUtilTrait;
use Dwnload\WpLoginLocker\Utilities\UserMetaCleanup;
use Dwnload\WpLoginLocker\WpMail\WpMail;
use Dwnload\WpSettingsApi\Api\Options;
use TheFrosty\WpLoginLocker\AbstractLoginLocker;
use TheFrosty\WpLoginLocker\Login\WpLogin;
use TheFrosty\WpLoginLocker\LoginLocker;
use TheFrosty\WpLoginLocker\Settings\Settings;
use TheFrosty\WpLoginLocker\Utilities\GeoUtilTrait;
use TheFrosty\WpLoginLocker\Utilities\UserMetaCleanup;
use TheFrosty\WpLoginLocker\WpMail\WpMail;
use TheFrosty\WpUtilities\Plugin\HooksTrait;

/**
* Class Login
*
* @package Dwnload\WpLoginLocker\Actions
* @package TheFrosty\WpLoginLocker\Actions
*/
class Login extends AbstractLoginLocker
{
Expand Down Expand Up @@ -86,7 +85,6 @@ protected function wpLoginAction(string $user_login, \WP_User $user): void

/**
* Trigger on a cron to cleanup old user meta.
*
* @param int $user_id
*/
protected function postMetaCleanup(int $user_id): void
Expand All @@ -99,7 +97,6 @@ protected function postMetaCleanup(int $user_id): void
*
* @param bool $protected
* @param string $meta_key
*
* @return bool
* @uses is_protected_meta()
*/
Expand Down Expand Up @@ -141,9 +138,7 @@ private function getEmailPretext(): string

/**
* Get our notification message from our messages templates.
*
* @param \WP_User $user
*
* @return string
*/
private function getEmailMessage(\WP_User $user): string
Expand Down Expand Up @@ -194,9 +189,7 @@ private function getEmailMessage(\WP_User $user): string
* Return a user name based on the current WP_User. Checks whether they
* have setup their first name\ or, display name before using their login
* user name.
*
* @param \WP_User $user
*
* @return string
*/
private function getUserName(\WP_User $user): string
Expand All @@ -212,7 +205,6 @@ private function getUserName(\WP_User $user): string

/**
* Returns the site url host.
*
* @return string
*/
private function getHomeUrl(): string
Expand Down
12 changes: 6 additions & 6 deletions src/Actions/NewUser.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php declare(strict_types=1);

namespace Dwnload\WpLoginLocker\Actions;
namespace TheFrosty\WpLoginLocker\Actions;

use Dwnload\WpLoginLocker\AbstractLoginLocker;
use Dwnload\WpLoginLocker\LoginLocker;
use Dwnload\WpLoginLocker\Utilities\GeoUtilTrait;
use TheFrosty\WpLoginLocker\AbstractLoginLocker;
use TheFrosty\WpLoginLocker\LoginLocker;
use TheFrosty\WpLoginLocker\Utilities\GeoUtilTrait;
use TheFrosty\WpUtilities\Plugin\HooksTrait;

/**
* Class NewUser
* @package Dwnload\WpLoginLocker\Actions
* @package TheFrosty\WpLoginLocker\Actions
*/
class NewUser extends AbstractLoginLocker
{
Expand All @@ -18,7 +18,7 @@ class NewUser extends AbstractLoginLocker
/**
* Add class hooks.
*/
public function addHooks()
public function addHooks(): void
{
$this->addAction('user_register', [$this, 'userRegisterAction']);
}
Expand Down
16 changes: 4 additions & 12 deletions src/Login/LastLoginColumns.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php declare(strict_types=1);

namespace Dwnload\WpLoginLocker\Login;
namespace TheFrosty\WpLoginLocker\Login;

use Dwnload\WpLoginLocker\LoginLocker;
use TheFrosty\WpLoginLocker\LoginLocker;
use TheFrosty\WpUtilities\Plugin\HooksTrait;
use TheFrosty\WpUtilities\Plugin\WpHooksInterface;

Expand All @@ -12,7 +12,7 @@
*
* @link https://wordpress.org/plugins/wp-last-login/
*
* @package Dwnload\WpLoginLocker\Login
* @package TheFrosty\WpLoginLocker\Login
*/
class LastLoginColumns implements WpHooksInterface
{
Expand All @@ -21,7 +21,7 @@ class LastLoginColumns implements WpHooksInterface
/**
* Add class hooks.
*/
public function addHooks()
public function addHooks(): void
{
// Make sure only 'Admins' who can `list_users` see the new columns.
if (\current_user_can('list_users')) {
Expand All @@ -37,9 +37,7 @@ public function addHooks()

/**
* Adds the last login column to the network admin user list.
*
* @param array $cols The default columns.
*
* @return array
*/
protected function addColumn(array $cols): array
Expand All @@ -52,11 +50,9 @@ protected function addColumn(array $cols): array

/**
* Adds the last login column to the network admin user list.
*
* @param string $value Value of the custom column.
* @param string $column_name The name of the column.
* @param int $user_id The user's id.
*
* @return string
*/
protected function manageUsersCustomColumn(string $value, string $column_name, int $user_id): string
Expand All @@ -76,9 +72,7 @@ protected function manageUsersCustomColumn(string $value, string $column_name, i

/**
* Register the column as sortable.
*
* @param array $columns
*
* @return array
*/
protected function addSortable(array $columns): array
Expand All @@ -91,9 +85,7 @@ protected function addSortable(array $columns): array

/**
* Handle ordering by last login.
*
* @param \WP_User_Query $user_query Request arguments.
*
* @return \WP_User_Query
*/
protected function preGetUsers(\WP_User_Query $user_query): \WP_User_Query
Expand Down
12 changes: 5 additions & 7 deletions src/Login/Login.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<?php declare(strict_types=1);

namespace Dwnload\WpLoginLocker\Login;
namespace TheFrosty\WpLoginLocker\Login;

use Dwnload\WpLoginLocker\AbstractLoginLocker;
use Dwnload\WpLoginLocker\Settings\Settings;
use Dwnload\WpSettingsApi\Api\Options;
use TheFrosty\WpLoginLocker\AbstractLoginLocker;
use TheFrosty\WpLoginLocker\Settings\Settings;

/**
* Class Login
*
* @package BeachbodyOnDemand\WpLogin
*/
class Login extends AbstractLoginLocker
Expand All @@ -17,7 +16,7 @@ class Login extends AbstractLoginLocker
* Settings array.
* @var array $settings
*/
private $settings = [];
private $settings;

/**
* Login constructor.
Expand All @@ -37,8 +36,7 @@ public function addHooks(): void
}
$this->addAction('login_enqueue_scripts', [$this, 'wpAddInlineLoginStyle']);
$this->addFilter('login_headerurl', [$this, 'loginHeaderUrl']);
$hook = \version_compare($GLOBALS['wp_version'], '5.2', '>=') ? 'login_headertext' : 'login_headertitle';
$this->addFilter($hook, [$this, 'loginHeaderTitle']);
$this->addFilter('login_headertext', [$this, 'loginHeaderTitle']);
}

/**
Expand Down
Loading

0 comments on commit f45c8ed

Please sign in to comment.