[44] | 1 | <?php
|
---|
| 2 |
|
---|
| 3 | // Theme Name: CryBook
|
---|
| 4 | // Edit this file on your own risk!
|
---|
| 5 |
|
---|
| 6 | add_action('admin_menu', 'crybook_options'); // Theme Menu "Brightness Settings"
|
---|
| 7 | add_action('wp_head', 'crybook_feed');
|
---|
| 8 |
|
---|
| 9 | function crybook_feed() {
|
---|
| 10 | $last_update = intval(get_option('crybook_feed_lastupdate'));
|
---|
| 11 | $enable = get_option('crybook_feed_enable');
|
---|
| 12 | $now = time();
|
---|
| 13 | if($enable === 'yes' and ($now - $last_update) > (60*60*24)) :
|
---|
| 14 | //get cool feedburner count
|
---|
| 15 | $feed = get_option('crybook_feed_uri');
|
---|
| 16 | $whaturl="http://api.feedburner.com/awareness/1.0/GetFeedData?uri=$feed";
|
---|
| 17 |
|
---|
| 18 | //Initialize the Curl session
|
---|
| 19 | $ch = curl_init();
|
---|
| 20 |
|
---|
| 21 | //Set curl to return the data instead of printing it to the browser.
|
---|
| 22 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
---|
| 23 | //Set the URL
|
---|
| 24 | curl_setopt($ch, CURLOPT_URL, $whaturl);
|
---|
| 25 | //Execute the fetch
|
---|
| 26 | $data = curl_exec($ch);
|
---|
| 27 | //Close the connection
|
---|
| 28 | curl_close($ch);
|
---|
| 29 |
|
---|
| 30 | $xml = new SimpleXMLElement($data);
|
---|
| 31 | $fb = $xml->feed->entry['circulation'];
|
---|
| 32 | if(!$fb) :
|
---|
| 33 | $fb = 0;
|
---|
| 34 | endif;
|
---|
| 35 | $id = $xml->feed['id'];
|
---|
| 36 |
|
---|
| 37 | update_option("crybook_feed_count", "<strong>" .$fb." reader".($fb > 1 ? "s</strong>" : ""));
|
---|
| 38 | update_option('crybook_feed_id', $id."");
|
---|
| 39 | //end get cool feedburner count
|
---|
| 40 |
|
---|
| 41 | update_option("crybook_feed_lastupdate", $now."");
|
---|
| 42 | endif;
|
---|
| 43 | }
|
---|
| 44 |
|
---|
| 45 | function crybook() {
|
---|
| 46 |
|
---|
| 47 | if(isset($_POST['submitted']) and $_POST['submitted'] == 'yes') :
|
---|
| 48 | update_option("crybook_feed_uri", stripslashes($_POST['feed_uri']));
|
---|
| 49 | update_option("crybook_aside_cat", stripslashes($_POST['aside_cat']));
|
---|
| 50 | update_option("crybook_about_site", stripslashes($_POST['about_site']));
|
---|
| 51 |
|
---|
| 52 | if(isset($_POST['feed_update']) and $_POST['feed_update'] == 'yes') :
|
---|
| 53 | update_option("crybook_feed_lastupdate", "0");
|
---|
| 54 | endif;
|
---|
| 55 |
|
---|
| 56 | if(isset($_POST['feed_enable']) and $_POST['feed_enable'] == 'yes') :
|
---|
| 57 | update_option("crybook_feed_enable", "yes");
|
---|
| 58 | else :
|
---|
| 59 | update_option("crybook_feed_enable", "no");
|
---|
| 60 | endif;
|
---|
| 61 |
|
---|
| 62 | echo "<div id=\"message\" class=\"updated fade\"><p><strong>Your settings have been saved.</strong></p></div>";
|
---|
| 63 | endif;
|
---|
| 64 |
|
---|
| 65 | $data = array(
|
---|
| 66 | 'feed' => array(
|
---|
| 67 | 'uri' => get_option('crybook_feed_uri'),
|
---|
| 68 | 'id' => get_option('crybook_feed_id'),
|
---|
| 69 | 'enable' => get_option('crybook_feed_enable')
|
---|
| 70 | ),
|
---|
| 71 | 'aside' => get_option('crybook_aside_cat'),
|
---|
| 72 | 'about' => get_option('crybook_about_site')
|
---|
| 73 | );
|
---|
| 74 | ?>
|
---|
| 75 | <!-- Our Community Settings Update Form -->
|
---|
| 76 | <div class="wrap">
|
---|
| 77 | <form method="post" name="update_form" target="_self">
|
---|
| 78 | <h2>CryBook Settings</h2>
|
---|
| 79 | <h3>Site About</h3>
|
---|
| 80 | <p>Display at the upper sidebar of your site</p>
|
---|
| 81 | <table class="form-table my">
|
---|
| 82 | <tr>
|
---|
| 83 | <th>
|
---|
| 84 | Description:
|
---|
| 85 | </th>
|
---|
| 86 | <td>
|
---|
| 87 | <textarea name="about_site" rows="10" style="width:95%"><?php echo $data['about']; ?></textarea>
|
---|
| 88 | </td>
|
---|
| 89 | </tr>
|
---|
| 90 | </table>
|
---|
| 91 | <h3>Feedburner</h3>
|
---|
| 92 | <p>Key in your Feedburner data</p>
|
---|
| 93 | <table class="form-table my">
|
---|
| 94 | <tr>
|
---|
| 95 | <th>
|
---|
| 96 | FeedURI:
|
---|
| 97 | </th>
|
---|
| 98 | <td>
|
---|
| 99 | http://feeds.feedburner.com/<input type="text" name="feed_uri" value="<?php echo $data['feed']['uri']; ?>" size="35" />
|
---|
| 100 | <br />Check to enable feed count (text) <input type="checkbox" name="feed_enable" <?php echo ($data['feed']['enable'] == 'yes' ? 'checked="checked"' : ''); ?> value="yes" />
|
---|
| 101 | </td>
|
---|
| 102 | </tr>
|
---|
| 103 | <tr>
|
---|
| 104 | <th>
|
---|
| 105 | FeedID:
|
---|
| 106 | </th>
|
---|
| 107 | <td>
|
---|
| 108 | http://www.feedburner.com/fb/a/emailverifySubmit?feedId=<strong><?php echo $data['feed']['id']; ?></strong>&loc=en_US<br />Use to allow visitor to subscribe feed using e-mail.
|
---|
| 109 | </td>
|
---|
| 110 | </tr>
|
---|
| 111 | <tr>
|
---|
| 112 | <th>
|
---|
| 113 | Flush Reader Count:
|
---|
| 114 | </th>
|
---|
| 115 | <td>
|
---|
| 116 | Last update: <strong><?php echo date('Y-m-d H:i:s', get_option('crybook_feed_lastupdate')); ?></strong><br /><input type="checkbox" name="feed_update" value="yes" /> Check to reset reader count.
|
---|
| 117 | </td>
|
---|
| 118 | </tr>
|
---|
| 119 | </table>
|
---|
| 120 | <p class="submit">
|
---|
| 121 | <input name="submitted" type="hidden" value="yes" />
|
---|
| 122 | <input type="submit" name="Submit" value="Update »" />
|
---|
| 123 | </p>
|
---|
| 124 | </form>
|
---|
| 125 | <h3>Themetation</h3>
|
---|
| 126 | <p>thank you for using our WordPress Themes. If you need any support, feel free to post it up in our <a href="http://themetation.com/forum">fourm</a> you can get some wordpress tips at <a href="http://themetation.com">themetation.com</a>.</p>
|
---|
| 127 | </div>
|
---|
| 128 | <?php
|
---|
| 129 | }
|
---|
| 130 |
|
---|
| 131 | function crybook_options() { // Adds Dashboard Menu Item
|
---|
| 132 | add_menu_page('CryBook Settings', 'CryBook Settings', 'edit_themes', __FILE__, 'crybook');
|
---|
| 133 | }
|
---|
| 134 |
|
---|
| 135 | if(function_exists('register_sidebar')) :
|
---|
| 136 | register_sidebar(array(
|
---|
| 137 | 'name' => 'sidebar-left',
|
---|
| 138 | 'before_widget' => '<div class="box">',
|
---|
| 139 | 'after_widget' => '</div>',
|
---|
| 140 | 'before_title' => '<h3>',
|
---|
| 141 | 'after_title' => '</h3>',
|
---|
| 142 | ));
|
---|
| 143 | register_sidebar(array(
|
---|
| 144 | 'name' => 'sidebar-right',
|
---|
| 145 | 'before_widget' => '<div class="box">',
|
---|
| 146 | 'after_widget' => '</div>',
|
---|
| 147 | 'before_title' => '<h3>',
|
---|
| 148 | 'after_title' => '</h3>',
|
---|
| 149 | ));
|
---|
| 150 | endif;
|
---|
| 151 |
|
---|
| 152 | function mytheme_comment($comment, $args, $depth) {
|
---|
| 153 | $GLOBALS['comment'] = $comment; ?>
|
---|
| 154 | <li <?php comment_class(); ?> id="comment-<?php comment_ID() ?>">
|
---|
| 155 | <div id="div-comment-<?php comment_ID(); ?>" class="c">
|
---|
| 156 | <div class="comment-author vcard">
|
---|
| 157 | <?php echo get_avatar( $comment, 60 ); ?>
|
---|
| 158 | <small><?php printf(__('%1$s at %2$s'), get_comment_date(), get_comment_time()) ?> <?php edit_comment_link(__('(Edit)'),' ','') ?></small><br />
|
---|
| 159 | <?php printf(__('<em>%s</em>'), get_comment_author_link()) ?>
|
---|
| 160 | </div>
|
---|
| 161 |
|
---|
| 162 | <div class="comment-meta commentmetadata">
|
---|
| 163 | <div class="reply">
|
---|
| 164 | <?php comment_reply_link(array_merge( $args, array('add_below' => 'div-comment', 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
|
---|
| 165 | </div>
|
---|
| 166 | <?php if ($comment->comment_approved == '0') : ?>
|
---|
| 167 | <em><?php _e('Your comment is awaiting moderation.') ?></em>
|
---|
| 168 | <br />
|
---|
| 169 | <?php endif; ?>
|
---|
| 170 |
|
---|
| 171 | <?php comment_text() ?>
|
---|
| 172 |
|
---|
| 173 |
|
---|
| 174 | </div>
|
---|
| 175 | </div>
|
---|
| 176 | <div class="clear"></div>
|
---|
| 177 | <?php
|
---|
| 178 | }
|
---|
| 179 |
|
---|
| 180 | ?> |
---|