Skip to content

Instantly share code, notes, and snippets.

View stefanolaru's full-sized avatar

Ștefan Olaru stefanolaru

View GitHub Profile
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
@stefanolaru
stefanolaru / gist:3959ef637b7835046736
Created October 25, 2014 10:00
Wordpress - get terms by custom post type
function get_terms_by_post_type($taxonomy, $post_type) {
//
global $wpdb;
$query = $wpdb->prepare("SELECT t4.*, t3.term_taxonomy_id, t3.description, COUNT(t2.ID) as `count` FROM wp_term_relationships AS t1 LEFT JOIN wp_posts AS t2 ON t1.object_id=t2.ID LEFT JOIN wp_term_taxonomy AS t3 ON t1.term_taxonomy_id=t3.term_taxonomy_id LEFT JOIN wp_terms AS t4 ON t3.term_id=t4.term_id WHERE t2.post_type='".$post_type."' AND t3.taxonomy='".$taxonomy."' GROUP BY t4.term_id", array());
$results = $wpdb->get_results($query);
//
return $results;
@stefanolaru
stefanolaru / gist:623616f9abc5d5e12292
Created December 7, 2015 09:02
Flush W3 cache on post save
function clear_w3_cache($post_ID) {
if (function_exists('w3tc_flush_all')) {
w3tc_flush_all();
}
return $post_ID;
}
add_action('wp_insert_post_data', 'clear_w3_cache');
@stefanolaru
stefanolaru / arrow-generator.less
Last active December 18, 2015 08:03
LESS sharp left/right arrow generator
.arrow-generator(@direction:right, @width:50, @height:20, @weight:2, @color:#000) {
.arrow-@{direction} {
position: relative;
width: unit(@width, px);
height: unit(@height, px);
display: inline-block;
&:after {
content: '';
border-right: unit(@weight, px) solid @color;
border-top: unit(@weight, px) solid @color;
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
$.concat = require('gulp-concat');
gulp.task('default', function() {
return gulp.src([
'js/foundation.core.js',
'js/foundation.util.box.js',
'js/foundation.util.keyboard.js',
'js/foundation.util.mediaQuery.js',
@stefanolaru
stefanolaru / gist:af749833ed9794e371c59333d9904b76
Created July 3, 2017 09:33
wp insert countries as country taxonomy
// create country tags
add_action( 'init', 'insert_countries');
function insert_countries() {
//
if(empty($_GET['importcountries'])) {
return;
}
$countries = array(
"AF" => array("country" => "Afghanistan", "continent" => "Asia"),
curl -X POST \
https://sift.email/api \
-H 'Authorization: Bearer YOUR_API_KEY' \
-F email=address@tovalidate.com
{
"email": "address@tovalidate.com",
"valid_format": true,
"disposable": false,
"free_email": false,
"role_based": false,
"smtp_status": -1,
"parts": {
"local_part": "address",
"domain": "tovalidate.com"
@stefanolaru
stefanolaru / sift.email.faas.html
Last active October 24, 2018 14:07
Form as a Service
<form action="https://send.sift.email" method="POST">
<input type="email" name="email" placeholder="Your email" required>
<input type="hidden" name="_key" value="YOUR SIFT KEY">
<input type="submit" value="Send">
</form>
<form action="https://send.sift.email" method="POST">
<!--
// Required Fields
-->
<input type="email" name="email" placeholder="Your email" required>
<input type="hidden" name="_key" value="YOUR SIFT FORM KEY">
<!--
// Optional Fields