Skip to content

Commit 586da73

Browse files
committed
Merge branch 'enhancements/45'
# Conflicts: # README.md
2 parents c2b6dc3 + 6edc85b commit 586da73

File tree

8 files changed

+1619
-1450
lines changed

8 files changed

+1619
-1450
lines changed

README.md

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,32 @@ Manage members on WordPress as post type. Implement: post type, authentification
66

77
## Important to know ##
88

9+
### 0.7.2
10+
Compatibility : 4.6
11+
12+
If you have implemented custom views before 0.7.2, you might update them. Find an exemple [here](https://github.com/BeAPI/members-post-type/commit/2562b7e79feebf09967a2f964f3144e8f6d10930#diff-fac5c1b7350b8f3af605e75406b9c751).
13+
14+
### 0.7.0
915
Compatibility : 4.4
1016

11-
Migration from 0.6.0 to 1.0.0
1217
If you use the roles and capabilities you have to migrate all data from meta for taxonomies to WordPress native functions.
1318
To do so, download the meta for taxonomies plugin and let the plugin migrate the data for you.
1419

1520
## Changelog ##
1621

17-
### 0.7.2
22+
### 1.0.0
23+
* 28 Nov 2016
24+
* Add for email notifications the available replacements values which are automatically replaced before email send.
25+
* Update the .pot and French po/mo.
1826

27+
### 0.7.2
1928
* 5 Oct 2016
20-
* `mpt_nonce_field()` method for nounce generating has been intagrated to decorrelate members and WordPress users on one hand, and to not share the same cookie for all connected members, as before, in other hand.
21-
* /!\ Please note that if you have implemented custom views before 0.7.2, you might update them. Find an exemple [here](https://github.com/BeAPI/members-post-type/commit/2562b7e79feebf09967a2f964f3144e8f6d10930#diff-fac5c1b7350b8f3af605e75406b9c751). /!\
29+
* `mpt_nonce_field()` method for nounce generating has been integrated to decorrelate members and WordPress users on one hand, and to not share the same cookie for all connected members, as before, in other hand.
30+
31+
### 0.7.1
32+
* 10 Mar 2016
33+
* Fix missing `mpt_verify_nonce`.
34+
35+
### 0.7.0
36+
* 10 Fev 2016
37+
* Update the way roles and capabilities works with members.

classes/admin/class-settings-main.php

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ public function __construct( ) {
1717
add_action( 'admin_init', array( __CLASS__, 'admin_init' ) );
1818

1919
add_action( 'admin_enqueue_scripts', array( __CLASS__, 'admin_enqueue_scripts' ), 10, 1 );
20+
21+
add_filter( 'mpt_admin\setting\replacement_values', array( $this, 'add_default_available_replacements_values' ), 20, 2 );
2022
}
2123

2224
/**
@@ -77,7 +79,7 @@ public static function admin_init( ) {
7779
//initialize settings
7880
self::$settings_api->admin_init( );
7981
}
80-
82+
8183
/**
8284
* TODO: Keep logic
8385
*
@@ -114,4 +116,63 @@ public static function validate_input( $input ) {
114116
return apply_filters( 'mpt_settings_validate_input', $output, $input, self::$id );
115117
}
116118

119+
/**
120+
* Add default replacement values and their description.
121+
* As context is the second argument, only wanted data will be returned.
122+
*
123+
* @since 1.0.0
124+
* @author Maxime CULEA
125+
*
126+
* @param array $available_values, By default it is empty
127+
* @param string $context, Where it has been called from.
128+
*
129+
* @return array, key / value corresponding to replacement value and description.
130+
*/
131+
public function add_default_available_replacements_values( $available_values, $context ) {
132+
switch ( $context ) {
133+
134+
case 'lost_password_admin' :
135+
$available_values = array(
136+
'blog_name' => __( "Blog's name", 'mpt' ),
137+
'user_name' => __( "User's name", 'mpt' ),
138+
);
139+
break;
140+
141+
case 'lost_password_member' :
142+
$available_values = array(
143+
'blog_name' => __( "Blog's name", 'mpt' ),
144+
'user_name' => __( "User's name", 'mpt' ),
145+
'reset_pwd_link' => __( "The password reset link", 'mpt' ),
146+
'site_url' => __( "Current site's url", 'mpt' ),
147+
);
148+
break;
149+
150+
case 'register_member' :
151+
$available_values = array(
152+
'blog_name' => __( "Blog's name", 'mpt' ),
153+
'user_name' => __( "User's name", 'mpt' ),
154+
'password' => __( "User's password", 'mpt' ),
155+
'login_url' => __( "The site's login url", 'mpt' ),
156+
);
157+
break;
158+
159+
case 'register_member_admin' :
160+
$available_values = array(
161+
'blog_name' => __( "Blog's name", 'mpt' ),
162+
'user_name' => __( "User's name", 'mpt' ),
163+
'user_email' => __( "User's email", 'mpt' )
164+
);
165+
break;
166+
167+
case 'register_member_validation' :
168+
$available_values = array(
169+
'blog_name' => __( "Blog's name", 'mpt' ),
170+
'site_url' => __( "Current site's url", 'mpt' ),
171+
'confirm_register_link' => __( "The register confirmation link", 'mpt' ),
172+
);
173+
break;
174+
}
175+
176+
return $available_values;
177+
}
117178
}

classes/helpers/class-options.php

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,112 @@ public static function get_default_value_from_default_options( $option_name, $ke
7676

7777
return $field_data['default'];
7878
}
79+
80+
/**
81+
* Find out if to display the setting's description or not.
82+
*
83+
* @since 1.0.0
84+
* @author Maxime CULEA
85+
*
86+
* @param $context, where it has been called from.
87+
*
88+
* @return bool, whatever to display the setting description or not.
89+
*/
90+
public static function can_display_setting_description( $context ) {
91+
92+
/**
93+
* Allow to hide or display th current admin's setting description.
94+
*
95+
* The dynamic portion of the hook name, `$context`, refers to
96+
* Where it has been called from.
97+
*
98+
* @since 1.0.0
99+
*
100+
* @param string $context Where it has been called from.
101+
*
102+
* @param bool $can_display, True or False for choosing whatever to display this setting description.
103+
*/
104+
$can_display = apply_filters( 'mpt_admin\setting\display_description_' . $context, true );
105+
106+
/**
107+
* Allow to hide or display multiple admin's settings descriptions.
108+
*
109+
* @since 1.0.0
110+
*
111+
* @param bool $can_display, True or False for choosing whatever to display this setting description.
112+
* @param string $context Where it has been called from.
113+
*/
114+
$can_display = apply_filters( 'mpt_admin\setting\display_descriptions', $can_display, $context );
115+
116+
/**
117+
* Allow to hide or display all admin's settings descriptions.
118+
*
119+
* @since 1.0.0
120+
*
121+
* @param bool $can_display, True or False for choosing whatever to display all settings descriptions.
122+
*/
123+
$can_display = apply_filters( 'mpt_admin\setting\display_all_descriptions', $can_display );
124+
125+
return $can_display;
126+
}
127+
128+
/**
129+
* Handle the admin's setting description name.
130+
*
131+
* @since 1.0.0
132+
* @author Maxime CULEA
133+
*
134+
* @param string $context : Where the method has been called from.
135+
*
136+
* @return string : If empty, setting description will not show up.
137+
*/
138+
public static function description_setting_name( $context ) {
139+
return self::can_display_setting_description( $context ) ? sprintf( '%s_description', $context ) : '';
140+
}
141+
142+
/**
143+
* Handle the admin's setting description desc.
144+
*
145+
* @since 1.0.0
146+
* @author Maxime CULEA
147+
*
148+
* @param string $context : Where the method has been called from.
149+
*
150+
* @return string $html
151+
*/
152+
public static function description_setting_desc( $context ) {
153+
// Default value
154+
$html = '';
155+
156+
if ( ! self::can_display_setting_description( $context ) ) {
157+
return $html;
158+
}
159+
160+
/**
161+
* Get the available replacement_values for the current context.
162+
*
163+
* The dynamic portion of the hook name, `$context`, refers to
164+
* Where it has been called from.
165+
*
166+
* @since 1.0.0
167+
*
168+
* @param array $replacement_values, All the available replacements values and their descriptions.
169+
* @param string $context Where it has been called from.
170+
*/
171+
$replacement_values = apply_filters( 'mpt_admin\setting\replacement_values', array(), $context );
172+
173+
if ( empty( $replacement_values ) ) {
174+
return $html;
175+
}
176+
177+
$html = '<h4>' . esc_html__( 'The available values are :', 'mpt' ) . '</h4>';
178+
$html .= '<p class="description">' . esc_html__( 'Values between "%% %%" will be dynamically replaced before email send.', 'mpt' ). '</p>';
179+
$html .= '<table><tbody>';
180+
foreach ( $replacement_values as $replacement_value => $replacement_label ) {
181+
$html .= sprintf( '<tr><td>%2$s : </td><td>%1$s</td></tr>', sprintf( '%%%%%s%%%%', esc_html( $replacement_value ) ), esc_html( $replacement_label ) );
182+
}
183+
$html .= '</tbody></table>';
184+
185+
return $html;
186+
}
79187
}
Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
<?php
22
return array(
33
array(
4-
'id' => 'mpt-main',
4+
'id' => 'mpt-main',
55
'tab_label' => __( 'General', 'mpt' ),
6-
'title' => __( 'Features available', 'mpt' ),
7-
'desc' => false,
6+
'title' => __( 'Features available', 'mpt' ),
7+
'desc' => false,
88
),
99
array(
10-
'id' => 'mpt-pages',
11-
'tab_label' => __( 'Feature Pages', 'mpt' ),
12-
'title' => __( 'Feature Pages', 'mpt' ),
13-
'desc' => __( 'You must define here the pages containing the WordPress shortcodes for different features (login, registration, etc).', 'mpt' ),
10+
'id' => 'mpt-pages',
11+
'tab_label' => __( 'Feature pages', 'mpt' ),
12+
'title' => __( 'Feature pages', 'mpt' ),
13+
'desc' => __( 'Define here the pages containing WordPress\'s shortcodes for the different features as login, registration, etc.', 'mpt' ),
1414
),
1515
array(
16-
'id' => 'mpt-security',
16+
'id' => 'mpt-security',
1717
'tab_label' => __( 'Security', 'mpt' ),
18-
'title' => __( 'Password strength', 'mpt' ),
19-
'desc' => __( 'Enforce a specific password strength for your members.', 'mpt' ),
18+
'title' => __( 'Security policy', 'mpt' ),
19+
'desc' => __( 'Define your custom password policy by changing default behaviour about password strength, length, must-use characters and so on.', 'mpt' ),
2020
),
2121
array(
22-
'id' => 'mpt-emails',
22+
'id' => 'mpt-emails',
2323
'tab_label' => __( 'Mails', 'mpt' ),
24-
'title' => __( 'Admin mail for Member registration', 'mpt' ),
25-
'desc' => __( 'Management of mail notification to the site administrator when a new member joins the site.', 'mpt' ),
24+
'title' => __( 'Manage admin and member email\'s templates', 'mpt' ),
25+
'desc' => __( 'Change however you want the admin\'s and member\'s email notifications. Please note that only described dynamic values will work for each notification.', 'mpt' ),
2626
)
2727
);

0 commit comments

Comments
 (0)