public static function verify_cookie($value) { if ($old_user_id = wp_validate_auth_cookie($value, 'logged_in')) { return user_can($old_user_id, 'view_query_monitor'); } return false; }
function app_process_login_form() { global $posted; if (isset($_REQUEST['redirect_to'])) { $redirect_to = $_REQUEST['redirect_to']; } else { $redirect_to = admin_url(); } if (is_ssl() && force_ssl_login() && !force_ssl_admin() && 0 !== strpos($redirect_to, 'https') && 0 === strpos($redirect_to, 'http')) { $secure_cookie = false; } else { $secure_cookie = ''; } $user = wp_signon('', $secure_cookie); $redirect_to = apply_filters('login_redirect', $redirect_to, isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : '', $user); if (!is_wp_error($user)) { // automatically redirect admins to the WP back-end if (user_can($user, 'manage_options')) { $redirect_to = admin_url('admin.php?page=admin-options.php'); } // otherwise redirect them to the hidden post url wp_safe_redirect($redirect_to); exit; } $errors = $user; return $errors; }
/** * Check if a user is customer * * @param int $user_id * @return boolean */ function dokan_is_user_customer($user_id) { if (!user_can($user_id, 'customer')) { return false; } return true; }
/** * API method to check if a user has access to a certain post. * Since v2.0 */ function pmpro_xmlrpc_hasMembershipAccess($args) { // Parse the arguments, assuming they're in the correct order $username = $args[0]; $password = $args[1]; $post_id = $args[2]; //post id to check $user_id = $args[3]; //optional user id passed in $return_membership_levels = $args[4]; //option to also include an array of membership levels with access to the post global $wp_xmlrpc_server; // Let's run a check to see if credentials are okay if (!($user = $wp_xmlrpc_server->login($username, $password))) { return $wp_xmlrpc_server->error; } // The user passed should be an admin or have the pmpro_xmlprc capability if (!user_can($user->ID, "manage_options") && !user_can($user->ID, "pmpro_xmlrpc")) { return "ERROR: User does not have access to the PMPro XMLRPC methods."; } // Default to logged in user if no user_id is given. if (empty($user_id)) { $user_id = $user->ID; } $has_access = pmpro_has_membership_access($post_id, $user_id, $return_membership_levels); return $has_access; }
/** * Edit a singular comment * * @param integer $comment_id Comment to view * @return void */ public function edit($comment_id) { $comment = $this->comment_model->get($comment_id); $user_id = current_user_id(); // Make sure the comment exists if ($comment) { // Are we an admin or have permission to edit comments? if (is_admin() or user_can('edit_own_comments')) { // Are we an admin or the owner of the comment itself? if (is_admin() || $comment->user_id == $user_id) { // Run form validation if ($this->form_validation->run('edit_comment') == FALSE) { $this->data['comment'] = $comment; $this->parser->parse('edit_comment', $this->data); } else { $update = $this->comment_model->update_comment($comment->id, $comment->story_id, $user_id, $comment->parent_id, $this->input->post('comment')); $this->parser->parse('edit_comment', $this->data); } } else { show_error("You do not have permission to edit this comment.", 500); } } else { show_error("You do not have permission to edit this comment.", 500); } } else { show_error("That comment doesn't exist", 404); } }
/** * Check if a user is seller * * @param int $user_id * @return boolean */ function dokan_is_user_seller($user_id) { if (!user_can($user_id, 'dokandar')) { return false; } return true; }
/** * Echo the comment badges. * * @since 1.0.0 */ function beans_comment_badges() { global $comment; // Trackback badge. if ($comment->comment_type == 'trackback') { echo beans_open_markup('beans_trackback_badge', 'span', array('class' => 'uk-badge uk-margin-small-left')); echo beans_output('beans_trackback_text', __('Trackback', 'tm-beans')); echo beans_close_markup('beans_trackback_badge', 'span'); } // Pindback badge. if ($comment->comment_type == 'pingback') { echo beans_open_markup('beans_pingback_badge', 'span', array('class' => 'uk-badge uk-margin-small-left')); echo beans_output('beans_pingback_text', __('Pingback', 'tm-beans')); echo beans_close_markup('beans_pingback_badge', 'span'); } // Moderation badge. if ('0' == $comment->comment_approved) { echo beans_open_markup('beans_moderation_badge', 'span', array('class' => 'uk-badge uk-margin-small-left uk-badge-warning')); echo beans_output('beans_moderation_text', __('Awaiting Moderation', 'tm-beans')); echo beans_close_markup('beans_moderation_badge', 'span'); } // Moderator badge. if (user_can($comment->user_id, 'moderate_comments')) { echo beans_open_markup('beans_moderator_badge', 'span', array('class' => 'uk-badge uk-margin-small-left')); echo beans_output('beans_moderator_text', __('Moderator', 'tm-beans')); echo beans_close_markup('beans_moderator_badge', 'span'); } }
function govi_main_theme_menu() { $current_user = wp_get_current_user(); $user_id = $current_user->ID; if (!user_can($user_id, 'create_users')) { return false; } ?> <div class="wrap govi-panel-wrap"> <div class="govi-admin-title-wrap"><h2>PMC Opções do Tema</h2></div> <div class="settings-top-strip"><a id="general-button" class="general-save-button" href="#">Salvar Opções</a></div> <div id="tabs"> <ul> <li><a rel="govi-generla-settings" href="#govi-general-settings">Opções Gerais</a></li> <li><a rel="govi-homepage-settings" href="#govi-home-settings">Página de Inicio</a></li> <li><a rel="govi-contact-links" href="#govi-contact-links">Links de Contato</a></li> <li><a rel="govi-element-settings" href="#govi-element-setings">Elementos</a></li> <li><a rel="govi-color-picker-elements-tab" href="#govi-social-midia">Redes Sociais</a></li> </ul> <?php general_settings(); govi_home_settings(); govi_contact_links(); govi_element_settings(); govi_social_midia_links(); ?> </div> <div class="settings-bottom-strip"><a id="general-button" class="general-save-button" href="#">Salvar Opções</a></div> </div> <?php }
function testTranslatorCaps() { global $wp_roles; $this->assertTrue($wp_roles->is_role('translator')); # Translators can manage translation jobs: $this->assertTrue(user_can($this->translator->ID, 'edit_bbl_jobs')); }
function pg_has_topics($args = '') { //check if being called by subscriptions and if so skip filtering (as you can only subscribe to forums you can already see) if ($args['post__in']) { return $args; } $default_post_parent = bbp_is_single_forum() ? bbp_get_forum_id() : 'any'; if ($default_post_parent == 'any') { if (bbp_is_user_keymaster()) { return $args; } $user_id = wp_get_current_user()->ID; if (user_can($user_id, 'moderate')) { $check = get_user_meta($user_id, 'private_group', true); if ($check == '') { return $args; } } global $wpdb; $topic = bbp_get_topic_post_type(); $post_ids = $wpdb->get_col("select ID from {$wpdb->posts} where post_type = '{$topic}'"); //check this list against those the user is allowed to see, and create a list of valid ones for the wp_query in bbp_has_topics $allowed_posts = check_private_groups_topic_ids($post_ids); $args['post__in'] = $allowed_posts; } return $args; }
function bogo_get_user_locale($user_id = 0) { global $current_user; $default_locale = bogo_get_default_locale(); $user_id = absint($user_id); if (!$user_id) { if (function_exists('wp_get_current_user') && !empty($current_user)) { $user_id = get_current_user_id(); } elseif (!($user_id = apply_filters('determine_current_user', false))) { return $default_locale; } } $locale = get_user_option('locale', $user_id); if (bogo_is_available_locale($locale) && user_can($user_id, 'bogo_access_locale', $locale)) { return $locale; } if (user_can($user_id, 'bogo_access_locale', $default_locale)) { return $default_locale; } foreach ((array) bogo_available_locales() as $locale) { if (user_can($user_id, 'bogo_access_locale', $locale)) { return $locale; } } return $default_locale; }
public function save($userModel = 'memberspace/user', $mailRedirect = 'memberspace/confirmation/confirm', $redirect = null) { $post = $this->input->post(); $modelName = pathinfo($userModel)['filename']; if (!$post || !isset($post['save-' . $modelName])) { return array(); } unset($_POST['save-' . $modelName]); $this->load->library('form_validation'); if (isset($post['id']) && !user_can('update', $userModel, $post['id'])) { return $post; } $this->load->model($userModel); $userId = $this->{$modelName}->fromPost(); if ($userId === false) { add_error($this->form_validation->error_string()); return $post; } if (!isset($post['id'])) { $this->sendMailConfirmation($userId, $mailRedirect); add_success('Vous avez bien été inscrit !'); } else { add_success('Vous avez bien mis à jour vos informations'); } if ($redirect) { redirect($redirect); } return $post; }
function schoolpress_admin_check() { global $user_ID; if (!user_can($user_ID, 'administrator')) { wp_redirect(site_url()); } }
function jr_process_login_form() { global $posted; if (isset($_REQUEST['redirect_to'])) { $redirect_to = $_REQUEST['redirect_to']; } else { $redirect_to = admin_url(); } if (is_ssl() && force_ssl_login() && !force_ssl_admin() && 0 !== strpos($redirect_to, 'https') && 0 === strpos($redirect_to, 'http')) { $secure_cookie = false; } else { $secure_cookie = ''; } $user = wp_signon('', $secure_cookie); $redirect_to = apply_filters('login_redirect', $redirect_to, isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : '', $user); if (!is_wp_error($user)) { if (user_can($user, 'manage_options')) { $redirect_to = admin_url(); } wp_safe_redirect($redirect_to); exit; } $errors = $user; return $errors; }
function pg_get_user_replies_created($user_id = 0) { // Validate user $user_id2 = bbp_get_user_id($user_id); $current_user = wp_get_current_user()->ID; if (empty($user_id)) { return false; } if (bbp_is_user_keymaster()) { $limit = 'n'; } if (user_can($current_user, 'moderate')) { $check = get_user_meta($current_user, 'private_group', true); if ($check == '') { $limit = 'n'; } } if ($limit != 'n') { global $wpdb; $reply = bbp_get_reply_post_type(); $post_ids = $wpdb->get_col("select ID from {$wpdb->posts} where post_type = '{$reply}'"); //check this list against those the user is allowed to see, and create a list of valid ones for the wp_query in bbp_has_topics $allowed_posts = check_private_groups_reply_ids($post_ids); } // The default reply query with allowed topic and reply ids array added // Try to get the topics $query = bbp_has_replies(array('post_type' => bbp_get_reply_post_type(), 'order' => 'DESC', 'author' => $user_id2, 'post__in' => $allowed_posts)); return apply_filters('pg_get_user_replies_created', $query, $user_id); }
private static function _save_search($args) { extract($args); if (!empty($user) && !empty($hash)) { if (!user_can($user->ID, self::$_capabilities['save_search']) || user_can($user->ID, self::$_capabilities['view_leads'])) { return 'User does not have the capability to save searches.'; } if (empty($name_exists)) { $saved_searches = !empty($user->{self::$_meta_keys['lead']['saved_searches']}) ? $user->{self::$_meta_keys['lead']['saved_searches']} : array(); $this_search = array('hash' => $hash, 'name' => $search_name); if (!empty($user->{self::$_meta_keys['api_user_id']})) { $saved_search_criteria = DispletRetsIdxResidentialsModel::get_search_criteria_from_hash($hash); $saved_search_id = DispletRetsIdxUsersApiController::create_saved_search($user->{self::$_meta_keys['api_user_id']}, $search_name, $saved_search_criteria); if (isset($saved_search_id)) { $this_search['api_id'] = $saved_search_id; } } $saved_searches[] = $this_search; update_user_meta($user->ID, self::$_meta_keys['lead']['saved_searches'], $saved_searches); new DispletRetsIdxEmail('saved_search', array('agent_id' => DispletRetsIdxLeadsModel::get_assigned_agent_id($user->ID), 'lender_id' => DispletRetsIdxLeadsModel::get_assigned_lender_id($user->ID), 'search_url' => trailingslashit(get_permalink(self::$_options['search_results_page_id'])) . $hash, 'user_email' => $user->user_email, 'user_name' => $user->display_name, 'user_phone' => $user->{self::$_meta_keys['lead']['phone']})); do_action('displetretsidx_post_lead_saved_search', $user->ID, $this_search); return 'Saved Search'; } } }
function force_2fa() { // Allows WP.com login to a local account if it matches the local account. add_filter('jetpack_sso_match_by_email', '__return_true', 9999); // multisite if (is_multisite()) { // Hide the login form add_filter('jetpack_remove_login_form', '__return_true', 9999); add_filter('jetpack_sso_bypass_login_forward_wpcom', '__return_true', 9999); add_filter('jetpack_sso_display_disclaimer', '__return_false', 9999); add_filter('wp_authenticate_user', function () { return new WP_Error('wpcom-required', "Local login disabled for this site."); }, 9999); add_filter('jetpack_sso_require_two_step', '__return_true'); add_filter('allow_password_reset', '__return_false'); } else { // Completely disable the standard login form for admins. add_filter('wp_authenticate_user', function ($user) { if ($user->has_cap($this->role)) { return new WP_Error('wpcom-required', "Local login disabled for this account.", $user->user_login); } return $user; }, 9999); add_filter('allow_password_reset', function ($allow, $user_id) { if (user_can($user_id, $this->role)) { return false; } return $allow; }, 9999, 2); add_action('jetpack_sso_pre_handle_login', array($this, 'jetpack_set_two_step_for_admins')); } }
/** * Checks whether the input user is allowed to edit this job * * @param stdClass|WP_User $user * * @return bool */ public function user_can_translate($user) { $translator_id = $this->get_translator_id(); $user_can_take_this_job = $translator_id === 0 || $translator_id === (int) $user->ID; $translator_has_job_language_pairs = $this->blog_translators->is_translator($user->ID, array('lang_from' => $this->get_source_language_code(), 'lang_to' => $this->get_language_code())); return $user_can_take_this_job && $translator_has_job_language_pairs || method_exists($user, 'has_cap') && $user->has_cap('manage_options') || !method_exists($user, 'has_cap') && user_can($user->ID, 'manage_options'); }
function ajax_return_to_admin_panel() { global $wpdb; if (!empty($_POST['secure_key'])) { $verify = $_POST['secure_key']; } else { exit(json_encode(array('status' => false, 'message' => __("Wrong data", WPC_CLIENT_TEXT_DOMAIN)))); } if (!empty($_COOKIE['wpc_key']) && is_user_logged_in()) { $key = $_COOKIE['wpc_key']; $user_data = $wpdb->get_row($wpdb->prepare("SELECT umeta_id, user_id, meta_value FROM {$wpdb->usermeta} WHERE meta_key = 'wpc_client_admin_secure_data' AND meta_value LIKE '%s'", '%"' . md5($key) . '"%'), ARRAY_A); if (isset($user_data['user_id']) && user_can($user_data['user_id'], 'wpc_admin_user_login') && wp_verify_nonce($verify, get_current_user_id() . $user_data['user_id'])) { if (!empty($user_data['meta_value'])) { $secure_array = unserialize($user_data['meta_value']); if (isset($secure_array['end_date']) && $secure_array['end_date'] > time()) { wp_set_auth_cookie($user_data['user_id'], true); $wpdb->delete($wpdb->usermeta, array('umeta_id' => $user_data['umeta_id'])); $secure_logged_in_cookie = 'https' === parse_url(get_option('home'), PHP_URL_SCHEME); setcookie("wpc_key", '', time() - 1, SITECOOKIEPATH, COOKIE_DOMAIN, $secure_logged_in_cookie, true); exit(json_encode(array('status' => true, 'message' => admin_url('admin.php?page=wpclient_clients')))); } } } } exit(json_encode(array('status' => false, 'message' => __("Wrong data", WPC_CLIENT_TEXT_DOMAIN)))); }
/** * Upgrades vendor permissions * * @since 2.2 * @return void */ function fes_22_upgrade_vendor_permissions() { $fes_version = get_option('fes_db_version', '2.1'); if (version_compare($fes_version, '2.2', '>=')) { return; } ignore_user_abort(true); if (!edd_is_func_disabled('set_time_limit') && !ini_get('safe_mode')) { set_time_limit(0); } $step = isset($_GET['step']) ? absint($_GET['step']) : 1; $offset = $step == 1 ? 0 : $step * 100; $users = new WP_User_Query(array('fields' => 'ID', 'number' => 100, 'offset' => $offset)); $users = $users->results; if ($users && count($users) > 0) { foreach ($users as $user => $id) { if (user_can($id, 'fes_is_vendor') && !user_can($id, 'fes_is_admin') && !user_can($id, 'administrator') && !user_can($id, 'editor')) { $user = new WP_User($id); $user->add_role('frontend_vendor'); } } // Keys found so upgrade them $step++; $redirect = add_query_arg(array('page' => 'fes-upgrades', 'edd_upgrade' => 'upgrade_vendor_permissions', 'step' => $step), admin_url('index.php')); wp_redirect($redirect); exit; } else { // No more keys found, update the DB version and finish up update_option('fes_db_version', fes_plugin_version); wp_redirect(admin_url('admin.php?page=fes-about')); exit; } }
/** * Test filtering user_has_cap. * * @see Plugin::filter_user_has_cap() */ function test_filter_user_has_cap() { $admin_user_id = $this->factory->user->create(array('role' => 'administrator')); $editor_user_id = $this->factory->user->create(array('role' => 'editor')); $this->assertFalse(user_can($editor_user_id, 'customize_publish')); $this->assertTrue(user_can($admin_user_id, 'customize_publish')); }
function dwqa_single_postclass($post_class) { global $post, $current_user; if (get_post_type($post) == 'dwqa-answer') { $post_class[] = 'dwqa-answer'; $post_class[] = 'dwqa-status-' . get_post_status($post->ID); if (dwqa_is_answer_flag($post->ID)) { $post_class[] = 'answer-flagged-content'; } if (user_can($post->post_author, 'edit_published_posts')) { $post_class[] = 'staff'; } $question_id = get_post_meta($post->ID, '_question', true); $best_answer_id = dwqa_get_the_best_answer($question_id); if ($best_answer_id && $best_answer_id == $post->ID) { $post_class[] = 'best-answer'; } if (!is_user_logged_in() || $current_user->ID != $post->ID || !current_user_can('edit_posts')) { $post_class[] = 'dwqa-no-click'; } } if (get_post_type($post) == 'dwqa-answer' && get_post_type($post) == 'dwqa-question') { if (in_array('hentry', $post_class)) { unset($post_class); } } return $post_class; }
/** * Render the user meta box in WordPress, associating it to the specified * user roles. * * @since 0.2.0 */ public function render() { global $user_id; if ($user_id) { $user = get_user_by('id', $user_id); if (!$user) { return; } /* Check if the meta box should be displayed for the current user's role. */ $check_current_user_role = true; if (!empty($this->_roles)) { foreach ((array) $this->_roles as $role) { $check_current_user_role = user_can($user, $role); if ($check_current_user_role) { break; } } } if (!$check_current_user_role) { return; } /* Check if the current can edit the user. */ $check_current_user_can_edit_user = $user && current_user_can('edit_user', $user->ID); if (!$check_current_user_can_edit_user) { return; } echo '<div class="ev ev-native-meta ev-user-metabox">'; wp_nonce_field('ev_user_meta_box', 'ev'); printf('<h3>%s</h3>', esc_html($this->title())); $this->render_elements(); echo '</div>'; } }
function pending_submission_send_email($new_status, $old_status, $post) { // Notifiy Admin that Contributor has writen a post if ($new_status == 'pending' && user_can($post->post_author, 'edit_posts') && !user_can($post->post_author, 'publish_posts')) { $pending_submission_email = get_option('pending_submission_notification_admin_email'); $admins = get_option('admin_email'); $url = get_permalink($post->ID); $edit_link = get_edit_post_link($post->ID, ''); $preview_link = get_permalink($post->ID) . '&preview=true'; $username = get_userdata($post->post_author); $subject = 'Nou article pendent: "' . $post->post_title . '"'; $message = 'Un nou article per revisar.'; $message .= "\r\n\r\n"; $message .= "Autor: {$username->user_login}\r\n"; $message .= "Títol: {$post->post_title}"; $message .= "\r\n\r\n"; $message .= "Edita: {$edit_link}\r\n"; $message .= "Visualitza: {$preview_link}"; $result = wp_mail($admins, $subject, $message); } else { if ($old_status == 'pending' && $new_status == 'publish' && user_can($post->post_author, 'edit_posts') && !user_can($post->post_author, 'publish_posts')) { $username = get_userdata($post->post_author); $url = get_permalink($post->ID); $subject = "El vostre article ha estat publicat:" . " " . $post->post_title; $message = '"' . $post->post_title . '"' . " ha estat aprovat i publicat. \r\n"; $message .= $url; $result = wp_mail($username->user_email, $subject, $message); } } }
/** * Check if a reply is needed. * * Takes a ticket ID and checks if a reply is needed. The check is based * on who replied last. If a client was the last to reply, or if the ticket * was just transferred from one agent to another, then it is considered * as "awaiting reply". * * @since 3.0.0 * @param integer $post_id The ID of the ticket to check * @param object $latest The object containing the ticket replies. If the object was previously generated we pass it directly in order to avoid re-querying * @return boolean True if a reply is needed, false otherwise */ function wpas_is_reply_needed($post_id, $latest = null) { if ('closed' === wpas_get_ticket_status($post_id)) { return false; } /* Prepare the new object */ if (is_null($latest)) { $latest = new WP_Query(array('posts_per_page' => 1, 'orderby' => 'post_date', 'order' => 'DESC', 'post_type' => 'ticket_reply', 'post_parent' => $post_id, 'post_status' => array('unread', 'read'), 'no_found_rows' => true, 'cache_results' => false, 'update_post_term_cache' => false, 'update_post_meta_cache' => false)); } /* No reply yet. */ if (empty($latest->posts)) { $post = get_post($post_id); /* Make sure the ticket wan not created by an agent on behalf of the client. */ if (!user_can($post->post_author, 'edit_ticket')) { return true; } } else { $last = $latest->post_count - 1; /* Check if the last user who replied is an agent. */ if (!user_can($latest->posts[$last]->post_author, 'edit_ticket') && 'unread' === $latest->posts[$last]->post_status) { return true; } } return false; }
public function store_commission_data($data, $query_mode, $api_object) { if ('store-commissions' != $query_mode) { return $data; } $user_id = $api_object->get_user(); if (!user_can($user_id, 'view_shop_reports')) { return $data; } $data = array('commissions' => array()); $paged = $api_object->get_paged(); $status = isset($_REQUEST['status']) ? sanitize_text_field($_REQUEST['status']) : 'unpaid'; $commission_args = array('post_type' => 'edd_commission', 'post_status' => 'publish', 'posts_per_page' => $api_object->per_page(), 'paged' => $paged); if ($status) { $commission_args['tax_query'] = array(array('taxonomy' => 'edd_commission_status', 'terms' => $status, 'field' => 'slug')); } $commissions = get_posts($commission_args); if ($commissions) { foreach ($commissions as $commission) { $commission_meta = get_post_meta($commission->ID, '_edd_commission_info', true); $commission_meta = get_post_meta($commission->ID, '_edd_commission_info', true); $renewal = (bool) get_post_meta($commission->ID, '_edd_commission_is_renewal', true); $data['commissions'][] = array('amount' => edd_sanitize_amount($commission_meta['amount']), 'rate' => $commission_meta['rate'], 'currency' => $commission_meta['currency'], 'item' => get_the_title($download_id), 'status' => eddc_get_commission_status($commission->ID), 'date' => $commission->post_date, 'renewal' => $renewal ? 1 : 0); } wp_reset_postdata(); } $data['total_unpaid'] = eddc_get_unpaid_totals(); return $data; }
/** * Set the content width based on the theme's design and stylesheet. * * Used to set the width of images and content. Should be equal to the width the theme * is designed for, generally via the style.css stylesheet. */ function comment_author_profile_link() { /* Get the comment author information */ global $comment; $comment_ID = $comment->user_id; $author = get_comment_author($comment_ID); $url = get_comment_author_url($comment_ID); /* Check if commenter is registered or not */ /* Registered Commenter */ $registeredID = get_userdata($comment_ID); $authorName = $registeredID->display_name; $authorLevel = $registeredID->user_level; $authorURL = $registeredID->user_url; $authorID = $registeredID->ID; /* Check if they have edit posts capabilities & is author or higher */ if ($authorLevel > 1 && user_can($authorID, 'edit_posts') == true && count_user_posts($authorID) > 0) { /* Author+ with Posts */ $return = '<a href="' . home_url() . '/?author=' . $authorID . '">' . $authorName . '</a>'; } else { /* Below Author */ if (empty($authorURL) || 'http://' == $authorURL) { $return = $authorName; } else { $return = "<a href='{$authorURL}' rel='external nofollow' class='url' target='_blank'>{$authorName}</a>"; } } return $return; }
private function turn($on) { if (user_can('edit', 'maintenance')) { $this->configuration->setValue('maintenance', $on); } $this->layout->view('maintenance/edit'); }
public function save($id = null) { $this->load->helper('memberspace/authorization'); $this->load->helper('flashmessages/flashmessages'); $this->load->model('memberspace/user'); $this->load->helper('form'); $datas = array(); if (isset($_POST) && isset($_POST['save-user'])) { $datas = $_POST; unset($_POST['save-user']); if (isset($_POST['id']) && $_POST['id']) { if (!user_can('update', 'user', $_POST['id'])) { add_error(translate('Vous ne pouvez pas modifier cet utilisateur')); } } else { if (!user_can('add', 'user', $_POST['id'])) { add_error(translate('Vous ne pouvez pas ajouter d\'utilisateur')); } } if ($this->user->fromPost() !== false) { add_success(translate('L\'utilisateur a bien été ajouté')); redirect('bo/users/all'); } else { add_error($this->form_validation->error_string()); } } else { if ($id) { $datas = $this->user->getId($id, 'array'); } } return $datas; }
function check_follow($matches) { #support of "meta=follow" option for admins. disabled by default to minify processing. if (!$this->options['dont_mask_admin_follow']) { return false; } $id = array(get_comment_ID(), get_the_ID()); //it is either page or post if ($id[0]) { $this->debug_info('It is a comment. id ' . $id[0]); } elseif ($id[1]) { $this->debug_info('It is a page. id ' . $id[1]); } $author = false; if ($id[0]) { $author = get_comment_author($id[0]); } else { if ($id[1]) { $author = get_the_author_meta('ID'); } } if (!$author) { $this->debug_info('it is neither post or page, applying usual rules'); } elseif (user_can($author, 'manage_options') && (stripos($matches[0], 'rel="follow"') !== FALSE || stripos($matches[0], "rel='follow'") !== FALSE)) { $this->debug_info('This link has a follow atribute and is posted by admin, not masking it.'); #wordpress adds rel="nofollow" by itself when posting new link in comments. get rid of it! Also, remove our follow attibute - it is unneccesary. return str_ireplace(array('rel="follow"', "rel='follow'", 'rel="nofollow"'), '', $matches[0]); } else { $this->debug_info('it does not have rel follow or is not posted by admin, masking it'); } return false; }