static function render_page() { if (isset($_POST['opinionstage_aptap']) && is_array($_POST['opinionstage_aptap'])) { $opinionstage_aptap = $_POST['opinionstage_aptap']; update_option('opinionstage_aptap', $opinionstage_aptap); ?> <div class="updated"><p><strong>Options saved.</strong></p></div><?php } opinionstage_add_stylesheet(); $post_types = get_post_types(array('public' => true)); function os_get_option($options, $option_name) { if (is_array($options)) { return isset($options[$option_name]) && !empty($options[$option_name]) ? $options[$option_name] : ''; } return ''; } $opinionstage_aptap = get_option('opinionstage_aptap'); ?> <div class="opinionstage-wrap"> <div id="opinionstage-head"></div> <div class="section"> <form action="" method="POST" <h2>Add Polls to all articles</h2> <hr /> <h3>Where to add:</h3> <div class="chkboxs" style="background-color: #FFF; border: 1px solid #DDD; padding: 5px 20px 5px 10px; display: inline-block;"> <?php foreach ($post_types as $pt) { ?> <?php if ($pt == 'attachment') { continue; } $is_checked = false; if (is_array(os_get_option($opinionstage_aptap, 'post_types'))) { $post_types = os_get_option($opinionstage_aptap, 'post_types'); if (in_array($pt, $post_types)) { $is_checked = true; } } ?> <label for="pt-<?php _e($pt); ?> "><input type="checkbox" name="opinionstage_aptap[post_types][]" value="<?php _e($pt); ?> " id="pt-<?php _e($pt); ?> " <?php _e($is_checked ? 'checked="checked"' : ''); ?> /> <?php _e($pt); ?> </label><br /> <?php } ?> </div> <br /> <h3><label for="pt-ct">What to add:</label></h3> <select name="opinionstage_aptap[content_types]" id="pt-ct"> <option value="poll" <?php _e(os_get_option($opinionstage_aptap, 'content_types') == 'poll' ? 'selected="selected"' : ''); ?> >Poll</option> <option value="set" <?php _e(os_get_option($opinionstage_aptap, 'content_types') == 'set' ? 'selected="selected"' : ''); ?> >Set</option> </select> <br /> <h3><label for="pt-cnfid">Configure ID</label></h3> <input type="text" value="<?php _e(os_get_option($opinionstage_aptap, 'configure_id')); ?> " name="opinionstage_aptap[configure_id]" id="pt-cnfid" /> <div><a href="#" id="pt-locid" target="_blank">Locate ID in Dashboard</a></div> <br /> <p class="submit"><input type="submit" class="button button-primary" value="Save Changes"></p> <br /> <div style="background-color: #FFF; border: 1px solid #DDD; padding: 5px 20px 5px 10px; display: inline-block; max-width: 300px;">Note: If you would like to add a poll/set to only one post/page, click on the Opinion Stage icon from the create post/page visual editor.</div> <br /> <p>Need more help? <a href="http://blog.opinionstage.com/wordpress-poll-how-to-add-polls-to-wordpress-sites/">Click here!</a></p> </form> </div> </div> <script type="text/javascript"> jQuery(function ($) { $("#toplevel_page_social-polls-by-opinionstage-opinionstage-polls").addClass("current").find(" > a").addClass("current"); $("#pt-ct").on("change", function () { var $this = $(this), v = $this.val(), $locid = $("#pt-locid"); var rootURL = "http://www.opinionstage.com/dashboard?o=wp35e8"; if (v == "set") rootURL += "&tab=sets"; $locid.attr("href", rootURL); }).trigger("change"); }); </script> <?php }
/** * Instructions page for adding a poll */ function opinionstage_add_poll_page() { opinionstage_add_stylesheet(); ?> <div class="opinionstage-wrap"> <div id="opinionstage-head"></div> <div class="section"> <h2>Actions</h2> <ul class="os_links_list"> <li><?php echo opinionstage_create_link('Create a Poll', 'new_poll', ''); ?> </li> <li><?php echo opinionstage_create_link('View Polls', 'dashboard', ''); ?> </li> <li><?php echo opinionstage_create_link('Create a Set', 'sets/new', ''); ?> </li> <li><?php echo opinionstage_create_link('View Sets', 'dashboard', 'tab=sets'); ?> </li> <li><?php echo opinionstage_create_link('View Placements', 'dashboard', 'tab=containers'); ?> </li> <li><a href="<?php _e(admin_url('admin.php?page=addpollstoallposts')); ?> ">Add Polls to all articles</a></li> </ul> <h2>Help</h2> <ul class="os_links_list"> <li><a href="http://blog.opinionstage.com/wordpress-poll-how-to-add-polls-to-wordpress-sites/?o=wp35e8" target="_blank">Help</a></li> <li><?php echo opinionstage_create_link('View Examples', 'showcase', ''); ?> </li> <li><a href="https://opinionstage.zendesk.com/anonymous_requests/new" target="_blank">Contact Us</a></li> </ul> </div> </div> <?php }