Pimping out WordPress
Not all plugins are created equal!
The way I see it, there are plugins and then there are real plugins. The first are only functions or function sets that either hook into or manipulate either the code or the database of WordPress. Real plugins are the same, but they offer fully configurable options as part of the admin area. However, this is not to say that the plain plugins are any less important to the flexibility that they offer the website owner.
The previous list of plugins aren't the full story, some functions I have borrowed, tweaked and/or rewritten and placed in the functions.php file inside of the template, and are loaded as part of that template. Here are those functions:
function time_since($older_date, $newer_date = false){ // array of time period chunks ); // $newer_date will equal false if we want to know the time elapsed between a date and the current time // $newer_date will have a value if we want to work out time elapsed between two known dates // difference in seconds $since = $newer_date - $older_date; // we only want to output two chunks of time here, eg: // x years, xx months // x days, xx hours // so there's only two bits of calculation below: // step one: the first chunk $seconds = $chunks[$i][0]; $name = $chunks[$i][1]; // finding the biggest chunk (if the chunk fits, break) break; endif; } // set output var $output = ($count == 1) ? '1 '.$name : "$count {$name}s"; // step two: the second chunk if ($i + 1 < $j): $seconds2 = $chunks[$i + 1][0]; $name2 = $chunks[$i + 1][1]; // add to output var $output .= ($count2 == 1) ? ', 1 '.$name2 : ", $count2 {$name2}s"; endif; endif; return $output; } function get_parent_category() { global $cat; foreach ((get_the_category()) as $cato): if($cat==$cato->cat_ID): if($cato->category_parent==0): return $cat; else: return $cato->category_parent; endif; endif; endforeach; return $cat; } function get_random_photos($before=" <li>",$after="</li> ",$numPosts="4") { $randposts = get_posts('numberposts='.$numPosts.'&category_name=photos&orderby=rand()'); if ( $randposts ): foreach ( $randposts as $post ): setup_postdata($post); $start = $before.'<a href="'.get_permalink().'" title="Visit ‘'.the_title('','',false).'’">'; $end = "</a>".$after."\n"; endforeach; else: echo "Nothing found"; endif; } function seriocomic_redirect() { $thiscat = get_parent_category(); if ( ($thiscat == '27') && (!is_feed()) && (!is_category()) && (file_exists(TEMPLATEPATH . '/rhetoric.php')) ): load_template(TEMPLATEPATH.'/rhetoric.php'); exit; load_template(TEMPLATEPATH.'/'.$_GET['template'].'.php'); exit; endif; } add_action('template_redirect','seriocomic_redirect'); remove_action('wp_head', 'rsd_link'); remove_action('wp_head', 'wlwmanifest_link'); remove_action('wp_head', 'wp_generator'); }
Permalink to this entry.
- Published:
- 3rd January, 2008
- Last Updated:
- June 1st, 2008
- Tagged With:
- code, enhance, functions, pimping wordpress, plugins, seriocomic, wordpress
- Discuss:
- 2 comments so far on this entry.
Feel free to comment yourself, or trackback from your website.
- Rhetoric Navigation:
- « Rhetoric Reborn Rhetoric Update »
- Possibly Related:
2 comments and counting...
Jump to comment form | comments rss[?]