function ameta_rebuildnicenames() { global $wpdb, $amr_nicenames; /* */ // amr_users_message (__('Rebuilding List of possible fields. This could take a while - I have to query evey meta record, of which there can be multiple for each main record. Please be patient...', 'amr-users')); /* check if we have some options already in Database. - use their names, if not, use default, else overwrite .*/ flush(); /* try does not always work */ $oldnn = ausers_get_option('amr-users-nicenames'); $nn = ameta_defaultnicenames(); /* get the default list names required */ /* Add any new fields in */ unset($list); $list = amr_get_alluserkeys(); /* maybe only do this if a refresh is required ? No only happens on admin anyway ? */ echo '<h3>' . __('Try to make some nicer names.', 'amr-users') . '</h3>'; /**** wp has changed - need to alllow for prefix now on fields. Actually due to wpmu - keep the prefix, let the user remove it! */ foreach ($list as $i => $v) { if (empty($nn[$v])) { /* set a reasonable default nice name */ if (!empty($oldnn[$v])) { $nn[$v] = $oldnn[$v]; //echo '<br />'. sprintf(__('Use existing name %s for %s', 'amr-users'),$nn[$v],$v); } else { // take the last part of the field only - no not nice too unpredictable //$lastdash = strripos($v,'-'); //$nn[$v] = substr($v, $lastdash); $nn[$v] = str_replace('s2member_custom_fields', 's2m', $v); // if it is a s2member field - reduce length of name $nn[$v] = str_replace('s2member', 's2m', $nn[$v]); $nn[$v] = str_replace('capabilities', 'Cap', $nn[$v]); $nn[$v] = str_replace('-', ' ', $nn[$v]); // if (isset ($wpdb->prefix)) {$nn[$v] = str_replace ($wpdb->prefix, '', $nn[$v]);} /* Note prefix has underscore*/ $nn[$v] = ucwords(str_replace('_', ' ', $nn[$v])); if (function_exists('amr_check_ym_custom_nicenames')) { // look and fix ym custom fields $nn[$v] = amr_check_ym_custom_nicenames($v); } echo '<br />' . sprintf(__('Created name %s for %s', 'amr-users'), $nn[$v], $v); } } } unset($list); amr_check_for_table_prefixes($nn); ausers_update_option('amr-users-nicenames', $nn); $amr_nicenames = $nn; return $nn; }
function ausers_get_option($option) { // allows user reports to be run either at site level and/or at blog level global $ausersadminurl, $amr_nicenames; if (amr_is_network_admin()) { $result = get_site_option($option); } else { $result = get_option($option); } if (empty($result)) { // it's new, get defaults //if ($option == 'amr-users-no-lists' ) return ameta_default_main(); // old - leave for upgrade check if ($option == 'amr-users-main') { // and it's empty //------------------------- //if (WP_DEBUG) echo '<br />Renaming stored option "amr-users-no-lists" to "amr-users-main" '; $amain = get_site_option('amr-users-no-lists'); // might return default ok, if not will have done upgrade check if (empty($amain)) { $amain = ausers_get_option('amr-users-no-lists'); if (empty($amain)) { $amain = ameta_default_main(); } } $amain['version'] = AUSERS_VERSION; ausers_update_option('amr-users-main', $amain); ausers_delete_option('amr-users-no-lists'); return $amain; //------------------------- } if ($option == 'amr-users') { return ameta_default_list_options(); } if ($option == 'amr-users-nicenames-excluded') { return array('attachment_count' => true, 'activation_key' => true, 'dismissed_wp_pointers' => true, 'default_password_nag' => true, 'nav_menu_item_count' => true, 'revision_count' => true, 'comment_count' => true, 'show_admin_bar_front' => true, 'show_welcome_panel' => true, 'user_activation_key' => true, 'user_status' => true, 'yim' => true, 'aim' => true, 'jabber' => true, 'reply_count' => true, 'topic_count' => true, 'forum_count' => true, 'use_ssl' => true); } if ($option == 'amr-users-original-keys') { return array(); } if ($option == 'amr-users-custom-headings') { return array(); } if ($option == 'amr-users-prefixes-in-use') { return array(); } if ($option == 'amr-users-nicenames') { $amr_nicenames = ameta_defaultnicenames(); } } return $result; }