Skip to content

Instantly share code, notes, and snippets.

View rxnlabs's full-sized avatar

De'Yonte W. rxnlabs

View GitHub Profile
@rxnlabs
rxnlabs / wordpress-enable-jetpack-dev-mode.php
Created October 3, 2018 13:08
WordPress - Enable Jetpack development mode if WP_DEBUG is true and Jetpack is NOT connected to WordPress.com. Useful if you want to test out Jetpack modules without needing to be connected to WordPress.com or if doing development from a localhost site
<?php
/**
* Enable Jetpack development mode if WP_DEBUG is true and jetpack is not active/connected to WordPress.com
* See: https://jetpack.com/support/development-mode/
*/
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
if ( method_exists( '\\Jetpack', 'is_active' ) && is_callable( array( '\\Jetpack', 'is_active' ) ) ) {
$jetpack_reflection = new \ReflectionMethod( '\\Jetpack', 'is_active' );
@rxnlabs
rxnlabs / wordpress-get-widget-id-name.php
Last active May 30, 2018 12:41
WordPress - Get the name and id of the widget area being used to display a certain widget. This adds the widget ID and widget area name as HTML comments to the frontend of the site
<?php
/**
* Add the widget ID and widget name as HTML comments.
*
* Makes it easiser to identify exactly which widget area a widget is appearing in.
* This helps a lot with themes that have a lot of sidebars and uses a lot of widgets.
*/
function which_dynamic_sidebar( $sidebar_params ) {
$sidebar_params['0']['class'] = empty( $sidebar_params['0']['class'] )?$sidebar_params['0']['id']:$sidebar_params['0']['class'].' '.$sidebar_params['0']['id'];
$sidebar_params['0']['before_widget'] = '<!--Widget-Area:id:'.esc_attr($sidebar_params['0']['id']).';name:'.esc_attr($sidebar_params['0']['name']).'-->'.$sidebar_params['0']['before_widget'];
@rxnlabs
rxnlabs / sass-scss-mixinx-default-display-block.scss
Last active August 30, 2017 16:46
SASS/SCSS Mixin with a list of elements with default display: block List from : https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements
// List from https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements
@mixin block-elements($context: '') {
#{$context} address,
#{$context} article,
#{$context} aside,
#{$context} blockquote,
#{$context} canvas,
#{$context} dd,
#{$context} div,
@rxnlabs
rxnlabs / regex
Created January 6, 2017 21:12
Regular Expression - Find comments in a file /* comments. Found here http://blog.ostermiller.org/find-comment
/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/
@rxnlabs
rxnlabs / git-file-conflicts-list.sh
Created June 19, 2016 18:28
Git - View list of file conflicts
git ls-files -u
@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 / additional-wordpress-columns-tables-updtae-after-moving.txt
Last active October 23, 2017 12:40
PHP + Bash - Move plugins from wordpress single install to composer.json file
# Change the upload path of the sites to make sure media files still work
SELECT * FROM wpdb_6_options WHERE option_name IN ('upload_path', 'upload_url_path');
@rxnlabs
rxnlabs / salsascript-storefront-get-items-in-stock.js
Created March 18, 2016 20:02
SalsaScript - Get stock of items in Salsa storefront using SalsaScript
<script type="text/javascript">
var storefront_items_stock = {};
<?
var storefront = DB.getObjects('store_item');
for each (item in storefront) {
print('storefront_items_stock[');
print( item.store_item_KEY );
print( '] = ' );
print( item.Number_in_Stock );
print( ';\n');
@rxnlabs
rxnlabs / sass-breakpoint-susy-media-mixin.sass
Last active March 17, 2016 18:17
SASS - Media Query mixins with support for Breakpoint and Susy-media mixins. Uses SASS conditional logic to check if the Breakpoint media query mixin or the Susy-media mixin exists. Fallbacks to regular media query if neither mixin exists
$media-query-mixin-warning: "You should be using the Breakpoint SASS mixin library or the Susy Grid mixin to take advantage of cool features. Your media query will still compile though"
=phone-only
+phone("down")
@content
=tablet-only
+tablet("only")
@content
@rxnlabs
rxnlabs / wp-cli-reset-password
Created March 9, 2016 15:37
WordPress - WP CLI reset user's password using wp-cli
wp db query "UPDATE wp_users SET user_pass=MD5('new_password_here') WHERE user_login='username'"