/** * Saves a flag in the user's options that tells Buoy not to show * the "webapp installer" scripts again. * * @uses check_ajax_referer() * @uses get_current_user_id() * @uses WP_Buoy_User_Settings::set() * @uses WP_Buoy_User_Settings::save() * @uses wp_send_json_success() * * @return void */ public static function handleDismissInstaller() { check_ajax_referer(self::$prefix . '_incident_nonce', self::$prefix . '_nonce'); $usropt = new WP_Buoy_User_Settings(get_current_user_id()); $usropt->set('installer_dismissed', true)->save(); wp_send_json_success(); }
/** * Makes this team the default team of the author. * * @uses WP_Buoy_User_Settings::set() * @uses WP_Buoy_User_Settings::save() * * @return WP_Buoy_Team */ public function make_default() { $usropt = new WP_Buoy_User_Settings($this->author->ID); $usropt->set('default_team', $this->wp_post->ID)->save(); return $this; }
/** * Saves profile field values to the database on profile update. * * @global $_POST Used to access values submitted by profile form. * * @param int $user_id * * @uses WP_Buoy_User_Settings::set() * @uses WP_Buoy_User_Settings::save() * * @return void */ public static function saveProfile($user_id) { $options = new WP_Buoy_User_Settings($user_id); $options->set('gender_pronoun_possessive', sanitize_text_field($_POST[self::$prefix . '_gender_pronoun_possessive']))->set('phone_number', sanitize_text_field($_POST[self::$prefix . '_phone_number']))->set('sms_provider', sanitize_text_field($_POST[self::$prefix . '_sms_provider']))->set('crisis_message', sanitize_text_field($_POST[self::$prefix . '_crisis_message']))->set('public_responder', isset($_POST[self::$prefix . '_public_responder']) ? true : false)->save(); }
<?php /** * Buoy uninstaller. * * @package WordPress\Plugin\WP_Buoy_Plugin\Uninstaller */ // Don't execute any uninstall code unless WordPress core requests it. if (!defined('WP_UNINSTALL_PLUGIN')) { exit; } require_once plugin_dir_path(__FILE__) . 'buoy.php'; require_once plugin_dir_path(__FILE__) . 'class-buoy-settings.php'; require_once plugin_dir_path(__FILE__) . 'class-buoy-user-settings.php'; $my_prefix = WP_Buoy_Plugin::$prefix; $post_types = array("{$my_prefix}_alert", "{$my_prefix}_team"); $posts = get_posts(array('post_type' => $post_types, 'post_status' => get_post_stati(), 'posts_per_page' => -1)); foreach ($posts as $post) { wp_delete_post($post->ID, true); } // Delete plugin options. delete_option(WP_Buoy_Settings::get_instance()->meta_key); foreach (get_users() as $usr) { // Delete all custom user profile data. $usropt = new WP_Buoy_User_Settings($usr); foreach ($usropt->default as $k => $v) { $usropt->delete($k); } $usropt->save(); }