/** * Special function called when an of out admin pages are loaded. This way we can load any needed JS/CSS or processing logic * * @global none * * @param none * * @return none */ function on_load_panels() { $this->_show_own_admin = true; /* These messages are displayed as part of the admin header message see 'admin_notices' WordPress action */ $this->_admin_notice_messages['success-settings'] = __("Settings have been updated.", $this->translation_domain); $this->_admin_notice_messages['success-log-delete'] = __("Chat Session Log has been deleted.", $this->translation_domain); $this->_admin_notice_messages['success-logs-delete'] = __("Chat Session Logs have been deleted.", $this->translation_domain); $this->_admin_notice_messages['success-log-hide'] = __("Chat Session Log has been hidden.", $this->translation_domain); $this->_admin_notice_messages['success-logs-hide'] = __("Chat Session Logs have been hidden.", $this->translation_domain); $this->_admin_notice_messages['success-log-unhide'] = __("Chat Session Log has been unhidden.", $this->translation_domain); $this->_admin_notice_messages['success-logs-unhide'] = __("Chat Session Logs have been unhidden.", $this->translation_domain); $this->_admin_notice_messages['success-message-delete'] = __("Chat Session Log Message has been deleted.", $this->translation_domain); $this->_admin_notice_messages['success-messages-delete'] = __("Chat Session Log Messages have been deleted.", $this->translation_domain); $this->_admin_notice_messages['success-message-hide'] = __("Chat Session Log Message has been hidden.", $this->translation_domain); $this->_admin_notice_messages['success-messages-hide'] = __("Chat Session Log Messages have been hidden.", $this->translation_domain); $this->_admin_notice_messages['success-message-unhide'] = __("Chat Session Log Message has been unhidden.", $this->translation_domain); $this->_admin_notice_messages['success-messages-unhide'] = __("Chat Session Log Messages have been unhidden.", $this->translation_domain); if (isset($_GET['page']) && $_GET['page'] == "chat_session_logs") { if (isset($_GET['maction']) && isset($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'chat-message-item')) { $_SERVER['REQUEST_URI'] = esc_url_raw(remove_query_arg(array('_wp_http_referer', '_wpnonce'), $_SERVER['REQUEST_URI'])); $mid = ''; if (isset($_GET['mid'])) { $mid = intval($_GET['mid']); } $maction = ''; if (isset($_GET['maction'])) { $maction = esc_attr($_GET['maction']); } $chat_href = esc_url_raw(remove_query_arg(array('_wpnonce', 'maction', 'mid', 'message'))); if ($maction == "delete") { $this->chat_session_logs_messages('message', 'delete', array($mid)); $chat_href = add_query_arg('message', 'success-message-delete', $chat_href); wp_redirect($chat_href); } else { if ($maction == "hide" || $maction == "unhide") { if ($maction == "hide") { $this->chat_session_logs_messages('message', 'hide', array($mid)); $chat_href = add_query_arg('message', 'success-message-hide', $chat_href); } else { if ($maction == "unhide") { $this->chat_session_logs_messages('message', 'unhide', array($mid)); $chat_href = add_query_arg('message', 'success-message-unhide', $chat_href); } } if (isset($_GET['lid'])) { global $wpdb; $sql_str = $wpdb->prepare("SELECT * FROM " . WPMUDEV_Chat::tablename('log') . " WHERE id=%d", intval($_GET['lid'])); if (is_multisite()) { $sql_str .= " AND blog_id=" . $this->filters['blog_id']; } $sql_str .= " LIMIT 1"; $log_item = $wpdb->get_row($sql_str); if (!empty($log_item) && isset($log_item->chat_id) && !empty($log_item->chat_id) && isset($log_item->session_type) && !empty($log_item->session_type)) { $transient_key = "chat-session-" . $log_item->chat_id . '-' . $log_item->session_type; if (defined('WP_CACHE') && WP_CACHE) { $chat_session_transient = get_option($transient_key); } else { $chat_session_transient = get_transient($transient_key); } if (!empty($chat_session_transient)) { $this->chat_session_update_message_rows_deleted($chat_session_transient); } } } wp_redirect($chat_href); } } wp_redirect($chat_href); } else { if (isset($_GET['laction']) && isset($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'chat-log-item')) { $_SERVER['REQUEST_URI'] = esc_url_raw(remove_query_arg(array('_wp_http_referer', '_wpnonce'), $_SERVER['REQUEST_URI'])); $lid = ''; if (isset($_GET['lid'])) { $lid = intval($_GET['lid']); } $laction = ''; if (isset($_GET['laction'])) { $laction = esc_attr($_GET['laction']); } $chat_href = esc_url_raw(remove_query_arg(array('_wpnonce', 'lid', 'laction', 'maction', 'message'))); if ($laction == "delete") { $this->chat_session_logs_messages('log', 'delete', array($lid)); $chat_href = add_query_arg('message', 'success-log-delete', $chat_href); wp_redirect($chat_href); } else { if ($laction == "hide") { $this->chat_session_logs_messages('log', 'hide', array($lid)); $chat_href = add_query_arg('message', 'success-log-hide', $chat_href); wp_redirect($chat_href); } else { if ($laction == "unhide") { $this->chat_session_logs_messages('log', 'unhide', array($lid)); $chat_href = add_query_arg('message', 'success-log-unhide', $chat_href); wp_redirect($chat_href); } else { if ($laction == "details") { $per_page = get_user_meta(get_current_user_id(), 'chat_page_chat_session_messages_per_page', true); if (!$per_page) { $per_page = 20; } if (isset($_POST['wp_screen_options']['option']) && $_POST['wp_screen_options']['option'] == "chat_page_chat_session_logs_per_page") { if (isset($_POST['wp_screen_options']['value'])) { $per_page = intval($_POST['wp_screen_options']['value']); if (!$per_page || $per_page < 1) { $per_page = 20; } update_user_meta(get_current_user_id(), 'chat_page_chat_session_messages_per_page', $per_page); } } add_screen_option('per_page', array('label' => __('per Page', $this->translation_domain), 'default' => $per_page)); } } } } } else { if (isset($_GET['chat-messages-bulk']) && is_array($_GET['chat-messages-bulk']) && count($_GET['chat-messages-bulk']) && isset($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'bulk-messages')) { $bulk_action = ''; if (isset($_GET['action']) && $_GET['action'] != '-1') { $bulk_action = esc_attr($_GET['action']); } else { if (isset($_GET['action2']) && $_GET['action2'] != '-1') { $bulk_action = esc_attr($_GET['action2']); } } $_SERVER['REQUEST_URI'] = esc_url_raw(remove_query_arg(array('_wp_http_referer', '_wpnonce', 'action', 'action2', 'mid'), $_SERVER['REQUEST_URI'])); if ($bulk_action && !empty($bulk_action)) { $chat_href = esc_url_raw(remove_query_arg(array('_wpnonce', 'maction', 'message'), $_GET['_wp_http_referer'])); if ($bulk_action == 'delete') { $this->chat_session_logs_messages('message', 'delete', $_GET['chat-messages-bulk']); $chat_href = add_query_arg('message', 'success-messages-delete', $chat_href); wp_redirect($chat_href); } else { if ($bulk_action == "hide") { $this->chat_session_logs_messages('message', 'hide', $_GET['chat-messages-bulk']); $chat_href = add_query_arg('message', 'success-messages-hide', $chat_href); wp_redirect($chat_href); } else { if ($bulk_action == "unhide") { $this->chat_session_logs_messages('message', 'unhide', $_GET['chat-messages-bulk']); $chat_href = add_query_arg('message', 'success-messages-unhide', $chat_href); wp_redirect($chat_href); } } } } } else { if (isset($_GET['chat-logs-bulk']) && is_array($_GET['chat-logs-bulk']) && count($_GET['chat-logs-bulk']) && isset($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'bulk-logs')) { $bulk_action = ''; if (isset($_GET['action']) && $_GET['action'] != '-1') { $bulk_action = esc_attr($_GET['action']); } else { if (isset($_GET['action2']) && $_GET['action2'] != '-1') { $bulk_action = esc_attr($_GET['action2']); } } $_SERVER['REQUEST_URI'] = esc_url_raw(remove_query_arg(array('_wp_http_referer', '_wpnonce', 'action', 'action2', 'mid'), $_SERVER['REQUEST_URI'])); if ($bulk_action && !empty($bulk_action)) { $chat_href = esc_url_raw(remove_query_arg(array('_wpnonce', 'maction', 'message'))); if ($bulk_action == 'delete') { $this->chat_session_logs_messages('log', 'delete', $_GET['chat-logs-bulk']); $chat_href = add_query_arg('message', 'success-logs-delete', $chat_href); } else { if ($bulk_action == "hide") { $this->chat_session_logs_messages('log', 'hide', $_GET['chat-logs-bulk']); $chat_href = add_query_arg('message', 'success-logs-hide', $chat_href); } else { if ($bulk_action == "unhide") { $this->chat_session_logs_messages('log', 'unhide', $_GET['chat-logs-bulk']); $chat_href = add_query_arg('message', 'success-logs-unhide', $chat_href); } } } wp_redirect($chat_href); } } else { // IF we are here there are no bulk or single actions to take. So we want to make clean URLs so // remove all the cruft query string args we don't need. Then redirect to load the page. $screen = get_current_screen(); $screen_per_page_option = str_replace('-', '_', $screen->id . "_per_page"); $per_page = 20; if (isset($_GET['laction']) && $_GET['laction'] == 'details') { $per_page_option = 'chat_page_chat_session_messages_per_page'; } else { $per_page_option = 'chat_page_chat_session_logs_per_page'; } if (isset($_POST['wp_screen_options']['option']) && $_POST['wp_screen_options']['option'] == $screen_per_page_option) { if (isset($_POST['wp_screen_options']['value'])) { $per_page = intval($_POST['wp_screen_options']['value']); if (!$per_page || $per_page < 1) { $per_page = 20; } update_user_meta(get_current_user_id(), $per_page_option, $per_page); } } if (isset($_GET['_wp_http_referer']) || isset($_GET['_wpnonce'])) { $remove_args_array = array('_wp_http_referer', '_wpnonce', 'chat-filter', 'action', 'action2'); $args_array = array(); wp_parse_str($_SERVER['REQUEST_URI'], $args_array); foreach ($args_array as $_key => $_val) { if ($_key == "paged" && $_val == 1) { $remove_args_array[] = $_key; } if (empty($_val)) { $remove_args_array[] = $_key; } } wp_redirect(esc_url_raw(remove_query_arg($remove_args_array, $_SERVER['REQUEST_URI']))); die; } $per_page = get_user_meta(get_current_user_id(), $per_page_option, true); if (empty($per_page)) { $per_page = 20; } add_screen_option('per_page', array('label' => __('per Page', $this->translation_domain), 'default' => $per_page)); if (isset($_GET['laction']) && $_GET['laction'] == 'details') { require_once dirname(__FILE__) . '/lib/wpmudev_chat_admin_session_messages.php'; $this->chat_log_list_table = new WPMUDEVChat_Session_Messages_Table(); } else { require_once dirname(__FILE__) . '/lib/wpmudev_chat_admin_session_logs.php'; $this->chat_log_list_table = new WPMUDEVChat_Session_Logs_Table(); } } } } } } $this->process_panel_actions(); //$this->load_configs(); include_once dirname(__FILE__) . '/lib/wpmudev_chat_form_sections.php'; // Since we are showing one of our admin panels we init the help system. include_once dirname(__FILE__) . '/lib/wpmudev_chat_admin_panels_help.php'; wpmudev_chat_panel_help(); // Add our tool tips. if (!class_exists('WpmuDev_HelpTooltips')) { require_once dirname(__FILE__) . '/lib/class_wd_help_tooltips.php'; } $this->tips = new WpmuDev_HelpTooltips(); $this->tips->set_icon_url(plugins_url('/images/information.png', __FILE__)); }
/** * Special function called when an of out admin pages are loaded. This way we can load any needed JS/CSS or processing logic * * @global none * @param none * @return none */ function on_load_panels() { $this->_show_own_admin = true; /* These messages are displayed as part of the admin header message see 'admin_notices' WordPress action */ $this->_messages['success-settings'] = __("Settings have been update.", $this->translation_domain); $this->_messages['success-log-delete'] = __("Chat Session Log has been deleted.", $this->translation_domain); $this->_messages['success-logs-delete'] = __("Chat Session Logs have been deleted.", $this->translation_domain); $this->_messages['success-log-hide'] = __("Chat Session Log has been hidden.", $this->translation_domain); $this->_messages['success-logs-hide'] = __("Chat Session Logs have been hidden.", $this->translation_domain); $this->_messages['success-log-unhide'] = __("Chat Session Log has been unhidden.", $this->translation_domain); $this->_messages['success-logs-unhide'] = __("Chat Session Logs have been unhidden.", $this->translation_domain); $this->_messages['success-message-delete'] = __("Chat Session Log Message has been deleted.", $this->translation_domain); $this->_messages['success-messages-delete'] = __("Chat Session Log Messages have been deleted.", $this->translation_domain); $this->_messages['success-message-hide'] = __("Chat Session Log Message has been hidden.", $this->translation_domain); $this->_messages['success-messages-hide'] = __("Chat Session Log Messages have been hidden.", $this->translation_domain); $this->_messages['success-message-unhide'] = __("Chat Session Log Message has been unhidden.", $this->translation_domain); $this->_messages['success-messages-unhide'] = __("Chat Session Log Messages have been unhidden.", $this->translation_domain); if (isset($_GET['page']) && $_GET['page'] == "chat_session_logs") { //echo "_GET<pre>"; print_r($_GET); echo "</pre>"; //echo "_POST<pre>"; print_r($_POST); echo "</pre>"; if (isset($_GET['maction']) && isset($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'chat-message-item')) { $_SERVER['REQUEST_URI'] = remove_query_arg(array('_wp_http_referer', '_wpnonce'), $_SERVER['REQUEST_URI']); $mid = ''; if (isset($_GET['mid'])) { $mid = intval($_GET['mid']); } $maction = ''; if (isset($_GET['maction'])) { $maction = esc_attr($_GET['maction']); } $chat_href = remove_query_arg(array('_wpnonce', 'maction', 'message')); if ($maction == "delete") { $this->chat_session_logs_messages('message', 'delete', array($mid)); $chat_href = add_query_arg('message', 'success-message-delete', $chat_href); wp_redirect($chat_href); } else { if ($maction == "hide") { $this->chat_session_logs_messages('message', 'hide', array($mid)); $chat_href = add_query_arg('message', 'success-message-hide', $chat_href); wp_redirect($chat_href); } else { if ($maction == "unhide") { $this->chat_session_logs_messages('message', 'unhide', array($mid)); $chat_href = add_query_arg('message', 'success-message-unhide', $chat_href); wp_redirect($chat_href); } } } wp_redirect($chat_href); } else { if (isset($_GET['laction']) && isset($_GET['_wpnonce']) && wp_verify_nonce($_GET['_wpnonce'], 'chat-log-item')) { $_SERVER['REQUEST_URI'] = remove_query_arg(array('_wp_http_referer', '_wpnonce'), $_SERVER['REQUEST_URI']); $lid = ''; if (isset($_GET['lid'])) { $lid = intval($_GET['lid']); } $laction = ''; if (isset($_GET['laction'])) { $laction = esc_attr($_GET['laction']); } $chat_href = remove_query_arg(array('_wpnonce', 'lid', 'laction', 'maction', 'message')); if ($laction == "delete") { $this->chat_session_logs_messages('log', 'delete', array($lid)); $chat_href = add_query_arg('message', 'success-log-delete', $chat_href); wp_redirect($chat_href); } else { if ($laction == "hide") { $this->chat_session_logs_messages('log', 'hide', array($lid)); $chat_href = add_query_arg('message', 'success-log-hide', $chat_href); wp_redirect($chat_href); } else { if ($laction == "unhide") { $this->chat_session_logs_messages('log', 'unhide', array($lid)); $chat_href = add_query_arg('message', 'success-log-unhide', $chat_href); wp_redirect($chat_href); } else { if ($laction == "details") { $per_page = get_user_meta(get_current_user_id(), 'chat_page_chat_session_messages_per_page', true); if (!$per_page) { $per_page = 20; } if (isset($_POST['wp_screen_options']['option']) && $_POST['wp_screen_options']['option'] == "chat_page_chat_session_logs_per_page") { if (isset($_POST['wp_screen_options']['value'])) { $per_page = intval($_POST['wp_screen_options']['value']); if (!$per_page || $per_page < 1) { $per_page = 20; } update_user_meta(get_current_user_id(), 'chat_page_chat_session_messages_per_page', $per_page); } } add_screen_option('per_page', array('label' => __('per Page', $this->translation_domain), 'default' => $per_page)); } } } } } else { if (isset($_POST['chat-messages-bulk']) && is_array($_POST['chat-messages-bulk']) && count($_POST['chat-messages-bulk']) && isset($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'bulk-messages')) { //echo "_POST<pre>"; print_r($_POST); echo "</pre>"; $bulk_action = ''; if (isset($_POST['action']) && $_POST['action'] != '-1') { $bulk_action = esc_attr($_POST['action']); } else { if (isset($_POST['action2']) && $_POST['action2'] != '-1') { $bulk_action = esc_attr($_POST['action2']); } } $_SERVER['REQUEST_URI'] = remove_query_arg(array('_wp_http_referer', '_wpnonce', 'action', 'action2'), $_SERVER['REQUEST_URI']); if ($bulk_action && !empty($bulk_action)) { $chat_href = remove_query_arg(array('_wpnonce', 'maction', 'message'), $_POST['_wp_http_referer']); if ($bulk_action == 'delete') { $this->chat_session_logs_messages('message', 'delete', $_POST['chat-messages-bulk']); $chat_href = add_query_arg('message', 'success-messages-delete', $chat_href); wp_redirect($chat_href); } else { if ($bulk_action == "hide") { $this->chat_session_logs_messages('message', 'hide', $_POST['chat-messages-bulk']); $chat_href = add_query_arg('message', 'success-messages-hide', $chat_href); wp_redirect($chat_href); } else { if ($bulk_action == "unhide") { $this->chat_session_logs_messages('message', 'unhide', $_POST['chat-messages-bulk']); $chat_href = add_query_arg('message', 'success-messages-unhide', $chat_href); wp_redirect($chat_href); } } } } } else { if (isset($_POST['chat-logs-bulk']) && is_array($_POST['chat-logs-bulk']) && count($_POST['chat-logs-bulk']) && isset($_POST['_wpnonce']) && wp_verify_nonce($_POST['_wpnonce'], 'bulk-logs')) { //echo "_POST<pre>"; print_r($_POST); echo "</pre>"; $bulk_action = ''; if (isset($_POST['action']) && $_POST['action'] != '-1') { $bulk_action = esc_attr($_POST['action']); } else { if (isset($_POST['action2']) && $_POST['action2'] != '-1') { $bulk_action = esc_attr($_POST['action2']); } } $_SERVER['REQUEST_URI'] = remove_query_arg(array('_wp_http_referer', '_wpnonce', 'action', 'action2'), $_SERVER['REQUEST_URI']); if ($bulk_action && !empty($bulk_action)) { $chat_href = remove_query_arg(array('_wpnonce', 'maction', 'message'), $_POST['_wp_http_referer']); if ($bulk_action == 'delete') { $this->chat_session_logs_messages('log', 'delete', $_POST['chat-logs-bulk']); $chat_href = add_query_arg('message', 'success-logs-delete', $chat_href); } else { if ($bulk_action == "hide") { $this->chat_session_logs_messages('log', 'hide', $_POST['chat-logs-bulk']); $chat_href = add_query_arg('message', 'success-logs-hide', $chat_href); } else { if ($bulk_action == "unhide") { $this->chat_session_logs_messages('log', 'unhide', $_POST['chat-logs-bulk']); $chat_href = add_query_arg('message', 'success-logs-unhide', $chat_href); wp_redirect($chat_href); } } } } } else { // IF we are here there are no bulk or single actions to take. So we want to make clean URLs so // remove all the cruft query string args we don't need. Then redirect to load the page. if (isset($_GET['_wp_http_referer']) || isset($_GET['_wpnonce'])) { $remove_args_array = array('_wp_http_referer', '_wpnonce', 'chat-filter', 'action', 'action2'); $args_array = array(); wp_parse_str($_SERVER['REQUEST_URI'], $args_array); foreach ($args_array as $_key => $_val) { if ($_key == "paged" && $_val == 1) { $remove_args_array[] = $_key; } if (empty($_val)) { $remove_args_array[] = $_key; } } wp_redirect(remove_query_arg($remove_args_array, $_SERVER['REQUEST_URI'])); die; } $per_page = get_user_meta(get_current_user_id(), 'chat_page_chat_session_logs_per_page', true); //echo "per_page[". $per_page ."]<br />"; if (!$per_page) { $per_page = 20; } if (isset($_POST['wp_screen_options']['option']) && $_POST['wp_screen_options']['option'] == "chat_page_chat_session_logs_per_page") { if (isset($_POST['wp_screen_options']['value'])) { $per_page = intval($_POST['wp_screen_options']['value']); if (!$per_page || $per_page < 1) { $per_page = 20; } update_user_meta(get_current_user_id(), 'chat_page_chat_session_logs_per_page', $per_page); } } add_screen_option('per_page', array('label' => __('per Page', $this->translation_domain), 'default' => $per_page)); } } } } } $this->process_panel_actions(); $this->load_configs(); include_once dirname(__FILE__) . '/lib/wpmudev_chat_form_sections.php'; // Since we are showing one of our admin panels we init the help system. include_once dirname(__FILE__) . '/lib/wpmudev_chat_admin_panels_help.php'; wpmudev_chat_panel_help(); // Add our tool tips. if (!class_exists('WpmuDev_HelpTooltips')) { require_once dirname(__FILE__) . '/lib/class_wd_help_tooltips.php'; } $this->tips = new WpmuDev_HelpTooltips(); $this->tips->set_icon_url(plugins_url('/images/information.png', __FILE__)); }