Skip to content

Instantly share code, notes, and snippets.

View khromov's full-sized avatar

Stanislav Khromov khromov

View GitHub Profile
@khromov
khromov / README.md
Last active September 20, 2020 22:04
docker-compose file for phpMyAdmin and MySQL
@khromov
khromov / polylang-multilingual-sitemap.php
Last active October 9, 2022 21:15
Multilingual Polylang sitemaps for "XML Sitemap & Google News" plugin
<?php
/**
* Plugin Name: Multilingual Polylang sitemaps for "XML Sitemap & Google News" plugin
* Description: For https://wordpress.org/plugins/xml-sitemap-feed/
* Version: 1.0
*/
add_action('xmlsf_tags_after', function () { // xmlsf_tags_after
//Bail early.
if (!function_exists('pll_languages_list')) {
@khromov
khromov / functions.php
Created April 7, 2020 19:38
WP Recipe Maker
<?php
// Your themes functions.php
add_action( 'init', function() {
add_rewrite_rule(
'recipe/([0-9]+)/?$',
'index.php?pagename=recipe&recipe_id=$matches[1]',
'top' );
});
@khromov
khromov / built-share-[id].js
Created March 24, 2020 20:44
Next.js built chunks
(window.webpackJsonp = window.webpackJsonp || []).push([
[21], {
"+51p": function(t, n, e) {
"use strict";
e.r(n), e.d(n, "__N_SSP", (function() {
return m
}));
var o = e("q1tI"),
r = e.n(o),
c = e("8Kt/"),
@khromov
khromov / PWAOfflineStatus.js
Last active July 26, 2020 04:57
React Progressive Web App Online / Offline warning message hook
import React, { useState, useEffect } from 'react';
function PWAOfflineStatus(props) {
const [isOnline, setOnlineStatus] = useState(true);
// https://stackoverflow.com/questions/44756154/progressive-web-app-how-to-detect-and-handle-when-connection-is-up-again
useEffect(() => {
const setFromEvent = function(event) {
if(event.type === 'online') {
setOnlineStatus(true);
@khromov
khromov / README.md
Last active May 16, 2020 07:38
Migrate an Amazing Marvin list to Wallabag

Migrate an Amazing Marvin reading list to Wallabag

Example: You've been using the Amazing Marvin Bookmarklet and now the tasks have piled up and Marvin is acting sluggish. Wallabag is a prefect place to migrate these bookmarks.

Prerequisites

  • PHP 7
  • Python 3

Process

  • Export one or more of your reading lists containings URLs from Amazing Marvin by going to Account > Backups > Backup.
@khromov
khromov / wp-config.php
Last active October 1, 2019 08:58
Convert MySQL connection string to wp-config.php parameters
<?php
//...
// This will usually be received from an env variable, for example $connectionString = getenv('DB_URL');
$connectionString = 'mysql://user:password@foo-bar.rds.amazonaws.com:3306/database';
// The values below will be your default values if $connectionString is empty.
$dbConfig = array_merge(
[
'host' => 'localhost',
@khromov
khromov / README.md
Created July 12, 2019 08:38
Amazing Marvin webhook

Webhook for Amazing Marvin

In order for this to work you need to fetch your Zapier token from Marvin Settings > Strategies > Zapier integration > Settings.

However, you don't actually need a Zapier for this to work, just send the request from your favourite framework.

@khromov
khromov / fix-broken-instagram.php
Last active March 1, 2018 11:33
Fix broken / overlapping Instagram embed for WordPress
<?php
/**
* Plugin Name: Fix broken Instagram oEmbed
* Description: Fixes an issue with Instagram posts being broken when multiple posts are oEmbedded.
* Version: 1.0
* Author: khromov
*/
/**
* Remove Instagram embed.js script on each embed
@khromov
khromov / infogram-oembed.php
Created October 19, 2017 12:25
Infogram oEmbed plugin
<?php
/*
Plugin Name: Infogram oEmbed
Plugin URI:
Description: Adds oEmbed support for infogr.am and infogram.com urls.
Author: khromov
Version: 1.0
Author URI: https://khromov.se
*/