Skip to content

Instantly share code, notes, and snippets.

View dnshulga's full-sized avatar
🌴
On vacation

Dmitry Shulga dnshulga

🌴
On vacation
  • Worldwide
View GitHub Profile
@mtx-z
mtx-z / wp-woocommerce-edit-product-loop-thumbnail-template.php
Last active February 22, 2024 08:47
Woocommerce (3.8.1-6.2.2) edit product loop thumbnail template (allows to had/edit HTML outputted by Woocommerce to generate the product loop thumbnail image area, as there is no dedicated template file to override) - Wordpress / WooCommerce 3.8.1-6.2.2
<?php
/**
* Edit default Woocommerce product loop thumbnail template
* As there is no dedicated Woocommerce template (eg wp-content/plugins/woocommerce/templates/loop/price.php)
* because it's generated using filter, we must remove Woocommerce hook, and add our own "at the same place"
* to edit the product loop thumbnail template
* tested up to
* 14/07/2023 :
* Woocommerce 6.2.2
* 12/10/2020 :
@dnshulga
dnshulga / Reinitialize slick slider
Last active June 5, 2019 13:35
A possibility to reinitialize slick slider if the variable of slick slider is unvisible in your js file
$('.slick-slider').not('.slick-initialized').slick({
infinite: false,
slidesToShow: 1,
slidesToScroll: 1,
dots: true,
arrows: false,
touchThreshold: 9
});
@dnshulga
dnshulga / Fix counters on section Pages Wordpress
Last active April 19, 2019 11:47
How to fix counters on Pages section after hiding of pages from dashboard Wordpress? Here we go
add_action( 'pre_get_posts' ,'dnshulga_exclude_pages' );
function dnshulga_exclude_pages( $query ) {
if( !is_admin() )
return $query;
global $pagenow;
if( 'edit.php' == $pagenow && ( get_query_var('post_type') && 'page' == get_query_var('post_type') ) )
$query->set( 'post__not_in', array(213, 221) ); //ids of pages to hide
return $query;
@dnshulga
dnshulga / Hide ACF totally
Created March 21, 2019 15:05
Hide ACF totally: remove admin menu page, remove gear of ACF from pages, do redirect from ACF admin menu page
<?php
/*Hide ACF Tottally*/
add_filter('acf/settings/show_admin', '__return_false');
function pands_admin_colors() {
echo '<style type="text/css">
h2.hndle.ui-sortable-handle a.acf-hndle-cog { display: none; visibility: hidden }
</style>';
}
add_action('acf/input/admin_head', 'pands_admin_colors');
function disallowed_acf_page() {
@slaus
slaus / menu_item_me_awake_when_you_scroll.js
Created April 12, 2018 14:01 — forked from yaroslavKas/menu_item_me_awake_when_you_scroll.js
МЕНЯЕМ АКТИВНЫЙ ПУНКТ МЕНЮ ПРИ ПРОКРУТКЕ СТРАНИЦЫ
var menu_selector = ".top-menu"; // Переменная должна содержать название класса или идентификатора, обертки нашего меню.
var menu = jQuery('#header').outerHeight();
jQuery("#mainnav li:first-child a").addClass("current");
function onScroll(){
var scroll_top = jQuery(document).scrollTop();
jQuery(menu_selector + " a").each(function(){
var hash = jQuery(this).attr("href");
var target = jQuery(hash);
@vielhuber
vielhuber / functions.php
Created October 17, 2017 13:28
get permalink / url by template name #wordpress
<?php
function get_page_url($template_name)
{
$pages = get_posts([
'post_type' => 'page',
'post_status' => 'publish',
'meta_query' => [
[
'key' => '_wp_page_template',
'value' => $template_name.'.php',
@leogopal
leogopal / youtube-id.php
Last active July 5, 2021 15:37
PHP function to get youtube ID from URL
<?php
function get_youtube_video_ID($youtube_video_url) {
/**
* Pattern matches
* http://youtu.be/ID
* http://www.youtube.com/embed/ID
* http://www.youtube.com/watch?v=ID
* http://www.youtube.com/?v=ID
* http://www.youtube.com/v/ID
* http://www.youtube.com/e/ID
@loorlab
loorlab / disable_tags_WP.php
Created March 5, 2017 17:04
Disable Tags WordPress
<?php
// Disable Tags Dashboard WP
add_action('admin_menu', 'my_remove_sub_menus');
function my_remove_sub_menus() {
remove_submenu_page('edit.php', 'edit-tags.php?taxonomy=post_tag');
}
// Remove tags support from posts
function myprefix_unregister_tags() {
unregister_taxonomy_for_object_type('post_tag', 'post');
@stormwild
stormwild / woocommerce-create-order.md
Last active November 5, 2023 01:40
WooCommerce Creating Order Programmatically

WooCommerce Creating Order Programmatically

WooCommerce Create Order

creating Woocommerce order with line_item programatically

// http://stackoverflow.com/questions/26581467/creating-woocommerce-order-with-line-item-programatically
$address = array(
            'first_name' => 'Fresher',
@ctlcltd
ctlcltd / wordpress_low-quality-image-placeholders_lqip.md
Last active June 22, 2023 20:08
How to easily generate low quality image placeholders (lqip) in WordPress

How to easily generate low quality image placeholders (lqip) in WordPress

I have made this function using the WP_Image_Editor class and I have filtered through the "wp_generate_attachment_metadata" hook. You can modify the "theme" namespace into function names with your theme name or in anyway you like.

Applying the filter directly to wp_generate_attachment_metadata the image placeholders are auto added into WordPress metadata, so when your add/modify/delete an image (or regenerate it via a plugin), it accomplishes to modify also to the image placeholders.

The use of the native theme support can prevent the generation of lqip or target specific image sizes to generate.

It contains an hook filter lqip_quality to modify the quality without have to modify the function.