Example #1
0
function un_do_db_upgrade()
{
    global $un_default_options, $wp_roles, $wpdb;
    $icons = array('idea' => 'icon-lightbulb', 'question' => 'icon-question-sign', 'problem' => 'icon-exclamation-sign', 'praise' => 'icon-heart');
    $plural = array('idea' => __('Ideas', 'usernoise'), 'question' => __('Questions', 'usernoise'), 'problem' => __('Problems', 'usernoise'), 'praise' => __('Praises', 'usernoise'));
    $index = 0;
    $wpdb->un_termmeta = $wpdb->prefix . "un_termmeta";
    if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->un_termmeta}'") != $wpdb->un_termmeta) {
        require_once ABSPATH . 'wp-admin/includes/upgrade.php';
        $sql = "CREATE TABLE `{$wpdb->un_termmeta}` (\n\t\t\t`meta_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,\n\t\t\t`un_term_id` bigint(20) unsigned NOT NULL DEFAULT '0',\n\t\t\t`meta_key` varchar(255) DEFAULT NULL,\n\t\t\t`meta_value` longtext,\n\t\t\tPRIMARY KEY (`meta_id`),\n\t\t\tKEY `un_term_id` (`un_term_id`),\n\t\t\tKEY `meta_key` (`meta_key`)\n\t\t);";
        dbDelta($sql);
    }
    foreach (array('idea' => __('Idea', 'usernoise'), 'question' => __('Question', 'usernoise'), 'problem' => __('Problem', 'usernoise'), 'praise' => __('Praise', 'usernoise')) as $type => $value) {
        if (null == ($term = get_term_by('slug', $type, 'feedback_type', ARRAY_A))) {
            $term = wp_insert_term($value, FEEDBACK_TYPE, array('slug' => $type));
        }
        if (null == un_get_term_meta($term['term_id'], 'icon')) {
            un_add_term_meta($term['term_id'], 'icon', $icons[$type], true);
            un_add_term_meta($term['term_id'], 'plural', $plural[$type], true);
            un_add_term_meta($term['term_id'], 'position', $index, true);
        }
        $index++;
    }
    if (!isset($wp_roles)) {
        $wp_roles = new WP_Roles();
    }
    foreach (un_get_capable_roles() as $role) {
        foreach (un_get_feedback_capabilities() as $cap) {
            $wp_roles->add_cap($role, $cap);
        }
    }
    update_option('un_db_revision', '2');
}
Example #2
0
 /**
  * given a permission string, check for access requirements
  *
  * @param string $str the permission to check
  *
  * @return boolean true if yes, else false
  * @access public
  */
 function check($str)
 {
     // Generic cms 'administer users' role tranlates to 'administrator' WordPress role
     $str = $this->translatePermission($str, 'WordPress', array('administer users' => 'administrator'));
     if ($str == CRM_Core_Permission::ALWAYS_DENY_PERMISSION) {
         return FALSE;
     }
     if ($str == CRM_Core_Permission::ALWAYS_ALLOW_PERMISSION) {
         return TRUE;
     }
     // for administrators give them all permissions
     if (!function_exists('current_user_can')) {
         return TRUE;
     }
     if (current_user_can('super admin') || current_user_can('administrator')) {
         return TRUE;
     }
     // Make string lowercase and convert spaces into underscore
     $str = CRM_Utils_String::munge(strtolower($str));
     if (is_user_logged_in()) {
         // Check whether the logged in user has the capabilitity
         if (current_user_can($str)) {
             return TRUE;
         }
     } else {
         //check the capabilities of Anonymous user)
         $roleObj = new WP_Roles();
         if ($roleObj->get_role('anonymous_user') != NULL && array_key_exists($str, $roleObj->get_role('anonymous_user')->capabilities)) {
             return TRUE;
         }
     }
     return FALSE;
 }
