Skip to content

Instantly share code, notes, and snippets.

@SitesByYogi
SitesByYogi / booking-cal.php
Created January 3, 2025 13:22
Booking Calendar Code
<?php
// Enqueue necessary scripts and styles for the booking calendar
function booking_calendar_assets() {
wp_enqueue_script('moment-js', 'https://cdn.jsdelivr.net/npm/[email protected]/moment.min.js', [], null, true);
wp_enqueue_script('fullcalendar-js', 'https://cdn.jsdelivr.net/npm/[email protected]/main.min.js', ['moment-js'], null, true);
wp_enqueue_style('fullcalendar-css', 'https://cdn.jsdelivr.net/npm/[email protected]/main.min.css', [], null);
wp_add_inline_script(
'fullcalendar-js',
@SitesByYogi
SitesByYogi / sprout-error.h
Created December 30, 2024 17:10
Sprout Error
[29-Dec-2024 03:31:22 UTC] PHP Warning: Undefined variable $offset in /home/billing3/public_html/wp-content/plugins/sprout-invoices-pro/bundles/sprout-invoices-addon-dynamic-text/inc/Dynamic_Text.php on line 81
[29-Dec-2024 03:31:22 UTC] PHP Warning: Undefined variable $offset in /home/billing3/public_html/wp-content/plugins/sprout-invoices-pro/bundles/sprout-invoices-addon-dynamic-text/inc/Dynamic_Text.php on line 81
[29-Dec-2024 04:23:38 UTC] PHP Warning: Undefined variable $option in /home/billing3/public_html/wp-content/plugins/sprout-invoices-addon-auto-billing/controllers/Sprout_Billings_Admin.php on line 322
[29-Dec-2024 04:23:38 UTC] PHP Fatal error: Uncaught Error: Call to undefined method SA_AuthorizeNet::create_transaction() in /home/billing3/public_html/wp-content/plugins/sprout-invoices-addon-auto-billing/payment-processors/authorize-net-cim/sprout-billings-authorizenet-cim.php:808
Stack trace:
#0 /home/billing3/public_html/wp-content/plugins/sprout-invoices-addon-auto-billing/payment-process
@SitesByYogi
SitesByYogi / list-product-urls.php
Created December 27, 2024 12:04
Creates a list of all published product URLs on your Website
<?php
function list_all_product_and_category_urls() {
// Get all products
$products = wc_get_products(array(
'limit' => -1, // Retrieve all products
'status' => 'publish' // Only published products
));
// Get all categories
<?php
// Add this code to your theme's functions.php file or use the Code Snippets plugin.
/**
* Recent Blog Posts Shortcode with Title
*/
function custom_recent_blog_posts_shortcode($atts) {
// Extract attributes
$atts = shortcode_atts(array(
@SitesByYogi
SitesByYogi / product-cats.php
Created December 27, 2024 11:59
Displays project categories in WordPress
<?php
// Add this code to your theme's functions.php file or use the Code Snippets plugin.
/**
* WooCommerce Product Categories Dropdown Shortcode with Title
*/
function custom_woocommerce_category_dropdown_shortcode($atts) {
// Ensure WooCommerce is active
if (!class_exists('WooCommerce')) {
@SitesByYogi
SitesByYogi / product-search.php
Created December 27, 2024 11:58
Display a product search bar on your WordPress
<?php
// Add this code to your theme's functions.php file or use the Code Snippets plugin.
/**
* WooCommerce Product Search Bar Shortcode
*/
function custom_woocommerce_product_search_shortcode($atts) {
// Ensure WooCommerce is active
if (!class_exists('WooCommerce')) {
@SitesByYogi
SitesByYogi / display-blog.php
Last active December 27, 2024 11:56
Shortcode to Display Full Blog Post by Post ID Without Featured Image or Title
<?php
// Shortcode to Display Full Blog Post by Post ID Without Featured Image or Title
function display_full_post_no_image($atts) {
// Shortcode Attributes
$atts = shortcode_atts(array(
'id' => '', // Default: no post ID
), $atts, 'full_post_no_image');
// Validate the Post ID
@SitesByYogi
SitesByYogi / shoppable.php
Last active December 27, 2024 11:54
Creates shoppable template cpt
<?php
// Register Custom Post Type: Shoppable Articles
function create_shoppable_articles_post_type() {
$labels = array(
'name' => _x('Shoppable Articles', 'Post Type General Name', 'your-text-domain'),
'singular_name' => _x('Shoppable Article', 'Post Type Singular Name', 'your-text-domain'),
'menu_name' => __('Shoppable Articles', 'your-text-domain'),
'name_admin_bar' => __('Shoppable Article', 'your-text-domain'),
'archives' => __('Shoppable Article Archives', 'your-text-domain'),
<table class="bg-table table hide-header table-borderless" style="table-layout: fixed; width: 100%; height: 736px;">
<thead>
<tr style="height: 0px;">
<th style="width: 45%;">Header 1</th>
<th style="width: 40%;">Header 2</th>
<th style="width: 15%;">Header 3</th>
</tr>
</thead>
<tbody>
<!-- Your table rows here -->
@SitesByYogi
SitesByYogi / audio-ext.php
Last active September 6, 2024 19:38
Adds new fields to audio player
<?php
// Hook into the attachment fields
add_filter('attachment_fields_to_edit', 'add_custom_audio_fields', 10, 2);
add_filter('attachment_fields_to_save', 'save_custom_audio_fields', 10, 2);
// Function to add custom fields
function add_custom_audio_fields($form_fields, $post) {
// Only show these fields for audio files
if ($post->post_mime_type == 'audio/mpeg' || $post->post_mime_type == 'audio/wav' || $post->post_mime_type == 'audio/ogg') {
// Record Label field