Changeset 468668
- Timestamp:
- 11/28/2011 06:04:37 PM (14 years ago)
- Location:
- any-hostname/trunk
- Files:
-
- 4 edited
-
any-hostname.php (modified) (10 diffs)
-
languages/anyhostname-sv_SE.mo (modified) (previous)
-
languages/anyhostname-sv_SE.po (modified) (2 diffs)
-
readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
any-hostname/trunk/any-hostname.php
r440304 r468668 5 5 Description: Alters all WordPress-generated URLs according to the servers current hostname, so that they will always correspond to the actual hostname as entered by the user. 6 6 Author: Simon Fransson 7 Version: 1.0 7 Version: 1.0.1 8 8 Author URI: http://dessibelle.se/ 9 9 */ … … 51 51 $this->enable_filters(); 52 52 53 add_action('admin_enqueue_scripts', array(&$this, 'init_admin') );54 add_action('admin_init', array(&$this, 'init_settings') );53 add_action('admin_enqueue_scripts', array(&$this, 'init_admin'), 1); 54 add_action('admin_init', array(&$this, 'init_settings'), 1); 55 55 56 56 // Setup functions to disable the filter on options-general.php 57 57 add_action('load-options-general.php', array(&$this, 'general_options_page_init')); 58 } 58 59 add_filter('plugin_action_links', array(&$this, 'action_links'), 10, 2 ); 60 } 61 62 public function action_links($links, $file) { 63 static $this_plugin; 64 if (!$this_plugin) 65 $this_plugin = plugin_basename(__FILE__); 66 67 if ($file == $this_plugin){ 68 $settings_link = sprintf('<a href="options-%s.php#any-hostname">%s</a>', $this->options_page, __("Settings", "loggedin")); 69 array_unshift($links, $settings_link); 70 } 71 return $links; 72 } 73 59 74 60 75 protected function enable_filters() { … … 62 77 add_filter('option_siteurl', array(&$this, 'siteurl'), 20); 63 78 add_filter('theme_root_uri', array(&$this, 'theme_root_uri'), 20); 79 80 add_filter('plugins_url', array(&$this, 'plugins_url'), 20, 3); 81 add_filter('content_url', array(&$this, 'content_url'), 20, 2); 82 add_filter('upload_dir', array(&$this, 'upload_dir'), 20); 83 64 84 //add_filter('allowed_redirect_hosts', array(&$this, 'allowed_redirect_hosts'), 20); 65 85 } … … 69 89 remove_filter('option_siteurl', array(&$this, 'siteurl'), 20); 70 90 remove_filter('theme_root_uri', array(&$this, 'theme_root_uri'), 20); 91 92 remove_filter('plugins_url', array(&$this, 'plugins_url'), 20, 3); 93 remove_filter('content_url', array(&$this, 'content_url'), 20, 2); 94 remove_filter('upload_dir', array(&$this, 'upload_dir'), 20); 95 71 96 //add_filter('allowed_redirect_hosts', array(&$this, 'allowed_redirect_hosts'), 20); 72 97 } … … 103 128 104 129 $parts = parse_url($url); 130 105 131 106 132 $host = apply_filters('any_hostname_host', $_SERVER['HTTP_HOST']); … … 116 142 } 117 143 144 /* Appears this is not needed, port is part of hostname */ 145 /* 118 146 if ($parts['port']) { 119 $port = ":" . $parts['port']; 120 } 147 $port = ":" . $parts['port']; 148 } 149 */ 121 150 122 151 if ($parts['query']) { … … 129 158 130 159 $url = sprintf('%s://%s%s%s%s%s%s', $parts['scheme'], $user_pass, $host, $port, $parts['path'], $query, $fragment); 131 160 132 161 return $url; 133 162 } … … 179 208 public function init_admin($hook) { 180 209 if( $hook == sprintf('options-%s.php', $this->options_page) ) { 181 wp_enqueue_script('any_hostname', $this->filter_url(WP_PLUGIN_URL) . '/any-hostname/js/admin.js', array('jquery'));210 wp_enqueue_script('any_hostname', plugins_url('js/admin.js', __FILE__), array('jquery')); 182 211 //wp_enqueue_style('any_hostname', WP_PLUGIN_URL . '/any-hostname/css/admin.css'); 183 212 } … … 250 279 $intro = __("Let's you alter all WordPress-generated URLs according to the servers current hostname, so that they will always correspond to the actual hostname as entered by the user.", 'anyhostname'); 251 280 252 printf('<p >%s</p>', $intro);281 printf('<p id="any-hostname">%s</p>', $intro); 253 282 } 254 283 … … 284 313 } 285 314 315 public function plugins_url($url, $path = null, $plugin = null) { 316 return $this->filter_url($url); 317 } 318 319 public function content_url($url, $path = null) { 320 return $this->filter_url($url); 321 } 322 323 public function upload_dir($values) { 324 325 $values['url'] = $this->filter_url($values['url']); 326 $values['baseurl'] = $this->filter_url($values['baseurl']); 327 328 return $values; 329 } 330 286 331 /* This is here just for shows (might come in handy in the future) */ 287 332 /* -
any-hostname/trunk/languages/anyhostname-sv_SE.po
r440301 r468668 3 3 "Project-Id-Version: Any Hostname\n" 4 4 "Report-Msgid-Bugs-To: \n" 5 "POT-Creation-Date: 2011-09- 14 18:11+0100\n"6 "PO-Revision-Date: 2011-09- 14 18:11+0100\n"5 "POT-Creation-Date: 2011-09-27 13:28+0100\n" 6 "PO-Revision-Date: 2011-09-27 13:28+0100\n" 7 7 "Last-Translator: Simon Fransson <[email protected]>\n" 8 8 "Language-Team: <[email protected]>\n" … … 17 17 "X-Poedit-SearchPath-0: ..\n" 18 18 19 #: ../any-hostname.php:189 19 #: ../any-hostname.php:68 20 msgid "Settings" 21 msgstr "Inställningar" 22 23 #: ../any-hostname.php:204 20 24 msgid "Any Hostname" 21 25 msgstr "Godtyckligt domännamn" 22 26 23 #: ../any-hostname.php: 19427 #: ../any-hostname.php:209 24 28 msgid "Allowed hosts" 25 29 msgstr "Tillåtna domännamn" 26 30 27 #: ../any-hostname.php:2 5031 #: ../any-hostname.php:265 28 32 msgid "Let's you alter all WordPress-generated URLs according to the servers current hostname, so that they will always correspond to the actual hostname as entered by the user." 29 33 msgstr "Låter dig anpassa samtliga adresser som genererats av WordPress enligt webbserverns nuvarande adress, så att de alltid pejar på samma domän." 30 34 31 #: ../any-hostname.php:2 6435 #: ../any-hostname.php:279 32 36 #, php-format 33 37 msgid "One host per row. This field uses %s, which means you can also use %s to allow any host, or %s to allow all .com-hosts. It is recommended that you use the input field below when adding hosts if you are unfamiliar with regular expressions." 34 38 msgstr "Ett domännamn per rad. Detta fält använder %s, vilket innebär att du kan ange %s för att tillåta vilken domän som helst, eller %s för vilken .com-domän som helst. Det är rekommenderat att du använder inmatningsfältet nedan om du inte behärskar regular expressions." 35 39 36 #: ../any-hostname.php:2 6840 #: ../any-hostname.php:283 37 41 msgid "example.com" 38 42 msgstr "" 39 43 40 #: ../any-hostname.php:2 6844 #: ../any-hostname.php:283 41 45 msgid "Add host" 42 46 msgstr "Lägg till domännamn" 43 47 44 #: ../any-hostname.php:2 7048 #: ../any-hostname.php:285 45 49 #, php-format 46 50 msgid "The list of allowed host does not contain the hostname that your are currently using (%s). This might result in making the site unreachable at this hostname. Are you sure you want to continue?" -
any-hostname/trunk/readme.txt
r440303 r468668 5 5 Requires at least: 2.7 6 6 Tested up to: 3.2.1 7 Stable tag: 1.0 7 Stable tag: 1.0.1 8 8 9 9 Any Hostname alters all WordPress-generated URLs according to the servers current hostname, allowing you to use a single site on multiple hostnames. … … 27 27 == Changelog == 28 28 29 = 1.0.1 = 30 * Plugin is now using `plugins_url()` instead of its own filter in order to get the correct path for its javascript. 31 * Added filters for `plugins_url`, `content_url` and `upload_dir`. 32 * Fixed an issue with the URL filter for URLs that have a port number 33 29 34 = 1.0 = 30 35 * Added localization support and Swedish localization. … … 41 46 == Known Issues == 42 47 43 This plugin will not be able to alter the contents of constants such as `WP_CONTENT_URL` and `WP_PLUGIN_URL` as these are (quite naturally) defined before any plugins are loaded. Plugin developers should instead rely on the `get_option()` function, which will always return the filtered hostname.48 This plugin will not be able to alter the contents of constants such as `WP_CONTENT_URL` and `WP_PLUGIN_URL` as these are (quite naturally) defined before any plugins are loaded. Plugin developers should instead rely on either one of the `plugins_url()`, `content_url()` or `get_option()` functions, which will always return the filtered hostname. An example of this is the WPtouch plugin, in which case you can override WPtouch's `compat_get_wp_content_url` function, as described by this Gist: https://gist.github.com/1401269. 44 49 45 50 Any Hostname might also obscure the value of WordPress and Site URL settings on the Options » General settings page, due to the fact that these values are retrieved using the `get_option()` function. The values actually stored in WordPress' database is in fact your site's true URL. From 1.0b2 up the plugin will deactivate the host filters on this page, which might cause some page resources to load from the default URL (potentially being unreachable). 51 52 Any Hostname will not work on WordPress Network sites (WPMU) due to the fact that the pages in a network install stores its URLs explicitily in the database. Any ideas on how ti circumvent this would be greatly appreciated. 46 53 47 54 Due to a bug in the WordPress Settings API (http://core.trac.wordpress.org/ticket/9296) the plugin settings are temporarily located on the Privacy page. These settings will likely be moved to the Permalinks page in a future version.
Note: See TracChangeset
for help on using the changeset viewer.