PriMoThemes — now s2Member® (official notice)
This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™
<?php
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// File:
// meta.php
// Description:
// This file compiles and processes the plugin's user meta options.
// Actions:
// 1) compile options
// 2) process and save options
// Date:
// Added on April 30th 2011
// Copyright:
// Copyright (c) 2011 Matthew Praetzel.
// License:
// This software is licensed under the terms of the GNU Lesser General Public License v3
// as published by the Free Software Foundation. You should have received a copy of of
// the GNU Lesser General Public License along with this software. In the event that you
// have not, please visit: http://www.gnu.org/licenses/gpl-3.0.txt
//
////////////////////////////////////////////////////////////////////////////////////////////////////
/****************************************Commence Script*******************************************/
// ******************************* //
//________________________________** INITIALIZE **_________________________________//
//////////////////////////////////** **///////////////////////////////////
// ** ** //
// ******************************* //
if($pagenow !== 'profile.php' and $pagenow !== 'user-edit.php') {
return;
}
// ******************************* //
//________________________________** ADD EVENTS **_________________________________//
//////////////////////////////////** **///////////////////////////////////
// ** ** //
// ******************************* //
add_action('profile_update','WP_members_list_meta_actions');
add_action('init','WP_members_list_meta_styles');
add_action('init','WP_members_list_meta_scripts');
add_action('edit_user_profile','WP_members_list_meta');
add_action('show_user_profile','WP_members_list_meta');
// ******************************* //
//________________________________** SCRIPTS **_________________________________//
//////////////////////////////////** **///////////////////////////////////
// ** ** //
// ******************************* //
function WP_members_list_meta_styles() {
}
function WP_members_list_meta_scripts() {
}
// ******************************* //
//________________________________** ACTIONS **_________________________________//
//////////////////////////////////** **///////////////////////////////////
// ** ** //
// ******************************* //
function WP_members_list_meta_actions($i) {
global $getWP,$tern_wp_members_defaults,$current_user,$wpdb,$profileuser,$current_user;
$o = $getWP->getOption('tern_wp_members',$tern_wp_members_defaults);
get_currentuserinfo();
if(!current_user_can('edit_users') and (($o['allow_display'] and $current_user->ID != $i) or !$o['allow_display'])) {
return;
}
global $getWP,$tern_wp_members_defaults,$current_user,$wpdb,$profileuser;
$o = $getWP->getOption('tern_wp_members',$tern_wp_members_defaults);
delete_user_meta($i,'_tern_wp_member_list');
foreach((array)$_REQUEST['lists'] as $v) {
add_user_meta($i,'_tern_wp_member_list',$v);
}
}
// ******************************* //
//________________________________** SETTINGS **_________________________________//
//////////////////////////////////** **///////////////////////////////////
// ** ** //
// ******************************* //
function WP_members_list_meta($i) {
global $getWP,$tern_wp_members_defaults,$profileuser,$current_user;
$o = $getWP->getOption('tern_wp_members',$tern_wp_members_defaults);
get_currentuserinfo();
if(!current_user_can('edit_users') and (($o['allow_display'] and $current_user->ID != $i->ID) or !$o['allow_display'])) {
return;
}
?>
<h3>Members Lists</h3>
<table class="form-table">
<tr>
<th><label for="lists">Select the lists you'd like this user displayed in:</label></th>
<td>
<ul>
<?php foreach($o['lists'] as $v) { ?>
<li><input type="checkbox" name="lists[]" value="<?php echo $v; ?>" <?php if(WP_members_list_is_in_list($i->ID,$v)) {?>checked<?php } ?> /> <?php echo $v; ?></li>
<?php } ?>
</ul>
</td>
</tr>
</table>
<?php
}
/****************************************Terminate Script******************************************/
?>
<?php
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// File:
// tern_wp_members.php
// Description:
// This file initializes the Wordpress Plugin - Members List Plugin
// Actions:
// 1) list members
// 2) search through members
// 3) perform administrative actions
// Date:
// Added on January 29th 2009
// Copyright:
// Copyright (c) 2010 Matthew Praetzel.
// License:
// This software is licensed under the terms of the GNU Lesser General Public License v3
// as published by the Free Software Foundation. You should have received a copy of of
// the GNU Lesser General Public License along with this software. In the event that you
// have not, please visit: http://www.gnu.org/licenses/gpl-3.0.txt
//
////////////////////////////////////////////////////////////////////////////////////////////////////
/****************************************Commence Script*******************************************/
// ******************************* //
//________________________________** ADD EVENTS **_________________________________//
//////////////////////////////////** **///////////////////////////////////
// ** ** //
// ******************************* //
add_action('admin_menu','tern_wp_members_menu');
//scripts & stylesheets
add_action('init','tern_wp_members_styles');
add_action('init','tern_wp_members_js');
add_action('wp_print_scripts','tern_wp_members_js_root');
//hide new members
add_action('user_register','tern_wp_members_hide');
//short code
add_shortcode('members-list','tern_wp_members_shortcode');
//errors
add_action('init','WP_members_list_errors');
// ******************************* //
//________________________________** MENUS **_________________________________//
//////////////////////////////////** **///////////////////////////////////
// ** ** //
// ******************************* //
function tern_wp_members_menu() {
if(function_exists('add_menu_page')) {
add_menu_page('Members List','Members List',10,__FILE__,'WP_members_list_settings');
add_submenu_page(__FILE__,'Members List','Settings',10,__FILE__,'WP_members_list_settings');
add_submenu_page(__FILE__,'Change Sort Fields','Change Sort Fields',10,'members-list-configure-sort','WP_members_list_sort_fields');
add_submenu_page(__FILE__,'Change Search Fields','Change Search Fields',10,'members-list-configure-search','WP_members_list_search_fields');
add_submenu_page(__FILE__,'Configure Mark-Up','Configure Mark-Up',10,'members-list-configure-mark-up','WP_members_list_markup');
add_submenu_page(__FILE__,'Edit Members','Edit Members',10,'members-list-edit-members-list','WP_members_list_list');
add_submenu_page(__FILE__,'Create a List','Create a List',10,'members-list-create-list','WP_members_list_create');
}
}
// ******************************* //
//________________________________** SCRIPTS **_________________________________//
//////////////////////////////////** **///////////////////////////////////
// ** ** //
// ******************************* //
function tern_wp_members_styles() {
if(!is_admin()) {
wp_enqueue_style('tern_wp_members_css',get_bloginfo('wpurl').'/wp-content/plugins/members-list/css/members-list.css');
}
}
function tern_wp_members_js() {
if(!is_admin()) {
wp_enqueue_script('members-list',get_bloginfo('wpurl').'/wp-content/plugins/members-list/js/scripts.js',array('jquery'));
}
}
function tern_wp_members_js_root() {
echo '<script type="text/javascript">var tern_wp_root = "'.get_bloginfo('home').'";</script>'."\n";
}
function tern_wp_members_hide($i) {
global $getWP,$tern_wp_members_defaults;
$o = $getWP->getOption('tern_wp_members',$tern_wp_members_defaults);
if($o['hide'] and !in_array($i,$o['hidden'])) {
$o['hidden'][] = $i;
$o = $getWP->getOption('tern_wp_members',$o,true);
}
}
// ******************************* //
//________________________________** SHORTCODE **_________________________________//
//////////////////////////////////** **///////////////////////////////////
// ** ** //
// ******************************* //
function tern_wp_members_shortcode($a) {
$m = new tern_members;
return $m->members($a,false);
}
// ******************************* //
//________________________________** ERRORS **_________________________________//
//////////////////////////////////** **///////////////////////////////////
// ** ** //
// ******************************* //
function WP_members_list_errors() {
global $getWP,$tern_wp_members_defaults;
$o = $getWP->getOption('tern_wp_members',$tern_wp_members_defaults);
//if(!$o['url'] or empty($o['url'])) {
// $getWP->addError('Please remember to select a page in your Members List settings. Otherwise, many of the Members List plugin\'s featured will not work.');
//}
$getWP->renderErrors();
}
// ******************************* //
//________________________________** FUNCTIONS **_________________________________//
//////////////////////////////////** **///////////////////////////////////
// ** ** //
// ******************************* //
function WP_members_list_is_in_list($u,$l) {
$m = get_user_meta($u,'_tern_wp_member_list');
$m = is_array($m) ? $m : array($m);
foreach($m as $v) {
if($v == $l) {
return true;
}
}
return false;
}
function WP_members_list_get_users_by_role($r) {
global $wpdb;
foreach($r as $v) {
$x .= empty($x) ? " $wpdb->usermeta.meta_value LIKE '%$v%' " : " or $wpdb->usermeta.meta_value LIKE %'$v'% ";
}
return $wpdb->get_results("select ID from $wpdb->users inner join $wpdb->usermeta on($wpdb->users.ID = $wpdb->usermeta.user_id) where $wpdb->usermeta.meta_key='$wpdb->prefix"."capabilities' and ($x)");
}
/****************************************Terminate Script******************************************/
?>
<?php
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// File:
// markup.php
// Description:
// This file compiles and processes the plugin's configure mark-up page.
// Actions:
// 1) compile plugin mark-up form
// 2) process and save plugin mark-up
// Date:
// Added on September 15th 2010
// Copyright:
// Copyright (c) 2010 Matthew Praetzel.
// License:
// This software is licensed under the terms of the GNU Lesser General Public License v3
// as published by the Free Software Foundation. You should have received a copy of of
// the GNU Lesser General Public License along with this software. In the event that you
// have not, please visit: http://www.gnu.org/licenses/gpl-3.0.txt
//
////////////////////////////////////////////////////////////////////////////////////////////////////
/****************************************Commence Script*******************************************/
// ******************************* //
//________________________________** INITIALIZE **_________________________________//
//////////////////////////////////** **///////////////////////////////////
// ** ** //
// ******************************* //
if((!isset($_REQUEST['page']) or $_REQUEST['page'] !== 'members-list-configure-mark-up') and $GLOBALS['pagenow'] != 'admin-ajax.php') {
return;
}
// ******************************* //
//________________________________** ADD EVENTS **_________________________________//
//////////////////////////////////** **///////////////////////////////////
// ** ** //
// ******************************* //
add_action('init','WP_members_list_markup_actions');
add_action('wp_ajax_markup','WP_members_list_markup_actions');
add_action('wp_ajax_getmarkup','WP_members_list_markup_actions');
add_action('init','WP_members_list_markup_styles');
add_action('init','WP_members_list_markup_scripts');
// ******************************* //
//________________________________** SCRIPTS **_________________________________//
//////////////////////////////////** **///////////////////////////////////
// ** ** //
// ******************************* //
function WP_members_list_markup_styles() {
wp_enqueue_style('tern_wp_members_css',get_bloginfo('wpurl').'/wp-content/plugins/members-list/css/members-list.css');
}
function WP_members_list_markup_scripts() {
wp_enqueue_script('TableDnD',get_bloginfo('wpurl').'/wp-content/plugins/members-list/js/jquery.tablednd_0_5.js.php',array('jquery'),'0.5');
wp_enqueue_script('members-list',get_bloginfo('wpurl').'/wp-content/plugins/members-list/js/admin.js');
}
// ******************************* //
//________________________________** ACTIONS **_________________________________//
//////////////////////////////////** **///////////////////////////////////
// ** ** //
// ******************************* //
function WP_members_list_markup_actions() {
global $getWP,$tern_wp_members_defaults,$current_user;
get_currentuserinfo();
$o = $getWP->getOption('tern_wp_members',$tern_wp_members_defaults);
if($_REQUEST['page'] == 'members-list-configure-mark-up') {
if(wp_verify_nonce($_REQUEST['_wpnonce'],'tern_wp_members_nonce')) {
switch($_REQUEST['action']) {
//update all fields
case 'markup' :
$o['fields'] = array();
foreach($_REQUEST['field_titles'] as $k => $v) {
$v = stripslashes($v);
$o['fields'][$v] = array(
'name' => $_REQUEST['field_names'][$k],
'markup' => stripslashes($_REQUEST['field_markups'][$k])
);
}
$o = $getWP->getOption('tern_wp_members',$o,true);
echo '<div id="message" class="updated fade"><p>Your order has been successfully saved.</p></div>';
die();
//add a field
case 'add' :
$f = $_REQUEST['new_field'];
$o['fields'][$f] = array(
'name' => $f,
'markup' => '<div class="tern_wp_members_'.$f.'">%value%</div>'
);
$o = $getWP->getOption('tern_wp_members',$o,true);
//delete a field
case 'remove' :
$a = array();
foreach($o['fields'] as $k => $v) {
if($v['name'] != $_REQUEST['fields'][0]) {
$a[$k] = $v;
}
}
$o['fields'] = $a;
$o = $getWP->getOption('tern_wp_members',$o,true);
}
}
//attempted to update all fields without nonce
elseif($_REQUEST['action'] == 'update' or $_REQUEST['action'] == 'add' or $_REQUEST['action'] == 'delete') {
echo '<div id="message" class="updated fade"><p>There was an error whil processing your request. Please try again.</p></div>';
die();
}
//get sample mark-up
if($_REQUEST['action'] == 'getmarkup') {
$m = new tern_members();
echo htmlentities($m->markup($current_user));
die();
}
}
}
// ******************************* //
//________________________________** SETTINGS **_________________________________//
//////////////////////////////////** **///////////////////////////////////
// ** ** //
// ******************************* //
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
}
/****************************************Terminate Script******************************************/
?>
$level1users = get_users('role=s2member_level1');
foreach ($level1users as $user) {
echo '<li>' . $user->display_name . '</li>';
}
Users browsing this forum: Exabot [Bot], Yahoo [Bot] and 1 guest