Skip to content

Commit 87105c8

Browse files
committed
Make Membership Plan human length filterable for minutes and hours support
1 parent 2d57f04 commit 87105c8

4 files changed

Lines changed: 30 additions & 2 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ Download and install just like any other WordPress plugin. If you want to be rea
3939

4040
## Changelog
4141

42+
### 0.4.2 - 2016.10.21
43+
* Tweak - Filter the human access length for membership plans that have a length in minutes or hours set via this helper plugin (Memberships 1.7.2+)
44+
4245
### 0.4.1 - 2016.10.18
4346
* Fix - Minutes and hours-long periods in membership plans did not work properly or when creating a user membership in admin and setting the length from the membership plan default
4447

includes/class-wc-dev-helper-memberships.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ class WC_Dev_Helper_Memberships {
3535
*/
3636
public function __construct() {
3737

38+
// add support for minutes and hours-long membership plans
3839
add_filter( 'wc_memberships_plan_access_period_options', array( $this, 'add_membership_plan_access_period_options' ) );
40+
// filter the human access length information so it can work with minutes and hours
41+
add_filter( 'wc_memberships_membership_plan_human_access_length', array( $this, 'filter_membership_human_access_length' ), 10, 2 );
3942
}
4043

4144

@@ -57,4 +60,26 @@ public function add_membership_plan_access_period_options( $periods ) {
5760
}
5861

5962

63+
/**
64+
* Display a human friendly format for the access length when it's minutes or hours-long
65+
*
66+
* @since 0.4.2
67+
* @param string $human_length The human length
68+
* @param string $standard_length The length in the standard machine-friendly format
69+
* @return string
70+
*/
71+
public function filter_membership_human_access_length( $human_length, $standard_length ) {
72+
73+
$has_minutes = strpos( $standard_length, 'minute' ) !== false;
74+
$has_hours = strpos( $standard_length, 'hour' ) !== false;
75+
76+
if ( $has_minutes || $has_hours ) {
77+
78+
$human_length = $standard_length;
79+
}
80+
81+
return $human_length;
82+
}
83+
84+
6085
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "woocommerce-dev-helper",
3-
"version": "0.4.1",
3+
"version": "0.4.2",
44
"author": "SkyVerge Team",
55
"homepage": "http://www.skyverge.com",
66
"repository": {

woocommerce-dev-helper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Description: A simple plugin for helping develop/debug WooCommerce & extensions
66
* Author: SkyVerge
77
* Author URI: http://www.skyverge.com
8-
* Version: 0.4.1
8+
* Version: 0.4.2
99
* Text Domain: woocommerce-dev-helper
1010
* Domain Path: /i18n/languages/
1111
*

0 commit comments

Comments
 (0)