This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Name: | |
# batchrename | |
# | |
# Synopsis: | |
# batchrename SEARCH [REPLACE] | |
# | |
# Description: | |
# Bash file renaming function. Can accept regular expression arguments | |
function batchrename { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Ensure document root superglobal contains no trailing slash | |
$_SERVER[ 'DOCUMENT_ROOT' ] = rtrim( $_SERVER[ 'DOCUMENT_ROOT' ], '\/' ); | |
// Get current script directory | |
$this_dir = dirname( __FILE__ ); | |
// Get a public, domain relative, path to current script directory | |
$this_public = substr( $this_dir, strlen( $_SERVER[ 'DOCUMENT_ROOT' ] ) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* In PHP >= 5.3 ini files you can detemine which of $_COOKIE, $_POST, $_GET variables appear in the | |
* $_REQUEST superglobal, and the order of precedence in the event of naming collisions. | |
* | |
* The following snippet simulates this for versions of PHP < 5.3 | |
*/ | |
$_REQUEST = array_merge( $_GET, $_POST ); // POST overrides GET in name clashes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_current_url ( $include_request_uri = true ) { | |
$https = isset( $_SERVER[ "HTTPS" ] ) && strtolower( $_SERVER[ "HTTPS" ] ) === "on"; | |
$protocol = 'http' . ( $https ? 's' : '' ) . '://'; | |
$host = $_SERVER[ "SERVER_NAME" ]; | |
$port = $_SERVER[ "SERVER_PORT" ]; | |
$request = $include_request_uri ? get_request_uri() : ''; | |
return $protocol . $host . ( $port != 80 ? ":$port" : '' ) . $request; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( !defined( 'ABSPATH' ) ) { | |
$search = 'wp-load.php'; | |
$limit = 20; // Avoid infinite loop if we're barking up the wrong tree | |
while ( !file_exists( $search ) and $limit-- ) $search = '../' . $search; | |
require_once $search; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_swf ( $url, $attributes = array(), $params = array(), $alt_content = null ) { | |
$attributes = is_array( $attributes ) ? $attributes : array(); | |
$attributes[ 'width' ] = is_numeric( $attributes[ 'width' ] ) ? $attributes[ 'width' ] : 100; | |
$attributes[ 'height' ] = is_numeric( $attributes[ 'height' ] ) ? $attributes[ 'height' ] : 100; | |
$attributes_fmt = " %s=\"%s\""; | |
$attributes_str = ''; | |
foreach ( $attributes as $name => $value ) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---------------------------------------------------------- | |
// A short snippet for detecting versions of IE: | |
// Uses a combination of object detection and user-agent | |
// sniffing. | |
// ---------------------------------------------------------- | |
// If you're not in IE then: | |
// ie === NaN // falsy | |
// If you're in IE then you can determine which version: | |
// ie === 7; // IE7 | |
// Thus, to detect IE: |
NewerOlder