This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ 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" }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |