Antworten auf deine Fragen:
Neues Thema erstellen

Autofocus+ Theme Custom Field hinzufügen

floei

freundlicher Helfer

Nochmal eine Frage:
Wie füge Ich denn im Autofocus+ Theme (Thematic Childtheme) Custom Fields hinzu? Weil mit den Tutorials von Wodpress bekomme Ich das nicht hin. Es soll einfach 3 Felder geben, bei denen ich eintragen kann welche Software genutzt wurde was mein Anteil war und welcher Client, am besten direkt unter das Video, das übrigens auch über ein custom field eingebunden wird!

Functions.php kannunten eingesehen werden, falls noch etwas benötigt wird stelle ich es gerne zur verfügung!

Hier der zum Portfolio

Gruß Flo

Theme-Functions:
PHP:
<?php

//    Conditional test for IE6
function browser_ie6() {
    $agents = array(
        'MSIE 6.0'
    );
    foreach ($agents as $agent) {
        if (strpos($_SERVER['HTTP_USER_AGENT'], $agent) or isset($_GET[$agent]) && $_GET[$agent] ) {
            return true;
        }
    }
  return false;
}

//    Thanks very much to Thin & Light (http://thinlight.org/) for this custom function!
function tl_excerpt($text, $excerpt_length = 25) {
    $text = str_replace(']]>', ']]&gt;', $text);
    $text = strip_tags($text);
    $text = preg_replace("/\[.*?]/", "", $text);
    $words = explode(' ', $text, $excerpt_length + 1);
    if (count($words) > $excerpt_length) {
        array_pop($words);
        array_push($words, '...');
        $text = implode(' ', $words);
    }
    
    return apply_filters('the_excerpt', $text);
}

function tl_post_excerpt($post) {
    $excerpt = ($post->post_excerpt == '') ? (tl_excerpt($post->post_content))
            : (apply_filters('the_excerpt', $post->post_excerpt));
    return $excerpt;
}

function previous_post_excerpt($in_same_cat = false, $excluded_categories = '') {
    if ( is_attachment() )
        $post = &get_post($GLOBALS['post']->post_parent);
    else
        $post = get_previous_post($in_same_cat, $excluded_categories);

    if ( !$post )
        return;
    $post = &get_post($post->ID);
    echo tl_post_excerpt($post);
}

function next_post_excerpt($in_same_cat = false, $excluded_categories = '') {
    $post = get_next_post($in_same_cat, $excluded_categories);

    if ( !$post )
        return;
    $post = &get_post($post->ID);
    echo tl_post_excerpt($post);
}

// Photo Author/Credit Display
function autofocus_credit() { 
    global $post;
        
    if ( get_the_author_meta('user_url') == '' ) { ?>
        <span class="photo-credit">&copy; <?php the_time('Y'); ?> <?php the_author_meta('display_name'); ?>. <?php _e('All rights reserved.', 'thematic'); ?></span>
    <?php } else { ?>
        <span class="photo-credit">&copy; <?php the_time('Y'); ?> <a href="<?php the_author_meta('user_url'); ?>" target="_blank" rel="author"><?php the_author_meta('display_name'); ?></a>. <?php _e('All rights reserved.', 'thematic'); ?></span>
    <?php } ?>

<?php }

//    Post Attachment image function. Direct link to file. 
function the_post_image($size=large, $fullsize=false, $width=940, $height=600, $max_dims=false) {
    
    global $post;
    $linkedimgtag = get_post_meta ($post->ID, 'image_tag', true);
    
    if ( $images = get_children(array(
        'post_parent' => get_the_ID(),
        'post_type' => 'attachment',
        'numberposts' => 1,
        'post_mime_type' => 'image',)))
        {
        foreach( $images as $image ) {
            $attachmenturl=wp_get_attachment_url($image->ID);
            $attachmentimage=wp_get_attachment_image( $image->ID, $size );
            $attachmentresize=get_attachment_innerHTML($image->ID, $fullsize, array($width, $height));

            echo $attachmentimage;
        }
        
    } elseif ( $linkedimgtag ) {

        echo $linkedimgtag;

    } elseif ( $linkedimgtag && $images = get_children(array(
        'post_parent' => get_the_ID(),
        'post_type' => 'attachment',
        'numberposts' => 1,
        'post_mime_type' => 'image',)))
        {
        foreach( $images as $image ) {
            $attachmenturl=wp_get_attachment_url($image->ID);
            $attachmentimage=wp_get_attachment_image( $image->ID, $size );
            $attachmentresize=get_attachment_innerHTML($image->ID, $size, array($width, $height));

            echo $attachmentresize;
        }
        
    } elseif (get_post_meta($post->ID, 'image_tag', $single = true) == "" && is_single()) {
        // Don’t show anything on Single pages that don’t have Image or Video attachments.

    } else {
        echo '<!-- No Image Attached! -->';
        echo '<img src="';
        echo get_bloginfo ( 'stylesheet_directory' ) . '/img/no-attachment.png';
        echo '" width="188" height="188" />';
    }
}

//    Setup Images for Attachment functions 
function image_setup($postid) {
    global $post;
    $post = get_post($postid);

    //    get url
    if ( !preg_match('/<img ([^>]*)src=(\"|\')(.+?)(\2)([^>\/]*)\/*>/', $post->post_content, $matches) ) {
        return false;
    }

    //    url setup /**/
    $post->image_url = $matches[3];
    if ( !$post->image_url = preg_replace('/\?w\=[0-9]+/','', $post->image_url) )
        return false;

    $post->image_url = clean_url( $post->image_url, 'raw' );
    
    delete_post_meta($post->ID, 'image_url');
    delete_post_meta($post->ID, 'image_tag');

    add_post_meta($post->ID, 'image_url', $post->image_url);
    add_post_meta($post->ID, 'image_tag', '<img src="'.$post->image_url.'" />');
}
add_action('publish_post', image_setup);
add_action('publish_page', image_setup);

