Skip to content

Instantly share code, notes, and snippets.

View jas8522's full-sized avatar

Jordan S jas8522

View GitHub Profile
@jas8522
jas8522 / get_divi_posts.sql
Created February 16, 2024 20:20
How to get all WordPress posts powered by Divi Builder via SQL query
SELECT * FROM `wp_postmeta`
INNER JOIN wp_posts ON wp_posts.ID=wp_postmeta.post_id
WHERE `meta_key` LIKE '_et_pb_use_builder'
AND `meta_value` LIKE 'on'
@jas8522
jas8522 / functions.php
Created January 18, 2022 19:58
BeaverBuilder Post Grid: Replace Featured Image with First video found in content
function ws_show_first_embedded_video($settings, $module){
$post = $GLOBALS['post'];
if (has_category('videos', $post)){
//Get the content, apply filters and execute shortcodes
$content = apply_filters( 'the_content', $post->post_content );
$embeds = get_media_embedded_in_content( $content );
@jas8522
jas8522 / installatron_plesk_change_domain.sh
Created November 3, 2021 18:45
This script updates Installatron apps when someone changes a domain in Plesk. It's triggered by Plesk change domain/subdomain hooks
#!/bin/bash
#For debugging
LOGFILE=/tmp/plesk_event_handler.log
if [ "${OLD_SUBDOMAIN_NAME}" != "${NEW_SUBDOMAIN_NAME}" ]; then
# This is a subdomain change
OLD_DOMAIN_NAME="${OLD_SUBDOMAIN_NAME}.${OLD_DOMAIN_NAME}"
NEW_DOMAIN_NAME="${NEW_SUBDOMAIN_NAME}.${NEW_DOMAIN_NAME}"
#echo "$PRIMARY_DOMAIN | $OLD_DOMAIN_NAME | $NEW_DOMAIN_NAME" >> $LOGFILE
@jas8522
jas8522 / functions.php
Last active October 20, 2020 13:56
Show first video found in content on post grid
/**
* Option 1: Replace the featured image spot with the video embed
*/
function ws_replace_image_with_first_embed($html, $post_id, $post_thumbnail_id, $size, $attr){
$post = get_post($post_id);
if (has_category('videos', $post)){
//Get the content, apply filters and execute shortcodes
@jas8522
jas8522 / functions.php
Last active September 14, 2020 03:14
Creates fl_social_icons shortcode for inserting BeaverBuilder theme shortcodes in your content
/**
* Custom Social Icons Shortcode: [fl_social_icons circle=true]
*/
function ws_social_icons( $atts ) {
extract( shortcode_atts( array(
'circle' => true,
), $atts, 'multilink' ) );
ob_start( );
@jas8522
jas8522 / index.php
Created April 16, 2019 17:35
woof by_text extention modification to support plurals and re-ordering of words
if (isset($WOOF->settings['by_text']['search_by_full_word'])) {
$search_by_full_word = (int) $WOOF->settings['by_text']['search_by_full_word'];
}
/*
if ($search_by_full_word) {
$woof_text = '[[:<:]]' . $woof_text . '[[:>:]]';
}
*/
/** ADDED APR 1, 2019 by websavers (+above comment out) **/
@jas8522
jas8522 / ws-wp-xmlrpc-jail.local
Last active September 3, 2018 15:05 — forked from gbot/wp-xmlrpc-jail.local
Fail2Ban WordPress XMLRPC Jail and Filter. Notes: log path is set for Plesk v12+. Adjusted to work with a 'normal' xmlrpc request hit rate and only ban when beyond normal.
[ws-wp-xmlrpc]
enabled = true
filter = ws-wp-xmlrpc
action = iptables-multiport[name=wp-xmlrpc, port="http,https"]
logpath = /var/www/vhosts/system/*/logs/*access*log tail
/var/log/httpd/*access_log tail
# If there are 50 hits in 30 seconds (1.66/s), ban the IP for 30 minutes
bantime = 1800
maxretry = 50
findtime = 30
@jas8522
jas8522 / dovecot-maildir-compress.sh
Last active December 15, 2020 21:41 — forked from cviebrock/dovecot-maildir-compress.sh
Compresses email in maildir format
#!/bin/bash
# Enable zlib in Dovecot alongside automatic writing of new emails in gzipped format
echo '# Enable zlib plugin for reading/writing:
protocol imap {
mail_plugins = $mail_plugins zlib
}
protocol pop3 {
mail_plugins = $mail_plugins zlib