This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$files = glob("*"); | |
$time = time(); | |
$ignore = array('cleanup.php','.ftpquota','index.html','robots.txt'); | |
foreach($files as $file) { | |
if(is_file($file) && !in_array($file,$ignore)) { | |
if($time - filemtime($file) >= 60*60*24*30) { // 30 days | |
unlink($file); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Remove bits of variation data from WooCommerce cart & emails we don't want to show | |
add_filter( 'woocommerce_get_item_data', 'mr_filter_variable_item_data', 10, 2 ); | |
function mr_filter_variable_item_data( $item_data, $cart_item ) { | |
// Labels we want to remove | |
$items_to_remove = [ 'Base price' ]; | |
// Remove any items where the label matches | |
foreach( $item_data as $key => $data ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class your_elementor_hooks { | |
use \Essential_Addons_Elementor\Traits\Helper; | |
function __construct() { | |
add_action( 'elementor/widget/render_content', array( $this, 'roxx_carousel_render' ), 10, 2 ); | |
} | |
public function roxx_carousel_render( $content, $widget ) { | |
if ( 'eael-post-carousel' === $widget->get_name() ) { | |
$settings = $widget->get_settings(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Don't allow blank searches (too intensive) | |
add_action( 'init', function() { | |
if( isset( $_GET['s'] ) && '' == $_GET['s'] && !is_admin() ) { | |
wp_redirect( site_url() ); | |
exit; | |
} | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'wp_login', 'set_user_agent', 10, 2 ); | |
add_action( 'init', 'check_user_agent', 1 ); | |
function set_user_agent( $user_login, $user ) { | |
$user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] ); | |
$user_ip = sanitize_text_field( $_SERVER['REMOTE_ADDR'] ); | |
update_user_meta( $user->ID, 'user_agent', $user_agent ); | |
update_user_meta( $user->ID, 'user_ip', $user_ip ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$files = glob("*"); | |
$time = time(); | |
$ignore = array('cleanup.php','.ftpquota','index.html','robots.txt'); | |
foreach($files as $file) { | |
if(is_file($file) && !in_array($file,$ignore)) { | |
if($time - filemtime($file) >= 60*60*24*30) { // 30 days | |
unlink($file); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$server = 'something.com'; | |
$ftp_user_name = 'username'; | |
$ftp_user_pass = 'password'; | |
$filename = 'June2Site.zip'; | |
$source = 'aaa/'.$filename; | |
$dest = '/new/'.$filename; | |
$mode = FTP_BINARY; // FTP_ASCII for text files (html, css, js etc) | |
$connection = ftp_ssl_connect ($server,24); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Disable the confirmation notices when an administrator changes their email address. | |
// Per http://codex.wordpress.com/Function_Reference/update_option_new_admin_email | |
// Remove existing hooks | |
remove_action( 'add_option_new_admin_email', 'update_option_new_admin_email' ); | |
remove_action( 'update_option_new_admin_email', 'update_option_new_admin_email' ); | |
// Add our new hooks | |
add_action( 'add_option_new_admin_email', 'mr_update_option_new_admin_email', 10, 2 ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function noindex_urls() { | |
global $wpdb; | |
$debug = true; | |
$urls = array( | |
'http://example.com/ok', | |
'http://example.com/blah/?g=ok', | |
'http://example.com/blah/foo/' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Usage: Example below makes the CPT archive "Events" show all upcoming events only, and order by soonest->latest | |
// Make sure to change the 'key' to your meta_value that has the post ID (you can use future posts but that can cause other problems) | |
function show_upcoming_events( $query ) { | |
if ( is_admin() || ! $query->is_main_query() ) { | |
return; | |
} | |
if ( is_post_type_archive( 'events' )) { |
NewerOlder