Skip to content

Instantly share code, notes, and snippets.

View ramonfincken's full-sized avatar

Ramon Fincken ramonfincken

View GitHub Profile
@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)
@jeremyfelt
jeremyfelt / open-source-search-compare.md
Last active July 19, 2023 01:28
Comparing open source search solutions
@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']});
@CMCDragonkai
CMCDragonkai / environment_variables_for_php_applications.md
Last active January 4, 2023 19:36
Environment Variables for PHP Applications #php #configuration

Environment variables for PHP Applications

According to 12 factor app, the best way to configure things for deployment is through environment variables, not necessarily environment variable files, but just any environment variables. The problem is how to get environment variables into PHP. It is quite complicated depending on what you're doing.

The first step is to make sure you're using getenv in PHP for environment variables as the $_ENV array may not be set unless you set variables_order=EGPCS in the INI settings. This is enough for command line PHP applications including the command line PHP server.

If you're running PHP through Apache either via mod_php or CGI, the only way is to use an .htaccess file along the path from the index.php to the document root and to use SetEnv NAME Value directives. Or you put them into the Virtual Host block inside Apache configuration.

If you're using NGINX + PHP-FPM. You have 3 options:

@mikejolley
mikejolley / gist:d4c46102d69d4560abb6
Created March 21, 2016 11:13
WooCommerce - Allow non-admin access to backend, and enable admin_bar
/* Code goes in theme functions.php */
add_filter( 'woocommerce_prevent_admin_access', '__return_false' );
add_filter( 'woocommerce_disable_admin_bar', '__return_false' );
@stefanzweifel
stefanzweifel / slack.php
Created May 8, 2014 13:26
Slack.com Webhook Integration (PHP) - Simple snippet which tells you, how to build your payload array.
<?php
//Options
$token = 'YOUR_TOKEN_HERE';
$domain = 'YOUR_SLACK_DOMAIN_GOES_HERE';
$channel = '#general';
$bot_name = 'Webhook';
$icon = ':alien:';
$message = 'Your message';
<?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
*/
@sergejmueller
sergejmueller / index.html
Last active December 14, 2021 09:50
Embedded Google Analytics: Fix “Leverage Browser Caching” Warning on Nginx
<html>
<!-- ... -->
<!-- Embed analytics.js as local file -->
<script src="/analytics.js"></script>
</html>
@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',