Skip to content

Instantly share code, notes, and snippets.

View gdarko's full-sized avatar
Crunching code, one line at a time.

Darko Gjorgjijoski gdarko

Crunching code, one line at a time.
  • Self-employed
  • The Internet
  • 04:27 (UTC +01:00)
View GitHub Profile
@gdarko
gdarko / dgv-loop-videos.php
Created February 19, 2024 17:28
Query uploaded videos
View dgv-loop-videos.php
<?php
// Loop videos
$database = new WP_DGV_Db_Helper();
$videos = $database->get_videos([
'author' => 'USER_ID_GOES_HERE',
'posts_per_page' => 5,
'paged' => 1,
]);
@gdarko
gdarko / functions.php
Created February 19, 2024 17:21
WPForms after upload hook.
View functions.php
<?php
/**
* Saves uploaded video through WPForms to current user meta.
*
* @param $hook_data
*
* What $hook_data contains:
*
* $hook_data = array(
View domjudge-install.sh
#!/usr/bin/env bash
#
# This is a script that can automatically
# setup DOMjudge server & judgehost, inside a same server.
#
# you can leave it by its default value
USERNAME=domjudge
USER_PASSWORD=domjudge
@gdarko
gdarko / dgv-create-post-type-entry.php
Last active September 18, 2023 00:15
Vimeify (Video Uploads for VImeo) - Creates post type entry on front-end upload
View dgv-create-post-type-entry.php
<?php
add_action('dgv_frontend_after_upload', function($data){
/**
* Example of the $data array:
* $data = array(
* 'vimeo_title' => $vimeo_title,
* 'vimeo_description' => $vimeo_description,
* 'vimeo_id' => $vimeo_id,
@gdarko
gdarko / motion_switch_light.yaml
Last active September 24, 2023 20:53 — forked from Ultra9k/motion_switch_light.yaml
This is a blueprint based on the original motion_light from Home Assistant. This one, however, allows you to control not only lights but also switches when motion is detected.
View motion_switch_light.yaml
blueprint:
name: Motion-activated Switch and/or Light
description: Turn on a switch and/or light when motion is detected.
domain: automation
source_url: https://darkog.com/blog/home-assistant-motion-lights-with-switches/
input:
motion_entity:
name: Motion Sensor
selector:
entity:
@gdarko
gdarko / dlm-restapi-disable-software.php
Created May 23, 2023 06:55
Simple plugin to disable the software parameter in the REST API activate endpoint when using Digital License Manager Pro
View dlm-restapi-disable-software.php
<?php
/**
* Plugin Name: DLM Disable Software from REST API
* Description: Sample plugin that disables software requirement for software parameter in activate endpoint in the rest api.
* Author: Darko Gjorgjijoski
* Version: 1.0.0
* License: GPLv2 or later
*/
@gdarko
gdarko / dlm-emails-move-licenses-ontop.php
Last active March 22, 2023 09:21
Move the licenses table above order details in the WooCommerce order email. Simply drop this in your plugins (or mu-plugins) directory or even add the snippet in your functions.php starting from line 13.
View dlm-emails-move-licenses-ontop.php
<?php
/**
* Plugin Name: DLM Emails Move Licenses On-Top
* Description: Move the licenses table above order details in the WooCommerce order email
* Author: Darko Gjorgjijoski
* Version: 1.0.0
* License: GPLv2 or later
*/
if ( ! defined( 'ABSPATH' ) ) {
@gdarko
gdarko / dlm-product-defaults.php
Created February 5, 2023 00:46
Simple plugin that sets Digital License Manager defaults when you publish a new products. To install this, drop it in mu-plugins or plugins dir.
View dlm-product-defaults.php
<?php
/**
* Plugin Name: DLM Product Defaults
* Description: Sample plugin that sets product defaults when you publish a product for a first time or create via Woo APIs.
* Author: Darko Gjorgjijoski
* Version: 1.0.0
* License: GPLv2 or later
*/
@gdarko
gdarko / wp-config.php
Created February 3, 2023 16:55
Enable debug log in WordPress
View wp-config.php
<?php
// Something else...
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_DISPLAY', false );
define( 'WP_DEBUG_LOG', true );
// something else...
@gdarko
gdarko / functions.php
Last active February 13, 2023 01:19
Add order id to the Vimeo title field on a GravityForms / WPForms based forms in the WooCommerce's order-received page
View functions.php
<?php
/**
* [WPForms]
* Prepopulate the order id in the WPForms on the order thank you page.
*
* @param $value
* @param $field
* @param $form
*