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 | |
/* | |
Plugin Name: Dashboard Commander | |
Plugin URI: http://www.warpconduit.net/wordpress-plugins/dashboard-commander/ | |
Description: Command your admin dashboard. Manage built-in widgets and dynamically registered widgets. Hide widgets depending upon user capabilities. Plugin is based upon Dashboard Heaven by Dave Kinkead. | |
Version: 1.0.1 | |
Author: Josh Hartman | |
Author URI: http://www.warpconduit.net | |
License: GPL2 | |
*/ |
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 | |
date_default_timezone_set('America/Chicago'); // Set this in your app's config | |
function getHowLongAgo($date, $display = array('Year', 'Month', 'Day', 'Hour', 'Minute', 'Second'), $ago = 'Ago') | |
{ | |
$date = getdate(strtotime($date)); | |
$current = getdate(); | |
$p = array('year', 'mon', 'mday', 'hours', 'minutes', 'seconds'); | |
$factor = array(0, 12, 30, 24, 60, 60); | |
for ($i = 0; $i < 6; $i++) { |
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 | |
$folder = opendir('.'); // Use '.' only if the PHP file is in the same folder as your files, otherwise use a relative or absolute path. | |
$file_types = array('jpg', 'jpeg', 'gif', 'png'); | |
$file_list = array(); | |
while ($file = readdir ($folder)) { | |
$parts = explode('.', $file); | |
$ext = array_pop($parts); | |
if(in_array($ext, $file_types)) { | |
array_push($file_list, $file); | |
} |
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 | |
date_default_timezone_set('America/Chicago'); | |
// This function will take a number and add "th, st, nd, rd, th" after it. For example: echo ordinal(10); // outputs '10th' | |
function ordinal($i){ | |
$l=substr($i,-1);$s=substr($i,-2,-1);return$i.(($l==1&&$s==1)||($l==2&&$s==1)||($l==3&&$s==1)||$l>3||$l==0?'th':($l==3?'rd':($l==2?'nd':'st'))); | |
} | |
echo 'Today is the '.ordinal(date('z')).' day of this '.ordinal(date('Y')).' year of the common era.'; | |
?> |
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 linkify($text) { | |
$text = preg_replace('/\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[A-Z0-9+&@#\/%=~_|]/i', '<a href="\0">\0</a>', $text); | |
$text = preg_replace('/\b((mailto:)?[A-Z0-9._%+-]+@[A-Z0-9._%-]+\.[A-Z]{2,4})/i', '<a href="mailto:\0">\0</a>', $text); | |
return $text; | |
} | |
$test_text = "An example of an email address is [email protected]. Google (http://www.google.com) is the leading search engine! Check out the latest tut @ http://nettuts.com."; | |
echo linkify($test_text); | |
?> |
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 shorten($n, $l=75, $e=' ...') { | |
if ($l >= strlen($n)) { return $n; } | |
$n = explode(' ', substr($n, 0, $l)); | |
if (count($n)>1) { unset($n[count($n)-1]); } | |
return implode(' ', $n).$e; | |
} | |
echo shorten('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras gravida purus gravida enim interdum bibendum non vel enim. In et massa eu nibh pellentesque porta.'); | |
?> |
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 | |
date_default_timezone_set('America/Chicago'); | |
function secsToStr($secs) { | |
if($secs>=86400){$days=floor($secs/86400);$secs=$secs%86400;$r=$days.' day';if($days<>1){$r.='s';}if($secs>0){$r.=', ';}} | |
if($secs>=3600){$hours=floor($secs/3600);$secs=$secs%3600;$r.=$hours.' hour';if($hours<>1){$r.='s';}if($secs>0){$r.=', ';}} | |
if($secs>=60){$minutes=floor($secs/60);$secs=$secs%60;$r.=$minutes.' minute';if($minutes<>1){$r.='s';}if($secs>0){$r.=', ';}} | |
$r.=$secs.' second';if($secs<>1){$r.='s';} | |
return $r; | |
} | |
echo secsToStr(time()-strtotime('1/1/2011')); |
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 | |
//this is a sample xml string | |
$xml_string="<?xml version='1.0'?> | |
<moleculedb> | |
<molecule name='Benzine'> | |
<symbol>ben</symbol> | |
<code>A</code> | |
</molecule> | |
<molecule name='Water'> | |
<symbol>h2o</symbol> |
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 | |
class TwitterFeed { | |
private var $feed_url; | |
private var $feed_data; | |
public function __construct($username, $limit=5){ | |
date_default_timezone_set('America/Chicago'); | |
$this->feed_url = "http://search.twitter.com/search.atom?q=from:".$username."&rpp=".$limit; | |
$this->feed_data = simplexml_load_file($this->feed_url); | |
} |
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 | |
register_post_type('job-opportunities', array( | |
'labels' => array( | |
'name' => 'Job Opportunities', | |
'singular_name' => 'Job Opportunity', | |
'add_new' => 'Add New Job', | |
'add_new_item' => 'Add New Job Opportunity', | |
'edit_item' => 'Edit Job', | |
'new_item' => 'New Job Opportunity', |
OlderNewer