public function tearDown() { if (get_current_user_id() != $this->current_user) { wp_delete_user(get_current_user_id()); } wp_set_current_user($this->current_user); }
/** * * Woo User Menu */ function user_menu() { $_Twoot_Woo = new Twoot_Woo(); $url = $_Twoot_Woo->shop_urls(); $user_data = get_userdata(get_current_user_id()); $avatar = get_option('show_avatars') ? '<span class="avatar">' . get_avatar(get_current_user_id(), 20) . '</span>' : ''; $tag = get_option('permalink_structure') == false ? '&' : '?'; $html = '<nav id="woo-user-menu">'; $html .= '<ul class="sf-menu clearfix">'; if (is_user_logged_in()) { $html .= '<li class="my-account"><a href="' . $url['account_overview'] . '">' . $avatar . esc_attr__('Howdy, ', 'Twoot') . $user_data->display_name . '</a>'; $html .= '<ul>'; $html .= '<li class="account-change-pw"><a href="' . $url['account_change_pw'] . '">' . esc_attr__('Change Password', 'Twoot') . '</a></li>'; $html .= '<li class="account-edit-adress"><a href="' . $url['account_edit_adress'] . '">' . esc_attr__('Edit Address', 'Twoot') . '</a></li>'; $html .= '<li class="account-view-order"><a href="' . $url['account_view_order'] . '">' . esc_attr__('View Order', 'Twoot') . '</a></li>'; $html .= '<li class="cart"><a href="' . $url['cart'] . '">' . esc_attr__('Shopping Cart', 'Twoot') . '</a></li>'; $html .= '<li class="checkout"><a href="' . $url['checkout'] . '">' . esc_attr__('Checkout', 'Twoot') . '</a></li>'; $html .= '</ul>'; $html .= '</li>'; $html .= '<li class="logout last"><a href="' . $url['logout'] . '">' . esc_attr__('Sign Out', 'Twoot') . '</a></li>'; } else { if (get_option('users_can_register') && get_option('woocommerce_enable_myaccount_registration') == 'yes') { $html .= '<li class="register"><a href="' . $url['register'] . $tag . 'user_account=register">' . esc_attr__('Create Account', 'Twoot') . '</a></li>'; } $html .= '<li class="login last"><a href="' . $url['account_overview'] . $tag . 'user_account=login">' . esc_attr__('Sign In', 'Twoot') . '</a></li>'; } $html .= '</ul>'; $html .= '</nav>'; return $html; }
/** * Process the request * @todo Setting for reassigning user's posts */ public function process() { // Verify the security nonce and die if it fails if (!isset($_POST['wp_delete_user_accounts_nonce']) || !wp_verify_nonce($_POST['wp_delete_user_accounts_nonce'], 'wp_delete_user_accounts_nonce')) { wp_send_json(array('status' => 'fail', 'title' => __('Error!', 'wp-delete-user-accounts'), 'message' => __('Request failed security check.', 'wp-delete-user-accounts'))); } // Don't permit admins to delete their own accounts if (current_user_can('manage_options')) { wp_send_json(array('status' => 'fail', 'title' => __('Error!', 'wp-delete-user-accounts'), 'message' => __('Administrators cannot delete their own accounts.', 'wp-delete-user-accounts'))); } // Get the current user $user_id = get_current_user_id(); // Get user meta $meta = get_user_meta($user_id); // Delete user's meta foreach ($meta as $key => $val) { delete_user_meta($user_id, $key); } // Destroy user's session wp_logout(); // Delete the user's account $deleted = wp_delete_user($user_id); if ($deleted) { // Send success message wp_send_json(array('status' => 'success', 'title' => __('Success!', 'wp-delete-user-accounts'), 'message' => __('Your account was successfully deleted. Fair well.', 'wp-delete-user-accounts'))); } else { wp_send_json(array('status' => 'fail', 'title' => __('Error!', 'wp-delete-user-accounts'), 'message' => __('Request failed.', 'wp-delete-user-accounts'))); } }
public function display() { if (isset($_GET['form_id'])) { if ('new' == $_GET['form_id']) { $form_id = 'tmp-' . time(); } else { $form_id = is_numeric($_GET['form_id']) ? absint($_GET['form_id']) : ''; } /* * FORM BUILDER */ Ninja_Forms::template('admin-menu-new-form.html.php'); $this->_enqueue_the_things($form_id); delete_user_option(get_current_user_id(), 'nf_form_preview_' . $form_id); if (!isset($_GET['ajax'])) { $this->_localize_form_data($form_id); $this->_localize_field_type_data(); $this->_localize_action_type_data(); $this->_localize_form_settings(); $this->_localize_merge_tags(); } } else { /* * ALL FORMS TABLE */ $this->table->prepare_items(); Ninja_Forms::template('admin-menu-all-forms.html.php', array('table' => $this->table, 'add_new_url' => admin_url('admin.php?page=ninja-forms&form_id=new'), 'add_new_text' => __('Add New Form', 'ninja-forms'))); } }
public function archive($bolo_id) { $servername = "localhost"; $username = "******"; $password = ""; $dbname = "bolo_creator"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("Connection failed: " . $conn->connect_error); } //mark bolo as archived $sql2 = <<<SQL \t UPDATE wp_flierform \t SET archive = TRUE \t WHERE bolo_id = "{$boloid}" SQL; if (!($result = $conn->query($sql2))) { die('There was an error running the query [' . $db->error . ']'); } //archive the bolo $author = get_current_user_id(); $sql = <<<SQL \t INSERT INTO bolo_archive \t SELECT *, "{$author}" AS archive_author, CURRENT_TIMESTAMP() \t FROM wp_flierform\t \t WHERE bolo_id = "{$boloid}" SQL; if (!($result = $conn->query($sql))) { die('There was an error running the query [' . $db->error . ']'); } }
public function add_pointers() { $pointers = $this->pointers; if (!$pointers || !is_array($pointers)) { return; } // Get dismissed pointers $dismissed = explode(',', (string) get_user_meta(get_current_user_id(), 'dismissed_wp_pointers', true)); $valid_pointers = array(); // Check pointers and remove dismissed ones. foreach ($pointers as $pointer_id => $pointer) { // Make sure we have pointers & check if they have been dismissed if (in_array($pointer_id, $dismissed) || empty($pointer) || empty($pointer_id) || empty($pointer['target']) || empty($pointer['options'])) { continue; } $pointer['pointer_id'] = $pointer_id; // Add the pointer to $valid_pointers array $valid_pointers['pointers'][] = $pointer; } // No valid pointers? Stop here. if (empty($valid_pointers)) { return; } $this->valid = $valid_pointers; wp_enqueue_style('wp-pointer'); wp_enqueue_script('wp-pointer'); }
/** * Show Seller Enable Error Message * * @since 2.4 * * @return void */ public function show_seller_enable_message() { $user_id = get_current_user_id(); if (!dokan_is_seller_enabled($user_id)) { echo dokan_seller_not_enabled_notice(); } }
/** * Synchronize connected user role changes */ static function user_role_change($user_id) { if (Jetpack::is_active() && Jetpack::is_user_connected($user_id)) { $current_user_id = get_current_user_id(); wp_set_current_user($user_id); $role = Jetpack::translate_current_user_to_role(); $signed_role = Jetpack::sign_role($role); wp_set_current_user($current_user_id); $master_token = Jetpack_Data::get_access_token(JETPACK_MASTER_USER); $master_user_id = absint($master_token->external_user_id); if (!$master_user_id) { return; } // this shouldn't happen Jetpack::xmlrpc_async_call('jetpack.updateRole', $user_id, $signed_role); //@todo retry on failure //try to choose a new master if we're demoting the current one if ($user_id == $master_user_id && 'administrator' != $role) { $query = new WP_User_Query(array('fields' => array('id'), 'role' => 'administrator', 'orderby' => 'id', 'exclude' => array($master_user_id))); $new_master = false; foreach ($query->results as $result) { $uid = absint($result->id); if ($uid && Jetpack::is_user_connected($uid)) { $new_master = $uid; break; } } if ($new_master) { Jetpack_Options::update_option('master_user', $new_master); } // else disconnect..? } } }
function _admin_init() { global $post; $screen = get_current_screen(); $pointers = array(); if ($screen->base == 'post' && $screen->post_type == UBERGRID_POST_TYPE) { $pointers = array('#add-new-cell' => array('title' => __('Add a cell', 'uber-grid'), 'content' => __('<p>Click here to add a first cell to your grid.</p>', 'uber-grid'), 'position' => array('edge' => 'right', 'align' => 'center')), '#shortcode' => array('title' => __('Save your grid', 'uber-grid'), 'content' => sprintf(__('<p>After saving your grid, insert this code <strong>[ubergrid id=%s]</strong> into your site pages to use the grid.</p>', 'uber-grid'), $post->ID), 'position' => array('edge' => 'top'))); } if ($screen->base == 'edit' && $screen->post_type == UBERGRID_POST_TYPE) { $pointers = array('.add-new-h2' => array('title' => __('Create a grid', 'uber-grid'), 'content' => __('<p>Please click here to create your first grid.</p>', 'uber-grid'))); } $disabled = get_user_meta(get_current_user_id(), 'uber_grid_disabled_pointers', true); if ($disabled) { foreach ($disabled as $item) { if (isset($pointers[$item])) { unset($pointers[$item]); } } } if ($pointers) { wp_enqueue_script("wp-pointer"); wp_enqueue_style("wp-pointer"); wp_enqueue_script('uber-grid-pointers', UBERGRID_URL . 'assets/js/admin-pointers.js'); wp_localize_script('uber-grid-pointers', 'uber_grid_pointers', array($pointers)); } }
/** * @group get */ public function test_hide_all_for_user() { $activity = $this->factory->activity->create(array('type' => 'activity_update')); BP_Activity_Activity::hide_all_for_user(get_current_user_id()); $activity = BP_Activity_Activity::get(array('in' => $activity, 'show_hidden' => true)); $this->assertEquals($activity['activities'][0]->hide_sitewide, 1); }
public function add_save() { $rules = array(array('field' => 'name', 'label' => 'name', 'rules' => 'trim|required'), array('field' => 'address', 'label' => 'address', 'rules' => 'trim|required'), array('field' => 'contact_person', 'label' => 'contact person', 'rules' => 'trim|required'), array('field' => 'phone', 'label' => 'phone', 'rules' => 'trim'), array('field' => 'fax', 'label' => 'fax', 'rules' => 'trim'), array('field' => 'email', 'label' => 'email', 'rules' => 'trim|valid_email'), array('field' => 'qq', 'label' => 'QQ', 'rules' => 'trim'), array('field' => 'username', 'label' => 'user name', 'rules' => 'trim'), array('field' => 'web', 'label' => 'web', 'rules' => 'trim')); $this->form_validation->set_rules($rules); if ($this->form_validation->run() == FALSE) { $error = validation_errors(); echo $this->create_json(0, $error); return; } // check if the provider exists ? if ($this->purchase_model->check_exists('purchase_provider', array('name' => $this->input->post('name')))) { echo $this->create_json(0, lang('provider_exists')); return; } $edit_user = get_current_user_id(); $data = array('name' => trim($this->input->post('name')), 'boss' => trim($this->input->post('boss')), 'address' => trim($this->input->post('address')), 'phone' => trim($this->input->post('phone')), 'fax' => trim($this->input->post('fax')), 'email' => trim($this->input->post('email')), 'qq' => trim($this->input->post('qq')), 'web' => trim($this->input->post('web')), 'contact_person' => trim($this->input->post('contact_person')), 'mobile' => trim($this->input->post('mobile')), 'open_bank' => trim($this->input->post('open_bank')), 'bank_account' => trim($this->input->post('bank_account')), 'bank_title' => trim($this->input->post('bank_title')), 'edit_user' => $edit_user, 'remark' => trim($this->input->post('remark'))); try { $provider_id = $this->purchase_model->add_a_new_provider($data); $user_ids = $this->input->post('permissions'); if (!is_array($user_ids)) { settype($user_ids, 'array'); } $user_id = $this->get_current_user_id(); if (in_array($user_id, $user_ids) == FALSE) { array_push($user_ids, $user_id); } $this->purchase_model->save_purchase_permissions($provider_id, $user_ids); echo $this->create_json(1, lang('provider_saved')); } catch (Exception $e) { echo lang('error_msg'); $this->ajax_failed(); } }
/** * load data needed for board's javascript * @param string $template the passed in template path * @return string the same template path */ static function send_page_data_to_template($template) { if (!isset(Kanban_Template::get_instance()->slug) || Kanban_Template::get_instance()->slug != self::$slug) { return $template; } global $wp_query; $wp_query->query_vars['kanban'] = (object) array(); $wp_query->query_vars['kanban']->board = (object) array(); // // get all data for the javascript $wp_query->query_vars['kanban']->board->allowed_users = Kanban_User::get_allowed_users(); $wp_query->query_vars['kanban']->board->estimates = Kanban_Terms::terms_in_order('task', 'estimate'); $wp_query->query_vars['kanban']->board->status_tax_key = Kanban_Utils::format_key('task', 'status'); $wp_query->query_vars['kanban']->board->status_color_field_name = sprintf('%s_colors', $wp_query->query_vars['kanban']->board->status_tax_key); $wp_query->query_vars['kanban']->board->status_colors = Kanban_Settings::get_option($wp_query->query_vars['kanban']->board->status_color_field_name, null, array()); $wp_query->query_vars['kanban']->board->statuses = Kanban_Terms::terms_in_order('task', 'status'); foreach ($wp_query->query_vars['kanban']->board->statuses as $status) { if (!isset($wp_query->query_vars['kanban']->board->status_colors[$status->term_id])) { continue; } $status->color = $wp_query->query_vars['kanban']->board->status_colors[$status->term_id]; } $wp_query->query_vars['kanban']->board->projects = Kanban_Project::get_all(); $wp_query->query_vars['kanban']->board->tasks = Kanban_Task::get_all(); $current_user_id = get_current_user_id(); $wp_query->query_vars['kanban']->board->current_user = get_user_by('id', $current_user_id); unset($wp_query->query_vars['kanban']->board->current_user->data->user_pass); $wp_query->query_vars['kanban']->board->current_user->data->long_name_email = Kanban_User::format_user_name($wp_query->query_vars['kanban']->board->current_user); $wp_query->query_vars['kanban']->board->current_user->data->short_name = Kanban_User::format_user_name($wp_query->query_vars['kanban']->board->current_user, TRUE); $wp_query->query_vars['kanban']->board->current_user->data->initials = Kanban_User::get_initials($wp_query->query_vars['kanban']->board->current_user); $wp_query->query_vars['kanban']->board->col_percent_w = count($wp_query->query_vars['kanban']->board->statuses) > 0 ? 100 / count($wp_query->query_vars['kanban']->board->statuses) : 100; $wp_query->query_vars['kanban']->board->sidebar_w = count($wp_query->query_vars['kanban']->board->statuses) > 0 ? 100 / (count($wp_query->query_vars['kanban']->board->statuses) - 2) : 0; return $template; }
public function display_payment_gateway_settings_form() { $selected_gateway = (string) get_user_option('wpsc_settings_selected_payment_gateway', get_current_user_id()); if (empty($selected_gateway) && !empty($this->active_gateways)) { $selected_gateway = $this->active_gateways[0]; } $payment_data = $this->get_gateway_form($selected_gateway); if (!$payment_data) { $payment_data = array('name' => __('Edit Gateway Settings', 'wpsc'), 'form_fields' => __('Modify a payment gateway settings by clicking "Edit" link on the left.', 'wpsc')); } ?> <td id='wpsc-payment-gateway-settings-panel' class='wpsc-module-settings' rowspan='2'> <div class='postbox'> <h3 class='hndle'><?php echo $payment_data['name']; ?> </h3> <div class='inside'> <table class='form-table'> <?php echo $payment_data['form_fields']; ?> </table> <div class='submit'> <input type='submit' value='<?php _e('Update »', 'wpsc'); ?> ' /> </div> </div> </td> <?php }
/** * Poll Voting * @since 1.1 * @version 1.1 */ public function vote_poll() { if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'polls' && is_user_logged_in()) { // Get Poll ID $poll_id = isset($_REQUEST['poll_id']) ? intval($_REQUEST['poll_id']) : 0; // Ensure Poll ID Is Valid if ($poll_id != 0) { // Verify Referer if (check_ajax_referer('poll_' . $poll_id . '-nonce', 'poll_' . $poll_id . '_nonce', false)) { // Which View switch ($_REQUEST['view']) { case 'process': $poll_aid = $_POST["poll_{$poll_id}"]; $poll_aid_array = array_unique(array_map('intval', explode(',', $poll_aid))); if ($poll_id > 0 && !empty($poll_aid_array) && check_allowtovote()) { $check_voted = check_voted($poll_id); if ($check_voted == 0) { $user_id = get_current_user_id(); // Make sure we are not excluded if (!$this->core->exclude_user($user_id)) { $this->core->add_creds('poll_voting', $user_id, $this->prefs['creds'], $this->prefs['log'], $poll_id, array('ref_type' => 'poll'), $this->mycred_type); } } } break; } } } } }
/** * Uloží fieldset * VOLÁ SE V HOOCE * * @author Jan Pokorný * @param int $user_id */ public function saveFieldset($user_id) { if (get_current_user_id() != $user_id && !current_user_can('edit_users')) { return; } $fieldset = $this->getFieldset(); $form = new KT_form(); $form->addFieldSetByObject($fieldset); $form->validate(); if ($form->hasError()) { // TODO has error } if ($fieldset->getSerializeSave()) { $fieldsetData = $form->getSavableFieldsetGroupValue($fieldset); if (KT::arrayIssetAndNotEmpty($fieldsetData)) { update_user_meta($user_id, $fieldset->getName(), $fieldsetData); } else { delete_user_meta($user_id, $fieldset->getName()); } } else { foreach ($fieldset->getFields() as $field) { $fieldValue = $form->getSavableFieldValue($field); if ($field && $fieldValue !== "") { update_user_meta($user_id, $field->getName(), $fieldValue); } else { delete_user_meta($user_id, $field->getName()); } } } }
function test_menu_page_url() { $current_user = get_current_user_id(); wp_set_current_user( $this->factory->user->create( array( 'role' => 'administrator' ) ) ); update_option( 'siteurl', 'http://example.com' ); // add some pages add_options_page( 'Test Settings', 'Test Settings', 'manage_options', 'testsettings', 'mt_settings_page' ); add_management_page( 'Test Tools', 'Test Tools', 'manage_options', 'testtools', 'mt_tools_page' ); add_menu_page( 'Test Toplevel', 'Test Toplevel', 'manage_options', 'mt-top-level-handle', 'mt_toplevel_page' ); add_submenu_page( 'mt-top-level-handle', 'Test Sublevel', 'Test Sublevel', 'manage_options', 'sub-page', 'mt_sublevel_page' ); add_submenu_page( 'mt-top-level-handle', 'Test Sublevel 2', 'Test Sublevel 2', 'manage_options', 'sub-page2', 'mt_sublevel_page2' ); add_theme_page( 'With Spaces', 'With Spaces', 'manage_options', 'With Spaces', 'mt_tools_page' ); add_pages_page( 'Appending Query Arg', 'Test Pages', 'edit_pages', 'testpages', 'mt_pages_page' ); $expected['testsettings'] = 'http://example.com/wp-admin/options-general.php?page=testsettings'; $expected['testtools'] = 'http://example.com/wp-admin/tools.php?page=testtools'; $expected['mt-top-level-handle'] = 'http://example.com/wp-admin/admin.php?page=mt-top-level-handle'; $expected['sub-page'] = 'http://example.com/wp-admin/admin.php?page=sub-page'; $expected['sub-page2'] = 'http://example.com/wp-admin/admin.php?page=sub-page2'; $expected['not_registered'] = ''; $expected['With Spaces'] = 'http://example.com/wp-admin/themes.php?page=WithSpaces'; $expected['testpages'] = 'http://example.com/wp-admin/edit.php?post_type=page&page=testpages'; foreach ($expected as $name => $value) { $this->assertEquals( $value, menu_page_url( $name, false ) ); } wp_set_current_user( $current_user ); }
function the_quiz_button($button, $quiz_id) { global $post; $quiz_id = get_the_ID(); $user_id = get_current_user_id(); $flag = 1; if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) { $pid = get_post_meta($quiz_id, 'vibe_quiz_product', true); if (isset($pid) && is_numeric($pid) && get_post_type($pid) == 'product') { $product_taken = wc_customer_bought_product('', $user_id, $pid); if (!$product_taken) { $pid = get_permalink($pid); $check = vibe_get_option('direct_checkout'); $check = intval($check); if (isset($check) && $check) { $pid .= '?redirect'; } $flag = 0; $html = '<a href="' . $pid . '"class="button create-group-button full"> ' . __('Take this Quiz', 'vibe') . '</a>'; } else { $flag = 1; } } } if (in_array('paid-memberships-pro/paid-memberships-pro.php', apply_filters('active_plugins', get_option('active_plugins'))) && is_user_logged_in()) { $membership_ids = vibe_sanitize(get_post_meta($quiz_id, 'vibe_quiz_membership', false)); if (!pmpro_hasMembershipLevel($membership_ids, $user_id) && isset($membership_ids) && count($membership_ids) >= 1) { $membership_taken = get_user_meta($user_id, $quiz_id, true); if (!$membership_taken) { $pmpro_levels_page_id = get_option('pmpro_levels_page_id'); $link = get_permalink($pmpro_levels_page_id); $html = '<a href="' . $link . '"class="button create-group-button full"> ' . __('Take this Quiz', 'vibe') . '</a>'; $flag = 0; } else { $flag = 1; } } } if (in_array('wplms-mycred-addon/wplms-mycred-addon.php', apply_filters('active_plugins', get_option('active_plugins')))) { $points = get_post_meta($quiz_id, 'vibe_quiz_mycred_points', true); $mycred = mycred(); $balance = $mycred->get_users_cred($user_id); if ($balance < $points) { $flag = 0; $html = '<a href="#"class="button create-group-button full"> ' . __('Take this Quiz', 'vibe') . '<span>' . __('<br/>Not enough points.', 'vibe') . '</span></a>'; } if (!$mycred->has_entry('purchase_quiz', $quiz_id, $user_id)) { $flag = 1; $deduct = -1 * $points; $mycred->update_users_balance($user_id, $deduct); $mycred->add_to_log('purchase_quiz', $user_id, $deduct, __('Student subscibed to quiz', 'wplms-mycred'), $quiz_id); } else { $flag = 1; } } if (!$flag) { return $html; } return $button; }
protected function _confirmSubmitButtonAction($sPressedInputName, $sSectionID, $sType = 'reset') { switch ($sType) { default: case 'reset': $_sFieldErrorMessage = $this->oFactory->oMsg->get('reset_options'); $_sTransientKey = 'apf_rc_' . md5($sPressedInputName . get_current_user_id()); break; case 'email': $_sFieldErrorMessage = $this->oFactory->oMsg->get('send_email'); $_sTransientKey = 'apf_ec_' . md5($sPressedInputName . get_current_user_id()); break; } $_aNameKeys = explode('|', $sPressedInputName) + array('', '', ''); $_sFieldID = $this->getAOrB($sSectionID, $_aNameKeys[2], $_aNameKeys[1]); $_aErrors = array(); if ($sSectionID && $_sFieldID) { $_aErrors[$sSectionID][$_sFieldID] = $_sFieldErrorMessage; } else { if ($_sFieldID) { $_aErrors[$_sFieldID] = $_sFieldErrorMessage; } } $this->oFactory->setFieldErrors($_aErrors); $this->setTransient($_sTransientKey, $sPressedInputName, 60 * 2); $this->oFactory->setSettingNotice($this->oFactory->oMsg->get('confirm_perform_task'), 'error confirmation'); return $this->oFactory->oProp->aOptions; }
/** * * Process the infoz * @since 1.0 */ function user_info() { if (isset($_POST['action'])) { // bail out if this user isnt logged in if (!is_user_logged_in()) { return; } if (!wp_verify_nonce($_POST['nonce'], 'process-user-info')) { return; } $user_id = get_current_user_id(); if ($_POST['action'] == 'process_user_info') { $gender = isset($_POST['gender']) ? sanitize_text_field($_POST['gender']) : false; $age = isset($_POST['age']) ? sanitize_text_field($_POST['age']) : false; $education = isset($_POST['education']) ? sanitize_text_field($_POST['education']) : false; $employment = isset($_POST['employment']) ? sanitize_text_field($_POST['employment']) : false; $data = array('gender' => $gender, 'age' => $age, 'education' => $education, 'employment' => $employment); update_user_meta($user_id, 'user_info', $data); update_user_meta($user_id, 'user_info_completed', 1); do_action('user_info_updated', $user_id, $data); wp_send_json_success(); } else { wp_send_json_error(); } } else { wp_send_json_error(); } }
/** * Show message if already applied */ public function already_applied_message() { global $post; if (is_user_logged_in() && user_has_applied_for_job(get_current_user_id(), $post->ID)) { get_job_manager_template('applied-notice.php', array(), 'wp-job-manager-applications', JOB_MANAGER_APPLICATIONS_PLUGIN_DIR . '/templates/'); } }
/** * Class constructor * * Sets definitions * Adds methods to appropriate hooks * * @author Ronald Huereca <*****@*****.**> * @since 1.0.0 * @access public * @param array $args If not set, then uses $defaults instead */ public function __construct($args) { // Get posts per page $user_id = get_current_user_id(); $posts_per_page = get_user_meta($user_id, 'reorder_items_per_page', true); if (!is_numeric($posts_per_page)) { $posts_per_page = 50; } $offset = absint($posts_per_page - 2); // Parse arguments $defaults = array('post_type' => '', 'posts_per_page' => $posts_per_page, 'offset' => $offset); $args = wp_parse_args($args, $defaults); // Set variables $this->post_type = $args['post_type']; //Get offset and posts_per_page $this->posts_per_page = absint($args['posts_per_page']); //todo - filterable? $this->offset = absint($args['offset']); //todo - filterable? if ($this->offset > $this->posts_per_page) { $this->offset = $this->posts_per_page; } //Add-on actions/filters add_action('metronet_reorder_menu_url_' . $this->post_type, array($this, 'set_reorder_url')); add_action('reorder_by_terms_interface_' . $this->post_type, array($this, 'output_interface')); add_action('metronet_reorder_posts_add_menu_' . $this->post_type, array($this, 'script_init')); add_filter('metronet_reorder_posts_tabs_' . $this->post_type, array($this, 'add_tab')); //Ajax actions add_action('wp_ajax_reorder_terms_only_sort', array($this, 'ajax_term_sort')); }
/** * @ticket 26948 */ public function test_dont_process_terms_if_taxonomy_does_not_allow_show_on_quick_edit() { register_taxonomy('wptests_tax_1', 'post', array('show_in_quick_edit' => false, 'hierarchical' => true)); register_taxonomy('wptests_tax_2', 'post', array('show_in_quick_edit' => true, 'hierarchical' => true)); $t1 = self::factory()->term->create(array('taxonomy' => 'wptests_tax_1')); $t2 = self::factory()->term->create(array('taxonomy' => 'wptests_tax_2')); // Become an administrator. $this->_setRole('administrator'); $post = self::factory()->post->create_and_get(array('post_author' => get_current_user_id())); // Set up a request. $_POST['_inline_edit'] = wp_create_nonce('inlineeditnonce'); $_POST['post_ID'] = $post->ID; $_POST['post_type'] = $post->post_type; $_POST['content'] = $post->post_content; $_POST['excerpt'] = $post->post_excerpt; $_POST['_status'] = $post->post_status; $_POST['post_status'] = $post->post_status; $_POST['screen'] = 'post'; $_POST['post_view'] = 'excerpt'; $_POST['tax_input'] = array('wptests_tax_1' => array($t1), 'wptests_tax_2' => array($t2)); // Make the request. try { $this->_handleAjax('inline-save'); } catch (WPAjaxDieContinueException $e) { unset($e); } // wptests_tax_1 terms should have been refused. $post_terms_1 = wp_get_object_terms($post->ID, 'wptests_tax_1'); $this->assertEmpty($post_terms_1); // wptests_tax_2 terms should have been added successfully. $post_terms_2 = wp_get_object_terms($post->ID, 'wptests_tax_2'); $this->assertEqualSets(array($t2), wp_list_pluck($post_terms_2, 'term_id')); }
function init_todos_db() { todolog("json_data_access.php | initializing todosDB"); global $todosDB; global $todos_db_file; if (!$todosDB) { $currentUserId = get_current_user_id(); if (!$currentUserId) { trigger_error("Please login before trying to access your To Do list"); } $todos_db_file = __DIR__ . "/../data/{$currentUserId}.json"; $todos_json_string = file_get_contents($todos_db_file); $tmpDB = json_decode($todos_json_string); $stdTodos = $tmpDB->todos; //print_r($stdTodos); $todoCount = count($stdTodos); //print_r($todoCount); $todosDB = array("nextId" => $tmpDB->nextId); if ($todoCount > 0) { todolog("json_data_access.php | found {$todoCount} todos"); $tmpTodos = array(); for ($index = 0; $index < $todoCount; $index++) { $tdo = $stdTodos[$index]; $todoObj = convert_todo_stdclass_to_map($tdo); array_push($tmpTodos, $todoObj); } $todosDB["todos"] = $tmpTodos; } else { $todosDB["todos"] = array(); } } }
public function initialize() { $this->user = new stdClass(); if (is_user_logged_in()) { /* Populate settings we need for the menu based on the current user. */ $this->user->blogs = get_blogs_of_user(get_current_user_id()); if (is_multisite()) { $this->user->active_blog = get_active_blog_for_user(get_current_user_id()); $this->user->domain = empty($this->user->active_blog) ? user_admin_url() : trailingslashit(get_home_url($this->user->active_blog->blog_id)); $this->user->account_domain = $this->user->domain; } else { $this->user->active_blog = $this->user->blogs[get_current_blog_id()]; $this->user->domain = trailingslashit(home_url()); $this->user->account_domain = $this->user->domain; } } add_action('wp_head', 'wp_admin_bar_header'); add_action('admin_head', 'wp_admin_bar_header'); if (current_theme_supports('admin-bar')) { $admin_bar_args = get_theme_support('admin-bar'); // add_theme_support( 'admin-bar', array( 'callback' => '__return_false') ); $header_callback = $admin_bar_args[0]['callback']; } if (empty($header_callback)) { $header_callback = '_admin_bar_bump_cb'; } add_action('wp_head', $header_callback); wp_enqueue_script('admin-bar'); wp_enqueue_style('admin-bar'); do_action('admin_bar_init'); }
/** * @see CPAC_Column_Actions::get_actions() * @since 2.4.7 */ public function get_actions($id) { $actions = array(); $user_object = new WP_User($id); $screen = get_current_screen(); if ('site-users-network' == $screen->id) { $url = "site-users.php?id={$this->site_id}&"; } else { $url = 'users.php?'; } if (get_current_user_id() == $user_object->ID) { $edit_link = 'profile.php'; } else { $edit_link = esc_url(add_query_arg('wp_http_referer', urlencode(stripslashes($_SERVER['REQUEST_URI'])), "user-edit.php?user_id={$user_object->ID}")); } if (current_user_can('edit_user', $user_object->ID)) { $edit = "<strong><a href=\"{$edit_link}\">{$user_object->user_login}</a></strong><br />"; $actions['edit'] = '<a href="' . $edit_link . '">' . __('Edit') . '</a>'; } else { $edit = "<strong>{$user_object->user_login}</strong><br />"; } if (!is_multisite() && get_current_user_id() != $user_object->ID && current_user_can('delete_user', $user_object->ID)) { $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url("users.php?action=delete&user={$user_object->ID}", 'bulk-users') . "'>" . __('Delete') . "</a>"; } if (is_multisite() && get_current_user_id() != $user_object->ID && current_user_can('remove_user', $user_object->ID)) { $actions['remove'] = "<a class='submitdelete' href='" . wp_nonce_url($url . "action=remove&user={$user_object->ID}", 'bulk-users') . "'>" . __('Remove') . "</a>"; } return $actions; }
/** * Outputs the content of the widget * * @param array $args * @param array $instance */ public function widget($args, $instance) { $title = apply_filters('widget_title', $instance['title']); echo $args['before_widget']; echo '<div class="event-widget">'; if (is_user_logged_in()) { if (!empty($instance['title'])) { echo $args['before_title'] . __('Profile Links') . $args['after_title']; } $user_ID = get_current_user_id(); $profile_id = get_user_meta($user_ID, 'uiu_profile', TRUE); $profile_link = !empty($profile_id) ? get_permalink($profile_id) : get_dashboard_url($user_ID); ?> <ul class="menu user-menu"> <li class="menu-item"><a href="<?php echo $profile_link; ?>">My Profile</a> </li> <li class="menu-item"><a href="<?php echo wp_logout_url(site_url()); ?>">Logout</a> </li> </ul> <?php } else { if (!empty($instance['title'])) { echo $args['before_title'] . apply_filters('widget_title', $instance['title']) . $args['after_title']; } wp_login_form($args); } echo $args['after_widget']; }
function hide_notice() { if (isset($_GET['wpupg_hide_new_notice'])) { check_admin_referer('wpupg_hide_new_notice', 'wpupg_hide_new_notice'); update_user_meta(get_current_user_id(), '_wpupg_hide_new_notice', get_option(WPUltimatePostGrid::get()->pluginName . '_version')); } }
public function log($connector, $message, $args, $object_id, $contexts, $user_id = null) { global $wpdb; if (is_null($user_id)) { $user_id = get_current_user_id(); } require_once MAINWP_WP_STREAM_INC_DIR . 'class-wp-stream-author.php'; $user = new WP_User($user_id); $roles = get_option($wpdb->get_blog_prefix() . 'user_roles'); if (!isset($args['author_meta'])) { $args['author_meta'] = array('user_email' => $user->user_email, 'display_name' => defined('WP_CLI') && empty($user->display_name) ? 'WP-CLI' : $user->display_name, 'user_login' => $user->user_login, 'user_role_label' => !empty($user->roles) ? $roles[$user->roles[0]]['name'] : null, 'agent' => MainWP_WP_Stream_Author::get_current_agent()); if (defined('WP_CLI') && function_exists('posix_getuid')) { $uid = posix_getuid(); $user_info = posix_getpwuid($uid); $args['author_meta']['system_user_id'] = $uid; $args['author_meta']['system_user_name'] = $user_info['name']; } } // Remove meta with null values from being logged $meta = array_filter($args, function ($var) { return !is_null($var); }); $recordarr = array('object_id' => $object_id, 'site_id' => is_multisite() ? get_current_site()->id : 1, 'blog_id' => apply_filters('blog_id_logged', is_network_admin() ? 0 : get_current_blog_id()), 'author' => $user_id, 'author_role' => !empty($user->roles) ? $user->roles[0] : null, 'created' => current_time('mysql', 1), 'summary' => vsprintf($message, $args), 'parent' => self::$instance->prev_record, 'connector' => $connector, 'contexts' => $contexts, 'meta' => $meta, 'ip' => mainwp_wp_stream_filter_input(INPUT_SERVER, 'REMOTE_ADDR', FILTER_VALIDATE_IP)); $record_id = MainWP_WP_Stream_DB::get_instance()->insert($recordarr); return $record_id; }
function wsl_watchdog_log_to_database($action_name, $action_args = array(), $user_id = 0, $provider = '') { global $wpdb; $sql = "CREATE TABLE IF NOT EXISTS `{$wpdb->prefix}wslwatchdog` ( \n\t\t\t `id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t `session_id` varchar(50) NOT NULL,\n\t\t\t `user_id` int(11) NOT NULL,\n\t\t\t `user_ip` varchar(50) NOT NULL,\n\t\t\t `url` varchar(450) NOT NULL,\n\t\t\t `provider` varchar(50) NOT NULL,\n\t\t\t `action_name` varchar(255) NOT NULL,\n\t\t\t `action_args` text NOT NULL,\n\t\t\t `is_connected` int(11) NOT NULL,\n\t\t\t `created_at` varchar(50) NOT NULL,\n\t\t\t PRIMARY KEY (`id`) \n\t\t\t)"; $wpdb->query($sql); $wpdb->insert("{$wpdb->prefix}wslwatchdog", array("session_id" => session_id(), "user_id" => $user_id, "user_ip" => $_SERVER['REMOTE_ADDR'], "url" => wsl_get_current_url(), "provider" => $provider, "action_name" => $action_name, "action_args" => json_encode($action_args), "is_connected" => get_current_user_id() ? 1 : 0, "created_at" => microtime(true))); }
function filter_user_reply($ids) { $data = get_option('mm_user_cap'); $user = new WP_User(get_current_user_id()); $roles = array(); //not init, use default if (!$data) { return $ids; } foreach ($user->roles as $role) { if (isset($data[$role])) { $roles = array_merge($roles, $data[$role]); } } foreach ($ids as $id) { if ($id != get_current_user_id()) { $send_to = new WP_User($id); //check if this user role in the list can send if (count(array_intersect($send_to->roles, $roles)) == 0) { unset($ids[array_search($id, $ids)]); } } } return $ids; }