PluginProbe ʕ •ᴥ•ʔ
Hustle – Email Marketing, Lead Generation, Optins, Popups / 7.8.14
Hustle – Email Marketing, Lead Generation, Optins, Popups v7.8.14
7.8.14 7.8.14.1 7.8.13 7.8.13.1 trunk 3.0 3.1 3.1.1 3.1.2 3.1.3 3.1.4 4.3.2 4.4.4 4.4.5 4.4.5.1 4.4.5.4 4.6 4.6.1.1 4.6.1.4 4.7.0.2 4.7.0.3 4.7.0.7 4.7.0.9 4.7.1.0 4.7.1.1 4.8.0.0 5.0.0 5.0.1 5.0.1.1 5.0.1.2 5.1 5.1.1 5.1.2 5.1.3 5.1.3.1 5.1.3.2 5.1.4 5.1.5 6.0 6.0.1 6.0.2 6.0.3 6.0.4.2 6.0.5 6.0.6.1 6.0.7 6.0.8.1 6.0.9 7.0.0.1 7.0.2 7.0.3 7.0.4 7.1.0 7.1.1 7.2.0 7.2.1 7.3.0 7.3.1 7.3.3 7.3.5 7.3.6 7.3.7 7.4.0 7.4.1 7.4.11 7.4.13 7.4.13.1 7.4.2 7.4.3 7.4.4 7.4.5 7.4.5.1 7.4.5.2 7.4.6 7.4.7 7.5.0 7.6.0 7.6.1 7.6.3 7.6.4 7.6.6 7.7.0 7.7.1 7.8.0 7.8.1 7.8.10 7.8.10.1 7.8.10.2 7.8.11 7.8.12 7.8.12.1 7.8.2 7.8.3 7.8.4 7.8.5 7.8.6 7.8.7 7.8.8 7.8.9 7.8.9.1 7.8.9.2 7.8.9.3
wordpress-popup / inc / display-conditions / class-opt-in-condition-categories.php
wordpress-popup / inc / display-conditions Last commit date
class-opt-in-condition-abstract.php 5 months ago class-opt-in-condition-archive-pages.php 5 months ago class-opt-in-condition-categories.php 5 months ago class-opt-in-condition-cookie-set.php 3 years ago class-opt-in-condition-cpt.php 4 years ago class-opt-in-condition-from-referrer.php 4 years ago class-opt-in-condition-on-browser.php 3 years ago class-opt-in-condition-on-url.php 5 months ago class-opt-in-condition-page-templates.php 4 years ago class-opt-in-condition-pages.php 5 months ago class-opt-in-condition-posts.php 4 years ago class-opt-in-condition-shown-less-than.php 3 years ago class-opt-in-condition-source-of-arrival.php 5 months ago class-opt-in-condition-tags.php 5 months ago class-opt-in-condition-user-registration.php 5 months ago class-opt-in-condition-user-roles.php 5 months ago class-opt-in-condition-visitor-commented.php 5 years ago class-opt-in-condition-visitor-country.php 5 years ago class-opt-in-condition-visitor-device.php 6 years ago class-opt-in-condition-visitor-logged-in-status.php 5 months ago class-opt-in-condition-wc-archive-pages.php 5 months ago class-opt-in-condition-wc-categories.php 5 months ago class-opt-in-condition-wc-pages.php 5 months ago class-opt-in-condition-wc-static-pages.php 5 months ago class-opt-in-condition-wc-tags.php 5 months ago class-opt-in-condition-wp-conditions.php 5 months ago
class-opt-in-condition-categories.php
76 lines
1 <?php
2 /**
3 * Opt_In_Condition_Categories class.
4 *
5 * @package Hustle
6 * @since unwknown
7 */
8
9 /**
10 * Class Opt_In_Condition_Categories.
11 * Handles posts categories.
12 *
13 * @since unknown
14 */
15 class Opt_In_Condition_Categories extends Opt_In_Condition_Abstract {
16
17 /**
18 * Returns whether the condition was met.
19 *
20 * @since unknwon
21 */
22 public function is_allowed() {
23
24 $selected_categories = ! empty( $this->args->categories ) ? (array) $this->args->categories : array();
25 $filter_type = isset( $this->args->filter_type ) && in_array( $this->args->filter_type, array( 'only', 'except' ), true )
26 ? $this->args->filter_type : 'except';
27
28 $current_categories = $this->get_current_categories();
29
30 // There was an error retrieving the categories.
31 if ( is_null( $current_categories ) ) {
32 return false;
33 }
34
35 if ( 'except' === $filter_type ) {
36
37 // The current post has no categories.
38 // Matching "all categories except: {any|none}". We're matching only posts with at least 1 category.
39 if ( empty( $current_categories ) ) {
40 return false;
41 }
42
43 return array() === array_intersect( $current_categories, $selected_categories );
44
45 } else {
46
47 // No categories were selected and the current post has no categories.
48 // Matching "only these categories: {none}". We're matching only posts with no categories.
49 if ( empty( $current_categories ) && empty( $selected_categories ) ) {
50 return true;
51 }
52
53 return array() !== array_intersect( $current_categories, $selected_categories );
54 }
55 }
56
57 /**
58 * Returns categories of current page|post
59 *
60 * @since 2.0.0
61 * @return null|array
62 */
63 private function get_current_categories() {
64 $post = self::get_post();
65 if ( ! isset( $post ) || ! ( $post instanceof WP_Post )
66 || ! in_array( $post->post_type, array( 'page', 'post' ), true )
67 || ! self::check( 'is_singular' ) ) {
68 return null;
69 }
70
71 $terms = get_the_terms( $post, 'category' );
72 $term_ids = $terms && ! is_wp_error( $terms ) ? wp_list_pluck( $terms, 'term_id' ) : array();
73 return array_map( 'strval', $term_ids );
74 }
75 }
76