function amr_meta_nice_names_page() { /* may be able to work generically */ global $amr_nicenames; global $ausersadminurl; //amr_meta_main_admin_header('Find fields, make nice names' ); amr_meta_admin_headings($plugin_page = ''); // does the nonce check etc if (isset($_POST['action']) and !($_POST['action'] === "save")) { return; } echo PHP_EOL . '<div class="clear" style="clear:both;"> </div>' . PHP_EOL; if (isset($_POST['update']) and $_POST['update'] === "Update") { /* Validate the input and save */ if (amrmeta_validate_nicenames()) { // updates inside the function now } else { echo '<h2>' . __('Validation failed', 'amr-users') . '</h2>'; } } if (isset($_POST['resetnice'])) { delete_option('amr-users-nicenames'); // delete then rebuild } if (isset($_POST['rebuild']) or isset($_POST['resetnice'])) { /* Rebuild the nicenames - could take a while */ $amr_nicenames = ameta_rebuildnicenames(); echo '<h3>' . __('Rebuild Complete.', 'amr-users') . '</h3>'; return; } else { amrmeta_check_find_fields(); } echo alist_rebuild_names_update(); ameta_list_nicenames_for_input($amr_nicenames); }
function ameta_list_nicenames_for_input($nicenames) { /* get the standard names and then the meta names */ if (!($excluded = ausers_get_option('amr-users-nicenames-excluded'))) { $excluded = array(); } if (!($showinwplist = ausers_get_option('amr-users-show-in-wplist'))) { $showinwplist = array(); } //we need to allow manual exclusion of metakeys becuase of s2members strange time keys on access_cap_limits and who knows there might be others. if (!($excluded_meta_keys = ausers_get_option('amr-users-excluded-meta-keys'))) { $excluded_meta_keys = amr_default_excluded_metakeys(); } foreach ($excluded_meta_keys as $k => $on) { // just get the excluded ones if (!$on) { unset($excluded_meta_keys[$k]); } } $orig_mk = ausers_get_option('amr-users-original-keys'); $wpfields = amr_get_usermasterfields(); foreach ($nicenames as $i => $k) { // just in case, check exclude if (isset($excluded_meta_keys[$i])) { if (!empty($excluded_meta_keys[$i])) { unset($nicenames[$i]); } } } ksort($nicenames); $total = count($nicenames); $totalex = count($excluded_meta_keys); echo PHP_EOL . '<div class="clear"> </div>' . PHP_EOL; echo '<div><!-- nice names list-->'; echo '<h2>' . __('Fields & Nice Names', 'amr-users') . ' (' . $total . ') ' . '</h2>' . '<h3><a href="' . admin_url('admin.php?page=ameta-admin-meta-keys.php') . '">' . sprintf(__('Note: %s meta keys excluded.', 'amr-users'), $totalex) . '</a> ' . __('Some pseudo fields added', 'amr-users') . '</h3>' . '<h3>' . __('Nicer names for list headings', 'amr-users') . '</h3>' . '<ul>' . '<li>' . __('Extracts all user meta records (almost, some specifically excluded.)', 'amr-users') . ' <strong>' . __('Sample data MUST exist!', 'amr-users') . '</strong>' . '</li>' . '<li>' . __('Digs deep into composite records, to extract out "fields" that should have been simple meta.', 'amr-users') . '</li>' . '<li>' . __('Composite user meta are usually created by plugins who do not do things the way wordpress intended.', 'amr-users') . '</li>' . '<li>' . __('If the necessary add ons have been activated, will dig deeper or look further into other tables.', 'amr-users') . '</li> ' . '</ul>'; echo alist_rebuild_names_update(); echo '<table class="widefat">'; echo '<tr><th> </th><th>' . __('Nice Name', 'amr-users') . '</th>' . '<th>' . '<a title="' . __('Yes the main wordpress user list', 'amr-users') . '" href="' . network_admin_url('users.php') . '">' . __('Show in wp user list?', 'amr-users') . '</a>' . '<br /><em>' . __('wp fields only', 'amr-users') . '</em>' . '</th>' . '<th>' . __('Exclude from Reports?', 'amr-users') . '</th>' . '</tr>'; // indicate additonal fields available echo '<tr><td>' . __('Roles and First bbpress Forum role', 'amr-users') . '</td>' . '<td>' . '<a title="' . __('Read more about multiple roles per users.', 'amr-users') . '" href="http://wpusersplugin.com/4799/roles-first-role-bbpress-forum-roles-s2member-levels/">' . __('Multiple roles per user?', 'amr-users') . '</a>' . '</td>' . '<td>' . '<a title="' . __('Get plus addons to add more features and functionality', 'amr-users') . '" href="http://wpusersplugin.com/related-plugins/">' . __('Read about add-ons?', 'amr-users') . '</a>' . '</td>' . '<td>' . '</td>' . '</tr>'; foreach ($nicenames as $i => $v) { echo "\n\t" . '<tr>' . '<td><label for="nn' . $i . '" >' . $i . '</label></td><td>' . '<input type="text" size="40" id="nn' . $i . '" name="nn[' . $i . ']" value= "' . $v . '" />'; echo '</td><td>'; echo '<input type="checkbox" id="wp' . $i . '" name="wp[' . $i . ']"'; if (!empty($showinwplist[$i])) { echo ' value=true checked="checked" '; } echo ' />'; if ((empty($orig_mk[$i]) or !($orig_mk[$i] == $i)) and !in_array($i, $wpfields)) { echo ' <a href="#" title="' . __('This field may/may not show in the wp list. It is not a simple user meta field', 'amr-users') . '">!</a> '; } echo '</td><td>'; if ($i === 'ID') { echo ' '; } else { echo '<input type="checkbox" id="nex' . $i . '" name="nex[' . $i . ']"'; if (!empty($excluded[$i])) { echo ' value=true checked="checked" '; } echo ' />'; } echo '</td>'; echo '</tr>'; } echo "\n\t" . '</table>' . PHP_EOL . '</div><!-- nice names list-->' . PHP_EOL; return; }