function tern_wp_members_shortcode($a)
{
    $m = new tern_members();
    return $m->members($a, false);
}
Esempio n. 2
0
function WP_members_list_markup()
{
    global $wpdb, $getWP, $ternSel, $tern_wp_members_defaults, $tern_wp_msg, $tern_wp_members_fields, $tern_wp_meta_fields, $current_user, $notice;
    $o = $getWP->getOption('tern_wp_members', $tern_wp_members_defaults);
    get_currentuserinfo();
    ?>
	<div class="wrap">
		<div id="icon-options-general" class="icon32"><br /></div>
		<h2>Configure Your Members List Mark-Up</h2>
		<?php 
    if (!empty($notice)) {
        ?>
<div id="notice" class="error"><p><?php 
        echo $notice;
        ?>
</p></div><?php 
    }
    ?>
		<p>
			Below you can configure what fields are shown when viewing your members list. Add fields to be displayed and edit their names, 
			mark-up and order. When editing their mark-up, use the string %value% to place the respective value for each field and use the string 
			%author_url% to add the url (e.g. http://blog.ternstyle.us/?author=1) for each respective author's page.
		</p>
		<div id="tern_wp_message">
		<?php 
    if (!empty($tern_wp_msg)) {
        echo '<div id="message" class="updated fade"><p>' . $tern_wp_msg . '</p></div>';
    }
    ?>
		</div>
		<form class="field-form" action="" method="get">
			<p class="field-box">
				<label class="hidden" for="new-field-input">Add New Field:</label>
				<?php 
    foreach ($tern_wp_members_fields as $k => $v) {
        foreach ($o['fields'] as $w) {
            if ($v == $w['name']) {
                continue 2;
            }
        }
        $a['Standard Fields'][] = array($k, $v);
    }
    foreach ($tern_wp_meta_fields as $k => $v) {
        foreach ($o['fields'] as $w) {
            if ($v == $w['name']) {
                continue 2;
            }
        }
        $a['Standard Meta Fields'][] = array($k, $v);
    }
    $r = $wpdb->get_col("select distinct meta_key from {$wpdb->usermeta}");
    foreach ($r as $v) {
        if (in_array($v, $tern_wp_members_fields) or in_array($v, $tern_wp_meta_fields)) {
            continue;
        }
        foreach ($o['fields'] as $w) {
            if ($v == $w['name']) {
                continue 2;
            }
        }
        $a['Available Meta Fields'][] = array($v, $v);
    }
    echo $ternSel->create(array('type' => 'tiered', 'data' => $a, 'key' => 0, 'value' => 1, 'id' => 'new_field', 'name' => 'new_field', 'select_value' => 'Add New Field'));
    ?>
				<input type="hidden" id="page" name="page" value="<?php 
    echo $_REQUEST['page'];
    ?>
" />
				<input type="submit" value="Add New Field" class="button" />
				<input type="hidden" name="action" value="add" />
				<input type="hidden" id="_wpnonce" name="_wpnonce" value="<?php 
    echo wp_create_nonce('tern_wp_members_nonce');
    ?>
" />
				<input type="hidden" name="_wp_http_referer" value="<?php 
    wp_get_referer();
    ?>
" />
			</p>
		</form>
		<form id="tern_wp_members_list_fm" method="post" action="">
			<table id="members_list_fields" class="widefat fixed" cellspacing="0">
				<thead>
				<tr class="thead">
					<th scope="col" id="cb" class="manage-column column-cb check-column" style=""><input type="checkbox" /></th>
					<th scope="col" id="field" class="manage-column column-field" style="width:20%;">Database Field</th>
					<th scope="col" id="name" class="manage-column column-name" style="width:20%;">Field Name</th>
					<th scope="col" id="markup" class="manage-column column-markup" style="">Mark-Up</th>
				</tr>
				</thead>
				<tfoot>
				<tr class="thead">
					<th scope="col" class="manage-column column-cb check-column" style=""><input type="checkbox" /></th>
					<th scope="col" id="field" class="manage-column column-field" style="">Database Field</th>
					<th scope="col" class="manage-column column-name" style="">Field Name</th>
					<th scope="col" class="manage-column column-markup" style="">Mark-Up</th>
				</tr>
				</tfoot>
				<tbody id="fields" class="list:fields field-list">
					<?php 
    foreach ($o['fields'] as $k => $v) {
        $d = empty($d) ? ' class="alternate"' : '';
        ?>
							<tr id='field-<?php 
        echo $v['name'];
        ?>
'<?php 
        echo $d;
        ?>
>
								<th scope='row' class='check-column'><input type='checkbox' name='fields[]' id='field_<?php 
        echo $v['name'];
        ?>
' value='<?php 
        echo $v['name'];
        ?>
' /></th>
								<td class="field column-field">
									<input type="hidden" name="field_names%5B%5D" value="<?php 
        echo $v['name'];
        ?>
" />
									<strong><?php 
        echo $v['name'];
        ?>
</strong><br />
									<div class="row-actions">
										<span class='edit tern_memebrs_edit'><a>Edit</a> | </span>
										<span class='edit'><a href="admin.php?page=members-list-configure-mark-up&fields%5B%5D=<?php 
        echo $v['name'];
        ?>
&action=remove&_wpnonce=<?php 
        echo wp_create_nonce('tern_wp_members_nonce');
        ?>
">Remove</a></span>
									</div>
								</td>
								<td class="name column-name">
									<input type="text" name="field_titles%5B%5D" class="tern_members_fields hidden" value="<?php 
        echo $k;
        ?>
" /><br class="tern_members_fields hidden" />
									<input type="button" value="Update Field" class="tern_members_fields hidden button" />
									<span class="tern_members_fields field_titles"><?php 
        echo $k;
        ?>
</span>
								</td>
								<td class="markup column-markup">
									<textarea name="field_markups%5B%5D" class="tern_members_fields hidden" rows="4" cols="10"><?php 
        echo $v['markup'];
        ?>
</textarea><br class="tern_members_fields hidden" />
									<input type="button" value="Update Field" class="tern_members_fields hidden button" />
									<span class="tern_members_fields field_markups"><?php 
        echo htmlentities($v['markup']);
        ?>
</span>
								</td>
							</tr>
					<?php 
    }
    ?>
				</tbody>
			</table>
			<input type="hidden" name="action" value="markup" />
			<input type="hidden" id="page" name="page" value="members-list-configure-mark-up" />
			<input type="hidden" id="_wpnonce" name="_wpnonce" value="<?php 
    echo wp_create_nonce('tern_wp_members_nonce');
    ?>
" />
			<input type="hidden" name="_wp_http_referer" value="<?php 
    wp_get_referer();
    ?>
" />
		</form>
		<h3>Your Mark-Up will look like this:</h3>
		<?php 
    $m = new tern_members();
    echo '<pre id="tern_members_sample_markup">' . htmlentities($m->markup($current_user)) . '</pre>';
    ?>
	</div>
<?php 
}