Skip to content

Instantly share code, notes, and snippets.

View apsolut's full-sized avatar
🎯
Focusing

Aleksandar Perisic apsolut

🎯
Focusing
View GitHub Profile
@apsolut
apsolut / preserve-page-and-taxonomy-hierarchy.php
Created April 21, 2017 07:32
WP backend navigation without pagination - nav-menus
<?php
/*
Plugin Name: Preserve Page and Taxonomy Hierarchy on Edit Menus Screen
Version: 0.1
Plugin URI: https://core.trac.wordpress.org/ticket/18282
Description: Disables paging for hierarchical post types and taxonomies on Edit Menus screen to preserve proper hierarchy in meta boxes.
Author: Sergey Biryukov
Author URI: http://profiles.wordpress.org/sergeybiryukov/
*/
@apsolut
apsolut / plesk-nginx
Created December 29, 2022 09:29
Additional nginx directives Plesk
location ~* ^(/.+)\.(jpg|jpeg|jpe|png|gif)$ {
add_header Vary Accept;
if ($http_accept ~* "webp"){
set $imwebp A;
}
if (-f $request_filename.webp) {
set $imwebp "${imwebp}B";
}
if ($imwebp = AB) {
@apsolut
apsolut / apsolut-wordpress-cleaner-example.php
Created April 12, 2023 09:00
WordPress Auto Cleaner - Example to Delete Comments, Pages and create new Page
<?php
/**
* Delete pages
* @link https://developer.wordpress.org/reference/functions/wp_delete_post/
*/
function apsolut_delete_multiple_pages_from_plugin() {
// Set an array of page IDs to delete
$page_ids = array(1, 2, 3); // Hello World, Homepage, Privacy Policy
@apsolut
apsolut / desc.php
Created April 24, 2022 20:53 — forked from igorbenic/desc.php
How to Programmatically Change Yoast SEO Open Graph Meta | http://www.ibenic.com/programmatically-change-yoast-seo-open-graph-meta
<?php
function change_yoast_seo_og_meta() {
add_filter( 'wpseo_opengraph_desc', 'change_desc' );
}
function change_desc( $desc ) {
// This article is actually a landing page for an eBook
if( is_singular( 123 ) ) {
@apsolut
apsolut / update-product-prices.php
Created December 8, 2021 19:59 — forked from devinsays/update-product-prices.php
Updates product prices via WP CLI script.
<?php
/**
* Updates product prices.
* More about WP CLI scripts:
* https://wptheming.com/2021/05/wp-cli-scripts-and-woocommerce/
*
* wp eval-file update-product-prices.php
*/
$products = get_posts([
@apsolut
apsolut / giftable-exclude-category-from-shop-archive.php
Created June 24, 2019 23:39
giftable-exclude-category-from-shop-archive
<?php //<- dont add me into functions.php
/**
* Hide Gift Product Category from Shop
* https://wordpress.org/support/topic/hide-gift-product-category-from-shop/
* Create category Exclude or Gifts
* Category slug: exclude, gifts
* add gifts that you want to exclude from shop archive to this category
*/
add_action( 'woocommerce_product_query', 'giftable_custom_pre_get_posts_query' );
@apsolut
apsolut / fix-wsl2-dns-resolution
Created November 27, 2021 13:25 — forked from coltenkrauter/fix-wsl2-dns-resolution
Fix DNS resolution in WSL2
More recent resolution:
1. cd ~/../../etc (go to etc folder in WSL).
2. echo "[network]" | sudo tee wsl.conf (Create wsl.conf file and add the first line).
3. echo "generateResolvConf = false" | sudo tee -a wsl.conf (Append wsl.conf the next line).
4. wsl --terminate Debian (Terminate WSL in Windows cmd, in case is Ubuntu not Debian).
5. cd ~/../../etc (go to etc folder in WSL).
6. sudo rm -Rf resolv.conf (Delete the resolv.conf file).
7. In windows cmd, ps or terminal with the vpn connected do: Get-NetIPInterface or ipconfig /all for get the dns primary and
secondary.
@apsolut
apsolut / docker-wordpress-base.yaml
Last active November 27, 2021 02:34
maybe its time for Docker - WordPress local development
#### TRY
### https://gitmemory.cn/repo/nezhar/wordpress-docker-compose/issues/74
###
###
###
###
version: "3.9"
services:
@apsolut
apsolut / woocommerce-javascript-events.js
Created October 14, 2021 06:30
WooCommerce JavaScript events
/**
* https://docs.woocommerce.com/document/composite-products/composite-products-js-api-reference/
* https://wordpress.stackexchange.com/questions/342148/list-of-js-events-in-the-woocommerce-frontend
*/
//Woocommerce Checkout JS events
$( document.body ).trigger( 'init_checkout' );
$( document.body ).trigger( 'payment_method_selected' );
$( document.body ).trigger( 'update_checkout' );
$( document.body ).trigger( 'updated_checkout' );