Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Remove admin bar if selected from the options menu
- $opt = get_option('lifestyle');
- if ( $opt['hide_admin'] == 1 ) {
- add_action( 'show_admin_bar', '__return_false' );
- }
- // Set the maximum image width to avoid over floating
- if ( ! isset( $content_width ) )
- $content_width = 590;
- // Add favicon and scripts to the theme head section
- function favicon_link() { $opt = get_option('lifestyle');
- $themedir = get_bloginfo('stylesheet_directory');
- echo '<link rel="shortcut icon" type="image/x-icon" href="' . $themedir . '/images/favicon.ico" />' . "\n";
- echo '<script type="text/javascript"><!--//--><![CDATA[//><!--
- sfHover = function() {
- if (!document.getElementsByTagName) return false;
- var sfEls = document.getElementsByTagName("menu").getElementsByTagName("li");
- for (var i=0; i<sfEls.length; i++) {
- sfEls[i].onmouseover=function() {
- this.className+=" sfhover";
- }
- sfEls[i].onmouseout=function() {
- this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
- }
- }
- }
- if (window.attachEvent) window.attachEvent("onload", sfHover);
- //--><!]]></script>' . "\n";
- if ( $opt['hide_st_top'] == 1 ) {
- echo '<style type="text/css">.sticky .entry-meta {display:none;}</style>';
- }
- if ( $opt['hide_st_btm'] == 1 ) {
- echo '<style type="text/css">.sticky .entry-utility {display:none;}</style>';
- }
- }
- add_action('wp_head', 'favicon_link');
- // Add custom header to child theme
- function lifestyle_header(){
- $themedir = get_bloginfo('stylesheet_directory');
- define( 'HEADER_IMAGE_WIDTH', apply_filters( 'twentyten_header_image_width', 1000 ) );
- define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height', 268 ) );
- define( 'HEADER_IMAGE', $themedir . '/images/header.png' );
- register_default_headers( array (
- 'lights' => array (
- 'url' => "$themedir/images/header.png",
- 'thumbnail_url' => "$themedir/images/header-thumb.png",
- 'description' => __( 'lifestyle Header', 'twentyten' )
- ),
- ));
- }
- add_action( 'after_setup_theme', 'lifestyle_header' );
- // Remove the default header images
- function lifestyle_remove_twenty_ten_headers(){
- unregister_default_headers( array(
- 'berries',
- 'cherryblossom',
- 'concave',
- 'fern',
- 'forestfloor',
- 'inkwell',
- 'path',
- 'sunset')
- );
- }
- add_action( 'after_setup_theme', 'lifestyle_remove_twenty_ten_headers', 11 );
- // Child theme default translations
- class lifestyle_translations {
- function site_generator($translation, $text, $domain) {
- $translations = &get_translations_for_domain( $domain );
- if ( $text == 'Proudly powered by %s.' ) {
- return $translations->translate( 'Powered by %s</a> · a <span id="wpshed-link"><a href="http://wpshed.com" title="wordpress how to">WPshed</a> design</span>' );
- }
- return $translation;
- }
- function comments_closed($translation, $text, $domain) {
- $translations = &get_translations_for_domain( $domain );
- if ( $text == 'Comments are closed.' ) {
- return $translations->translate( '' );
- }
- return $translation;
- }
- function leave_reply($translation, $text, $domain) {
- $translations = &get_translations_for_domain( $domain );
- if ( $text == 'Leave a Reply' ) {
- return $translations->translate( 'Speak Your Mind' );
- }
- return $translation;
- }
- function filed_under($translation, $text, $domain) {
- $translations = &get_translations_for_domain( $domain );
- 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>.' ) {
- return $translations->translate( 'Filed under: %1$s Tagged with: %2$s. - <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.' );
- }
- return $translation;
- }
- function filed_under_no_tag($translation, $text, $domain) {
- $translations = &get_translations_for_domain( $domain );
- if ( $text == 'This entry was posted in %1$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.' ) {
- return $translations->translate( 'Filed under: %1$s. Bookmark the <a href="%3$s" title="Permalink to %4$s" rel="bookmark">permalink</a>.' );
- }
- return $translation;
- }
- }
- add_filter('gettext', array('lifestyle_translations', 'site_generator'), 10, 4);
- add_filter('gettext', array('lifestyle_translations', 'comments_closed'), 10, 4);
- add_filter('gettext', array('lifestyle_translations', 'leave_reply'), 10, 4);
- add_filter('gettext', array('lifestyle_translations', 'filed_under'), 10, 4);
- add_filter('gettext', array('lifestyle_translations', 'filed_under_no_tag'), 10, 4);
- // Content end excerpt read more link hacks
- add_filter( 'the_content_more_link', 'lifestyle_more_link', 10, 2 );
- function lifestyle_more_link( $more_link, $more_link_text ) {
- global $post;
- return '<a href="'.get_permalink($post->ID).'" class="read-more">Continue Reading</a>';
- }
- // Add theme support for post thumbnails
- add_theme_support('post-thumbnails');
- set_post_thumbnail_size(150, 150, true);
- add_image_size( 'custom_thumb', $opt['thumb_width'], $opt['thumb_height'], true);
- // Add custom excerpt lenght
- function remove_twentyten_excerpt(){
- remove_filter( 'excerpt_length', 'twentyten_excerpt_length' );
- }
- add_action( 'after_setup_theme', 'remove_twentyten_excerpt' );
- function lifestyle_excerpt_length( $length ) {
- $opt = get_option('lifestyle');
- return $opt['excerpt_lenght'];
- }
- add_filter( 'excerpt_length', 'lifestyle_excerpt_length' );
- // Add thumbnail to excerpt
- add_filter( 'the_excerpt', 'excerpt_thumbnail' );
- function excerpt_thumbnail($excerpt){
- if(is_single()) return $excerpt;
- global $post;
- if ( has_post_thumbnail() ) {
- $img .= '<a href="'.get_permalink($post->ID).'">'.get_the_post_thumbnail($post->ID, 'custom_thumb').'</a>';
- } else {
- $img = '';
- }
- return $img.$excerpt;
- }
- // Turn off comments and pingbacks by default for pages
- function default_comments_off_for_pages ( $data ) {
- if( $data['post_type'] == 'page' && $data['post_status'] == 'auto-draft' ) {
- $data['comment_status'] = 0;
- $data['ping_status'] = 0;
- }
- return $data;
- }
- add_filter( 'wp_insert_post_data', 'default_comments_off_for_pages' );
- // Add social sharing foot not to single posts
- function lifestyle_footnote($content) { global $post; $opt = get_option('lifestyle');
- if(is_single() && ( 'post' == $post->post_type )) {
- if ( $opt['show_share'] == 1 ) {
- $content.= '<div class="social-share">';
- $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>';
- $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>';
- $content.= '</div>';
- }
- }
- return $content;
- }
- add_filter ('the_content', 'lifestyle_footnote');
- // Create the theme settings page
- $defaults = array (
- 'hide_admin' => '',
- 'show_share' => '',
- 'hide_st_top' => '',
- 'hide_st_btm' => '',
- 'thumb_width' => 100,
- 'thumb_height' => 100,
- 'excerpt_lenght' => 65
- );
- add_option('lifestyle', $defaults, '', 'yes');
- add_action('admin_init', 'lifestyle_options_init' );
- function lifestyle_options_init(){
- register_setting( 'lifestyle', 'lifestyle' );
- }
- add_action('admin_menu', 'create_lifestyle_menu');
- function create_lifestyle_menu() {
- add_theme_page( __( 'Theme Options' ), __( 'Theme Options' ), 'edit_theme_options', 'theme_options', 'lifestyle_settings_page' );
- }
- function lifestyle_settings_page() { global $msg;?>
- <div class="wrap"><div id="icon-themes" class="icon32"><br /></div><?php echo $msg; ?>
- <h2><?php _e('Theme Options Page'); ?></h2>
- <?php $url = 'http://wpshed.com/xyz/twentyten.php'; $request = new WP_Http; $result = $request->request( $url ); $json = $result['body']; echo $json; ?>
- <form method="post" action="options.php">
- <?php settings_fields('lifestyle'); ?><?php $opt = get_option('lifestyle'); ?>
- <table class="form-table">
- <tr valign="top"><th scope="row"><?php _e('Hide Admin Bar'); ?>?</th>
- <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>
- </tr>
- <tr valign="top"><th scope="row"><?php _e('Include Social Sharring'); ?>?</th>
- <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>
- </tr>
- <tr valign="top"><th scope="row"><?php _e('Hide Sticky Meta Top'); ?>?</th>
- <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>
- </tr>
- <tr valign="top"><th scope="row"><?php _e('Hide Sticky Meta Bottom'); ?>?</th>
- <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>
- </tr>
- <tr valign="top"><th scope="row"><?php _e('Archive Thumbnail Width'); ?>?</th>
- <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>
- </tr>
- <tr valign="top"><th scope="row"><?php _e('Archive Thumbnail Height'); ?>?</th>
- <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>
- </tr>
- <tr valign="top"><th scope="row"><?php _e('Excerpt Length'); ?>:</th>
- <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>
- </tr>
- <tr valign="top"><th scope="row"></th>
- <td><input type="submit" class="button" value="<?php _e('Save Changes') ?>" /></td>
- </tr>
- </table>
- </form>
- </div>
- <?php
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement