Skip to content

Instantly share code, notes, and snippets.

Dimitris Marlagkoutsos sirtimid

Block or report user

Report or block sirtimid

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@sirtimid
sirtimid / um_vies_vat_validation.php
Last active Dec 7, 2016
VIES VAT custom validation for Wordpress Ultimate Members field
View um_vies_vat_validation.php
<?php
/**
* This is a custom validation for Ultimate Members Wordpress plugin
* Apply custom validation to VAT field with the name vat_number
* It requires also a country field
* This expects a user to enter a VAT Number in the following format:
* EL-123456789
*
* Add um_custom_vat_validation on Custom Action field
@sirtimid
sirtimid / template-skroutz.php
Last active Nov 16, 2016
Wordpress WooCommerce Skroutz XML feed generator
View template-skroutz.php
<?php
/*
*Template Name: Skroutz XML
*/
/*
* This Wordpress template generates a xml feed for skroutz.gr
*/
header ("Content-Type:text/xml");
@sirtimid
sirtimid / detonify.js
Created Nov 8, 2016
Detonify a string in Javascript
View detonify.js
String.prototype.detonify = function () {
'use strict';
// set string of characters with tones
let tones = 'ΆάΈέΉήΌόΎύΏώΊΪϊίΫϋ'.split('')
// set the equivalent string of characters without tones
let detones = 'ΑαΕεΗηΟοΥυΩωΙΙιιΥυ'.split('')
let str = this.toString()
for (let key in tones) {
let regex = new RegExp(tones[key], 'g')
str = str.replace(regex, detones[key] || tones[key])
@sirtimid
sirtimid / fade.js
Created Nov 1, 2016
Fade in/out an element with vanilla javascript
View fade.js
/**
* Fade in/out an element
* Note: I am not using requestAnimationFrame as it does not play well in mobile browsers
*
* @param {Object} [options={}] An object with options.
* @param {Element} [options.el] The Element object.
* @param {String} [options.type='in'] The fade type: 'in' or 'out'.
* @param {Integer} [options.duration=400] The duration of the animation in miliseconds.
* @param {String} [options.display='block'] The display property of the element when fade in starts.
* @param {Boolean} [options.empty=false] Set to true if you need to empty the element after fade out.
@sirtimid
sirtimid / wp_cleanup.php
Last active Mar 14, 2017
Cleanup wordpress of unwanted dashboard widgets and injected styles
View wp_cleanup.php
<?php
// filter to remove TinyMCE emojis
if ( !function_exists( 'disable_emojicons_tinymce' ) ) {
function disable_emojicons_tinymce( $plugins ) {
if ( is_array( $plugins ) ) {
return array_diff( $plugins, array( 'wpemoji' ) );
} else {
return array();
}
@sirtimid
sirtimid / get_url_by_template.php
Last active Nov 16, 2016
Get a wordpress page URL by template name
View get_url_by_template.php
<?php
if(!function_exists('get_url_by_template')){
function get_url_by_template($tmpl){
$pages = query_posts(array(
'post_type' =>'page',
'meta_key' =>'_wp_page_template',
'meta_value'=> $tmpl
));
@sirtimid
sirtimid / auto-polylang-media.php
Last active May 15, 2019
Translate media automatically when using Polylang in Wordpress
View auto-polylang-media.php
<?php
if ( !function_exists( 'translate_all_media' ) ) {
function translate_all_media() {
global $polylang;
if(!$polylang) return;
// find languages
$langs = array();
@sirtimid
sirtimid / simple-node-server.js
Last active Jan 27, 2017
A simple node http server that logs all requests
View simple-node-server.js
'use strict'
const http = require('http')
const port = 3000
http
.createServer((request, response) => {
// Set CORS headers
response.setHeader('Access-Control-Allow-Origin', '*');
response.setHeader('Access-Control-Request-Method', '*');
You can’t perform that action at this time.