Table of Contents

lib/class-wc-settings-additional-field-types.php 2
lib/class-wc-settings-plugin-promo.php 1
lib/Plugin/Admin/Admin_Links.php 5
lib/Plugin/Admin/Plugin_Updater.php 9
lib/Plugin/License/Admin/edd-settings-functions.php 4
lib/Plugin/License/Admin/License_Key_Setting.php 14
lib/Plugin/License/Admin/License_Notices.php 9
lib/Plugin/License/EDD_Licensing.php 5
lib/Plugin/License/Plugin_License.php 46
lib/Plugin/Premium_Plugin.php 1
lib/Plugin/Simple_Plugin.php 2
lib/Scheduled_Task.php 3
lib/Util.php 4
lib/vendor/admin-notices/src/Dismiss.php 14
lib/vendor/admin-notices/src/Notice.php 22
lib/vendor/admin-notices/src/Notices.php 5
src/Admin/Admin_Controller.php 2
src/Admin/Category_Visibility_Setting.php 12
src/Admin/Settings_Page.php 10
src/Category_Prefixer.php 3
src/Category_Protector.php 40
src/Category_Visibility.php 22
src/deprecated.php 3
src/Integration/Theme_Compat.php 3
src/Login_Shortcode.php 1
src/Loop_Buffer.php 3
src/Password_Form.php 9
src/Plugin.php 8
src/template-functions.php 2
src/Template_Handler.php 16
src/Util.php 15
woocommerce-protected-categories.php 6


Type Line Description
27 Redo the description as WC runs wp_kes_post() on it which messes up any inline CSS
92 Get current values


Type Line Description
42 Check we're on the correct settings section


Type Line Description
30 Add settings link from Plugins page.
33 Add documentation link to meta info on Plugins page.
42 Don't add link if it's a WooCommerce plugin but WooCommerce is not active.
47 Don't add link if it's an EDD plugin but EDD is not active.
61 Bail if there's no documentation URL.


Type Line Description
70 First check if plugin info already exists in the WP transient.
114 Add note about license key if no automatic update available (i.e. no update package).
138 Make sure the plugin property is set to the plugin's name/location. See issue 1463 on Software Licensing's GitHub repo.
141 Add an ID for the update details.
144 Check the license before returning.
157 Prevent automatic plugin update if license is invalid. Clearing the package URL will do this.
165 First check the cache.
169 Nothing in cache, so get latest version from API.
193 We cache the version info for 4 hours, to reduce the number of API requests.


Type Line Description
5 Prevent direct access.
23 Change setting back to a 'text' input. We set the type to 'barn2_license' initially so we can provide our own callback.
26 Settings_API_Helper uses input_class instead of class.
30 Ensure a default is set.


Type Line Description
41 Include EDD settings callbacks.
44 Handle the license settings message for EDD.
47 Add hidden field to WooCommerce settings.
99 EDD uses title case for setting names, so let's keep things consistent.
102 Set type to 'barn2_license' so the callback to render setting will be 'edd_barn2_license_callback'.
105 EDD uses 'name' instead of 'title'.
150 Deactivate old license key first if it was valid.
155 If new license key is different to current key, or current key isn't active, attempt to activate.
186 Clear any other messages (e.g. 'Settings Updated') so we only show our license message.
189 Need to use 'edd-notices' setting to get message to show in EDD settings pages.
198 Check if we're overriding the license activation.
240 @todo: Spinner icon
250 If we have a license key and it's not active, mark it red for user to take action.
252 ...except if the user has just deactivated, in which case just show a plain confirmation message.


Type Line Description
41 Don't add notices if we're doing a post (e.g. saving the settings).
49 Add first activation notice.
52 Add expired license notice.
55 Add disabled license notice
58 Add 'site moved to new URL' notice.
64 Don't add the notice if it's a WooCommerce plugin and WooCommerce is not installed, as license page won't be available.
69 Ditto for EDD plugins.
156 Clear notice dismissal transients when license is activated.
180 Check data is valid.


