Skip to content

Instantly share code, notes, and snippets.

View rolandinsh's full-sized avatar
🧔
Remote developer (LEMP, Node.js, Neo4j [graph])

Rolands rolandinsh

🧔
Remote developer (LEMP, Node.js, Neo4j [graph])
View GitHub Profile
@rolandinsh
rolandinsh / gist:3177639
Last active October 7, 2015 14:18
HTML5 MB
<!doctype html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta charset="utf-8">
<link rel="dns-prefetch" href="//s2.me2j.com" /><link rel="dns-prefetch" href="//i2.me2j.com" />
<!--[if lt IE 9]><script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /><![endif]-->
<title>Lapa</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<!--
All other head parts
-->
<?php
/*
Plugin Name: Test
*/
class My_Like_Button {
function __construct()
{
$this->hooks();
}
@rolandinsh
rolandinsh / gist:3263895
Created August 5, 2012 10:58 — forked from kloon/gist:2376300
WooCommerce Automatically add product to cart on site visit
/*
* 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;
@rolandinsh
rolandinsh / gist:3311580
Created August 10, 2012 06:04
wp get_query_var term get term info on Archive page
<?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 );
<?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
@rolandinsh
rolandinsh / gist:3596420
Created September 2, 2012 10:09
PHP with/without www
<?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']);
}
@rolandinsh
rolandinsh / gist:3596401
Created September 2, 2012 10:07
.htaccess with/without www
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]
<!--
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" />
@rolandinsh
rolandinsh / gist:3721176
Created September 14, 2012 10:18
!WPSEO_VERSION
<?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 {
@rolandinsh
rolandinsh / gist:3736133
Created September 17, 2012 08:14
Twitter feed with < em>
<!-- Twitter feed with < em> -->
<item>
<title>Es Tevi v&#x113;roju! http://t.co/yTu9nlFB</title>
<link>http://twitter.com/skatskat/statuses/247322950267699200</link>
<description>Es Tevi v&#x113;roju!&lt;em&gt; http:&lt;em&gt;/&lt;em&gt;/t.co/yTu9nlFB&lt;/em&gt;</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&#xb0; )</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>