Skip to content

Commit

Permalink
Dokumentation och funktioner för att fixa rss flödet
Browse files Browse the repository at this point in the history
  • Loading branch information
rickard2 committed Mar 4, 2012
1 parent 41db6ff commit a1f6d89
Show file tree
Hide file tree
Showing 2 changed files with 101 additions and 2 deletions.
2 changes: 1 addition & 1 deletion comments.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<section class="comments-wrapper">
<section id="comments" class="comments-wrapper">

<h1>Kommentarer</h1>

Expand Down
101 changes: 100 additions & 1 deletion functions.php
Original file line number Diff line number Diff line change
@@ -1,34 +1,99 @@
<?php
/**
* Piratpartied WordPress Theme
* @version 1.0
* @author Rickard Andersson <[email protected]>
*/


/**
* Main class for the theme
* @since 1.0
*/
class Piratpartiet {

/**
* Theme name and directory name
* @var string
*/
private $plugin_name = "piratpartiet";

/**
* Initializes the theme functionality
*/
function __construct() {

// Initializing functions
add_action('init', array( $this, 'init_assets') );
add_action('init', array( $this, 'init_menus') );
add_action('init', array( $this, 'init_sidebars') );

// Enable post thumbnails and set the size to 190x190
add_theme_support('post-thumbnails');
set_post_thumbnail_size( 190, 190 );

// This theme has custom header support, this function will enable it
$this->custom_header_support();

// Change some excerpt settings
add_filter('excerpt_more', array($this, 'excerpt_more'));
add_filter('excerpt_length', array($this, 'excerpt_length'), 999);

// Filters for adding the featured image to the rss feed, only applies to sub-blogs. The main blog
// is fetching the content from RSS and the images are already included there.
if ( !class_exists('PP_Ettan')) {
add_filter('the_excerpt_rss', array($this, 'featured_image_rss') );
add_filter('the_content_feed', array($this, 'featured_image_rss') );
}
}

/**
* Adds the featured image to the rss feed
* @param $content
* @return string
* @since 1.0
*/
function featured_image_rss($content) {

global $post;

if ( has_post_thumbnail( $post->ID ) ) {

$thumbnail = '<figure class="alignleft">';
$thumbnail .= get_the_post_thumbnail( $post->ID, 'thumbnail' );
$thumbnail .= '</figure>';

$content = $thumbnail . $content;
}

return $content;
}

/**
* Attached to the filter excerpt_length
* @param $length
* @return int
* @since 1.0
*/
function excerpt_length( $length ) {
return 86;
}

/**
* Attached to the filter excerpt_more
* @param $more
* @return string
* @since 1.0
*/
function excerpt_more($more) {
global $post;
return '... <a href="'. get_permalink($post->ID) .'">Läs mer</a>';
}

/**
* Adds custom header support for this theme
* @since 1.0
* @return void
*/
function custom_header_support() {

add_custom_image_header( array($this, 'custom_header_style'), null );
Expand All @@ -40,12 +105,22 @@ function custom_header_support() {
define('NO_HEADER_TEXT', true );
}

/**
* Needed function for the custom header
* @since 1.0
* @return void
*/
function custom_header_style() {
?><style type="text/css">
#banner { background-image: url(<?php header_image(); ?>); }
</style><?php
}

/**
* Initialize the sidebars
* @since 1.0
* @return void
*/
function init_sidebars() {

$args = array(
Expand Down Expand Up @@ -97,10 +172,20 @@ function init_sidebars() {
register_sidebar($args);
}

/**
* Initialize the menus
* @since 1.0
* @return void
*/
function init_menus() {
register_nav_menu('main', __('PP Huvudmeny'));
}

/**
* Initialize javascript and stylesheets
* @since 1.0
* @return void
*/
function init_assets() {

// Only enqueue files on the public part of the page
Expand All @@ -121,8 +206,15 @@ function init_assets() {
}
}

// Load the theme
new Piratpartiet();

/**
* Get the swedish month name
* @param int $month
* @return string
* @since 1.0
*/
function month_sv($month) {

$month = intval($month);
Expand Down Expand Up @@ -237,6 +329,13 @@ function end_el(&$output, $comment, $depth, $args) {
}
}

/**
* Improved comment form
* @param array $args
* @param int $post_id
* @since 1.0
* @return void
*/
function pp_comment_form( $args = array(), $post_id = null ) {
global $id;

Expand Down

0 comments on commit a1f6d89

Please sign in to comment.