Created
February 27, 2016 14:13
-
-
Save seeekr/558d0d81154d24851abb to your computer and use it in GitHub Desktop.
fixing shariff custom post types on/off detection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 1531e3ed5393f28e1bcf8ef275cd6df0dbd1cefe Mon Sep 17 00:00:00 2001 | |
From: Denis Andrejew <[email protected]> | |
Date: Thu, 25 Feb 2016 14:42:55 +0100 | |
Subject: [PATCH] fixing shariff's custom post handling logic | |
--- | |
shariff.php | 18 ++++++++++++------ | |
1 file changed, 12 insertions(+), 6 deletions(-) | |
diff --git a/shariff.php b/shariff.php | |
index e2ddf09..c6d05fe 100644 | |
--- a/shariff.php | |
+++ b/shariff.php | |
@@ -541,25 +541,31 @@ function shariffPosts( $content ) { | |
} | |
// now add Shariff | |
+ // type of current post | |
+ $current_post_type = get_post_type(); | |
+ if ($current_post_type === 'page') { | |
+ $current_post_type = 'pages'; | |
+ } | |
+ if ($current_post_type === 'post') { | |
+ $current_post_type = 'posts'; | |
+ } | |
if ( ! is_singular() ) { | |
// on blog page | |
if( isset( $shariff3UU["add_before"]["posts_blogpage"] ) && $shariff3UU["add_before"]["posts_blogpage"] == '1') $content = buildShariffShorttag() . $content; | |
if( isset( $shariff3UU["add_after"]["posts_blogpage"] ) && $shariff3UU["add_after"]["posts_blogpage"] == '1' ) $content .= buildShariffShorttag(); | |
} elseif ( is_singular( 'post' ) ) { | |
// on single post | |
- if ( isset( $shariff3UU["add_before"]["posts"] ) && $shariff3UU["add_before"]["posts"] == '1' ) $content = buildShariffShorttag() . $content; | |
- if ( isset( $shariff3UU["add_after"]["posts"] ) && $shariff3UU["add_after"]["posts"] == '1' ) $content .= buildShariffShorttag(); | |
+ if ( isset( $shariff3UU["add_before"][$current_post_type] ) && $shariff3UU["add_before"][$current_post_type] == '1' ) $content = buildShariffShorttag() . $content; | |
+ if ( isset( $shariff3UU["add_after"][$current_post_type] ) && $shariff3UU["add_after"][$current_post_type] == '1' ) $content .= buildShariffShorttag(); | |
} elseif ( is_singular( 'page' ) ) { | |
// on pages | |
- if ( isset( $shariff3UU["add_before"]["pages"] ) && $shariff3UU["add_before"]["pages"] == '1' ) $content = buildShariffShorttag() . $content; | |
- if ( isset( $shariff3UU["add_after"]["pages"] ) && $shariff3UU["add_after"]["pages"] == '1' ) $content .= buildShariffShorttag(); | |
+ if ( isset( $shariff3UU["add_before"][$current_post_type] ) && $shariff3UU["add_before"][$current_post_type] == '1' ) $content = buildShariffShorttag() . $content; | |
+ if ( isset( $shariff3UU["add_after"][$current_post_type] ) && $shariff3UU["add_after"][$current_post_type] == '1' ) $content .= buildShariffShorttag(); | |
} else { | |
// on custom_post_types | |
$all_custom_post_types = get_post_types( array ( '_builtin' => FALSE ) ); | |
if ( is_array( $all_custom_post_types ) ) { | |
$custom_types = array_keys( $all_custom_post_types ); | |
- // type of current post | |
- $current_post_type = get_post_type(); | |
// add shariff, if custom type and option checked in the admin menu | |
if ( isset( $shariff3UU['add_after'][$current_post_type] ) && $shariff3UU['add_after'][$current_post_type] == 1 ) { | |
$content .= buildShariffShorttag(); | |
-- | |
2.7.2 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment