Skip to content

Instantly share code, notes, and snippets.

View dev-w3's full-sized avatar
💻
Working from home

W3use dev-w3

💻
Working from home
View GitHub Profile
@dev-w3
dev-w3 / git-commands
Last active December 19, 2019 11:39
git init
git config --list --show-origin
git config --global user.name 'dev-w3'
git config --global user.email 'dev-w3@yahoo.com'
git config --list
git remote add origin https://github.com/dev-w3/nodeone.git
git status
git add .
git stash
@dev-w3
dev-w3 / tabbed-description.liquid
Last active March 13, 2020 07:10
Shopify: Tabs for product descriptions
{% comment %}
if combine_pretext is false, the text before the first <h6> will be shown above all tabs, otherwise added to the first tab
{% endcomment %}
{% assign combine_pretext = false %}
{% assign description = tabbed-description | default: product.description %}
{% if description contains "<h6>" %}
{% assign tab_heads = '' %}
{% assign tab_texts = '' %}
{% assign pretext = '' %}
@dev-w3
dev-w3 / CSVmanager.php
Last active April 12, 2024 17:37
CSV Manager for WP Store Locator
<?php
#CSV Manager for WP Store Locator
#https://wordpress.org/plugins/wp-store-locator/
// Redirect to 404 if script is accessed directly
if ( ! defined("ABSPATH") ) {
header("Location: http://{$_SERVER['HTTP_HOST']}/404");
die;
};
@dev-w3
dev-w3 / isVisible.js
Created March 13, 2020 07:06
jQuery event to trigger action when a Element is made visible
jQuery(document).ready(function ($) {
let alreadyThere = false;
$.fn.isVisible = function (topSet = 0) {
_this = $(this);
_this = (typeof _this == 'object' || typeof _this == 'function') ? _this.get(0) : _this;
const rect = _this.getBoundingClientRect();
return (
rect.bottom >= 0 &&
add_action( 'rest_api_init', 'register_api_hooks' );
add_action( 'rest_api_init', 'wp_rest_user_endpoints' );
function register_api_hooks() {
register_rest_route(
'apihandle/', '/login/',
array(
'methods' => 'POST',
'callback' => 'login_api',
@dev-w3
dev-w3 / getalllinks.php
Created March 10, 2021 09:49
Get All href link from third party URL
<?php
$curl = curl_init('https://www.domain.com/outwell/posadas-foldaway-bed-single');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($curl,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13');
$page = curl_exec($curl);
$related_products = array();
// Get Content Inside of productdetail_lblProductName Div/ Regex Match
$regex = '/<div id="productdetail_lblProductName">(.*?)<\/div>/s';
@dev-w3
dev-w3 / wix.js
Last active July 21, 2021 09:09
Wix - Velo: Accessing 3rd-Party Services with the Fetch API
// API Reference: https://www.wix.com/velo/reference/api-overview/introduction
// “Hello, World!” Example: https://learn-code.wix.com/en/article/1-hello-world
import wixData from 'wix-data';
import { getJSON } from 'wix-fetch';
import {local} from 'wix-storage';
export function getrentallistings () {
const mySecret = 'key_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
<?php
## Function to set file permissions to 0644 and folder permissions to 0755
function AllDirChmod( $dir = "./", $dirModes = 0755, $fileModes = 0644 ){
$d = new RecursiveDirectoryIterator( $dir );
foreach( new RecursiveIteratorIterator( $d, 1 ) as $path ){
if( $path->isDir() ) chmod( $path, $dirModes );
else if( is_file( $path ) ) chmod( $path, $fileModes );
}
@dev-w3
dev-w3 / hidepaymentmethod.php
Last active July 21, 2021 09:06
To hide payment method if coupon is applied in woo-commerce
<?php
add_filter('woocommerce_available_payment_gateways', '_hide_payment_gateways', 20, 1 );
function _hide_payment_gateways( $available_gateways){
// Not in backend (admin)
if( is_admin() )
return $available_gateways;
// If at least a coupon is applied
if( sizeof( WC()->cart->get_applied_coupons() ) > 0 ){