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
@igorbenic
igorbenic / checkout-1.js
Created May 26, 2023 15:09
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 );
@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.'
);
@mtx-z
mtx-z / .htaccess
Last active February 15, 2023 11:17
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 / wl-api.php
Created August 3, 2021 13:19 — forked from ivandoric/wl-api.php
WordPress Rest API Custom Filters (Video Tutorials Notes) - Check out the video: https://www.youtube.com/watch?v=5rSfAkLO5eo
<?php
/**
* Plugin Name: Custom API
* Plugin URI: http://chrushingit.com
* Description: Crushing it!
* Version: 1.0
* Author: Art Vandelay
* Author URI: http://watch-learn.com
*/
@wpmu-authors
wpmu-authors / widget.php
Created February 11, 2021 08:06
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.'
);
@ivandoric
ivandoric / wl-api.php
Created October 5, 2020 09:17
WordPress Rest API Custom Filters (Video Tutorials Notes) - Check out the video: https://www.youtube.com/watch?v=5rSfAkLO5eo
<?php
/**
* Plugin Name: Custom API
* Plugin URI: http://chrushingit.com
* Description: Crushing it!
* Version: 1.0
* Author: Art Vandelay
* Author URI: http://watch-learn.com
*/
<?php
/**
* Created by PhpStorm.
* User: Bobby
* Date: 11/26/14
* Time: 1:30 PM
* Channel Log:
* @ V 1.0.0 - 11/26/14
*/
/**
@alexander-young
alexander-young / functions.php
Created January 15, 2020 02:32
Defer Javascript in WordPress
function defer_parsing_of_js($url)
{
if (is_admin()) return $url; //don't break WP Admin
if (false === strpos($url, '.js')) return $url;
if (strpos($url, 'jquery.js')) return $url;
return str_replace(' src', ' defer src', $url);
}
add_filter('script_loader_tag', 'defer_parsing_of_js', 10);
// Get The Page ID You Need
get_option( 'woocommerce_shop_page_id' );
get_option( 'woocommerce_cart_page_id' );
get_option( 'woocommerce_checkout_page_id' );
get_option( 'woocommerce_pay_page_id' );
get_option( 'woocommerce_thanks_page_id' );
get_option( 'woocommerce_myaccount_page_id' );
get_option( 'woocommerce_edit_address_page_id' );
get_option( 'woocommerce_view_order_page_id' );
get_option( 'woocommerce_terms_page_id' );
@damiencarbery
damiencarbery / amforanpr-cmb2.php
Last active September 6, 2022 13:31
CMB2 Options page to generate a list of services - Another example of using CMB2 repeater fields to replace ACF Pro repeater feature. https://www.damiencarbery.com/2019/04/cmb2-options-page-to-generate-a-list-of-services/
<?php
/*
Plugin Name: AMForanPR PR Services with CMB2
Plugin URI: http://www.damiencarbery.com
Description: Use CMB2 for the PR Services page.
Author: Damien Carbery
Version: 0.2
*/
add_action( 'cmb2_admin_init', 'dcwd_pr_services_options' );