Skip to content

Instantly share code, notes, and snippets.

View finalwebsites's full-sized avatar

Olaf Lederer finalwebsites

View GitHub Profile
@finalwebsites
finalwebsites / functions.php
Last active January 12, 2024 08:59
Child theme for WordPress and OceanWP
<?php
add_action( 'wp_enqueue_scripts', 'fw_theme_enqueue_styles', 100 );
function fw_theme_enqueue_styles() {
$dependencies = array(); // add here other theme handles, for example from the parent theme or WooCommerce
wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', $dependencies, '1.0.0' );
}
@finalwebsites
finalwebsites / woocommerce_archive_description.php
Last active April 15, 2023 14:25
WooCommerce hooks example codes
<?php
// remove the category description above the product list
remove_action( 'woocommerce_archive_description', 'woocommerce_taxonomy_archive_description', 10 );
// add the category description below the product list
add_action( 'woocommerce_after_shop_loop', 'woocommerce_taxonomy_archive_description', 100 );
@finalwebsites
finalwebsites / functions.php
Last active October 20, 2023 18:20
Add aan extra description to your WooCommerce product archive with ACF
<?php
/*
Place this code in your functions.php file to show a short description before the grid on product categorie archive pages.
Disclaimer: Use this code snippet with extreme care and at your own risk.
*/
add_action('woocommerce_archive_description', function() {
if (!is_paged() && is_product_category()) {
if (function_exists('get_field')) {
$term_id = get_queried_object()->term_id;
echo '
@finalwebsites
finalwebsites / woocommerce_merken.php
Last active April 8, 2023 10:09
Merken functionaliteit voor WooCommerce, met en zonder Elementor
<?php
/*
Copy/paste deze code in het functions.php bestand van je child theme.
Disclaimer:
Afhankelijk van je website instellingen is het mogelijk
dat deze code niet werkt of zelfs een storing in je website oproept.
Het gebruik van deze code gebeurd op eigen risico!
*/
@finalwebsites
finalwebsites / getinvoicelist.php
Created December 30, 2022 09:15
EFD getinvoicelist
<?php
function getInvoices($contact, $page = 0) {
global $link, $api, $today, $year_ago;
$filters = array(
'contact_id' => $contact,
'is_sent' => 1,
'invoice_date' => array($year_ago, $today)
);
//print_r($filters);
@finalwebsites
finalwebsites / Bestaande_klanten.php
Last active December 18, 2022 11:28
WooCommerce code voorbeelden voor de integratie met Clicky Analytics
<?php
add_action('wp_footer', 'fw_get_user_for_clicky');
function fw_get_user_for_clicky() {
$current_user = wp_get_current_user();
if ( $current_user->exists() ) {
// Vraag je klant/gebruiker eerst om toestemming voordat je deze code toont
echo '
<script type="text/javascript">
var clicky_custom = clicky_custom || {};
clicky_custom.visitor = {
@finalwebsites
finalwebsites / functions.php
Last active October 5, 2022 07:06
WordPress - remove the comment author URL field
<?php
// add this code snippet to your child theme's functions.php file
add_filter('comment_form_default_fields', 'fw_remove_comment_author_url');
function fw_remove_comment_author_url($fields) {
if (isset($fields['url'])) {
unset($fields['url']);
}
return $fields;
}
@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 / mysql_db_backup.sh
Last active August 28, 2022 10:04
Create daily backups from your MySQL databases (simple script)
#!/bin/sh
# Find out what databases are in mysql and back them up
# Delete old backups
STARTTIME=` date +%Y%m%d-%H%M `
BACKUP_DIR="/srv/users/serverpilot/apps/backups"
LOGFILE="/srv/users/serverpilot/apps/backups/db_backup.log"
USER="root"
PASSWD="ENTER_ROOT_PASSWORD"
KEEP="20"
@finalwebsites
finalwebsites / redirect_user_add.php
Last active May 6, 2022 08:39
This snippet will redirect the WordPress admin to the user profile page after a new user was added.
<?php
// place this code snippet to the functions.php file from your WordPress child theme
add_action("current_screen", "redirect_user_add");
function redirect_user_add() {
if (!empty($_GET['id'])) {
$currentScreen = get_current_screen();
if ($currentScreen->id == "users") {
wp_redirect( admin_url("/user-edit.php?user_id=".(int)$_GET['id']) );