'',
'page' => '',
'recent' => '',
'header' => '',
'title' => '',
'count' => '',
'random' => '',
'type' => 'manage',
'id' => '',
'noid' => '',
'exclude' => 'tweet',
'submit' => '',
'state1' => '',
'state2' => '',
'state3' => '',
);
echo amen_list_requests( $the_amen );
}
/**************************************
* ADD SHORTCODE FOR LISTING REQUESTS
**************************************/
function amen_list_requests( $amen_atts ) {
global $amen_options;
extract( shortcode_atts( array(
'author' => '',
'page' => '',
'recent' => '',
'header' => '',
'title' => '',
'count' => '',
'random' => '',
'type' => 'list',
'id' => '',
'noid' => '',
'exclude' => '',
'submit' => '',
'state1' => '',
'state2' => '',
'state3' => '',
), $amen_atts ) );
// DEFINE SHORTCODE ARG ARRAY
$the_amen = array(
'author' => ' ' . $author,
'page' => $page,
'recent' => $recent,
'header' => $header,
'count' => $count,
'random' => $random,
'type' => $type,
'id' => $id,
'noid' => $noid,
'exclude' => ' ' . $exclude,
'submit' => $submit,
'state1' => $state1,
'state2' => $state2,
'state3' => $state3,
);
'' == $header ? $the_amen['header'] = $title : FALSE;
$the_amen['submit'] = '' == $the_amen['submit'] ? $amen_options['submit_text'] : $the_amen['submit'];
$the_amen['state1'] = '' == $the_amen['state1'] ? $amen_options['submitted_state_one'] : $the_amen['state1'];
$the_amen['state2'] = '' == $the_amen['state2'] ? $amen_options['submitted_state_two'] : $the_amen['state2'];
$the_amen['state3'] = '' == $the_amen['state3'] ? $amen_options['submitted_state_three'] : $the_amen['state3'];
$the_amen['recent'] = $count;
$the_amen['type'] = $type;
$the_amen['id'] = $id;
$amen_request_list = amen_query_requests( $the_amen );
return $amen_request_list;
unset( $the_amen );
}
add_shortcode( 'amen', 'amen_list_requests' );
function amen_query_requests( $the_amen ) {
global $amen_session, $amen_options, $post;
// begin buffer for display
ob_start();
/**************************************
* INCLUDE TWEET BUTTON JAVASCRIPT
**************************************/
if ( !( strpos( $the_amen['exclude'], 'tweet' ) > 0 ) && $amen_options['tweet_public_requests'] ) {
echo '';
}
/**************************************
* DISPLAY SUBMISSION FORM
**************************************/
?>
display_name;
} else {
$display_name = isset( $_POST['display_name'] ) ? $_POST['display_name'] : '';
}
if ( is_user_logged_in() ) {
$email = $user_email;
} else {
$email = isset( $_POST['amenemail'] ) ? $_POST['amenemail'] : '';
}
// call update db functions on form post
if ( isset($_POST['prayer_item']) && !empty($_POST['prayer_item']) ) {
amen_create_request($_POST['prayer_item'], $_POST['urgency'], $_POST['privacy'], $_POST['praying_tag'], $amen_session, $display_name, $email, $_POST['notify'] );
} else if ( isset($_POST['toggleUrgency']) && !empty($_POST['toggleUrgency']) && isset($_POST['toggleTo']) && !empty($_POST['toggleTo']) ) {
if ( $_POST['toggleTo'] == 'urgentize' ) {
amen_urgentize_request(intval($_POST['toggleUrgency']));
} else {
amen_deurgentize_request(intval($_POST['toggleUrgency']));
}
} else if ( isset($_POST['toggleNotification']) && !empty($_POST['toggleNotification']) && isset($_POST['toggleTo']) && !empty($_POST['toggleTo']) ) {
if ( $_POST['toggleTo'] == 'notifize' ) {
amen_notifize_request(intval($_POST['toggleNotification']));
} else {
amen_denotifize_request(intval($_POST['toggleNotification']));
}
} else if ( isset($_POST['toggleRequest']) && !empty($_POST['toggleRequest']) && isset($_POST['toggleTo']) && !empty($_POST['toggleTo']) ) {
if ( $_POST['toggleTo'] == 'activate' ) {
amen_activate_request(intval($_POST['toggleRequest']));
} else {
amen_deactivate_request(intval($_POST['toggleRequest']));
}
} else if ( isset($_POST['togglePrivacy']) && !empty($_POST['togglePrivacy']) && isset($_POST['toggleTo']) && !empty($_POST['toggleTo']) ) {
if ( $_POST['toggleTo'] == 'privatize' ) {
amen_privatize_request(intval($_POST['togglePrivacy']));
} else {
amen_deprivatize_request(intval($_POST['togglePrivacy']));
}
} else if ( isset($_POST['toggleApproval']) && !empty($_POST['toggleApproval']) && isset($_POST['toggleTo']) && !empty($_POST['toggleTo']) ) {
if ( $_POST['toggleTo'] == 'approve' ) {
amen_approve_request(intval($_POST['toggleApproval']));
}
} else if ( isset($_POST['prayer_update']) && !empty( $_POST['prayer_update'] ) ) {
amen_update_request( intval($_POST['updateRequest']), $_POST['prayer_update'] );
} else if ( isset($_POST['request_edit']) && !empty( $_POST['request_edit'] ) ) {
amen_edit_request( intval($_POST['editRequest']), $_POST['request_edit'] );
} else if ( isset($_POST['deleteRequest']) && !empty($_POST['deleteRequest']) ) {
amen_delete_request( intval($_POST['deleteRequest'] ) );
}
// include header on admin page
echo is_admin() ? '
Manage Prayer Requests
' : '';
?>
user_login . ')';
break;
case 'displayname':
$amen_author_display = ' (' . wp_get_current_user()->display_name . ')';
break;
default:
$amen_author_display = '';
break;
}
} else {
$amen_author_display = '' != $amen_options['public_user'] ? ' (' . $amen_options['public_user'] . ')' : '';
}
echo $amen_author_display;
// begin form display ?>
created_by )->user_login ) > 0 && ( '' != $r->praying_tag && $r->praying_tag == $the_amen['page'] ) ) {
$amen_list_this_request = TRUE;
} else { $amen_list_this_request = FALSE; }
}
// if author is set and page is not
elseif ( ' ' != $the_amen['author'] && '' == $the_amen['page'] ) {
// if request is in author, then include
if ( strpos( $the_amen['author'], get_userdata( $r->created_by )->user_login ) > 0 ) {
$amen_list_this_request = TRUE;
} else { $amen_list_this_request = FALSE; }
}
// if page is set and author is not
elseif ( ' ' == $the_amen['author'] && '' != $the_amen['page'] ) {
// if request is in page, then include
if ( '' != $r->praying_tag && $r->praying_tag == $the_amen['page'] ) {
$amen_list_this_request = TRUE;
} else { $amen_list_this_request = FALSE; }
}
// if author and page not set, then include request
elseif ( ' ' == $the_amen['author'] && '' == $the_amen['page'] ) {
$amen_list_this_request = TRUE;
}
// else, don't include - is this needed?
else {
$amen_list_this_request = FALSE;
}
// if request is included, check other parameters (could be optimized with above code)
if ( $amen_list_this_request ) {
// if recent is not set or still serving recently requested
if ( '' == $the_amen['recent'] || $i < intval( $the_amen['recent'] ) ) {
// set options to true or false
$praying = intval($r->praying) == 1;
$active = intval($r->active) == 1;
$urgent = intval($r->urgency) == 1;
$private = intval($r->privacy) == 1;
$approved = intval($r->approved) == 1;
$notify = intval($r->notify) == 1;
//$faved = isset($r->faved) ? TRUE : FALSE;
// set classes
$cssClasses = 'pray_request_wrap';
$cssClasses .= ' amen-' . $r->id;
// check if user is in fav list
$fav = unserialize( $r->fav_list );
'' == $fav ? $fav = array() : FALSE;
foreach ( $fav as $favuser => $status ) {
if ( _get_amen_user_ID() == $favuser ) {
$cssClasses .= ' included-in-favs';
}
}
!$active ? $cssClasses .= $cssClasses .= ' amen-inactive' : '';
!$urgent ? $cssClasses .= '' : $cssClasses .= ' pray_request_urgent';
!$private ? $cssClasses .= '' : $cssClasses .= ' pray_request_private';
$approved ? $cssClasses .= '' : $cssClasses .= ' pray_request_not_approved';
// show header, if shortcode parameter set
if ($i == 0 && '' != $the_amen['header']) { amen_header( $the_amen['header'] ); }
// include anchor to request, then begin display
?>
twitter_handle ? $amen_options['public_user'] : $r->twitter_handle;
switch ( $amen_options['author_display'] ) {
case 'none':
if ( current_user_can( 'delete_users' ) ) {
$amen_author_display = get_userdata( $r->created_by ) ? get_userdata( $r->created_by )->user_login : $public_author;
$amen_author_display .= ( get_userdata( $r->created_by ) && 'manage' == $the_amen['type'] ) ? ' (' . get_userdata( $r->created_by )->display_name . ')' : FALSE;
$amen_author_display .= ': ';
} else {
$amen_author_display = '';
}
break;
case 'username':
// if author exclusion not set in shortcode
if ( !( strpos( $the_amen['exclude'], 'author' ) > 0 ) ) {
$amen_author_display = get_userdata( $r->created_by ) ? get_userdata( $r->created_by )->user_login : $public_author;
if ( current_user_can( 'delete_users' ) ) {
$amen_author_display .= ( get_userdata( $r->created_by ) && 'manage' == $the_amen['type'] ) ? ' (' . get_userdata( $r->created_by )->display_name . ')' : FALSE;
}
$amen_author_display .= ': ';
}
break;
case 'displayname':
// if author exclusion not set in shortcode
if ( !( strpos( $the_amen['exclude'], 'author' ) > 0 ) ) {
$amen_author_display = get_userdata( $r->created_by ) ? get_userdata( $r->created_by )->display_name : $public_author;
if ( current_user_can( 'delete_users' ) ) {
$amen_author_display .= ( get_userdata( $r->created_by ) && 'manage' == $the_amen['type'] ) ? ' (' . get_userdata( $r->created_by )->user_login . ')' : FALSE;
}
$amen_author_display .= ': ';
}
break;
default:
$amen_author_display = '';
break;
}
// set id for admin on management page
if ( current_user_can( 'delete_users' ) && 'manage' == $the_amen['type'] ) { $amen_id = '
[Amen-ID: ' . $r->id . '] '; } else { $amen_id = ''; }
// set status on management page
if ( 'manage' == $the_amen['type'] ) {
$amen_id .= $private ? 'Privately ' : 'Publicly ';
$amen_id .= $active ? 'Active' : 'Inactive';
$amen_id .= $notify ? '
(Notifying ' . $r->email . ')' : '
(Notifications Disabled)';
}
// show id, author, and item
echo '
' . $amen_id . $amen_author_display . $r->prayer_item;
// show toggle forms on management page
if ( 'manage' == $the_amen['type'] ) { ?>
';
// if counter enabled and not excluded by shortcode
if ( !( strpos( $the_amen['exclude'], 'counter' ) > 0 ) && $amen_options['enable_submit_count'] && $r->approved ) {
echo '
';
// if already praying, show this
if ( $praying ) {
echo count_contents($r->count, $praying, $the_amen);
}
// if not praying, show this
else {
echo count_contents($r->count, $praying, $the_amen);
echo ' – ';
echo '
' . amen_set_display($r->count, $the_amen['submit']) . '';
}
echo '
';
}
// if not yet approved, show this (restricted to author elsewhere)
if ( !$r->approved ) {
echo '
Pending Approval
';
}
// if tweet enabled, not excluded by shortcode, and post not private and approved
elseif ( !( strpos( $the_amen['exclude'], 'tweet' ) > 0 ) && !$r->privacy && $r->approved && $amen_options['tweet_public_requests'] ) {
echo '
';
$amen_add_name = $amen_options['prepend_name_to_tweet'] ? $amen_author_display : '';
if ( 'hashtag' == $amen_options['tweet_type'] ) {
$amen_options['hashtag_in_button'] ? $amen_display_hashtag = '?button_hashtag=' . $amen_options['custom_hashtag'] : $amen_display_hashtag = '';
$amen_options['custom_hashtag'] ? $amen_custom_hashtag = ' #' . $amen_options['custom_hashtag'] : $amen_custom_hashtag = '';
echo '';
} elseif ( 'share_count' == $amen_options['tweet_type'] ) {
echo '';
}
echo '
';
}
// if private, show this
elseif ( $r->privacy ) {
echo '
Private Request
';
}
echo '
';
// show update
if ( '' != $r->prayer_updated ) {
echo '
' . $r->prayer_updated . '
';
}
// if allowed to author and management page
if ( ( is_user_logged_in() || $amen_options['allow_public_requests'] ) && 'manage' == $the_amen['type'] ) {
global $user_email; ?>
user_login ) === FALSE ) || current_user_can( 'delete_users' ) ) {
$tagged_pages = $wpdb->get_results(
"
SELECT meta_value, post_id
FROM $wpdb->postmeta
WHERE meta_key = 'praying'
"
);
foreach ( $tagged_pages as $tagged_page ) {
if ( $tagged_page->meta_value == get_userdata( $r->created_by )->user_login ) {
echo get_the_title( $tagged_page->post_id ) . ', ';
}
}
echo $r->praying_tag ? ' On Pages: ' . get_the_title( $r->praying_tag ) . ' | ' : '';
}
echo '[' . $r->created_at . ']'; ?>
created_by ) ) ) { ?>
|
|
0 ) ) ) { ?>
|
|
|
0 ) ) && isset( $_GET['amen-action'] ) ) {
if ( 'approve' == $_GET['amen-action'] ) {
amen_approve_request( $_GET[ $amen_options['custom_id_name'] ] );
} elseif ( 'delete' == $_GET['amen-action'] ) {
amen_delete_request( $_GET[ $amen_options['custom_id_name'] ] );
}
}
}
add_action( 'init', 'amen_action_from_email' );
/**************************************
* DISPLAY COUNT FOR REQUEST
**************************************/
function count_contents($count, $praying = 0, $the_amen) {
global $amen_options;
$count = intval($count);
$state_one = '' == $the_amen['state1'] ? $amen_options['submitted_state_one'] : $the_amen['state1'];
$state_two = '' == $the_amen['state2'] ? $amen_options['submitted_state_two'] : $the_amen['state2'];
$state_three = '' == $the_amen['state3'] ? $amen_options['submitted_state_three'] : $the_amen['state3'];
if ( !$praying ) { $amen_final_text = amen_set_display( $count, $state_one ); return $amen_final_text; }
elseif ( $count == '1' && $praying ) { $amen_final_text = amen_set_display( $count, $state_two ); return $amen_final_text; }
else { $amen_final_text = amen_set_display( $count, $state_three ); return $amen_final_text; }
}
function amen_set_display( $count, $amen_text ) {
$amen_text = str_replace( '{count}', $count, $amen_text);
$amen_text = str_replace( '{count-1}', $count - 1, $amen_text);
$amen_text = str_replace( '{count+1}', $count + 1, $amen_text);
( $count > 1 || $count == 0 ) ? $amen_text = str_replace( '{s}', 's', $amen_text ) : $amen_text = str_replace( '{s}', '', $amen_text );
$count == 1 ? $amen_text = str_replace( '{1s}', 's', $amen_text ) : $amen_text = str_replace( '{1s}', '', $amen_text );
return $amen_text;
unset($amen_text);
}
?>