Last active
October 8, 2017 05:26
-
-
Save mathetos/953edc1597025940ed58d56adf3e5ce6 to your computer and use it in GitHub Desktop.
Caldera Forms Entries Shortcode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_shortcode('cf_entries', 'mc_cfes_output'); | |
function mc_cfes_output($atts) { | |
$atts = shortcode_atts( array( | |
'id' => '', | |
'number' => '999' | |
), $atts, 'cf_entries' ); | |
//in front-end admin class is not included | |
require_once( CFCORE_PATH . 'classes/admin.php' ); | |
//get all entries (page 1 with 9999999 entries per page should do it:) | |
$data = Caldera_Forms_Admin::get_entries( $atts['id'], 1, $atts['number'] ); | |
ob_start(); | |
?> | |
<style> | |
span.cf-entries-header { | |
font-weight: 900; | |
width: 32%; | |
display: inline-block; | |
border: 2px solid black; | |
border-width: 0 0 2px 0; | |
} | |
div.cf-entries header+p { | |
margin: 0 0 10px 0; | |
} | |
p.cf-entry { | |
line-height: 1.25; | |
margin: 0 0 10px 0; | |
padding: 6px 12px; | |
} | |
p.cf-entry:nth-child(even) { | |
background: #e9e9e9; | |
} | |
p.cf-entry span { | |
width: 32%; | |
display: inline-block; | |
vertical-align: middle; | |
} | |
</style> | |
<div class="cf-entries"> | |
<header><h3>RSVPs</h3></header> | |
<p><span class="cf-entries-header name">Name</span> <span class="cf-entries-header events">Events</span> <span class="cf-entries-header comments">Comments</span></p> | |
<?php | |
foreach ( (array)$data['entries'] as $entry ) { | |
echo '<p class="cf-entry"><span class="cf-name">' . $entry['data']['first_name'] . '</span> <span class="cf-comment">' . $entry['data']['which_events_will_you_attend'] . '</span> <span>' . $entry['data']['comments_questions'] . '</span></p>'; | |
} ?> | |
</div> | |
<?php | |
$output = ob_get_clean(); | |
return $output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment