Skip to content

Instantly share code, notes, and snippets.

lusareal

Block or report user

Report or block lusareal

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
@lusareal
lusareal / loader.js
Created Mar 4, 2019 — forked from wpscholar/loader.js
Vanilla JS loader indicator
View loader.js
function Loader(el) {
el.loader = this;
this.el = el;
this.style = document.getElementById('js-loader-styles');
this.init();
if (!document.body.animate) {
if (!this.style) {
this.style = document.createElement('style');
@lusareal
lusareal / .htaccess
Created Mar 4, 2019 — forked from wpscholar/.htaccess
Set up WordPress Multi Network
View .htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
View Rewrite rule which strips all query params where the key begins with "utm_" (Google Analytics)
# Google Analytics & Campaign Monitor
# Removes all query params where the key begins with "utm_"
# Skip the rewrites if no "utm_*" key exist.
RewriteCond %{QUERY_STRING} !(^|&)utm_ [NC]
RewriteRule .* - [S=3]
# Check and handle first query param.
RewriteCond %{QUERY_STRING} ^utm_[A-Za-z0-9]+=[^&]+(.*) [NC]
RewriteRule (.*) /$1?%1 [R=301,L]
@lusareal
lusareal / wpml-detach-duplicates.sql
Created Feb 25, 2019 — forked from hampusn/wpml-detach-duplicates.sql
SQL queries to detach WPML duplicates and translate them separately.
View wpml-detach-duplicates.sql
# Select all posts which are duplicates of a language.
# The language parameter is to only select by the new language (not the original duplication language).
SET @lang_code = 'da';
SELECT pm.*, p.post_title, p.post_type, icl.language_code
FROM wp_postmeta pm
INNER JOIN wp_icl_translations icl ON icl.element_id = pm.post_id
INNER JOIN wp_posts p ON p.`ID` = pm.post_id
WHERE meta_key='_icl_lang_duplicate_of' AND icl.language_code = @lang_code;
@lusareal
lusareal / PHP-get-timezone-from-address.php
Created Feb 1, 2019 — forked from mycarrysun/PHP-get-timezone-from-address.php
Gets the Timezone from an Address based on the current time
View PHP-get-timezone-from-address.php
<?php
$addr = 'Columbus,OH,43235';
$maps_api_key = 'insert key here';
/**
* Gets the timezone id (eg. America/New_York, America/Detroit)
* @param string $address
* @return string|bool
*/
function get_timezone_from_address($address){
@lusareal
lusareal / admin_filter_by_custom_fields.php
Created Sep 7, 2018 — forked from abrudtkuhl/admin_filter_by_custom_fields.php
WordPress Filter Posts By Custom Field Value In Admin
View admin_filter_by_custom_fields.php
<?php
/*
Plugin Name: Admin Filter BY Custom Fields
Plugin URI: http://en.bainternet.info
Description: Filter posts or pages in admin by custom fields (post meta)
Version: 1.0
Author: Bainternet
Author URI: http://en.bainternet.info
*/
View dimox_breadcrumbs.php
<?php
/*
* WordPress Breadcrumbs
* author: Dimox
* version: 2017.21.01
* license: MIT
*/
function dimox_breadcrumbs() {
/* === OPTIONS === */
View gist:77bfed655748f359b5f394230e6e4df0
// умное позиционирование
var win = $(window);
var topOffset = selectbox.offset().top;
var bottomOffset = win.height() - selectHeight - (topOffset - win.scrollTop());
var visible = opt.selectVisibleOptions;
var minHeight = liHeight * 6;
var newHeight = liHeight * visible;
if (visible > 0 && visible < 6) minHeight = newHeight;
// раскрытие вверх
if (bottomOffset < 0 || bottomOffset < minHeight) {
View functions.php
<?php
/**
* Recursively get taxonomy hierarchy
*
* @source http://www.daggerhart.com/wordpress-get-taxonomy-hierarchy-including-children/
* @param string $taxonomy
* @param int $parent - parent term id
*
* @return array
@lusareal
lusareal / custom-queries.php
Created Apr 10, 2018 — forked from carlodaniele/custom-queries.php
An example plugin showing how to add custom query vars, rewrite tags and rewrite rules to WordPress
View custom-queries.php
<?php
/**
* @package Custom_queries
* @version 1.0
*/
/*
Plugin Name: Custom queries
Plugin URI: http://wordpress.org/extend/plugins/#
Description: This is an example plugin
Author: Carlo Daniele
You can’t perform that action at this time.