/** * Saves option for number of rows when listing posts, pages, comments, etc. * * @since 0.0.1 */ function set_screen_options() { if (isset($_POST['hq_screen_options']) && is_array($_POST['hq_screen_options'])) { check_admin_referer('screen-options-nonce', 'screenoptionnonce'); if (!($user = hq_get_current_user())) { return; } $option = $_POST['hq_screen_options']['option']; $value = $_POST['hq_screen_options']['value']; if ($option != sanitize_key($option)) { return; } $map_option = $option; $type = str_replace('edit_', '', $map_option); $type = str_replace('_per_page', '', $type); if (in_array($type, get_taxonomies())) { $map_option = 'edit_tags_per_page'; } elseif (in_array($type, get_post_types())) { $map_option = 'edit_per_page'; } else { $option = str_replace('-', '_', $option); } switch ($map_option) { case 'edit_per_page': case 'users_per_page': case 'edit_comments_per_page': case 'upload_per_page': case 'edit_tags_per_page': case 'plugins_per_page': // Network admin // Network admin case 'sites_network_per_page': case 'users_network_per_page': case 'site_users_network_per_page': case 'plugins_network_per_page': case 'themes_network_per_page': case 'site_themes_network_per_page': $value = (int) $value; if ($value < 1 || $value > 999) { return; } break; default: /** * Filter a screen option value before it is set. * * The filter can also be used to modify non-standard [items]_per_page * settings. See the parent function for a full list of standard options. * * Returning false to the filter will skip saving the current option. * * @since 0.0.1 * * @see set_screen_options() * * @param bool|int $value Screen option value. Default false to skip. * @param string $option The option name. * @param int $value The number of rows to use. */ $value = apply_filters('set-screen-option', false, $option, $value); if (false === $value) { return; } break; } update_user_meta($user->ID, $option, $value); hq_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), hq_get_referer())); exit; } }
/** * Execute custom background modification. * * @since 0.0.1 */ public function take_action() { if (empty($_POST)) { return; } if (isset($_POST['reset-background'])) { check_admin_referer('custom-background-reset', '_hqnonce-custom-background-reset'); remove_theme_mod('background_image'); remove_theme_mod('background_image_thumb'); $this->updated = true; return; } if (isset($_POST['remove-background'])) { // @TODO: Uploaded files are not removed here. check_admin_referer('custom-background-remove', '_hqnonce-custom-background-remove'); set_theme_mod('background_image', ''); set_theme_mod('background_image_thumb', ''); $this->updated = true; hq_safe_redirect($_POST['_hq_http_referer']); return; } if (isset($_POST['background-repeat'])) { check_admin_referer('custom-background'); if (in_array($_POST['background-repeat'], array('repeat', 'no-repeat', 'repeat-x', 'repeat-y'))) { $repeat = $_POST['background-repeat']; } else { $repeat = 'repeat'; } set_theme_mod('background_repeat', $repeat); } if (isset($_POST['background-position-x'])) { check_admin_referer('custom-background'); if (in_array($_POST['background-position-x'], array('center', 'right', 'left'))) { $position = $_POST['background-position-x']; } else { $position = 'left'; } set_theme_mod('background_position_x', $position); } if (isset($_POST['background-attachment'])) { check_admin_referer('custom-background'); if (in_array($_POST['background-attachment'], array('fixed', 'scroll'))) { $attachment = $_POST['background-attachment']; } else { $attachment = 'fixed'; } set_theme_mod('background_attachment', $attachment); } if (isset($_POST['background-color'])) { check_admin_referer('custom-background'); $color = preg_replace('/[^0-9a-fA-F]/', '', $_POST['background-color']); if (strlen($color) == 6 || strlen($color) == 3) { set_theme_mod('background_color', $color); } else { set_theme_mod('background_color', ''); } } $this->updated = true; }
<?php exit; } if (empty($redirect_to) || $redirect_to == 'hq-admin/' || $redirect_to == admin_url()) { // If the user doesn't belong to a blog, send them to user admin. If the user can't edit posts, send them to their profile. //TODO: Goyo no multisite //if ( is_multisite() && !get_active_blog_for_user($user->ID) && !is_super_admin( $user->ID ) ) if (false && !get_active_blog_for_user($user->ID) && !is_super_admin($user->ID)) { $redirect_to = user_admin_url(); } elseif (false && !$user->has_cap('read')) { $redirect_to = get_dashboard_url($user->ID); } elseif (!$user->has_cap('edit_posts')) { $redirect_to = admin_url('profile.php'); } } hq_safe_redirect($redirect_to); exit; } $errors = $user; // Clear errors if loggedout is set. if (!empty($_GET['loggedout']) || $reauth) { $errors = new HQ_Error(); } if ($interim_login) { if (!$errors->get_error_code()) { $errors->add('expired', __('Session expired. Please log in again. You will not move away from this page.'), 'message'); } } else { // Some parts of this script use the main login form to display a message if (isset($_GET['loggedout']) && true == $_GET['loggedout']) { $errors->add('loggedout', __('You are now logged out.'), 'message');