Skip to content

Commit

Permalink
use core "featured image" instead of homemade stuff
Browse files Browse the repository at this point in the history
use core jQuery
removed obsolete scripts and options
  • Loading branch information
PowerKiKi committed Mar 12, 2011
1 parent 5643cdf commit 6558f16
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 5,103 deletions.
12 changes: 12 additions & 0 deletions grace/functions.php
Expand Up @@ -3,6 +3,18 @@
include(TEMPLATEPATH.'/includes/themeoptions.php');
$cpanel = new Panel();

if ( function_exists( 'add_theme_support' ) ) {
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 280, 140, true);
add_filter( 'post_thumbnail_html', 'my_post_image_html', 10, 3 );

function my_post_image_html( $html, $post_id, $post_image_id ) {

$html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $post_id ) ) . '">' . $html . '</a>';

return $html;
}
}

if ( function_exists('register_sidebar') )
{
Expand Down
28 changes: 13 additions & 15 deletions grace/header.php
Expand Up @@ -5,40 +5,41 @@
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />

<title><?php wp_title('&laquo;', true, 'right'); ?> <?php bloginfo('name'); ?></title>
<?php
if ( is_singular() ) wp_enqueue_script( 'comment-reply' );
wp_enqueue_script('jquery');
wp_head();
?>

<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
<link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" />
<link rel="alternate" type="application/atom+xml" title="<?php bloginfo('name'); ?> Atom Feed" href="<?php bloginfo('atom_url'); ?>" />
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />

<script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/scripts/jquery-1.3.2.js"></script>
<script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/scripts/chili-1.7.pack.js"></script>
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
<script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/scripts/jquery.cycle.all.min.js"></script>
<script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/scripts/jquery.easing.1.2.js"></script>
<script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/scripts/cufon-yui.js"></script>
<script type="text/javascript" src="<?php bloginfo('stylesheet_directory'); ?>/scripts/YDIPaintL_400.font.js"></script>

<?php $theme_options = get_option('Grace'); ?>



<script type="text/javascript">
Cufon.replace('h1');
Cufon.replace('h2');

<?php if ( !is_single() ) : ?>

<?php if (!isset($theme_options["galleryspeed"]) || $theme_options["galleryspeed"] == "default") { $speed = 4000; } else if (!isset($theme_options["galleryspeed"]) || $theme_options["galleryspeed"] == "fast") { $speed = 2000; } else if (!isset($theme_options["galleryspeed"]) || $theme_options["galleryspeed"] == "slow") { $speed = 8000; } ?>
$(function() {
$('#feature').cycle({
<?php
if (!isset($theme_options["galleryspeed"]) || $theme_options["galleryspeed"] == "default") { $speed = 4000; } else if (!isset($theme_options["galleryspeed"]) || $theme_options["galleryspeed"] == "fast") { $speed = 2000; } else if (!isset($theme_options["galleryspeed"]) || $theme_options["galleryspeed"] == "slow") { $speed = 8000; } ?>
jQuery(function() {
jQuery('#feature').cycle({
speed: 1000,
timeout: <?php echo $speed; ?>
});
});

<?php else: ?>
$(function() {
$('#feature').cycle({
jQuery(function() {
jQuery('#feature').cycle({
timeout: 0,
pagerEvent: 'mouseenter',
pagerAnchorBuilder: function(idx, slide) {
Expand All @@ -48,10 +49,7 @@
});
});
<?php endif; ?>
</script>

<?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?>
<?php wp_head(); ?>
</script>
</head>
<body>

Expand Down
19 changes: 8 additions & 11 deletions grace/homepage.php
Expand Up @@ -11,19 +11,16 @@
<?php

$catID = get_cat_id('Featured'); // Get the category ID for the Featured category used to display rotating images on homepage

query_posts('cat='.$catID.''); // Retrieve the latest post from the Featured category

if (have_posts()) : while (have_posts()) : the_post(); // Start the Featured loop

$image = grace_get_featured_image($post);
$imageTag = wp_get_attachment_image($image->ID, 'original', false, array('id' => 'attachment_' . $image->post_name, 'title' => the_title_attribute(array('echo' => false))));
?>
<a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php echo $imageTag; ?></a>
<?php

endwhile; endif; // End the Featured loop

if (have_posts())
{
while (have_posts())
{
the_post(); // Start the Featured loop
if (has_post_thumbnail()) the_post_thumbnail('full', array('title' => ''));
}
}
?>

</div> <!-- feature -->
Expand Down
23 changes: 0 additions & 23 deletions grace/includes/themeoptions.php
Expand Up @@ -2,7 +2,6 @@
class Panel {
var $default_settings = Array(
'galleryspeed' => 'default',
'autothumb' => 'timthumbon',
);

function Panel() {
Expand All @@ -25,16 +24,7 @@ function optionsmenu() {
if (isset($_POST['galleryspeed_act2'])) {
$this->options['galleryspeed'] = $_POST['galleryspeed_act2'];
}
else { $this->options['colorscheme'] = 'default'; }


if (isset($_POST['autothumb_act2'])) {
$this->options['autothumb'] = $_POST['autothumb_act2'];
}
else { $this->options["autothumb"] = "timthumbon"; }

update_option('Grace', $this->options);

}
?>

Expand Down Expand Up @@ -64,19 +54,6 @@ function optionsmenu() {
</select>
</td>
</tr>
<!-- -->
<tr>
<td>
<strong>Automatic Thumbnails</strong><br />
Select whether to use automatic thumbnails. By default these are switched on.
</td>
<td>
<select name="autothumb_act2" id="autothumb_act2">
<option value="timthumbon" <?php if ($this->options["autothumb"] == "timthumbon") { echo "selected"; }?>>Auto Thumbnails On</option>
<option value="timthumboff" <?php if ($this->options["autothumb"] == "timthumboff") { echo "selected"; }?>>Auto Thumbnails Off</option>
</select>
</td>
</tr>
</tbody>
</table>
<p class="submit" style="text-align: right; border: none; margin: 0 0 20px 0;"><input type="submit" value="Update Options" name="save" /></p>
Expand Down
69 changes: 29 additions & 40 deletions grace/includes/thumbs.php
@@ -1,43 +1,32 @@
<?php
if (have_posts()) :
$i = 1; // set variable used to control which style is applied to thumbnail
while (have_posts()) :
the_post();

// check if $i is divisible by 2 with no remainder then apply style to variable $c
if ($i % 2 == 0)
{
$c = ' class="alt"';
}
else
{
$c = '';
}

// retreive thumbnail custom field value
?>
<li<?php echo $c ?>>
<?php

$i = 1; // set variable used to control which style is applied to thumbnail

if (have_posts()) : while (have_posts()) : the_post(); // check if there are any posts

if ($i % 2 == 0) { // check if $i is divisible by 2 with no remainder then apply style to variable $c
$c = ' class="alt"';
} else {
$c = '';
}

$post_id = $post->ID;
$single = true;


$image = grace_get_featured_image($post);
$theme_options = get_option('Grace');
if (true ||!isset($theme_options["autothumb"]) || $theme_options["autothumb"] == "timthumbon")
{
$info = wp_get_attachment_image_src($image->ID, 'original');
$thumbnail_value = '<img src="' . get_bloginfo('template_directory') . '/scripts/timthumb.php?src=' . $info[0] . '&w=280&h=140&zc=1" title="' . get_the_title() . '" alt="' . get_the_title() . '" />';
}
else
{
$thumbnail_value = wp_get_attachment_image($image->ID, 'medium', false, array('alt' => get_the_title(), 'title' => get_the_title()));
}

if ( $thumbnail_value ) : // retreive thumbnail custom field value

if (has_post_thumbnail()):
the_post_thumbnail('post-thumbnail', array('title' => '') );
else:
?><a href="<?php the_permalink() ?>"><strong><?php the_title(); ?></strong></a><br/><?php the_excerpt();
endif;
?>
</li>

<li<?php echo $c ?>>
<a href="<?php the_permalink() ?>">
<?php echo $thumbnail_value; ?>
</a>
</li>

<?php $i++; else :?>

<li<?php echo $c ?>><a href="<?php the_permalink() ?>"><strong><?php the_title(); ?></strong></a><br/><?php the_excerpt(); ?></li>

<?php $i++; endif; endwhile; endif; ?>
<?php
$i++;
endwhile;
endif;
Binary file not shown.
Binary file not shown.
Binary file not shown.
24 changes: 0 additions & 24 deletions grace/scripts/chili-1.7.pack.js

This file was deleted.

0 comments on commit 6558f16

Please sign in to comment.