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 $todayid = date("z"); // to get today's day of year | |
function dayofyear2date( $tDay, $tFormat = 'd-m-Y' ) { | |
$day = intval( $tDay ); | |
$day = ( $day == 0 ) ? $day : $day - 1; | |
$offset = intval( intval( $tDay ) * 86400 ); | |
$str = date( $tFormat, strtotime( 'Jan 1, ' . date( 'Y' ) ) + $offset ); | |
return( $str ); | |
} | |
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
/* | |
* goes in theme functions.php or a custom plugin | |
**/ | |
// add item to cart on visit | |
add_action( 'init', 'add_product_to_cart' ); | |
function add_product_to_cart() { | |
if ( ! is_admin() ) { | |
global $woocommerce; | |
$product_id = 64; | |
$found = false; |
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 | |
/* | |
via http://wordpress.stackexchange.com/a/15287/7577 | |
codex: http://codex.wordpress.org/Function_Reference/get_query_var | |
*/ | |
$termslug = get_query_var( 'term' ); | |
$taxoname = get_query_var( 'taxonomy' ); | |
$thisterm = get_term_by( 'slug', $termslug, $taxoname ); |
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 | |
/** | |
* Google Analytics Integration http://www.phpkode.com/source/s/woocommerce/woocommerce/classes/integrations/google-analytics/class-wc-google-analytics.php | |
* | |
* Allows tracking code to be inserted into store pages. | |
* | |
* @class WC_Google_Analytics | |
* @package WooCommerce | |
* @category Integrations | |
* @author WooThemes |
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
function get_smc_dnt() { | |
/* | |
* Do Not Track for privacy. | |
* When this feature is enabled, webpage should exclude all tracking tools, | |
* like Google Analytic and advertising networks | |
*/ | |
// returns TRUE if DNT is on and is equal to 1, | |
// returns FALSE if DNT is unset OR not equal to 1 | |
return (isset($_SERVER['HTTP_DNT']) && $_SERVER['HTTP_DNT'] == 1); | |
} |
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
RewriteEngine On | |
# with www | |
# RewriteCond %{HTTP_HOST} !^www\. | |
# RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L] | |
# without www | |
RewriteCond %{HTTP_HOST} ^www.(.*)$ [NC] | |
RewriteRule ^(.*)$ http://%1/$1 [R=301,L] |
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 | |
/* redirect to with/without www version of page | |
* @date 2012-09-02 | |
*/ | |
if (substr($_SERVER['HTTP_HOST'],0,3) != 'www'){ | |
header('HTTP/1.1 301 Moved Permanently'); | |
header('Location: http://www.'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']); | |
} |
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
<!-- | |
based on: | |
* https://gist.github.com/3259153 | |
* https://gist.github.com/3182211 | |
Full information: | |
http://simplemediacode.com/wordpress-pugins/itemprop-wp/ | |
--> | |
<span itemscope itemtype="http://schema.org/Article"> | |
<!-- Itemprop WP 3.3.5 by Rolands Umbrovskis http://umbrovskis.com --> | |
<meta itemprop="name" content="Title of the Article" /> |
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 | |
/* http://simplemediacode.info/snippets/better-page-title-with-and-without-yoast-wordpress-seo-plugin/ */ | |
?> | |
<title> | |
<?php if (!defined('WPSEO_VERSION')) { | |
// if there is no WordPress SEO plugin activated | |
wp_title(' | ', true, 'right'); | |
echo get_bloginfo('name') | |
.' '.get_bloginfo('description'); // or some WordPress default | |
}else { |
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
<!-- Twitter feed with < em> --> | |
<item> | |
<title>Es Tevi vēroju! http://t.co/yTu9nlFB</title> | |
<link>http://twitter.com/skatskat/statuses/247322950267699200</link> | |
<description>Es Tevi vēroju!<em> http:<em>/<em>/t.co/yTu9nlFB</em></description> | |
<pubDate>Sun, 16 Sep 2012 13:16:01 +0000</pubDate> | |
<guid>http://twitter.com/skatskat/statuses/247322950267699200</guid> | |
<author>skatskat@twitter.com (skatskat.lv 360° )</author> | |
<media:content type="image/jpg" height="48" width="48" url="http://a0.twimg.com/profile_images/1150354480/ziarfe_80x80_normal.jpg"/> | |
<google:image_link>http://a0.twimg.com/profile_images/1150354480/ziarfe_80x80_normal.jpg</google:image_link> |