Skip to content

Instantly share code, notes, and snippets.

View wolfcoder's full-sized avatar
💭
Full Stack Developer

bams wolfcoder

💭
Full Stack Developer
View GitHub Profile
@wolfcoder
wolfcoder / gist:b3cf1fd231b3b84c428eea38ba096eb4
Created November 1, 2023 06:26
Colorado Woocommerce fee WordPress
//Colorado fee
/**
* Add a .27 surcharge to orders shipping to Colorado
* https://www.thathandsomebeardedguy.com/woocommerce-colorado-retail-delivery-fee/
*/
add_action('woocommerce_cart_calculate_fees', 'handsome_bearded_guy_custom_surcharge');
function handsome_bearded_guy_custom_surcharge() {
global $woocommerce;
@wolfcoder
wolfcoder / sample-guttenberg-block.php
Last active May 18, 2023 03:45
sample guttenberg block
const { registerBlockType } = wp.blocks;
registerBlockType( 'my-plugin/hello-world', {
title: 'Hello World',
icon: 'smiley',
category: 'common',
edit: () => {
return (
<p>Hello World!</p>
);
<?php
/*
Plugin Name: Meta Box Example
Description: Example demonstrating how to add Meta Boxes.
Plugin URI: https://plugin-planet.com/
Author: Jeff Starr
Version: 1.0
*/
// register meta box
@wolfcoder
wolfcoder / navigation-ii.js
Created June 11, 2022 12:01
navigation menu open overlay
class NavigationII{
//1. Describe and initiate our object
constructor() {
this.openMenu = document.getElementById('open-menu')
this.closeMenu = document.getElementById('close-menu')
this.mobileMenu = document.getElementById('mobile-menu')
this.htmlBody = document.getElementsByTagName('body')
this.events()
}
@wolfcoder
wolfcoder / index.php
Last active June 9, 2022 14:13
wordpress database management
<?php
global $wpdb;
$tbl = $wpdb->prefix . 'posts';
$post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d", 1 ) ); // posts can reference in the phpstorm
$prefix_post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $tbl WHERE ID = %d", 1 ) ); // phpstorm: unable to resolve ID
$prepare_query = $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE ID = %d", 1 );
$prepare_result = $wpdb->get_col( $prepare_query ); // 1
<?php
defined( 'ABSPATH' ) || exit;
global $vap, $vap_sync;
$lastsync_option = $vap_sync->vap_get_lastsync();
$ls_timestamp = $lastsync_option['timestamp'];
$ls_category = $lastsync_option['category'];
$ls_page = $lastsync_option['page'];
<?php
global $vap, $vap_settings;
if( isset( $_REQUEST['vap_setting_save'] ) && isset( $_REQUEST['vap_setting'] ) && $_REQUEST['vap_setting'] != '' ) {
do_action( 'vap_save_settings', $_POST );
}
echo '<div class="wrap vap_content">';
if( isset( $_SESSION['vap_cfg_msg_status'] ) && $_SESSION['vap_cfg_msg_status'] ) {
<?php
if( !class_exists ( 'VAP_Settings' ) ) {
class VAP_Settings {
function __construct(){
add_action( "vap_save_settings", array( $this, "vap_save_settings_func" ), 10 , 1 );
add_action( 'wp_ajax_vap_setting_dellastsync', array( $this, 'vap_setting_dellastsync' ) );
<?php
/*
Plugin Name: VIN Articles Post
Plugin URI: https://www.vinpractice.com/
Description: Sync / import CDP articles from VIN Api
@wolfcoder
wolfcoder / vap_admin_js.js
Created June 8, 2022 05:39
VIN article js
var vapSyncCategories = [];
var vapAllSuccess = true;
var vapRunning = false;
function vapGetCategoryArticles(categoryIndex, pageIndex) {
var post_data = {
action: 'vap_sync_start',
on_sync: true,
category_id: vapSyncCategories[categoryIndex].id,
category_wpid: vapSyncCategories[categoryIndex].wpid,