Skip to content

Instantly share code, notes, and snippets.

@froger-me
froger-me / wp-specific-auto-updates.php
Last active November 19, 2021 10:19
WordPress auto updates for specific plugins and themes
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
function auto_update_specific_plugins( $update, $item ) {
// Array of plugin slugs to always auto-update
$plugins = array(
'dummy-plugin',
@froger-me
froger-me / wp-request-update.php
Last active August 24, 2018 02:59
WordPress force request update - emulate wp-cron
<?php
require dirname( __FILE__ ) . '/wp-load.php';
add_filter( 'wp_doing_cron', '__return_true' );
wp_maybe_auto_update();
remove_filter( 'wp_doing_cron', '__return_true' );
die();
?>
@froger-me
froger-me / memory-test.php
Created August 31, 2018 03:33
Test memory usage in PHP
<?php
function get_formatted_memory_peak( $bytes, $precision = 2 ) {
$units = array( 'b', 'kb', 'mb', 'gb', 'tb' );
$bytes = max( $bytes, 0 );
$pow = floor( ( $bytes ? log( $bytes ) : 0 ) / log( 1024 ) );
$pow = min( $pow, count( $units ) - 1 );
$bytes /= ( 1 << ( 10 * $pow ) );
return round( $bytes, $precision ) . ' ' . $units[ $pow ];
@froger-me
froger-me / wp-weixin-crossdomain-nexus.php
Last active January 19, 2020 04:04
WP Weixin Crossdomain Nexus - Customize the blog ID used for WeChat API authentication calls when using a subdomain-based multisite network
<?php
/*
Plugin Name: WP Weixin Crossdomain Nexus
Plugin URI: https://gist.github.com/froger-me/c918d7f2c4f88eff1b330a50d8962f23
Description: Requires WP Weixin. Customize the blog IDs used for WeChat API authentication and WeChat Pay transactions when using a domain/subdomain-based multisite network. NEEDS TO BE EDITED BY A DEVELOPER BEFORE USE!
Version: 1.3.5
Author: Alexandre Froger
Author URI: https://froger.me
WC tested up to: 3.8.1
*/
@froger-me
froger-me / wechat-pay-plugin.php
Last active December 3, 2018 13:52
WordPress WeChat Pay integration plugin skeleton
<?php
/*
Plugin Name: WeChat Pay integration plugin skeleton
Plugin URI: https://gist.github.com/froger-me/2c66a842ef8900b017809d7c738130c9
Description: Requires WP Weixin version min 1.3. A skeleton plugin. NEEDS TO BE EDITED BY A DEVELOPER BEFORE USE!
Version: 1.3
Author: Alexandre Froger
Author URI: https://froger.me
WC tested up to: 3.5.2
*/
@froger-me
froger-me / wp-weixin-force-follow-all-browsers.php
Last active April 11, 2022 02:53
WP Weixin - Force users to be followers even if they are not using the WeChat built-in browser.
<?php
// Place this code in your child theme's functions.php or in one of your custom plugins
// Adds an action before displaying a page
add_action( 'template_redirect', 'wp_weixin_force_follow_all_browsers', 0, 0 );
// The action executed before displaying a page
function wp_weixin_force_follow_all_browsers() {
// change `home_url( '/' )` with the URL of an existing page with your Official Account QR code of your choice,
// or add a WordPress filter "wp_weixin_force_follow_all_browsers_url" of your own to change the destination
$page_url = apply_filters( 'wp_weixin_force_follow_all_browsers_url', home_url( '/' ) );

Rsync Github Deploy

Preparation & requirements - on the destination server:

  • Create SSH keys (without passphrase):
cd ~/.ssh
ssh-keygen -t rsa -b 4096 -C "email@host.tld"
@froger-me
froger-me / tw3facts.txt
Created September 11, 2023 09:07 — forked from Berny23/tw3facts.txt
The Witcher 3 - Facts (Mirror)
The Witcher 3 - Facts
Source: http://www.vertigofx.com/public/games/tw3/tw3facts.txt
== dlc/bob/data/gameplay/community/dialogues/chats/chat_beauclair_citizens_01.w2scene:
lw_ww_geralt_of_rivia_wine
== dlc/bob/data/gameplay/community/dialogues/chats/chat_beauclair_citizens_02.w2scene:
mq7015_done
This file has been truncated, but you can view the full file.
-- dlc/bob/journal/bestiary/alp.journal:
chunk = {}
chunk[1] = {
entry = 2,
}
chunk[2] = {
baseName = "alp",
order = 4261412862,
@froger-me
froger-me / s3link-v4.php
Created November 3, 2023 08:50 — forked from kelvinmo/s3link-v4.php
PHP code to generate a pre-signed URL to access a restricted AWS S3 object