Example #3
0
 /**
  * Delete User Role and all User's in role if requested
  * 
  * @param boolean $delete_users
  * 
  * @return boolean
  * 
  * @access public
  */
 public function delete($delete_users = false)
 {
     $role = new WP_Roles();
     if ($this->getId() !== 'administrator') {
         if ($delete_users) {
             if (current_user_can('delete_users')) {
                 //delete users first
                 $users = new WP_User_Query(array('number' => '', 'blog_id' => get_current_blog_id(), 'role' => $this->getId()));
                 foreach ($users->get_results() as $user) {
                     //user can not delete himself
                     if ($user instanceof WP_User && $user->ID != get_current_user_id()) {
                         wp_delete_user($user->ID);
                     }
                 }
                 $role->remove_role($this->getId());
                 $status = true;
             } else {
                 $status = false;
             }
         } else {
             $role->remove_role($this->getId());
             $status = true;
         }
     } else {
         $status = false;
     }
     return $status;
 }
 /**
  * Adds plugin-specific caps to all roles so that 3rd party plugins can manage them
  */
 function add_caps()
 {
     $version = get_option('post_forking_cap_version');
     // Bail Early if we have already set the caps and aren't updating them
     if ($version !== false && $this->cap_version <= (int) $version) {
         return;
     }
     add_option('post_forking_cap_version', $this->cap_version, '', 'yes');
     global $wp_roles;
     if (!isset($wp_roles)) {
         $wp_roles = new WP_Roles();
     }
     foreach ($wp_roles->role_names as $role => $label) {
         //if the role is a standard role, map the default caps, otherwise, map as a subscriber
         $caps = array_key_exists($role, $this->defaults) ? $this->defaults[$role] : $this->defaults['subscriber'];
         //loop and assign
         foreach ($caps as $cap => $grant) {
             //check to see if the user already has this capability, if so, don't re-add as that would override grant
             if (!isset($wp_roles->roles[$role]['capabilities'][$cap])) {
                 $wp_roles->add_cap($role, $cap, $grant);
             } else {
                 $wp_roles->remove_cap($role, $cap);
                 $wp_roles->add_cap($role, $cap, $grant);
             }
         }
     }
 }
Example #5
0
 public function action_plugins_loaded()
 {
     global $wpdb;
     $db_version = get_option('un_version');
     if ($db_version == UN_VERSION) {
         return;
     }
     if (!$db_version) {
         add_option('un_version', UN_VERSION);
         $wpdb->query("UPDATE {$wpdb->postmeta} \n\t\t\t\tINNER JOIN {$wpdb->posts} ON {$wpdb->posts}.ID = {$wpdb->postmeta}.post_id\n\t\t\t\tSET meta_key = '_email' \n\t\t\t\tWHERE meta_key = 'email' AND post_type = 'feedback'\n\t\t\t\t");
     }
     if (version_compare($db_version, '0.4') == -1) {
         $wpdb->query($wpdb->prepare("UPDATE {$wpdb->posts} SET post_type = %s WHERE post_type = %s", FEEDBACK, 'feedback'));
         global $wp_roles;
         if (!isset($wp_roles)) {
             $wp_roles = new WP_Roles();
         }
         foreach (un_get_capable_roles() as $role) {
             foreach (un_get_feedback_capabilities() as $cap) {
                 $wp_roles->add_cap($role, $cap);
             }
         }
     }
     if (version_compare($db_version, '0.6') == -1) {
         $options = array(UN_USE_FONT, UN_FEEDBACK_BUTTON_TEXT, UN_FEEDBACK_BUTTON_COLOR, UN_FEEDBACK_BUTTON_TEXT_COLOR, UN_FEEDBACK_BUTTON_POSITION, UN_FEEDBACK_FORM_TITLE, UN_FEEDBACK_FORM_TEXT, UN_FEEDBACK_FORM_SHOW_SUMMARY, UN_FEEDBACK_FORM_SHOW_TYPE, UN_FEEDBACK_FORM_SHOW_EMAIL, UN_SUBMIT_FEEDBACK_BUTTON_TEXT, UN_THANKYOU_TITLE, UN_THANKYOU_TEXT, UN_ADMIN_NOTIFY_ON_FEEDBACK, UN_SUBMIT_FEEDBACK_BUTTON_TEXT, UN_SHOW_POWERED_BY, UN_FEEDBACK_BUTTON_SHOW_BORDER, UN_DISABLE_ON_MOBILES, UN_ENABLED, UN_LOAD_IN_FOOTER);
         foreach ($options as $option) {
             $value = get_option('un_' . $option);
             if ($value) {
                 un_set_option($option, $value);
             }
             delete_option('un_' . $option);
         }
     }
     update_option('un_version', UN_VERSION);
 }
