Skip to content

Instantly share code, notes, and snippets.

View ramonfincken's full-sized avatar

Ramon Fincken ramonfincken

View GitHub Profile
@johnalarcon
johnalarcon / functions.php
Created May 12, 2021 18:32
Remove the /users/ REST API endpoint in WordPress and ClassicPress
/**
* The following code will remove access to the /users/ endpoint. This makes the
* endpoint inaccessible while not blocking access to other endpoints. This code
* works with both WordPress and ClassicPress.
*
* Why do this? The REST API is very handy, however, by default, it exposes data
* that you may not want exposed – namely, your site's usernames. With a list of
* your usernames, the success of a brut-force attack becomes more likely.
*
*/
@johnalarcon
johnalarcon / functions.php
Created October 25, 2020 07:22
Remove plugins from search results in ClassicPress dashboard
/**
* Remove plugins from search results in ClassicPress dashboard.
* A little ditty by Code Potent. https://codepotent.com
*/
// Add slugs for any individual plugins to remove.
function codepotent_plugins_to_remove() {
$slugs = [
'wordfence',
'jetpack',
@richaber
richaber / README.md
Last active March 20, 2024 15:14
Integrate WPML and WP Search with Algolia, customize labels in autocomplete.php per language

First, make sure you have you read and followed the instructions for WPML integration found at https://community.algolia.com/wordpress/wpml.html

Following those instructions will ensure that the content itself has a wpml.locale attribute in the index for faceting, and will expose a window.current_locale JS variable in the page, which you can use for further customization.

From there you should be able to customize the Algolia JS widgets in the autocomplete.php and instantsearch.php templates for your use case.

There is additional documentation about customizing those templates here https://community.algolia.com/wordpress/customize-autocomplete.html and here https://community.algolia.com/wordpress/customize-search-page.html.

The following example(s) extend what is described in the references above, to provide translations for the labels in the autocomplete drop down.

@azaozz
azaozz / image-meta-tests.php
Last active June 20, 2019 13:24
Small WordPress plugin to display and test image meta and creation of missing image sub-sizes
<?php
/**
* Plugin Name: Image Meta Tests (Do not use in production!)
* Description: A small plugin to enable displaying and testing of image attachment meta data. The data is displayed on the Media Library list view screen.
* Version: 0.0.1-private-plugin
* Author: Andrew Ozz
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU
@mbaersch
mbaersch / bot-detection-variable-gtm.js
Last active August 21, 2023 10:33
JavaScript Variable für Google Tag Manager zur Ermittlung eines Bot Markers (zur Verwendung als Benutzerdefinierte Dimension)
function(){
//----------------------------------------------------------------
// Erkennung von Crawlern anhand User-Agent oder Feature-Detection
//----------------------------------------------------------------
//Soll ein einmal bestandender Test innerhalb der Session reichen? Dann hier einschalten
var cache2Session = true;
// --- Ende Setup ---
@MogulChris
MogulChris / custom-acf-admin.js
Last active August 7, 2023 06:25 — forked from ChrisWebbNZ/hierearchical-select-acf.php
Hierarchical select for native Advanced Custom Fields taxonomy fields.
jQuery(document).ready(function($){
//Modify select2 ajax request to include a parent_id parameter, used by custom_acf_taxonomy_hierarchy()
acf.add_filter('select2_ajax_data', function( data, args, $input, field, instance ){
var target_field_key = 'field_5c7634ca3413f'; //YOUR TARGET FIELD KEY HERE
if(data.field_key == target_field_key){
var parent_id = 0; //by default we want terms with parent of 0 (top level)
<?php
/*
Plugin Name: Programmatically add Gravity Forms
Plugin URI: https://daan.kortenba.ch/programmatically-add-gravity-forms/
Description: Programmatically add persistent Gravity Forms forms.
Author: Daan Kortenbach
Version: 0.1
Author URI: https://daan.kortenba.ch/
License: GPLv2 or later
*/
@Niq1982
Niq1982 / wpcli-ai1wm.md
Last active February 21, 2024 04:00
Site migration using All in One WP Migration and WP CLI

Do a backup

Install the plugin

wp plugin install all-in-one-wp-migration --activate

You must reload the page once before continuing

Do the backup

@goranefbl
goranefbl / functions.php
Last active December 24, 2018 09:48
Refer a friend by WPGens - Woocommerce Subscription discount
<?php
add_filter('wcs_new_order_created','gens_renewal_order_created', 10, 2 );
function gens_renewal_order_created($order, $subscription){
$_user_id = $order->get_user_id();
$user_info = get_userdata($_user_id);
$user_email = $user_info->user_email;
$args = array(
'posts_per_page' => -1,
@schollz
schollz / fetch2.js
Created August 27, 2017 15:16
Use Puppeteer to download a webpage after its been processed by javascript
// save as index.js
// npm install https://github.com/GoogleChrome/puppeteer/
// node index.js URL
const puppeteer = require('puppeteer');
(async () => {
const url = process.argv[2];
const browser = await puppeteer.launch();
// use tor
//const browser = await puppeteer.launch({args:['--proxy-server=socks5://127.0.0.1:9050']});