Skip to content

Instantly share code, notes, and snippets.

Avatar

Olaf Lederer finalwebsites

View GitHub Profile
@finalwebsites
finalwebsites / getinvoicelist.php
Created December 30, 2022 09:15
EFD getinvoicelist
View getinvoicelist.php
<?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
View Bestaande_klanten.php
<?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
View functions.php
<?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
View .htaccess
# 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)
View mysql_db_backup.sh
#!/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.
View redirect_user_add.php
<?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']) );
@finalwebsites
finalwebsites / uitverkocht-uitschakelen.php
Created February 20, 2022 16:04
WooCommerce product variaties uitschakelen wanneer deze zijn uitverkocht
View uitverkocht-uitschakelen.php
<?php
// plaats deze code in het functions.php bestand van je child thema
add_filter( 'woocommerce_variation_is_active', 'fws_disable_variations_out_of_stock', 10, 2 );
function fws_disable_variations_out_of_stock( $is_active, $variation ) {
if ( ! $variation->is_in_stock() ) return false;
return $is_active;
}
@finalwebsites
finalwebsites / Admin_columns_variation_name.php
Created January 31, 2022 11:14
Admin Columns: Add variation name to column
View Admin_columns_variation_name.php
<?php
function ac_column_value_usage( $col_value, $id, AC\Column $column ) {
if ('column-wc-product_details' == $column->get_type()) {
$order = wc_get_order( $id );
foreach ( $order->get_items() as $item_id => $item ) {
if ( $item->get_variation_id() ) {
$product = $item->get_product();
foreach ( $product->get_attributes() as $attribute => $value ) {
$name = term_exists( $value, $attribute ) ? get_term_by( 'slug', $value, $attribute )->name : $value;
$col_value = $col_value .'<br>' . $name;
@finalwebsites
finalwebsites / functions.php
Created July 12, 2021 06:21
reCaptacha for HTML Forms
View functions.php
<?php
function fws_enqueue_recaptcha() {
$sitekey = mysitekey';
wp_enqueue_script( 'fws-recaptcha', '//www.google.com/recaptcha/api.js?render=' . $sitekey, null, null, true );
}
add_action( 'wp_enqueue_scripts', 'oceanwp_child_enqueue_parent_style' );
@finalwebsites
finalwebsites / check-email-list.php
Created July 6, 2021 06:58
Check your email list with the email validation service from mailboxlayer
View check-email-list.php
<?php
set_time_limit(0);
ini_set('memory_limit', '2048M'); // if your list is very long
$api_key = 'PLACE HERE YOUR API';
$fp = fopen('emailchecked.csv', 'w');
fputcsv($fp, array('Email address', 'Valid MX', 'Valid SMTP', 'Score'));
$count = 0;