function frontier_post_set_cap()
{
    include FRONTIER_POST_DIR . "/include/frontier_post_defaults.php";
    $fps_saved_capabilities = frontier_post_get_capabilities();
    // Reinstate roles
    $fps_roles = new WP_Roles();
    $role_list = $fps_roles->get_names();
    foreach ($role_list as $key => $item) {
        $xrole = get_role($key);
        $tmp_caplist = $fps_saved_capabilities[$key];
        foreach ($tmp_caplist as $tmp_cap => $tmp_value) {
            $fps_cap_name = $tmp_cap;
            // Check that the name is a capability (not editor or category)
            if (array_key_exists($fps_cap_name, $fp_capability_list) == true) {
                if ($tmp_value == "true") {
                    $xrole->add_cap($tmp_cap);
                } else {
                    $xrole->remove_cap($tmp_cap);
                }
                $xrole->remove_cap('frontier_post_' . $tmp_cap);
            } else {
            }
        }
        // end tmp_caplist
    }
    // end role_list
}
function handle_rhc_uninstall()
{
    $WP_Roles = new WP_Roles();
    foreach (array('calendarize_author', 'edit_' . RHC_CAPABILITY_TYPE, 'read_' . RHC_CAPABILITY_TYPE, 'delete_' . RHC_CAPABILITY_TYPE, 'edit_' . RHC_CAPABILITY_TYPE . 's', 'edit_others_' . RHC_CAPABILITY_TYPE . 's', 'edit_published_' . RHC_CAPABILITY_TYPE . 's', 'delete_published_' . RHC_CAPABILITY_TYPE . 's', 'delete_private_' . RHC_CAPABILITY_TYPE . 's', 'delete_others_' . RHC_CAPABILITY_TYPE . 's', 'publish_' . RHC_CAPABILITY_TYPE . 's', 'read_private_' . RHC_CAPABILITY_TYPE . 's', 'manage_' . RHC_VENUE, 'manage_' . RHC_CALENDAR, 'manage_' . RHC_ORGANIZER) as $cap) {
        $WP_Roles->remove_cap(RHC_ADMIN_ROLE, $cap);
    }
    //-----
}
Example #8
0
function wlb_uninstall()
{
    $WP_Roles = new WP_Roles();
    foreach (array('wlb_branding', 'wlb_navigation', 'wlb_login', 'wlb_color_scheme', 'wlb_options', 'wlb_role_manager', 'wlb_license', 'wlb_downloads', 'wlb_dashboard_tool') as $cap) {
        $WP_Roles->remove_cap(WLB_ADMIN_ROLE, $cap);
    }
    //-----
}
 public static function get_all_wp_roles()
 {
     global $wp_roles;
     if (!isset($wp_roles)) {
         $wp_roles = new WP_Roles();
     }
     return $wp_roles->get_names();
 }
Example #10
0
 public function wp_roles()
 {
     global $wp_roles;
     if (!isset($wp_roles)) {
         $wp_roles = new WP_Roles();
     }
     $return = $wp_roles->get_names();
     return $return;
 }
function cab_get_roles()
{
    global $wp_roles;
    if (!isset($wp_roles)) {
        $wp_roles = new WP_Roles();
    }
    $roles = $wp_roles->get_names();
    return $roles;
}
Example #12
0
 /**
  * Init dokan user roles
  *
  * @since Dokan 1.0
  * @global WP_Roles $wp_roles
  */
 function user_roles()
 {
     global $wp_roles;
     if (class_exists('WP_Roles') && !isset($wp_roles)) {
         $wp_roles = new WP_Roles();
     }
     add_role('seller', __('Seller', 'dokan'), array('read' => true, 'publish_posts' => true, 'edit_posts' => true, 'delete_published_posts' => true, 'edit_published_posts' => true, 'delete_posts' => true, 'manage_categories' => true, 'moderate_comments' => true, 'unfiltered_html' => true, 'upload_files' => true, 'dokandar' => true));
     $wp_roles->add_cap('shop_manager', 'dokandar');
     $wp_roles->add_cap('administrator', 'dokandar');
 }