Type Line Description
142 We're forced to use the (potentially usafe) maybe_unserialize here as the
143 EDD Software Licensing API serializes some of the returned plugin data.
152 Call the Software Licensing API.
160 Build the result.


Type Line Description
45 early, before any is_valid() checks.
57 A 'valid' license is one which is active or expired.
58 For expired licenses the plugin will still work (i.e. is valid) but plugin updates will be disabled.
130 Check a license was supplied.
147 Successful response - now check whether license is valid.
150 $response->license will be 'valid' or 'invalid'.
157 Invalid license.
162 Store the returned license info.
165 API error - set license to invalid as we can't activate.
182 Bail early if already inactive.
187 If license is overridden bypass API and set status manually.
193 We can't deactivate a license if it's not currently active.
204 Successful response - now check whether license is valid.
208 $response->license will be 'deactivated' or 'failed'.
210 License deactivated, so update status.
213 Store returned license info.
217 Deactivation failed - reasons: already deactivated via Account page, license has expired, bad data, etc.
218 In this case we refresh license data to ensure we have correct state stored in database.
224 API error
240 No point refreshing if license doesn't exist.
245 If license is overridden, we shouldn't refresh as it will lose override state.
254 We use the home url when checking the license, as the license result should reflect the current site, not any previous site.
258 Successful response returned.
262 Valid (and active) license.
265 Invalid license - $response->license will contain the reason for the invalid license - e.g. expired, inactive, site_inactive, etc.
270 Store returned license info.
275 API error - store the error but don't change license status (e.g. temporary communication error).
357 See if we have a valid expiry date by checking first 4 chars are numbers (the expiry year).
358 This is only a rough check - createFromFormat() will validate fully and return a DateTime object if valid.
400 Exclude overridden licenses - we don't want to automatically deactivate these or show admin notice to user.
438 Migrate from legacy license data.
454 Remove legacy license data.
466 We don't use home_url() here as this runs the 'home_url' filter which other plugins hook into (e.g. multi-lingual plugins).
485 To lowercase.
488 Strip www.
489 www.', ':/www.' ), '://', $url );
491 Strip scheme.
492 ', 'https://', 'http:/', 'https:/' ), '', $url );
494 Remove trailing slash.
537 Clear any previous error before updating.
541 Merge current data with new $data before setting.
553 License is invalid if there's no license key.
579 License info should always return the expiry date, so it's considered valid if this is present.
581 Cast response to array.
584 Remove the stuff we don't need.
597 Status is sanitized during update_license_data().


Type Line Description
70 Default to plugin settings URL if there's no license setting path.


Type Line Description
41 Check for 'item_id' in case 'id' not set.
46 WooCommerce plugins cannot be EDD plugins (and vice-versa).


Type Line Description
25 Attach the action to run when the cron event is fired.
28 Schedule the cron event if not already scheduled.
33 Unschedule event on plugin deactivation.


Type Line Description


Type Line Description
1 phpcs:ignore WordPress.Files.FileName
8 GPL-2.0-or-later
58 Set the object properties.
63 Handle AJAX requests to dismiss the notice.
76 Create a nonce.
83 Add an event listener to the dismiss button.
88 Build the data to send in our request.
89 Data has to be formatted as a string here.
112 Check if the notice has been dismissed when using user-meta.
130 Sanity check: Early exit if we're not on a wptrt_dismiss_notice action.
135 Sanity check: Early exit if the ID of the notice is not the one from this object.
140 Security check: Make sure nonce is OK.
143 If we got this far, we need to dismiss the notice.


