This file contains hidden or 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 mysql_to_unix($time = '') | |
{ | |
// YYYY-MM-DD HH:MM:SS | |
$time = str_replace(array('-', ':', ' '), '', $time); | |
// YYYYMMDDHHMMSS | |
return mktime( | |
substr($time, 8, 2), | |
substr($time, 10, 2), | |
substr($time, 12, 2), |
This file contains hidden or 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 force_download($filename = '', $data = '') | |
{ | |
if ($filename == '' OR $data == '') | |
{ | |
return FALSE; | |
} | |
// Try to determine if the filename includes a file extension. | |
// We need it in order to set the MIME type |
This file contains hidden or 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 | |
require_once('../../../../wp-load.php'); | |
header("Content-type: text/css"); | |
$days_to_cache = 10; | |
header('Expires: '.gmdate('D, d M Y H:i:s',time() + (60 * 60 * 24 * $days_to_cache)).' GMT'); | |
$plugin_path = WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__)); // plugin folder ex: http://localhost/wordpress/wp-content/plugins/dynamic-style/ | |
$some_option = get_option('blogname'); | |
$some_data = 450; | |
?> | |
.my_half_width_class { width: <?php echo $some_data; ?>px; } |
This file contains hidden or 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 fadigits($text) | |
{ | |
$fa = array('۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'); | |
$en = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'); | |
return str_replace($en, $fa, $text); | |
} | |
function endigits($text) | |
{ | |
$fa = array('۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹'); |
This file contains hidden or 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
<h1>Filter Tests</h1> | |
<fieldset> | |
<legend><a href="<?php echo $_SERVER['PHP_SELF'] ?>">Demo Form</a></legend> | |
<form name="testForm" id="testForm" action="" method="get"> | |
<input type="text" name="value" id="value" value="" /> | |
<input type="submit" value="Submit" /> | |
</form> | |
<div id="examples"> | |
<strong>Try these examples:</strong> <a href="?value=nettuts">nettuts</a> | <a href="?value=123456">123456</a> | <a href="?value=1">1</a> | <a href="?value=0">0</a> | <a href="?value=123.456">123.456</a> | <a href="?value=-123.456">-123.456</a> | <a href="?value=123,456">123,456</a> | <a href="?value=true">true</a> | <a href="?value=false">false</a> | <a href="?value=http://net.tutsplus.com">http://net.tutsplus.com</a> | <a href="?value=http://net.tuts®plus.com">http://net.tuts®plus.com</a> | <a href="?value=192.168.0.1">192.168.0.1</a> | <a href="?value=1.2.3.4.5.6.7.8.9">1.2.3.4.5.6.7.8.9</a> | <a href="[email protected]">[email protected]</a> | <a href="?value=t(e)[email protected]">t(e)[email protected]</a> | <a href=" |
This file contains hidden or 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 | |
ob_start("ob_gzhandler"); | |
?> | |
<div><p>Lorem ipsum dolor sit amet tellus.</p></div> | |
<div><blockquote>Etiam quis nulla pretium et.</blockquote></div> | |
<div><img src="images/inset.png" alt="Inset Image" /></div> | |
<ul> | |
<li><p>Lorem ipsum dolor sit amet tellus.</p></li> | |
<li><blockquote>Etiam quis nulla pretium et.</blockquote></li> | |
<li><img src="images/inset.png" alt="Inset Image" /></li> |
This file contains hidden or 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
WP_PLUGIN_URL . "/" . plugin_basename( dirname(__FILE__)); |
This file contains hidden or 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 | |
add_filter( 'logout_url', 'custom_logout_url' ); | |
function custom_logout_url( $default ) | |
{ | |
return add_query_arg('redirect_to', get_bloginfo('url'),$default); | |
} | |
?> |
This file contains hidden or 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
//array to hold replacements | |
String[][] replacements = {{"call me", "cm"}, | |
{"as soon as possible", "asap"}}; | |
//loop over the array and replace | |
String strOutput = inString; | |
for(String[] replacement: replacements) { | |
strOutput = strOutput.replace(replacement[0], replacement[1]); | |
} |
This file contains hidden or 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 | |
// Hook into WordPress | |
add_action( 'admin_init', 'add_custom_metabox' ); | |
add_action( 'save_post', 'save_custom_url' ); | |
/** | |
* Add meta box | |
*/ | |
function add_custom_metabox() { |