public static function output() { ?> <div class="wrap"> <div id="icon-options-general" class="icon32"></div> <h2><?php _e('Tokens', 'pnfw'); ?> </h2> <?php if (isset($_REQUEST['action']) && 'delete' === $_REQUEST['action']) { if (!isset($_REQUEST['_wpnonce']) || !wp_verify_nonce($_REQUEST['_wpnonce'], 'delete' . $_REQUEST['id'])) { _e('Are you sure you want to do this?', 'pnfw'); die; } global $wpdb; $table_name = $wpdb->get_blog_prefix() . 'push_tokens'; $user_id = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM {$table_name} WHERE id = %d", $_REQUEST['id'])); $wpdb->delete($table_name, array('id' => $_REQUEST['id'])); pnfw_log(PNFW_ALERT_LOG, sprintf(__("Removed from the Tokens page the token with ID %s.", 'pnfw'), $_REQUEST['id'])); $user = new WP_User($user_id); if (in_array(PNFW_Push_Notifications_for_WordPress_Lite::USER_ROLE, $user->roles) && empty($user->user_email)) { pnfw_log(PNFW_SYSTEM_LOG, sprintf(__("Automatically deleted the anonymous user %s (%s) since left without tokens.", 'pnfw'), $user->user_login, $user_id)); if (is_multisite()) { require_once ABSPATH . 'wp-admin/includes/ms.php'; if (is_user_member_of_blog($user_id)) { wpmu_delete_user($user_id); } } else { wp_delete_user($user_id); } } ?> <div class="updated below-h2" id="message"><p><?php _e('Item deleted', 'pnfw'); ?> </p></div> <?php } else { if (isset($_REQUEST['action']) && 'send_test_notification' === $_REQUEST['action']) { if (!isset($_REQUEST['_wpnonce']) || !wp_verify_nonce($_REQUEST['_wpnonce'], 'send_test_notification' . $_REQUEST['id'])) { _e('Are you sure you want to do this?', 'pnfw'); die; } global $wpdb; $table_name = $wpdb->get_blog_prefix() . 'push_tokens'; $rows = $wpdb->get_results($wpdb->prepare("SELECT os, token FROM {$table_name} WHERE id = %d", $_REQUEST['id'])); if (count($rows) > 0) { $os = $rows[0]->os; $token = $rows[0]->token; $title = __('This is a test notification', 'pnfw'); if ('iOS' == $os) { require_once dirname(__FILE__) . '/../includes/notifications/class-pnfw-notifications-ios.php'; $sender = new PNFW_Notifications_iOS(); $count = $sender->send_title_to_tokens($title, array($token)); } else { if ('Android' == $os) { require_once dirname(__FILE__) . '/../includes/notifications/class-pnfw-notifications-android.php'; $sender = new PNFW_Notifications_Android(); $count = $sender->send_title_to_tokens($title, array($token)); } else { if ('Fire OS' == $os) { require_once dirname(__FILE__) . '/../includes/notifications/class-pnfw-notifications-kindle.php'; $sender = new PNFW_Notifications_Kindle(); $count = $sender->send_title_to_tokens($title, array($token)); } } } if ($count > 0) { ?> <div class="updated below-h2" id="message"><p><?php echo sprintf(__('Notification sent to %s device', 'pnfw'), $os); ?> </p></div> <?php } else { $url = admin_url('admin.php?page=pnfw-debug-identifier'); ?> <div class="error below-h2" id="message"><p><?php echo sprintf(__("There was an error sending the notification. For more information, see the <a href='%s'>Debug</a> page", 'pnfw'), $url); ?> </p></div> <?php } } else { ?> <div class="error below-h2" id="message"><p><?php echo _e('Error'); ?> </p></div> <?php } } } $tokesTable = new Tokens_Table(); $tokesTable->prepare_items(); $tokesTable->display(); ?> </div> <?php }
protected function raw_send($tokens, $title, $post_id) { $this->post_id = $post_id; return parent::raw_send($tokens, $title, array('id' => $post_id)); }