//    Post Attachment image function for Attachment Pages. 
function the_attachment_image($size=large) {
    $attachmenturl=wp_get_attachment_url($image->ID);
    $attachmentimage=wp_get_attachment_image( $image->ID, $size );

    echo ''.$attachmentimage.'';
}

//    Grab EXIF Data from Attachments
//    http://www.bloggingtips.com/2008/07/20/wordpress-gallery-and-exif/
function grab_exif_data() {
    global $id, $post;
    $imgmeta = wp_get_attachment_metadata($id, false);

    //    Start to display EXIF and IPTC data of digital photograph
    echo "<h3 id='exif-data'>Exif Data</h3>";
    echo "<ul><li><span class=\"exif-title\">Date Taken:</span> " . date("d-M-Y H:i:s", $imgmeta['image_meta']['created_timestamp'])."</li>";
    echo "<li><span class=\"exif-title\">Copyright:</span> " . $imgmeta['image_meta']['copyright']."</li>";
    echo "<li><span class=\"exif-title\">Credit:</span> " . $imgmeta['image_meta']['credit']."</li>";
    echo "<li><span class=\"exif-title\">Title:</span> " . $imgmeta['image_meta']['title']."</li>";
    echo "<li><span class=\"exif-title\">Caption:</span> " . $imgmeta['image_meta']['caption']."</li>";
    echo "<li><span class=\"exif-title\">Camera:</span> " . $imgmeta['image_meta']['camera']."</li>";
    echo "<li><span class=\"exif-title\">Focal Length:</span> " . $imgmeta['image_meta']['focal_length']."mm</li>";
    echo "<li><span class=\"exif-title\">Aperture:</span> f/" . $imgmeta['image_meta']['aperture']."</li>";
    echo "<li><span class=\"exif-title\">ISO:</span> " . $imgmeta['image_meta']['iso']."</li>";
    echo "<li><span class=\"exif-title\">Shutter Speed:</span> " . number_format($imgmeta['image_meta']['shutter_speed'], 2)." seconds</li>\n</ul>";
}

//    Get the Post Thumbnail URL for the EXIF link
function exif_link( $post_id = NULL, $size = 'single-post-thumbnail', $attr = '' ) {
    global $id;
    $post_id = ( NULL === $post_id ) ? $id : $post_id;
    $post_thumbnail_id = get_post_thumbnail_id( $post_id );
    $size = apply_filters( 'single-post-thumbnail', $size );
    if ( $post_thumbnail_id ) {
        $thumburl = get_attachment_link( $post_thumbnail_id, $size, false, $attr );
    } else {
        $thumburl = '';
    }
    return $thumburl;
}

