Skip to content

Instantly share code, notes, and snippets.

View rxnlabs's full-sized avatar

De'Yonte W. rxnlabs

View GitHub Profile
rxnlabs / package.json
Last active May 29, 2024 17:28
Custom RollupJS configuration file to support multiple entry points using a Glob import and also excluding entries using a Glob import. Outputs all of the entries to a custom directory and supports exporting as an IIFE (unlike and…
"name": "custom-rollup-js-config-multi-entry-glob",
"version": "0.1.0",
"description": "package.json for custom RollupJS configuration that supports glob'ing entries from a directory or multiple directories",
"author": "rxnlabs",
"license": "GPL-2.0-or-later",
"scripts": {
"dev": "npm run scripts -- --watch",
"build": "npm run scripts",
"scripts": "rollup --config"
rxnlabs / redirect-apache-git-folder
Created July 25, 2023 16:15
Apache - .htaccess prevent Git repos .git/ folder from being viewable
# BEGIN Cornershop
# VCS lockdown
# Deny access to version control content
# Will not work if both Alias & Rewrite modules are disabled
# To verify with git content, check these two URLs:
# 1. /.git/HEAD
# 2. /.gitignore
<IfModule mod_alias.c>
# Deny access to VCS content using Alias Module
RedirectMatch 404 ^(.*/)?\.(git|svn|hg|bzr)+
rxnlabs / wp-allow-external-ajax-cors.php
Last active June 27, 2023 20:02
WordPress - Allow CORS headers for external sites. Allow external site to make an AJAX request against the WP site if you don't have access to the .htaccess file or your site is hosted on an NGINX server
* Add CORS HTTP headers to the page request to allow the MTS curriculm site to make an AJAX request against the site
* Modify the HTTP headers that WordPress outputs before they are sent so we can add CORS headers to the request for things like an AJAX request
* @param array $headers The HTTP headers that WordPress is about to send
* @param WP $wp The current WordPress environment instance
rxnlabs / experimental-theme.json
Last active October 15, 2021 16:09 — forked from thetwopct/experimental-theme.json
An actual working experimental-theme.json as the WordPress documentation is utter shit
"templateParts": {
"header": {
"area": "header"
"footer": {
"area": "footer"
"settings": {
rxnlabs /
Last active July 14, 2023 09:23
Gravity Forms - GFAPI::submit_form bug when the $_POST variable contains existing data because of array_merge_recursive

Gravity Forms GFAPI::submit_form bug

There is a bug with the Gravity Forms GFAPI::submit_form method when the $_POST variable contains any existing values that match what you pass to GFAPI::submit_form.

Because GFAPI::submit_form internally uses array_merge_recursive, any existing values in the $_POST variable will be added to any values that exist in the second parameter that you pass to GFAPI::submit_form.

This bug appears in the latest version of Gravity Forms and in the latest 2.5 beta.

UPDATE ON 07/14/2023: This is a known bug in Gravity Forms and the plugin developers (i.e. Rocket Genius) are aware of it. Since other developers have made custom workaround to get around this issue, patching this bug would break that custom code, so Rocket Genius has not patched it. This code is probably present in the latest version of the plugin and will probably be present in all future versions.

rxnlabs /
Last active August 31, 2023 13:41
WordPress - WP: Add /blog to your Post post type only and remove it from your other custom post types and taxonomies after adding /blog

Add a /blog to your WordPress blog posts only and remove it from the other post types

This is useful if you want to know when a user is viewing a blog post in Google Analytics vs a page. Or if you want to just have an easy way to distinguish your blog content from your other content using the URL.

There may be an easier way to do this but all of my Googling didn't turn up any answers that let you modify the post URLs only.

  1. Add the code from remove-blog-front-from-custom-post-types.php to your theme's functions.php or to a custom plugin or some file where it will get loaded. This code prevents the new blog base from being applied to the URLs of Custom POst types and taxonomy archives.
  2. Log into your WordPress admin
  3. Go to Settings -> Permalinks
  4. Select the Custom Structure field and add /blog to the Permalink structure (add this before the /%postname% part of the URL
rxnlabs / js-fill-height-of-viewport-width-section-minus-header-height.js
Created April 2, 2020 14:31
CSS + JS - Fill height of viewport with section minus the header height
$( window ).on( 'resize', debounce( function () {
var $header = $('.site-header');
$.each($('.content-section.type-hero'), function (index, node) {
var $hero = $(node);
$hero.css('height', 'calc(100vh - ' + $header.height() + 'px)');
} ) );
function debounce( func, wait, immediate ) {
var timeout;
rxnlabs / wp-admin-popup-replace-image.js
Created December 22, 2019 14:53
JS - WP (WordPress) admin replace featured image when we don't have access to SSH
Run as a bookmarklet in your browser. Run in the WordPress admin area. Set the WordPress admin posts view number really high from the default 20 posts to something like 500 posts to decrease the number of times we need to run this.
Make sure to disable your browser's popup blocker since this will open a LOT of windows.
Update the featured image of all of the posts that in the WordPress admin on the Posts table page
(function() {
/*Check if a value is a positive, whole number integer*/
function isNormalInteger(str) {
rxnlabs / wp-upload-file-post-wp-http.php
Last active July 18, 2023 20:13
WordPress - Upload files to remote API using WP_Http / wp_remote_post + cURL + fsockopen + CurlFile
$url = '';
// The file is stored on your system/host
$path_to_uploaded_file = '/full-path-to-file/picture.jpg';
$form_fields = [ 'first_name' => 'Foo', 'last_name' => 'Bar' ];
if ( file_exists( $path_to_uploaded_file ) ) {
$form_fields['profile_picture'] = new CurlFile( $path_to_uploaded_file );
rxnlabs / facebook-detect-embed-link-regex.php
Created November 8, 2018 01:17
PHP - Detect if a link text contains Facebook embeddable content using regular Expressions