Permalink
Browse files

New page option to disable sidebars on pages via the page-editor, tot…

…al rewrite of layout-head and layout-foot completely optimizing performance, added 3 new layouts as well while doing it.

Removed #pagewrap-right and #pagewrap-left in exchange for .area-wrap to handle the wraps of the GN layouts

Changed the way the functions.php handles certain variables that were global to see if I could release some overhead memory

Signed-off-by: Philip M. Hofer (Frumph) <frumph_dragon@yahoo.com>
  • Loading branch information...
1 parent 7804484 commit 117facab28686f99afd826854db7e68d88f9ab9c Philip M. Hofer (Frumph) committed Jan 26, 2011
View
@@ -0,0 +1,49 @@
+<?php
+// page options - extra page options for comicpress, shown in a meta box in the page editor
+
+function comicpress_page_editor_options($post) {
+?>
+<div class="inside" style="overflow: hidden">
+ <?php
+ wp_nonce_field( 'comicpress_post_options-'.$post->ID, 'comicpress-update-page-options' );
+ $disable_sidebars = get_post_meta($post->ID, 'disable-sidebars', true);
+ ?>
+ <table>
+ <td valign="top">
+ <input id="comicpress_sidebar_remove" name="comicpress_sidebar_remove" type="checkbox" value="1"<?php echo $disable_sidebars ? ' checked="checked"' : ''; ?> /> Disable Sidebars
+ </td>
+ </tr>
+ </table>
+</div>
+<?php
+}
+add_action('add_meta_boxes', 'comicpress_add_page_editor_meta_box');
+
+function comicpress_add_page_editor_meta_box() {
+ add_meta_box('comicpress-page-options', __('ComicPress Page Options', 'comicpress'), 'comicpress_page_editor_options', 'page', 'side', 'high');
+}
+
+function comicpress_save_page_editor_options($post_id) {
+ if (isset($_POST['comicpress-update-page-options']) && !wp_verify_nonce( $_POST['comicpress-update-page-options'], 'comicpress_post_options-'.$post_id )) {
+ return $post_id;
+ }
+ if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
+ return $post_id;
+ if ( $_POST['post_type'] == 'page' ) {
+ if ( !current_user_can( 'edit_page', $post_id ) )
+ return $post_id;
+ } else {
+ if ( !current_user_can( 'edit_post', $post_id ) )
+ return $post_id;
+ }
+
+ if (isset($_POST['comicpress_sidebar_remove'])) {
+ update_post_meta($post_id, 'disable-sidebars', '1');
+ } else {
+ delete_post_meta($post_id, 'disable-sidebars');
+ }
+ return $post_id;
+}
+add_action('save_post', 'comicpress_save_page_editor_options');
+
+?>
View
@@ -3,7 +3,7 @@
Template Name: Comic Year Archive
*/
get_header();
-
+Protect();
if (isset($_GET['archive_year'])) {
$archive_year = (int)$_GET['archive_year'];
} else {
@@ -71,4 +71,7 @@
</div>
<div class="post-foot"></div>
</div>
-<?php get_footer() ?>
+<?php
+UnProtect();
+get_footer();
+?>
View
@@ -1,9 +1,11 @@
-2.9.2.29.2
+2.9.2.30
Fixed the issue with the comic navigation widget text boxes not properly escaping and unescapping strings
moved the facebook like script to load in the header to avoid a script error
fixed the reply to javascript to show apparently it doesnt like is_singular, go figure
displaying category list properly now, instead of multiple
removed trailingslashit from around $comic in displaycomic.php line #350, thanks @nismorack
+added easels disable sidebars on page options
+moved some data placement around to try to optimize usage
2.9.2.29.1
$is_comic needed to be set in the archive.php before hand, was giving notice
View
@@ -123,7 +123,8 @@ function comicpress_admin_options() {
'blogposts_with_comic',
'static_blog',
'disable_page_titles',
- 'disable_post_titles'
+ 'disable_post_titles',
+ 'enable_page_options'
) as $key) {
if (!isset($_REQUEST[$key])) $_REQUEST[$key] = 0;
$comicpress_options[$key] = (bool)( $_REQUEST[$key] == 1 ? true : false );
View
@@ -1,5 +1,4 @@
<?php
-
/* DEFINES */
// xili-language plugin check
@@ -21,33 +20,6 @@
if (!isset($content_width)) $content_width = 520;
-global $comiccat, $blogcat, $comic_folder, $rss_comic_folder, $archive_comic_folder, $mini_comic_folder,
-$archive_comic_width, $rss_comic_width, $mini_comic_width, $blog_postcount;
-
-if (is_multisite()) {
- // This section keeps it compatible with comicpress manager's options
- $variables_to_extract = array();
-
- foreach (array(
- 'comiccat' => 'comiccat',
- 'blogcat' => 'blogcat',
- 'comics_path' => 'comic_folder',
- 'comicsrss_path' => 'rss_comic_folder',
- 'comicsarchive_path' => 'archive_comic_folder',
- 'comicsmini_path' => 'mini_comic_folder',
- 'archive_comic_width' => 'archive_comic_width',
- 'rss_comic_width' => 'rss_comic_width',
- 'mini_comic_width' => 'mini_comic_width',
- 'blog_postcount' => 'blog_postcount') as $options => $variable_name) {
- $variables_to_extract[$variable_name] = get_option("comicpress-${options}");
- }
-
- extract($variables_to_extract);
-
-} else {
- @require_once( get_template_directory() . '/comicpress-config.php');
-}
-
/* child-functions.php / child-widgets.php - in the child theme */
get_template_part('child', 'functions');
get_template_part('child', 'widgets');
@@ -103,7 +75,8 @@ function comicpress_config() {
@require_once(get_template_directory() . '/addons/relatedposts.php');
if (comicpress_themeinfo('facebook_meta') || comicpress_themeinfo('facebook_like_comic_post') || comicpress_themeinfo('facebook_like_comic_post'))
@require_once(get_template_directory() . '/addons/facebook.php');
-
+if (comicpress_themeinfo('enable_page_options'))
+ @require_once(get_template_directory() . '/addons/page-options.php');
// Dashboard Menu Comicpress Options and ComicPress CSS
if (is_admin()) {
@require_once(get_template_directory() . '/comicpress-admin.php');
@@ -152,8 +125,7 @@ function comicpress_sidebar_init() {
// put things in here that need to go into the init ONLY
function __comicpress_init() {
- global $wp_query, $comiccat, $blogcat, $comic_folder, $rss_comic_folder, $archive_comic_folder,
- $archive_comic_width, $rss_comic_width, $mini_comic_width, $blog_postcount, $content_width;
+ global $wp_query;
// initiate the scripts
if (!is_admin()) {
@@ -186,7 +158,7 @@ function __comicpress_init() {
wp_enqueue_script('bookmark', get_template_directory_uri() . '/js/bookmark.js', array('prototype', 'cookiejar'));
}
if (is_active_widget('comicpress_facebook_like_widget', false, 'comicpress_facebook_like_widget', true) || comicpress_themeinfo('facebook_like_blog_post') || comicpress_themeinfo('facebook_like_comic_post'))
- wp_enqueue_script('easel-facebook', 'http://connect.facebook.net/en_US/all.js#xfbml=1'); // force to the header instead of footer
+ wp_enqueue_script('comicpress-facebook', 'http://connect.facebook.net/en_US/all.js#xfbml=1'); // force to the header instead of footer
}
do_action('comicpress_init');
@@ -230,7 +202,6 @@ function comicpress_add_head() {
<?php }
}
-
if (!function_exists('is_cp_theme_layout')) {
function is_cp_theme_layout($choices) {
$choices = explode(",", $choices);
@@ -245,7 +216,7 @@ function is_cp_theme_layout($choices) {
function is_cp_layout_avail($layout, $avail_layouts) {
if (empty($layout)) return false;
- if (empty($avail_layouts)) $avail_layouts = 'standard,v,3c,3c2r,v3c,v3cr,gn,rgn';
+ if (empty($avail_layouts)) $avail_layouts = '2cr,2cl,2cvr,2cvl,3c,3c2r,3c2l,v3c,v3cr,v3cl,lgn,rgn';
$avail_layouts = explode(",",$avail_layouts);
foreach ($avail_layouts as $able_layout) {
if ($layout == $able_layout) {
@@ -268,7 +239,7 @@ function comicpress_stripslashes($str_to_strip) {
return $str_to_strip;
}
-function comicpress_clean_filename($filename) {
+function comicpress_clean_url($filename) {
return str_replace("%2F", "/", rawurlencode($filename));
}
@@ -299,7 +270,7 @@ function comicpress_in_comic_category($cat = null) {
* Parse all categories and sort them into comics and non-comics categories.
*/
function comicpress_create_category_tree() {
- global $category_tree, $comiccat;
+ global $category_tree;
if (empty($category_tree)) {
$categories_by_id = comicpress_get_comic_category_objects_by_id();
if (empty($categories_by_id) || !is_array($categories_by_id)) return false;
@@ -335,7 +306,7 @@ function comicpress_create_category_tree() {
$new_category_tree = array();
foreach ($category_tree as $node) {
$parts = explode("/", $node);
- if ($parts[1] == $comiccat) {
+ if ($parts[1] == comicpress_themeinfo('comiccat')) {
$new_category_tree[] = $node;
}
}
@@ -482,15 +453,16 @@ function comicpress_load_options() {
'facebook_meta' => false,
'enable_comic_lightbox' => false,
'cdn_url' => '',
- 'comiccat' => '1',
+/* 'comiccat' => '1',
'blogcat' => '3',
'comic_folder' => 'comics',
'rss_comic_folder' => 'comics-rss',
'archive_comic_folder' => 'comics-archive',
'mini_comic_folder' => 'comics-mini',
'rss_comic_width' => '240',
'archive_comic_width' => '420',
- 'mini_comic_width' => '198'
+ 'mini_comic_width' => '198' */
+ 'enable_page_options' => true
) as $field => $value) {
$comicpress_options[$field] = $value;
}
@@ -501,17 +473,41 @@ function comicpress_load_options() {
}
function comicpress_themeinfo($whichinfo = null) {
- global $comicpress_themeinfo, $comiccat, $blogcat, $comic_folder, $rss_comic_folder, $archive_comic_folder, $mini_comic_folder,
- $archive_comic_width, $rss_comic_width, $mini_comic_width, $blog_postcount;
+ global $comicpress_themeinfo;
+
if (empty($comicpress_themeinfo) || $whichinfo == 'reset') {
-
+
+ if (is_multisite()) {
+ // This section keeps it compatible with comicpress manager's options
+ $variables_to_extract = array();
+
+ foreach (array(
+ 'comiccat' => 'comiccat',
+ 'blogcat' => 'blogcat',
+ 'comics_path' => 'comic_folder',
+ 'comicsrss_path' => 'rss_comic_folder',
+ 'comicsarchive_path' => 'archive_comic_folder',
+ 'comicsmini_path' => 'mini_comic_folder',
+ 'archive_comic_width' => 'archive_comic_width',
+ 'rss_comic_width' => 'rss_comic_width',
+ 'mini_comic_width' => 'mini_comic_width',
+ 'blog_postcount' => 'blog_postcount') as $options => $variable_name) {
+ $variables_to_extract[$variable_name] = get_option("comicpress-${options}");
+ }
+
+ extract($variables_to_extract);
+
+ } else {
+ @require_once( get_template_directory() . '/comicpress-config.php');
+ }
+
$comicpress_themeinfo = '';
// $comicpress_config = comicpress_load_config();
$comicpress_options = comicpress_load_options();
$comicpress_coreinfo = wp_upload_dir();
$comicpress_addinfo = array(
'upload_path' => get_option('upload_path'),
- 'version' => '2.9.2.29.2',
+ 'version' => '2.9.2.30',
'siteurl' => trailingslashit(get_option('siteurl')),
'home' => trailingslashit(home_url()),
'comiccat' => $comiccat,
@@ -529,15 +525,16 @@ function comicpress_themeinfo($whichinfo = null) {
$comicpress_themeinfo = array_merge($comicpress_coreinfo, $comicpress_addinfo);
$comicpress_themeinfo = array_merge($comicpress_themeinfo, $comicpress_options);
+
if ($comicpress_themeinfo['enable-storyline-support']) {
// This is now sep. to make sure that it only loads when it needs to
$comicpress_storyline = array(
'category_tree' => comicpress_create_category_tree(),
'storyline-category-order' => get_option('comicpress-storyline-category-order')
);
$comicpress_themeinfo = array_merge($comicpress_themeinfo, $comicpress_storyline);
- }
- $comicpress_themeinfo['blog_postcount'] = $blog_postcount;
+ }
+
if (is_multisite()) {
$comicpress_themeinfo['basedir'] = trailingslashit(ABSPATH.$comicpress_themeinfo['upload_path']);
$comicpress_themeinfo['baseurl'] = trailingslashit($comicpress_themeinfo['siteurl'].'files');
@@ -569,12 +566,11 @@ function comicpress_get_comic_category_objects_by_id() {
// This uses the comicpress_load_config() because it's not yet triggered in themeinfo
function comicpress_all_comic_categories_array() {
- global $comicpress_all_comic_categories_array, $comiccat;
+ global $comicpress_all_comic_categories_array;
if (empty($comicpress_all_comic_categories_array)) {
-// $comicpress_config = comicpress_load_config();
- $comicpress_all_comic_categories_array[] = $comiccat;
+ $comicpress_all_comic_categories_array[] = comicpress_themeinfo('comiccat');
foreach (get_all_category_ids() as $cats) {
- if (cat_is_ancestor_of($comiccat, $cats)) {
+ if (cat_is_ancestor_of(comicpress_themeinfo('comiccat'), $cats)) {
$comicpress_all_comic_categories_array[] = $cats;
}
}
@@ -636,5 +632,14 @@ function comicpress_get_string_to_exclude_all_but_provided_categories($category)
return implode(" and ", array_diff($category_ids, $category));
}
+function comicpress_disable_sidebars() {
+ global $post;
+ if (comicpress_is_signup()) return true;
+ if (is_page() && !empty($post)) {
+ $sidebars_disabled = get_post_meta($post->ID, 'disable-sidebars', true);
+ if ($sidebars_disabled) return true;
+ }
+ return false;
+}
?>
View
@@ -84,6 +84,8 @@ function comicpress_body_class($classes = '') {
$classes[] = 'attachment-' . $type;
endforeach;
}
+
+ if (comicpress_disable_sidebars()) $classes[] = 'wide';
$classes[] = 'layout-'.comicpress_themeinfo('cp_theme_layout');
View
@@ -47,7 +47,7 @@ function comicpress_display_comic_area() {
}
function comicpress_display_comic_swf($post, $comic) {
- $file_url = comicpress_themeinfo('baseurl') . comicpress_clean_filename($comic);
+ $file_url = comicpress_themeinfo('baseurl') . comicpress_clean_url($comic);
$height = get_post_meta( $post->ID, "fheight", true );
$width = get_post_meta( $post->ID, "fwidth", true );
if (empty($height)) $height = '300';
@@ -112,7 +112,7 @@ function comicpress_display_comic_thumbnail($type = 'mini', $override_post = nul
$thumbnail = array();
if (!empty($thumb_found)) {
foreach ($thumb_found as $thumb) {
- $thumbnail[] = comicpress_themeinfo('baseurl') . comicpress_clean_filename($thumb);
+ $thumbnail[] = comicpress_themeinfo('baseurl') . comicpress_clean_url($thumb);
}
}
}
@@ -161,9 +161,9 @@ function comicpress_display_comic_image($post, $comic) {
global $wp_query;
$cdn_url = comicpress_themeinfo('cdn_url');
if (!empty($cdn_url)) {
- $file_url = trailingslashit($cdn_url) . comicpress_clean_filename($comic);
+ $file_url = trailingslashit($cdn_url) . comicpress_clean_url($comic);
} else {
- $file_url = comicpress_themeinfo('baseurl') . comicpress_clean_filename($comic);
+ $file_url = comicpress_themeinfo('baseurl') . comicpress_clean_url($comic);
}
$alt_text = comicpress_the_hovertext($post);
if (!is_search() && !is_archive() && !is_feed()) {
@@ -413,5 +413,21 @@ function get_comic_url($folder = 'comic', $override_post = null, $filter = 'defa
return false;
}
+add_action('comic-area', 'comicpress_inject_comic_home');
+function comicpress_inject_comic_home() {
+ global $wp_query;
+ if (!is_paged() && is_home()) {
+ if (!comicpress_themeinfo('disable_comic_frontpage')) {
+ $wp_query->in_the_loop = true; $comicFrontpage = new WP_Query(); $comicFrontpage->query('showposts=1&cat='.comicpress_all_comic_categories_string());
+ while ($comicFrontpage->have_posts()) : $comicFrontpage->the_post();
+ comicpress_display_comic_area();
+ endwhile;
+ }
+ } else {
+ if (is_single() && comicpress_in_comic_category()) {
+ comicpress_display_comic_area();
+ }
+ }
+}
?>
@@ -12,7 +12,10 @@ function comicpress_display_post_title($is_comic = false) {
}
if (is_home() || is_search() || is_archive() || $is_comic && !is_page()) $post_title .= "<a href=\"".get_permalink()."\">";
- $post_title .= get_the_title();
+ $the_post_title = get_the_title();
+ if (empty($the_post_title)) $the_post_title = __('No Post Title','comicpress');
+ $post_title .= $the_post_title;
+
if (is_home() || is_search() || is_archive() || $is_comic && !is_page()) $post_title .= "</a>";
$post_title .= "</h2>\r\n";
echo apply_filters('comicpress_display_post_title',$post_title);
Oops, something went wrong.

0 comments on commit 117faca

Please sign in to comment.