/**
 * 
 * @global WP_Roles $wp_roles
 * @return type
 */
function bd_pseudo_role_field_get_available_roles()
{
    global $wp_roles;
    if (empty($wp_roles)) {
        $wp_roles = new WP_Roles();
    }
    $all_roles = $wp_roles->get_names();
    //all roles as role=>role_name
    return apply_filters('bp_pseudo_role_field_roles', $all_roles);
}
 function get_role_names()
 {
     global $wp_roles;
     if (!isset($wp_roles)) {
         $wp_roles = new WP_Roles();
     }
     $roles = $wp_roles->get_names();
     $roles['guest'] = 'Guest';
     return $roles;
 }
 public static function woocommerce_add_filter_hide_product($settings)
 {
     $args = array('post_type' => 'product', 'posts_per_page' => '-1');
     $checkproducts = get_posts($args);
     if (is_array($checkproducts)) {
         foreach ($checkproducts as $product) {
             $product_id[] = $product->ID;
             $product_title[] = get_the_title($product->ID);
         }
     }
     if (is_array($checkproducts)) {
         $newcombinedvalues = array_combine((array) $product_id, (array) $product_title);
     }
     $get_terms_product = get_terms('product_cat', array('hide_empty' => 'false'));
     //var_dump($get_terms_product);
     $current_category_products = array();
     if (!empty($get_terms_product) && is_array($get_terms_product)) {
         foreach ($get_terms_product as $each_term) {
             $current_category_products[$each_term->term_id] = $each_term->name;
         }
     }
     //var_dump($current_category_products);
     $updated_settings = array();
     $mainvariable = array();
     foreach ($settings as $section) {
         if (isset($section['id']) && '_woo_hide_products_maincontent' == $section['id'] && isset($section['type']) && 'sectionend' == $section['type']) {
             global $wp_roles;
             if (!isset($wp_roles)) {
                 $wp_roles = new WP_Roles();
             }
             $getdata = $wp_roles->get_names();
             foreach ($getdata as $data => $key) {
                 $updated_settings[] = array('name' => __('Toggle Shop Products for ' . $key, 'woohideproducts'), 'type' => 'title', 'id' => '_woo_hide_products_' . $data);
                 $updated_settings[] = array('name' => __('Toggle Type', 'woohideproducts'), 'desc' => __('Toggle Products by category or certain products', 'woohideproducts'), 'tip' => '', 'id' => 'woo_toggle_products_by_type_' . $data, 'css' => '', 'std' => '1', 'defaultvalue' => 'woo_toggle_products_by_type_' . $data, 'type' => 'select', 'options' => array('1' => __('By Products', 'woohideproducts'), '2' => __('By Categories', 'woohideproducts')), 'desc_tip' => true);
                 $updated_settings[] = array('name' => __('Hide Products in Category', 'woohideproducts'), 'desc' => __('Hide Products in Category Page of WooCommerce', 'woohideproducts'), 'tip' => '', 'id' => 'woo_hide_products_in_category_' . $data, 'css' => '', 'std' => 'yes', 'defaultvalue' => 'woo_hide_products_in_category_' . $data, 'type' => 'checkbox', 'desc_tip' => '');
                 $updated_settings[] = array('name' => __('Hide Products in Search Result', 'woohideproducts'), 'desc' => __('Hide Products in Search Result of WooCommerce', 'woohideproducts'), 'tip' => '', 'id' => 'woo_hide_products_in_search_' . $data, 'css' => '', 'std' => 'yes', 'defaultvalue' => 'woo_hide_products_in_search_' . $data, 'type' => 'checkbox', 'desc_tip' => '');
                 $updated_settings[] = array('name' => __('Toggle Include/Exclude Archive Products', 'woohideproducts'), 'desc' => __('Toggle Include Products/Exclude Products in WooCommerce Shop Page', 'woohideproducts'), 'tip' => '', 'id' => 'woo_include_exclude_products_' . $data, 'css' => '', 'std' => '2', 'defaultvalue' => 'woo_include_exclude_products_' . $data, 'type' => 'radio', 'options' => array('1' => __('Include', 'woohideproducts'), '2' => __('Exclude', 'woohideproducts')), 'desc_tip' => true);
                 $updated_settings[] = array('name' => __('Choose Category', 'woohideproducts'), 'desc' => __('Want to hide products in a bulk way then using this option to hide the products', 'woohideproducts'), 'tip' => '', 'id' => 'woo_toggle_type_category_' . $data, 'css' => '', 'std' => '', 'defaultvalue' => 'woo_toggle_type_category_' . $data, 'type' => 'multiselect', 'options' => $current_category_products);
                 $updated_settings[] = array('name' => __('Select Product to Toggle Shop', 'woohideproducts'), 'desc' => __('Select Product which will be Toggle Shop in Shop Page', 'woohideproducts'), 'tip' => '', 'id' => 'woo_select_products_' . $data, 'css' => '', 'std' => '', 'type' => 'multiselect', 'options' => $newcombinedvalues);
                 $updated_settings[] = array('type' => 'sectionend', 'id' => '_woo_hide_products_' . $data);
             }
             $updated_settings[] = array('name' => __('Toggle Shop Products for Guest', 'woohideproducts'), 'type' => 'title', 'id' => '_woo_hide_products_guest');
             $updated_settings[] = array('name' => __('Toggle Type', 'woohideproducts'), 'desc' => __('Toggle Products by category or certain products', 'woohideproducts'), 'tip' => '', 'id' => 'woo_toggle_products_by_type_guest', 'css' => '', 'std' => '1', 'defaultvalue' => 'woo_toggle_products_by_type_guest', 'type' => 'select', 'options' => array('1' => __('By Products', 'woohideproducts'), '2' => __('By Categories', 'woohideproducts')), 'desc_tip' => true);
             $updated_settings[] = array('name' => __('Hide Products in Category', 'woohideproducts'), 'desc' => __('Hide Products in Category Page of WooCommerce', 'woohideproducts'), 'tip' => '', 'id' => 'woo_hide_products_in_category_guest', 'css' => '', 'std' => 'yes', 'defaultvalue' => 'woo_hide_products_in_category_guest', 'type' => 'checkbox', 'desc_tip' => '');
             $updated_settings[] = array('name' => __('Hide Products in Search Result', 'woohideproducts'), 'desc' => __('Hide Products in Search Result of WooCommerce', 'woohideproducts'), 'tip' => '', 'id' => 'woo_hide_products_in_search_guest', 'css' => '', 'std' => 'yes', 'defaultvalue' => 'woo_hide_products_in_search_guest', 'type' => 'checkbox', 'desc_tip' => '');
             $updated_settings[] = array('name' => __('Toggle Include/Exclude Archive Products', 'woohideproducts'), 'desc' => __('Toggle Include Products/Exclude Products in WooCommerce Shop Page', 'woohideproducts'), 'tip' => '', 'id' => 'woo_include_exclude_products_guest', 'css' => '', 'std' => '2', 'defaultvalue' => 'woo_include_exclude_products_guest', 'type' => 'radio', 'options' => array('1' => __('Include', 'woohideproducts'), '2' => __('Exclude', 'woohideproducts')), 'desc_tip' => true);
             $updated_settings[] = array('name' => __('Choose Category', 'woohideproducts'), 'desc' => __('Want to hide products in a bulk way then using this option to hide the products', 'woohideproducts'), 'tip' => '', 'id' => 'woo_toggle_type_category_guest', 'css' => '', 'std' => '', 'defaultvalue' => 'woo_toggle_type_category_guest', 'type' => 'multiselect', 'options' => $current_category_products);
             $updated_settings[] = array('name' => __('Select Product to Toggle Shop', 'woohideproducts'), 'desc' => __('Select Product which will be Toggle Shop in Shop Page', 'woohideproducts'), 'tip' => '', 'id' => 'woo_select_products_guest', 'css' => '', 'std' => '', 'type' => 'multiselect', 'options' => $newcombinedvalues);
             $updated_settings[] = array('type' => 'sectionend', 'id' => '_woo_hide_products_guest');
         }
         $updated_settings[] = $section;
     }
     return $updated_settings;
 }
 public function remove_roles()
 {
     global $wp_roles;
     if (class_exists('WP_Roles')) {
         if (!isset($wp_roles)) {
             $wp_roles = new WP_Roles();
         }
     }
     $wp_roles->remove_role('ap_participant');
     $wp_roles->remove_role('ap_editor');
     $wp_roles->remove_role('ap_moderator');
 }
