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
  • 22:19 (UTC +02:00)
View GitHub Profile
@gdarko
gdarko / dgv-loop-videos.php
Created February 19, 2024 17:28
Query uploaded videos
<?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.
<?php
/**
* Saves uploaded video through WPForms to current user meta.
*
* @param $hook_data
*
* What $hook_data contains:
*
* $hook_data = array(
#!/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 / str_contains.php
Last active October 16, 2023 14:03
str_contains() was introduced in PHP8. This is a polyfill for PHP7 or lower.
<?php
if (!function_exists('str_contains')) {
/**
* Check if substring is contained in string
*
* @param $haystack
* @param $needle
*
* @return bool
*/
@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.
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 / 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
<?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 / 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
<?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.
<?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 / file-upload.css
Last active March 11, 2023 21:11
WordPress Custom Profile Image Ajax Upload
.upload-thumb {
display: inline-block;
width: 120px;
height: 120px;
overflow: hidden;
background: #e2e2e2;
border: 1px solid #cdcdcd;
line-height: 120px;
margin-bottom: 10px;
}
@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
<?php
/**
* [WPForms]
* Prepopulate the order id in the WPForms on the order thank you page.
*
* @param $value
* @param $field
* @param $form
*