Skip to content

Commit

Permalink
Merged master
Browse files Browse the repository at this point in the history
  • Loading branch information
Miika Arponen committed Nov 4, 2021
2 parents 922b550 + cc844d9 commit 0a8487f
Show file tree
Hide file tree
Showing 9 changed files with 745 additions and 333 deletions.
70 changes: 70 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,76 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.
- `wp_kses_post` (`|kses`), `esc_attr` (`|attr`), `esc_html` (`|html`) and `esc_url` (`|url`) filters added.
- Ability to include custom filters via `dustpress/filters` filter.

## [1.35.0] - 2021-11-04

### Fixed
- A bug where model termination would not work immediately if `terminate()` was called in constructor.
- Template usage for CPT posts. Also allow page templates to use any name, as intended in WP.

# Released

## [1.34.4] - 2021-10-14

### Fixed
- Current menu item check on archive pages.

## [1.34.3] - 2021-09-30

### Fixed
- Pagination parameter page_count didn't always return the right value.

## [1.34.2] - 2021-08-09

### Added
- Pagination parameters `page` and `page_count`. These can be used inside pagination.dust

## [1.34.1] - 2021-06-22

### Fixed
- Archive pages for custom taxonomies when filtering with another taxonomy.
- A variable typo

## [1.34.0] - 2021-06-10

### Added
- The UserActivateExtend class for allowing the functionality to be extended by the theme.

## [1.33.3] - 2021-05-05

### Fixed
- PHP 7.4 notice when using @menu helper with empty or non-assigned menu.

## [1.33.1] - 2021-04-20

### Changed
- Search template to precede home template to fix hierarchy problem with Polylang searching.

## [1.33.0] - 2021-03-23

### Added
- `no_form` parameter to `@password` helper to be used when there's more than one instance of the helper at a page.

### Changed
- DustPress.js calls returning JSON now return clear error messages from JSON encoding problems.

## [1.32.0] - 2021-03-02

### Added
- DustPress will now measure it's own performance.

## [1.31.0] - 2021-02-25

### Added
- Highlight color for performance alerts.

### Changed
- Decreased DustPress-debugger performance alert from 0.1s to 0.02s.

## [1.30.1] - 2021-02-16

### Fixed
- Possible fatal error caused by measure_hooks_performance.

## [1.30.0] - 2021-01-21

