[ Index ]

PHP Cross Reference of YOURLS

title

Body

[close]

/user/plugins/hyphens-in-urls/ -> plugin.php (source)

   1  <?php
   2  /**
   3   * Plugin Name: Allow Hyphens in Short URLs
   4   * Plugin URI: http://yourls.org/
   5   * Description: Allow hyphens in short URLs (like <tt>http://sho.rt/hello-world</tt>)
   6   * Version: 1.1
   7   * Author: Ozh
   8   * Author URI: http://ozh.org/
   9   */
  10  
  11  /** Release History:
  12   *
  13   * 1.0 Initial release
  14   * 1.1 Modified: Make random keywords hyphen free
  15   */
  16  
  17  // No direct call
  18  if( !defined( 'YOURLS_ABSPATH' ) ) die();
  19  
  20  // Add hyphen to the allowed character set
  21  yourls_add_filter( 'get_shorturl_charset', 'ozh_hyphen_in_charset' );
  22  // Unless we are crafting a random keyword
  23  yourls_add_action('add_new_link_create_keyword', function() {yourls_remove_filter('get_shorturl_charset', 'ozh_hyphen_in_charset');});
  24  
  25  function ozh_hyphen_in_charset( $in ) {
  26      return $in.'-';
  27  }


Generated: Wed Sep 28 05:10:02 2022 Cross-referenced by PHPXref 0.7.1