Last active
August 29, 2015 14:23
-
-
Save bologer/2465a3694be0574fd66f to your computer and use it in GitHub Desktop.
category-wordpress.old.php
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
<?php | |
// abs path function | |
function url_origin($s, $use_forwarded_host = false){ | |
$ssl = (!empty($s['HTTPS']) && $s['HTTPS'] == 'on') ? true:false; | |
$sp = strtolower($s['SERVER_PROTOCOL']); | |
$protocol = substr($sp, 0, strpos($sp, '/')) . (($ssl) ? 's' : ''); | |
$port = $s['SERVER_PORT']; | |
$port = ((!$ssl && $port=='80') || ($ssl && $port=='443')) ? '' : ':'.$port; | |
$host = ($use_forwarded_host && isset($s['HTTP_X_FORWARDED_HOST'])) ? $s['HTTP_X_FORWARDED_HOST'] : (isset($s['HTTP_HOST']) ? $s['HTTP_HOST'] : null); | |
$host = isset($host) ? $host : $s['SERVER_NAME'] . $port; | |
return $protocol . '://' . $host; | |
} | |
function full_url($s, $use_forwarded_host=false) | |
{ | |
return url_origin($s, $use_forwarded_host) . $s['REQUEST_URI']; | |
} | |
$absolute_url = full_url($_SERVER); | |
// end function abs path | |
if( !has_category( $post->ID ) ): | |
the_category( '', '', $post->ID ); | |
// global $post; | |
$category_detail = get_the_category( $post->ID ); | |
foreach ($category_detail as $key => $object): | |
if( $key != 0): | |
echo ' | |
<script> | |
jQuery(function() { | |
console.log( jQuery(".post-categories") ); | |
jQuery("a").each(function() { | |
if( jQuery(this).attr("href") == "'. $absolute_url .'") { | |
jQuery(this).addClass("active active_id_" + ' . $object->term_id . '); | |
} | |
}); | |
}); | |
</script> | |
'; | |
//|| jQuery(this).attr("href") == "http://www.cs-client.com/?cat='. $object->term_id.'" | |
endif; | |
endforeach; | |
else: | |
echo '<center>Нет рубрик.</center>'; | |
endif; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment