Skip to content

Instantly share code, notes, and snippets.

View rxnlabs's full-sized avatar

De'Yonte W. rxnlabs

View GitHub Profile
@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 / 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 / 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 / git-file-conflicts-list.sh
Created June 19, 2016 18:28
Git - View list of file conflicts
git ls-files -u
@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 / 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 / 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 / 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 / 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
@rxnlabs
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
<?php
$url = 'https://insert-domain-here.com/api-endpoint';
// 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 );
}
/*