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 | |
// Change all pages and hierarchical custom post types to date order | |
function custom_page_order( $wp_query ) { | |
global $pagenow; | |
if (is_admin() && 'edit.php' == $pagenow && !isset($_GET['orderby'])) { | |
$wp_query->set( 'orderby', 'date' ); | |
$wp_query->set( 'order', 'DSC' ); | |
} | |
} |
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 | |
/* | |
Plugin Name: Post Expirator | |
Plugin URI: http://wordpress.org/extend/plugins/post-expirator/ | |
Description: Allows you to add an expiration date (minute) to posts which you can configure to either delete the post, change it to a draft, or update the post categories at expiration time. | |
Author: Aaron Axelsen | |
Version: 2.1.4 | |
Author URI: http://postexpirator.tuxdocs.net/ | |
Translation: Thierry (http://palijn.info) | |
Text Domain: post-expirator |
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 | |
/* | |
For a better understanding of ics requirements and time formats | |
please check https://gist.github.com/jakebellacera/635416 | |
*/ | |
// UTILS | |
// Check if string is a timestamp |
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
/*DELETE FROM wp_posts; | |
DELETE FROM wp_postmeta;*/ | |
TRUNCATE TABLE wp_posts; | |
TRUNCATE TABLE wp_postmeta; |
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
<div id="calendar"> | |
<?php | |
// Dates | |
$year = date('Y'); | |
$first_month_this_year_ts = mktime(0, 0, 0, date("F", strtotime('first month of this year')) + 1, date('d'), date('Y')); // timestamp | |
$today = date("j F Y", strtotime('today')); // human date | |
$today_ts = strtotime('today'); // timestamp | |
$today_day_of_year = date("z", $today_ts);// int |
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 | |
// PHP – parse a string between two strings | |
// Credits: http://www.justin-cook.com/wp/2006/03/31/php-parse-a-string-between-two-strings/ | |
function get_string_between($string, $start, $end){ | |
$string = " ".$string; | |
$ini = strpos($string,$start); | |
if ($ini == 0) return ""; | |
$ini += strlen($start); | |
$len = strpos($string,$end,$ini) - $ini; |
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 | |
// Setup Swiper before deploy | |
// http://idangero.us/swiper | |
// Add Slideshow Shortcode for WordPress | |
function slideshow_custom_shortcode($atts, $content = null ) { | |
extract( shortcode_atts( array( | |
'plain_text_url' => 'no' // in case the urls are plain text urls, write yes in the parameter eg. [slideshow plain_text_url="yes"]plain text urls here[/slideshow] | |
), $atts ) ); |
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
<table style="table-layout: fixed;"> | |
<colgroup> | |
<col span="1" style="width: 10%;"> | |
<col span="1" style="width: 10%;"> | |
<col span="1" style="width: 40%;"> | |
<col span="1" style="width: 40%;"> | |
</colgroup> | |
<tbody> |
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 | |
// Let's be honest, RegEx is not fun, so these may come in handy | |
// I'll update this in case I write/find more | |
$text = '[video mp4="http://somevideo.com/abc"]'; | |
preg_match_all("\bmp4="(.+)\b", $text, $matches); | |
var_dump($matches[0]); | |
// http://somevideo.com/abc | |