Skip to content

Instantly share code, notes, and snippets.

@danmaby
danmaby / functions.php
Created September 28, 2023 10:38
Simple log in / log out shortcode for WordPress. Conditionally display a login or logout text link based on users logged in status.
<?php
/**
* Shortcode to display "Log in" or "Log out" link.
*
* @return string HTML string for the login/logout link.
*/
function dm_login_logout_shortcode() {
// Initialize an empty string to hold the output HTML.
$output = '';
@danmaby
danmaby / export_woo_subscriptions_to_csv.php
Last active September 13, 2023 09:37
Export WooCommerce Subscriptions to CSV. Provides a `Export Subscriptions` button in Woo admin menu
<?php
/**
* Plugin Name: Export WooCommerce subscriptions
* Plugin URI: https://www.blue37.com/
* Description: Export WooCommerce subscriptions to a CSV file.
* Version: 0.0.1
* Requires at least: 6.0
* Requires PHP: 8.0
* Author: Blue 37
@danmaby
danmaby / functions.php
Created July 24, 2023 08:52
A shortcode that displays the SEO description generated by the Filter Everything Pro plugin
/**
* Adds a shortcode that displays the SEO description generated by the Filter Everything Pro
* plugin. If no description is available, the shortcode will display the default content. An
* an optional 'default' attribute can be used to specify the default content.
*
* @param array $atts An array of shortcode attributes.
* @return string The shortcode output.
*/
function ps_add_filters_seo_description_shortcode($atts)
{
@danmaby
danmaby / functions.php
Created November 7, 2022 08:10
Set default button styles for GenerateBlocks
<?php
/*
* set GenerateBlocks button defaults
*
* @url https://github.com/tomusborne/generateblocks/blob/c2aad72f6868001c6f7fa9b606cafef511eebd1b/includes/defaults.php#L231-L243
*/
add_filter("generateblocks_defaults", function ($defaults) {
$color_settings = wp_parse_args(
get_option("generate_settings", []),
generate_get_color_defaults()
@danmaby
danmaby / readme.md
Created April 1, 2022 12:02
Install SSL with Node.js, Express and Socket.io

Getting started

A basic installation of Node.js, Express, and Socket.io served over https:// using a Letsencrypt SSL certificate.

Step 1 - Build DO Droplet (or server of your choice)

  • Spin up DO droplet
  • Set up DNS
  • Access the server via SSH
@danmaby
danmaby / attendee-login-open.php
Last active March 23, 2022 09:39
Apply Conditional Blocks PHP Logic using WordPress Pods custom settings options
<?php
/**
* Function to determine if login blocks should show.
*
* @return boolean true/false to show the block or not.
*/
function dv_atttendee_login_open( $option_name, $defaults = array() ) {
$options = get_option('dv_event_settings_dv_settings_allow_attendee_login');
//checking if setting is empty
@danmaby
danmaby / jitsi-meet-multi-server.md
Last active April 3, 2022 16:50
This tutorial is for jitsi-meet installation using 2 server or more. The main server will contain jitsi-meet react source code, prosody, nginx, and jicofo. The videobridge will be installed seperatelly on the second server and so on.

How to Install Jitsi Meet with Multi Server Configuration

This tutorial is for jitsi-meet installation using 2 server or more. The main server will contain jitsi-meet react source code, prosody, nginx, and jicofo. The videobridge will be installed seperatelly on the second server and so on.

Prerequisite

  1. Minimum 2 servers with 1 IP Public each
  2. Ubuntu 18.04

Sudo Privileges

Before starting make sure there are no permission issues on the installation.

@danmaby
danmaby / restart-jitsi.bash
Created June 19, 2020 08:54
Restart Jitsi Meet
sudo systemctl restart prosody
sudo systemctl restart jicofo
sudo systemctl restart jitsi-videobridge2
sudo systemctl restart nginx
@danmaby
danmaby / functions.php
Created October 5, 2019 17:22
Populate GiveWP fields via query string
// Hooking into the single form view.
add_action( 'give_post_form_output', 'give_populate_amount_name_email' );
function give_populate_amount_name_email() {
?>
<script>
// use an enclosure so we don't pollute the global space
(function(window, document, $, undefined){
@danmaby
danmaby / functions.php
Last active October 10, 2018 19:10
Exclude products from a particular category on the shop page (WooCommerce)
<?php
/**
* Exclude products from a particular category on the shop page
*/
function custom_pre_get_posts_query( $q ) {
$tax_query = (array) $q->get( 'tax_query' );
$tax_query[] = array(