这是一个漫长的两天,试图从零开始编程一个插件,以提供一个包含2个表单的前端登录页。
根据用户想要使用的表单,表单应更改数据库中的值(如果不存在自定义字段“key”=>“value”,则添加或创建)。
如果运气不好,对与操纵$\\u POST和获取其价值等相关的表单和功能进行了多次更改,但都没有成功!
有人愿意看看我下面的代码吗?目的是在提交时区分两种表格。之后,如果按下第二个提交按钮,则会在wp\\U Posteta表中更新自定义字段值。
<?php
$lucs_stored_meta = get_post_meta($post->ID);
// salt shaker, drawing straws, randomness
function lucs_random_thumbnail() {
$lucs_random_image = rand(0,1);
if ($lucs_random_image == 0) {
$lucs_thumb_ra = plugins_url(\'/img/thumb0.png\',__FILE__);
} else {
$lucs_thumb_ra = plugins_url(\'/img/thumb1.png\',__FILE__);
}
return $lucs_thumb_ra;
}
// if participant has no featured image, display the following default image included in plugin
function lucs_get_featured_image() {
if (has_post_thumbnail()) {
the_post_thumbnail(\'thumbnail\',array( \'class\' => \'showcase-thumbnail\' ));
} else {
echo \'<img src="\' . lucs_random_thumbnail() . \'" class="showcase-thumbnail" alt="Organization">\';
}
}
/*START OF CONTESTANT FORM*/
if (isset($_POST[\'lucs_nonce_guest\']) && wp_verify_nonce($_POST[\'lucs_nonce_guest\'],\'post_nonce\')) {
if (isset($_POST[\'password\']) && trim($_POST[\'password\']) != \'\') {
$lucs_form_details = array(
\'post_title\' => wp_strip_all_tags($_POST[\'org_contestant\']),
\'post_content\' => sanitize_text_field($_POST[\'org_reason\']),
\'post_type\' => \'lucs_contestant\',
\'post_status\' => \'trash\',
\'comment_status\' => \'closed\',
);
$lucs_if_posted = wp_insert_post($lucs_form_details);
add_post_meta($lucs_if_posted,\'org_contestant\',sanitize_text_field($_POST[\'org_contestant\']));
add_post_meta($lucs_if_posted,\'org_contact_person\',sanitize_text_field($_POST[\'org_contact_person\']));
add_post_meta($lucs_if_posted,\'org_zip\',sanitize_text_field($_POST[\'org_zip\']));
add_post_meta($lucs_if_posted,\'org_contact_phone\',sanitize_text_field($_POST[\'org_contact_phone\']));
add_post_meta($lucs_if_posted,\'org_contact_email\',sanitize_text_field($_POST[\'org_contact_email\']));
add_post_meta($lucs_if_posted,\'org_pets_rescued\',sanitize_text_field($_POST[\'org_pets_rescued\']));
lucs_redirect_to_help();
} elseif ($_POST[\'org_reason\'] == \'\' || $_POST[\'org_contact_phone\'] == \'\') {
lucs_redirect_to_help();
} elseif (isset($_POST[\'lucsy_form\'])) {
$lucs_form_details = array(
\'post_title\' => wp_strip_all_tags($_POST[\'org_contestant\']),
\'post_content\' => \'\',
\'post_type\' => \'lucs_contestant\',
\'post_status\' => \'pending\',
\'comment_status\' => \'closed\',
);
$lucs_if_posted = wp_insert_post($lucs_form_details);
add_post_meta($lucs_if_posted,\'org_contestant\',sanitize_text_field($_POST[\'org_contestant\']));
add_post_meta($lucs_if_posted,\'org_contact_person\',sanitize_text_field($_POST[\'org_contact_person\']));
add_post_meta($lucs_if_posted,\'org_zip\',sanitize_text_field($_POST[\'org_zip\']));
add_post_meta($lucs_if_posted,\'org_contact_phone\',sanitize_text_field($_POST[\'org_contact_phone\']));
add_post_meta($lucs_if_posted,\'org_contact_email\',sanitize_text_field($_POST[\'org_contact_email\']));
add_post_meta($lucs_if_posted,\'org_pets_rescued\',sanitize_text_field($_POST[\'org_pets_rescued\']));
add_post_meta($lucs_if_posted,\'org_reason\',sanitize_text_field($_POST[\'org_reason\']));
add_post_meta($lucs_if_posted,\'org_participation\',sanitize_text_field($_POST[\'org_participation\']));
add_post_meta($lucs_if_posted,\'org_votes\',sanitize_text_field($_POST[\'org_votes\']));
lucs_redirect_to_thanks();
} elseif (isset($_POST[\'org_vote\'])) {
$submitted_array = array_keys($_POST[\'lucs_current_entry\']);
$lucs_hola = $submitted_array[0];
function lucs_add_one_vote($value) {
//Get current bid
$myvote0 = get_post_meta($value, \'org_votes\', true);
//Increase the bid, for example the amount here is 100?
$myvote1 = $myvote0 + 1;
//Update the database with the increased bid value
update_post_meta($value,\'org_votes\',$myvote1,$myvote0);
// In case you need to update another meta for the user, you
// can access the user ID with the get_current_user_id() function
}
lucs_add_one_vote($lucs_hola);
lucs_redirect_to_thanks();
}
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title><?php echo get_the_title(); ?></title>
<meta name="description" content="<?php if (!empty($lucs_stored_meta[\'contest_results\'][0]) && $lucs_stored_meta[\'contest_status\'][0] == \'Over\') { echo $lucs_stored_meta[\'contest_results\'][0]; } ?>">
<meta name="author" content="<?php echo get_the_modified_author(); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=1">
<link rel="stylesheet" href="<?php
switch ($lucs_stored_meta[\'contest_theme\'][0]) {
case "Plain": echo esc_url(plugins_url(\'css/contest-plain/contest-plain.css\', __FILE__)); break;
case "Green Eggs": echo esc_url(plugins_url(\'css/contest-green/contest-green-eggs.css\', __FILE__)); break;
case "Modern": echo esc_url(plugins_url(\'css/contest-modern/contest-modern.css\', __FILE__)); break;
}
?>">
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<header class="contest-header">
<div class="contest-logo">
<img alt="Contest hosted by example.org" src="<?php echo esc_url(plugins_url(\'img/logo.png\', __FILE__)); ?>">
</div>
<div class="sarfb">
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.5";
fjs.parentNode.insertBefore(js, fjs);
}(document, \'script\', \'facebook-jssdk\'));</script>
<div class="fb-like" data-href="https://www.facebook.com/company" data-width="250" data-layout="standard" data-action="like" data-show-faces="true" data-share="false"></div>
</div>
<div style="text-align:left;background-color: white; height:0px;border-bottom-color:rgb(204, 204, 204);border-width: medium medium 1px; border-style: none none solid; ">
</div>
<div style="text-align:left;background-color: white; border-top-color:rgb(229, 229, 229);padding-bottom:1px;border-width: 4px medium medium; border-style: solid none none; "></div>
</header>
<div id="contest-status">
<p>This contest is <?php echo strtolower(sanitize_text_field($lucs_stored_meta[\'contest_status\'][0])) ?>! <span class="light-end-date">End Date: <?php echo sanitize_text_field($lucs_stored_meta[\'contest_end_date\'][0]) ?></span></p>
</div>
<div class="featured-image-container">
<img alt="Contest brought to you by example.org" src="<?php if (has_post_thumbnail()) { echo wp_get_attachment_url(get_post_thumbnail_id()); } else { echo sanitize_text_field(plugins_url( \'/img/default-featured-image.jpg\', __FILE__ )); } ?>" class="featured-image">
</div>
<div class="contest-share-container">
<div class="contest-share-instruction">E-mail this contest to your friends and followers or Share!</div>
<div class="contest-share-button">
<a href="mailto:?body=%0D%0A%0D%0AStumbled upon this and thought you might be interested: %0D%0A%0D%0A<?php echo esc_url(get_permalink( $post->ID )); ?>&subject=Check Out This Contest" target="_blank" title="Email"><img src="<?php echo esc_url(plugins_url(\'css/contest-plain/img/email.png\', __FILE__)); ?>"> E-mail </a>
</div>
<div class="contest-share-button">
<a href="http://www.facebook.com/sharer.php?u=<?php esc_url(get_permalink( $post->ID ));?>&t=<?php the_title(); ?>" title="Share on Facebook"><img src="<?php echo esc_url(plugins_url(\'css/contest-plain/img/facebook_16.png\', __FILE__)); ?>"> Facebook </a>
</div>
<div class="contest-share-button">
<a href="javascript:window.location=%22https://twitter.com/share?url=%22+encodeURIComponent(document.location)+%22&text=%22+encodeURIComponent(document.title)" title="Tweet"><img src="<?php echo esc_url(plugins_url(\'css/contest-plain/img/twitter_16.png\', __FILE__)); ?>"> Twitter </a>
</div>
<div class="contest-share-button">
<a href="https://plusone.google.com/_/+1/confirm?hl=en&url=<?php esc_url(get_permalink( $post->ID )); ?>" target="_blank" title="Plus one this page on Google"><img src="<?php echo esc_url(plugins_url(\'css/contest-plain/img/plus_16.png\', __FILE__)); ?>"> Google+ </a>
</div>
<div class="contest-share-button">
<a href="//pinterest.com/pin/create/link/?url=<?php esc_url(get_permalink( $post->ID ))?>&description=<?php the_title();?>" title="Pin it"><img src="<?php echo esc_url(plugins_url(\'css/contest-plain/img/pinterest_16.png\', __FILE__)); ?>"> Pinterest </a>
</div>
<div class="contest-share-button">
<a href="http://www.linkedin.com/shareArticle?mini=true&url=<?php esc_url(get_permalink( $post->ID )) ?>" target="_blank"><img src="<?php echo esc_url(plugins_url(\'css/contest-plain/img/in_16.png\', __FILE__)); ?>"> Linked in </a>
</div>
</div>
<div class="lucs-frontform-title">WIN 5,000 Meals For Your Rescue</div>
<div class="lucs-frontform">
<form action="" id="lucs-contestant-registration" method="POST">
<fieldset>
<div class="lucs-label">
<label for="org-contestant"><b>Rescue</b> Organization Name</label>
</div>
<div class="lucs-detail-input">
<input type="text" name="org_contestant" id="org-contestant" />
</div>
</fieldset>
<fieldset>
<div class="lucs-label">
<label for="org-contact-person">Contact Person [Name]</label>
</div>
<div class="lucs-detail-input">
<input type="text" name="org_contact_person" id="org-contact-person" />
</div>
</fieldset>
<fieldset>
<div class="lucs-label">
<label for="org-zip">Zip Code</label>
</div>
<div class="lucs-detail-input">
<input type="text" maxlength="5" name="org_zip" id="org-zip" />
</div>
</fieldset>
<fieldset>
<div class="lucs-label"><label>Preferred Contact Method</label></div>
<div class="lucs-label">
<label for="org-contact-phone">Phone</label>
</div>
<div class="lucs-detail-input">
<input type="text" name="org_contact_phone" id="org-contact-phone" />
</div>
<div class="lucs-label">
<label for="org-contestant">E-mail</label>
</div>
<div class="lucs-detail-input">
<input type="text" name="org_contact_email" id="org-contact-email" />
</div>
</fieldset>
<fieldset>
<div class="lucs-label"><label for="org-pets-rescued">Question for viewer</label></div>
<div class="lucs-detail-input">
<input type="text" maxlength="5" name="org_pets_rescued" id="org-pets-rescued" />
</div>
</fieldset>
<fieldset>
<div class="lucs-label"><label for="org-reason">Tell Us in 100-500 Words or Less Why You Could Use these 5,000 Meals.</label></div>
<textarea name="org_reason" id="org-reason" rows="4"></textarea>
</fieldset>
<fieldset>
<div class="lucs-detail-input">
<input type="hidden" maxlength="5" name="org_participation" id="org-participation" value="<?php echo the_ID(); ?>" />
</div>
</fieldset>
<fieldset>
<div class="lucs-detail-input">
<input type="hidden" maxlength="5" name="org_votes" id="org-votes" value="0" />
</div>
</fieldset>
<?php //the password is an anti-spam measure ?>
<input type="text" name="password" id="password" autofill="off" style="display:none !important;" />
<?php wp_nonce_field(\'post_nonce\',\'lucs_nonce_guest\'); ?>
<button name="lucsy_form" type="submit">Submit</button>
</form>
</div>
<div class="tab-container">
<a href="#" class="tab-left">A-C</a>
<a href="#" class="tab-left">D-F</a>
<a href="#" class="tab-left">G-I</a>
<a href="#" class="tab-left">J-L</a>
<a href="#" class="tab-left">M-O</a>
<a href="#" class="tab-left">P-R</a>
<a href="#" class="tab-left">S-U</a>
<a href="#" class="tab-left">V-Z</a>
</div>
<div class="showcase-container">
<?php
// WP_Query arguments
$lucs_current_contest_id = get_the_id();
$args = array (
\'post_type\' => array( \'lucs_contestant\' ),
\'post_status\' => array( \'publish\' ),
\'pagination\' => true,
\'posts_per_page\' => \'40\',
\'ignore_sticky_posts\' => false,
\'order\' => \'DESC\',
\'orderby\' => \'date\',
\'meta_query\' => array(
array(
\'key\' => \'org_participation\',
\'value\' => $lucs_current_contest_id,
\'compare\' => \'=\',
\'type\' => \'NUMERIC\',
),
),
\'cache_results\' => true,
\'update_post_meta_cache\' => true,
);
// The Query
$lucs_query_participants = new WP_Query( $args );
// The Loop
if ( $lucs_query_participants->have_posts() ) {
while ( $lucs_query_participants->have_posts() ) {
$lucs_query_participants->the_post();
// do something
$lucs_single_contestant_meta = get_post_meta($post->ID);
?>
<div class="showcase-individual">
<div class="showcase-thumbnail-container">
<a href="<?php echo esc_url(get_permalink($post->ID)); ?>" title="<?php echo get_the_title($post->ID); ?>">
<?php lucs_get_featured_image(); ?>
</a>
</div>
<div class="showcase-title">
<a href="<?php echo esc_url(get_permalink($post->ID)); ?>" title="<?php echo get_the_title($post->ID); ?>"><?php echo the_title(); ?></a>
</div>
<div class="showcase-intro">
<p><?php if (!empty($lucs_single_contestant_meta[\'org_reason\'])) echo esc_html(wp_trim_words($lucs_single_contestant_meta[\'org_reason\'][0],40,\'...\')) . \'<a href="\'. esc_url(get_permalink($post->ID)) .\'"> Read More </a>\'; ?></p>
</div>
<div class="showcase-counter">
<form method="post">
<input type="hidden" name="lucs_current_entry[<?php echo $post->ID; ?>]" value="lucs_vote">
<button type="submit" name="org_vote">Vote</button>
</form>
</div>
</div>
<?php
}
} else {
echo \'COMING SOON\';
}
// Restore original Post Data
wp_reset_postdata();
?>
</div> <!-- END OF class="showcase-container" -->
<footer class="contest-footer">
<div class="lucs-divider"></div>
<?php if ($lucs_stored_meta[\'contest_sponsor_visibility\'][0] == \'Yes\') { ?>
<div class="sponsor-notice-box">
<div class="sponsor-notice-title">
<div class="sponsor-notice-text"><b>Brought to you by </b><?php echo esc_html($lucs_stored_meta[\'contest_sponsor\'][0]) ?>
</div>
</div>
</div>
<?php
} else {
echo \'\';
}
?>
<p>By participating in this promotion you agree to the Official Rules.</p>
<p>This promotion is in no way sponsored, endorsed or administered by, or associated with, Facebook. By participating, you hereby release and hold harmless Facebook from any and all liability associated with this promotion.</p>
<div class="fb-like" data-layout="button_count" data-action="like" data-show-faces="false" data-share="false"></div>
</footer>
</body>
</html>
SO网友:TeamHal
结果表明,第二个表单需要自己的nonce,并更新了页面标题中的代码,以便在仅提交第二个表单的情况下执行某些操作。请参阅新代码:
<?php
$lucs_stored_meta = get_post_meta($post->ID);
// salt shaker, drawing straws, randomness
function lucs_random_thumbnail() {
$lucs_random_image = rand(0,1);
if ($lucs_random_image == 0) {
$lucs_thumb_ra = plugins_url(\'/img/thumb0.png\',__FILE__);
} else {
$lucs_thumb_ra = plugins_url(\'/img/thumb1.png\',__FILE__);
}
return $lucs_thumb_ra;
}
// if participant has no featured image, display the following default image included in plugin
function lucs_get_featured_image() {
if (has_post_thumbnail()) {
the_post_thumbnail(\'thumbnail\',array( \'class\' => \'showcase-thumbnail\' ));
} else {
echo \'<img src="\' . lucs_random_thumbnail() . \'" class="showcase-thumbnail" alt="Organization">\';
}
}
function lucs_add_one_vote($lucs_cid) {
//Get current bid
$myvote0 = get_post_meta($lucs_cid, \'org_votes\', true);
//Increase the bid, for example the amount here is 100?
$myvote1 = $myvote0 + 1;
//Update the database with the increased bid value
update_post_meta($lucs_cid,\'org_votes\',$myvote1,$myvote0);
lucs_redirect_to_thanks();
}
/*START OF CONTESTANT FORM*/
if (isset($_POST[\'lucs_nonce_guest\']) && wp_verify_nonce($_POST[\'lucs_nonce_guest\'],\'post_nonce\')) {
if (isset($_POST[\'password\']) && trim($_POST[\'password\']) != \'\') {
$lucs_form_details = array(
\'post_title\' => wp_strip_all_tags($_POST[\'org_contestant\']),
\'post_content\' => sanitize_text_field($_POST[\'org_reason\']),
\'post_type\' => \'lucs_contestant\',
\'post_status\' => \'trash\',
\'comment_status\' => \'closed\',
);
$lucs_if_posted = wp_insert_post($lucs_form_details);
add_post_meta($lucs_if_posted,\'org_contestant\',sanitize_text_field($_POST[\'org_contestant\']));
add_post_meta($lucs_if_posted,\'org_contact_person\',sanitize_text_field($_POST[\'org_contact_person\']));
add_post_meta($lucs_if_posted,\'org_zip\',sanitize_text_field($_POST[\'org_zip\']));
add_post_meta($lucs_if_posted,\'org_contact_phone\',sanitize_text_field($_POST[\'org_contact_phone\']));
add_post_meta($lucs_if_posted,\'org_contact_email\',sanitize_text_field($_POST[\'org_contact_email\']));
add_post_meta($lucs_if_posted,\'org_pets_rescued\',sanitize_text_field($_POST[\'org_pets_rescued\']));
lucs_redirect_to_help();
} elseif ($_POST[\'org_reason\'] == \'\' || $_POST[\'org_contact_phone\'] == \'\') {
lucs_redirect_to_lost();
} elseif (isset($_POST[\'lucsy_form\'])) {
$lucs_form_details = array(
\'post_title\' => wp_strip_all_tags($_POST[\'org_contestant\']),
\'post_content\' => \'\',
\'post_type\' => \'lucs_contestant\',
\'post_status\' => \'pending\',
\'comment_status\' => \'closed\',
);
$lucs_if_posted = wp_insert_post($lucs_form_details);
add_post_meta($lucs_if_posted,\'org_contestant\',sanitize_text_field($_POST[\'org_contestant\']));
add_post_meta($lucs_if_posted,\'org_contact_person\',sanitize_text_field($_POST[\'org_contact_person\']));
add_post_meta($lucs_if_posted,\'org_zip\',sanitize_text_field($_POST[\'org_zip\']));
add_post_meta($lucs_if_posted,\'org_contact_phone\',sanitize_text_field($_POST[\'org_contact_phone\']));
add_post_meta($lucs_if_posted,\'org_contact_email\',sanitize_text_field($_POST[\'org_contact_email\']));
add_post_meta($lucs_if_posted,\'org_pets_rescued\',sanitize_text_field($_POST[\'org_pets_rescued\']));
add_post_meta($lucs_if_posted,\'org_reason\',sanitize_text_field($_POST[\'org_reason\']));
add_post_meta($lucs_if_posted,\'org_participation\',sanitize_text_field($_POST[\'org_participation\']));
add_post_meta($lucs_if_posted,\'org_votes\',sanitize_text_field($_POST[\'org_votes\']));
lucs_redirect_to_thanks();
}
}
if (isset($_POST[\'lucs_grabbing_id\']) && isset($_POST[\'lucs_nonce_voter\']) && wp_verify_nonce($_POST[\'lucs_nonce_voter\'],\'post_nonce\')) {
$lucs_myid = isset($_POST[\'lucs_grabbing_id\']);
lucs_add_one_vote(151);
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title><?php echo get_the_title(); ?></title>
<meta name="description" content="<?php if (!empty($lucs_stored_meta[\'contest_results\'][0]) && $lucs_stored_meta[\'contest_status\'][0] == \'Over\') { echo $lucs_stored_meta[\'contest_results\'][0]; } ?>">
<meta name="author" content="<?php echo get_the_modified_author(); ?>">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=1">
<link rel="stylesheet" href="<?php
switch ($lucs_stored_meta[\'contest_theme\'][0]) {
case "Plain": echo esc_url(plugins_url(\'css/contest-plain/contest-plain.css\', __FILE__)); break;
case "Green Eggs": echo esc_url(plugins_url(\'css/contest-green/contest-green-eggs.css\', __FILE__)); break;
case "Modern": echo esc_url(plugins_url(\'css/contest-modern/contest-modern.css\', __FILE__)); break;
}
?>">
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<header class="contest-header">
<div class="contest-logo">
<img alt="Contest hosted by SaveaRescue.org" src="<?php echo esc_url(plugins_url(\'img/save-a-rescue-logo.png\', __FILE__)); ?>">
</div>
<div class="sarfb">
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.5";
fjs.parentNode.insertBefore(js, fjs);
}(document, \'script\', \'facebook-jssdk\'));</script>
<div class="fb-like" data-href="https://www.facebook.com/savearescue" data-width="250" data-layout="standard" data-action="like" data-show-faces="true" data-share="false"></div>
</div>
<div style="text-align:left;background-color: white; height:0px;border-bottom-color:rgb(204, 204, 204);border-width: medium medium 1px; border-style: none none solid; ">
</div>
<div style="text-align:left;background-color: white; border-top-color:rgb(229, 229, 229);padding-bottom:1px;border-width: 4px medium medium; border-style: solid none none; "></div>
</header>
<div id="contest-status">
<p>This contest is <?php echo strtolower(sanitize_text_field($lucs_stored_meta[\'contest_status\'][0])) ?>! <span class="light-end-date">End Date: <?php echo sanitize_text_field($lucs_stored_meta[\'contest_end_date\'][0]) ?></span></p>
</div>
<div class="featured-image-container">
<img alt="Contest brought to you by SaveaRescue.org" src="<?php if (has_post_thumbnail()) { echo wp_get_attachment_url(get_post_thumbnail_id()); } else { echo sanitize_text_field(plugins_url( \'/img/default-featured-image.jpg\', __FILE__ )); } ?>" class="featured-image">
</div>
<div class="contest-share-container">
<div class="contest-share-instruction">E-mail this contest to your friends and followers or Share!</div>
<div class="contest-share-button">
<a href="mailto:?body=%0D%0A%0D%0AStumbled upon this and thought you might be interested: %0D%0A%0D%0A<?php echo esc_url(get_permalink( $post->ID )); ?>&subject=Check Out This Contest" target="_blank" title="Email"><img src="<?php echo esc_url(plugins_url(\'css/contest-plain/img/email.png\', __FILE__)); ?>"> E-mail </a>
</div>
<div class="contest-share-button">
<a href="http://www.facebook.com/sharer.php?u=<?php esc_url(get_permalink( $post->ID ));?>&t=<?php the_title(); ?>" title="Share on Facebook"><img src="<?php echo esc_url(plugins_url(\'css/contest-plain/img/facebook_16.png\', __FILE__)); ?>"> Facebook </a>
</div>
<div class="contest-share-button">
<a href="javascript:window.location=%22https://twitter.com/share?url=%22+encodeURIComponent(document.location)+%22&text=%22+encodeURIComponent(document.title)" title="Tweet"><img src="<?php echo esc_url(plugins_url(\'css/contest-plain/img/twitter_16.png\', __FILE__)); ?>"> Twitter </a>
</div>
<div class="contest-share-button">
<a href="https://plusone.google.com/_/+1/confirm?hl=en&url=<?php esc_url(get_permalink( $post->ID )); ?>" target="_blank" title="Plus one this page on Google"><img src="<?php echo esc_url(plugins_url(\'css/contest-plain/img/plus_16.png\', __FILE__)); ?>"> Google+ </a>
</div>
<div class="contest-share-button">
<a href="//pinterest.com/pin/create/link/?url=<?php esc_url(get_permalink( $post->ID ))?>&description=<?php the_title();?>" title="Pin it"><img src="<?php echo esc_url(plugins_url(\'css/contest-plain/img/pinterest_16.png\', __FILE__)); ?>"> Pinterest </a>
</div>
<div class="contest-share-button">
<a href="http://www.linkedin.com/shareArticle?mini=true&url=<?php esc_url(get_permalink( $post->ID )) ?>" target="_blank"><img src="<?php echo esc_url(plugins_url(\'css/contest-plain/img/in_16.png\', __FILE__)); ?>"> Linked in </a>
</div>
</div>
<div class="lucs-frontform-title">WIN 5,000 Meals For Your Rescue</div>
<div class="lucs-frontform">
<form action="" id="lucs-contestant-registration" method="POST">
<fieldset>
<div class="lucs-label">
<label for="org-contestant"><b>Rescue</b> Organization Name</label>
</div>
<div class="lucs-detail-input">
<input type="text" name="org_contestant" id="org-contestant" />
</div>
</fieldset>
<fieldset>
<div class="lucs-label">
<label for="org-contact-person">Contact Person [Name]</label>
</div>
<div class="lucs-detail-input">
<input type="text" name="org_contact_person" id="org-contact-person" />
</div>
</fieldset>
<fieldset>
<div class="lucs-label">
<label for="org-zip">Zip Code</label>
</div>
<div class="lucs-detail-input">
<input type="text" maxlength="5" name="org_zip" id="org-zip" />
</div>
</fieldset>
<fieldset>
<div class="lucs-label"><label>Preferred Contact Method</label></div>
<div class="lucs-label">
<label for="org-contact-phone">Phone</label>
</div>
<div class="lucs-detail-input">
<input type="text" name="org_contact_phone" id="org-contact-phone" />
</div>
<div class="lucs-label">
<label for="org-contestant">E-mail</label>
</div>
<div class="lucs-detail-input">
<input type="text" name="org_contact_email" id="org-contact-email" />
</div>
</fieldset>
<fieldset>
<div class="lucs-label"><label for="org-pets-rescued">Number of Dogs/Cats this Rescue Organization has Saved This Year</label></div>
<div class="lucs-detail-input">
<input type="text" maxlength="5" name="org_pets_rescued" id="org-pets-rescued" />
</div>
</fieldset>
<fieldset>
<div class="lucs-label"><label for="org-reason">Tell Us in 100-500 Words or Less Why You Could Use these 5,000 Meals.</label></div>
<textarea name="org_reason" id="org-reason" rows="4"></textarea>
</fieldset>
<fieldset>
<div class="lucs-detail-input">
<input type="hidden" maxlength="5" name="org_participation" id="org-participation" value="<?php echo the_ID(); ?>" />
</div>
</fieldset>
<fieldset>
<div class="lucs-detail-input">
<input type="hidden" maxlength="5" name="org_votes" id="org-votes" value="0" />
</div>
</fieldset>
<?php //the password is an anti-spam measure ?>
<input type="text" name="password" id="password" autofill="off" style="display:none !important;" />
<?php wp_nonce_field(\'post_nonce\',\'lucs_nonce_guest\'); ?>
<button name="lucsy_form" type="submit">Submit</button>
</form>
</div>
<div class="tab-container">
<a href="#" class="tab-left">A-C</a>
<a href="#" class="tab-left">D-F</a>
<a href="#" class="tab-left">G-I</a>
<a href="#" class="tab-left">J-L</a>
<a href="#" class="tab-left">M-O</a>
<a href="#" class="tab-left">P-R</a>
<a href="#" class="tab-left">S-U</a>
<a href="#" class="tab-left">V-Z</a>
</div>
<div class="showcase-container">
<?php
// WP_Query arguments
$lucs_current_contest_id = get_the_id();
$args = array (
\'post_type\' => array( \'lucs_contestant\' ),
\'post_status\' => array( \'publish\' ),
\'pagination\' => true,
\'posts_per_page\' => \'40\',
\'ignore_sticky_posts\' => false,
\'order\' => \'DESC\',
\'orderby\' => \'date\',
\'meta_query\' => array(
array(
\'key\' => \'org_participation\',
\'value\' => $lucs_current_contest_id,
\'compare\' => \'=\',
\'type\' => \'NUMERIC\',
),
),
\'cache_results\' => true,
\'update_post_meta_cache\' => true,
);
// The Query
$lucs_query_participants = new WP_Query( $args );
// The Loop
if ( $lucs_query_participants->have_posts() ) {
while ( $lucs_query_participants->have_posts() ) {
$lucs_query_participants->the_post();
// do something
$lucs_single_contestant_meta = get_post_meta($post->ID);
?>
<div class="showcase-individual">
<div class="showcase-thumbnail-container">
<a href="<?php echo esc_url(get_permalink($post->ID)); ?>" title="<?php echo get_the_title($post->ID); ?>">
<?php lucs_get_featured_image(); ?>
</a>
</div>
<div class="showcase-title">
<a href="<?php echo esc_url(get_permalink($post->ID)); ?>" title="<?php echo get_the_title($post->ID); ?>"><?php echo the_title(); ?></a>
</div>
<div class="showcase-intro">
<p><?php if (!empty($lucs_single_contestant_meta[\'org_reason\'])) echo esc_html(wp_trim_words($lucs_single_contestant_meta[\'org_reason\'][0],40,\'...\')) . \'<a href="\'. esc_url(get_permalink($post->ID)) .\'"> Read More </a>\'; ?></p>
</div>
<div class="showcase-counter">
<form action="" method="post">
<?php wp_nonce_field(\'post_nonce\',\'lucs_nonce_voter\'); ?>
<button type="submit" name="lucs_grabbing_id" value="<?php echo $post->ID ?>">Vote</button>
</form>
</div>
</div>
<?php
}
} else {
echo \'COMING SOON\';
}
// Restore original Post Data
wp_reset_postdata();
?>
</div> <!-- END OF class="showcase-container" -->
<footer class="contest-footer">
<div class="lucs-divider"></div>
<?php if ($lucs_stored_meta[\'contest_sponsor_visibility\'][0] == \'Yes\') { ?>
<div class="sponsor-notice-box">
<div class="sponsor-notice-title">
<div class="sponsor-notice-text"><b>Brought to you by </b><?php echo esc_html($lucs_stored_meta[\'contest_sponsor\'][0]) ?>
</div>
</div>
</div>
<?php
} else {
echo \'\';
}
?>
<p>By participating in this promotion you agree to the Official Rules.</p>
<p>This page is powered by <a href="http://">LUCS</a>. LUCS does not endorse, sponsor, or administer this.</p>
<p>This promotion is in no way sponsored, endorsed or administered by, or associated with, Facebook. By participating, you hereby release and hold harmless Facebook from any and all liability associated with this promotion.</p>
<div class="fb-like" data-layout="button_count" data-action="like" data-show-faces="false" data-share="false"></div>
</footer>
</html>
</body>