Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2012
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.68 KB | None | 0 0
  1. <?php
  2.  
  3. // Remove admin bar if selected from the options menu
  4. $opt = get_option('lifestyle');
  5. if ( $opt['hide_admin'] == 1 ) {
  6. add_action( 'show_admin_bar', '__return_false' );
  7. }
  8.  
  9. // Set the maximum image width to avoid over floating
  10. if ( ! isset( $content_width ) )
  11. $content_width = 590;
  12.  
  13. // Add favicon and scripts to the theme head section
  14. function favicon_link() { $opt = get_option('lifestyle');
  15. $themedir = get_bloginfo('stylesheet_directory');
  16. echo '<link rel="shortcut icon" type="image/x-icon" href="' . $themedir . '/images/favicon.ico" />' . "\n";
  17. echo '<script type="text/javascript"><!--//--><![CDATA[//><!--
  18. sfHover = function() {
  19. if (!document.getElementsByTagName) return false;
  20. var sfEls = document.getElementsByTagName("menu").getElementsByTagName("li");
  21.  
  22. for (var i=0; i<sfEls.length; i++) {
  23. sfEls[i].onmouseover=function() {
  24. this.className+=" sfhover";
  25. }
  26. sfEls[i].onmouseout=function() {
  27. this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
  28. }
  29. }
  30. }
  31. if (window.attachEvent) window.attachEvent("onload", sfHover);
  32. //--><!]]></script>' . "\n";
  33. if ( $opt['hide_st_top'] == 1 ) {
  34. echo '<style type="text/css">.sticky .entry-meta {display:none;}</style>';
  35. }
  36. if ( $opt['hide_st_btm'] == 1 ) {
  37. echo '<style type="text/css">.sticky .entry-utility {display:none;}</style>';
  38. }
  39. }
  40. add_action('wp_head', 'favicon_link');
  41.  
  42. // Add custom header to child theme
  43. function lifestyle_header(){
  44. $themedir = get_bloginfo('stylesheet_directory');
  45.  
  46. define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyten_header_image_width', 1000 ) );
  47. define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height', 268 ) );
  48. define( 'HEADER_IMAGE', $themedir . '/images/header.png' );
  49.  
  50. register_default_headers( array (
  51. 'lights' => array (
  52. 'url' => "$themedir/images/header.png",
  53. 'thumbnail_url' => "$themedir/images/header-thumb.png",
  54. 'description' => __( 'lifestyle Header', 'twentyten' )
  55. ),
  56. ));
  57.  
  58. }
  59. add_action( 'after_setup_theme', 'lifestyle_header' );
  60.  
  61. // Remove the default header images
  62. function lifestyle_remove_twenty_ten_headers(){
  63. unregister_default_headers( array(
  64. 'berries',
  65. 'cherryblossom',
  66. 'concave',
  67. 'fern',
  68. 'forestfloor',
  69. 'inkwell',
  70. 'path',
  71. 'sunset')
  72. );
  73. }
  74. add_action( 'after_setup_theme', 'lifestyle_remove_twenty_ten_headers', 11 );
  75.  
  76. // Child theme default translations
  77. class lifestyle_translations {
  78. function site_generator($translation, $text, $domain) {
  79. $translations = &get_translations_for_domain( $domain );
  80. if ( $text == 'Proudly powered by %s.' ) {
  81. return $translations->translate( 'Powered by %s</a> &middot; a <span id="wpshed-link"><a href="http://wpshed.com" title="wordpress how to">WPshed</a> design</span>' );
  82. }
  83. return $translation;
  84. }
  85. function comments_closed($translation, $text, $domain) {
  86. $translations = &get_translations_for_domain( $domain );
  87. if ( $text == 'Comments are closed.' ) {
  88. return $translations->translate( '' );
  89. }
  90. return $translation;
  91. }
  92. function leave_reply($translation, $text, $domain) {
  93. $translations = &get_translations_for_domain( $domain );
  94. if ( $text == 'Leave a Reply' ) {
  95. return $translations->translate( 'Speak Your Mind' );
  96. }
  97. return $translation;
  98. }
  99. function filed_under($translation, $text, $domain) {
  100. $translations = &get_translations_for_domain( $domain );
  101. if ( $text == 'This entry was posted in %1$s and tagged %2$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.' ) {
  102. return $translations->translate( 'Filed under: %1$s Tagged with: %2$s. - <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.' );
  103. }
  104. return $translation;
  105. }
  106. function filed_under_no_tag($translation, $text, $domain) {
  107. $translations = &get_translations_for_domain( $domain );
  108. if ( $text == 'This entry was posted in %1$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.' ) {
  109. return $translations->translate( 'Filed under: %1$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.' );
  110. }
  111. return $translation;
  112. }
  113.  
  114. }
  115. add_filter('gettext', array('lifestyle_translations', 'site_generator'), 10, 4);
  116. add_filter('gettext', array('lifestyle_translations', 'comments_closed'), 10, 4);
  117. add_filter('gettext', array('lifestyle_translations', 'leave_reply'), 10, 4);
  118. add_filter('gettext', array('lifestyle_translations', 'filed_under'), 10, 4);
  119. add_filter('gettext', array('lifestyle_translations', 'filed_under_no_tag'), 10, 4);
  120.  
  121. // Content end excerpt read more link hacks
  122. add_filter( 'the_content_more_link', 'lifestyle_more_link', 10, 2 );
  123. function lifestyle_more_link( $more_link, $more_link_text ) {
  124. global $post;
  125. return '<a href="'.get_permalink($post->ID).'" class="read-more">Continue Reading</a>';
  126. }
  127.  
  128. // Add theme support for post thumbnails
  129. add_theme_support('post-thumbnails');
  130. set_post_thumbnail_size(150, 150, true);
  131. add_image_size( 'custom_thumb', $opt['thumb_width'], $opt['thumb_height'], true);
  132.  
  133. // Add custom excerpt lenght
  134. function remove_twentyten_excerpt(){
  135. remove_filter( 'excerpt_length', 'twentyten_excerpt_length' );
  136. }
  137. add_action( 'after_setup_theme', 'remove_twentyten_excerpt' );
  138. function lifestyle_excerpt_length( $length ) {
  139. $opt = get_option('lifestyle');
  140. return $opt['excerpt_lenght'];
  141. }
  142. add_filter( 'excerpt_length', 'lifestyle_excerpt_length' );
  143.  
  144. // Add thumbnail to excerpt
  145. add_filter( 'the_excerpt', 'excerpt_thumbnail' );
  146. function excerpt_thumbnail($excerpt){
  147. if(is_single()) return $excerpt;
  148. global $post;
  149. if ( has_post_thumbnail() ) {
  150. $img .= '<a href="'.get_permalink($post->ID).'">'.get_the_post_thumbnail($post->ID, 'custom_thumb').'</a>';
  151. } else {
  152. $img = '';
  153. }
  154. return $img.$excerpt;
  155. }
  156.  
  157. // Turn off comments and pingbacks by default for pages
  158. function default_comments_off_for_pages ( $data ) {
  159. if( $data['post_type'] == 'page' && $data['post_status'] == 'auto-draft' ) {
  160. $data['comment_status'] = 0;
  161. $data['ping_status'] = 0;
  162. }
  163.  
  164. return $data;
  165. }
  166. add_filter( 'wp_insert_post_data', 'default_comments_off_for_pages' );
  167.  
  168. // Add social sharing foot not to single posts
  169. function lifestyle_footnote($content) { global $post; $opt = get_option('lifestyle');
  170. if(is_single() && ( 'post' == $post->post_type )) {
  171. if ( $opt['show_share'] == 1 ) {
  172. $content.= '<div class="social-share">';
  173. $content.= '<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>';
  174. $content.= '<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like href="'.urlencode(get_permalink($post->ID)).'" layout="button_count" show_faces="false" style="margin:0;padding:width:125px;"></fb:like>';
  175. $content.= '</div>';
  176. }
  177. }
  178. return $content;
  179. }
  180. add_filter ('the_content', 'lifestyle_footnote');
  181.  
  182. // Create the theme settings page
  183. $defaults = array (
  184. 'hide_admin' => '',
  185. 'show_share' => '',
  186. 'hide_st_top' => '',
  187. 'hide_st_btm' => '',
  188. 'thumb_width' => 100,
  189. 'thumb_height' => 100,
  190. 'excerpt_lenght' => 65
  191. );
  192. add_option('lifestyle', $defaults, '', 'yes');
  193.  
  194. add_action('admin_init', 'lifestyle_options_init' );
  195. function lifestyle_options_init(){
  196. register_setting( 'lifestyle', 'lifestyle' );
  197. }
  198.  
  199. add_action('admin_menu', 'create_lifestyle_menu');
  200. function create_lifestyle_menu() {
  201. add_theme_page( __( 'Theme Options' ), __( 'Theme Options' ), 'edit_theme_options', 'theme_options', 'lifestyle_settings_page' );
  202. }
  203. function lifestyle_settings_page() { global $msg;?>
  204. <div class="wrap"><div id="icon-themes" class="icon32"><br /></div><?php echo $msg; ?>
  205.  
  206. <h2><?php _e('Theme Options Page'); ?></h2>
  207.  
  208. <?php $url = 'http://wpshed.com/xyz/twentyten.php'; $request = new WP_Http; $result = $request->request( $url ); $json = $result['body']; echo $json; ?>
  209.  
  210. <form method="post" action="options.php">
  211. <?php settings_fields('lifestyle'); ?><?php $opt = get_option('lifestyle'); ?>
  212. <table class="form-table">
  213. <tr valign="top"><th scope="row"><?php _e('Hide Admin Bar'); ?>?</th>
  214. <td><input name="lifestyle[hide_admin]" type="checkbox" value="1" <?php checked('1', $opt['hide_admin']); ?> /> <span class="description"><?php _e('Hide the admin bar from the front-page when you are logged in.'); ?></span></td>
  215. </tr>
  216. <tr valign="top"><th scope="row"><?php _e('Include Social Sharring'); ?>?</th>
  217. <td><input name="lifestyle[show_share]" type="checkbox" value="1" <?php checked('1', $opt['show_share']); ?> /> <span class="description"><?php _e('Include Facebook and Twitter share button in your posts.'); ?></span></td>
  218. </tr>
  219. <tr valign="top"><th scope="row"><?php _e('Hide Sticky Meta Top'); ?>?</th>
  220. <td><input name="lifestyle[hide_st_top]" type="checkbox" value="1" <?php checked('1', $opt['hide_st_top']); ?> /> <span class="description"><?php _e('Check to hide sticky (featured) post top meta information.'); ?></span></td>
  221. </tr>
  222. <tr valign="top"><th scope="row"><?php _e('Hide Sticky Meta Bottom'); ?>?</th>
  223. <td><input name="lifestyle[hide_st_btm]" type="checkbox" value="1" <?php checked('1', $opt['hide_st_btm']); ?> /> <span class="description"><?php _e('Check to hide sticky (featured) post bottom meta information.'); ?></span></td>
  224. </tr>
  225. <tr valign="top"><th scope="row"><?php _e('Archive Thumbnail Width'); ?>?</th>
  226. <td><input type="text" name="lifestyle[thumb_width]" value="<?php echo $opt['thumb_width']; ?>" size="3" />px <span class="description"><?php _e('The width of the archive thumbnail if featured image is set.'); ?></span></td>
  227. </tr>
  228. <tr valign="top"><th scope="row"><?php _e('Archive Thumbnail Height'); ?>?</th>
  229. <td><input type="text" name="lifestyle[thumb_height]" value="<?php echo $opt['thumb_height']; ?>" size="3" />px <span class="description"><?php _e('The height of the archive thumbnail if featured image is set.<br />Please note: If featured images are already set and cropped to a specific dimension you should re-upload the featured image after changing these values.'); ?></span></td>
  230. </tr>
  231. <tr valign="top"><th scope="row"><?php _e('Excerpt Length'); ?>:</th>
  232. <td><input type="text" name="lifestyle[excerpt_lenght]" value="<?php echo $opt['excerpt_lenght']; ?>" size="3" /> <span class="description"><?php _e('The excerpt length (in number of words).'); ?></span></td>
  233. </tr>
  234. <tr valign="top"><th scope="row"></th>
  235. <td><input type="submit" class="button" value="<?php _e('Save Changes') ?>" /></td>
  236. </tr>
  237. </table>
  238. </form>
  239. </div>
  240. <?php
  241. }
  242.  
  243. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement