/** * Fires when a new blog post is moved into the published status * @param string $new_status Status the blog post is moving to * @param string $old_status Previous post status * @param object $post The Post Object * @return void */ function ckpn_post_published($new_status, $old_status, $post) { // By default only send on post and page publishing $allowed_post_types = apply_filters('ckpn_post_publish_types', array('post', 'page')); // Only do this when a post transitions to being published if (in_array($post->post_type, $allowed_post_types) && $new_status == 'publish' && $old_status != 'publish') { $user_keys = array(); $title = get_bloginfo('name') . ': ' . __('New Post', CKPN_CORE_TEXT_DOMAIN); $title = apply_filters('ckpn_new_post_title', $title, $post); $author_data = get_userdata($post->post_author); $author_name = $author_data->display_name; $message = get_the_title($post->ID) . __(' by ', CKPN_CORE_TEXT_DOMAIN) . $author_name; $message = apply_filters('ckpn_new_post_message', $message, $post); $url = get_permalink($post->ID); $url_title = __('View Post', CKPN_CORE_TEXT_DOMAIN); $args = array('title' => $title, 'message' => $message, 'url' => $url, 'url_title' => $url_title); $new_post_roles = ckpn_get_option('new_post_roles'); $user_array = array(); foreach ($new_post_roles as $role => $value) { $user_args = array('role' => $role, 'fields' => 'ID'); $users = get_users($user_args); $user_array = array_unique(array_merge($users, $user_array)); } $super_admins = array(); if (defined('MULTISITE') && MULTISITE) { $super_admin_logins = get_super_admins(); foreach ($super_admin_logins as $super_admin_login) { $user = get_user_by('login', $super_admin_login); if ($user) { $super_admins[] = $user->ID; } } } $users_to_alert = array_unique(array_merge($user_array, $super_admins)); $current_user = wp_get_current_user(); // Unset the Post Author for non-scheduled posts if ($old_status !== 'future' && ($key = array_search($post->post_author, $users_to_alert)) !== false && $current_user->ID == $post->post_author) { unset($users_to_alert[$key]); } $options = ckpn_get_options(); // Add the default admin key from settings if it's different than the authors if (get_user_meta($post->post_author, 'ckpn_user_key', true) !== $options['api_key']) { $user_keys = array($options['api_key']); } $users_with_keys = ckpn_get_users_with_keys(); // Search the users for their Keys and send the posts foreach ($users_to_alert as $user) { $selected = get_user_meta($user, 'ckpn_user_notify_posts', true); if ($selected && array_key_exists($user, $users_with_keys)) { $user_keys[] = $users_with_keys[$user]; } } $user_keys = array_unique($user_keys); foreach ($user_keys as $user) { $args['user'] = $user; ckpn_send_notification($args); } } }
/** * Send a Pushover Notification when a moderator is assigned to a topic */ function wi_bbp_send_pushover_notification_on_assignment() { if (isset($_POST['bbps_support_topic_assign'])) { if (!function_exists('ckpn_send_notification')) { return; } $user_id = absint($_POST['bbps_assign_list']); $topic = bbp_get_topic($_POST['bbps_topic_id']); if ($user_id > 0 && $user_id != get_current_user_id()) { $title = __('Easy Digital Downloads: A forum topic has been assigned to you', 'wi_bbp'); $message = sprintf(__('You have been assigned to %1$s by another moderator', 'wi_bbp'), $topic->post_title); $user_push_key = get_user_meta($user_id, 'ckpn_user_key', true); if ($user_push_key) { $url = $topic->guid; $url_title = __('View Topic', 'wi_bbp'); $args = array('title' => $title, 'message' => $message, 'user' => $user_push_key, 'url' => $url, 'url_title' => $url_title); ckpn_send_notification($args); } } } }
/** * Send notifications * @param array $passed_args The arguments used by the Pushover API * @return void * @access public * @deprecated Deprecated since 1.8 - Use the non-class function ckpn_send_notification with the same arguments */ public function ckpn_send_notification($passed_args) { // Back compat ckpn_send_notification($passed_args); }