Skip to content

Instantly share code, notes, and snippets.

@kankadev
kankadev / functions.php
Created June 29, 2024 18:53
[remove author] remove author data from embed / sharing in e.g. Discord #embed
add_filter( 'oembed_response_data', 'disable_embeds_filter_oembed_response_data_' );
function disable_embeds_filter_oembed_response_data_( $data ) {
unset($data['author_url']);
unset($data['author_name']);
return $data;
}
@kankadev
kankadev / functions.php
Last active February 18, 2024 14:43
[Inhaltsverzeichnis für Posts per JS] #Inhaltsverzeichnis #wordpress #wp
add_action('wp_enqueue_scripts', 'theme_enqueue_styles');
function theme_enqueue_styles()
{
wp_enqueue_style('parent-style', get_template_directory_uri() . '/style.css');
wp_enqueue_script('child-script', get_stylesheet_directory_uri() . '/js/custom.js');
if (is_single()) {
wp_enqueue_script('singlepost-script', get_stylesheet_directory_uri() . '/js/post.js');
}
}
@kankadev
kankadev / custom.js
Last active March 15, 2023 17:43
[Play video automatically if it's in viewport] This script plays a video automatically if it's visible in the viewport and it's paused if you scroll further. Add the class "knk-autoplay" to the videos parent div. #divi #jquery #wordpress #video
$(function() {
const autoplayVideos = $('.knk-autoplay .et_pb_video_box');
if (autoplayVideos.length) {
autoplayVideos.find('video').prop('muted', true)
.attr({
loop: 'loop',
playsInline: ''
});
@kankadev
kankadev / notify_ssh_login_slack.sh
Created March 13, 2023 20:40
[SSH Login Notification to Slack] This script notifies about SSH logins in a Slack channel #ssh #slack #linux
#!/bin/bash
# Add an incoming webhook in Slack first.
# Then save this script somewhere, e.g. /etc/ssh/scripts/notify_ssh_login_slack.sh and execute these commands once:
# chmod +x /etc/ssh/scripts/notify_ssh_login_slack.sh
# sudo echo "session optional pam_exec.so seteuid /etc/ssh/scripts/notify_ssh_login_slack.sh" >> /etc/pam.d/sshd
if [ "$PAM_TYPE" != "close_session" ]; then
URL="<slack-webhook-url>"
@kankadev
kankadev / functions.php
Created February 27, 2023 18:25
[CF7 Replace Input-Submit with real button] Replaces <input type="submit"> with real button in CF7 #cf7 #functions.php #wordpress
#region CF7
#region Submit-Input durch Button ersetzen
remove_action('wpcf7_init', 'wpcf7_add_form_tag_submit');
add_action('wpcf7_init', 'nd_cf7_button');
if (!function_exists('nd_cf7_button')) {
function nd_cf7_button()
{
wpcf7_add_form_tag('submit', 'nd_cf7_button_handler');
}
}
@kankadev
kankadev / open_directory.lua
Created February 14, 2023 08:09
[Open Directory VLC Plugin] This plugin opens the file explorer window of the directory where the current playing video is located. #vlc #lua
--[[
Open Directory VLC Plugin
This plugin opens the file explorer window of the directory where the current playing video is located.
Installation:
1. Move this file to the VLC plugins directory. On Windows, the default directory is "C:\Program Files (x86)\VideoLAN\VLC\lua\extensions".
2. Restart VLC.
3. Play a file.
4. Go to "View" and click on the plugin's name. The directory of the current playing file will be opened.
@kankadev
kankadev / functions.php
Created February 3, 2023 19:50
[Rename Elementor "add to cart" button] Rename Elementor (single) add to cart button. #elementor #wordpress #php #functions.php
add_filter('woocommerce_product_single_add_to_cart_text', function ($label) {
return 'Jetzt buchen!';
}, 9999999);
add_filter('woocommerce_product_add_to_cart_text', function ($label) {
return 'Jetzt buchen!';
}, 9999999);
@kankadev
kankadev / apt-updates.py
Created January 29, 2023 16:55
Send notification of available APT updates via Discord. Call apt-updates.py daily in a cronjob.
#!/usr/bin/env python3
# coding=utf-8
import apt
import apt_pkg
from time import strftime
import os
import subprocess
import sys
from discord import webhook as dc
@kankadev
kankadev / functions.php
Created December 6, 2022 17:20
[Yoast SEO Breadcrumb Filter] How to filter single breadcrumbs and style "Home" link #yoast #yoastseo #breadcrumb #wordpress #wp
#region Yoast SEO Breadcrumb Filter
function wpseo_remove_breadcrumb_link($link_output, $link)
{
$text_to_remove = 'Startseite';
if ($link['text'] == $text_to_remove) {
$link_output = '<a class="knk_breadcrumb_home" href="' . get_home_url() . '"></a>';
}
return $link_output;
@kankadev
kankadev / style.css
Last active August 18, 2022 14:13
[fix Divi header mobile menu overflow] Makes huge mobile menu scrollable #WordPress #Divi #CSS
header#main-header ul#mobile_menu {
overflow: scroll;
max-height: 80vh;
-overflow-scrolling: touch;
-webkit-overflow-scrolling: touch;
}