Version Description
August 30, 2012 =
Fixed a PHP warning about load_plugin_textdomain using a deprecated argument
Fixed a PHP error if no nav menu is set
Added a role option to the members shortcode (Use like [members role="administrator"][/members])
Download this release
Release Info
Developer | brandon.wamboldt |
Plugin | WordPress Access Control |
Version | 3.1.3 |
Comparing to | |
See all releases |
Code changes from version 3.1.2 to 3.1.3
- documentation/index.html +102 -93
- readme.txt +16 -7
- wordpress-access-control.php +112 -106
documentation/index.html
CHANGED
@@ -5,28 +5,28 @@
|
|
5 |
<head>
|
6 |
<meta charset="UTF-8" />
|
7 |
<title>Documentation » WordPress Access Control</title>
|
8 |
-
|
9 |
<link rel="stylesheet" href="assets/css/readme.css" type="text/css" />
|
10 |
</head>
|
11 |
|
12 |
<body>
|
13 |
<h1 id="logo">
|
14 |
-
<a href="http://wordpress.org/"><img alt="WordPress" src="wp-admin/images/wordpress-logo.png" width="250" height="68" /></a><br />
|
15 |
WordPress Access Control Documentation Version 3.1
|
16 |
</h1>
|
17 |
-
|
18 |
<p style="text-align: center">The complete guide this plugin</p>
|
19 |
|
20 |
<h1>First Things First</h1>
|
21 |
-
|
22 |
<p>
|
23 |
WordPress Access Control is an access control plugin for WordPress, and was
|
24 |
built by Brandon Wamboldt. If you have questions outside of the scope of this
|
25 |
-
help file, require assistance, want to report a bug, request a feature or
|
26 |
anything else, please <a href="mailto:brandon.wamboldt@gmail.com">email me</a> or
|
27 |
leave a comment on my blog, <a href="http://brandonwamboldt.ca/plugins/members-only-menu-plugin/">http://brandonwamboldt.ca/plugins/members-only-menu-plugin/</a>.
|
28 |
</p>
|
29 |
-
|
30 |
<h1>Table Of Contents</h1>
|
31 |
|
32 |
<ol class="alpha" id="toc">
|
@@ -49,34 +49,34 @@
|
|
49 |
<li><a href="#changelog">Changelog</a></li>
|
50 |
<li><a href="#credits">Sources and Credits</a></li>
|
51 |
</ol>
|
52 |
-
|
53 |
<h1 id="introduction">A) Introduction - <a href="#toc">top</a></h1>
|
54 |
-
|
55 |
<p>
|
56 |
The purpose of WordPress Access Control is to provide an easy interface to users for
|
57 |
restricting access to content. It was designed for use on members sites where not all
|
58 |
content should be accessible by the public, such as with organizations or pay-sites.
|
59 |
-
</p>
|
60 |
-
|
61 |
<p>
|
62 |
WPAC gives you the ability to restrict content to members, specific roles, or even
|
63 |
non-members on a per-page/per-post basis, or using shortcodes. You can still add
|
64 |
restricted pages to the navigation, and by default they will only show up to users
|
65 |
with the required access. This is an option however.
|
66 |
</p>
|
67 |
-
|
68 |
<p>
|
69 |
WPAC also gives you the ability to customize search/archive pages, completing hiding
|
70 |
restricted posts/pages from search results if a user can't access them, showing just
|
71 |
the title with a customizable message where the excerpt would be, or showing the title
|
72 |
and excerpt.
|
73 |
</p>
|
74 |
-
|
75 |
<p>
|
76 |
WPAC now gives admins the ability to set the visibility of certain widgets to members only
|
77 |
or non-members only, as well as create member only versions of all WordPress nav menus.
|
78 |
</p>
|
79 |
-
|
80 |
<p>
|
81 |
This plugin supports custom post types via an easy to use admin option.
|
82 |
</p>
|
@@ -84,19 +84,19 @@
|
|
84 |
<h1 id="requirements">B) Requirements - <a href="#toc">top</a></h1>
|
85 |
|
86 |
<p>
|
87 |
-
WordPress Access Control has only been tested with WordPress 2.9 and greater. WordPress Access Control requires <strong>PHP4</strong> or higher, although <strong>PHP5</strong> is recommended.
|
88 |
</p>
|
89 |
-
|
90 |
<p style="color:red;">
|
91 |
WordPress Access Control may not work with all themes. If you find are using WPAC with a theme and it's not working well, please contact me with the name of the theme as well as a link to the theme, and your PHP version.
|
92 |
</p>
|
93 |
-
|
94 |
<h1 id="installation">C) Installation & Configuration - <a href="#toc">top</a></h1>
|
95 |
-
|
96 |
<p>
|
97 |
-
Installation is simple, just follow these steps and you should have no problems.
|
98 |
</p>
|
99 |
-
|
100 |
<ol>
|
101 |
<li>Upload the wordpress-access-control/ folder included in the zip to your WordPress installation's plugin folder. The default location should be /wp-content/plugins/</li>
|
102 |
<li>Login to your WordPress administration panel, located by default at http://your-site-here.com/wp-admin/</li>
|
@@ -106,202 +106,211 @@
|
|
106 |
<li>Set your default settings. An explanation of the settings can be found below.</li>
|
107 |
<li>Finished!</li>
|
108 |
</ol>
|
109 |
-
|
110 |
<h1 id="settings">D) Settings - <a href="#toc">top</a></h1>
|
111 |
-
|
112 |
<p>
|
113 |
-
Using the settings screen, you can set many default options for the
|
114 |
-
plugin, which is useful for saving time if most of your pages/posts
|
115 |
-
will have similar access settings. Most of these settings can be
|
116 |
overwritten on a per-page/per-post basis.
|
117 |
</p>
|
118 |
-
|
119 |
<h2 id="general_options">A) General Options - <a href="#toc">top</a></h2>
|
120 |
-
|
121 |
<p>
|
122 |
<strong>Make Blog Members Only</strong><br />
|
123 |
-
This setting will make the blog page itself, as well as any archive
|
124 |
-
pages restricted to members. Regular pages will still be accessible
|
125 |
-
to non-members however. This setting uses the <a href="http://codex.wordpress.org/Function_Reference/is_home">is_home()</a> and
|
126 |
<a href="http://codex.wordpress.org/Function_Reference/is_archive">is_archive()</a> functions to determine blog/archive pages.<br /><br />
|
127 |
-
|
128 |
<strong>Members Blog Redirect</strong><br />
|
129 |
This setting is a website address to redirect users to if they try to
|
130 |
-
access the blog or archive pages with the "Make Blog Members Only"
|
131 |
setting active. By default, it will redirect to the login page.<br /><br />
|
132 |
-
|
133 |
<strong>Custom Post Types</strong><br />
|
134 |
This setting allows you to enable the Members Only controls for custom
|
135 |
post types. This setting only works if the custom post type uses the
|
136 |
standard WordPress interface. This option will not be displayed if there
|
137 |
are no custom post types.
|
138 |
</p>
|
139 |
-
|
140 |
<h2 id="override_permissions">B) Override Permisisons - <a href="#toc">top</a></h2>
|
141 |
-
|
142 |
<p>
|
143 |
<strong>Always Accessible By</strong><br />
|
144 |
-
|
145 |
This will override any per-page or per-post settings and allow the specified user
|
146 |
groups to always have access to members only content. This was to fix a scenario
|
147 |
in which a lesser user such as a Contributor could make content invisible to a
|
148 |
higher user such as an administrator.
|
149 |
</p>
|
150 |
-
|
151 |
<h2 id="menu_options">C) Menu Options - <a href="#toc">top</a></h2>
|
152 |
-
|
153 |
<p>
|
154 |
<strong>Display In Menus</strong><br />
|
155 |
This setting determines how menu items work when a restricted page/post is
|
156 |
-
added to the navigation and a user doesn't have access to it. You can
|
157 |
show the menu only if a user has access to it, or you can show it all
|
158 |
the time. If you decide to show it all the time, a user who clicks on a menu
|
159 |
item but does not have access to view it will be redirected.
|
160 |
</p>
|
161 |
-
|
162 |
<h2 id="postpage_default_options">D) Post/Page Default Options - <a href="#toc">top</a></h2>
|
163 |
-
|
164 |
<p>
|
165 |
<strong>Default Post State</strong><br />
|
166 |
This setting determines the default option when creating a new post. Public
|
167 |
is the default setting and means the post will be accessible to all. Members
|
168 |
Only restricts the post to authenticated users, and Non-Members restricts
|
169 |
the post to unauthenticated users.<br /><br />
|
170 |
-
|
171 |
<strong>Posts: Only Accessible By</strong><br />
|
172 |
This setting determines the default option when creating a new page for which
|
173 |
roles can access the post. This setting is only used if the post is set for
|
174 |
Members Only. Roles are managed using plugins.<br /><br />
|
175 |
-
|
176 |
<strong>Default Page State</strong><br />
|
177 |
This setting determines the default option when creating a new page. Public
|
178 |
is the default setting and means the page will be accessible to all. Members
|
179 |
Only restricts the page to authenticated users, and Non-Members restricts
|
180 |
-
the page to unauthenticated users.<br /><br />This setting also acts as
|
181 |
the default for custom post types.<br /><br />
|
182 |
-
|
183 |
<strong>Pages: Only Accessible By</strong><br />
|
184 |
This setting determines the default option when creating a new page for which
|
185 |
roles can access the page. This setting is only used if the page is set for
|
186 |
-
Members Only. Roles are managed using plugins.<br /><br />This setting also acts as
|
187 |
the default for custom post types.<br /><br />
|
188 |
-
|
189 |
<strong>Default Redirect For Members Only Pages</strong><br />
|
190 |
This is the default URL to redirect users to when they attempt to access
|
191 |
a restricted page/post.<br /><br />
|
192 |
-
|
193 |
The link provided here is automatically appended with a redirect_to query
|
194 |
argument, so that the page may redirect the user back if they wish.
|
195 |
</p>
|
196 |
-
|
197 |
<h2 id="search_options">E) Search/Archive Options - <a href="#toc">top</a></h2>
|
198 |
-
|
199 |
<p>
|
200 |
<strong>Search Options</strong><br />
|
201 |
-
This setting determines how restricted posts/pages will appear in
|
202 |
search or archive pages. This setting uses <a href="http://codex.wordpress.org/Function_Reference/is_search">is_search()</a>
|
203 |
-
and <a href="http://codex.wordpress.org/Function_Reference/is_archive">is_archive()</a>
|
204 |
to determine use.<br /><br />
|
205 |
If you do not check "Show restricted post excerpts in search results?" the excerpt
|
206 |
will be replaced with text from the below options.<br /><br />
|
207 |
The page settings for this setting determine defaults for custom post types.<br /><br />
|
208 |
-
|
209 |
<strong>Search Excerpt (Posts)/Search Excerpt (Pages)</strong><br />
|
210 |
This text is displayed instead of the post/page excerpt in archive/search pages to users
|
211 |
-
without the required access, but only if the post/page is set to now show it's
|
212 |
excerpt.
|
213 |
</p>
|
214 |
-
|
215 |
<h1 id="shortcodes">E) Shortcodes - <a href="#toc">top</a></h1>
|
216 |
-
|
217 |
<p>
|
218 |
There are two shortcodes available for use with this plugin.<br /><br />
|
219 |
-
|
220 |
[members][/members] will hide the content within them unless the user is
|
221 |
authenticated. Also works during searching, so that if a user searches for
|
222 |
a term found in the shortcodes, but is not logged in, the page/post will
|
223 |
-
not show up in the results.
|
|
|
224 |
</p>
|
225 |
-
|
226 |
<p>
|
227 |
[nonmembers][/nonmembers] will hide the content within them unless the user is
|
228 |
not authenticated. Also works during searching, so that if a user searches for
|
229 |
a term found in the shortcodes, but is logged in, the page/post will
|
230 |
not show up in the results.
|
231 |
</p>
|
232 |
-
|
233 |
<h1 id="interface">F) Posts/Pages Interface - <a href="#toc">top</a></h1>
|
234 |
-
|
235 |
<p>
|
236 |
-
By default, when you edit/add a new post/page, the control interface should be displayed on
|
237 |
the right, directly above the "Publish" box. If you do not see it, please ensure it is set to
|
238 |
display under the "Screen Options" panel.
|
239 |
</p>
|
240 |
-
|
241 |
<p style="text-align:center;">
|
242 |
<img src="assets/images/default_interface.png" alt="" /><br />
|
243 |
The default interface is very small, and lacks many options. More options will appear once
|
244 |
you've checked an option.
|
245 |
</p>
|
246 |
-
|
247 |
<p style="text-align:center;">
|
248 |
<img src="assets/images/members_interface.png" alt="" /><br />
|
249 |
If you select "Only accessible by members?", several new options appear. The default values
|
250 |
-
are governed by the options screen, and an explanation of the options are available above
|
251 |
as well.
|
252 |
</p>
|
253 |
-
|
254 |
<p style="text-align:center;">
|
255 |
<img src="assets/images/nonmembers_interface.png" alt="" /><br />
|
256 |
If you select "Only accessible by non-members?", one new option appears. This is the URL
|
257 |
to redirect a user to, such as the my profile page or even a logout page.
|
258 |
</p>
|
259 |
-
|
260 |
<h1 id="widgets_interface">G) Widgets Interface - <a href="#toc">top</a></h1>
|
261 |
-
|
262 |
<p>
|
263 |
Now, when you add certain supported widgets to a widget area, you have the option to select
|
264 |
the visibility of the widget as members only or non-members only. Currently, the only supported
|
265 |
widget is the Custom Menu widget. If you would like more widgets added, please contact the developer.
|
266 |
</p>
|
267 |
-
|
268 |
<p style="text-align:center;">
|
269 |
<img src="assets/images/widgets_interface.jpg" alt="" /><br />
|
270 |
The additional options are limited. You can select "Only visible by members" and the widget will
|
271 |
only be displayed to users who are logged in. If you select "Only visibile by non-members" the
|
272 |
widget will only be displayed to users who are NOT logged in.
|
273 |
</p>
|
274 |
-
|
275 |
<h1 id="menus_interface">H) Nav Menus Interface - <a href="#toc">top</a></h1>
|
276 |
-
|
277 |
<p>
|
278 |
Admins now have the ability of creating a second version of any menu that their theme supports,
|
279 |
-
which will only be visible to logged in users.
|
280 |
</p>
|
281 |
-
|
282 |
<p style="text-align:center;">
|
283 |
<img src="assets/images/menus_interface.jpg" alt="" /><br />
|
284 |
The second menu in the list, "Primary Menu - Members Only" is automatically generated by this plugin. If
|
285 |
you assign it a menu that is not empty, it will be displayed instead of it's regular version to any logged
|
286 |
in user.
|
287 |
</p>
|
288 |
-
|
289 |
<h1 id="changelog">I) Changelog - <a href="#toc">top</a></h1>
|
290 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
291 |
<p><strong>Version 3.1.2 - December 7, 2011</strong></p>
|
292 |
-
|
293 |
<ul>
|
294 |
<li>Fixed a PHP error when there are no nav menus</li>
|
295 |
</ul>
|
296 |
-
|
297 |
<p><strong>Version 3.1.1 - December 7, 2011</strong></p>
|
298 |
-
|
299 |
<ul>
|
300 |
<li>Fixed a bug that might cause memory issues</li>
|
301 |
</ul>
|
302 |
-
|
303 |
<p><strong>Version 3.1 - December 7, 2011</strong></p>
|
304 |
-
|
305 |
<ul>
|
306 |
<li>Custom Post Type section is no longer displayed on the options page if there are no custom post types</li>
|
307 |
<li>Members Only Blog now properly restricts the entire site</li>
|
@@ -311,39 +320,39 @@
|
|
311 |
<li>Updated the documentation</li>
|
312 |
<li>Added new screenshots</li>
|
313 |
</ul>
|
314 |
-
|
315 |
<p><strong>Version 3.0.5 - June 6, 2011</strong></p>
|
316 |
-
|
317 |
<ul>
|
318 |
<li>Fixed the PHP issue properly this time</li>
|
319 |
</ul>
|
320 |
-
|
321 |
<p><strong>Version 3.0.4 - June 6, 2011</strong></p>
|
322 |
-
|
323 |
<ul>
|
324 |
<li>Fixed a PHP issue if a second argument wasn't supplied to several functions</li>
|
325 |
</ul>
|
326 |
-
|
327 |
<p><strong>Version 3.0.3 - June 5, 2011</strong></p>
|
328 |
-
|
329 |
<ul>
|
330 |
<li>Added an option to apply members settings to all children of a page</li>
|
331 |
<li>Fixed a bug where the page navigation for posts/archives was broken</li>
|
332 |
<li>Fixed a bug where themes that used the_content on archive/search pages could show all the contents of a post instead of the no excerpt message</li>
|
333 |
</ul>
|
334 |
-
|
335 |
<p><strong>Version 3.0.2 - June 2, 2011</strong></p>
|
336 |
-
|
337 |
<ul>
|
338 |
<li>Added do_shortcode commands to allow nested shortcodes in the [members] and [nonmembers] shortcodes</li>
|
339 |
</ul>
|
340 |
-
|
341 |
<p><strong>Version 3.0.1 - June 1, 2011</strong></p>
|
342 |
-
|
343 |
<ul>
|
344 |
<li>Fixed an issue where a members only blog with no redirect link specified would cause an infinite loop</li>
|
345 |
</ul>
|
346 |
-
|
347 |
<p><strong>Version 3.0 - May 26, 2011</strong></p>
|
348 |
|
349 |
<ul>
|
@@ -357,9 +366,9 @@
|
|
357 |
<li>Added a redirect_to argument even when using custom redirect links</li>
|
358 |
<li>Added [member][/member] and [nonmember][/nonmember] shortcodes</li>
|
359 |
</ul>
|
360 |
-
|
361 |
<h1 id="credits">J) Sources and Credits - <a href="#toc">top</a></h1>
|
362 |
-
|
363 |
<p>
|
364 |
<ul>
|
365 |
<li>I'd like to thank the <a href="http://wordpress.org/">WordPress community</a> for making such an awesome development platform.</li>
|
@@ -368,4 +377,4 @@
|
|
368 |
</p>
|
369 |
</body>
|
370 |
|
371 |
-
</html>
|
5 |
<head>
|
6 |
<meta charset="UTF-8" />
|
7 |
<title>Documentation » WordPress Access Control</title>
|
8 |
+
|
9 |
<link rel="stylesheet" href="assets/css/readme.css" type="text/css" />
|
10 |
</head>
|
11 |
|
12 |
<body>
|
13 |
<h1 id="logo">
|
14 |
+
<a href="http://wordpress.org/"><img alt="WordPress" src="wp-admin/images/wordpress-logo.png" width="250" height="68" /></a><br />
|
15 |
WordPress Access Control Documentation Version 3.1
|
16 |
</h1>
|
17 |
+
|
18 |
<p style="text-align: center">The complete guide this plugin</p>
|
19 |
|
20 |
<h1>First Things First</h1>
|
21 |
+
|
22 |
<p>
|
23 |
WordPress Access Control is an access control plugin for WordPress, and was
|
24 |
built by Brandon Wamboldt. If you have questions outside of the scope of this
|
25 |
+
help file, require assistance, want to report a bug, request a feature or
|
26 |
anything else, please <a href="mailto:brandon.wamboldt@gmail.com">email me</a> or
|
27 |
leave a comment on my blog, <a href="http://brandonwamboldt.ca/plugins/members-only-menu-plugin/">http://brandonwamboldt.ca/plugins/members-only-menu-plugin/</a>.
|
28 |
</p>
|
29 |
+
|
30 |
<h1>Table Of Contents</h1>
|
31 |
|
32 |
<ol class="alpha" id="toc">
|
49 |
<li><a href="#changelog">Changelog</a></li>
|
50 |
<li><a href="#credits">Sources and Credits</a></li>
|
51 |
</ol>
|
52 |
+
|
53 |
<h1 id="introduction">A) Introduction - <a href="#toc">top</a></h1>
|
54 |
+
|
55 |
<p>
|
56 |
The purpose of WordPress Access Control is to provide an easy interface to users for
|
57 |
restricting access to content. It was designed for use on members sites where not all
|
58 |
content should be accessible by the public, such as with organizations or pay-sites.
|
59 |
+
</p>
|
60 |
+
|
61 |
<p>
|
62 |
WPAC gives you the ability to restrict content to members, specific roles, or even
|
63 |
non-members on a per-page/per-post basis, or using shortcodes. You can still add
|
64 |
restricted pages to the navigation, and by default they will only show up to users
|
65 |
with the required access. This is an option however.
|
66 |
</p>
|
67 |
+
|
68 |
<p>
|
69 |
WPAC also gives you the ability to customize search/archive pages, completing hiding
|
70 |
restricted posts/pages from search results if a user can't access them, showing just
|
71 |
the title with a customizable message where the excerpt would be, or showing the title
|
72 |
and excerpt.
|
73 |
</p>
|
74 |
+
|
75 |
<p>
|
76 |
WPAC now gives admins the ability to set the visibility of certain widgets to members only
|
77 |
or non-members only, as well as create member only versions of all WordPress nav menus.
|
78 |
</p>
|
79 |
+
|
80 |
<p>
|
81 |
This plugin supports custom post types via an easy to use admin option.
|
82 |
</p>
|
84 |
<h1 id="requirements">B) Requirements - <a href="#toc">top</a></h1>
|
85 |
|
86 |
<p>
|
87 |
+
WordPress Access Control has only been tested with WordPress 2.9 and greater. WordPress Access Control requires <strong>PHP4</strong> or higher, although <strong>PHP5</strong> is recommended.
|
88 |
</p>
|
89 |
+
|
90 |
<p style="color:red;">
|
91 |
WordPress Access Control may not work with all themes. If you find are using WPAC with a theme and it's not working well, please contact me with the name of the theme as well as a link to the theme, and your PHP version.
|
92 |
</p>
|
93 |
+
|
94 |
<h1 id="installation">C) Installation & Configuration - <a href="#toc">top</a></h1>
|
95 |
+
|
96 |
<p>
|
97 |
+
Installation is simple, just follow these steps and you should have no problems.
|
98 |
</p>
|
99 |
+
|
100 |
<ol>
|
101 |
<li>Upload the wordpress-access-control/ folder included in the zip to your WordPress installation's plugin folder. The default location should be /wp-content/plugins/</li>
|
102 |
<li>Login to your WordPress administration panel, located by default at http://your-site-here.com/wp-admin/</li>
|
106 |
<li>Set your default settings. An explanation of the settings can be found below.</li>
|
107 |
<li>Finished!</li>
|
108 |
</ol>
|
109 |
+
|
110 |
<h1 id="settings">D) Settings - <a href="#toc">top</a></h1>
|
111 |
+
|
112 |
<p>
|
113 |
+
Using the settings screen, you can set many default options for the
|
114 |
+
plugin, which is useful for saving time if most of your pages/posts
|
115 |
+
will have similar access settings. Most of these settings can be
|
116 |
overwritten on a per-page/per-post basis.
|
117 |
</p>
|
118 |
+
|
119 |
<h2 id="general_options">A) General Options - <a href="#toc">top</a></h2>
|
120 |
+
|
121 |
<p>
|
122 |
<strong>Make Blog Members Only</strong><br />
|
123 |
+
This setting will make the blog page itself, as well as any archive
|
124 |
+
pages restricted to members. Regular pages will still be accessible
|
125 |
+
to non-members however. This setting uses the <a href="http://codex.wordpress.org/Function_Reference/is_home">is_home()</a> and
|
126 |
<a href="http://codex.wordpress.org/Function_Reference/is_archive">is_archive()</a> functions to determine blog/archive pages.<br /><br />
|
127 |
+
|
128 |
<strong>Members Blog Redirect</strong><br />
|
129 |
This setting is a website address to redirect users to if they try to
|
130 |
+
access the blog or archive pages with the "Make Blog Members Only"
|
131 |
setting active. By default, it will redirect to the login page.<br /><br />
|
132 |
+
|
133 |
<strong>Custom Post Types</strong><br />
|
134 |
This setting allows you to enable the Members Only controls for custom
|
135 |
post types. This setting only works if the custom post type uses the
|
136 |
standard WordPress interface. This option will not be displayed if there
|
137 |
are no custom post types.
|
138 |
</p>
|
139 |
+
|
140 |
<h2 id="override_permissions">B) Override Permisisons - <a href="#toc">top</a></h2>
|
141 |
+
|
142 |
<p>
|
143 |
<strong>Always Accessible By</strong><br />
|
144 |
+
|
145 |
This will override any per-page or per-post settings and allow the specified user
|
146 |
groups to always have access to members only content. This was to fix a scenario
|
147 |
in which a lesser user such as a Contributor could make content invisible to a
|
148 |
higher user such as an administrator.
|
149 |
</p>
|
150 |
+
|
151 |
<h2 id="menu_options">C) Menu Options - <a href="#toc">top</a></h2>
|
152 |
+
|
153 |
<p>
|
154 |
<strong>Display In Menus</strong><br />
|
155 |
This setting determines how menu items work when a restricted page/post is
|
156 |
+
added to the navigation and a user doesn't have access to it. You can
|
157 |
show the menu only if a user has access to it, or you can show it all
|
158 |
the time. If you decide to show it all the time, a user who clicks on a menu
|
159 |
item but does not have access to view it will be redirected.
|
160 |
</p>
|
161 |
+
|
162 |
<h2 id="postpage_default_options">D) Post/Page Default Options - <a href="#toc">top</a></h2>
|
163 |
+
|
164 |
<p>
|
165 |
<strong>Default Post State</strong><br />
|
166 |
This setting determines the default option when creating a new post. Public
|
167 |
is the default setting and means the post will be accessible to all. Members
|
168 |
Only restricts the post to authenticated users, and Non-Members restricts
|
169 |
the post to unauthenticated users.<br /><br />
|
170 |
+
|
171 |
<strong>Posts: Only Accessible By</strong><br />
|
172 |
This setting determines the default option when creating a new page for which
|
173 |
roles can access the post. This setting is only used if the post is set for
|
174 |
Members Only. Roles are managed using plugins.<br /><br />
|
175 |
+
|
176 |
<strong>Default Page State</strong><br />
|
177 |
This setting determines the default option when creating a new page. Public
|
178 |
is the default setting and means the page will be accessible to all. Members
|
179 |
Only restricts the page to authenticated users, and Non-Members restricts
|
180 |
+
the page to unauthenticated users.<br /><br />This setting also acts as
|
181 |
the default for custom post types.<br /><br />
|
182 |
+
|
183 |
<strong>Pages: Only Accessible By</strong><br />
|
184 |
This setting determines the default option when creating a new page for which
|
185 |
roles can access the page. This setting is only used if the page is set for
|
186 |
+
Members Only. Roles are managed using plugins.<br /><br />This setting also acts as
|
187 |
the default for custom post types.<br /><br />
|
188 |
+
|
189 |
<strong>Default Redirect For Members Only Pages</strong><br />
|
190 |
This is the default URL to redirect users to when they attempt to access
|
191 |
a restricted page/post.<br /><br />
|
192 |
+
|
193 |
The link provided here is automatically appended with a redirect_to query
|
194 |
argument, so that the page may redirect the user back if they wish.
|
195 |
</p>
|
196 |
+
|
197 |
<h2 id="search_options">E) Search/Archive Options - <a href="#toc">top</a></h2>
|
198 |
+
|
199 |
<p>
|
200 |
<strong>Search Options</strong><br />
|
201 |
+
This setting determines how restricted posts/pages will appear in
|
202 |
search or archive pages. This setting uses <a href="http://codex.wordpress.org/Function_Reference/is_search">is_search()</a>
|
203 |
+
and <a href="http://codex.wordpress.org/Function_Reference/is_archive">is_archive()</a>
|
204 |
to determine use.<br /><br />
|
205 |
If you do not check "Show restricted post excerpts in search results?" the excerpt
|
206 |
will be replaced with text from the below options.<br /><br />
|
207 |
The page settings for this setting determine defaults for custom post types.<br /><br />
|
208 |
+
|
209 |
<strong>Search Excerpt (Posts)/Search Excerpt (Pages)</strong><br />
|
210 |
This text is displayed instead of the post/page excerpt in archive/search pages to users
|
211 |
+
without the required access, but only if the post/page is set to now show it's
|
212 |
excerpt.
|
213 |
</p>
|
214 |
+
|
215 |
<h1 id="shortcodes">E) Shortcodes - <a href="#toc">top</a></h1>
|
216 |
+
|
217 |
<p>
|
218 |
There are two shortcodes available for use with this plugin.<br /><br />
|
219 |
+
|
220 |
[members][/members] will hide the content within them unless the user is
|
221 |
authenticated. Also works during searching, so that if a user searches for
|
222 |
a term found in the shortcodes, but is not logged in, the page/post will
|
223 |
+
not show up in the results. This shortcode also has an option to specify
|
224 |
+
a specific role, using the syntax [members role="rolename"][/members].
|
225 |
</p>
|
226 |
+
|
227 |
<p>
|
228 |
[nonmembers][/nonmembers] will hide the content within them unless the user is
|
229 |
not authenticated. Also works during searching, so that if a user searches for
|
230 |
a term found in the shortcodes, but is logged in, the page/post will
|
231 |
not show up in the results.
|
232 |
</p>
|
233 |
+
|
234 |
<h1 id="interface">F) Posts/Pages Interface - <a href="#toc">top</a></h1>
|
235 |
+
|
236 |
<p>
|
237 |
+
By default, when you edit/add a new post/page, the control interface should be displayed on
|
238 |
the right, directly above the "Publish" box. If you do not see it, please ensure it is set to
|
239 |
display under the "Screen Options" panel.
|
240 |
</p>
|
241 |
+
|
242 |
<p style="text-align:center;">
|
243 |
<img src="assets/images/default_interface.png" alt="" /><br />
|
244 |
The default interface is very small, and lacks many options. More options will appear once
|
245 |
you've checked an option.
|
246 |
</p>
|
247 |
+
|
248 |
<p style="text-align:center;">
|
249 |
<img src="assets/images/members_interface.png" alt="" /><br />
|
250 |
If you select "Only accessible by members?", several new options appear. The default values
|
251 |
+
are governed by the options screen, and an explanation of the options are available above
|
252 |
as well.
|
253 |
</p>
|
254 |
+
|
255 |
<p style="text-align:center;">
|
256 |
<img src="assets/images/nonmembers_interface.png" alt="" /><br />
|
257 |
If you select "Only accessible by non-members?", one new option appears. This is the URL
|
258 |
to redirect a user to, such as the my profile page or even a logout page.
|
259 |
</p>
|
260 |
+
|
261 |
<h1 id="widgets_interface">G) Widgets Interface - <a href="#toc">top</a></h1>
|
262 |
+
|
263 |
<p>
|
264 |
Now, when you add certain supported widgets to a widget area, you have the option to select
|
265 |
the visibility of the widget as members only or non-members only. Currently, the only supported
|
266 |
widget is the Custom Menu widget. If you would like more widgets added, please contact the developer.
|
267 |
</p>
|
268 |
+
|
269 |
<p style="text-align:center;">
|
270 |
<img src="assets/images/widgets_interface.jpg" alt="" /><br />
|
271 |
The additional options are limited. You can select "Only visible by members" and the widget will
|
272 |
only be displayed to users who are logged in. If you select "Only visibile by non-members" the
|
273 |
widget will only be displayed to users who are NOT logged in.
|
274 |
</p>
|
275 |
+
|
276 |
<h1 id="menus_interface">H) Nav Menus Interface - <a href="#toc">top</a></h1>
|
277 |
+
|
278 |
<p>
|
279 |
Admins now have the ability of creating a second version of any menu that their theme supports,
|
280 |
+
which will only be visible to logged in users.
|
281 |
</p>
|
282 |
+
|
283 |
<p style="text-align:center;">
|
284 |
<img src="assets/images/menus_interface.jpg" alt="" /><br />
|
285 |
The second menu in the list, "Primary Menu - Members Only" is automatically generated by this plugin. If
|
286 |
you assign it a menu that is not empty, it will be displayed instead of it's regular version to any logged
|
287 |
in user.
|
288 |
</p>
|
289 |
+
|
290 |
<h1 id="changelog">I) Changelog - <a href="#toc">top</a></h1>
|
291 |
+
|
292 |
+
<p><strong>Version 3.1.3 - August 30, 2012</strong></p>
|
293 |
+
|
294 |
+
<ul>
|
295 |
+
<li>Fixed a PHP warning about load_plugin_textdomain using a deprecated argument</li>
|
296 |
+
<li>Fixed a PHP error if no nav menu is set</li>
|
297 |
+
<li>Added a role option to the members shortcode (Use like [members role="administrator"][/members])</li>
|
298 |
+
</ul>
|
299 |
+
|
300 |
<p><strong>Version 3.1.2 - December 7, 2011</strong></p>
|
301 |
+
|
302 |
<ul>
|
303 |
<li>Fixed a PHP error when there are no nav menus</li>
|
304 |
</ul>
|
305 |
+
|
306 |
<p><strong>Version 3.1.1 - December 7, 2011</strong></p>
|
307 |
+
|
308 |
<ul>
|
309 |
<li>Fixed a bug that might cause memory issues</li>
|
310 |
</ul>
|
311 |
+
|
312 |
<p><strong>Version 3.1 - December 7, 2011</strong></p>
|
313 |
+
|
314 |
<ul>
|
315 |
<li>Custom Post Type section is no longer displayed on the options page if there are no custom post types</li>
|
316 |
<li>Members Only Blog now properly restricts the entire site</li>
|
320 |
<li>Updated the documentation</li>
|
321 |
<li>Added new screenshots</li>
|
322 |
</ul>
|
323 |
+
|
324 |
<p><strong>Version 3.0.5 - June 6, 2011</strong></p>
|
325 |
+
|
326 |
<ul>
|
327 |
<li>Fixed the PHP issue properly this time</li>
|
328 |
</ul>
|
329 |
+
|
330 |
<p><strong>Version 3.0.4 - June 6, 2011</strong></p>
|
331 |
+
|
332 |
<ul>
|
333 |
<li>Fixed a PHP issue if a second argument wasn't supplied to several functions</li>
|
334 |
</ul>
|
335 |
+
|
336 |
<p><strong>Version 3.0.3 - June 5, 2011</strong></p>
|
337 |
+
|
338 |
<ul>
|
339 |
<li>Added an option to apply members settings to all children of a page</li>
|
340 |
<li>Fixed a bug where the page navigation for posts/archives was broken</li>
|
341 |
<li>Fixed a bug where themes that used the_content on archive/search pages could show all the contents of a post instead of the no excerpt message</li>
|
342 |
</ul>
|
343 |
+
|
344 |
<p><strong>Version 3.0.2 - June 2, 2011</strong></p>
|
345 |
+
|
346 |
<ul>
|
347 |
<li>Added do_shortcode commands to allow nested shortcodes in the [members] and [nonmembers] shortcodes</li>
|
348 |
</ul>
|
349 |
+
|
350 |
<p><strong>Version 3.0.1 - June 1, 2011</strong></p>
|
351 |
+
|
352 |
<ul>
|
353 |
<li>Fixed an issue where a members only blog with no redirect link specified would cause an infinite loop</li>
|
354 |
</ul>
|
355 |
+
|
356 |
<p><strong>Version 3.0 - May 26, 2011</strong></p>
|
357 |
|
358 |
<ul>
|
366 |
<li>Added a redirect_to argument even when using custom redirect links</li>
|
367 |
<li>Added [member][/member] and [nonmember][/nonmember] shortcodes</li>
|
368 |
</ul>
|
369 |
+
|
370 |
<h1 id="credits">J) Sources and Credits - <a href="#toc">top</a></h1>
|
371 |
+
|
372 |
<p>
|
373 |
<ul>
|
374 |
<li>I'd like to thank the <a href="http://wordpress.org/">WordPress community</a> for making such an awesome development platform.</li>
|
377 |
</p>
|
378 |
</body>
|
379 |
|
380 |
+
</html>
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
|
|
4 |
Tags: members, only, plugin, restricted, access, menus, 3.3, wp_nav_menu, nonmembers
|
5 |
Requires at least: 2.9
|
6 |
Tested up to: 3.3
|
7 |
-
Stable tag: 3.1.
|
8 |
|
9 |
Restrict pages, posts, custom post types, menus and widgets to members, nonmembers or specific roles and still add to navigation
|
10 |
|
@@ -12,7 +12,7 @@ Restrict pages, posts, custom post types, menus and widgets to members, nonmembe
|
|
12 |
|
13 |
**Now with shortcodes and post/custom-post-type support, as well as a comprehensive admin interface for setting plugin defaults**
|
14 |
|
15 |
-
WordPress Access Control is a plugin designed to integrate into membership sites where certain pages, posts and custom post types should only be available to members of the site. The plugin offers fine tuned features for this purpose, including the ability to set site wide defaults and override these on a per-page basis.
|
16 |
|
17 |
You can easily set a page to be accessible only by members of your site, or even a specific role. You can also set pages to be accessible only to non-members of your site, useful for registration pages.
|
18 |
|
@@ -48,6 +48,9 @@ Please make sure you have the meta enabled under the Screen Options panel (top r
|
|
48 |
**This plugin doesn't work with theme XYZ**
|
49 |
Please leave a comment at http://brandonwamboldt.ca/plugins/members-only-menu-plugin/ and I will address it A.S.A.P.
|
50 |
|
|
|
|
|
|
|
51 |
== Screenshots ==
|
52 |
|
53 |
1. The meta box added by this plugin
|
@@ -57,6 +60,12 @@ Please leave a comment at http://brandonwamboldt.ca/plugins/members-only-menu-pl
|
|
57 |
|
58 |
== Changelog ==
|
59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
= 3.1.2 - December 7, 2011 =
|
61 |
|
62 |
* Fixed a PHP error when there are no nav menus
|
@@ -72,7 +81,7 @@ Please leave a comment at http://brandonwamboldt.ca/plugins/members-only-menu-pl
|
|
72 |
* Admins now have the ability to override permissions to prevent lower level users from denying admins access to posts
|
73 |
* Admins may now create menu widgets that are only visible to members or non-members from the Widgets screen
|
74 |
* Admins may now create WordPress nav menus that are only visible to members
|
75 |
-
* Updated the documentation
|
76 |
* Added new screenshots
|
77 |
|
78 |
= 3.0.5 - June 6, 2011 =
|
@@ -126,7 +135,7 @@ Please leave a comment at http://brandonwamboldt.ca/plugins/members-only-menu-pl
|
|
126 |
= 1.6.3 =
|
127 |
* Fixed a problem in pre WordPress 3 instances where a PHP error is generated due to lack of the Walker_Nav_Menu class
|
128 |
|
129 |
-
= 1.6.2 =
|
130 |
* Fixed (X)HTML validation errors caused by an empty ul which could occur if all items in a submenu were members only but the parent element was not.
|
131 |
|
132 |
= 1.6 =
|
@@ -135,7 +144,7 @@ Please leave a comment at http://brandonwamboldt.ca/plugins/members-only-menu-pl
|
|
135 |
= 1.5 =
|
136 |
* Fixed an error where submenus would still be generated if the parent was marked as members only. This has been fixed.
|
137 |
|
138 |
-
= 1.4 =
|
139 |
* Added support for PHP4
|
140 |
|
141 |
= 1.3 =
|
@@ -167,10 +176,10 @@ Please leave a comment at http://brandonwamboldt.ca/plugins/members-only-menu-pl
|
|
167 |
* Admins now have the ability to override permissions to prevent lower level users from denying admins access to posts
|
168 |
* Admins may now create menu widgets that are only visible to members or non-members from the Widgets screen
|
169 |
* Admins may now create WordPress nav menus that are only visible to members
|
170 |
-
* Updated the documentation
|
171 |
* Added new screenshots
|
172 |
|
173 |
-
= 1.6.4 =
|
174 |
* Fixed several bugs including adding support for wp_list_pages
|
175 |
|
176 |
= 1.6 =
|
4 |
Tags: members, only, plugin, restricted, access, menus, 3.3, wp_nav_menu, nonmembers
|
5 |
Requires at least: 2.9
|
6 |
Tested up to: 3.3
|
7 |
+
Stable tag: 3.1.3
|
8 |
|
9 |
Restrict pages, posts, custom post types, menus and widgets to members, nonmembers or specific roles and still add to navigation
|
10 |
|
12 |
|
13 |
**Now with shortcodes and post/custom-post-type support, as well as a comprehensive admin interface for setting plugin defaults**
|
14 |
|
15 |
+
WordPress Access Control is a plugin designed to integrate into membership sites where certain pages, posts and custom post types should only be available to members of the site. The plugin offers fine tuned features for this purpose, including the ability to set site wide defaults and override these on a per-page basis.
|
16 |
|
17 |
You can easily set a page to be accessible only by members of your site, or even a specific role. You can also set pages to be accessible only to non-members of your site, useful for registration pages.
|
18 |
|
48 |
**This plugin doesn't work with theme XYZ**
|
49 |
Please leave a comment at http://brandonwamboldt.ca/plugins/members-only-menu-plugin/ and I will address it A.S.A.P.
|
50 |
|
51 |
+
**Can I restrict content to a specific role using shortcodes?**
|
52 |
+
Yes, this is a new feature in 3.1.3. Use the syntax [members role="administrator"]Your content[/members] where administrator is the desired role
|
53 |
+
|
54 |
== Screenshots ==
|
55 |
|
56 |
1. The meta box added by this plugin
|
60 |
|
61 |
== Changelog ==
|
62 |
|
63 |
+
= 3.1.3 - August 30, 2012 =
|
64 |
+
|
65 |
+
* Fixed a PHP warning about load_plugin_textdomain using a deprecated argument
|
66 |
+
* Fixed a PHP error if no nav menu is set
|
67 |
+
* Added a role option to the members shortcode (Use like [members role="administrator"][/members])
|
68 |
+
|
69 |
= 3.1.2 - December 7, 2011 =
|
70 |
|
71 |
* Fixed a PHP error when there are no nav menus
|
81 |
* Admins now have the ability to override permissions to prevent lower level users from denying admins access to posts
|
82 |
* Admins may now create menu widgets that are only visible to members or non-members from the Widgets screen
|
83 |
* Admins may now create WordPress nav menus that are only visible to members
|
84 |
+
* Updated the documentation
|
85 |
* Added new screenshots
|
86 |
|
87 |
= 3.0.5 - June 6, 2011 =
|
135 |
= 1.6.3 =
|
136 |
* Fixed a problem in pre WordPress 3 instances where a PHP error is generated due to lack of the Walker_Nav_Menu class
|
137 |
|
138 |
+
= 1.6.2 =
|
139 |
* Fixed (X)HTML validation errors caused by an empty ul which could occur if all items in a submenu were members only but the parent element was not.
|
140 |
|
141 |
= 1.6 =
|
144 |
= 1.5 =
|
145 |
* Fixed an error where submenus would still be generated if the parent was marked as members only. This has been fixed.
|
146 |
|
147 |
+
= 1.4 =
|
148 |
* Added support for PHP4
|
149 |
|
150 |
= 1.3 =
|
176 |
* Admins now have the ability to override permissions to prevent lower level users from denying admins access to posts
|
177 |
* Admins may now create menu widgets that are only visible to members or non-members from the Widgets screen
|
178 |
* Admins may now create WordPress nav menus that are only visible to members
|
179 |
+
* Updated the documentation
|
180 |
* Added new screenshots
|
181 |
|
182 |
+
= 1.6.4 =
|
183 |
* Fixed several bugs including adding support for wp_list_pages
|
184 |
|
185 |
= 1.6 =
|
wordpress-access-control.php
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
-
* Plugin Name: WordPress Access Control
|
4 |
* Plugin URI: http://brandonwamboldt.ca/plugins/members-only-menu-plugin/
|
5 |
* Author: Brandon Wamboldt
|
6 |
* Author URI: http://brandonwamboldt.ca/
|
7 |
-
* Version: 3.1.
|
8 |
* Description: This plugin is a powerful tool which gives you fine grained control over your pages and posts (and custom post types), allowing you to restrict a page, post, or custom post type to members, non-members, or even specific roles. You can customize how these pages and posts show up in search results, where users are directed when they visit them, and much more. <strong>You can even make your entire blog members only!</strong>.
|
9 |
*/
|
10 |
|
@@ -65,7 +65,7 @@ if ( class_exists( 'Walker_Nav_Menu' ) ) {
|
|
65 |
$indent = str_repeat( ' ', $depth );
|
66 |
$output .= "$indent</ul>\n";
|
67 |
}
|
68 |
-
}
|
69 |
|
70 |
function start_el( & $output, $item, $depth, $args )
|
71 |
{
|
@@ -220,28 +220,28 @@ if ( class_exists( 'Walker_Page' ) ) {
|
|
220 |
|
221 |
/**
|
222 |
* The main plugin
|
223 |
-
*
|
224 |
* @author Brandon Wamboldt
|
225 |
* @package WordPress
|
226 |
* @subpackage WordPressAccessControl
|
227 |
*/
|
228 |
-
class WordPressAccessControl
|
229 |
{
|
230 |
function admin_init()
|
231 |
{
|
232 |
wp_enqueue_style( 'wpac-style', plugin_dir_url( __FILE__ ) . 'public/css/wpac.css' );
|
233 |
-
|
234 |
// Load translation files
|
235 |
-
if ( ! load_plugin_textdomain( 'wpac'
|
236 |
-
load_plugin_textdomain( 'wpac',
|
237 |
}
|
238 |
}
|
239 |
-
|
240 |
function admin_menu()
|
241 |
{
|
242 |
add_options_page( 'WordPress Access Control Settings', 'Members Only', 'manage_options', 'wpac-options', array( 'WordPressAccessControl', 'options_page' ) );
|
243 |
}
|
244 |
-
|
245 |
function options_page()
|
246 |
{
|
247 |
// Save options?
|
@@ -249,134 +249,134 @@ class WordPressAccessControl
|
|
249 |
if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'wpac_options_save' ) ) {
|
250 |
$admin_error = __( 'Security check failed, please try again', 'wpac' );
|
251 |
} else {
|
252 |
-
|
253 |
// Make the blog members only
|
254 |
if ( isset( $_REQUEST['wpac_members_only_blog'] ) && $_REQUEST['wpac_members_only_blog'] == 'yes' ) {
|
255 |
update_option( 'wpac_members_only_blog', true );
|
256 |
} else {
|
257 |
update_option( 'wpac_members_only_blog', false );
|
258 |
}
|
259 |
-
|
260 |
// Members blog redirect link
|
261 |
if ( isset( $_REQUEST['wpac_members_blog_redirect'] ) ) {
|
262 |
update_option( 'wpac_members_blog_redirect', esc_url( $_REQUEST['wpac_members_blog_redirect'] ) );
|
263 |
} else {
|
264 |
delete_option( 'wpac_members_blog_redirect' );
|
265 |
}
|
266 |
-
|
267 |
// Support custom post types
|
268 |
if ( isset( $_REQUEST['wpac_custom_post_types'] ) && is_array( $_REQUEST['wpac_custom_post_types'] ) ) {
|
269 |
update_option( 'wpac_custom_post_types', $_REQUEST['wpac_custom_post_types'] );
|
270 |
} else {
|
271 |
delete_option( 'wpac_custom_post_types' );
|
272 |
}
|
273 |
-
|
274 |
// Override per-page permissions
|
275 |
if ( isset( $_REQUEST['wpac_always_accessible_by'] ) && is_array( $_REQUEST['wpac_always_accessible_by'] ) ) {
|
276 |
$wpac_always_accessible_by = array();
|
277 |
-
|
278 |
foreach ( $_REQUEST['wpac_always_accessible_by'] as $role ) {
|
279 |
$wpac_always_accessible_by[] = $role;
|
280 |
}
|
281 |
-
|
282 |
update_option( 'wpac_always_accessible_by', $wpac_always_accessible_by );
|
283 |
} else {
|
284 |
update_option( 'wpac_always_accessible_by', array() );
|
285 |
}
|
286 |
-
|
287 |
// Show in the menu settings
|
288 |
if ( isset( $_REQUEST['wpac_show_in_menus'] ) && $_REQUEST['wpac_show_in_menus'] == 'always' ) {
|
289 |
update_option( 'wpac_show_in_menus', 'always' );
|
290 |
} else {
|
291 |
update_option( 'wpac_show_in_menus', 'with_access' );
|
292 |
}
|
293 |
-
|
294 |
// Default post state setting
|
295 |
if ( isset( $_REQUEST['default_post_state'] ) && in_array( $_REQUEST['default_post_state'], array( 'public', 'members', 'nonmembers' ) ) ) {
|
296 |
update_option( 'wpac_default_post_state', $_REQUEST['default_post_state'] );
|
297 |
} else {
|
298 |
update_option( 'wpac_default_post_state', 'public' );
|
299 |
}
|
300 |
-
|
301 |
// Default post roles
|
302 |
if ( isset( $_REQUEST['wpac_posts_default_restricted_to'] ) && is_array( $_REQUEST['wpac_posts_default_restricted_to'] ) ) {
|
303 |
update_option( 'wpac_posts_default_restricted_to', $_REQUEST['wpac_posts_default_restricted_to'] );
|
304 |
} else {
|
305 |
update_option( 'wpac_posts_default_restricted_to', array() );
|
306 |
}
|
307 |
-
|
308 |
// Default page state setting
|
309 |
if ( isset( $_REQUEST['default_page_state'] ) && in_array( $_REQUEST['default_page_state'], array( 'public', 'members', 'nonmembers' ) ) ) {
|
310 |
update_option( 'wpac_default_page_state', $_REQUEST['default_page_state'] );
|
311 |
} else {
|
312 |
update_option( 'wpac_default_page_state', 'public' );
|
313 |
}
|
314 |
-
|
315 |
// Default page roles
|
316 |
if ( isset( $_REQUEST['wpac_pages_default_restricted_to'] ) && is_array( $_REQUEST['wpac_pages_default_restricted_to'] ) ) {
|
317 |
update_option( 'wpac_pages_default_restricted_to', $_REQUEST['wpac_pages_default_restricted_to'] );
|
318 |
} else {
|
319 |
update_option( 'wpac_pages_default_restricted_to', array() );
|
320 |
}
|
321 |
-
|
322 |
// Default redirect
|
323 |
if ( isset( $_REQUEST['wpac_default_members_redirect'] ) && ! empty( $_REQUEST['wpac_default_members_redirect'] ) ) {
|
324 |
update_option( 'wpac_default_members_redirect', $_REQUEST['wpac_default_members_redirect'] );
|
325 |
} else {
|
326 |
update_option( 'wpac_default_members_redirect', '' );
|
327 |
}
|
328 |
-
|
329 |
// Search Options
|
330 |
if ( isset( $_REQUEST['show_posts_in_search'] ) && $_REQUEST['show_posts_in_search'] == 'yes' ) {
|
331 |
update_option( 'wpac_show_posts_in_search', true );
|
332 |
} else {
|
333 |
update_option( 'wpac_show_posts_in_search', false );
|
334 |
}
|
335 |
-
|
336 |
if ( isset( $_REQUEST['show_post_excerpts_in_search'] ) && $_REQUEST['show_post_excerpts_in_search'] == 'yes' ) {
|
337 |
update_option( 'wpac_show_post_excerpts_in_search', true );
|
338 |
} else {
|
339 |
update_option( 'wpac_show_post_excerpts_in_search', false );
|
340 |
}
|
341 |
-
|
342 |
if ( isset( $_REQUEST['show_pages_in_search'] ) && $_REQUEST['show_pages_in_search'] == 'yes' ) {
|
343 |
update_option( 'wpac_show_pages_in_search', true );
|
344 |
} else {
|
345 |
update_option( 'wpac_show_pages_in_search', false );
|
346 |
}
|
347 |
-
|
348 |
if ( isset( $_REQUEST['show_page_excerpts_in_search'] ) && $_REQUEST['show_page_excerpts_in_search'] == 'yes' ) {
|
349 |
update_option( 'wpac_show_page_excerpts_in_search', true );
|
350 |
} else {
|
351 |
update_option( 'wpac_show_page_excerpts_in_search', false );
|
352 |
}
|
353 |
-
|
354 |
// Custom excerpts
|
355 |
if ( isset( $_REQUEST['page_excerpt_text'] ) ) {
|
356 |
update_option( 'wpac_page_excerpt_text', $_REQUEST['page_excerpt_text'] );
|
357 |
}
|
358 |
-
|
359 |
if ( isset( $_REQUEST['post_excerpt_text'] ) ) {
|
360 |
update_option( 'wpac_post_excerpt_text', $_REQUEST['post_excerpt_text'] );
|
361 |
}
|
362 |
-
|
363 |
$admin_message = '<strong>' . __( 'Settings Saved.') . '</strong>';
|
364 |
}
|
365 |
}
|
366 |
-
|
367 |
include( dirname( __FILE__ ) . '/templates/options.php' );
|
368 |
}
|
369 |
-
|
370 |
-
function add_column( $columns )
|
371 |
{
|
372 |
$columns['wpac'] = '<img src="' . plugin_dir_url( __FILE__ ) . 'public/images/lock.png" alt="Access" />';
|
373 |
return $columns;
|
374 |
}
|
375 |
-
|
376 |
-
function show_column( $name )
|
377 |
{
|
378 |
global $post;
|
379 |
-
|
380 |
switch ( $name ) {
|
381 |
case 'wpac':
|
382 |
if ( get_post_meta( $post->ID, '_wpac_is_members_only', true ) ) {
|
@@ -384,11 +384,11 @@ class WordPressAccessControl
|
|
384 |
} else if ( get_post_meta( $post->ID, '_wpac_is_nonmembers_only', true ) ) {
|
385 |
echo '<img src="' . plugin_dir_url( __FILE__ ) . 'public/images/unlock.png" alt="Non-members Only" title="Non-members Only" />';
|
386 |
}
|
387 |
-
|
388 |
break;
|
389 |
}
|
390 |
}
|
391 |
-
|
392 |
function check_conditions( $page_id )
|
393 |
{
|
394 |
global $wp_roles, $current_user;
|
@@ -433,23 +433,23 @@ class WordPressAccessControl
|
|
433 |
function check_for_members_only()
|
434 |
{
|
435 |
global $post;
|
436 |
-
|
437 |
if ( is_admin() ) return;
|
438 |
-
|
439 |
// Check for a members only blog
|
440 |
$blog_is_members_only = get_option( 'wpac_members_only_blog', false );
|
441 |
-
|
442 |
if ( $blog_is_members_only && ! is_user_logged_in() ) {
|
443 |
$redirect_to = get_option( 'wpac_members_blog_redirect', wp_login_url( $_SERVER['REQUEST_URI'] ) );
|
444 |
|
445 |
if ( empty( $redirect_to ) ) {
|
446 |
$redirect_to = wp_login_url( $_SERVER['REQUEST_URI'] );
|
447 |
}
|
448 |
-
|
449 |
header( 'Location: ' . add_query_arg( 'redirect_to', $_SERVER['REQUEST_URI'], $redirect_to ) );
|
450 |
exit();
|
451 |
}
|
452 |
-
|
453 |
if ( get_post_meta( $post->ID, '_wpac_is_members_only', true ) && ! WordPressAccessControl::check_conditions( $post->ID ) ) {
|
454 |
if ( is_singular() ) {
|
455 |
$redirect_to = get_post_meta( $post->ID, '_wpac_members_redirect_to', true );
|
@@ -459,7 +459,7 @@ class WordPressAccessControl
|
|
459 |
} else {
|
460 |
header( 'Location: ' . add_query_arg( 'redirect_to', $_SERVER['REQUEST_URI'], $redirect_to ) );
|
461 |
}
|
462 |
-
|
463 |
exit();
|
464 |
}
|
465 |
}
|
@@ -468,7 +468,7 @@ class WordPressAccessControl
|
|
468 |
function check_for_nonmembers_only()
|
469 |
{
|
470 |
if ( is_admin() ) return;
|
471 |
-
|
472 |
global $post;
|
473 |
|
474 |
if ( get_post_meta( $post->ID, '_wpac_is_nonmembers_only', true ) && ! WordPressAccessControl::check_conditions( $post->ID ) ) {
|
@@ -483,51 +483,51 @@ class WordPressAccessControl
|
|
483 |
exit();
|
484 |
}
|
485 |
}
|
486 |
-
|
487 |
function remove_excerpt( $excerpt )
|
488 |
{
|
489 |
if ( is_admin() || is_single() ) return $excerpt;
|
490 |
-
|
491 |
global $post;
|
492 |
-
|
493 |
if ( get_post_meta( $post->ID, '_wpac_is_members_only', true ) && ! WordPressAccessControl::check_conditions( $post->ID ) ) {
|
494 |
$show_excerpt = get_post_meta( $post->ID, '_wpac_show_excerpt_in_search', true );
|
495 |
-
|
496 |
if ( ! is_singular() && $show_excerpt != 'yes' ) {
|
497 |
if ( $post->post_type == 'post' ) {
|
498 |
$excerpt = get_option( 'wpac_post_excerpt_text', __( 'To view the contents of this post, you must be authenticated and have the required access level.', 'wpac' ) );
|
499 |
} else {
|
500 |
$excerpt = get_option( 'wpac_page_excerpt_text', __( 'To view the contents of this page, you must be authenticated and have the required access level.', 'wpac' ) );
|
501 |
}
|
502 |
-
|
503 |
return wpautop( $excerpt );
|
504 |
} else {
|
505 |
return $excerpt;
|
506 |
}
|
507 |
}
|
508 |
-
|
509 |
return $excerpt;
|
510 |
}
|
511 |
|
512 |
-
function posts_join_paged( $join, $query )
|
513 |
{
|
514 |
global $wpdb;
|
515 |
-
|
516 |
if ( is_admin() ) return $join;
|
517 |
-
|
518 |
if ( ! is_singular() && ! is_admin() ) {
|
519 |
$join .= " LEFT JOIN {$wpdb->postmeta} PMWPAC3 ON PMWPAC3.post_id = {$wpdb->posts}.ID AND PMWPAC3.meta_key = '_wpac_show_in_search' LEFT JOIN {$wpdb->postmeta} PMWPAC ON PMWPAC.post_id = {$wpdb->posts}.ID AND PMWPAC.meta_key = '_wpac_is_members_only' LEFT JOIN {$wpdb->postmeta} PMWPAC2 ON PMWPAC2.post_id = {$wpdb->posts}.ID AND PMWPAC2.meta_key = '_wpac_is_nonmembers_only' ";
|
520 |
}
|
521 |
-
|
522 |
return $join;
|
523 |
}
|
524 |
-
|
525 |
-
function posts_where_paged( $where, $query )
|
526 |
{
|
527 |
global $wpdb;
|
528 |
-
|
529 |
if ( is_admin() ) return $where;
|
530 |
-
|
531 |
if ( ! is_singular() && ! is_admin() ) {
|
532 |
if ( ! is_user_logged_in() ) {
|
533 |
$where .= " AND ( PMWPAC.meta_value IS NULL OR PMWPAC3.meta_value = '1' OR PMWPAC.meta_value != 'true' ) ";
|
@@ -535,7 +535,7 @@ class WordPressAccessControl
|
|
535 |
$where .= " AND ( PMWPAC2.meta_value IS NULL OR PMWPAC2.meta_value != 'true' ) ";
|
536 |
}
|
537 |
}
|
538 |
-
|
539 |
return $where;
|
540 |
}
|
541 |
|
@@ -543,7 +543,7 @@ class WordPressAccessControl
|
|
543 |
{
|
544 |
return $posts;
|
545 |
echo $query->request;exit();
|
546 |
-
|
547 |
if ( ! is_singular() && ! is_admin() ) {
|
548 |
$new_posts = array();
|
549 |
|
@@ -553,24 +553,24 @@ class WordPressAccessControl
|
|
553 |
if ( get_post_meta( $post->ID, '_wpac_show_in_search', true ) != 1 ) {
|
554 |
continue;
|
555 |
}
|
556 |
-
}
|
557 |
-
|
558 |
// The page is non-members only and we do NOT have access to it
|
559 |
if ( get_post_meta( $post->ID, '_wpac_is_nonmembers_only', true ) && ! WordPressAccessControl::check_conditions( $post->ID ) ) {
|
560 |
if ( get_post_meta( $post->ID, '_wpac_show_in_search', true ) != 1 ) {
|
561 |
continue;
|
562 |
}
|
563 |
}
|
564 |
-
|
565 |
// Remove results where the search term is in a [member] or [nonmember] tag and we don't have access
|
566 |
$st = get_search_query();
|
567 |
$content = do_shortcode( $post->post_content );
|
568 |
-
|
569 |
-
|
570 |
if ( ! empty( $st ) && is_search() && ! stristr( $content, $st ) ) {
|
571 |
continue;
|
572 |
}
|
573 |
-
|
574 |
$new_posts[] = $post;
|
575 |
}
|
576 |
|
@@ -578,10 +578,10 @@ class WordPressAccessControl
|
|
578 |
$query->max_num_pages = ceil( count( $new_posts ) / $query->query_vars['posts_per_page'] );
|
579 |
$query->posts = $new_posts;
|
580 |
$query->post_count = count( $new_posts );
|
581 |
-
|
582 |
return $new_posts;
|
583 |
}
|
584 |
-
|
585 |
return $posts;
|
586 |
}
|
587 |
|
@@ -610,16 +610,16 @@ class WordPressAccessControl
|
|
610 |
function add_wpac_meta_box()
|
611 |
{
|
612 |
global $post;
|
613 |
-
|
614 |
$is_members_only = get_post_meta( $post->ID, '_wpac_is_members_only', true );
|
615 |
$is_nonmembers_only = get_post_meta( $post->ID, '_wpac_is_nonmembers_only', true );
|
616 |
-
|
617 |
if ( $post->post_type == 'post' ) {
|
618 |
$wpac_default_post_state = get_option( 'wpac_default_post_state', 'public' );
|
619 |
} else {
|
620 |
$wpac_default_post_state = get_option( 'wpac_default_page_state', 'public' );
|
621 |
}
|
622 |
-
|
623 |
if ( $is_members_only == 'true' || ( $post->post_status == 'auto-draft' && $wpac_default_post_state == 'members' ) ) {
|
624 |
$is_members_only = 'checked="checked"';
|
625 |
}
|
@@ -627,7 +627,7 @@ class WordPressAccessControl
|
|
627 |
if ( $is_nonmembers_only == 'true' || ( $post->post_status == 'auto-draft' && $wpac_default_post_state == 'nonmembers' ) ) {
|
628 |
$is_nonmembers_only = 'checked="checked"';
|
629 |
}
|
630 |
-
|
631 |
$wpac_show_in_search = get_post_meta( $post->ID, '_wpac_show_in_search', true );
|
632 |
$wpac_show_excerpt_in_search = get_post_meta( $post->ID, '_wpac_show_excerpt_in_search', true );
|
633 |
$pass_to_children = get_post_meta( $post->ID, '_wpac_pass_to_children', true );
|
@@ -656,7 +656,7 @@ class WordPressAccessControl
|
|
656 |
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
657 |
return $post_id;
|
658 |
}
|
659 |
-
|
660 |
if ( isset( $_POST['members_only'] ) && $_POST['members_only'] == 'true' ) {
|
661 |
update_post_meta( $post_id, '_wpac_is_members_only', 'true' );
|
662 |
|
@@ -697,10 +697,10 @@ class WordPressAccessControl
|
|
697 |
|
698 |
if ( isset( $_POST['pass_to_children'] ) && $_POST['pass_to_children'] == 'true' ) {
|
699 |
update_post_meta( $post_id, '_wpac_pass_to_children', 'true' );
|
700 |
-
|
701 |
$original_id = $post_id;
|
702 |
$is_revision = wp_is_post_revision( $original_id );
|
703 |
-
|
704 |
if ( $is_revision ) {
|
705 |
$original_id = $is_revision;
|
706 |
}
|
@@ -713,10 +713,10 @@ class WordPressAccessControl
|
|
713 |
} else {
|
714 |
delete_post_meta( $post_id, '_wpac_pass_to_children' );
|
715 |
}
|
716 |
-
|
717 |
return $post_id;
|
718 |
}
|
719 |
-
|
720 |
/**
|
721 |
* Replaces the default WordPress nav menu walker with our own version
|
722 |
*
|
@@ -752,11 +752,11 @@ class WordPressAccessControl
|
|
752 |
|
753 |
return $args;
|
754 |
}
|
755 |
-
|
756 |
/**
|
757 |
* This hooks in at a higher level to make sure functions like wp_list_pages
|
758 |
* won't return members only pages.
|
759 |
-
*
|
760 |
* @param array $pages
|
761 |
* @return array
|
762 |
*
|
@@ -769,7 +769,7 @@ class WordPressAccessControl
|
|
769 |
if ( is_admin() ) {
|
770 |
return $pages;
|
771 |
}
|
772 |
-
|
773 |
// Whether or not the user is logged in
|
774 |
$auth = is_user_logged_in();
|
775 |
|
@@ -789,7 +789,7 @@ class WordPressAccessControl
|
|
789 |
|
790 |
return $pages;
|
791 |
}
|
792 |
-
|
793 |
/**
|
794 |
* Adds links to the plugin row to view the options page or view the plugin
|
795 |
* documentation.
|
@@ -806,17 +806,17 @@ class WordPressAccessControl
|
|
806 |
* @since WordPress Access Control 3.0
|
807 |
* @author Brandon Wamboldt <brandon.wamboldt@gmail.com>
|
808 |
*/
|
809 |
-
function plugin_row_meta( $plugin_meta, $plugin_file, $plugin_data, $status )
|
810 |
{
|
811 |
if ( $plugin_file == str_replace( '.php', '/', basename( __FILE__ ) ) . basename( __FILE__ ) ) {
|
812 |
$plugin_meta[] = '<a href="options-general.php?page=wpac-options">' . __( 'Visit options page', 'wpac' ) . '</a>';
|
813 |
$plugin_meta[] = '<a href="' . plugin_dir_url( __FILE__ ) . 'documentation/index.html">' . __( 'Plugin Documentation', 'wpac' ) . '</a>';
|
814 |
}
|
815 |
-
|
816 |
return $plugin_meta;
|
817 |
}
|
818 |
-
|
819 |
-
|
820 |
/**
|
821 |
* Hides content for users that are not logged in and displays content for
|
822 |
* users who are logged in. Calls do_shortcode on the content to allow
|
@@ -829,17 +829,23 @@ class WordPressAccessControl
|
|
829 |
* @since WordPress Access Control 3.0
|
830 |
* @author Brandon Wamboldt <brandon.wamboldt@gmail.com>
|
831 |
*/
|
832 |
-
function shortcode_members( $attributes, $content = NULL )
|
833 |
{
|
834 |
-
global $post;
|
835 |
-
|
836 |
if ( is_user_logged_in() ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
837 |
return wpautop( do_shortcode( $content ) );
|
838 |
}
|
839 |
-
|
840 |
return '';
|
841 |
}
|
842 |
-
|
843 |
/**
|
844 |
* Hides content for users that are logged in and displays content for users
|
845 |
* who are not logged in. Calls do_shortcode on the content to allow nested
|
@@ -852,17 +858,17 @@ class WordPressAccessControl
|
|
852 |
* @since WordPress Access Control 3.0
|
853 |
* @author Brandon Wamboldt <brandon.wamboldt@gmail.com>
|
854 |
*/
|
855 |
-
function shortcode_nonmembers( $attributes, $content = NULL )
|
856 |
{
|
857 |
global $post;
|
858 |
-
|
859 |
if ( ! is_user_logged_in() ) {
|
860 |
return wpautop( do_shortcode( $content ) );
|
861 |
}
|
862 |
-
|
863 |
return '';
|
864 |
}
|
865 |
-
|
866 |
/*
|
867 |
* Loads a file that will override certain WordPress default widgets with
|
868 |
* a slightly modified version that allows admins to select it's visibility
|
@@ -875,7 +881,7 @@ class WordPressAccessControl
|
|
875 |
{
|
876 |
require( dirname( __FILE__ ) . '/default-widgets.php' );
|
877 |
}
|
878 |
-
|
879 |
/**
|
880 |
* Adds our member only menus for each regular menu
|
881 |
*
|
@@ -885,14 +891,14 @@ class WordPressAccessControl
|
|
885 |
function add_wpac_nav_menus()
|
886 |
{
|
887 |
global $_wp_registered_nav_menus;
|
888 |
-
|
889 |
$original = (array) $_wp_registered_nav_menus;
|
890 |
-
|
891 |
foreach ( $original as $location => $label ) {
|
892 |
$_wp_registered_nav_menus[$location . '_wpac'] = $label . ' - Members Only';
|
893 |
}
|
894 |
}
|
895 |
-
|
896 |
/**
|
897 |
* Checks to see if a members only version of the current menu is available
|
898 |
* and will load that instead of the normal menu.
|
@@ -912,25 +918,25 @@ class WordPressAccessControl
|
|
912 |
{
|
913 |
// Don't do anything if the user isn't logged in
|
914 |
if ( is_user_logged_in() ) {
|
915 |
-
|
916 |
// See if the theme even passed a proper menu ID
|
917 |
if ( ! empty( $args['theme_location'] ) ) {
|
918 |
-
|
919 |
-
// Member only menus end in _wpac
|
920 |
$theme_location = $args['theme_location'] . '_wpac';
|
921 |
-
|
922 |
// Get the nav menu based on the theme_location
|
923 |
if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $theme_location ] ) ) {
|
924 |
$menu = wp_get_nav_menu_object( $locations[ $theme_location ] );
|
925 |
-
|
926 |
// Only use the member only menu if it's not empty
|
927 |
-
if ( $menu->count > 0 ) {
|
928 |
$args['theme_location'] = $theme_location;
|
929 |
}
|
930 |
}
|
931 |
}
|
932 |
}
|
933 |
-
|
934 |
return $args;
|
935 |
}
|
936 |
-
}
|
1 |
<?php
|
2 |
/**
|
3 |
+
* Plugin Name: WordPress Access Control
|
4 |
* Plugin URI: http://brandonwamboldt.ca/plugins/members-only-menu-plugin/
|
5 |
* Author: Brandon Wamboldt
|
6 |
* Author URI: http://brandonwamboldt.ca/
|
7 |
+
* Version: 3.1.3
|
8 |
* Description: This plugin is a powerful tool which gives you fine grained control over your pages and posts (and custom post types), allowing you to restrict a page, post, or custom post type to members, non-members, or even specific roles. You can customize how these pages and posts show up in search results, where users are directed when they visit them, and much more. <strong>You can even make your entire blog members only!</strong>.
|
9 |
*/
|
10 |
|
65 |
$indent = str_repeat( ' ', $depth );
|
66 |
$output .= "$indent</ul>\n";
|
67 |
}
|
68 |
+
}
|
69 |
|
70 |
function start_el( & $output, $item, $depth, $args )
|
71 |
{
|
220 |
|
221 |
/**
|
222 |
* The main plugin
|
223 |
+
*
|
224 |
* @author Brandon Wamboldt
|
225 |
* @package WordPress
|
226 |
* @subpackage WordPressAccessControl
|
227 |
*/
|
228 |
+
class WordPressAccessControl
|
229 |
{
|
230 |
function admin_init()
|
231 |
{
|
232 |
wp_enqueue_style( 'wpac-style', plugin_dir_url( __FILE__ ) . 'public/css/wpac.css' );
|
233 |
+
|
234 |
// Load translation files
|
235 |
+
if ( ! load_plugin_textdomain( 'wpac' ) ) {
|
236 |
+
load_plugin_textdomain( 'wpac', false, 'wordpress-access-control/languages/' );
|
237 |
}
|
238 |
}
|
239 |
+
|
240 |
function admin_menu()
|
241 |
{
|
242 |
add_options_page( 'WordPress Access Control Settings', 'Members Only', 'manage_options', 'wpac-options', array( 'WordPressAccessControl', 'options_page' ) );
|
243 |
}
|
244 |
+
|
245 |
function options_page()
|
246 |
{
|
247 |
// Save options?
|
249 |
if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'wpac_options_save' ) ) {
|
250 |
$admin_error = __( 'Security check failed, please try again', 'wpac' );
|
251 |
} else {
|
252 |
+
|
253 |
// Make the blog members only
|
254 |
if ( isset( $_REQUEST['wpac_members_only_blog'] ) && $_REQUEST['wpac_members_only_blog'] == 'yes' ) {
|
255 |
update_option( 'wpac_members_only_blog', true );
|
256 |
} else {
|
257 |
update_option( 'wpac_members_only_blog', false );
|
258 |
}
|
259 |
+
|
260 |
// Members blog redirect link
|
261 |
if ( isset( $_REQUEST['wpac_members_blog_redirect'] ) ) {
|
262 |
update_option( 'wpac_members_blog_redirect', esc_url( $_REQUEST['wpac_members_blog_redirect'] ) );
|
263 |
} else {
|
264 |
delete_option( 'wpac_members_blog_redirect' );
|
265 |
}
|
266 |
+
|
267 |
// Support custom post types
|
268 |
if ( isset( $_REQUEST['wpac_custom_post_types'] ) && is_array( $_REQUEST['wpac_custom_post_types'] ) ) {
|
269 |
update_option( 'wpac_custom_post_types', $_REQUEST['wpac_custom_post_types'] );
|
270 |
} else {
|
271 |
delete_option( 'wpac_custom_post_types' );
|
272 |
}
|
273 |
+
|
274 |
// Override per-page permissions
|
275 |
if ( isset( $_REQUEST['wpac_always_accessible_by'] ) && is_array( $_REQUEST['wpac_always_accessible_by'] ) ) {
|
276 |
$wpac_always_accessible_by = array();
|
277 |
+
|
278 |
foreach ( $_REQUEST['wpac_always_accessible_by'] as $role ) {
|
279 |
$wpac_always_accessible_by[] = $role;
|
280 |
}
|
281 |
+
|
282 |
update_option( 'wpac_always_accessible_by', $wpac_always_accessible_by );
|
283 |
} else {
|
284 |
update_option( 'wpac_always_accessible_by', array() );
|
285 |
}
|
286 |
+
|
287 |
// Show in the menu settings
|
288 |
if ( isset( $_REQUEST['wpac_show_in_menus'] ) && $_REQUEST['wpac_show_in_menus'] == 'always' ) {
|
289 |
update_option( 'wpac_show_in_menus', 'always' );
|
290 |
} else {
|
291 |
update_option( 'wpac_show_in_menus', 'with_access' );
|
292 |
}
|
293 |
+
|
294 |
// Default post state setting
|
295 |
if ( isset( $_REQUEST['default_post_state'] ) && in_array( $_REQUEST['default_post_state'], array( 'public', 'members', 'nonmembers' ) ) ) {
|
296 |
update_option( 'wpac_default_post_state', $_REQUEST['default_post_state'] );
|
297 |
} else {
|
298 |
update_option( 'wpac_default_post_state', 'public' );
|
299 |
}
|
300 |
+
|
301 |
// Default post roles
|
302 |
if ( isset( $_REQUEST['wpac_posts_default_restricted_to'] ) && is_array( $_REQUEST['wpac_posts_default_restricted_to'] ) ) {
|
303 |
update_option( 'wpac_posts_default_restricted_to', $_REQUEST['wpac_posts_default_restricted_to'] );
|
304 |
} else {
|
305 |
update_option( 'wpac_posts_default_restricted_to', array() );
|
306 |
}
|
307 |
+
|
308 |
// Default page state setting
|
309 |
if ( isset( $_REQUEST['default_page_state'] ) && in_array( $_REQUEST['default_page_state'], array( 'public', 'members', 'nonmembers' ) ) ) {
|
310 |
update_option( 'wpac_default_page_state', $_REQUEST['default_page_state'] );
|
311 |
} else {
|
312 |
update_option( 'wpac_default_page_state', 'public' );
|
313 |
}
|
314 |
+
|
315 |
// Default page roles
|
316 |
if ( isset( $_REQUEST['wpac_pages_default_restricted_to'] ) && is_array( $_REQUEST['wpac_pages_default_restricted_to'] ) ) {
|
317 |
update_option( 'wpac_pages_default_restricted_to', $_REQUEST['wpac_pages_default_restricted_to'] );
|
318 |
} else {
|
319 |
update_option( 'wpac_pages_default_restricted_to', array() );
|
320 |
}
|
321 |
+
|
322 |
// Default redirect
|
323 |
if ( isset( $_REQUEST['wpac_default_members_redirect'] ) && ! empty( $_REQUEST['wpac_default_members_redirect'] ) ) {
|
324 |
update_option( 'wpac_default_members_redirect', $_REQUEST['wpac_default_members_redirect'] );
|
325 |
} else {
|
326 |
update_option( 'wpac_default_members_redirect', '' );
|
327 |
}
|
328 |
+
|
329 |
// Search Options
|
330 |
if ( isset( $_REQUEST['show_posts_in_search'] ) && $_REQUEST['show_posts_in_search'] == 'yes' ) {
|
331 |
update_option( 'wpac_show_posts_in_search', true );
|
332 |
} else {
|
333 |
update_option( 'wpac_show_posts_in_search', false );
|
334 |
}
|
335 |
+
|
336 |
if ( isset( $_REQUEST['show_post_excerpts_in_search'] ) && $_REQUEST['show_post_excerpts_in_search'] == 'yes' ) {
|
337 |
update_option( 'wpac_show_post_excerpts_in_search', true );
|
338 |
} else {
|
339 |
update_option( 'wpac_show_post_excerpts_in_search', false );
|
340 |
}
|
341 |
+
|
342 |
if ( isset( $_REQUEST['show_pages_in_search'] ) && $_REQUEST['show_pages_in_search'] == 'yes' ) {
|
343 |
update_option( 'wpac_show_pages_in_search', true );
|
344 |
} else {
|
345 |
update_option( 'wpac_show_pages_in_search', false );
|
346 |
}
|
347 |
+
|
348 |
if ( isset( $_REQUEST['show_page_excerpts_in_search'] ) && $_REQUEST['show_page_excerpts_in_search'] == 'yes' ) {
|
349 |
update_option( 'wpac_show_page_excerpts_in_search', true );
|
350 |
} else {
|
351 |
update_option( 'wpac_show_page_excerpts_in_search', false );
|
352 |
}
|
353 |
+
|
354 |
// Custom excerpts
|
355 |
if ( isset( $_REQUEST['page_excerpt_text'] ) ) {
|
356 |
update_option( 'wpac_page_excerpt_text', $_REQUEST['page_excerpt_text'] );
|
357 |
}
|
358 |
+
|
359 |
if ( isset( $_REQUEST['post_excerpt_text'] ) ) {
|
360 |
update_option( 'wpac_post_excerpt_text', $_REQUEST['post_excerpt_text'] );
|
361 |
}
|
362 |
+
|
363 |
$admin_message = '<strong>' . __( 'Settings Saved.') . '</strong>';
|
364 |
}
|
365 |
}
|
366 |
+
|
367 |
include( dirname( __FILE__ ) . '/templates/options.php' );
|
368 |
}
|
369 |
+
|
370 |
+
function add_column( $columns )
|
371 |
{
|
372 |
$columns['wpac'] = '<img src="' . plugin_dir_url( __FILE__ ) . 'public/images/lock.png" alt="Access" />';
|
373 |
return $columns;
|
374 |
}
|
375 |
+
|
376 |
+
function show_column( $name )
|
377 |
{
|
378 |
global $post;
|
379 |
+
|
380 |
switch ( $name ) {
|
381 |
case 'wpac':
|
382 |
if ( get_post_meta( $post->ID, '_wpac_is_members_only', true ) ) {
|
384 |
} else if ( get_post_meta( $post->ID, '_wpac_is_nonmembers_only', true ) ) {
|
385 |
echo '<img src="' . plugin_dir_url( __FILE__ ) . 'public/images/unlock.png" alt="Non-members Only" title="Non-members Only" />';
|
386 |
}
|
387 |
+
|
388 |
break;
|
389 |
}
|
390 |
}
|
391 |
+
|
392 |
function check_conditions( $page_id )
|
393 |
{
|
394 |
global $wp_roles, $current_user;
|
433 |
function check_for_members_only()
|
434 |
{
|
435 |
global $post;
|
436 |
+
|
437 |
if ( is_admin() ) return;
|
438 |
+
|
439 |
// Check for a members only blog
|
440 |
$blog_is_members_only = get_option( 'wpac_members_only_blog', false );
|
441 |
+
|
442 |
if ( $blog_is_members_only && ! is_user_logged_in() ) {
|
443 |
$redirect_to = get_option( 'wpac_members_blog_redirect', wp_login_url( $_SERVER['REQUEST_URI'] ) );
|
444 |
|
445 |
if ( empty( $redirect_to ) ) {
|
446 |
$redirect_to = wp_login_url( $_SERVER['REQUEST_URI'] );
|
447 |
}
|
448 |
+
|
449 |
header( 'Location: ' . add_query_arg( 'redirect_to', $_SERVER['REQUEST_URI'], $redirect_to ) );
|
450 |
exit();
|
451 |
}
|
452 |
+
|
453 |
if ( get_post_meta( $post->ID, '_wpac_is_members_only', true ) && ! WordPressAccessControl::check_conditions( $post->ID ) ) {
|
454 |
if ( is_singular() ) {
|
455 |
$redirect_to = get_post_meta( $post->ID, '_wpac_members_redirect_to', true );
|
459 |
} else {
|
460 |
header( 'Location: ' . add_query_arg( 'redirect_to', $_SERVER['REQUEST_URI'], $redirect_to ) );
|
461 |
}
|
462 |
+
|
463 |
exit();
|
464 |
}
|
465 |
}
|
468 |
function check_for_nonmembers_only()
|
469 |
{
|
470 |
if ( is_admin() ) return;
|
471 |
+
|
472 |
global $post;
|
473 |
|
474 |
if ( get_post_meta( $post->ID, '_wpac_is_nonmembers_only', true ) && ! WordPressAccessControl::check_conditions( $post->ID ) ) {
|
483 |
exit();
|
484 |
}
|
485 |
}
|
486 |
+
|
487 |
function remove_excerpt( $excerpt )
|
488 |
{
|
489 |
if ( is_admin() || is_single() ) return $excerpt;
|
490 |
+
|
491 |
global $post;
|
492 |
+
|
493 |
if ( get_post_meta( $post->ID, '_wpac_is_members_only', true ) && ! WordPressAccessControl::check_conditions( $post->ID ) ) {
|
494 |
$show_excerpt = get_post_meta( $post->ID, '_wpac_show_excerpt_in_search', true );
|
495 |
+
|
496 |
if ( ! is_singular() && $show_excerpt != 'yes' ) {
|
497 |
if ( $post->post_type == 'post' ) {
|
498 |
$excerpt = get_option( 'wpac_post_excerpt_text', __( 'To view the contents of this post, you must be authenticated and have the required access level.', 'wpac' ) );
|
499 |
} else {
|
500 |
$excerpt = get_option( 'wpac_page_excerpt_text', __( 'To view the contents of this page, you must be authenticated and have the required access level.', 'wpac' ) );
|
501 |
}
|
502 |
+
|
503 |
return wpautop( $excerpt );
|
504 |
} else {
|
505 |
return $excerpt;
|
506 |
}
|
507 |
}
|
508 |
+
|
509 |
return $excerpt;
|
510 |
}
|
511 |
|
512 |
+
function posts_join_paged( $join, $query )
|
513 |
{
|
514 |
global $wpdb;
|
515 |
+
|
516 |
if ( is_admin() ) return $join;
|
517 |
+
|
518 |
if ( ! is_singular() && ! is_admin() ) {
|
519 |
$join .= " LEFT JOIN {$wpdb->postmeta} PMWPAC3 ON PMWPAC3.post_id = {$wpdb->posts}.ID AND PMWPAC3.meta_key = '_wpac_show_in_search' LEFT JOIN {$wpdb->postmeta} PMWPAC ON PMWPAC.post_id = {$wpdb->posts}.ID AND PMWPAC.meta_key = '_wpac_is_members_only' LEFT JOIN {$wpdb->postmeta} PMWPAC2 ON PMWPAC2.post_id = {$wpdb->posts}.ID AND PMWPAC2.meta_key = '_wpac_is_nonmembers_only' ";
|
520 |
}
|
521 |
+
|
522 |
return $join;
|
523 |
}
|
524 |
+
|
525 |
+
function posts_where_paged( $where, $query )
|
526 |
{
|
527 |
global $wpdb;
|
528 |
+
|
529 |
if ( is_admin() ) return $where;
|
530 |
+
|
531 |
if ( ! is_singular() && ! is_admin() ) {
|
532 |
if ( ! is_user_logged_in() ) {
|
533 |
$where .= " AND ( PMWPAC.meta_value IS NULL OR PMWPAC3.meta_value = '1' OR PMWPAC.meta_value != 'true' ) ";
|
535 |
$where .= " AND ( PMWPAC2.meta_value IS NULL OR PMWPAC2.meta_value != 'true' ) ";
|
536 |
}
|
537 |
}
|
538 |
+
|
539 |
return $where;
|
540 |
}
|
541 |
|
543 |
{
|
544 |
return $posts;
|
545 |
echo $query->request;exit();
|
546 |
+
|
547 |
if ( ! is_singular() && ! is_admin() ) {
|
548 |
$new_posts = array();
|
549 |
|
553 |
if ( get_post_meta( $post->ID, '_wpac_show_in_search', true ) != 1 ) {
|
554 |
continue;
|
555 |
}
|
556 |
+
}
|
557 |
+
|
558 |
// The page is non-members only and we do NOT have access to it
|
559 |
if ( get_post_meta( $post->ID, '_wpac_is_nonmembers_only', true ) && ! WordPressAccessControl::check_conditions( $post->ID ) ) {
|
560 |
if ( get_post_meta( $post->ID, '_wpac_show_in_search', true ) != 1 ) {
|
561 |
continue;
|
562 |
}
|
563 |
}
|
564 |
+
|
565 |
// Remove results where the search term is in a [member] or [nonmember] tag and we don't have access
|
566 |
$st = get_search_query();
|
567 |
$content = do_shortcode( $post->post_content );
|
568 |
+
|
569 |
+
|
570 |
if ( ! empty( $st ) && is_search() && ! stristr( $content, $st ) ) {
|
571 |
continue;
|
572 |
}
|
573 |
+
|
574 |
$new_posts[] = $post;
|
575 |
}
|
576 |
|
578 |
$query->max_num_pages = ceil( count( $new_posts ) / $query->query_vars['posts_per_page'] );
|
579 |
$query->posts = $new_posts;
|
580 |
$query->post_count = count( $new_posts );
|
581 |
+
|
582 |
return $new_posts;
|
583 |
}
|
584 |
+
|
585 |
return $posts;
|
586 |
}
|
587 |
|
610 |
function add_wpac_meta_box()
|
611 |
{
|
612 |
global $post;
|
613 |
+
|
614 |
$is_members_only = get_post_meta( $post->ID, '_wpac_is_members_only', true );
|
615 |
$is_nonmembers_only = get_post_meta( $post->ID, '_wpac_is_nonmembers_only', true );
|
616 |
+
|
617 |
if ( $post->post_type == 'post' ) {
|
618 |
$wpac_default_post_state = get_option( 'wpac_default_post_state', 'public' );
|
619 |
} else {
|
620 |
$wpac_default_post_state = get_option( 'wpac_default_page_state', 'public' );
|
621 |
}
|
622 |
+
|
623 |
if ( $is_members_only == 'true' || ( $post->post_status == 'auto-draft' && $wpac_default_post_state == 'members' ) ) {
|
624 |
$is_members_only = 'checked="checked"';
|
625 |
}
|
627 |
if ( $is_nonmembers_only == 'true' || ( $post->post_status == 'auto-draft' && $wpac_default_post_state == 'nonmembers' ) ) {
|
628 |
$is_nonmembers_only = 'checked="checked"';
|
629 |
}
|
630 |
+
|
631 |
$wpac_show_in_search = get_post_meta( $post->ID, '_wpac_show_in_search', true );
|
632 |
$wpac_show_excerpt_in_search = get_post_meta( $post->ID, '_wpac_show_excerpt_in_search', true );
|
633 |
$pass_to_children = get_post_meta( $post->ID, '_wpac_pass_to_children', true );
|
656 |
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
657 |
return $post_id;
|
658 |
}
|
659 |
+
|
660 |
if ( isset( $_POST['members_only'] ) && $_POST['members_only'] == 'true' ) {
|
661 |
update_post_meta( $post_id, '_wpac_is_members_only', 'true' );
|
662 |
|
697 |
|
698 |
if ( isset( $_POST['pass_to_children'] ) && $_POST['pass_to_children'] == 'true' ) {
|
699 |
update_post_meta( $post_id, '_wpac_pass_to_children', 'true' );
|
700 |
+
|
701 |
$original_id = $post_id;
|
702 |
$is_revision = wp_is_post_revision( $original_id );
|
703 |
+
|
704 |
if ( $is_revision ) {
|
705 |
$original_id = $is_revision;
|
706 |
}
|
713 |
} else {
|
714 |
delete_post_meta( $post_id, '_wpac_pass_to_children' );
|
715 |
}
|
716 |
+
|
717 |
return $post_id;
|
718 |
}
|
719 |
+
|
720 |
/**
|
721 |
* Replaces the default WordPress nav menu walker with our own version
|
722 |
*
|
752 |
|
753 |
return $args;
|
754 |
}
|
755 |
+
|
756 |
/**
|
757 |
* This hooks in at a higher level to make sure functions like wp_list_pages
|
758 |
* won't return members only pages.
|
759 |
+
*
|
760 |
* @param array $pages
|
761 |
* @return array
|
762 |
*
|
769 |
if ( is_admin() ) {
|
770 |
return $pages;
|
771 |
}
|
772 |
+
|
773 |
// Whether or not the user is logged in
|
774 |
$auth = is_user_logged_in();
|
775 |
|
789 |
|
790 |
return $pages;
|
791 |
}
|
792 |
+
|
793 |
/**
|
794 |
* Adds links to the plugin row to view the options page or view the plugin
|
795 |
* documentation.
|
806 |
* @since WordPress Access Control 3.0
|
807 |
* @author Brandon Wamboldt <brandon.wamboldt@gmail.com>
|
808 |
*/
|
809 |
+
function plugin_row_meta( $plugin_meta, $plugin_file, $plugin_data, $status )
|
810 |
{
|
811 |
if ( $plugin_file == str_replace( '.php', '/', basename( __FILE__ ) ) . basename( __FILE__ ) ) {
|
812 |
$plugin_meta[] = '<a href="options-general.php?page=wpac-options">' . __( 'Visit options page', 'wpac' ) . '</a>';
|
813 |
$plugin_meta[] = '<a href="' . plugin_dir_url( __FILE__ ) . 'documentation/index.html">' . __( 'Plugin Documentation', 'wpac' ) . '</a>';
|
814 |
}
|
815 |
+
|
816 |
return $plugin_meta;
|
817 |
}
|
818 |
+
|
819 |
+
|
820 |
/**
|
821 |
* Hides content for users that are not logged in and displays content for
|
822 |
* users who are logged in. Calls do_shortcode on the content to allow
|
829 |
* @since WordPress Access Control 3.0
|
830 |
* @author Brandon Wamboldt <brandon.wamboldt@gmail.com>
|
831 |
*/
|
832 |
+
function shortcode_members( $attributes, $content = NULL )
|
833 |
{
|
834 |
+
global $current_user, $post;
|
835 |
+
|
836 |
if ( is_user_logged_in() ) {
|
837 |
+
if (isset($attributes['role'])) {
|
838 |
+
if (!in_array($attributes['role'], $current_user->roles)) {
|
839 |
+
return '';
|
840 |
+
}
|
841 |
+
}
|
842 |
+
|
843 |
return wpautop( do_shortcode( $content ) );
|
844 |
}
|
845 |
+
|
846 |
return '';
|
847 |
}
|
848 |
+
|
849 |
/**
|
850 |
* Hides content for users that are logged in and displays content for users
|
851 |
* who are not logged in. Calls do_shortcode on the content to allow nested
|
858 |
* @since WordPress Access Control 3.0
|
859 |
* @author Brandon Wamboldt <brandon.wamboldt@gmail.com>
|
860 |
*/
|
861 |
+
function shortcode_nonmembers( $attributes, $content = NULL )
|
862 |
{
|
863 |
global $post;
|
864 |
+
|
865 |
if ( ! is_user_logged_in() ) {
|
866 |
return wpautop( do_shortcode( $content ) );
|
867 |
}
|
868 |
+
|
869 |
return '';
|
870 |
}
|
871 |
+
|
872 |
/*
|
873 |
* Loads a file that will override certain WordPress default widgets with
|
874 |
* a slightly modified version that allows admins to select it's visibility
|
881 |
{
|
882 |
require( dirname( __FILE__ ) . '/default-widgets.php' );
|
883 |
}
|
884 |
+
|
885 |
/**
|
886 |
* Adds our member only menus for each regular menu
|
887 |
*
|
891 |
function add_wpac_nav_menus()
|
892 |
{
|
893 |
global $_wp_registered_nav_menus;
|
894 |
+
|
895 |
$original = (array) $_wp_registered_nav_menus;
|
896 |
+
|
897 |
foreach ( $original as $location => $label ) {
|
898 |
$_wp_registered_nav_menus[$location . '_wpac'] = $label . ' - Members Only';
|
899 |
}
|
900 |
}
|
901 |
+
|
902 |
/**
|
903 |
* Checks to see if a members only version of the current menu is available
|
904 |
* and will load that instead of the normal menu.
|
918 |
{
|
919 |
// Don't do anything if the user isn't logged in
|
920 |
if ( is_user_logged_in() ) {
|
921 |
+
|
922 |
// See if the theme even passed a proper menu ID
|
923 |
if ( ! empty( $args['theme_location'] ) ) {
|
924 |
+
|
925 |
+
// Member only menus end in _wpac
|
926 |
$theme_location = $args['theme_location'] . '_wpac';
|
927 |
+
|
928 |
// Get the nav menu based on the theme_location
|
929 |
if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $theme_location ] ) ) {
|
930 |
$menu = wp_get_nav_menu_object( $locations[ $theme_location ] );
|
931 |
+
|
932 |
// Only use the member only menu if it's not empty
|
933 |
+
if ( $menu && $menu->count > 0 ) {
|
934 |
$args['theme_location'] = $theme_location;
|
935 |
}
|
936 |
}
|
937 |
}
|
938 |
}
|
939 |
+
|
940 |
return $args;
|
941 |
}
|
942 |
+
}
|