Skip to content

Instantly share code, notes, and snippets.

View UVLabs's full-sized avatar
🏠
Probably coding

Uriahs Victor UVLabs

🏠
Probably coding
View GitHub Profile
@UVLabs
UVLabs / wc-check-direct-download-login-status.php
Last active December 4, 2020 16:01
Prevent logged out users from downloading WooCommerce downloadable product files.
<?php
function prefix_check_direct_download_link(){
$request = $_SERVER['REQUEST_URI'];
$parts = explode('&', $request);
// $parts[0] would be ?download_file=<product_id>
// We are assuming here... because that's how WooCommerce currently has the URL structured.
// A more full-proof way would be to use regex
@UVLabs
UVLabs / dnsbl.php
Created October 9, 2020 17:22 — forked from tbreuss/dnsbl.php
IP Blacklist Check Script - This is a simple PHP script to lookup for blacklisted IP against multiple DNSBLs at once.
<?php // Simple PHP script to lookup for blacklisted IP against multiple DNSBLs at once. ?>
<html>
<head>
<title>DNSBL Lookup Tool - IP Blacklist Check Script</title>
</head>
<body>
<h2>IP Blacklist Check Script</h2>
<form action="" method="get">
<input type="text" value="" name="ip"/>
<input type="submit" value="LOOKUP"/>
@UVLabs
UVLabs / prepare.sh
Created September 28, 2020 01:59
Bash script to copy files into a folder and then zip up that folder automatically.
#!/bin/bash
# This is a simple script that copies files and directories to a folder, and then zips up that folder.
# You can think of it as sort of a low level deployment script, at least thats what I use it for;
# To quickly create a zip using only the files needed for the production version of a WordPress plugin which I then upload to CodeCanyon.
# Feel free to extend and modify for your particular use-case.
# Instructions:
# From your command line, navigate to location of script and then execute it using command:
# sh prepare.sh
@UVLabs
UVLabs / ninja_forms_filter_redirect_url.php
Created July 24, 2020 14:21
Change/filter the Ninja Forms redirect hook
<?php
function nf_filter_redirect_url( $action_settings, $form_id, $action_id, $form_settings ) {
if( $form_id !== <id> ){
return $action_settings;
}
// more conditions can be added as needed
// doc: https://developer.ninjaforms.com/codex/submission-processing-hooks/
<?php
// Outputs an easy to read call trace
// Credit: https://www.php.net/manual/en/function.debug-backtrace.php#112238
function generateCallTrace()
{
$e = new Exception();
$trace = explode("\n", $e->getTraceAsString());
// reverse array to make steps line up chronologically
@UVLabs
UVLabs / Contract Killer 3.md
Created June 21, 2020 23:57 — forked from malarkey/Contract Killer 3.md
The latest version of my ‘killer contract’ for web designers and developers [original UK version 2016]

Contract Killer

The popular open-source contract for web professionals by Stuff & Nonsense

  • Originally published: 23rd December 2008
  • Revised date: March 15th 2016
  • Original post

@UVLabs
UVLabs / Contract Killer 3.md
Last active June 21, 2020 23:56 — forked from tony-caffe/Contract Killer 3.md
The latest version of Bytes Unlimited ‘Contract Killer’ for web professionals [US Version 2020]

Contract Killer

The popular open-source contract for web professionals by Stuff & Nonsense

  • Originally published: 23rd December 2008
  • Revised date: March 15th 2016
  • Revised by Bytes Unlimited : Feb 3rd 2020

@UVLabs
UVLabs / import_users_from_csv.php
Created May 23, 2020 23:59
WordPress - Import Users From CSV and Send Email
<?php
/*
Plugin Name: Import Users From CSV
Description: Imports users from a CSV file
Version: 1.0.0
Author: Uriahs Victor
Author URI: https://uriahsvictor.com
License: GPL v2
*/
@UVLabs
UVLabs / make-pot.sh
Last active March 6, 2024 09:40
Using WordPress makepot.php to generate pot file used for the internationalization of your plugin or theme.
#!/bin/bash
php path/to/makepot.php wp-plugin /path/to/your/plugin pluginname.pot
#php path/to/makepot.php wp-theme /path/to/your/theme themename.pot
@UVLabs
UVLabs / wp-check-cron-event-firing.php
Last active September 28, 2020 02:09
Check if a WordPress cron event is firing and show a notice if not
<?php
/*
Usecase:
You might have an important task within your plugin/theme that requires WP CRON working flawlessly. If a user website has little traffic, WP CRON is turned off via wp_config.php, or there is an issue with WP CRON; your scheduled task will not fire.
The code below allows you to set a value in minutes after which a notice(or whatever else you might want to happen) would appear in the user admin dashboard.
Users can permanently dismiss the notice.