function the_detail_box($post = 0) { $post = get_post($post); $bg = has_featured_image() ? get_the_post_thumbnail($post->ID, 'full') : '<div class="background"></div>'; $details = get_the_details(); if (has_details()) { ?> <div id="details"> <?php echo $bg; ?> <h2>Overview</h2> <table> <?php foreach (get_the_details() as $key => $val) { ?> <tr> <td><?php echo strpretty($key); ?> </td> <td><hr></td> <td><?php echo $val; ?> </td> </tr> <?php } ?> </table> </div> <?php } }
function review_settings() { $posted = false; $details = get_option('lg_detail_list'); if (isset($_POST['detail_list'])) { $detailspost = isset($_POST['detail_list']) ? (array) $_POST['detail_list'] : array(); $detailspost = array_filter($detailspost); if ($detailspost != $details) { update_option('lg_detail_list', $detailspost); $posted = true; } else { $posted = 'nochange'; } } $review = get_option('lg_review_options'); if (isset($_POST['review'])) { $reviewpost = isset($_POST['review']) ? (array) $_POST['review'] : array(); $reviewpost['criteria'] = array_filter($reviewpost['criteria']); $labelarr = array(); foreach ($reviewpost['labels'] as $arr) { if (isset($arr['key'])) { $labelarr[$arr['key']] = $arr['value']; } } $reviewpost['labels'] = array_filter($labelarr); if ($reviewpost != $review) { update_option('lg_review_options', array_filter($reviewpost)); $posted = true; } elseif ($posted !== true) { $posted = 'nochange'; } } if ($posted === true) { echo '<div id="message" class="updated">Review settings saved</div>'; } elseif ($posted === 'nochange') { echo '<div id="message" class="update-nag">Nothing was changed</div>'; } ?> <form method="POST" action=""> <?php wp_nonce_field('save-review-options', 'nonce_review_options'); ?> <div id="poststuff"> <div class="stuffbox-container"> <div class="meta-box"> <div class="stuffbox"> <h3 class="hndle">Details</h3> <div class="inside"> <div class="lg-field"> <?php $details = $details ? $details : array(''); foreach ($details as $key => $detail) { ?> <div class="slot"> <span title="Drag to sort" class="handle dashicons-before dashicons-sort" style="display: none; cursor: move;"></span> <input type="text" style="width: 50%;" name="detail_list[<?php echo $key; ?> ]" id="detail-list<?php idnum($key); ?> " placeholder="Enter New Detail" value="<?php echo if_value($detail); ?> "> <a href="#" class="button remove" style="display: none;">-</a> </div> <?php } ?> <a href="#" class="button-primary add">+</a> </div> </div> </div> <div class="stuffbox"> <h3 class="hndle">Review Settings</h3> <div class="inside"> <div class="lg-field"> <?php $criteria = $review['criteria'] ? $review['criteria'] : array(''); foreach ($criteria as $key => $criterion) { ?> <div class="slot"> <span title="Drag to sort" class="handle dashicons-before dashicons-sort" style="display: none; cursor: move;"></span> <input type="text" style="width: 50%;" name="review[criteria][<?php echo $key; ?> ]" id="review-criterion<?php idnum($key); ?> " placeholder="Enter New Criterion" value="<?php echo if_value($criterion); ?> "> <a href="#" class="button remove" style="display: none;">-</a> </div> <?php } ?> <a href="#" class="button-primary add">+</a> </div> </div> </div> <div class="stuffbox"> <h3 class="hndle">Review Labels</h3> <div class="inside"> <div class="lg-field"> <?php $labels = $review['labels'] ? $review['labels'] : array(''); $i = 0; foreach ($labels as $key => $label) { ?> <div class="slot"> <span title="Drag to sort" class="handle dashicons-before dashicons-sort" style="display: none; cursor: move;"></span> <select name="review[labels][<?php echo $i; ?> ][key]"> <option disabled selected>Select Criterion</option> <?php foreach (array('positives', 'negatives', 'bottom_line') as $value) { ?> <option value="<?php echo $value; ?> " <?php if ($key === $value) { echo 'selected'; } ?> ><?php echo strpretty($value); ?> </option> <?php } ?> </select> <input type="text" style="width: 50%;" name="review[labels][<?php echo $i; ?> ][value]" id="review-labels<?php idnum($key); ?> " placeholder="Enter New Label" value="<?php echo if_value($label); ?> "> <a href="#" class="button remove" style="display: none;">-</a> </div> <?php $i++; } ?> <a href="#" class="button-primary add">+</a> </div> </div> </div> </div> </div> </div> <p> <input type="submit" value="Save Settings" class="button-primary"/> </p> </form> <?php }