Skip to content

Instantly share code, notes, and snippets.

@dtbaker
dtbaker / custom_invoice_number.php
Created December 29, 2015 21:15
Format the invoice number in UCM
<?php
// this changes the invoice number format to a 7 digit string padded with 0's at the start
// example: instead of "Invoice #1" it will be "Invoice #0000007"
// upload this file to a new folder called 'includes/plugin_custom_invoice_number/custom_invoice_number.php'
if(!function_exists('custom_invoice_number')) {
function custom_invoice_number( $customer_id ) {
@dtbaker
dtbaker / functions.php
Created January 18, 2016 23:29
Beautiful Watercolor wordpress theme child functions
<?php
function beautiful_blog_links() {
if ( 'post' == get_post_type() ) : ?>
<div class="blog_links">
<?php
$blog_links = array();
$blog_links ['date'] = beautiful_posted_on( true );
if ( comments_open() ) {
@dtbaker
dtbaker / data_link.php
Last active September 20, 2016 03:30
Create a link to a custom data entry in UCM. Upload this file to includes/plugin_data_link/data_link.php - change the 'data_type_id' value to the ID of your customer data in your UCM system.
@dtbaker
dtbaker / help.cpp
Created April 16, 2016 13:06
C++ help? Using
###### ImAcq.cpp:
ImAcq *imAcqAlloc()
{
ImAcq *imAcq = (ImAcq *)malloc(sizeof(ImAcq));
imAcq->method = IMACQ_PI;
imAcq->RaspiCam_Cv_Camera = ???? // dave added this
imAcq->currentFrame = 1;
@dtbaker
dtbaker / run_bot.php
Created May 28, 2016 12:29
Run this PHP script and it will start a "bot" user on Slack that does Google Searches for you
<?php
require 'vendor/autoload.php';
use PhpSlackBot\Bot;
// Custom command
class MyCommand extends \PhpSlackBot\Command\BaseCommand {
protected function configure() {
$this->setName('bot');
@dtbaker
dtbaker / db.php
Created July 19, 2016 02:43
Upgrade from mysql_connect() to mysqli_connect() - handle port number and socket.
// These are examples of MySQL host names that will work fine in mysql_connect() but fail in mysqli_connect()
// If you are upgrading an old script to mysqli the client may have configured these as values for their database server.
// The below script parses out port number or socket and translates that into a correct mysqli_connect() call.
define('_DB_SERVER', '1.2.3.4:3306');
define('_DB_SERVER', '1.2.3.4:/tmp/socket4');
if(function_exists('mysqli_connect')){
$server = _DB_SERVER;
$port_number = null;
$socket = null;
@dtbaker
dtbaker / code.php
Last active May 21, 2022 10:48
Add a custom control to an existing Elementor widget
// This example will add a custom "select" drop down to the "Image Box"
// This will change the class="" on the rendered image box so we can style the Image Box differently
// based on the selected option from the editor.
// The class will be "my-image-box-style-blue" or "my-image-box-style-green" based on the selected option.
add_action('elementor/element/before_section_end', function( $section, $section_id, $args ) {
if( $section->get_name() == 'image-box' && $section_id == 'section_image' ){
// we are at the end of the "section_image" area of the "image-box"
$section->add_control(
@dtbaker
dtbaker / create-quote.php
Last active June 2, 2018 20:23
Create a quote in UCM from a remote url
<?php
chdir('/path/to/ucm/folder/on/webhost/');
include('init.php'); // the UCM init code.
// login as admin
module_security::user_id_temp_set(1);
$customer_data = array(
'customer_name' => 'Name Here',
@dtbaker
dtbaker / foo.php
Created February 26, 2017 03:03
Hacky way to import pictures after a WordPress site migration that didn't go well.
// This will search through all blog content and find/replace <a href> and <img src> links
// It will find images on the old multi-site host, e.g. http://dtbaker.net/wp-content/uploads/sites/* and import those images into the new blog, then update the links/src in the post content.
add_action('init', function(){
if(isset($_REQUEST['do_import'])){
ini_set('display_errors',true);
ini_set('error_reporting',E_ALL);
require_once ('wp-admin/includes/admin.php');

Keybase proof

I hereby claim:

  • I am dtbaker on github.
  • I am dtbaker (https://keybase.io/dtbaker) on keybase.
  • I have a public key ASC97lhPufWpAR3JpYNuOXAUFR0ETsK3xbBuJtdxUsbiIAo

To claim this, I am signing this object: