Skip to content

Instantly share code, notes, and snippets.

View vyskoczilova's full-sized avatar

Karolína Vyskočilová vyskoczilova

View GitHub Profile
@vyskoczilova
vyskoczilova / Add new user: add to wp_usersmeta.sql
Last active February 6, 2018 16:36
Add new user: add to wp_usersmeta
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '9999', 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}'), (NULL, '9999', 'wp_user_level', '10');
@vyskoczilova
vyskoczilova / Add new user: add to wp_users.sql
Last active February 6, 2018 16:36
Add new user: add to wp_users
INSERT INTO `wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES ('9999', 'username', MD5('password'), 'nickname', '[email protected]', '', '2014-11-04 00:00:00', '', '0', 'username');
@vyskoczilova
vyskoczilova / upload_max_filesize_wpmu.php
Last active February 19, 2018 13:27
Upload max filesize | WP Multisite
/**
* @snippet Upload max filesize | WP Multisite
* @comment Put the correct blog id number in the if condition. Currently set to the main blog.
* @source https://kybernaut.cz/clanky/wp-multisite-maximalni-velikost-nahravaneho-souboru/
* @author Karolína Vyskočilová (https://kybernaut.cz)
* @testedwith WordPress Multisite 4.9
*/
// -------------------
function custom_filter_fileupload_maxk( $maxk ) {
@vyskoczilova
vyskoczilova / tax_placeholders_for_price_display_suffix.php
Last active June 19, 2020 09:48
Tax placeholders for Price Display Suffix
<?php
/**
* @snippet Tax placeholders for Price Display Suffix | WooCommerce
* @comment Use "{tax_rate}" and "{tax_rate_label}" placeholder for displaying the product tax rate and its label
* @source https://gist.github.com/vyskoczilova/2ff56afcfd4c75338fb7f0be3a5615c2
* @author Karolína Vyskočilová (https://kybernaut.cz)
* @testedwith WooCommerce 4.2
*/
// -------------------
@vyskoczilova
vyskoczilova / woocommerce-stock-filter-for-wordpress-admin.php
Last active April 24, 2021 16:30
WooCommerce add stock filter to WordPress Admin (Products)
/**
* @snippet Add Stock Filter to Products page in WordPress admin | WooCommerce
* @comment Localization is automatic if you have localized WooCommerce to your language
* @source https://gist.github.com/vyskoczilova/fbc9dd818af20ff514cdb2d50eab410a
* @updatedversionof https://popoleodesigns.com/add-inout-of-stock-filter-to-wordpress-admin/
* @author Karolína Vyskočilová
* @testedwith WooCommerce 3.0.7
*/
// -------------------
@vyskoczilova
vyskoczilova / WooCommerce check Billing phone against pattern
Created May 10, 2017 17:33
WooCommerce check Billing phone against pattern
add_filter( 'woocommerce_checkout_fields' , 'wc_kbnt_override_checkout_fields' );
function wc_kbnt_override_checkout_fields( $fields )
{
$fields['billing']['billing_phone']['custom_attributes'] = array( "pattern" => "^\+?{1}[0-9 ]{9,17}$" );
return $fields;
}
@vyskoczilova
vyskoczilova / Phone number not required in WooCommerce checkout
Last active May 7, 2017 10:35
Make the phone number not required in WooCommerce checkout
add_filter( 'woocommerce_billing_fields', 'wc_kbnt_filter_phone', 10, 1 );
function wc_kbnt_filter_phone( $address_fields ) {
$address_fields['billing_phone']['required'] = false;
return $address_fields;
}
<?php
function change_wp_search_size($query) {
if ( $query->is_search ) // Make sure it is a search page
$query->query_vars['posts_per_page'] = 10; // Change 10 to the number of posts you would like to show
return $query; // Return our modified query variables
}
add_filter('pre_get_posts', 'change_wp_search_size'); // Hook our custom function onto the request filter
add_filter( 'allow_subdirectory_install',
create_function( '', 'return true;' )
);
<?php
add_shortcode( 'kbnt_svatek', 'kybernaut_svatek' );