Type Line Description
1 phpcs:ignore WordPress.Files.FileName
10 GPL-2.0-or-later
128 Set the object properties.
134 Sanity check: Early exit if ID or message are empty.
148 Instantiate the Dismiss object.
161 Early exit if we don't want to show this notice.
169 Print the notice.
172 The ID.
173 The classes.
174 The HTML.
187 Don't show if the user doesn't have the required capability.
192 Don't show if we're not on the right screen.
197 Don't show if notice has been dismissed.
218 Make sure the defined type is allowed.
221 Add the class for notice-type.
224 Do we want alt styles?
229 Combine classes to a string.
242 Sanity check: Early exit if no title is defined.
273 If screen is empty we want this shown on all screens.
278 Make sure the get_current_screen function exists.
283 Check if we're on one of the defined screens.


Type Line Description
1 phpcs:ignore WordPress.Files.FileName
10 GPL-2.0-or-later
43 Add the notice.
46 Print the script to the footer.


Type Line Description
39 Back-compat: selectWoo was introducted in WC 3.2
56 Plugin settings or edit category screen.


Type Line Description
19 Add visibility field
23 Save visibility field
27 Add visibility column to product category table
71 Bail if no visibility to save (e.g. on 'quick edit')
79 Remove existing meta for this category
85 If no protection options set, revert to public visibility.
88 Passwords
92 Filter array to remove any empty inputs
96 Set default password in case none was entered
103 User roles
109 Users
180 If there are no passwords, add an empty one so we always display at least one password input


Type Line Description
30 Register our custom settings types.
34 Back compat.
42 Add the plugin settings.
46 Save the settings.
51 Add plugin promo section.
64 Check we're on the correct settings section.
218 settings array
236 Check we're saving the correct option.
241 Add the login shortcode to selected page.
258 Remove from old page, if we have one.


Type Line Description
23 Prefix category titles (i.e. 'Private' or 'Protected' prefix).
26 Prefix menu items.
31 'wp_head' check prevents adjustment inside <title> tag


Type Line Description
23 Adjust query to exclude products in private or protected categories
26 Protect products in WC shortcodes
29 Protect product categories, e.g. in product categories widget
32 Adjust category counts - priority 15 to run after 'wc_change_term_counts' filter
35 Protect categories and products in nav menus
38 Ensure protected products are not purchasable
44 Query is for product post type
46 Search results page
48 Product category, product tag or other archive (e.g. product attribute)
50 Main shop page
59 Exclude protected categories from query used in shortcode
70 Check we have the right taxonomy
75 Bail if our internal flag is set ('wc_ppc')
80 Bail if we're getting the terms for one or more objects
85 Bail if 'get' => 'all' set, e.g. when getting the term hierarchy or get_term_by() called
90 Bail if we're building the exclusions list within get_terms() itself.
91 get_terms() is recursive when 'exclude_tree' is specified so we need to check here to avoid an infinite loop.
96 Fix WP bug where 'include' is set to the non-empty array "Array ( [0] => null )"
101 Bail if 'include' is set, as 'exclude_tree' will be ignored.
106 Bail if there are no hidden categories.
111 Merge in any other exclude trees.
122 Bail if there are no terms, we have the wrong taxonomy, we're not padding term counts, or we're not returning term objects
127 Adjust category counts - loop through each top-level category or sub-category
130 Get number of (unique) products in the hidden child categories
145 Back-compat - default nav menu visibility to the same as main visibility setting
153 Product menu item
156 Product category menu item
168 Now find and remove any children of any removed menu item - simples!
179 Update the removed list with the removed child items and start over
201 Bail early if no categories to protect.
206 Is there already a tax query present?
208 If current tax query is an 'OR' we need to nest it and wrap our query outside with an 'AND' relation
224 If we have unlocked categories, we need to ensure that these are not parents of a hidden category.
225 In this case, the hidden category will take precedence over the unlocked parent, as it's lower in the category hierarchy.
228 Get the ancestors for each hidden category.
233 Remove duplicates.
236 Now remove any hidden ancestors from the list of unlocked categories.
239 If we still have unlocked categories, make sure we include these (IN) in our tax query.
261 Get all the product categories, and check which are hidden.
275 Get all the product categories, and check which are unlocked.