Example #17
0
 /**
  * Returns all the settings fields
  *
  * @return array settings fields
  */
 static function get_settings_fields()
 {
     global $wp_roles;
     $settings_fields = array();
     if (!$wp_roles) {
         $wp_roles = new WP_Roles();
     }
     $role_names = $wp_roles->get_names();
     $settings_fields['cpm_general'] = apply_filters('cpm_settings_field_general', array(array('name' => 'upload_limit', 'label' => __('File Upload Limit', 'cpm'), 'default' => '2', 'desc' => __('file size in Megabyte. e.g: 2')), array('name' => 'pagination', 'label' => __('Number of project per page', 'cpm'), 'type' => 'text', 'default' => '10', 'desc' => __('-1 for unlimited', 'cpm')), array('name' => 'project_manage_role', 'label' => __('Project Manage Capability', 'cpm'), 'default' => array('editor' => 'editor', 'author' => 'author', 'administrator' => 'administrator'), 'desc' => __('Select the user role who can see and manage all projects', 'cpm'), 'type' => 'multicheck', 'options' => $role_names), array('name' => 'project_create_role', 'label' => __('Project Create Capability', 'cpm'), 'default' => array('editor' => 'editor', 'author' => 'author', 'administrator' => 'administrator'), 'desc' => __('Select the user role who can create projects', 'cpm'), 'type' => 'multicheck', 'options' => $role_names)));
     $settings_fields['cpm_mails'] = apply_filters('cpm_settings_field_mail', array(array('name' => 'email_from', 'label' => __('From Email', 'cpm'), 'type' => 'text', 'desc' => '', 'default' => get_option('admin_email')), array('name' => 'email_type', 'label' => __('E-Mail Type', 'cpm'), 'type' => 'select', 'default' => 'text/plain', 'options' => array('text/html' => __('HTML Mail', 'cpm'), 'text/plain' => __('Plain Text', 'cpm'))), array('name' => 'email_bcc_enable', 'label' => __('Send email via Bcc', 'cpm'), 'type' => 'checkbox', 'default' => 'off', 'desc' => __('Enable Bcc'))));
     return apply_filters('cpm_settings_fields', $settings_fields);
 }
