Skip to content

Instantly share code, notes, and snippets.

My notes for upgrading laragon to work with latest apache and php8.1
Update to laragon 5:
- Stop all running services in laragon
- Make sure laragon itself is properly closed
- Download the latest laragon.exe and overwrite your original laragon.exe
https://github.com/leokhoa/laragon/releases/download/5.0.0/laragon.exe
Update to latest apache
- Download the latest apache 2.4 VS16 for windows (Apache 2.4.x OpenSSL 1.1.1 VS16):
@acrosman
acrosman / FA_Signing.php
Last active April 3, 2023 06:27
A PHP function to sign dynamic parameters for FormAssembly
<?php
function prepareFormAssemblyQueryString(array $parameters, $salt, $expire_timeout) {
$parts = [];
$signString = '';
foreach($parameters as $key => $value) {
$signString .= $key . $value;
$parts[] = rawurlencode($key) . '=' . rawurlencode($value);
}
$expireTime = time() + $expire_timeout;
$signString .= 'expire' . (string)$expireTime;
@RadGH
RadGH / rs_upload_from_url.php
Last active October 1, 2024 08:07
Upload a file from a URL to the WordPress media gallery. Supports images, PDFs, and other file types.
<?php
/**
* This function uploads a file from a URL to the media library, designed to be placed in your own theme or plugin.
* Metadata will be generated and images will generate thumbnails automatically.
*
* HOW TO USE:
* 1. Add the function below to your theme or plugin
* 2. Call the function and provide the URL to an image or other file.
* 3. If successful, the attachment ID will be returned.
@squarestar
squarestar / install-wp-plugins.php
Last active November 16, 2024 19:57
Programmatically install and activate wordpress plugins
<?php
/**
* Programmatically install and activate wordpress plugins
*
* Usage:
* 1. Edit the $pluginSlugs array at the beginning of this file to include the slugs of all the
* plugins you want to install and activate
* 2. Upload this file to the wordpress root directory (the same directory that contains the
* 'wp-admin' directory).
* 3. Navigate to <your-domain-wordpress-root>/install-wp-plugins.php (If wordpress is installed
@maxkostinevich
maxkostinevich / php-fpm-restart.sh
Last active November 16, 2024 20:53
Cloudways PHP-FPM restart via API
# Restart PHP-FPM on CloudWays via API
# Replace YOUR_NAME%40DOMAIN.COM with your email (URL-encoded), YOUR_API_KEY with your Cloudways API key and SERVER_ID with id of your server
# If you want to use it with DeployBot just add the following commands to the "Run commands after new version becomes active" section.
# Do auth and receive access_token
cloudways_token=$(curl -X POST --header 'Content-Type: application/x-www-form-urlencoded' --header 'Accept: application/json' -d 'email=YOUR_NAME%40DOMAIN.COM&api_key=YOUR_API_KEY' 'https://api.cloudways.com/api/v1/oauth/access_token' | python3 -c "import sys, json; print(json.load(sys.stdin)['access_token'])")
# Restart PHP-FPM
curl -X POST --header 'Content-Type: application/x-www-form-urlencoded' --header 'Accept: application/json' --header "Authorization: Bearer ${cloudways_token}" -d 'server_id=SERVER_ID&service=php7.0-fpm&state=restart' 'https://api.cloudways.com/api/v1/service/state'
@lukaszfiszer
lukaszfiszer / ISO_3166-1_countries_pl.js
Last active May 21, 2024 17:31
List of all countries with their ISO 3166-1 codes, polish and english names, in javascript and json. Sorted by polish name. Source: http://pl.wikipedia.org/wiki/ISO_3166-1 Lista wszystkich państw świata wraz z ich polską i angielską nazwą oraz kodem wg. ISO 3166-1, w formatach javascript i JSON. Posortowana wg. polskiej nazwy: Zródło: http://pl.…
[
{ name_pl: "Afganistan", name_en: "Afghanistan", code: "AF" },
{ name_pl: "Albania", name_en: "Albania", code: "AL" },
{ name_pl: "Algieria", name_en: "Algeria", code: "DZ" },
{ name_pl: "Andora", name_en: "Andorra", code: "AD" },
{ name_pl: "Angola", name_en: "Angola", code: "AO" },
{ name_pl: "Anguilla", name_en: "Anguilla", code: "AI" },
{ name_pl: "Antarktyka", name_en: "Antarctica", code: "AQ" },
{ name_pl: "Antigua i Barbuda", name_en: "Antigua and Barbuda", code: "AG" },
{ name_pl: "Arabia Saudyjska", name_en: "Saudi Arabia", code: "SA" },
@westonruter
westonruter / filter-post-thumbnail-id.php
Last active January 5, 2023 06:42
How to filter the response for get_post_thumbnail_id()
<?php
/**
* How to filter the value that would be returned by get_post_thumbnail_id()
*/
add_filter( 'get_post_metadata', function ( $value, $post_id, $meta_key, $single ) {
// We want to pass the actual _thumbnail_id into the filter, so requires recursion
static $is_recursing = false;
// Only filter if we're not recursing and if it is a post thumbnail ID