Skip to content

Instantly share code, notes, and snippets.

View someguy9's full-sized avatar
🏠
Working from home

Andy Feliciotti someguy9

🏠
Working from home
View GitHub Profile
<?php
@ini_set( 'upload_max_size' , '128M' );
@ini_set( 'post_max_size', '128M');
@ini_set( 'max_execution_time', '300' );
//URLBOX
function urlbox_url_generate($url, $options){
$options['url'] = $url;
$options['url'] = preg_replace("(^https?://)", "", $options['url'] );
$format = isset($options['format']) ? $options['format'] : 'png';
unset($options['format']);
$_parts = [];
foreach ($options as $key => $values) {
$values = is_array($values) ? $values : [$values];
foreach ($values as $value) {
@someguy9
someguy9 / user-last-login-wordpress.php
Last active August 17, 2024 08:21
Saves a WordPress user's last login and puts it in a sortable column in the WordPress dashboard
<?php
//Record user's last login to custom meta
add_action( 'wp_login', 'smartwp_capture_login_time', 10, 2 );
function smartwp_capture_login_time( $user_login, $user ) {
update_user_meta( $user->ID, 'last_login', time() );
}
//Register new custom column with last login time
add_filter( 'manage_users_columns', 'smartwp_user_last_login_column' );
<?php
function smartwp_defer_js_parsing( $url ){
if(is_admin()) return $url; //Skip admin JS files
if(is_user_logged_in()) return $url; //Skip if user is logged in
if(false === strpos($url, '.js')) return $url; //If it's not a JS file skip
if(strpos($url, 'jquery.js')) return $url; //Don't defer jQuery
return str_replace(' src', ' defer src', $url); //defer JS file
}
add_filter( 'script_loader_tag', 'smartwp_defer_js_parsing', 10 );
@someguy9
someguy9 / example-usage-wp_enqueue_script.php
Created February 19, 2021 19:50
Example usage of wp_enqueue_script
<?php
function wp_smartwp_scripts_method() {
wp_enqueue_script( 'my-custom-script', get_stylesheet_directory_uri() . '/js/your_custom_script.js', array( 'jquery' ), true );
}
add_action( 'wp_enqueue_scripts', 'wp_smartwp_scripts_method' );
@someguy9
someguy9 / disable-core-update-emails-wordpress.php
Created February 17, 2021 14:18
Disable automatic "Your Site Has Been Updated..." emails
<?php
//Disable automatic "Your Site Has Been Updated..." emails
add_filter( 'auto_core_update_send_email', 'smartwp_disable_core_update_emails', 10, 4 );
function smartwp_disable_core_update_emails( $send, $type, $core_update, $result ) {
if ( !empty($type) && $type == 'success' ) {
return false;
}
return true;
}
@someguy9
someguy9 / allow-unsafe-link-target-wordpress.php
Created February 15, 2021 15:11
Removed rel="noopener" from links in WordPress
@someguy9
someguy9 / wordpress-get-featured-image-with-size.php
Created December 12, 2020 16:32
Displays the featured image in a <img> tag resized to the 'large' thumbnail size (use this in a loop)
memory_limit = 256M;
@someguy9
someguy9 / increase-wordpress-memory-limit.php
Created October 22, 2020 19:26
Increase WordPress memory limit (add this to wp-config.php)
<?php
define('WP_MEMORY_LIMIT', '256M');