Skip to content

Instantly share code, notes, and snippets.

@lusareal
lusareal / popup-maker-test-rest-api-call.php
Created June 29, 2022 11:12 — forked from marklchaves/popup-maker-test-rest-api-call.php
Check if adblockers like Ghostery block Popup Maker REST API calls
<?php // Ignore this first line when copying to your child theme's functions.php file.
add_action( 'wp_footer', function () { ?>
<script>
(function () {
function testRestApi(url, cb) {
jQuery.ajax({
url: url,
dataType: "text",
type: "GET",
@lusareal
lusareal / geocode-parallel.php
Created January 31, 2020 10:38 — forked from mtmail/geocode-parallel.php
parallel geocoding using PHP
#!/usr/bin/php
<?php
// 1. install https://github.com/stil/curl-easy
//
// composer require stil/curl-easy
//
// 2. fill a text file 'queries.txt' with queries, e.g.
// Berlin
// Madrid
@lusareal
lusareal / loader.js
Created March 4, 2019 17:05 — forked from wpscholar/loader.js
Vanilla JS loader indicator
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 March 4, 2019 17:05 — forked from wpscholar/.htaccess
Set up WordPress Multi Network
# 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]
# 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 February 25, 2019 14:50 — forked from hampusn/wpml-detach-duplicates.sql
SQL queries to detach WPML duplicates and translate them separately.
# 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 February 1, 2019 15:51 — forked from mycarrysun/PHP-get-timezone-from-address.php
Gets the Timezone from an Address based on the current time
<?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 September 7, 2018 14:26 — forked from abrudtkuhl/admin_filter_by_custom_fields.php
WordPress Filter Posts By Custom Field Value In Admin
<?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
*/
<?php
/*
* WordPress Breadcrumbs
* author: Dimox
* version: 2017.21.01
* license: MIT
*/
function dimox_breadcrumbs() {
/* === OPTIONS === */
// умное позиционирование
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) {