Example #18
0
 /**
  *
  * @return type
  */
 public function add()
 {
     $name = trim(aam_Core_Request::post('name'));
     $roles = new WP_Roles();
     $role_id = 'aamrole_' . uniqid();
     if ($roles->add_role($role_id, $name)) {
         $response = array('status' => 'success', 'role' => $role_id);
     } else {
         $response = array('status' => 'failure');
     }
     return json_encode($response);
 }
 protected function add_gf_import_capability()
 {
     global $wp_roles;
     if (!isset($wp_roles)) {
         $wp_roles = new WP_Roles();
     }
     $admin_role = $wp_roles->get_role('administrator');
     if (!empty($admin_role) && !$admin_role->has_cap('gravityforms_import')) {
         $wp_roles->use_db = true;
         //  save changes to the database
         $admin_role->add_cap('gravityforms_import');
     }
 }
Example #20
0
 public function install_capabilities()
 {
     $roles = $GLOBALS['wp_roles']->roles;
     global $wp_roles;
     if (!isset($roles)) {
         $wp_roles = new WP_Roles();
         $roles = $wp_roles->get_names();
     }
     if (is_array($roles)) {
         foreach ($roles as $key => $value) {
             $this->add_role_capabilities($key);
         }
     }
 }
Example #21
0
/**
 * Add XRDS entries for OpenID Server.  Entries added will be highly 
 * dependant on the requested URL and plugin configuration.
 */
