Changeset 816479
- Timestamp:
- 12/07/2013 03:29:19 PM (12 years ago)
- Location:
- divisions/trunk
- Files:
-
- 4 edited
-
divisions.php (modified) (5 diffs)
-
includes/dvs_constants.php (modified) (1 diff)
-
includes/dvs_link_modification.php (modified) (3 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
divisions/trunk/divisions.php
r783523 r816479 4 4 Plugin URI: http://www.nachstedt.com/en/divisions-wordpress-plugin-en 5 5 Description: Create multiple divisions in your site with individual menus, sidebars and header images. Divisions may easily change share content of all types while maintaining a consistent look. 6 Version: 0.2. 16 Version: 0.2.2 7 7 Author: Timo Nachstedt 8 8 Author URI: http://www.nachstedt.com … … 94 94 // register filters 95 95 add_filter( 96 'post_link',97 array(&$this, 'post_link_filter'), 1, 2);98 add_filter(99 96 'wp_edit_nav_menu_walker', 100 97 array( &$this, 'wp_edit_nav_menu_walker_filter' ) ); … … 163 160 } 164 161 update_option(dvs_Constants::DATABASE_VERSION_OPTION, $my_version); 162 } 163 164 public function get_current_division() 165 { 166 return $this->current_division; 165 167 } 166 168 … … 191 193 : $this->current_division->get_id(); 192 194 193 $division = $division_enabled 194 ? $chosen_division 195 : $current_division_id; 196 197 // chosen_division <0 means "no division" 198 if ($division >= 0) 199 { 200 $menu_item->url = dvs_LinkModification::add_division_to_url( 201 $menu_item->url, 202 $division); 203 } 204 205 if ($division_enabled && $division==$current_division_id) 206 { 207 $menu_item->classes[] = 208 dvs_Constants::CSS_CLASS_MENU_ITEM_CURRENT_DIVISION; 209 } 195 if ($division_enabled) 196 { 197 // chosen_division <0 means "no division" 198 if ($chosen_division >= 0 && $current_division_id >=0) 199 { 200 $menu_item->url = 201 dvs_LinkModification::replace_division_in_url( 202 $menu_item->url, 203 $chosen_division); 204 } 205 if ($chosen_division >= 0 && $current_division_id < 0) 206 { 207 $menu_item->url = 208 dvs_LinkModification::add_division_to_url( 209 $menu_item->url, 210 $chosen_division); 211 } 212 else 213 if ($chosen_division < 0 && $current_division_id >=0) 214 { 215 $menu_item->url = 216 dvs_LinkModification::remove_division_from_url( 217 $menu_item->url); 218 } 219 if ($chosen_division==$current_division_id) 220 { 221 $menu_item->classes[] = 222 dvs_Constants::CSS_CLASS_MENU_ITEM_CURRENT_DIVISION; 223 } 224 225 } 226 210 227 return $menu_item; 211 228 } … … 282 299 $this->current_division = new dvs_Division($division_id); 283 300 } 284 }285 286 /**287 * Filter links to posts288 *289 * This method filters links to posts in page and adds the current division290 * as query argument291 *292 * @param string $permalink_url original post link url293 * @param array $post_data meta data of the linke post294 * @return string modified link url295 */296 public function post_link_filter($permalink_url, $post_data) {297 if ($this->current_division==NULL) {return $permalink_url;}298 return dvs_LinkModification::add_division_to_url(299 $permalink_url,300 $this->current_division->get_id());301 301 } 302 302 -
divisions/trunk/includes/dvs_constants.php
r783523 r816479 6 6 class dvs_Constants { 7 7 8 const VERSION = '0.2. 1';8 const VERSION = '0.2.2'; 9 9 const DATABASE_VERSION_OPTION = "divisions_plugion_version"; 10 10 -
divisions/trunk/includes/dvs_link_modification.php
r783523 r816479 42 42 array(__CLASS__, 'deactivation_hook')); 43 43 } 44 else 45 { 46 add_filter( 47 'page_link', 48 array(__CLASS__, 'page_link_filter')); 49 add_filter( 50 'post_link', 51 array(__CLASS__, 'post_link_filter'), 1, 2); 52 } 44 53 } 45 54 … … 93 102 } 94 103 } 104 105 public static function page_link_filter($permalink_url) 106 { 107 global $tn_divisions_plugin; 108 $current_division = $tn_divisions_plugin->get_current_division(); 109 if ($current_division==NULL) 110 { 111 return $permalink_url; 112 } 113 return self::add_division_to_url( 114 $permalink_url, 115 $current_division->get_id()); 116 } 117 118 /** 119 * Filter links to posts 120 * 121 * This method filters links to posts in page and adds the current division 122 * as query argument 123 * 124 * @param string $permalink_url original post link url 125 * @param array $post_data meta data of the linke post 126 * @return string modified link url 127 */ 128 public static function post_link_filter($permalink_url, $post_data) { 129 global $tn_divisions_plugin; 130 $current_division = $tn_divisions_plugin->get_current_division(); 131 if ($current_division==NULL) 132 { 133 return $permalink_url; 134 } 135 return self::add_division_to_url( 136 $permalink_url, 137 $current_division->get_id()); 138 } 139 140 public static function remove_division_from_url($url) 141 { 142 if (dvs_Settings::get_use_permalinks() 143 && get_option('permalink_structure')) 144 { 145 $site_url = get_site_url(); 146 $relative_url = substr($url, strlen($site_url)+1); 147 $first_slash = strpos($relative_url, '/'); 148 if ($first_slash) 149 { 150 return $site_url . substr($relative_url, $first_slash); 151 } 152 else 153 { 154 return $url; 155 } 156 } 157 else 158 { 159 return add_query_arg( 160 dvs_Constants::QUERY_ARG_NAME_DIVISION, 161 FALSE, 162 $url); 163 } 164 165 return $url; 166 } 167 168 public static function replace_division_in_url($url, $division_id) 169 { 170 return self::add_division_to_url( 171 self::remove_division_from_url($url), $division_id); 172 } 95 173 96 174 public static function rewrite_rules_array_filter($rules) … … 117 195 foreach ($divisions as $division) 118 196 { 119 $url = $division->get_permalink_slug() ;197 $url = $division->get_permalink_slug() . "$"; 120 198 $rewrite = '/index.php?division=' . $division->get_id(); 121 199 $newrules[$url] = $rewrite; -
divisions/trunk/readme.txt
r783523 r816479 5 5 Requires at least: 3.6 6 6 Tested up to: 3.6 7 Stable tag: 0.2. 17 Stable tag: 0.2.2 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 43 43 == Changelog == 44 44 45 = 0.2.2 = 46 * fixed bug that always forwarded pretty permalinks to startpage 47 * fixed bug that added division twice to pretty permalinks in menu 48 * added method get_current_division() to plugin item for external use 49 45 50 = 0.2.1 = 46 51 * Division permalinks for homepages work … … 67 72 == Upgrade Notice == 68 73 74 = 0.2.2 = 75 Fixed severe bugs related to pretty permalinks 76 69 77 = 0.2.1 = 70 78 Fixed bugs related to new permalink option
Note: See TracChangeset
for help on using the changeset viewer.