Skip to content

Instantly share code, notes, and snippets.

View abaicus's full-sized avatar

Andrei Băicuș abaicus

View GitHub Profile
@abaicus
abaicus / node.js
Created October 26, 2022 07:50
Get the theme mods for the starter content in PHP format
import fs from 'fs';
import fetch from 'node-fetch';
const run = async () => {
const data = await fetch(
'https://demosites.io/web-agency-gb/wp-json/ti-demo-data/data'
);
const json = await data.json();
fs.writeFile('theme_mods.json', JSON.stringify(json.theme_mods), function (err) {
<?xml version="1.0" encoding="UTF-8" ?>
<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. -->
<!-- It contains information about your site's posts, pages, comments, categories, and other content. -->
<!-- You may use this file to transfer that content from one site to another. -->
<!-- This file is not intended to serve as a complete backup of your site. -->
<!-- To import this information into a WordPress site follow these steps: -->
<!-- 1. Log in to that site as an administrator. -->
<!-- 2. Go to Tools: Import in the WordPress admin panel. -->
<!-- 3. Install the "WordPress" importer from the list. -->
<?xml version="1.0" encoding="UTF-8" ?>
<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your site. -->
<!-- It contains information about your site's posts, pages, comments, categories, and other content. -->
<!-- You may use this file to transfer that content from one site to another. -->
<!-- This file is not intended to serve as a complete backup of your site. -->
<!-- To import this information into a WordPress site follow these steps: -->
<!-- 1. Log in to that site as an administrator. -->
<!-- 2. Go to Tools: Import in the WordPress admin panel. -->
<!-- 3. Install the "WordPress" importer from the list. -->
@abaicus
abaicus / wp-config.php
Created December 2, 2021 10:22
Multisite redirects to the wp-signup.php page
<?php
$allowed_mappings = [
'domain.test',
];
define( 'NOBLOGREDIRECT', isset( $_SERVER['HTTP_HOST'] ) && in_array( $_SERVER['HTTP_HOST'], $allowed_mappings ) );
@abaicus
abaicus / user-insert.php
Last active November 23, 2021 16:08
Inserts 13000 lot of users into the db
<?php
const TEST_USERS_OPT = 'test-users-generated';
$generated = get_option( TEST_USERS_OPT );
if( $generated === 'yes' ) {
return;
}
<?php
/**
* Migrate hfg_builders on demosites.
*/
function demosites_run_builders_migrator() {
$option = 'neve_demosites_header_migrated';
$has_migrated = get_option( $option );
if ( $has_migrated === true ) {
@abaicus
abaicus / ngrok.php
Last active March 15, 2021 16:45
ngrok mu-plugins drop-in for WordPress
<?php
if ( strpos( $_SERVER['HTTP_HOST'], 'ngrok' ) ) {
add_filter( "option_siteurl", 'adapt_ngrok' );
add_filter( "option_home", 'adapt_ngrok' );
}
function adapt_ngrok() {
return 'http://' . $_SERVER['HTTP_HOST'];
}
@abaicus
abaicus / starter-sites-import.sh
Last active October 11, 2019 13:37
Starter sites import
#!/usr/bin/env bash
# Delete all network sites.
wp site list --field=blog_id --allow-root | xargs -I % wp site delete % --yes --allow-root
wp plugin activate neve-pro-addon --network --allow-root;
# Create all onboarding sites and switch theme.
wp themeisle-si list --field=slug --allow-root | xargs -n1 -I % wp site create --slug=% --allow-root
wp site list --field=url --allow-root | xargs -n1 -I % wp --url=% theme activate neve --allow-root
@abaicus
abaicus / Ae.js
Last active May 3, 2019 19:24
After Effects Expressions
// Delay from parent.
delayFrames = 5;
delay = framesToTime(delayFrames);
transform.position + (parent.transform.position.valueAtTime(time-delay) - parent.transform.position.valueAtTime(time))
@abaicus
abaicus / hestia-yoast-breadcrumbs.php
Last active November 26, 2018 20:15
Adding Yoast breadcrumbs to the single post in Hestia / Hestia Pro. This should either be done in a child theme, or in a plugin.
<?php
/**
* Add Yoast breadcrumbs to Hestia Single Post.
*
* There are two ways to do this:
*
* 1. Create a child theme and add this snippet to your functions.php file.
* Check out the docs: https://docs.themeisle.com/article/656-how-to-create-a-child-theme-for-hestia
*