Skip to content

Instantly share code, notes, and snippets.

Avatar

Keith Crain kwcjr

View GitHub Profile
@kwcjr
kwcjr / gist:7ccb956346e924ca8d03819f75d8ea9d
Created Jul 26, 2022
List wp /upload directory file sizes.
View gist:7ccb956346e924ca8d03819f75d8ea9d
$upload_dir = wp_upload_dir();
$folder = $upload_dir['basedir'];
$files = list_files( $folder );
foreach ( $files as $file ) {
if ( is_file( $file ) ) {
$filesize = size_format( filesize( $file ) );
$filename = basename( $file );
echo esc_html( $filename . " - (" . $filesize ) . ")<br />";
}
@kwcjr
kwcjr / domain-status.php
Created Jul 16, 2022
Domain Status Report snippet
View domain-status.php
<?php if ( $plugin_active_domainmonitor ) { ?>
<tr><th><?php echo __( 'Domain status', 'mainwp-pro-reports-extension' ); ?></th><td>[domain.monitor.status]</td></tr>
<?php } ?>
View svg.css
#adminmenu #toplevel_page_ContactSupport2 .dashicons-admin-generic::before{
content: ' ';
background-repeat: no-repeat;
background-image: url(data:image/svg+xml;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAEHSURBVDhPpZPPCgFRFIe/mUhYUFJi5xW8gvIOFmJrR7OyUrKw8wJsvYPyJhY2kp2Fv0XHZU5Jrkt8dZvfmXPna+69M57s90K3C5EIFArQbOJkPIb5HC4X6HRAej0Rc7mPYlE+Uio95geB+MTjqjYkkxocJBIaDOZZX+NveN6fAoNbMJ3CbKaFHbegUoFyWQs7dkG/f18f6XR4tLfcamnzGbug0YBoFDYbWC4hFoMg0OYzdkE+D6sVjEYwHMJ6Hb6Jhfd7kMlArQbVKqRSevMV9ybePu9sVgs7bsEX/Ccwf4TP8aiVYbvV4GC302A4HPDkdBIGg/DYcjmo17X7hskEFgs4n6Hd5goYOmhHCaP71QAAAABJRU5ErkJggg==);
}
@kwcjr
kwcjr / functions.php
Last active Mar 2, 2022
Add custom preview text to wp_mail
View functions.php
<?php
/**
* Plugin Name: Replace Pre-Header Email Text.
* Description: Replace Line 27 with what text you want. This will replace the text just after your Subject - "Your text".
* Author: Keith Crain ( Kronoslabs.io )
* License: GNU General Public License v3 or later
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
/**
@kwcjr
kwcjr / klbs_custom_woo_pre_header_text.php
Last active Mar 2, 2022
Replace WooCommerce Subject line Preview Text ( drop in /wp-content/mu-plugins/ folder.
View klbs_custom_woo_pre_header_text.php
<?php
/**
* Plugin Name: Replace Pre-Header Email Text.
* Description: Replace Line 27 with what text you want. This will replace the text just after your Subject - "Your text".
* Author: Keith Crain ( Kronoslabs.io )
* License: GNU General Public License v3 or later
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
/**
@kwcjr
kwcjr / add_to_cart.php
Last active Feb 12, 2022
Change add to cart text
View add_to_cart.php
// To change add to cart text on single product page.
add_filter( 'woocommerce_product_single_add_to_cart_text', 'custom_add_to_cart_callback' );
// To change add to cart text on product archives(Collection) page.
add_filter( 'woocommerce_product_add_to_cart_text', 'custom_add_to_cart_callback' );
// Custom add_to_cart text to change to.
function custom_add_to_cart_callback() {
return __( 'Submit Payment', 'text-domain' );
}
@kwcjr
kwcjr / divi_popup.php
Last active Jan 29, 2022
Load custom Divi popup scripts.
View divi_popup.php
/**
* Load custom Divi popup scripts.
* @source https://divihacks.com/how-to-create-a-popup-in-divi-without-a-plugin/
*/
function uniqueID_content_after_body_open_tag() {
?>
<script type="text/javascript">jQuery(document).ready(function(t){t('div:not(.et_mobile_menu) .lightbox-content, div:not(.et_mobile_menu) [class*="lightbox-content-"]').addClass("mfp-hide"),t("div:not(.et_mobile_menu) .lightbox-trigger").magnificPopup({items:{src:"div:not(.et_mobile_menu) .lightbox-content",type:"inline"}}),t('div:not(.et_mobile_menu) [class*="lightbox-trigger-"]').each(function(){var i=".lightbox-content-"+Array.prototype.find.call(this.classList,function(t){return t.indexOf("lightbox-trigger-")>-1}).split("lightbox-trigger-")[1];t(this).magnificPopup({items:{src:i,type:"inline"}})}),t(this).click(function(){t(".mfp-wrap").attr("id","et-boc")}),t('[class*="lightbox-content"]').prepend('<div class="lightbox-overlay"></div>')});</script>
<script src="/wp-content/themes/Divi/includes/builder/feature/d
@kwcjr
kwcjr / mainwp-pro-report-template.php
Created Jan 16, 2022
MainWP Pro Reports WordFence Table.
View mainwp-pro-report-template.php
<!-- WordFence Data -->
<div class="page-break"></div>
<div style="padding:30px;">
<div style="padding:30px;">
<h2><?php echo __( 'WordFence', 'mainwp-pro-reports-extension' ); ?></h2>
<h3><?php echo __( 'Total Scan Count: ', 'mainwp-pro-reports-extension' ); ?>[wordfence.scan.count]</h3>
<table>
<thead>
<tr>
<th><?php echo __( 'Scanned on', 'mainwp-pro-reports-extension' ); ?></th>
@kwcjr
kwcjr / delete-wp-readme.php
Created Nov 27, 2021
Delete WP readme.html
View delete-wp-readme.php
/**
* Delete WP readme.html file remotely.
*
* This snippet will delete the readme.html file from your Child Site root dir.
*
* @snippetType: Return info from Child Site.
*/
// Load in WP Core files we need.
include_once(ABSPATH . WPINC . '/functions.php');
include_once(ABSPATH . WPINC . '/plugins.php');
@kwcjr
kwcjr / purge-ls-after-updates.php
Created Nov 25, 2021
Purge LiteSpeed cache after updates.
View purge-ls-after-updates.php
/**
* Purge LiteSpeed Cache after updates.
*
* This snippet will check if LS plugin is activated & then Purge all Cache
* after any Core, Theme or Plugin Installation, Update or rollback.
*
* @snippetType: Execute on Child Sites
*/
function my_upgrade_function( $upgrader_object, $options ) {
// Purge all LS Cache.