### Added
Expand Down
12 changes: 8 additions & 4 deletions classes/model.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,10 @@ public function fetch_data( $functions = null, $tidy = false ) {
// Loop through all public methods and run the ones we wanted to deliver the data to the views.
foreach ( $methods as $class => $class_methods ) {
foreach ( $class_methods as $name => $m ) {
if ( $this->terminated ) {
break 2;
}

if ( $perf_monitoring_enabled ) {
$perf_key = $this->perf_key( $m );
dustpress()->start_performance( $perf_key );
Expand Down Expand Up @@ -374,10 +378,6 @@ public function fetch_data( $functions = null, $tidy = false ) {
if ( $perf_monitoring_enabled ) {
dustpress()->save_performance( $perf_key );
}

if ( $this->terminated ) {
break 2;
}
}

unset( $class_methods );
Expand All @@ -386,6 +386,10 @@ public function fetch_data( $functions = null, $tidy = false ) {
// If there are private methods to run, run them too.
if ( is_array( $private_methods ) && count( $private_methods ) > 0 ) {
foreach ( $private_methods as $method ) {
if ( $this->terminated ) {
break;
}

$data = $this->run_restricted( $method );

if ( is_null( $data ) ) {
Expand Down
166 changes: 166 additions & 0 deletions classes/user-activate-extend.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
<?php
/**
* This file contains the DustPress UserActivateExtend class.
*/

namespace DustPress;

/**
* Class UserActivateExtend
*
* Replaces wp-activate.php and offers user way to make custom partial for it.
*/
class UserActivateExtend extends Model {

private $state;
private $print;
private $signup;

/**
* Returns the state of the page and sets the right strings for printing.
* States:
* no-key No activation key is set. Normally outputs form for user to give the key.
* site-active-mail Site has been activated and mail sent to user.
* account-active-mail Account has been activated and mail sent to user.
* account-active-no-mail Account has been activated but no mail is sent. Normally outputs username and password.
* error Error occurred during activation. Sets error message to print['error'].
*
* @param N /A
*
* @return $state (string) State of the view.
*/
public function State() {
$valid_error_codes = [ 'already_active', 'blog_taken' ];

// Get the key from cookie if set
$activate_cookie = 'wp-activate-' . COOKIEHASH;

$key = '';

if ( isset( $_COOKIE[ $activate_cookie ] ) ) {
$key = $_COOKIE[ $activate_cookie ];
}

if ( ! $key ) {
// activation key required
$state = "no-key";
$this->print['title'] = apply_filters( 'dustpress/activate/key_required', __( 'Activation Key Required' ) );
$this->print['wp-activate-link'] = network_site_url( 'wp-activate.php' );
}
else {
$result = wpmu_activate_signup( $key );

if ( is_wp_error( $result ) && in_array( $result->get_error_code(), $valid_error_codes ) ) {
$signup = $result->get_error_data();

$this->signup = $signup;
$this->print['title'] = apply_filters( 'dustpress/activate/account_active', __( 'Your account is now active!' ) );

if ( $signup->domain . $signup->path == '' ) {
// account active and email sent
$state = "account-active-mail";
$this->print['message'] = apply_filters(
'dustpress/activate/user_activated',
sprintf( /* translators: 1: login URL, 2: username, 3: user email, 4: lost password URL */
__( 'Your account has been activated. You may now <a href="%1$s">log in</a> to the site using your chosen username of &#8220;%2$s&#8221;. Please check your email inbox at %3$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%4$s">reset your password</a>.' ),
network_site_url( 'wp-login.php', 'login' ),
$signup->user_login,
$signup->user_email,
wp_lostpassword_url()
),
$signup->user_login,
$signup->user_email
);
}
else {
// site active and email sent
$state = "site-active-mail";
/* translators: 1: site URL, 2: site domain, 3: username, 4: user email, 5: lost password URL */
$this->print['message'] = apply_filters(
'dustpress/activate/site_activated',
sprintf( /* translators: 1: site URL, 2: site domain, 3: username, 4: user email, 5: lost password URL */
__( 'Your site at <a href="%1$s">%2$s</a> is active. You may now log in to your site using your chosen username of &#8220;%3$s&#8221;. Please check your email inbox at %4$s for your password and login instructions. If you do not receive an email, please check your junk or spam folder. If you still do not receive an email within an hour, you can <a href="%5$s">reset your password</a>.' ),
'https://' . $signup->domain,
$signup->domain,
$signup->user_login,
$signup->user_email,
wp_lostpassword_url()
),
$signup->domain,
$signup->user_login,
$signup->user_email
);
}
}
elseif ( $result === null || is_wp_error( $result ) ) {
$state = "error";

$this->print['title'] = apply_filters( 'dustpress/activate/error_occurred', __( 'An error occurred during the activation' ) );
$this->print['error'] = $result->get_error_message();
}
else {
$state = "account-active-no-mail";

$url = isset( $result['blog_id'] ) ? get_home_url( (int) $result['blog_id'] ) : '';
$user = get_userdata( (int) $result['user_id'] );

$this->print['title'] = apply_filters( 'dustpress/activate/account_active', __( 'Your account is now active!' ) );
$this->print['username'] = $user->user_login;
$this->print['useremail'] = $user->user_email;
$this->print['password'] = $result['password'];

if ( $url && $url != network_home_url( '', 'http' ) ) {
switch_to_blog( (int) $result['blog_id'] );
$login_url = wp_login_url();
restore_current_blog();
// log in link to blog
$this->print['message'] = apply_filters(
'dustpress/activate/account_activated',
sprintf( /* translators: 1: site URL, 2: login URL */
__( 'Your account is now activated. <a href="%1$s">View your site</a> or <a href="%2$s">Log in</a>' ),
$url,
esc_url( $login_url )
),
$url,
$login_url,
$user,
$result['blog_id']
);
}
else {
//log in link to main site
$this->print['message'] = apply_filters(
'dustpress/activate/account_activated',
sprintf( /* translators: 1: login URL, 2: network home URL */
__( 'Your account is now activated. <a href="%1$s">Log in</a> or go back to the <a href="%2$s">homepage</a>.' ),
network_site_url( 'wp-login.php', 'login' ),
network_home_url()
),
$user
);
}
}
}
$this->state = $state;

return $state;
}

/**
* Returns strings for printing.
*
* Available strings:
* title - Site header
* wp-activate-link - Activation link
* message - Translated message.
* error - Possible error
* username - User's loginname
* password - Translated string of "Your chosen password".
*
* @return $this->print (string) Messages for the view.
*/
public function Print() {
return $this->print;
}

}
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,8 @@
"require": {
"php": ">=7.1",
"ext-json": "*"
},
"conflict": {
"devgeniem/dustpress-debugger": "<1.7.0"
}
}
Loading

0 comments on commit 0a8487f

Please sign in to comment.