Skip to content

Instantly share code, notes, and snippets.

@beflash
beflash / validate-vat.php
Last active January 27, 2025 01:19
validate UST-id/VAT
<?php
function validateVAT($vatNumber) {
$url = "https://ec.europa.eu/taxation_customs/vies/vatResponse.html";
$response = file_get_contents("$url?memberStateCode=" . substr($vatNumber, 0, 2) . "&number=" . substr($vatNumber, 2));
if (strpos($response, 'valid="true"') !== false) {
return true; // VAT-ID ist gültig
}
return false; // VAT-ID ist ungültig
@beflash
beflash / related_post.php
Last active December 25, 2024 04:45
related_post.php
<?php
$related_posts = ci_get_related_posts( get_the_ID(), 3 );
if ( $related_posts->have_posts() ) {
echo '<ul>';
while ( $related_posts->have_posts() ) {
$related_posts->the_post();
echo '<li><a href="' . get_permalink() . '">' . get_the_title() . '</a></li>';
}
echo '</ul>';
@beflash
beflash / preloader.php
Created December 12, 2024 14:29
preloader.php (functions/preloader.php)
<?php
add_action( 'init', 'Redpishi_Preloader' );
function Redpishi_Preloader() { if(!is_admin() && $GLOBALS["pagenow"] !== "wp-login.php" ) {
$delay = 1; //seconds
$loader = 'https://redpishi.com/wp-content/uploads/2022/06/preloader3.svg';
$overlayColor = '#ffffff';
echo '<div class="Preloader"><img src="'.$loader.'" alt="" style="height: 150px;"></div>
@beflash
beflash / function.php
Created December 12, 2024 14:11
functions import files
<?php
/*IMPORT Plugins */
$roots_includes = array(
'/functions/_snippets.php',
'/functions/back-to-top.php',
'/functions/darkmode-backend.php',
'/functions/duplicate.php',
'/functions/login.php',
'/functions/rss-feed.php',
@beflash
beflash / darkmode-backend.php
Created December 12, 2024 14:03
darkmode-backend.php (functions/darkmode-backend.php)
<?php
function applyCustomStyles() {
echo '
<style>
/* Change link colour to white */
#wpbody-content a {
color: #0026FC !important;
}
@beflash
beflash / duplicate.php
Last active December 12, 2024 13:58
duplicate.php (functions/duplicate.php)
<?php
add_filter( 'post_row_actions', 'rd_duplicate_post_link', 10, 2 );
add_filter( 'page_row_actions', 'rd_duplicate_post_link', 10, 2 );
function rd_duplicate_post_link( $actions, $post ) {
if( ! current_user_can( 'edit_posts' ) ) {
return $actions;
}
$url = wp_nonce_url(
@beflash
beflash / rss-feed.php
Last active December 12, 2024 13:58
back-to-top.php (functions/rss-feed.php)
<?php
add_action( 'wp_footer', function () { if ( !is_admin() ) {
$location = 'right'; // left or right
$scale = '1';
$icon = '
<svg width="100%" height="100%" viewBox="0 0 1067 1067" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:1.5;"><circle cx="533.333" cy="533.333" r="504.399" style="fill:#fff;stroke:#0026fc;stroke-width:38.74px;"/><circle cx="602.196" cy="738.431" r="12.648" style="fill:#ebebeb;"/><path d="M741.794,583.333l-208.252,-163.44l-208.67,160.276" style="fill:none;stroke:#0026fc;stroke-width:38.74px;"/></svg>
';
@beflash
beflash / svg-to-allowed.php
Last active December 12, 2024 13:51
SVG to allowed file uploads WordPress
/**
* add SVG to allowed file uploads - copy in the functions.php
**/
function add_file_types_to_uploads($file_types){
$new_filetypes = array();
$new_filetypes['svg'] = 'image/svg+xml';
$file_types = array_merge($file_types, $new_filetypes );
@beflash
beflash / rss-feed.php
Last active December 12, 2024 13:49
rss-feed.php (functions/rss-feed.php)
<?php
// FEED EINZELABFRAGE
function fetch_rss_feed($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$data = curl_exec($ch);
curl_close($ch);
@beflash
beflash / login.php
Last active December 12, 2024 13:59
login.php (functions/login.php)
<?php
// Redpishi.com WordPress login page Photography Template
add_filter( 'the_content', 'redpihi_custom_login' );
function redpihi_custom_login( $content ) {
$fullScreen = 1;
$logo = 'https://redpishi.com/wp-content/uploads/2022/06/3.png';
$bg ='https://redpishi.com/wp-content/uploads/2022/06/bg3-scaled.webp';
$loging_users = '<p>Hello '.wp_get_current_user()->user_login.'! You are logged in.</p>';
if (is_page(get_page_by_title( 'login' )->ID)) {