//    Add Images/Video/Embeds to feeds
//    - Based on the Custom Fields for Feeds Plugin by Justin Tadlock
//    - http://justintadlock.com/archives/2008/01/27/custom-fields-for-feeds-wordpress-plugin
function autofocus_feed( $content ) {
    global $post, $id, $afoptions;
    foreach ($afoptions as $value) {
        if (get_settings( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_settings( $value['id'] ); }
    }
    
    $data = get_post_meta( $post->ID, 'autofocus', true );
    $blog_key = substr( md5( get_bloginfo('url') ), 0, 16 );
    
    if ( !is_feed() ) return $content;
 
//    Is there a Video attached?
//    - WordPress doesn’t setup [embed] codes as shortcodes. 
//    - Embedded content will not work in feeds without it. 
//    - See: http://core.trac.wordpress.org/ticket/12505

//    if ($data[ 'videoembed_value' ]) {
//        $af_video_url = $data[ 'videoembed_value' ];
//        $mediafeed = '[embed width="800" height="450"]' . $af_video_url . '[/embed]';
//    }

//    If there’s no video is there an image thumbnail?
    if ( has_post_thumbnail() ) {
        $mediafeed = the_post_thumbnail('medium');
    }

//    If there's a video or an image, display the media with the content
    if ($mediafeed !== '') {
        $content = '<p>' .$mediafeed . '</p><br />' . $content;
        return $content;
 
//    If there's no media, just display the content
    } else {
        $content = $content;
        return $content;
    }
}
add_filter('the_content', 'autofocus_feed');

//    Add Post Thumbnails Support
if ( function_exists( 'add_theme_support' ) ) { // Added in 2.9
    add_theme_support( 'post-thumbnails' );
    set_post_thumbnail_size( 88, 88, true ); // Default thumbnail size
    add_image_size( 'archive-thumbnail', 188, 188, true ); // Archives thumbnail size
    add_image_size( 'single-post-thumbnail', 940, 600 ); // Single Posts thumbnail size
    add_image_size( 'front-page-thumbnail', 940, 368, true ); // Front Page thumbnail size
}

//    Set default content width for images in post content
$_GLOBALS['content_width'] = 494;

// Custom AutoFocus Thumbnail Sizes
function af_image_sizes( $sizes ) {
    $sizes[] = 'afthumb';
    $sizes[] = 'aflarge';
    $sizes[] = 'afsingle';
    return $sizes;
}
add_filter( 'intermediate_image_sizes', 'af_image_sizes' );

//    Custom image size settings initiated at activation
if ( is_admin() && isset($_GET['activated'] ) && $pagenow == 'themes.php' ) {
    if( FALSE === get_option('af_size_w') ) {
        add_option('afthumb_size_w', '188');
        add_option('afthumb_size_h', '188');
        add_option('afthumb_crop', '1');

        add_option('aflarge_size_w', '940');
        add_option('aflarge_size_h', '368');
        add_option('aflarge_crop', '0');

        add_option('afsingle_size_w', '940');
        add_option('afsingle_size_h', '600');
        add_option('afsingle_crop', '0');
    } else {
        update_option('afthumb_size_w', '188');
        update_option('afthumb_size_h', '188');
        update_option('afthumb_crop', '1');

        update_option('aflarge_size_w', '940');
        update_option('aflarge_size_h', '368');
        update_option('aflarge_crop', '0');

        update_option('afsingle_size_w', '940');
        update_option('afsingle_size_h', '600');
        update_option('afsingle_crop', '0');
    }

    update_option('thumbnail_size_h', '88');
    update_option('thumbnail_size_w', '88');
    update_option('thumbnail_crop', '1');

    update_option('medium_size_h', '188');
    update_option('medium_size_w', '188');
    update_option('medium_crop', '0');

    update_option('large_size_h', '494');
    update_option('large_size_w', '494');
    update_option('large_crop', '0');

    update_option('thread_comments', '1');
    update_option('thread_comments_depth', '2');
    
    update_option( 'posts_per_page', '12');
    update_option( 'date_format', __('j M ’y') );
}

//    Load Color Options
function af_load_color_options() {
    global $afoptions;
    foreach ($afoptions as $afvalue) {
        if (get_settings( $afvalue['id'] ) === FALSE) { $$afvalue['id'] = $afvalue['std']; } else { $$afvalue['id'] = get_settings( $afvalue['id'] ); }
    } ?>
    <style type="text/css">
    /* <![CDATA[ */
    /* AutoFocus+ Color Options */
<?php $afcoloroptions = dirname( __FILE__ ) . '/css/af-styles.php'; if( is_file( $afcoloroptions ) ) require $afcoloroptions; ?>
    /* ]]> */
    </style>
<?php }
add_action('wp_head', 'af_load_color_options');

//    Post Options and Instructions
//    - New Video Array For Video Embed Codes
$key = "autofocus";
$af_meta_boxes = array(
"video" => array(
    "name" => "videoembed_value",
    "title" => __("Embed URL","thematic"),
    "description" => __("Paste your oEmbed URL here. (Examples: http://vimeo.com/7757262, http://www.flickr.com/photos/bking/3598750242/)","thematic")),
"copyright" => array(
    "name" => "copyright_value",
    "title" => __("Photo Credit","thematic"),
    "description" => __("Text entered here will replace the default Photo credit. (Example: &copy; 2009 Image Author. All rights reserved.)<br />Using HTML here works but is not recommended.","thematic")),

"What I did" => array(
    "name" => "whatidid_value",
    "title" => __("What I did","thematic"),
    "description" => __("hier kommt rein was ich gemacht habe.)<br />Using HTML here works but is not recommended.","thematic")),
); 

//    - New Meta Boxes For Video Embed Codes
function display_meta_box() {
    global $post, $af_meta_boxes, $key; ?>  

    <div class="form-wrap">  
    <?php wp_nonce_field( plugin_basename( __FILE__ ), $key . '_wpnonce', false, true );  
        foreach($af_meta_boxes as $meta_box) {
        $data = get_post_meta($post->ID, $key, true); ?>

        <div class="form-field form-required">
            <label for="<?php echo $meta_box[ 'name' ]; ?>"><?php echo $meta_box[ 'title' ]; ?></label>
            <input type="text" name="<?php echo $meta_box[ 'name' ]; ?>" value="<?php echo htmlspecialchars( $data[ $meta_box[ 'name' ] ] ); ?>" />
            <p><?php echo $meta_box[ 'description' ]; ?></p>
        </div>
    <?php } ?>
    </div>

<?php }

//    - Create Form Data
function create_meta_box() {
    global $key;
    if( function_exists( 'add_meta_box' ) ) {  
        add_meta_box( 'new-meta-boxes', 'AutoFocus+ Post Options', 'display_meta_box', 'post', 'normal', 'high' );
    }
}

//    - Save Form Data
function save_meta_box( $post_id ) {
    global $post, $af_meta_boxes, $key;
    foreach( $af_meta_boxes as $meta_box ) {
        $data[ $meta_box[ 'name' ] ] = $_POST[ $meta_box[ 'name' ] ];
    }

    if ( !wp_verify_nonce( $_POST[ $key . '_wpnonce' ], plugin_basename(__FILE__) ) )
        return $post_id;

    if ( !current_user_can( 'edit_post', $post_id ))
        return $post_id;
        update_post_meta( $post_id, $key, $data );
}
add_action( 'admin_menu', 'create_meta_box' );
add_action( 'save_post', 'save_meta_box' );

//    Theme Options --------------------------------------------
$afthemename = "AutoFocus+";
$afshortname = "af";
$afoptions = array();

function autofocus_options() {
    global $afthemename, $afshortname, $afoptions;
        $af_categories_obj = get_categories('hide_empty=0');
        $af_categories = array();
        foreach ($af_categories_obj as $af_cat) {
                $af_categories[$af_cat->cat_ID] = $af_cat->cat_name;
        }
        $categories_std = array_unshift($af_categories, "Select a category:");

        $afoptions = array (
                                        
                array(    "name" => __('Text Color'),
                        "desc" => __('Change the color of links, backgrounds and borders by entering a HEX color number. (ie: <span style="font-family:Monaco,Lucida Console,Courier,monospace;">003333</span>)','thematic'),
                        "id" => $afshortname."_text_color",
                        "std" => "999999",
                        "type" => "colorpicker"),

                array(    "name" => __('Link Color','thematic'),
                        "desc" => __('Change the color of hover links by entering a HEX color number. (ie: <span style="font-family:Monaco,Lucida Console,Courier,monospace;">FF6600</span>)','thematic'),
                        "id" => $afshortname."_link_color",
                        "std" => "00CCFF",
                        "type" => "colorpicker"),

                array(    "name" => __('Background Color','thematic'),
                        "desc" => __('Change the color of hover links by entering a HEX color number. (ie: <span style="font-family:Monaco,Lucida Console,Courier,monospace;">FF6600</span>)','thematic'),
                        "id" => $afshortname."_bg_color",
                        "std" => "FFFFFF",
                        "type" => "colorpicker"),

                array(    "name" => __('Photo Background Color','thematic'),
                        "desc" => __('Change the background color of Portrait (narrow) images by entering a HEX color number. (ie: <span style="font-family:Monaco,Lucida Console,Courier,monospace;">FF6600</span>. Note: If left empty, the background color will be transparent.','thematic'),
                        "id" => $afshortname."_photo_color",
                        "std" => "F0F0F0",
                        "type" => "colorpicker"),

                array(    "name" => __('Show Post Titles','thematic'),
                        "desc" => __("Add a check here to show Post Titles instead of Post Dates on the home page.",'thematic'),
                        "id" => $afshortname."_show_post_title",
                        "std" => "false",
                        "type" => "checkbox"),

                array(    "name" => __('Show Exif data','thematic'),
                        "desc" => __("Add a check here to show the Exif data for your images on attachment pages (WP Gallery Images only).",'thematic'),
                        "id" => $afshortname."_show_exif_data",
                        "std" => "false",
                        "type" => "checkbox")

          );
}
add_action('init', 'autofocus_options');

//    Make a Theme Options Page
function childtheme_add_admin() {

    global $afthemename, $afshortname, $afoptions;

    if ( $_GET['page'] == basename(__FILE__) ) {
    
        if ( 'save' == $_REQUEST['action'] ) {

                foreach ($afoptions as $afvalue) {
                    update_option( $afvalue['id'], $_REQUEST[ $afvalue['id'] ] ); }

                foreach ($afoptions as $afvalue) {
                    if( isset( $_REQUEST[ $afvalue['id'] ] ) ) { update_option( $afvalue['id'], $_REQUEST[ $afvalue['id'] ]  ); } else { delete_option( $afvalue['id'] ); } }

                header("Location: themes.php?page=functions.php&saved=true");
                die;

        } else if( 'reset' == $_REQUEST['action'] ) {

            foreach ($afoptions as $afvalue) {
                delete_option( $afvalue['id'] ); }

            header("Location: themes.php?page=functions.php&reset=true");
            die;

        }
    }

    add_theme_page($afthemename." Options", "$afthemename Options", 'edit_themes', basename(__FILE__), 'childtheme_admin');

}

function childtheme_admin() {

    global $afthemename, $afshortname, $afoptions;

    if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$afthemename.' settings saved.</strong></p></div>';
    if ( $_REQUEST['reset'] ) echo '<div id="message" class="updated fade"><p><strong>'.$afthemename.' settings reset.</strong></p></div>';
    
?>
<script language="javascript" type="text/javascript" src="<?php echo bloginfo('stylesheet_directory') ?>/js/jscolor/jscolor.js"></script>
<div class="wrap">
<h2><?php echo $afthemename; ?> Options</h2>

<form method="post">

<table class="form-table">

<?php foreach ($afoptions as $afvalue) { 
    
    switch ( $afvalue['type'] ) {
        case 'text':
        ?>
        <tr valign="top"> 
            <th scope="row"><?php echo $afvalue['name']; ?>:</th>
            <td>
                <input name="<?php echo $afvalue['id']; ?>" id="<?php echo $afvalue['id']; ?>" type="<?php echo $afvalue['type']; ?>" value="<?php if ( get_settings( $afvalue['id'] ) != "") { echo get_settings( $afvalue['id'] ); } else { echo $afvalue['std']; } ?>" />
                <?php echo $afvalue['desc']; ?>
            </td>
        </tr>
        <?php
        break;
        
        case 'colorpicker':
        ?>
        <tr valign="top"> 
            <th scope="row"><label for="<?php echo $afvalue['id']; ?>"><?php echo __($afvalue['name'],'thematic'); ?></label></th>
            <td>
                <input type="<?php echo $afvalue['type']; ?>" name="<?php echo $afvalue['id']; ?>" id="<?php echo $afvalue['id']; ?>" value="<?php if ( get_option( $afvalue['id'] ) != "") { echo get_option( $afvalue['id'] ); } else { echo $afvalue['std']; } ?>" class="color {pickerPosition:'right'}" />
                <?php echo __($afvalue['desc'],'thematic'); ?>

            </td>
        </tr>
        <?php
        break;
        
        case 'select':
        ?>
        <tr valign="top"> 
            <th scope="row"><?php echo $afvalue['name']; ?></th>
            <td>
                <select name="<?php echo $afvalue['id']; ?>" id="<?php echo $afvalue['id']; ?>">
                    <?php foreach ($afvalue['options'] as $option) { ?>
                    <option<?php if ( get_settings( $afvalue['id'] ) == $option) { echo ' selected="selected"'; } elseif ($option == $afvalue['std']) { echo ' selected="selected"'; } ?>><?php echo $option; ?></option>
                    <?php } ?>
                </select>
                <?php echo $afvalue['desc']; ?>
            </td>
        </tr>
        <?php
        break;
        
        case 'textarea':
        $ta_options = $afvalue['options'];
        ?>
        <tr valign="top"> 
            <th scope="row"><?php echo $afvalue['name']; ?>:</th>
            <td>
                <?php echo $afvalue['desc']; ?>
                <textarea name="<?php echo $afvalue['id']; ?>" id="<?php echo $afvalue['id']; ?>" cols="<?php echo $ta_options['cols']; ?>" rows="<?php echo $ta_options['rows']; ?>"><?php 
                if( get_settings($afvalue['id']) != "") {
                        echo stripslashes(get_settings($afvalue['id']));
                    }else{
                        echo $afvalue['std'];
                }?></textarea>
            </td>
        </tr>
        <?php
        break;

        case "radio":
        ?>
        <tr valign="top"> 
            <th scope="row"><?php echo $afvalue['name']; ?>:</th>
            <td>
                <?php foreach ($afvalue['options'] as $key=>$option) { 
                $radio_setting = get_settings($afvalue['id']);
                if($radio_setting != ''){
                    if ($key == get_settings($afvalue['id']) ) {
                        $checked = "checked=\"checked\"";
                        } else {
                            $checked = "";
                        }
                }else{
                    if($key == $afvalue['std']){
                        $checked = "checked=\"checked\"";
                    }else{
                        $checked = "";
                    }
                }?>
                <input type="radio" name="<?php echo $afvalue['id']; ?>" value="<?php echo $key; ?>" <?php echo $checked; ?> /><?php echo $option; ?><br />
                <?php } ?>
            </td>
        </tr>
        <?php
        break;
        
        case "checkbox":
        ?>
            <tr valign="top"> 
                <th scope="row"><?php echo $afvalue['name']; ?></th>
                <td>
                   <?php
                        if(get_settings($afvalue['id'])){
                            $checked = "checked=\"checked\"";
                        }else{
                            $checked = "";
                        }
                    ?>
                    <input type="checkbox" name="<?php echo $afvalue['id']; ?>" id="<?php echo $afvalue['id']; ?>" value="true" <?php echo $checked; ?> />
                    <?php  ?>
                <?php echo $afvalue['desc']; ?>
                </td>
            </tr>
            <?php
        break;

        default:

        break;
    }
}
?>

</table>

<p class="submit">
<input name="save" type="submit" value="Save changes" />    
<input type="hidden" name="action" value="save" />
</p>
</form>
<form method="post">
<p class="submit">
<input name="reset" type="submit" value="Reset" />
<input type="hidden" name="action" value="reset" />
</p>
</form>

<p><?php _e('For more information about this theme, visit the <a href="http://fthrwght.com/autofocus">documentation page</a>. If you have any questions, check out <a href="http://wpquestions.com/">WPQuestions.com</a>.', 'thematic'); ?></p>

<?php }
add_action('admin_menu' , 'childtheme_add_admin');

//    Add Thematic Body and Post Classes, Comment form classes & RSS links
define('THEMATIC_COMPATIBLE_BODY_CLASS', true);
define('THEMATIC_COMPATIBLE_POST_CLASS', true);
define('THEMATIC_COMPATIBLE_COMMENT_FORM', true);
define('THEMATIC_COMPATIBLE_FEEDLINKS', true);

//    Add custom jQuery plugins and functions
function af_enqueue_styles() {
    if (!is_admin()) {
        //    BOO IE6! :-/
        if( browser_ie6() ) { 
            wp_enqueue_style('afiestyles', get_bloginfo('stylesheet_directory') . '/css/ie-styles.css','','20100329','all');
        }
    }
}
add_action('init', 'af_enqueue_styles');

//    Add jQuery Plugins when not in IE
function af_enqueue_scripts() {
    if( !browser_ie6() ) { 
        wp_enqueue_script('imgCenter', get_bloginfo('stylesheet_directory') . '/js/jquery.imgCenter.minified.js', array('jquery'), '20100329' );
        wp_enqueue_script('hotkeys', get_bloginfo('stylesheet_directory') . '/js/jquery.hotkeys-0.7.9.min.js', array('jquery'), '20100329' );
        wp_enqueue_script('autofocusjs', get_bloginfo('stylesheet_directory') . '/js/afscripts.js', array('jquery'), '20100329' );
    }
}
add_action('wp_print_scripts', 'af_enqueue_scripts');

//    Load Thematic Functions
require_once(STYLESHEETPATH . '/thematic-functions.php');

?>
Thematic-Functions:
PHP:
<?php

//    Favorite Icon
function autofocus_favicon() { ?>
    <link rel="shortcut icon" href="<?php echo bloginfo('stylesheet_directory') ?>/img/favicon.ico">
<?php }
add_action('wp_head', 'autofocus_favicon', 1);

//    Add a Home link to your menu
//    updated for Thematic 0.9.7.7
function childtheme_menu_args($args) {
        $args = array(
        'show_home' => 'Home',
        'sort_column' => 'menu_order',
        'menu_class' => 'menu',
        'echo' => false
    );
    return $args;
} 
add_filter('wp_page_menu_args','childtheme_menu_args', 20);

//    Create Arrow Navigation
//    - remove default navigation
function remove_thematic_actions() {
    remove_action('thematic_navigation_above', 'thematic_nav_above', 2);
    remove_action('thematic_navigation_below', 'thematic_nav_below', 2);
}
add_action('init','remove_thematic_actions');

//    - add arrow navigation
function autofocus_nav_above() { 
    if (is_single()) { ?>
            <div id="nav-above" class="navigation">
                <div class="nav-previous"><?php previous_post_link('%link', __('<span class="meta-nav">&larr;</span>', 'thematic')) ?></div>
                <div class="nav-next"><?php next_post_link('%link', __('<span class="meta-nav">&rarr;</span>', 'thematic')) ?></div>
            </div>
    
<?php } else { ?>
            <div id="nav-above" class="navigation">
                <div class="nav-previous"><?php next_posts_link(__('<span class="meta-nav">&larr;</span>', 'thematic')) ?></div>
                <div class="nav-next"><?php previous_posts_link(__('<span class="meta-nav">&rarr;</span>', 'thematic')) ?></div>
            </div>    
    
<?php } }
add_action('thematic_navigation_above', 'autofocus_nav_above', 2);

//    Add arrows to the Post excerpt 
function autofocus_readmore($text) {
    //    No arrows on the Home page excerpts 
    if (is_home() || is_feed()) {
        return str_replace('[...]', ' &hellip;', $text);
    } else {
        return str_replace('[...]', ' &hellip; <a href="'.get_permalink().'" class="more-link">' . __('Read More ', 'thematic') . '<span class="excerpt-arrow">&rarr;</span></a>', $text);
} }
add_filter('get_the_excerpt', 'autofocus_readmore');

//    Add New Excerpt Word Count
function autofocus_excerpt_length($length) {
    //    Add more words for the Archive pages
    if (is_archive() || is_search()) {
        return 45;
    } else {
        return 25;
} }
add_filter('excerpt_length', 'autofocus_excerpt_length'); 

//    Show excerpts on Home pages and Archives
function autofocus_content($content) {
    global $content;
    if ( is_archive() || is_front_page() || is_search() ) {
        $content= 'excerpt';
    } else {
        $content= 'full';
    }
    return $content;
}
add_filter('thematic_content', 'autofocus_content');
 
//    Add <p> Tags to Excerpts
function autofocus_excerpt_autop() {
    global $content;

    if ( strtolower($content) == 'full' ) {
        $post = get_the_content(more_text());
        $post = apply_filters('the_content', $post);
        $post = str_replace(']]>', ']]>', $post);

    } elseif ( strtolower($content) == 'excerpt') {
        $post = get_the_excerpt();

        //    add in the <p>
        $post = wpautop($post);

    } elseif ( strtolower($content) == 'none') {
    } else {
        $post = get_the_content(more_text());
        $post = apply_filters('the_content', $post);
        $post = str_replace(']]>', ']]>', $post);
    }
    return $post;
}
add_filter('thematic_post','autofocus_excerpt_autop');

// Add the Featured/Sticky Post section 
function af_sticky_area() { 
global $afoptions;
foreach ($afoptions as $value) {
    if (get_settings( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_settings( $value['id'] ); }
}
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

    if( is_home() && !is_paged() ) { ?>

        <?php if (get_option('sticky_posts')) { ?>
            <?php
            $sticky = get_option('sticky_posts');
            $randomStickyNo = 0;
            $randomStickyNo = (rand()%(count($sticky)));
            $postno = $sticky[($randomStickyNo)];
            $temp = $stickyquery;
            $stickyquery = null;
            $stickyquery = new WP_Query();
            $stickyquery->query('orderby=rand&showposts=1&p=' . $postno); ?>

            <?php while ($stickyquery->have_posts()) : $stickyquery->the_post(); $do_not_duplicate = $post->ID; ?>
                <div id="sticky-feature">
                    <div id="post-<?php the_ID() ?>" class="<?php thematic_post_class(); ?> sticky-feature-post">

                <?php echo thematic_postheader_posttitle(); ?>

                        <div class="entry-meta">
                <?php if ($af_show_post_title == 'false') { ?>
                            
                <?php } ?>
                        </div>
                <?php if ( has_post_thumbnail() ) { ?>
                        <a href="<?php the_permalink() ?>" rel="bookmark" class="post-image-container"><?php the_post_thumbnail('aflarge'); ?></a>
                <?php } else { ?>
                        <a href="<?php the_permalink() ?>" rel="bookmark" class="post-image-container"><?php the_post_image('aflarge'); ?></a>
                <?php } ?>
                
                        <div class="entry-content">
                <?php the_excerpt(); ?>
                        </div>
                
                        <div class="entry-utility">
                            <?php edit_post_link(__('Edit', 'thematic'), "\t\n\t\t\t\t\t<span class=\"edit-link\">", "</span>\n"); ?>
                        </div><!-- .entry-utility -->
                    </div>
                </div><!-- #sticky-feature -->

            <?php endwhile; ?>

            <?php query_posts(array(
                    'post__not_in' =>get_option('sticky_posts'),
                    'caller_get_posts' => 1,
                    'paged' => $paged,
                    )); ?>

        <?php } ?>
        
    <?php } else { ?>

        <?php query_posts(array(
                'post__not_in' =>get_option('sticky_posts'),
                'caller_get_posts' => 1,
                'exclude' => $postno,
                'paged' => $paged,
                )); ?>

    <?php } ?>

<?php }
add_action('thematic_above_indexloop','af_sticky_area');

//    Custom Post Header
function autofocus_postheader() {
    global $post;
    global $afoptions;
    foreach ($afoptions as $value) {
        if (get_settings( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_settings( $value['id'] ); }
    }

    $data = get_post_meta( $post->ID, 'autofocus', true );

    if (is_page()) { ?>
        <h2 class="entry-title"><?php the_title(); ?></h2>

<?php } elseif (is_404()) { ?>
        <h2 class="entry-title">Not Found</h2>

<?php } elseif (is_single()) { ?>
        
        <?php if ($data[ 'videoembed_value' ]) {  ?>
            <div class="post-video-container">
        <?php $af_video_url = $data[ 'videoembed_value' ]; $content = apply_filters('the_content', '<span>[embed width="800" height="600"]'.$af_video_url.'[/embed]</span>'); echo $content; ?>
            </div>
        
        <?php } else { ?>
            <div class="post-image-container">
            <?php if ($data[ 'copyright_value' ]) {  ?>
                <span class="photo-credit"><?php echo $data[ 'copyright_value' ]; ?></span>
            <?php } else { ?>
                <?php autofocus_credit(); ?>
            <?php } ?>

            <?php if ( has_post_thumbnail() ) { ?>
                    <?php the_post_thumbnail('single-post-thumbnail'); ?>

            <?php } else { ?>
                <?php the_post_image('afsingle'); ?>

            <?php } ?>
            </div>
        <?php } ?>
        
        <h2 class="entry-title"><?php the_title(); ?></h2>

<?php } elseif (is_archive() || is_search()) { ?>

    <?php if ( $post->post_type == 'post' ) { //    Hide entry utility on searches ?>
            
        <?php if ( has_post_thumbnail() ) { ?>
                <a href="<?php the_permalink() ?>" rel="bookmark" class="post-image-container"><?php the_post_thumbnail('archive-thumbnail'); ?></a>
        <?php } else { ?>
                <a href="<?php the_permalink() ?>" rel="bookmark" class="post-image-container"><?php the_post_image('afthumb'); ?></a>
        <?php } ?>

    <?php } ?>                

        <h3 class="entry-title"><a href="<?php the_permalink() ?>" title="<?php printf(__('Permalink to %s', 'thematic'), wp_specialchars(get_the_title(), 1)) ?>" rel="bookmark"><?php the_title(); ?></a></h3>

<?php } else { ?>
        <h2 class="entry-title"><a href="<?php the_permalink() ?>" title="<?php printf(__('Permalink to %s', 'thematic'), wp_specialchars(get_the_title(), 1)) ?>" rel="bookmark"><?php the_title(); ?></a></h2>

<?php } }
add_filter ('thematic_postheader_posttitle', 'autofocus_postheader');

//    AutoFocus Post Meta
function autofocus_postmeta() {
    global $post;
    global $afoptions;
    foreach ($afoptions as $value) {
        if (get_settings( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_settings( $value['id'] ); }
    }

    $data = get_post_meta( $post->ID, 'autofocus', true );

    if (is_single()) { ?>
                <div class="entry-meta">
                    <abbr class="published" title="<?php the_time('Y-m-d\TH:i:sO') ?>"><?php the_time('j M') ?></abbr></span>
                    <?php if ($af_show_exif_data == 'true' && has_post_thumbnail() && ($data[ 'videoembed_value' ] == '')) { ?>
                    <span class="exif-data"><a href="<?php echo exif_link(); ?>/#exif-data"><?php _e('View Exif Data', 'thematic') ?></a></span>
                    <?php } ?>
                    <span class="cat-links"><?php printf(__('Filed under %s.', 'thematic'), get_the_category_list(', ')) ?></span>
                    <?php echo get_the_tag_list("<span class=\"tag-links\"> Tagged ",', ','.</span>'); ?>
                    <?php echo autofocus_postconnect(); ?>
                    <?php edit_post_link(__('Edit', 'thematic'), "\t\n\t\t\t\t\t<span class=\"edit-link\">", "</span>\n"); ?>
                </div>

<?php } elseif (is_home()) { ?>

        <?php if ($af_show_post_title == 'false') { ?>
            <div class="entry-meta">
                <a href="<?php the_permalink() ?>" class="published" title="<?php the_time('Y-m-d\TH:i:sO') ?>" rel="bookmark"><abbr class="published" title="<?php the_time('Y-m-d\TH:i:sO') ?>"><?php the_time('j M') ?></abbr></a></span>
            </div>

        <?php } elseif ($af_show_post_title == 'true') { ?>
            

        <?php } ?>
                
        <?php if ( has_post_thumbnail() ) { ?>
                    <a href="<?php the_permalink() ?>" rel="bookmark" class="post-image-container"><?php the_post_thumbnail('front-page-thumbnail'); ?></a>
        <?php } else { ?>
                    <a href="<?php the_permalink() ?>" rel="bookmark" class="post-image-container"><?php the_post_image('aflarge'); ?></a>
        <?php } ?>
                
<?php } else { ?>
                <div class="entry-meta">
                    <abbr class="published" title="<?php the_time('Y-m-d\TH:i:sO') ?>"><?php the_time('j M') ?></abbr></span>
                    <span class="cat-links"><?php printf(__('Filed under %s.', 'thematic'), get_the_category_list(', ')) ?></span>
                    <span class="comments-link"><?php comments_popup_link(__('No comments.', 'thematic'), __('1 Comment.', 'thematic'), __('% Comments.', 'thematic'), '', '') ?></span>
                    <?php edit_post_link(__('Edit', 'thematic'), "\t\n\t\t\t\t\t<span class=\"edit-link\">", "</span>\n"); ?>
                </div>

<?php } }
add_filter ('thematic_postheader_postmeta', 'autofocus_postmeta');

//    AutoFocus Post Footer
function autofocus_postfooter() {
    global $post; 
 
    if (is_single() || is_page()) {
        if (is_sidebar_active('single-sidebar')) {
            echo thematic_before_widget_area('single-sidebar');
            dynamic_sidebar('single-sidebar');
            echo thematic_after_widget_area('single-sidebar');
        } ?>

    <?php } elseif (is_home()) { ?>
        <div class="entry-utility">
            <?php edit_post_link(__('Edit', 'thematic'), "\t\n\t\t\t\t\t<span class=\"edit-link\">", "</span>\n"); ?>
        </div><!-- .entry-utility -->

    <?php } else {
        //    Show nothing
    }
}
add_filter ('thematic_postfooter', 'autofocus_postfooter');

//    AutoFocus Post Connect
function autofocus_postconnect() { ?>
    <?php printf(__('<span class="bookmark">Bookmark the <a href="%1$s" title="Permalink to %2$s" rel="bookmark">permalink</a>.</span>', 'thematic'),
        get_permalink(),
        wp_specialchars(get_the_title(), 'double') ) ?>
    <?php if ((comments_open()) && (pings_open())) : //    Comments and trackbacks open ?>
            <?php printf(__('<span class="post-a-comment"><a class="comment-link" href="#respond" title="Post a comment">Post a comment</a>.</span> <span class="trackback">Leave a <a class="trackback-link" href="%s" title="Trackback URL for your post" rel="trackback">Trackback (URL)</a>.</span>', 'thematic'), get_trackback_url()) ?>
    <?php elseif (!(comments_open()) && (pings_open())) : //    Only trackbacks open ?>
            <?php printf(__('<span class="trackback">Leave a <a class="trackback-link" href="%s" title="Trackback URL for your post" rel="trackback">Trackback (URL)</a>.</span>', 'thematic'), get_trackback_url()) ?>
    <?php elseif ((comments_open()) && !(pings_open())) : //    Only comments open ?>
            <?php printf(__('<span class="post-a-comment"><a class="comment-link" href="#respond" title="Post a comment">Post a comment</a>.</span>', 'thematic')) ?>
    <?php elseif (!(comments_open()) && !(pings_open())) : //    Comments and trackbacks closed ?>
            <?php // Show nothing ?>
    <?php endif; ?>
<?php }
// add_filter('thematic_postfooter_postconnect', 'autofocus_postconnect');

//    Navigation Below. 
function autofocus_nav_below() { 
    if (is_single()) { ?>
            <div id="nav-below" class="navigation">
                <h3><?php _e('Browse', 'thematic') ?></h3>
        <?php 
            $previouspost = get_previous_post($in_same_cat, $excluded_categories);
            if ($previouspost != null) {
            
            echo '<div class="nav-previous">';
            previous_post_link('<span class="meta-nav">&larr;</span> Older: %link');
            echo '<div class="nav-excerpt">';
            previous_post_excerpt();
            echo '</div></div>';
             } ?>

        <?php 
            $nextpost = get_next_post($in_same_cat, $excluded_categories);
            if ($nextpost != null) {
            
            echo '<div class="nav-next">';
            next_post_link('Newer: %link <span class="meta-nav">&rarr;</span>');
            echo '<div class="nav-excerpt">';
            next_post_excerpt();
            echo '</div></div>';
             } ?>

            </div><!-- #nav-below -->
    
<?php } elseif (browser_ie6() && is_home() ) { ?>
            
            <div id="nav-below" class="navigation">
                <div class="nav-previous"><?php next_posts_link(__('<span class="meta-nav">&larr;</span>', 'thematic')) ?></div>
                <div class="nav-next"><?php previous_posts_link(__('<span class="meta-nav">&rarr;</span>', 'thematic')) ?></div>
            </div>    

<?php } }
add_action('thematic_navigation_below', 'autofocus_nav_below', 2);

//    UNregister non-used sidebars
function childtheme_sidebars_init() {
    
    // Register the 4th Subsidairy Sidebar
    register_sidebar(array(
        'name' => '4th Subsidiary Aside',
        'id' => '4th-subsidiary-aside',
        'description' => __('The 4th widget area in the footer.', 'thematic'),
        'before_widget' => thematic_before_widget(),
        'after_widget' => thematic_after_widget(),
        'before_title' => thematic_before_title(),
        'after_title' => thematic_after_title(),
    ));

    // Register the Single Page Sidebar
    register_sidebar(array(
        'name' => 'Single Page Sidebar',
        'id' => 'single-sidebar',
        'description' => __('This widget area shows up under the post meta on Single Posts and Pages.', 'thematic'),
        'before_widget' => thematic_before_widget(),
        'after_widget' => thematic_after_widget(),
        'before_title' => thematic_before_title(),
        'after_title' => thematic_after_title(),
    ));

    unregister_sidebar('primary-aside');
    unregister_sidebar('secondary-aside');
    unregister_sidebar('index-top');
    unregister_sidebar('index-insert');
    unregister_sidebar('index-bottom');
    unregister_sidebar('single-top');
    unregister_sidebar('single-insert');
    unregister_sidebar('single-bottom');
    unregister_sidebar('page-top');
    unregister_sidebar('page-bottom');
}
add_action( 'init', 'childtheme_sidebars_init',20 );

// Add 4th Sidebar Area
function add_fourth_sidebar() {
    if (is_sidebar_active('4th-subsidiary-aside')) {
        echo thematic_before_widget_area('4th-subsidiary-aside');
        dynamic_sidebar('4th-subsidiary-aside');
        echo thematic_after_widget_area('4th-subsidiary-aside');
    }
}
add_action('thematic_after_third_sub','add_fourth_sidebar');

//    Add a link to the footer for credit
function childtheme_theme_link($themelink) {
    $loginlinkage = thmfooter_login_link();
    return '<a class="child-theme-link" href="http://fthrwght.com/autofocus/" title="AutoFocus Pro" rel="theme">AutoFocus Pro Child Theme</a> &amp; the ' . $themelink . '. ' . $loginlinkage;
}
add_filter('thematic_theme_link', 'childtheme_theme_link');

// Adds commented credit
function author_credit() { ?>
<!-- Design based on AutoFocus Pro by Allan Cole for http://fthrwght.com/autofocusplus -->
<?php }
add_action('wp_footer','author_credit');

?>
 
Zuletzt bearbeitet:
Bilder bitte hier hochladen und danach über das Bild-Icon (Direktlink vorher kopieren) platzieren.
Antworten auf deine Fragen:
Neues Thema erstellen

Willkommen auf PSD-Tutorials.de

In unseren Foren vernetzt du dich mit anderen Personen, um dich rund um die Themen Fotografie, Grafik, Gestaltung, Bildbearbeitung und 3D auszutauschen. Außerdem schalten wir für dich regelmäßig kostenlose Inhalte frei. Liebe Grüße senden dir die PSD-Gründer Stefan und Matthias Petri aus Waren an der Müritz. Hier erfährst du mehr über uns.

Stefan und Matthias Petri von PSD-Tutorials.de

Nächster neuer Gratisinhalt

03
Stunden
:
:
25
Minuten
:
:
19
Sekunden

Flatrate für Tutorials, Assets, Vorlagen

Zurzeit aktive Besucher

Statistik des Forums

Themen
118.611
Beiträge
1.538.341
Mitglieder
67.524
Neuestes Mitglied
BSKGA
Oben