Skip to content

Instantly share code, notes, and snippets.

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

Filipe Seabra filipecsweb

🏠
Working from home
View GitHub Profile
@filipecsweb
filipecsweb / functions.php
Last active September 7, 2024 19:22
Rename WordPress media file name when doing upload
<?php
/**
* Rename file name while doing upload.
*
* @param string $filename The name of the file being uploaded
*
* @return string The sanitized string
*/
function my_custom_file_name( $filename ) {
$info = pathinfo( $filename );
@filipecsweb
filipecsweb / get_color_scheme_css.js
Last active May 11, 2019 19:54
Builds a stylesheet content using coolors.co Color Scheme.
(function ($) {
let stylesheet = '',
html = '';
function get_colors(parent) {
let colors = {};
colors.lighter = String($(".color-shade:nth-child(5)", parent).data("color"));
@filipecsweb
filipecsweb / wp-sweep-uploads.php
Last active April 10, 2023 23:39
WordPress - Delete unused image files from uploads directory
<?php
/**
* @author Filipe Seabra
* @link https://wp-cli.org/
* @version 1.0.0
*
* Put this file in the root directory of your WordPress installation.
*
* You make better usage of this file by using WP CLI (link above). Command line example:
* `wp eval-file wp-sweep-uploads.php`.
@filipecsweb
filipecsweb / functions.php
Last active August 1, 2019 19:57
WordPress - Remove useless registered image sizes
<?php
/**
* Hooked into `intermediate_image_sizes` filter hook.
*
* @param array $image_sizes
*
* @return array
*/
function ss_unset_intermediate_image_sizes( $image_sizes ) {
$bad_sizes = array(