Skip to content

Instantly share code, notes, and snippets.

View finalwebsites's full-sized avatar

Olaf Lederer finalwebsites

View GitHub Profile
@finalwebsites
finalwebsites / wp-install.sh
Created December 1, 2025 09:46
Cleavr Quick Script - Configure WordPress after site installation
user={{ serverUser }}
site={{ siteName }}
cd /home/$user/$site/current/
wp language core install nl_NL
wp site switch-language nl_NL
wp theme install hello-elementor
wp theme install https://github.com/finalwebsites/hello-elementor-child/archive/refs/heads/master.zip
wp theme activate hello-elementor-child
@finalwebsites
finalwebsites / shortcode_image_tag.php
Last active July 25, 2025 10:11
Add the shortcode option to dynamic tags for background images in Elementor
<?php
// place the snippet inside the functions.php file from your WordPress child theme
use Elementor\Controls_Manager;
add_action( 'elementor/dynamic_tags/register_tags', function( $dynamic_tags ) {
class Custom_Image_Tag extends Elementor\Core\DynamicTags\Data_Tag {
public function get_name() {
return 'shortcode-image';
}
@finalwebsites
finalwebsites / download-example.php
Last active July 17, 2025 07:33
PHP download file script code example
<?php
echo '
<a href="http://mydomain.com/download.php?download_file=some_file.pdf">PHP download file</a>';
@finalwebsites
finalwebsites / functions.php
Created July 15, 2025 18:37
Add subscribers to EmailOctopus via your WordPress Contact Form
<?php
// add this code to your child theme
add_action('fwsacf_after_success_form', 'fw_add_newsletter_contact_form');
function fw_add_newsletter_contact_form($form_obj) {
if (!class_exists('FWEO_EmailOctopus_integration')) return;
$data = array('FirstName' => $form_obj['name']);
if (!empty($form_obj['accept_terms'])) {
$data['tags'] = 'newsletter';
}
$list = get_option('fweo_emailoctopus_list_id');
@finalwebsites
finalwebsites / functions.php
Created July 10, 2025 08:10
Add a minimum order message to the cart page in WooCommerce
<?php
// add this code to the functions.php file from your child theme
add_action( 'woocommerce_before_cart' , 'wc_minimum_order_amount' );
function wc_minimum_order_amount() {
// Set this variable to specify a minimum order value
$minimum = 250;
$min_passed = true;
$subtotal = WC()->cart->get_subtotal();
if ( $subtotal < $minimum ) {
@finalwebsites
finalwebsites / class-wcapf-pro-form.php
Created June 19, 2025 07:35
Use two WCAPF forms based on the chosen language
<?php
protected function retrieve_form() {
global $wcapf_form;
if ( ! $wcapf_form ) {
return array();
}
$desired_form = array();
@finalwebsites
finalwebsites / hostname.conf
Last active March 30, 2025 11:57
NGINX server configuration for the UrBackup web interface
# Redirect all http traffic to https
server {
listen 80;
listen [::]:80;
#Replace with your host or domain name
server_name YOURHOSTNAME;
return 301 https://$host$request_uri;
}
server {
@finalwebsites
finalwebsites / 404.php
Created March 2, 2025 15:13
Static 404 page template for WordPress
<!doctype html>
<html lang="nl">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>404 - page not found</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css" integrity="sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l" crossorigin="anonymous">
<style>
body { background: #dedede; }
.page-wrap { min-height: 100vh; }
@finalwebsites
finalwebsites / .htaccess
Created September 3, 2022 06:52
Ignore missing files and report a 404 status
# add this code to your .htaccess file (Apache based servers only)
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} \.(jpg|jpeg|png|gif|bmp|ico|css|js|swf|htm|html|txt|php|asp|aspx)$ [NC]
RewriteRule .* - [L,R=404]
</IfModule>
@finalwebsites
finalwebsites / functions.php
Created December 31, 2024 15:17
Send WordPress emails with a template created in Maileroo
<?php
// replace the template ID 123 with your own
add_filter('ssbm_add_template_data', function($payload, $atts) {
if ($atts['message'] == strip_tags($payload['html'])) {
$message = nl2br($atts['message']);
unset($payload['html']);
$payload['template_id'] = 123;
$payload['template_data'] = json_encode(
array('content' => $message)