Changeset 1248862
- Timestamp:
- 09/18/2015 10:23:40 PM (9 years ago)
- Location:
- smarter-navigation/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
smarter-navigation/trunk/main.php
r692862 r1248862 4 4 Description: Generates more specific previous / next post links based on referrer. 5 5 Author: scribu, versusbassz 6 Version: 1. 3.26 Version: 1. 7 7 Plugin URI: http://wordpress.org/extend/plugins/smarter-navigation/ 8 8 */ … … 14 14 static $data = false; 15 15 16 function init() {16 function init() { 17 17 add_action( 'template_redirect', array( __CLASS__, 'manage_cookie' ) ); 18 18 add_action( 'posts_clauses', array( __CLASS__, 'posts_clauses' ), 10, 2 ); 19 19 } 20 20 21 function manage_cookie() {21 function manage_cookie() { 22 22 // Default conditions 23 23 $clear_condition = false; … … 33 33 } 34 34 35 private function read_cookie() {35 private function read_cookie() { 36 36 if ( empty( $_COOKIE[self::NAME] ) ) 37 37 return; … … 64 64 } 65 65 66 public function set_cookie( $data = '' ) {66 public function set_cookie( $data = '' ) { 67 67 $data = wp_parse_args( $data, array( 68 68 'query' => json_encode( $GLOBALS['wp_query']->query ), … … 75 75 } 76 76 77 public function clear_cookie() {77 public function clear_cookie() { 78 78 if ( empty( $_COOKIE[self::NAME] ) ) 79 79 return; … … 83 83 } 84 84 85 private function get_name( $key ) {85 private function get_name( $key ) { 86 86 return self::NAME . '[' . $key . ']'; 87 87 } -
smarter-navigation/trunk/readme.txt
r692862 r1248862 4 4 Requires at least: 3.2 5 5 Tested up to: 3.5 6 Stable tag: 1. 3.26 Stable tag: 1. 7 7 License: GPLv2 or later 8 8 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 69 69 == Changelog == 70 70 71 72 73 74 71 75 = 1.3.2 = 72 76 * fix case when plugin worked incorrect with pagination -
smarter-navigation/trunk/template-tags.php
r598633 r1248862 3 3 // Replaces previous_post_link() 4 4 // if $fallback is set to true, previous_post_link() will be called if there is no post found 5 function previous_post_smart( $format = '« %link', $title = '%title', $fallback = true, $in_same_ cat = true, $excluded_categories = '' ) {6 return Smarter_Navigation::adjacent_post( $format, $title, true, $fallback, $in_same_ cat, $excluded_categories);5 function previous_post_smart( $format = '« %link', $title = '%title', $fallback = true, $in_same_' ) { 6 return Smarter_Navigation::adjacent_post( $format, $title, true, $fallback, $in_same_ ); 7 7 } 8 8 9 9 // Replaces next_post_link() 10 10 // if $fallback is set to true, next_post_link() will be called if there is no post found 11 function next_post_smart( $format = '%link »', $title = '%title', $fallback = true, $in_same_ cat = true, $excluded_categories = '' ) {12 return Smarter_Navigation::adjacent_post( $format, $title, false, $fallback, $in_same_ cat, $excluded_categories);11 function next_post_smart( $format = '%link »', $title = '%title', $fallback = true, $in_same_' ) { 12 return Smarter_Navigation::adjacent_post( $format, $title, false, $fallback, $in_same_ ); 13 13 } 14 14 … … 23 23 } 24 24 25 // Retrieve the category, based on the referrer URL. Useful if you have posts with multiple categories 26 function get_referrer_category() { 25 // Retrieve the term, based on the referrer URL. Useful if you have posts with multiple terms 26 // $taxonomy defaults to 'category'. Can be changed to custom taxonomy 27 function get_referrer_term( $taxonomy = 'category' ) { 27 28 global $posts; 28 29 … … 30 31 return false; 31 32 32 foreach ( get_the_ category( $posts[0]->ID ) as $cat) {33 $ cat_link = get_category_link( $cat->term_id);33 foreach ( get_the_ ) { 34 $ ); 34 35 35 if ( false !== strpos( $referrer_url, $ cat_link ) )36 return $ cat;36 if ( false !== strpos( $referrer_url, $_link ) ) 37 return $; 37 38 } 38 39 39 40 return false; 41 42 43 44 45 46 47 48 49 50 51 52 40 53 } 41 54
Note: See TracChangeset
for help on using the changeset viewer.