style = get_option('hem_style');
}
function date_format($slashes = false){
global $hemingwayEx_options;
if ($slashes)
return $hemingwayEx_options['international_dates'] == 1 ? 'd/m' : 'm/d';
else
return $hemingwayEx_options['international_dates'] == 1 ? 'd.m' : 'm.d';
}
// Excerpt cutting. I'd love to use the_excerpt_reloaded, but needless licensing prohibits me from doing so
function excerpt(){
echo $this->get_excerpt();
}
function get_excerpt(){
global $post;
global $hemingwayEx_options;
//modified by Nalin. Added option to allow user to specify length of excerpt
if (!is_null($hemingwayEx_options['excerpt_length'])
|| $hemingwayEx_options['excerpt_length'] != 0 ) {
$max_length = $hemingwayEx_options['excerpt_length'];
} else {
$max_length = 75; // Maximum words.
}
// If they've manually put in an excerpt, let it go!
if ($post->post_excerpt) return $post->post_excerpt;
// Check to see if it's a password protected post
if ($post->post_password) {
if ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) {
if(is_feed()) {
return __('This is a protected post');
} else {
return get_the_password_form();
}
}
}
if( strpos($post->post_content, '') ) { // There's a more link
$temp_ex = explode('', $post->post_content, 2);
$excerpt = $temp_ex[0];
} else {
$temp_ex = explode(' ', $post->post_content); // Split up the spaces
$length = count($temp_ex) < $max_length ? count($temp_ex) : $max_length;
for ($i=0; $i<$length; $i++) $excerpt .= $temp_ex[$i] . ' ';
}
$excerpt = balanceTags($excerpt);
$excerpt = apply_filters('the_excerpt', $excerpt);
return $excerpt;
}
}
$hemingwayEx = new HemingwayEx();
$hemingwayEx->version = "1.5";
$hemingwayEx->date = "2008-09-03";
// Default Options. Used only when HemingwayEx is not installed or a newer version is available
$default_options = Array(
'international_dates' => 0,
'excerpt_length' => 75,
'asc_comments' => 1,
'page_comments' => 1,
'slidebar_enabled' => 1,
'bottombar_enabled' => 1,
'post_navigation' => 0,
'excerpt_enabled' => 1,
'font_resizer' => 1,
'paging_enabled' => 0,
);
if (!get_option('hem_version') || get_option('hem_version') < $hemingwayEx->version){
// HemingwayEx isn't installed, so we'll need to add options
if (!get_option('hem_version') )
add_option('hem_version', $hemingwayEx->version, 'Hemingway Version installed');
else
update_option('hem_version', $hemingwayEx->version);
if (!get_option('hem_last_updated'))
add_option('hem_last_updated', '0000-00-00', 'Last date HemingwayEx was checked for an update');
if (!get_option('hem_known_update'))
add_option('hem_known_update', '0000-00-00', 'Last known date when HemingwayEx update was released');
if (!get_option('hem_style'))
add_option('hem_style', '', 'Location of custom style sheet');
if (!get_option('hem_options')) {
add_option('hem_options', $default_options, 'Default options for HemingwayEx');
}
wp_cache_flush(); // I was having caching issues
}
// Stuff
add_action ('admin_menu', 'hemingway_menu');
$hem_loc = '../themes/' . basename(dirname($file));
$hemingwayEx_options = get_option('hem_options');
$hemingwayEx_last_updated = get_option('hem_last_updated');
$hemingwayEx->get_style();
// Ajax Stuff
function hemingwayEx_message($message) {
echo "
\n";
}
function hemingwayEx_update_version() {
global $hemingwayEx;
$known_update = get_option('hem_known_update');
$found_update = "";//$known_update;
// check for new versions if it's been a week
if (strcmp(date("Y-m-d", time() - 7 * 24 * 60 * 60), get_option('hem_last_updated')) > 0) {
// collects only publicly-available stats
$stats = Array(
'php' => PHP_VERSION,
'server' => $_SERVER['SERVER_SOFTWARE'],
'blog' => 'Wordpress',
'version' => get_bloginfo('version'),
'url' => get_bloginfo('wpurl'),
'locale' => WPLANG,
);
$args = array();
foreach($stats as $key => $value) {
$args[] = $key . '=' . urlencode($value);
}
$args = implode('&', $args);
// load wp rss functions for update checking.
if (!function_exists('parse_w3cdtf')) {
require_once(ABSPATH . WPINC . '/rss-functions.php');
}
// note the updating and fetch potential updates
update_option('hem_last_updated', date("Y-m-d"));
$update = fetch_rss("http://nalinmakar.com/tag/hemingwayex/feed?$args");
if ($update === False) {
hemingwayEx_message(__('HemingwayEx tried to check for updates but failed. This might be the way PHP is set up, or just random network issues. Please visit the HemingwayEx website to update manually if needed.', 'hemingwayEx'));
return;
}
// loop through feed, pulling out any updates
foreach($update->items as $item) {
$updates = Array();
if (preg_match('||', $item['content']['encoded'], $updates)) {
// if this is the newest update, save it
if ($updates[1] > $found_update) {
$found_update = $updates[1];
$version = $updates[2];
}
}
}
// if an newer update was found, save it
if (strcmp($found_update, $known_update) > 0)
update_option('hem_known_update', $found_update);
// if the best-known update is newer than this ver, tell user
if (strcmp($found_update, $hemingwayEx->date) > 0)
hemingwayEx_message(__('An update of HemingwayEx is available as of ', 'hemingwayEx') . $found_update . __('. Download HemingwayEx ', 'hemingwayEx') . $version . '.');
}
}
function hemingway_menu() {
add_submenu_page('themes.php', 'HemingwayEx Options', 'HemingwayEx Options', 5, $hem_loc . 'functions.php', 'menu');
}
function menu() {
global $hem_loc, $hemingwayEx, $message, $hemingwayEx_options;
if ($_POST['custom_styles']){
update_option('hem_style', $_POST['custom_styles']);
wp_cache_flush();
$message = __('Styles updated!','hemingwayex');
}
if ($_POST['reset'] == 1){
delete_option('hem_style');
delete_option('hem_blocks');
delete_option('hem_version');
delete_option('hem_options');
delete_option('hem_known_update');
delete_option('hem_last_updated');
$message = __('Settings removed.','hemingwayex');
}
if ($_POST['misc_options']){
$hemingwayEx_options['international_dates'] = $_POST['international_dates'];
$hemingwayEx_options['excerpt_length'] = $_POST['excerpt_length'];
$hemingwayEx_options['asc_comments'] = $_POST['asc_comments'];
$hemingwayEx_options['page_comments'] = $_POST['page_comments'];
$hemingwayEx_options['slidebar_enabled'] = $_POST['slidebar_enabled'];
$hemingwayEx_options['bottombar_enabled'] = $_POST['bottombar_enabled'];
$hemingwayEx_options['excerpt_enabled'] = $_POST['excerpt_enabled'];
$hemingwayEx_options['post_navigation'] = $_POST['post_navigation'];
$hemingwayEx_options['font_resizer'] = $_POST['font_resizer'];
$hemingwayEx_options['paging_enabled'] = $_POST['paging_enabled'];
update_option('hem_options', $hemingwayEx_options);
wp_cache_flush();
$message = __('Options updated!','hemingwayex');
}
?>
HemingwayEx checks for new versions when you bring up this page. (At most once per week.)
This copy of HemingwayEx is version version; ?> released on date; ?>.
date) > 0) { ?>
There is an update available as of . HemingwayEx.
You have the latest version installed.
Last checked on .
'Slidebar Left',
'before_widget' => '
',
'after_widget' => '',
'before_title' => '
',
'after_title' => '
',
));
register_sidebar(array(
'name'=>'Slidebar Center',
'before_widget' => '
',
'after_widget' => '',
'before_title' => '
',
'after_title' => '
',
));
register_sidebar(array(
'name'=>'Slidebar Right',
'before_widget' => '
',
'after_widget' => '',
'before_title' => '
',
'after_title' => '
',
));
}
if ($hemingwayEx_options['bottombar_enabled'] == 1){
register_sidebar(array(
'name'=>'Bottombar Left',
'before_widget' => '
',
'after_widget' => '',
'before_title' => '
',
'after_title' => '
',
));
register_sidebar(array(
'name'=>'Bottombar Center',
'before_widget' => '
',
'after_widget' => '',
'before_title' => '
',
'after_title' => '
',
));
register_sidebar(array(
'name'=>'Bottombar Right',
'before_widget' => '
',
'after_widget' => '',
'before_title' => '
',
'after_title' => '
',
));
}
}
?>