function openid_provider_xrds_simple($xrds)
{
    global $wp_roles;
    if (!$wp_roles) {
        $wp_roles = new WP_Roles();
    }
    $provider_enabled = false;
    foreach ($wp_roles->role_names as $key => $name) {
        $role = $wp_roles->get_role($key);
        if ($role->has_cap('use_openid_provider')) {
            $provider_enabled = true;
            break;
        }
    }
    if (!$provider_enabled) {
        return $xrds;
    }
    $user = openid_server_requested_user();
    if (!$user && get_option('openid_blog_owner')) {
        $url_parts = parse_url(get_option('home'));
        $script = preg_replace('/index.php$/', '', $_SERVER['SCRIPT_NAME']);
        if ('/' . $url_parts['path'] != $script && !is_admin()) {
            return $xrds;
        }
        if (!defined('OPENID_DISALLOW_OWNER') || !OPENID_DISALLOW_OWNER) {
            $user = get_userdatabylogin(get_option('openid_blog_owner'));
        }
    }
    if ($user) {
        // if user doesn't have capability, bail
        $user_object = new WP_User($user->ID);
        if (!$user_object->has_cap('use_openid_provider')) {
            return $xrds;
        }
        if (get_usermeta($user->ID, 'openid_delegate')) {
            $services = get_usermeta($user->ID, 'openid_delegate_services');
        } else {
            $services = array(0 => array('Type' => array(array('content' => 'http://specs.openid.net/auth/2.0/signon')), 'URI' => trailingslashit(get_option('siteurl')) . '?openid_server=1', 'LocalID' => get_author_posts_url($user->ID)), 1 => array('Type' => array(array('content' => 'http://openid.net/signon/1.1')), 'URI' => trailingslashit(get_option('siteurl')) . '?openid_server=1', 'openid:Delegate' => get_author_posts_url($user->ID)));
        }
    } else {
        $services = array(array('Type' => array(array('content' => 'http://specs.openid.net/auth/2.0/server')), 'URI' => trailingslashit(get_option('siteurl')) . '?openid_server=1', 'LocalID' => 'http://specs.openid.net/auth/2.0/identifier_select'));
    }
    if (!empty($services)) {
        foreach ($services as $index => $service) {
            $name = 'OpenID Provider Service (' . $index . ')';
            $xrds = xrds_add_service($xrds, 'main', $name, $service, $index);
        }
    }
    return $xrds;
}
function handle_rhc_uninstall()
{
    $WP_Roles = new WP_Roles();
    foreach (array('calendarize_author', 'edit_' . RHC_CAPABILITY_TYPE, 'read_' . RHC_CAPABILITY_TYPE, 'delete_' . RHC_CAPABILITY_TYPE, 'delete_' . RHC_CAPABILITY_TYPE . 's', 'edit_' . RHC_CAPABILITY_TYPE . 's', 'edit_others_' . RHC_CAPABILITY_TYPE . 's', 'edit_published_' . RHC_CAPABILITY_TYPE . 's', 'delete_published_' . RHC_CAPABILITY_TYPE . 's', 'delete_private_' . RHC_CAPABILITY_TYPE . 's', 'delete_others_' . RHC_CAPABILITY_TYPE . 's', 'publish_' . RHC_CAPABILITY_TYPE . 's', 'read_private_' . RHC_CAPABILITY_TYPE . 's', 'manage_' . RHC_VENUE, 'manage_' . RHC_CALENDAR, 'manage_' . RHC_ORGANIZER) as $cap) {
        $WP_Roles->remove_cap(RHC_ADMIN_ROLE, $cap);
    }
    //-----
    delete_site_transient('update_plugins');
    delete_option('rhc_dismiss_help_notice');
    $filename = get_home_path() . '.htaccess';
    if (file_exists($filename)) {
        insert_with_markers($filename, 'RHC', array());
    }
}
Example #23
0
 /**
  * Returns default options
  *
  * @since 6.3
  * @access public
  *
  * @return array Default options
  */
 public static function default_options()
 {
     global $wp_roles;
     if (empty($wp_roles)) {
         $wp_roles = new WP_Roles();
     }
     $options = array();
     foreach ($wp_roles->get_names() as $role => $role_name) {
         if ('pending' != $role) {
             $options[$role] = array(array('title' => __('Dashboard', 'theme-my-login'), 'url' => admin_url()), array('title' => __('Profile', 'theme-my-login'), 'url' => admin_url('profile.php')));
         }
     }
     return $options;
 }
