';
$output .= __('The current theme is not an Easel theme; Comic Easel will not load.','comiceasel').' ';
$output .=' ';
$output .='
';
echo $output;
}
add_action( 'admin_notices', 'ceo_no_ceo_theme' );
return;
}
// only load the plugin code of we're in the administration part of WordPress.
@require('ceo-core.php');
@require('functions/admin-meta.php');
} else {
// This style needs to be loaded on all the comic-easel pages inside ceo-core.php instead.
wp_enqueue_style('comiceasel-default-style', ceo_pluginfo('plugin_url').'/css/comiceasel.css');
}
// Flush Rewrite Rules & create chapters
register_activation_hook( __FILE__, 'ceo_flush_rewrite' );
register_deactivation_hook( __FILE__, 'ceo_flush_rewrite' );
function ceo_flush_rewrite() {
global $wp_rewrite;
$wp_rewrite->flush_rules();
}
// Checks chapters, creates them if needs be, checks directories, creates them if need be.
// This does not work yet, its purpose is to generate default chapters if no chapters exist.
function ceo_checkdefaults() {
$checkchapters = get_terms('chapters', 'orderby=count&hide_empty=0');
if (empty($checkchapters)) {
$bookname = stripslashes(__('Book 1', 'comiceasel'));
$bookslug = sanitize_title($bookname);
// Should I check for .. the slug of term or name of term?
if (!term_exists($bookslug, 'chapters')) {
$args = array(
'description' => stripslashes(__('The first book.', 'comiceasel')),
'slug' => $bookslug
);
$returned_book_info = wp_insert_term($bookname, 'chapters', $args);
$parent_term_id = 0;
// should I get term_taxonomy_id ?
// old: if (isset($returned_book_info['term_id'])) $parent_term_id = $returned_book_info['term_id'];
$parent_term = term_exists( $bookslug, 'chapters' ); // array is returned if taxonomy is given
$parent_term_id = $parent_term['term_id']; // get numeric term id
if ($parent_term_id) {
$chaptername = stripslashes(__('Chapter 1', 'comiceasel'));
$chapterslug = sanitize_title($chaptername);
$args = array(
'description' => stripslashes(__('First chapter of Book 1', 'comiceasel')),
'slug' => $chapterslug,
'parent' => $parent_term_id
);
$returned_chapter_info = wp_insert_term($chaptername, 'chapters', $args);
}
}
}
}
// This file handles navigation of the comic
@require('functions/navigation.php');
// This file handles reading the comic from the filesystem and displaying it
@require('functions/displaycomic.php');
// This file contains the functions that are injected into the theme
@require('functions/injections.php');
/**
* This is function ceo_clean_filename
*
* @param string $filename the BASE filename
* @return string returns the rawurlencoded filename with the %2F put back to /
*
*/
function ceo_clean_filename($filename) {
return str_replace("%2F", "/", rawurlencode($filename));
}
/**
* Get the path to the plugin folder.
*/
function ceo_get_plugin_path() {
return PLUGINDIR . '/' . preg_replace('#^.*/([^\/]*)#', '\\1', dirname(plugin_basename(__FILE__)));
}
/**
* These set of functions are for the configuration ceo_pluginfo() information
*
*/
function ceo_load_options($reset = false) {
if ($reset) delete_option('comiceasel-config');
$ceo_config = get_option('comiceasel-config');
if (empty($ceo_config)) {
delete_option('comiceasel-config');
foreach (array(
'comic_folder' => 'comics',
'comic_folder_medium' => 'comics-medium',
'comic_folder_small' => 'comics-small',
'medium_comic_width' => '360',
'small_comic_width' => '200',
'add_dashboard_frumph_feed_widget' => true
) as $field => $value) {
$ceo_config[$field] = $value;
}
add_option('comiceasel-config', $ceo_config, '', 'yes');
}
return $ceo_config;
}
function ceo_pluginfo($whichinfo = null) {
global $ceo_pluginfo;
if (empty($ceo_pluginfo) || $whichinfo == 'reset') {
// Important to assign pluginfo as an array to begin with.
$ceo_pluginfo = array();
$ceo_options = ceo_load_options('reset'); // TEMP: Reset is temporary
$ceo_coreinfo = wp_upload_dir();
// Child and Parent theme directories style = child(or parent), theme = parent
$ceo_addinfo = array(
// if wp_upload_dir reports an error, capture it
'error' => $ceo_coreinfo['error'],
// upload_path-url
'base_url' => trailingslashit($ceo_coreinfo['baseurl']),
'base_path' => trailingslashit($ceo_coreinfo['basedir']),
// Parent theme
'theme_url' => get_template_directory_uri(),
'theme_path' => get_template_directory(),
// Child Theme (or parent if no child)
'style_url' => get_stylesheet_directory_uri(),
'style_path' => get_stylesheet_directory(),
// comic-easel plugin directory/url
'plugin_url' => plugin_dir_url(dirname (__FILE__)) . 'comic-easel',
'plugin_path' => trailingslashit(ABSPATH) . ceo_get_plugin_path(),
// Comic folders
'comic_url' => trailingslashit($ceo_coreinfo['baseurl']) . $ceo_options['comic_folder'],
'comic_path' => trailingslashit($ceo_coreinfo['basedir']) . $ceo_options['comic_folder'],
// Medium Thumbnail Folder
'thumbnail_medium_url' => trailingslashit($ceo_coreinfo['baseurl']) . $ceo_options['comic_folder_medium'],
'thumbnail_medium_path' => trailingslashit($ceo_coreinfo['basedir']) . $ceo_options['comic_folder_medium'],
// Small Thumbnail Folder
'thumbnail_small_url' =>trailingslashit($ceo_coreinfo['baseurl']) . $ceo_options['comic_folder_small'],
'thumbnail_small_path' => trailingslashit($ceo_coreinfo['basedir']) . $ceo_options['comic_folder_small']
);
// Combine em.
$ceo_pluginfo = array_merge($ceo_pluginfo, $ceo_addinfo);
$ceo_pluginfo = array_merge($ceo_pluginfo, $ceo_options);
}
if ($whichinfo && isset($ceo_pluginfo[$whichinfo])) return $ceo_pluginfo[$whichinfo];
return $ceo_pluginfo;
}
/**
* This functions is to display test information on the dashboard, instead of dumping it out to everyone.
* This is so that a plugin doesn't generate errors on output of the var_dump() to the end user.
*/
function ceo_test_information($vartodump) { ?>