Skip to content

Instantly share code, notes, and snippets.

View Jehu's full-sized avatar

Marco Michely Jehu

View GitHub Profile
@adamslowe
adamslowe / WP-CLI Default Site Settings
Created January 8, 2024 01:59
WP-CLI Default Site Settings
# WP Config Settings
wp config set AUTOMATIC_UPDATER_DISABLED true
wp config set CORE_UPGRADE_SKIP_NEW_BUNDLED true
# Changing Site URL to https
wp option get siteurl | sed "s/http:/https:/g" | xargs -I {} wp option update siteurl {}
wp option get home | sed "s/http:/https:/g" | xargs -I {} wp option update home {}
# Install themes & plugins
@Suleman-Elahi
Suleman-Elahi / worker.js
Created March 4, 2022 05:17
Sending Free Emails from Cloudflare Workers using MailChannels Send API. You do not need an account with MailChannels in order to start sending email. You also do not have to verify your domain with Cloudflare.
addEventListener("fetch", event => {
event.respondWith(handleRequest(event.request))
})
let body = {};
async function handleRequest(request) {
let content = "just drop if it fails...okay ?";
for( var i of request.headers.entries() ) {
content += i[0] + ": " + i[1] + "\n";
}
let respContent = "";
@Spellhammer
Spellhammer / urlparamexistscondition
Last active August 15, 2022 10:30
Check for presence of URL parameter condition for Oxygen
if( function_exists('oxygen_vsb_register_condition') ) {
global $oxy_condition_operators;
// Condition to check if a URL parameter is present.
oxygen_vsb_register_condition('URL Param Exists', array('options'=>array(), 'custom'=>true), array('--'), 'oxy_url_param_exists_callback', 'Other');
function oxy_url_param_exists_callback($value, $operator) {
if( isset($_GET[$value]) && $_GET[$value] ) {
@Jehu
Jehu / plugin.php
Last active November 29, 2019 09:56
Use Groundhogg contact fields inside WPForms as smart tags
<?php
/**
* Plugin Name: WPForms GH Contact Smart Tag
* Plugin URI:
* Description: Use Groundhogg contact fields inside WPForms with Smart Tags. Se here for more informations about WPFOrms Smart Tags: https://wpforms.com/docs/how-to-use-smart-tags-in-wpforms/
* Version: 1.0
* Author: Marco Michely
* Author URI: https://www.michely-web-engineering.de
*/
defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
Date: select first date
StartOfDateWeek: fromTimestamp(timestamp(prop("Date")) - (((day(prop("Date")) == 0) ? 7 : ((day(prop("Date")) - 1) * 24 + toNumber(formatDate(prop("Date"), "H")))) * 60 + toNumber(formatDate(prop("Date"), "m"))) * 60 * 1000)
WeeksFromOriginal: ceil(dateBetween(now(), prop("Date"), "days") / 7)
NearestDate: dateAdd(prop("Date"), prop("WeeksFromOriginal"), "weeks")
Whenever it's 24 hours from last event, NearestDate should update to same + 7 days.
@ebetancourt
ebetancourt / wp-disable-plugin-update.php
Last active March 29, 2024 13:03 — forked from rniswonger/wp-disable-plugin-update.php
WordPress - Disable specific plugin update check
<?php
// have to add that opening tag to get syntax highlighting... ¯\_(ツ)_/¯
/**
* Prevent update notification for plugin
* http://www.thecreativedev.com/disable-updates-for-specific-plugin-in-wordpress/
* Place in theme functions.php or at bottom of wp-config.php
*/
function disable_plugin_updates( $value ) {
@imelgrat
imelgrat / check-youtube-id.php
Last active April 27, 2018 05:27
Verify whether a YouTube video exists using PHP and oEmbed status codes. Instead of actually fetching the video’s URL using a tool suchas a cURL, we can speed things up by just checking the response headers by using PHP’s get_headers() function. Full article: https://imelgrat.me/json-xml/oembed-protocol-embed-videos-news/
<?php
/**
* @author Ivan Melgrati
* @copyright 2018
*/
function YouTube_Check_ID($videoID)
{
$is_valid = true;
@jaircuevajunior
jaircuevajunior / change_wordpress_domain.md
Last active July 20, 2019 10:43
Change/Migrate wordpress domain in MySQL

Find/Replace within dump method

This is a very simple method, and for me (as a SysAdmin) it's very practical as I usually make things through SSH terminal.

It's important to say that everything (including text inside posts) that matches the find string WILL BE REPLACED!

For me it's never been a problem so far, but one never knows

First we generate the dump itself, for example:

mysqldump -umyuser -pmypass mydatabase > mydumpfile.sql
@JustThomas
JustThomas / wordpress-multisite-internal-redirect-loop.md
Last active March 27, 2024 14:45
WordPress Multisite: How to fix error "too many redirects"

WordPress Multisite: How to fix error "Request exceeded the limit of 10 internal redirects"

I am running a WordPress multisite network with sub-directory setup. When I check my error.log file, it is full of entries like this one:

Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'Limit InternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

The problem was, in my case, one specific rewrite rule in the .htaccess file.

Problem description

@dperetti
dperetti / call_modal_client.js
Last active February 27, 2020 05:54
Meteor Handlebars modal pattern
Session.set('modalData', {template: "modal-backups", title: "Backup", files: [{name: "blah", date: new Date()}]});
$('#myModal').modal();