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 / 01_github-action-create-release-on-merge.md
Last active March 30, 2024 14:48
Github Action: Create Tag and Release when a pull request is merged into master/main branch with release notes parsed from merge comment

This Github Action workflow along with the rest of these files/scripts will allow you to create a Tag as well as a Release with the release notes set to the text added in the body of the merge comment when a pull request is merged.

Create release on merge github action

Note:

Merge comment title needs to contain the text "release" or else the workflow will not run (see line 11 of create-release.yml).

@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 / Fonts
Last active February 27, 2024 02:59
A list of noteworthy fonts
Professional - Corperate
https://fonts.google.com/specimen/Inter
https://www.dafontfree.io/gilroy-font-family
https://fonts.google.com/specimen/Signika
https://fonts.google.com/specimen/DM+Sans
https://github.com/github/mona-sans
https://fonts.google.com/specimen/Albert+Sans
hhttps://fonts.google.com/specimen/Rubik?query=rubik
https://github.com/stijndevries/Eudoxus-Sans
@UVLabs
UVLabs / detect-highlighted-text.html
Last active February 11, 2024 04:28
Detect highlighted text using JavaScript
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Selected Text Example</title>
<script>
// Adapted from: https://jsfiddle.net/timdown/SW54T/
// Fixed bug where alert would show twice: once when text is selected and again after page is cicked when exiting alert.
function getSelectedText() {
@UVLabs
UVLabs / add_xcd_equivalent.php
Created September 19, 2023 18:55
Adds the XCD equivalent of a product's price next to the USD amount. The example is for XCD but can be used for any currency by just changing the conversion rate.
function sl_add_price_suffix( $html, $product, $price, $qty ){
if(empty($product) && !is_object($product)){
return;
}
$is_variable = $product->is_type('variable');
$min_price = '';
$max_price = '';
@UVLabs
UVLabs / zoho_apis_access_token.php
Created August 31, 2023 17:41
Example PHP script for generating access token and refresh token for Zoho APIs.
<?php
$api_url = "https://accounts.zoho.com/oauth/v2/token";
$content_type = "application/x-www-form-urlencoded";
$code = "1000.7c7b9fa2259fac74331e0045d4bf24b2.7de27ed34xxxxxxxxxxxx"; //Generated with a max of 10 min life from https://api-console.zoho.com for example scope: ZohoCRM.modules.ALL
$redirect_uri = "https://example.com/zoho.php"; // When testing on Localhost with PHP local server like: php -S localhost:8080 you can set the redirect URL as the same localhost root url example: http://localhost:8080/
// Live client
// $client_id = "1000.xxx..."; //Static Client ID from https://api-console.zoho.com
@UVLabs
UVLabs / php-blacklist-checker
Created March 30, 2023 03:17
Blacklist checker script
<?php
// Simple PHP script to lookup for blacklisted IP against multiple DNSBLs at once.
// Note from Uriahs - I Didn't write any of this...I think...I'm pretty sure I just found the code somewhere online, but I can't remember..Saving as a gist for future reference.
?>
<html>
<head>
<title>DNSBL Lookup Tool - IP Blacklist Check Script</title>
</head>
<body>
@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 / make-script-module.php
Last active January 23, 2023 13:40
Turns a WordPress JavaScript file into a module while still supporting wp_add_inline_script()
<?php
// Below function will ensure that any scripts added using wp_add_inline_script() are not touched during the filtering process.
// We need to do this because the filte runs after the inline scripts have been concatenated: https://github.com/WordPress/WordPress/blob/6.1.1/wp-includes/class-wp-scripts.php#L406
function make_scripts_modules( $tag, $handle, $src ) {
if ( 'your-script-handle' !== $handle ) {
return $tag;
}
@UVLabs
UVLabs / php_media_queries.php
Last active December 15, 2022 20:24
Media Queries in PHP
<?php
if (isset($_GET['width'])) {
$width = $_GET['width'];
if ($width <= 480) {include ('mobile_file.php');} //mobile devices
} else {
echo "<script language='javascript'>\n";
echo " location.href=\"${_SERVER['SCRIPT_NAME']}?${_SERVER['QUERY_STRING']}" . "&width=\" + screen.width; \n";
echo "</script>\n";