if ('click' == $popup->display) { if (!isset($script_data['script'])) { $script_data['script'] = ''; } $script_data['script'] .= 'me.custom_handler = ' . $this->script_on_click(); } return $script_data; } /** * Returns the javascript code that triggers the click event. * * @since 4.6 */ public function script_on_click() { ob_start(); ?> function( me ) { if ( me.data.display_data['click_multi'] ) { jQuery(document).on( 'click', me.data.display_data['click'], me.show_popup ); } else { jQuery(document).one( 'click', me.data.display_data['click'], me.show_popup ); } } <?php $code = ob_get_clean(); return $code; } } IncPopupRules::register('IncPopupRule_Events');
$qget[trim($kv[0])] = trim($kv[1]); } } if (isset($qget['source'])) { $response = $qget['source'] == 'web'; } return $response; } /** * Returns the referrer. * * @since 4.6 * @return string */ public function get_referrer() { $referrer = ''; $is_ajax = defined('DOING_AJAX') && DOING_AJAX || !empty($_POST['_po_method_']) && 'raw' == $_POST['_po_method_']; if (isset($_REQUEST['thereferrer'])) { $referrer = $_REQUEST['thereferrer']; } else { if (!$is_ajax && isset($_SERVER['HTTP_REFERER'])) { // When doing Ajax request we NEVER use the HTTP_REFERER! $referrer = $_SERVER['HTTP_REFERER']; } } return $referrer; } } IncPopupRules::register('IncPopupRule_Referrer');
== == == HELPER FUNCTIONS == == == ========================================== \*======================================*/ /** * Sanitizes the data parameter so it can be savely used by other functions. * * @since 4.6 * @param mixed $data * @return array */ protected function sanitize_values($data) { if (is_numeric($data)) { $data = array('min' => $data, 'max' => $this->max_width); } else { if (!is_array($data)) { $data = array(); } } $data['min'] = absint(@$data['min']); $data['max'] = absint(@$data['max']); if (!$data['max'] || $data['max'] < $data['min']) { $data['max'] = $this->max_width; } return $data; } } IncPopupRules::register('IncPopupRule_Width');
/** * Registers a rule. * * @since 4.6 * @param string $id * @param string $label * @param string $description * @param string $exclude * @param int $priority */ protected function add_rule($id, $label, $description, $exclude = '', $priority = 10) { IncPopupRules::add_rule($this, $this->filename, $id, $label, $description, $exclude, $priority); }
if (!function_exists('xprofile_get_field_data')) { return true; } if (empty($field)) { return true; } $user_value = xprofile_get_field_data($field, get_current_user_id(), 'comma'); $match = false; switch ($cond) { case 'regex_is': $match = preg_match("#{$po_value}#i", $user_value); break; case 'regex_not': $match = !preg_match("#{$po_value}#i", $user_value); break; case 'reverse': $match = $po_value != $user_value; break; default: $match = $po_value == $user_value; break; } if ($match) { return 'match' == $type; } else { return 'fail' == $type; } } } IncPopupRules::register('IncPopupRule_XProfile');
protected function form_no_prosite($data) { if (!$this->is_active) { $this->render_plugin_inactive(); } } /*======================================*\ ========================================== == == == HELPER FUNCTIONS == == == ========================================== \*======================================*/ /** * Displays a warning message in case the Membership plugin is not active. * * @since 1.0.0 */ protected function render_plugin_inactive() { ?> <div class="error below-h2"><p> <?php printf(__('This condition requires that the <a href="%s" target="_blank">' . 'Pro Sites Plugin</a> is installed and activated.', PO_LANG), 'http://premium.wpmudev.org/project/pro-sites/'); ?> </p></div> <?php } } IncPopupRules::register('IncPopupRule_Prosite');
public function check_url($test_url, $list) { $response = false; $list = array_map('trim', $list); $test_url = strtok($test_url, '#'); if (empty($list)) { $response = true; } else { foreach ($list as $match) { $match = preg_quote(strtok($match, '#')); if (false === strpos($match, '://')) { $match = '\\w+://' . $match; } if (substr($match, -1) != '/') { $match .= '/?'; } else { $match .= '?'; } $exp = '#^' . $match . '$#i'; $res = preg_match($exp, $test_url); if ($res) { $response = true; break; } } } return $response; } } IncPopupRules::register('IncPopupRule_Url');
* Apply the rule-logic to the specified popup * * @since 4.6 * @param mixed $data Rule-data which was saved via the save_() handler. * @return bool Decission to display popup or not. */ protected function apply_mobile($data) { return wp_is_mobile(); } /*===============================*\ =================================== == == == NO_MOBILE == == == =================================== \*===============================*/ /** * Apply the rule-logic to the specified popup * * @since 4.6 * @param mixed $data Rule-data which was saved via the save_() handler. * @return bool Decission to display popup or not. */ protected function apply_no_mobile($data) { return !wp_is_mobile(); } } IncPopupRules::register('IncPopupRule_Browser');
$type = @$_POST['type']; $ip = $this->get_users_ip(); $service = $this->get_service($type); if ('db' == $service->url) { IncPopupAddon_GeoDB::init(); $country = apply_filters('popup-get-country', $country, $ip); } else { $country = $this->country_from_api($ip, $service); } echo 'IP: ' . $ip . "\nService: " . $service->label . "\nCountry: " . $country; die; } /*----- Country list ------*/ /* country list array from http://snipplr.com/view.php?codeview&id=33825 */ public function country_list() { $Countries = null; if (null === $Countries) { $Countries = array('AU' => __('Australia', PO_LANG), 'AF' => __('Afghanistan', PO_LANG), 'AL' => __('Albania', PO_LANG), 'DZ' => __('Algeria', PO_LANG), 'AS' => __('American Samoa', PO_LANG), 'AD' => __('Andorra', PO_LANG), 'AO' => __('Angola', PO_LANG), 'AI' => __('Anguilla', PO_LANG), 'AQ' => __('Antarctica', PO_LANG), 'AG' => __('Antigua & Barbuda', PO_LANG), 'AR' => __('Argentina', PO_LANG), 'AM' => __('Armenia', PO_LANG), 'AW' => __('Aruba', PO_LANG), 'AT' => __('Austria', PO_LANG), 'AZ' => __('Azerbaijan', PO_LANG), 'BS' => __('Bahamas', PO_LANG), 'BH' => __('Bahrain', PO_LANG), 'BD' => __('Bangladesh', PO_LANG), 'BB' => __('Barbados', PO_LANG), 'BY' => __('Belarus', PO_LANG), 'BE' => __('Belgium', PO_LANG), 'BZ' => __('Belize', PO_LANG), 'BJ' => __('Benin', PO_LANG), 'BM' => __('Bermuda', PO_LANG), 'BT' => __('Bhutan', PO_LANG), 'BO' => __('Bolivia', PO_LANG), 'BA' => __('Bosnia/Hercegovina', PO_LANG), 'BW' => __('Botswana', PO_LANG), 'BV' => __('Bouvet Island', PO_LANG), 'BR' => __('Brazil', PO_LANG), 'IO' => __('British Indian Ocean Territory', PO_LANG), 'BN' => __('Brunei Darussalam', PO_LANG), 'BG' => __('Bulgaria', PO_LANG), 'BF' => __('Burkina Faso', PO_LANG), 'BI' => __('Burundi', PO_LANG), 'KH' => __('Cambodia', PO_LANG), 'CM' => __('Cameroon', PO_LANG), 'CA' => __('Canada', PO_LANG), 'CV' => __('Cape Verde', PO_LANG), 'KY' => __('Cayman Is', PO_LANG), 'CF' => __('Central African Republic', PO_LANG), 'TD' => __('Chad', PO_LANG), 'CL' => __('Chile', PO_LANG), 'CN' => __('China, People\'s Republic of', PO_LANG), 'CX' => __('Christmas Island', PO_LANG), 'CC' => __('Cocos Islands', PO_LANG), 'CO' => __('Colombia', PO_LANG), 'KM' => __('Comoros', PO_LANG), 'CG' => __('Congo', PO_LANG), 'CD' => __('Congo, Democratic Republic', PO_LANG), 'CK' => __('Cook Islands', PO_LANG), 'CR' => __('Costa Rica', PO_LANG), 'CI' => __('Cote d\'Ivoire', PO_LANG), 'HR' => __('Croatia', PO_LANG), 'CU' => __('Cuba', PO_LANG), 'CY' => __('Cyprus', PO_LANG), 'CZ' => __('Czech Republic', PO_LANG), 'DK' => __('Denmark', PO_LANG), 'DJ' => __('Djibouti', PO_LANG), 'DM' => __('Dominica', PO_LANG), 'DO' => __('Dominican Republic', PO_LANG), 'TP' => __('East Timor', PO_LANG), 'EC' => __('Ecuador', PO_LANG), 'EG' => __('Egypt', PO_LANG), 'SV' => __('El Salvador', PO_LANG), 'GQ' => __('Equatorial Guinea', PO_LANG), 'ER' => __('Eritrea', PO_LANG), 'EE' => __('Estonia', PO_LANG), 'ET' => __('Ethiopia', PO_LANG), 'FK' => __('Falkland Islands', PO_LANG), 'FO' => __('Faroe Islands', PO_LANG), 'FJ' => __('Fiji', PO_LANG), 'FI' => __('Finland', PO_LANG), 'FR' => __('France', PO_LANG), 'FX' => __('France, Metropolitan', PO_LANG), 'GF' => __('French Guiana', PO_LANG), 'PF' => __('French Polynesia', PO_LANG), 'TF' => __('French South Territories', PO_LANG), 'GA' => __('Gabon', PO_LANG), 'GM' => __('Gambia', PO_LANG), 'GE' => __('Georgia', PO_LANG), 'DE' => __('Germany', PO_LANG), 'GH' => __('Ghana', PO_LANG), 'GI' => __('Gibraltar', PO_LANG), 'GR' => __('Greece', PO_LANG), 'GL' => __('Greenland', PO_LANG), 'GD' => __('Grenada', PO_LANG), 'GP' => __('Guadeloupe', PO_LANG), 'GU' => __('Guam', PO_LANG), 'GT' => __('Guatemala', PO_LANG), 'GN' => __('Guinea', PO_LANG), 'GW' => __('Guinea-Bissau', PO_LANG), 'GY' => __('Guyana', PO_LANG), 'HT' => __('Haiti', PO_LANG), 'HM' => __('Heard Island And Mcdonald Island', PO_LANG), 'HN' => __('Honduras', PO_LANG), 'HK' => __('Hong Kong', PO_LANG), 'HU' => __('Hungary', PO_LANG), 'IS' => __('Iceland', PO_LANG), 'IN' => __('India', PO_LANG), 'ID' => __('Indonesia', PO_LANG), 'IR' => __('Iran', PO_LANG), 'IQ' => __('Iraq', PO_LANG), 'IE' => __('Ireland', PO_LANG), 'IL' => __('Israel', PO_LANG), 'IT' => __('Italy', PO_LANG), 'JM' => __('Jamaica', PO_LANG), 'JP' => __('Japan', PO_LANG), 'JT' => __('Johnston Island', PO_LANG), 'JO' => __('Jordan', PO_LANG), 'KZ' => __('Kazakhstan', PO_LANG), 'KE' => __('Kenya', PO_LANG), 'KI' => __('Kiribati', PO_LANG), 'KP' => __('Korea, Democratic Peoples Republic', PO_LANG), 'KR' => __('Korea, Republic of', PO_LANG), 'KW' => __('Kuwait', PO_LANG), 'KG' => __('Kyrgyzstan', PO_LANG), 'LA' => __('Lao People\'s Democratic Republic', PO_LANG), 'LV' => __('Latvia', PO_LANG), 'LB' => __('Lebanon', PO_LANG), 'LS' => __('Lesotho', PO_LANG), 'LR' => __('Liberia', PO_LANG), 'LY' => __('Libyan Arab Jamahiriya', PO_LANG), 'LI' => __('Liechtenstein', PO_LANG), 'LT' => __('Lithuania', PO_LANG), 'LU' => __('Luxembourg', PO_LANG), 'MO' => __('Macau', PO_LANG), 'MK' => __('Macedonia', PO_LANG), 'MG' => __('Madagascar', PO_LANG), 'MW' => __('Malawi', PO_LANG), 'MY' => __('Malaysia', PO_LANG), 'MV' => __('Maldives', PO_LANG), 'ML' => __('Mali', PO_LANG), 'MT' => __('Malta', PO_LANG), 'MH' => __('Marshall Islands', PO_LANG), 'MQ' => __('Martinique', PO_LANG), 'MR' => __('Mauritania', PO_LANG), 'MU' => __('Mauritius', PO_LANG), 'YT' => __('Mayotte', PO_LANG), 'MX' => __('Mexico', PO_LANG), 'FM' => __('Micronesia', PO_LANG), 'MD' => __('Moldavia', PO_LANG), 'MC' => __('Monaco', PO_LANG), 'MN' => __('Mongolia', PO_LANG), 'MS' => __('Montserrat', PO_LANG), 'MA' => __('Morocco', PO_LANG), 'MZ' => __('Mozambique', PO_LANG), 'MM' => __('Union Of Myanmar', PO_LANG), 'NA' => __('Namibia', PO_LANG), 'NR' => __('Nauru Island', PO_LANG), 'NP' => __('Nepal', PO_LANG), 'NL' => __('Netherlands', PO_LANG), 'AN' => __('Netherlands Antilles', PO_LANG), 'NC' => __('New Caledonia', PO_LANG), 'NZ' => __('New Zealand', PO_LANG), 'NI' => __('Nicaragua', PO_LANG), 'NE' => __('Niger', PO_LANG), 'NG' => __('Nigeria', PO_LANG), 'NU' => __('Niue', PO_LANG), 'NF' => __('Norfolk Island', PO_LANG), 'MP' => __('Mariana Islands, Northern', PO_LANG), 'NO' => __('Norway', PO_LANG), 'OM' => __('Oman', PO_LANG), 'PK' => __('Pakistan', PO_LANG), 'PW' => __('Palau Islands', PO_LANG), 'PS' => __('Palestine', PO_LANG), 'PA' => __('Panama', PO_LANG), 'PG' => __('Papua New Guinea', PO_LANG), 'PY' => __('Paraguay', PO_LANG), 'PE' => __('Peru', PO_LANG), 'PH' => __('Philippines', PO_LANG), 'PN' => __('Pitcairn', PO_LANG), 'PL' => __('Poland', PO_LANG), 'PT' => __('Portugal', PO_LANG), 'PR' => __('Puerto Rico', PO_LANG), 'QA' => __('Qatar', PO_LANG), 'RE' => __('Reunion Island', PO_LANG), 'RO' => __('Romania', PO_LANG), 'RU' => __('Russian Federation', PO_LANG), 'RW' => __('Rwanda', PO_LANG), 'WS' => __('Samoa', PO_LANG), 'SH' => __('St Helena', PO_LANG), 'KN' => __('St Kitts & Nevis', PO_LANG), 'LC' => __('St Lucia', PO_LANG), 'PM' => __('St Pierre & Miquelon', PO_LANG), 'VC' => __('St Vincent', PO_LANG), 'SM' => __('San Marino', PO_LANG), 'ST' => __('Sao Tome & Principe', PO_LANG), 'SA' => __('Saudi Arabia', PO_LANG), 'SN' => __('Senegal', PO_LANG), 'SC' => __('Seychelles', PO_LANG), 'SL' => __('Sierra Leone', PO_LANG), 'SG' => __('Singapore', PO_LANG), 'SK' => __('Slovakia', PO_LANG), 'SI' => __('Slovenia', PO_LANG), 'SB' => __('Solomon Islands', PO_LANG), 'SO' => __('Somalia', PO_LANG), 'ZA' => __('South Africa', PO_LANG), 'GS' => __('South Georgia and South Sandwich', PO_LANG), 'ES' => __('Spain', PO_LANG), 'LK' => __('Sri Lanka', PO_LANG), 'XX' => __('Stateless Persons', PO_LANG), 'SD' => __('Sudan', PO_LANG), 'SR' => __('Suriname', PO_LANG), 'SJ' => __('Svalbard and Jan Mayen', PO_LANG), 'SZ' => __('Swaziland', PO_LANG), 'SE' => __('Sweden', PO_LANG), 'CH' => __('Switzerland', PO_LANG), 'SY' => __('Syrian Arab Republic', PO_LANG), 'TW' => __('Taiwan, Republic of China', PO_LANG), 'TJ' => __('Tajikistan', PO_LANG), 'TZ' => __('Tanzania', PO_LANG), 'TH' => __('Thailand', PO_LANG), 'TL' => __('Timor Leste', PO_LANG), 'TG' => __('Togo', PO_LANG), 'TK' => __('Tokelau', PO_LANG), 'TO' => __('Tonga', PO_LANG), 'TT' => __('Trinidad & Tobago', PO_LANG), 'TN' => __('Tunisia', PO_LANG), 'TR' => __('Turkey', PO_LANG), 'TM' => __('Turkmenistan', PO_LANG), 'TC' => __('Turks And Caicos Islands', PO_LANG), 'TV' => __('Tuvalu', PO_LANG), 'UG' => __('Uganda', PO_LANG), 'UA' => __('Ukraine', PO_LANG), 'AE' => __('United Arab Emirates', PO_LANG), 'GB' => __('United Kingdom', PO_LANG), 'UM' => __('US Minor Outlying Islands', PO_LANG), 'US' => __('USA', PO_LANG), 'HV' => __('Upper Volta', PO_LANG), 'UY' => __('Uruguay', PO_LANG), 'UZ' => __('Uzbekistan', PO_LANG), 'VU' => __('Vanuatu', PO_LANG), 'VA' => __('Vatican City State', PO_LANG), 'VE' => __('Venezuela', PO_LANG), 'VN' => __('Vietnam', PO_LANG), 'VG' => __('Virgin Islands (British)', PO_LANG), 'VI' => __('Virgin Islands (US)', PO_LANG), 'WF' => __('Wallis And Futuna Islands', PO_LANG), 'EH' => __('Western Sahara', PO_LANG), 'YE' => __('Yemen Arab Rep.', PO_LANG), 'YD' => __('Yemen Democratic', PO_LANG), 'YU' => __('Yugoslavia', PO_LANG), 'ZR' => __('Zaire', PO_LANG), 'ZM' => __('Zambia', PO_LANG), 'ZW' => __('Zimbabwe', PO_LANG)); /** * Filter the countries so users can add/remove/rename items. */ $Countries = apply_filters('popover-country-list', $Countries); // Deprecated filter name. $Countries = apply_filters('popover_country_list', $Countries); } return $Countries; } } IncPopupRules::register('IncPopupRule_Geo');
/** * Tests if the current user belongs to one of the specified roles. * * @since 1.0.0 * @param array $data Contains the element ['roles'] * @return boolean */ protected function user_has_role($data) { $result = false; if (!is_array($data)) { $data = array(); } if (!is_array(@$data['roles'])) { $data['roles'] = array(); } $role_list = $data['roles']; $user = wp_get_current_user(); $user_roles = $user->roles; // Can a user have more than one Role? Better be sure and use a loop... foreach ($user_roles as $key) { if (in_array($key, $role_list)) { $result = true; break; } } return $result; } } IncPopupRules::register('IncPopupRule_UserRole');
<div class="error below-h2"><p> <?php printf(__('This condition requires that the <a href="%s" target="_blank">' . 'Membership2 Plugin</a> is installed and activated.', PO_LANG), 'http://premium.wpmudev.org/project/membership/'); ?> </p></div> <?php } /** * Tests if the current user has a specific membership subscription. * * @since 1.0.0 * @param array $data Contains the element ['pc_subscription'] * @return boolean */ protected function user_has_membership($data) { $result = false; $data = lib2()->array->get($data); $data['pc_subscription'] = lib2()->array->get($data['pc_subscription']); $member = MS_Plugin::$api->get_current_member(); foreach ($data['pc_subscription'] as $membership_id) { if ($member->has_membership($membership_id)) { $result = true; break; } } return $result; } } IncPopupRules::register('IncPopupRule_ProtectedContent');
id="po-time-until" name="po_rule_data[date_until_time]" maxlength="5" value="<?php echo esc_attr($time_from); ?> " /> </div> <?php } /** * Update and return the $settings array to save the form values. * * @since 4.7.1 * @param array $data The contents of $_POST['po_rule_data']. * @return mixed Data collection of this rule. */ protected function save_date_until($data) { lib2()->array->equip($data, 'date_until', 'date_until_time'); $date_str = $data['date_until'] . ' ' . $data['date_until_time']; $date_until = strtotime($date_str); if ($date_until) { $date_until += 59; // add 59 seconds } return $date_until; } } IncPopupRules::register('IncPopupRule_Datetime');
== == == HELPER FUNCTIONS == == == ========================================== \*======================================*/ /** * Checks if the user did already post any comments. * * @since 4.6 * @return bool */ protected function did_user_comment() { global $wpdb; static $Comment = null; if (null === $Comment) { // Guests (and maybe logged in users) are tracked via a cookie. $Comment = isset($_COOKIE['comment_author_' . COOKIEHASH]) ? 1 : 0; if (!$Comment && is_user_logged_in()) { // For logged-in users we can also check the database. $sql = "\r\n\t\t\t\t\tSELECT COUNT(1)\r\n\t\t\t\t\tFROM {$wpdb->comments}\r\n\t\t\t\t\tWHERE user_id = %s\r\n\t\t\t\t"; $sql = $wpdb->prepare($sql, get_current_user_id()); $count = absint($wpdb->get_var($sql)); $Comment = $count > 0; } } return $Comment; } } IncPopupRules::register('IncPopupRule_User');
if (in_array($term_id, $taxonomies)) { $response = true; // We have a cat. break; } } } } } else { if (!$cur_single && in_array('plural', $url_types)) { if (empty($taxonomies)) { $response = true; // Any cat, archive } else { if (!empty($cur_cats)) { foreach ($cur_cats as $term_id) { if (in_array($term_id, $taxonomies)) { $response = true; // We have a cat. break; } } } } } } return $response; } } IncPopupRules::register('IncPopupRule_Taxonomy');
$cur_type = $_REQUEST['posttype']; $cur_single = 0 != absint(@$_REQUEST['is_single']); } else { // Via wp_footer $cur_type = get_post_type(); $cur_single = is_singular(); } if ($cur_single && in_array('singular', $url_types)) { if (empty($posttype)) { $response = true; // Any posttype, singular. } else { $response = in_array($cur_type, $posttype); // We have the post type! } } else { if (!$cur_single && in_array('plural', $url_types)) { if (empty($posttype)) { $response = true; // Any posttype, archive } else { return in_array($cur_type, $posttype); // We have the post type! } } } return $response; } } IncPopupRules::register('IncPopupRule_Posttype');
/** * Validates and sanitizes the current popup details. * * @since 4.6 */ protected function validate_data() { $styles = apply_filters('popup-styles', array()); // Color. if (!is_array($this->color)) { $this->color = array(); } if (!isset($this->color['col1'])) { $this->color['col1'] = ''; } if (!isset($this->color['col2'])) { $this->color['col2'] = ''; } if (!empty($this->color['col1']) && $this->color['col1'][0] !== '#') { $this->color['col1'] = '#' . $this->color['col1']; } if (!empty($this->color['col2']) && $this->color['col2'][0] !== '#') { $this->color['col2'] = '#' . $this->color['col2']; } // Size. if (!is_array($this->size)) { $this->size = array(); } if (!isset($this->size['width'])) { $this->size['width'] = ''; } if (!isset($this->size['height'])) { $this->size['height'] = ''; } // Style. if (!isset($styles[$this->style])) { $this->style = 'minimal'; } // default style. $this->deprecated_style = @$styles[$this->style]->deprecated; // Boolean types. $this->custom_size = true == $this->custom_size; $this->custom_colors = true == $this->custom_colors; $this->deprecated_style = true == $this->deprecated_style; $this->round_corners = true == $this->round_corners; $this->scroll_body = true == $this->scroll_body; $this->can_hide = true == $this->can_hide; $this->close_hides = true == $this->close_hides; $this->overlay_close = true == $this->overlay_close; $this->inline = true == $this->inline; // Numeric types. $this->hide_expire = absint($this->hide_expire); $this->display_data['delay'] = absint(@$this->display_data['delay']); $this->display_data['scroll'] = absint(@$this->display_data['scroll']); $this->display_data['delay_type'] = @$this->display_data['delay_type']; $this->display_data['scroll_type'] = @$this->display_data['scroll_type']; $this->display_data['anchor'] = @$this->display_data['anchor']; // Display behavior. if (!in_array($this->display, self::$display_opts)) { $this->display = 'delay'; } if ('m' != $this->display_data['delay_type']) { $this->display_data['delay_type'] = 's'; } if ('px' != $this->display_data['scroll_type']) { $this->display_data['scroll_type'] = '%'; } // Rules. if (!is_array($this->rule)) { $this->rule = array(); } $this->rule_files = array(); foreach ($this->rule as $ind => $key) { if (empty($key)) { unset($this->rule[$ind]); } // Set rule-files. $file = IncPopupRules::file_for_rule($key); if ($file && !in_array($file, $this->rule_files)) { $this->rule_files[] = $file; } } if (!is_array($this->rule_data)) { $this->rule_data = array(); } foreach ($this->rule_data as $ind => $key) { if (empty($key)) { unset($this->rule_data[$ind]); } } // Generate unique ID. $this->code = (object) array(); $this->code->id = 'a' . md5($this->id . date('dis')); $this->code->cls = 'wdpu-' . $this->id; // Display data (legacy code for old styles). if ($this->custom_colors) { $this->code->colors = 'color:' . $this->color['col2'] . ';background:' . $this->color['col1'] . ';'; } else { $this->code->colors = 'color:#000000;background:#FFFFFF;'; } // Display data. if (!$this->custom_colors || empty($this->color['col1'])) { $this->code->color1 = '#488CFD'; } else { $this->code->color1 = $this->color['col1']; } if (!$this->custom_colors || empty($this->color['col2'])) { $this->code->color2 = '#FFFFFF'; } else { $this->code->color2 = $this->color['col2']; } // Very rough validation that makes sure that the field does not close // the <style> tag manually. $this->custom_css = str_replace('</s', 's', $this->custom_css); $this->class = lib2()->array->get($this->class); $this->script_data['html_id'] = $this->code->id; $this->script_data['popup_id'] = $this->id; $this->script_data['close_hide'] = $this->close_hides; $this->script_data['expiry'] = $this->hide_expire; $this->script_data['custom_size'] = $this->custom_size; $this->script_data['width'] = trim(str_replace('px', '', $this->size['width'])); $this->script_data['height'] = trim(str_replace('px', '', $this->size['height'])); $this->script_data['overlay_close'] = $this->overlay_close; $this->script_data['display'] = $this->display; $this->script_data['display_data'] = $this->display_data; $this->script_data['scroll_body'] = $this->scroll_body; $this->script_data['form_submit'] = $this->form_submit; $this->script_data['animation_in'] = $this->animation_in; $this->script_data['animation_out'] = $this->animation_out; $this->script_data['inline'] = $this->inline; // Validation only done when editing popups. if (!$this->is_upfront && is_admin() && $this->id >= 0) { // Name. if (empty($this->name)) { $this->name = __('New PopUp', PO_LANG); } // Order. if (empty($this->id) || empty($this->order)) { $this->order = IncPopupDatabase::next_order(); } // Rule-files. $this->rule_files = array(); foreach ($this->rule as $ind => $key) { $file = IncPopupRules::file_for_rule($key); if ($file && !in_array($file, $this->rule_files)) { $this->rule_files[] = $file; } } // Check if the "id" is valid! if ($this->id > 0 && self::POST_TYPE !== get_post_type($this->id)) { $this->id = 0; } } }
// Any cat, singular. } else { foreach ($cur_cats as $term_id) { if (in_array($term_id, $categories)) { $response = true; // We have a cat. break; } } } } else { if (!$cur_single && in_array('plural', $url_types)) { if (empty($categories)) { $response = true; // Any cat, archive } else { foreach ($cur_cats as $term_id) { if (in_array($term_id, $categories)) { $response = true; // We have a cat. break; } } } } } return $response; } } IncPopupRules::register('IncPopupRule_Category');
class="inp-small" name="po_rule_data[count]" min="1" max="999" maxlength="3" placeholder="10" value="<?php echo esc_attr(absint($count)); ?> " /> <?php } /** * Update and return the $settings array to save the form values. * * @since 4.6 * @param array $data The contents of $_POST['po_rule_data']. * @return mixed Data collection of this rule. */ protected function save_count($data) { lib2()->array->equip($data, 'count'); $count = absint($data['count']); if ($count < 1) { $count = 1; } return $count; } } IncPopupRules::register('IncPopupRule_Popup');
} } } return $result; } /** * Tests if the current user has a specific membership subscription. * * @since 1.0.0 * @param array $data Contains the element ['membership_sub'] * @return boolean */ protected function user_has_subscription($data) { $result = false; if ($this->is_active) { $data = lib2()->array->get($data); lib2()->array->equip($data, 'membership_sub'); $data['membership_sub'] = lib2()->array->get($data['membership_sub']); foreach ($data['membership_sub'] as $subscription) { if (current_user_on_subscription($subscription)) { $result = true; break; } } } return $result; } } IncPopupRules::register('IncPopupRule_Membership');