/** * @return bool */ protected function _isDismissed() { $dismissed = IfwPsn_Wp_Proxy_User::getCurrentUserMetaSingle('dismissed_wp_pointers'); if (!is_array($dismissed)) { $dismissed = explode(',', $dismissed); } return in_array($this->_id, $dismissed); }
/** * @return mixed */ public function getOption() { if ($this->_optionValue === null) { $option = IfwPsn_Wp_Proxy_Screen::getOption('per_page', 'option'); $value = IfwPsn_Wp_Proxy_User::getCurrentUserMetaSingle($option); if (method_exists($this, '_getOptionCallback')) { $value = $this->_getOptionCallback($value); } $this->_optionValue = $value; } return $this->_optionValue; }
/** * Checks if editor restriction matches * * @return bool */ protected function _matchesEditorRestriction() { $editorRestriction = $this->getEditorRestriction(); if (empty($editorRestriction) or IfwPsn_Wp_Proxy_User::isCurrentUserMemberOfRoles($editorRestriction)) { return true; } return false; }
/** * @return array */ protected function _getCurrentUserData() { $result = array(); $whitelist = IfwPsn_Wp_Proxy_Filter::apply('psn_notification_placeholders_current_user_data_whitelist', array('ID', 'user_login', 'user_nicename', 'user_email', 'user_url', 'user_registered', 'user_status', 'display_name', 'user_firstname', 'user_lastname', 'nickname', 'user_description')); $userdata = IfwPsn_Wp_Proxy_User::getCurrentUserData(); if ($userdata instanceof WP_User) { foreach ($whitelist as $prop) { if (!$userdata->has_prop($prop)) { continue; } if (strpos($prop, 'user_') === 0) { $placeholder = str_replace('user_', 'current_user_', $prop); } else { $placeholder = 'current_user_' . $prop; } $result[$placeholder] = $userdata->get($prop); } } return $result; }
/** * @return array */ public static function getAllUsersEmails() { if (self::$_allUsersEmails === null) { self::$_allUsersEmails = self::getEmails(self::getAllUsers()); } return self::$_allUsersEmails; }
/** * Prepares TO, CC and BCC recipients * * @param Psn_Model_Rule $rule * @param $post */ protected function _prepareRecipients(Psn_Model_Rule $rule, $post) { // recipient handling (To, Cc, Bcc) $recipientSelections = array(array('name' => 'recipient_selection', 'modelGetter' => 'getRecipient', 'serviceAdder' => 'addTo', 'custom_field_name' => 'to'), array('name' => 'cc_selection', 'modelGetter' => 'getCcSelect', 'serviceAdder' => 'addCc', 'custom_field_name' => 'cc'), array('name' => 'bcc_selection', 'modelGetter' => 'getBccSelect', 'serviceAdder' => 'addBcc', 'custom_field_name' => 'bcc')); foreach ($recipientSelections as $recSel) { $recipient = $rule->{$recSel}['modelGetter'](); if (in_array('admin', $recipient)) { $this->{$recSel}['serviceAdder'](IfwPsn_Wp_Proxy_Blog::getAdminEmail()); } if (in_array('author', $recipient)) { $this->{$recSel}['serviceAdder'](IfwPsn_Wp_Proxy_User::getEmail($post->post_author)); } // handle dynamic recipients managed by modules IfwPsn_Wp_Proxy_Action::doAction('psn_service_email_' . $recSel['name'], $this); // check for custom recipient $custom_recipient = $rule->get($recSel['custom_field_name']); if (!empty($custom_recipient)) { $custom_recipient = $rule->getReplacer()->replace($custom_recipient); $customRecipientStack = explode(',', $custom_recipient); foreach ($customRecipientStack as $customRecipientEmail) { $this->{$recSel}['serviceAdder'](trim($customRecipientEmail)); } } } }