Example #24
0
 /**
  * Delete User Role 
  *
  * @return boolean
  *
  * @access public
  */
 public function delete()
 {
     $status = false;
     $role = new WP_Roles();
     if ($this->getId() !== 'administrator') {
         $count = count_users();
         $stats = $count['avail_roles'];
         if (empty($stats[$this->getId()])) {
             $role->remove_role($this->getId());
             $status = true;
         }
     }
     return $status;
 }
Example #25
0
 /**
  *
  * @return type
  */
 public function addCapability()
 {
     $roles = new WP_Roles();
     $capability = trim(aam_Core_Request::post('capability'));
     if ($capability) {
         $normalized = str_replace(' ', '_', strtolower($capability));
         //add the capability to administrator's role as default behavior
         $roles->add_cap('administrator', $normalized);
         $response = array('status' => 'success', 'capability' => $normalized);
     } else {
         $response = array('status' => 'failure');
     }
     return json_encode($response);
 }
Example #26
0
 /**
  * Returns default options
  *
  * @since 6.3
  * @access public
  *
  * @return array Default options
  */
 public static function default_options()
 {
     global $wp_roles;
     if (empty($wp_roles)) {
         $wp_roles = new WP_Roles();
     }
     $options = array();
     foreach ($wp_roles->get_names() as $role => $label) {
         if ('pending' != $role) {
             $options[$role] = array('theme_profile' => true, 'restrict_admin' => false);
         }
     }
     return $options;
 }
 /**
  * Returns default options
  *
  * @since 6.3
  * @access public
  *
  * @return array Default options
  */
 public static function default_options()
 {
     global $wp_roles;
     if (empty($wp_roles)) {
         $wp_roles = new WP_Roles();
     }
     $options = array();
     foreach ($wp_roles->get_names() as $role => $label) {
         if ('pending' != $role) {
             $options[$role] = array('login_type' => 'default', 'login_url' => '', 'logout_type' => 'default', 'logout_url' => '');
         }
     }
     return $options;
 }
 function set_permissions()
 {
     $wp_roles = new WP_Roles();
     $all_roles = $wp_roles->get_names();
     foreach ($all_roles as $role => $name) {
         $role_object = get_role($role);
         foreach ($this->permissions as $cap => $grant) {
             if ($cap == 'publish_wiki_pages' && $role == 'wiki_editor') {
                 continue;
             } else {
                 $role_object->add_cap($cap);
             }
         }
     }
 }
Example #29
0
 /**
  * Add New Role
  * 
  * @return string
  * 
  * @access public
  */
 public function add()
 {
     $name = trim(aam_Core_Request::post('name'));
     $roles = new WP_Roles();
     if (aam_Core_ConfigPress::getParam('aam.native_role_id') === 'true') {
         $role_id = strtolower($name);
     } else {
         /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
         /////////////////////////////////// SIGOES //////////////////////////////////////////////////////////////////////////
         //$role_id = 'aamrole_' . uniqid(); // QUITA EL CODIGO DEL ROL EN WP_CAPABILITIES
         $role_id = $name;
         /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     }
     //if inherited role is set get capabilities from it
     $parent = trim(aam_Core_Request::post('inherit'));
     if ($parent && $roles->get_role($parent)) {
         $caps = $roles->get_role($parent)->capabilities;
     } else {
         $caps = array();
     }
     if ($roles->add_role($role_id, $name, $caps)) {
         $response = array('status' => 'success', 'role' => $role_id);
     } else {
         $response = array('status' => 'failure');
     }
     return json_encode($response);
 }
Example #30
0
 public function add_dentix_caps_to_admin()
 {
     global $wp_roles;
     if (!isset($wp_roles)) {
         $wp_roles = new WP_Roles();
     }
     //create a new role, based on the subscriber role
     $subscriber = $wp_roles->get_role('subscriber');
     $wp_roles->add_role('dentist', __('Dentist', 'dentix'), $subscriber->capabilities);
     $caps = array('read', 'read_patient', 'read_private_patients', 'edit_patients', 'edit_private_patients', 'edit_published_patients', 'edit_others_patients', 'publish_patients', 'delete_patients', 'delete_private_patients', 'delete_published_patients', 'delete_others_patients', 'upload_files');
     $roles = array(get_role('administrator'), get_role('dentist'));
     foreach ($roles as $role) {
         foreach ($caps as $cap) {
             $role->add_cap($cap);
         }
     }
 }