Skip to content

Instantly share code, notes, and snippets.

View rxnlabs's full-sized avatar

De'Yonte W. rxnlabs

View GitHub Profile
@rxnlabs
rxnlabs / js-gravityform-save-multistep.js
Last active July 7, 2022 12:29
WordPress - Save and submit a multistep form using Gravity Forms. Multistep forms don't allow you to submit the form if the user decides to leave before completing the form. This allows the user to submit the form at any step.
//clone the form submit button for the form
var save_btn = jQuery('#gform_submit_button_2').clone();
//change the label of the midway submit button
save_btn.val('Save and Submit');
//get the ID of the gravity form
var gravity_form = jQuery('#gform_submit_button_2').closest('form');
var gravity_form_id = gravity_form.attr('id');
gravity_form_id = gravity_form_id.split("_");
gravity_form_id = gravity_form_id[1];
//get the last page of the form
@rxnlabs
rxnlabs / php-wp-add-tinymce-button.php
Last active July 2, 2022 15:28
WordPress - Add button to TinyMCE editor in WordPress. Great for creating menus so users can add shortcodes without having to remember the syntax
<?php
/*Add this code to your functions.php file of current theme OR plugin file if you're making a plugin*/
//add the button to the tinymce editor
add_action('media_buttons_context','add_my_tinymce_media_button');
function add_my_tinymce_media_button($context){
return $context.=__("
<a href=\"#TB_inline?width=480&inlineId=my_shortcode_popup&width=640&height=513\" class=\"button thickbox\" id=\"my_shortcode_popup_button\" title=\"Add My Shortcode\">Add My Shortcode</a>");
}
@rxnlabs
rxnlabs / restart-php-7-fpm-homestead-module.bash
Created May 4, 2016 02:08
bash - Restart php-fpm and nginx after comiling and adding a PHP module in Homestead with PHP 7
sudo nginx -s reload
sudo service php7.0-fpm restart
@rxnlabs
rxnlabs / ps-import-mysql-database
Created June 18, 2014 14:24
PowerShell - import mysql file using mysql-cli using PowerShell
& cmd.exe /c "mysql -u root -p -h localhost < myql_database.sql"
@rxnlabs
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
rxnlabs / mongodb-cpanel-install
Last active July 8, 2021 19:20
Install MongoDB on cPanel/WHM
http://www.webmaster.net/how-install-mongodb-centos-6x-or-whm-server
http://linuxdiviner.wordpress.com/2012/07/25/compile-and-install-php-module-without-easyapache-on-cpanel-servers/
1. cd /etc/yum.repos.d
2. vi mongodb.repo
3. Add this code to file
[mongodb]
name=MongoDB Repo
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=0
@rxnlabs
rxnlabs / js-call-javascript-function-by-string.js
Last active August 11, 2020 16:16
JS - Call and execute javascript functions by names by passing the function name as a string. Use case: Pass an event to ALL Google analytics properties on a page.
//http://stackoverflow.com/questions/359788/how-to-execute-a-javascript-function-when-i-have-its-name-as-a-string
// http://www.sitepoint.com/call-javascript-function-string-without-using-eval/
function executeFunctionByName(functionName, context, args) {
var args = [].slice.call(arguments).splice(2);
var namespaces = functionName.split(".");
var func = namespaces.pop();
for(var i = 0; i < namespaces.length; i++) {
context = context[namespaces[i]];
}
return context[func].apply(this, args);
@rxnlabs
rxnlabs / wp-add-admin-user-mysql.sql
Last active May 21, 2020 14:55
WP - WordPress add new admin user to MySQL table using raw SQL queries. Use in case you don't have access to WordPress dashboard since you may not be a user yet.
# MariaDB is throwing an error when attempting to use variables. You will have to hardcode the database tables
SET @username = 'YOUR_USER_NAME';
SET @password = 'YOUR_PASSWORD';
SET @nicename = 'YOUR_NICENAME';
SET @email_address = 'YOUR_EMAIL_ADDRESS';
SET @fullname = 'YOUR_FULL_NAME';
SET @wpdb_prefix = 'wp_';
SET @wpdb_users_table = CONCAT(@wpdb_prefix,'', 'users');
SET @wpdb_usermeta_table = CONCAT(@wpdb_prefix,'', 'usermeta');
@rxnlabs
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
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) {