Skip to content

Instantly share code, notes, and snippets.

View rxnlabs's full-sized avatar

De'Yonte W. rxnlabs

View GitHub Profile
@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 / css-center-align-menu.css
Last active October 23, 2017 12:32
CSS - Center align navigation menu. Navigation menu for navs whose elements are center align in their container. File for CSS and SCSS
/*******************************TOP NAVIGATION MENU*************************************/
div.navigation {
margin-bottom:30px;
border:0 solid #E7E7E7;
border-width:1px 0
}
/* Main menu settings */
nav#main {
clear:both;
@rxnlabs
rxnlabs / regex-select-between-parentheses
Created July 25, 2014 12:40
Regex - Select characters between two parentheses. PHP based
// http://www.regexr.com/397dr
/\((.*?)\)/s
@rxnlabs
rxnlabs / xampp-enable-ssl
Created July 30, 2014 14:13
XAMPP - enable ssl on Mac
sudo ./Applications/XAMPP/xamppfiles/xampp enablessl
@rxnlabs
rxnlabs / sublime-text-example-project-file-1920.json
Last active August 29, 2015 14:04
Sublime Text - SublimeText 3 example project file. One I personally use
{
"folders":
[
{
"follow_symlinks": true,
"path": "."
}
],
"settings":
{
@rxnlabs
rxnlabs / wp-php-woocommerce-convert-new-post-type.php
Last active February 28, 2018 15:20
WP - PHP Convert/Update/Migrate WooCommerce data attributes to a new custom post type. Convert WooCommerce products to new custom post type. Should be used from the Command Line. This was used to convert a WooCommerce store to another post type when WooCommerce was no longer needed.
<?php
ini_set('memory_limit','1500M');
/**
* Update/Covert all WooCommerce Products data to a new post type
*
* Moving all WooCommerce custom data to a new custom post type. Should only be executed from CLI since it uses so many processes.
*
* @author De'Yonte W. <admin@rxnlabs.com>
* @return void
*/
@rxnlabs
rxnlabs / command-line-zip-folder-cli
Last active October 23, 2017 12:33
Command Line - Zip folder and all files (gzip, bz2)
tar -cvzf filename.tar.gz folder
tar -cvjf filename.tar.bz2 folder # even more compression
@rxnlabs
rxnlabs / php-wp-change-template-page.php
Last active August 29, 2015 14:06
WP - PHP WordPress chage page template at run time
<?php
add_filter( 'template_include', 'my_callback' );
function my_callback( $original_template ) {
if ( some_condition() ) {
return SOME_PATH . '/some-custom-file.php';
} else {
return $original_template;
}
@rxnlabs
rxnlabs / wordpress-php-upgrade-database-command-line
Created September 8, 2014 17:55
WP - PHP upgrade WordPress database from the command line. Useful if upgrading a large database or upgrading multiple sites and you don't want to visit each sites dashboard.
#initialize PHP interactive shell
php -a
require 'wp-load.php';ini_set('memory_limit',-1);require 'wp-admin/includes/admin.php';require 'wp-admin/includes/upgrade.php';wp_upgrade();
@rxnlabs
rxnlabs / php-get-first-value-serailized-multidimensional-array.php
Last active August 29, 2015 14:06
PHP - Get the first value from a multidimensional array where the first value may be a serialized array.
<?php
/**
Get first value from multidimensional serialized array
*/
function get_value_from_multidimensional_array( $possible_array ){
if( is_array($possible_array) ){
$maybe_serialized = @unserialize($possible_array[0]);
if( $maybe_serialized !== false ){
$possible_array[0] = $maybe_serialized;