Skip to content

Instantly share code, notes, and snippets.

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

Viorel-Cosmin Miron uhlhosting

🏠
Working from home
View GitHub Profile
@daliborgogic
daliborgogic / functions.php
Created April 14, 2020 07:09
Global Trade Identification Number (GTIN) WooCommerce
<?php
/**
* Global Trade Identification Numbers (GTINs) to WooCommerce products.
* Render the Global Trade Identification Number (GTIN) meta field.
*/
function woocommerce_render_gtin_field() {
$input = array(
'id' => '_gtin',
'label' => sprintf(
'<abbr title="%1$s">%2$s</abbr>',
@kosmala007
kosmala007 / wp-actions.php
Last active December 13, 2020 09:18
Usefull actions for wordpres eg, remove version rom source, remove emojis scripts, enable recaptcha or contact form 7 only on specyfic pages
<?php
/**
* Change default WP login errors message.
*/
add_filter('login_errors', function (): string {
return 'Invalid credentials ¯\_(ツ)_/¯';
});
/**
@alanzhaonys
alanzhaonys / gist:b69cf996ae6cdbfbd386a745da2b3bd6
Last active October 30, 2020 21:14
WordPress Admin Bar, Dashboard, head and footer Clean Up
<?php
//
//
// Below is the code that cleans up dashboard and admin bar
//
//
//
// Remove admin bar from frontend
@MalteKiefer
MalteKiefer / HowTo
Last active January 13, 2025 13:37
UFW Block IPs from abuseipdb Blacklist
# API Key
First of all create a free account here and create an API key to use the blacklist: https://www.abuseipdb.com
# UFW
You should have installed and started UFW, test it with
```bash
ufw status
```
# Cronjob
@Balachandark
Balachandark / functions.php
Last active January 3, 2024 20:19
Preload fonts
add_filter( 'astra_enable_default_fonts', 'temp_disable_astra_fonts' );
function temp_disable_astra_fonts( $load ) {
$load = false;
return $load;
}
add_action( 'wp_head', 'add_astra_fonts_preload', 1 );
function add_astra_fonts_preload() {
?>
<link rel="preload" href="<?php echo get_site_url(); ?>/wp-content/themes/astra/assets/fonts/astra.woff" as="font" crossorigin />
<link rel="preload" href="<?php echo get_site_url(); ?>/wp-content/themes/astra/assets/fonts/astra.ttf" as="font" crossorigin />
@465media
465media / gist:7e40adf2cf25ce395e11ccb4835d4a06
Created November 22, 2019 18:07
Remove Oxygen post from Insert/edit link
function removeCustomPostTypesFromTinyMCELinkBuilder($query){
$key = false;
$cpt_to_remove = array(
'oxy_user_library',
'ct_template'
);
foreach ($cpt_to_remove as $custom_post_type) {
$key = array_search($custom_post_type, $query['post_type']);
@yankiara
yankiara / customization-plugin.php
Last active October 22, 2024 07:46
Oxygen Builder dummy theme used to increase plugins compatibility
/**
* Oxy-Dummy activation (thank you Sridhar Katakam)
* Paste this code snippet in your Oxygen's customization plugin
* or copy the file to /wp-content/plugins/customization-plugin/
*/
remove_filter( 'template', 'ct_oxygen_template_name' );
remove_filter( 'template_directory', 'ct_disable_theme_load', 1, 1 );
remove_filter( 'stylesheet_directory', 'ct_disable_theme_load', 1, 1 );
/**
* Add Oxygen's global colors to Gutenberg's backend editor palette
*/
function pavenum_gutenberg_oxygen_palette() {
$gutenberg_colors = [];
$oxy_colors = oxy_get_global_colors();
foreach( $oxy_colors['colors'] as $oxy_color) {
$gutenberg_colors[] = [ 'name' => $oxy_color['name'], 'slug' => 'color-' . $oxy_color['id'], 'color' => $oxy_color['value'] ];
@swalkinshaw
swalkinshaw / application.php
Created November 17, 2019 17:29
Trellis + Sentry
<?php
/**
* composer require sentry/sentry-sdk
*/
use Sentry;
Env::init();
// Bedrock application config...
if (env('SENTRY_DSN')) {
Sentry\init([
'dsn' => env('SENTRY_DSN'),
@tzkmx
tzkmx / optimize-google-fonts-example.php
Created November 8, 2019 17:04
WordPress: Optimize google fonts download to reduce network requests, conditional load to category && page
<?php
add_filter('style_loader_src', 'modify_lato_google_font');
function modify_lato_google_font( $src ) {
$catch= preg_match('/family=Lato/', $src, $matches );
if($catch) {
$parts = preg_split('/&subset=/', $src);
$src = $parts[0] . '|Oswald:regular,700|EB+Garamond,400';
//error_log(var_export($src, true), 0);
if(!is_admin() && ( is_home() || in_category(12) )) {