Skip to content

Instantly share code, notes, and snippets.

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

Vecsei Szilveszter weszty

🏠
Working from home
View GitHub Profile
@weszty
weszty / checkout-1.js
Created October 13, 2023 11:37 — forked from igorbenic/checkout-1.js
How to add a City Dropdown to WooCommerce Checkout
jQuery( function( $ ) {
var cities = wc_city_dropdown.cities;
wrapper_selectors = '.woocommerce-billing-fields,' +
'.woocommerce-shipping-fields,' +
'.woocommerce-address-fields';
$( document.body ).on( 'change refresh', 'select.country_to_state, input.country_to_state', function() {
var $wrapper = $( this ).closest( wrapper_selectors );
<?php
/**
* Plugin Name: Static Templates
*
* If most of your site content is in .php template files, and you're tired of
* creating new pages, assigning them page templates, creating page templates
* then doing it all over again on production, this plugin is for you.
*
* Examples:
*
@weszty
weszty / functions.php
Created February 24, 2023 13:41 — forked from schilke/functions.php
Remove query strings
<?php
// don't copy above line when copying and pasting into your functions.php
// Remove WP version number from js and css files.
// more exact function, removes also "&"
function remove_cssjs_ver( $src ) {
if( strpos( $src, '?ver=' ) || strpos( $src, '&ver=' ) )
$src = remove_query_arg( 'ver', $src );
@weszty
weszty / functions.php
Created February 23, 2023 18:53 — forked from schilke/functions.php
How to load CSS files asynchronously in WordPress (using Scott Jehl's "loadCSS")
<?php
// This is the cleaner code per request of a thread in the LinkedIn group "WordPress"
// ...
// register and enqueue loadCSS
function load_scripts_and_styles() {
// register loadCSS
wp_register_script( 'load-css-async', get_stylesheet_directory_uri() . '/path/to/js/loadCSS.js', array(), '', false );
@weszty
weszty / .htaccess
Created February 15, 2023 11:17 — forked from mtx-z/.htaccess
Wordpress .htaccess with Header Caching + CSP Content Security Policy + Gzip compression + PHP execution protection + Spam protection (WIP)
#WP block - see https://fr.wordpress.org/support/article/htaccess/
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
# ajouter un slash après /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
@weszty
weszty / action1.php
Created February 13, 2023 21:26 — forked from igorbenic/action1.php
How to add a Custom Column in WordPress with OOP | http://www.ibenic.com/add-custom-column-wordpress-oop/
<?php
// Action Hook to add column value for posts
add_action( 'manage_posts_custom_column' , 'your_function', 10, 2 );
@weszty
weszty / image-cropper.php
Created February 9, 2023 12:33 — forked from BhargavBhandari90/image-cropper.php
Image Cropper With PLUpload & JCrop
<?php
/**
* Enqueues the css and js required by the Image Crop.
*/
function blp_core_cover_image_scripts() {
wp_enqueue_script( 'jcrop', array( 'jquery' ) );
wp_enqueue_script( 'plupload', array(), false, false );
wp_enqueue_style( 'jcrop' );
}
@weszty
weszty / child-theme-functions.js
Created February 8, 2023 12:10 — forked from yanknudtskov/child-theme-functions.js
Dynamically add fees based on selected payment gateway in WooCommerce #woocommerce #dynamic-fees #fees
jQuery(document).ready(function() {
jQuery(document.body).on('change', 'input[name="payment_method"]', function() {
jQuery('body').trigger('update_checkout');
});
});
@weszty
weszty / gist:8f9ed3fffbe331ea3855d8d7ec513984
Created February 5, 2023 15:06 — forked from habibmac/gist:2883255
WP: Sharpen resized images (JPG only)
function ajx_sharpen_resized_files( $resized_file ) {
$image = wp_load_image( $resized_file );
if ( !is_resource( $image ) )
return new WP_Error( 'error_loading_image', $image, $file );
$size = @getimagesize( $resized_file );
if ( !$size )
return new WP_Error('invalid_image', __('Could not read image size'), $file);
list($orig_w, $orig_h, $orig_type) = $size;
@weszty
weszty / widget.php
Created January 15, 2023 22:54 — forked from wpmu-authors/widget.php
widget.php
<?php
class My_Favorite_Director_Widget extends WP_Widget
{
function __construct()
{
$widget_details = array(
'classname' => 'my-favorite-director-widget',
'description' => 'Display movies from your favorite director.'
);