Type Line Description
26 Default to public if visibility not set.
31 Back-compat
39 Back-compat - for passwords stored as separate meta items
60 Lazy loaded so we only do this once
201 Only check ancestors if flag set and this category is public
229 If this category itself is unlocked, then it's not protected (regardless of parent protection level).
234 Only check ancestors if flag set and this category itself is not protected.
258 It's not password protected if the correct password has been entered
263 Only check ancestors if flag set and this category itself is not password protected
288 Only check ancestors if flag set and this category itself is not role protected
313 Only check ancestors if flag set and this category itself is not user protected
342 Only check ancestors if flag set and this category itself is not private
354 Getters
384 Can't be unlocked by password if it's not password protected.
391 Can't be unlocked by password if there's no cookie set.
397 Term ID doesn't match, so not valid.
401 Valid cookie, so now check password.
407 Correct password, so category is unlocked.
416 If there are no roles, then it can't be unlocked by role.
426 If there's a role overlap, then the current user has at least one of the required roles, so category is unlocked.
434 If there are no users, then it can't be unlocked by user.
450 @todo: Create 'read_private_product_categories' cap and inherit settings from 'read_private_products'.


Type Line Description
3 Prevent direct file access
32 @todo: Deprecate after next WPT update
33 _deprecated_function( __FUNCTION__, '2.4', 'Barn2\\Plugin\\WC_Protected_Categories\\wpc()' );


Type Line Description
27 Prefix title for Qode themes, e.g. Bridge.
33 Reset Avada's page ID so it picks up our spoofed ID later.
39 Kallyas theme - hide the title/subtitle for private products.


Type Line Description
50 If these args are set to false, unset them so we use defaults from the plugin settings.


Type Line Description
34 Discard buffered content
37 Show the password form
40 Reset buffering


Type Line Description
41 Bail if we're not loading a front-end template, or password form not submitted.
60 Form submitted from central login page, shortcode or widget, so we fetch all categories.
63 Form submitted from a product catetory.
66 Form submitted from a single product.
74 Check the password against each category.
77 Got a valid password, so set password cookie then redirect.
121 If we have a password label, add a space after to align the form better
172 Check the passed form ID matches the one in $_POST
183 If we have a password, and we're doing a POST request (therefore we haven't redirected), then the password must be wrong.


Type Line Description
61 Don't load anything if WooCommerce not active.
67 before WC includes wc-template-functions.php
78 Create the admin service.
83 Create core services if license is valid.
96 Ingegrations
119 Cookie has to be same one used by WP for password protected posts, as all caching plugins exclude it.
125 Everything is autoloaded, apart from the following...
137', true ), '</a>' ),


Type Line Description
2 Prevent direct file access
11 Override WooCommerce template function to show the subcategory title inside the product loop.


Type Line Description
27 Run on 'wp' hook so we can set cache constants.
28 after Password_Form->do_login()
34 Return if we're not loading a template on the front-end.
48 If central login page is the main shop page, hide all products/categories (the shortcode will handle display of form).
53 before ordering & results count
54 after pagination
79 attempt to avoid clash with a valid post
90 important
91 append post ID to avoid clash
98 Convert to WP_Post object
101 Add our fake post to the cache
105 Override main query
143 Update globals
147 Add body class for the password login page.
208 Set headers to prevent caching
211 Set constants to prevent caching in certain caching plugins


Type Line Description
22 Arguments for get_terms changed in WP 4.5
173 We found something protected, so no point continuing up ancestor tree; break and continue to next category.
191 Shouldn't ever get here, but return false (not protected) just in case.
218 Double-check we have a valid number of days
231 Cookie is stored in this format: <term id>|<password hash>
244 Cookie not in correct format (e.g. password protected post).
252 Invalid term ID.
257 Invalid password hash.


Type Line Description
32 Prevent direct file access
40 Include autoloader.
52 Load the plugin.

Search results