Skip to content

Commit

Permalink
readded moods in core
Browse files Browse the repository at this point in the history
  • Loading branch information
kniebremser committed Sep 13, 2015
1 parent 51dbe30 commit f1865e4
Show file tree
Hide file tree
Showing 45 changed files with 151 additions and 3 deletions.
1 change: 0 additions & 1 deletion content.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
easel_display_post_title();
if (!easel_is_bbpress()) easel_display_post_calendar();
if (is_sticky()) { ?><div class="sticky-image">Featured Post</div><?php }
/* Integrate of the deprecated function easel_show_mood_in_post */
if (function_exists('easel_show_mood_in_post')) easel_show_mood_in_post();
?>
<div class="post-text">
Expand Down
3 changes: 3 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,9 @@ function easel_load_options() {
'enable_jetpack_infinite_scrolling' => false,
'content_width' => 500,
'content_width_disabled_sidebars' => 700,
'add_pw_async_code_to_head' => false,
'over-blog-sidebar-all-posts' => false,
'moods_directory' => 'none'
) as $field => $value) {
$easel_options[$field] = $value;
}
Expand Down
1 change: 0 additions & 1 deletion functions/displaypost.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ function easel_display_post() {
if (!easel_is_bbpress()) easel_display_author_gravatar();
if (!easel_is_bbpress()) easel_display_post_calendar();
if (is_sticky()) { ?><div class="sticky-image">Featured Post</div><?php }
/* Integrate of the deprecated function easel_show_mood_in_post */
if (function_exists('easel_show_mood_in_post')) easel_show_mood_in_post();
?>
<div class="post-text">
Expand Down
113 changes: 113 additions & 0 deletions functions/moods.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
<?php
/**
* Theme Function: Moods
* Author: Philip M. Hofer (Frumph)
* Created: 08/22/2009
* Author Email: [email protected]
* You may use this and adapt this code to anything you like however keep the author information retained in
* the appropriate files.
*
* Lets you set and make moods for your blog posts.
*
* Usage: if (function_exists('easel_show_mood_in_post')) easel_show_mood_in_post();
*
* Edit a post and it you will see the possible moods you can use, select one.
*
*/


add_action('admin_menu', 'mood_admin_function');
add_action('save_post', 'easel_handle_edit_post_mood_save' ,5, 1);
add_action('add_meta_boxes', 'easel_add_moods_into_posts');

function easel_add_moods_into_posts() {
global $post;
if (!empty($post) && ($post->post_type == 'comic' || $post->post_type == 'post')) {
add_meta_box('easel_showmood_edit_post', __('Moods', 'comiceasel'), 'easel_showmood_edit_post', 'post', 'normal', 'low');
}
}


function easel_show_mood_in_post() {
global $post;
$moods_directory = easel_themeinfo('moods_directory');
if (!empty($moods_directory) && $moods_directory != 'none') {
$mood_file = get_post_meta( get_the_ID(), "mood", true );
if (!empty($mood_file) && $mood_file != '') {
$mood = explode(".", $mood_file);
$mood = reset($mood);
if ( !empty($mood_file) && file_exists(get_stylesheet_directory() . '/images/moods/'.$moods_directory.'/'.$mood_file) ) { ?>
<div class="post-mood post-<?php echo $mood; ?>"><img src="<?php echo get_stylesheet_directory_uri(); ?>/images/moods/<?php echo $moods_directory; ?>/<?php echo $mood_file; ?>" alt="<?php echo $mood; ?>" title="<?php echo $mood; ?>" /></div>
<?php } elseif (!empty($mood_file) && file_exists(get_template_directory() . '/images/moods/' .$moods_directory . '/' . $mood_file) ) { ?>
<div class="post-mood post-<?php echo $mood; ?>"><img src="<?php echo get_template_directory_uri(); ?>/images/moods/<?php echo $moods_directory; ?>/<?php echo $mood_file; ?>" alt="<?php echo $mood; ?>" title="<?php echo $mood; ?>" /></div>
<?php }
}
}
}

function easel_showmood_edit_post() {
global $post;
$moods_directory = easel_themeinfo('moods_directory');
if (!empty($moods_directory) && $moods_directory != 'none') { ?>
<div class="inside" style="overflow: hidden">
<?php _e('Available Moods, you can set which mood images to use in the easel Options.','easel'); ?><br />
<br />
<?php

$currentmood = get_post_meta( $post->ID, "mood", true );

if (empty($currentmood) || $currentmood == '' || $currentmood == null) {
$mood = __('none','easel');
} else {
$mood = explode(".", $currentmood);
$mood = reset($mood);
}

$count = 0;
$count = count($results = glob(get_stylesheet_directory() . '/images/moods/'.$moods_directory.'/*'));
if (!$count) {
$count = count($results = glob(get_template_directory() . '/images/moods/'.$moods_directory.'/*'));
$moods_uri = get_template_directory_uri();
} else {
$moods_uri = get_stylesheet_directory_uri();
}
echo $count .__(' moods are available.','easel').'<br />
'.__('Using Moods from directory: ','easel').$moods_directory.'<br />
'.__('Current Mood: ','easel').$mood.'<br /><br />';
if (!empty($results)) { ?>
<div style="float:left; margin-top: 70px; text-align: center; width: 68px; overflow: hidden;">
<label for="postmood-none" style="cursor:pointer;">
none
</label>
<br />
<input name="postmood" style="margin-top: 3px;" id="postmood-anger" type="radio" value="none" <?php if ( $mood == 'none' ) { echo " checked"; } ?> />
</div>
<?php foreach ($results as $file) {
$newmood_file = basename($file);
$newmood = explode(".", $newmood_file);
$newmood = $newmood[0]; ?>
<div style="float:left; margin-top: 10px; text-align: center; width: 68px; overflow: hidden;">
<label for="postmood-<?php echo $newmood; ?>" style="cursor:pointer;">
<img src="<?php echo $moods_uri; ?>/images/moods/<?php echo $moods_directory; ?>/<?php echo basename($file); ?>" /><br />
<?php echo $newmood; ?>
</label>
<br />
<input name="postmood" style="margin-top: 3px;" id="postmood-<?php echo $newmood; ?>" type="radio" value="<?php echo $newmood_file; ?>"<?php if ( $mood == $newmood ) { echo " checked"; } ?> />
</div>
<?php }
} ?>
</div>
<?php }
}


function easel_handle_edit_post_mood_save($post_id) {
$moods_directory = easel_themeinfo('moods_directory');
if (!empty($moods_directory) && $moods_directory != 'none') {
$currentmood = get_post_meta( $post_id, "mood", true );
if (isset($_POST['postmood']) && $_POST['postmood'] !== $currentmood) {
$postmood = $_POST['postmood'];
update_post_meta($post_id, 'mood', $postmood);
}
}
}
Binary file added images/moods/default/anger.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/moods/default/angry.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/moods/default/awe.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/moods/default/burn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/moods/default/confused.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/moods/default/cool.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/moods/default/coolglare.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/moods/default/crazy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/moods/default/cry.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/moods/default/crying.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/moods/default/dizzy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/moods/default/embarrass.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/moods/default/fire.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/moods/default/grimace.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/moods/default/happy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/moods/default/love.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/moods/default/lust.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/moods/default/miao.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/moods/default/morequestions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/moods/default/music.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/moods/default/ninja.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/moods/default/normal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/moods/default/ooo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/moods/default/prettiness.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/moods/default/pwnburn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/moods/default/question.png
Binary file added images/moods/default/shout.png
Binary file added images/moods/default/shy.png
Binary file added images/moods/default/silent.png
Binary file added images/moods/default/sleep.png
Binary file added images/moods/default/slobber.png
Binary file added images/moods/default/smile.png
Binary file added images/moods/default/spook.png
Binary file added images/moods/default/startle.png
Binary file added images/moods/default/surprise.png
Binary file added images/moods/default/sweat.png
Binary file added images/moods/default/tears.png
Binary file added images/moods/default/thirst.png
Binary file added images/moods/default/vomit.png
1 change: 1 addition & 0 deletions options.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ function easel_admin_options() { ?>
}

foreach (array(
'moods_directory',
'avatar_directory',
'home_post_count',
'copyright_name',
Expand Down
35 changes: 34 additions & 1 deletion options/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,40 @@
<td>
<?php _e( 'Checkmarking this will make it so that it will show when the last time that the post was modified in the post date information.', 'easel' ); ?>
</td>
</tr>
</tr>
<?php
$current_directory = comicpress_themeinfo('moods_directory');
if (empty($current_directory)) $current_directory = 'default';
$dirs_to_search = array_unique(array(get_template_directory(), get_stylesheet_directory()));
$mood_directories = array();
foreach ($dirs_to_search as $moodir) {
if (is_dir($moodir . '/images/moods')) {
$thisdir = null;
$thisdir = array();
$thisdir = glob($moodir. '/images/moods/*');
$mood_directories = array_merge($mood_directories, $thisdir);
}
}
?>
<tr class="alternate">
<th scope="row" colspan="2">
<label for="moods_directory"><?php _e('Moods Directory','comicpress'); ?></label>
<select name="moods_directory" id="moods_directory">
<option class="level-0" value="none" <?php if ($current_directory == "none") { ?>selected="selected"<?php } ?>><?php _e( 'none', 'comicpress' ); ?></option>
<?php
foreach ($mood_directories as $mood_dirs) {
if (is_dir($mood_dirs)) {
$mood_dir_name = basename($mood_dirs); ?>
<option class="level-0" value="<?php echo $mood_dir_name; ?>" <?php if ($current_directory == $mood_dir_name) { ?>selected="selected"<?php } ?>><?php echo $mood_dir_name; ?></option>
<?php }
}
?>
</select>
</th>
<td>
<?php _e('Choose a directory to get the post moods from. Set this to <strong>none</strong> to turn off use. Mood directories are found in your theme directory/images/moods/* . To create your own custom moods just create a directory under images/moods/ and place ONLY image files inside of it. The name of the image file represents what the mood is.','comicpress'); ?>
</td>
</tr>
</table>

<table class="widefat">
Expand Down

0 comments on commit f1865e4

Please sign in to comment.