Plugin Directory

Changeset 468668


Ignore:
Timestamp:
11/28/2011 06:04:37 PM (14 years ago)
Author:
chokladzingo
Message:

Version 1.0.1

Location:
any-hostname/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • any-hostname/trunk/any-hostname.php

    r440304 r468668  
    55Description: 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.
    66Author: Simon Fransson
    7 Version: 1.0
     7Version: 1.0.1
    88Author URI: http://dessibelle.se/
    99*/
     
    5151        $this->enable_filters();
    5252       
    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);
    5555       
    5656        // Setup functions to disable the filter on options-general.php
    5757        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   
    5974   
    6075    protected function enable_filters() {
     
    6277        add_filter('option_siteurl', array(&$this, 'siteurl'), 20);
    6378        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       
    6484        //add_filter('allowed_redirect_hosts', array(&$this, 'allowed_redirect_hosts'), 20);
    6585    }
     
    6989        remove_filter('option_siteurl', array(&$this, 'siteurl'), 20);
    7090        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               
    7196        //add_filter('allowed_redirect_hosts', array(&$this, 'allowed_redirect_hosts'), 20);
    7297    }
     
    103128       
    104129        $parts = parse_url($url);
     130       
    105131       
    106132        $host = apply_filters('any_hostname_host',  $_SERVER['HTTP_HOST']);
     
    116142        }
    117143       
     144        /* Appears this is not needed, port is part of hostname */
     145        /*
    118146        if ($parts['port']) {
    119             $port = ":" . $parts['port'];
    120         }
     147            $port = ":" . $parts['port'];
     148        }
     149        */
    121150       
    122151        if ($parts['query']) {
     
    129158               
    130159        $url = sprintf('%s://%s%s%s%s%s%s', $parts['scheme'], $user_pass, $host, $port, $parts['path'], $query, $fragment);
    131        
     160               
    132161        return $url;
    133162    }
     
    179208    public function init_admin($hook) {
    180209        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'));
    182211            //wp_enqueue_style('any_hostname', WP_PLUGIN_URL . '/any-hostname/css/admin.css');
    183212        }
     
    250279        $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');
    251280       
    252         printf('<p>%s</p>', $intro);
     281        printf('<p id="any-hostname">%s</p>', $intro);
    253282    }
    254283   
     
    284313    }
    285314   
     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   
    286331    /* This is here just for shows (might come in handy in the future) */
    287332    /*
  • any-hostname/trunk/languages/anyhostname-sv_SE.po

    r440301 r468668  
    33"Project-Id-Version: Any Hostname\n"
    44"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"
    77"Last-Translator: Simon Fransson <[email protected]>\n"
    88"Language-Team:  <[email protected]>\n"
     
    1717"X-Poedit-SearchPath-0: ..\n"
    1818
    19 #: ../any-hostname.php:189
     19#: ../any-hostname.php:68
     20msgid "Settings"
     21msgstr "Inställningar"
     22
     23#: ../any-hostname.php:204
    2024msgid "Any Hostname"
    2125msgstr "Godtyckligt domännamn"
    2226
    23 #: ../any-hostname.php:194
     27#: ../any-hostname.php:209
    2428msgid "Allowed hosts"
    2529msgstr "Tillåtna domännamn"
    2630
    27 #: ../any-hostname.php:250
     31#: ../any-hostname.php:265
    2832msgid "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."
    2933msgstr "Låter dig anpassa samtliga adresser som genererats av WordPress enligt webbserverns nuvarande adress, så att de alltid pejar på samma domän."
    3034
    31 #: ../any-hostname.php:264
     35#: ../any-hostname.php:279
    3236#, php-format
    3337msgid "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."
    3438msgstr "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."
    3539
    36 #: ../any-hostname.php:268
     40#: ../any-hostname.php:283
    3741msgid "example.com"
    3842msgstr ""
    3943
    40 #: ../any-hostname.php:268
     44#: ../any-hostname.php:283
    4145msgid "Add host"
    4246msgstr "Lägg till domännamn"
    4347
    44 #: ../any-hostname.php:270
     48#: ../any-hostname.php:285
    4549#, php-format
    4650msgid "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  
    55Requires at least: 2.7
    66Tested up to: 3.2.1
    7 Stable tag: 1.0
     7Stable tag: 1.0.1
    88
    99Any Hostname alters all WordPress-generated URLs according to the servers current hostname, allowing you to use a single site on multiple hostnames.
     
    2727== Changelog ==
    2828
     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
    2934= 1.0 =
    3035* Added localization support and Swedish localization.
     
    4146== Known Issues ==
    4247
    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.
     48This 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.
    4449
    4550Any 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
     52Any 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.
    4653
    4754Due 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.