Skip to content

Instantly share code, notes, and snippets.

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

WordPress Vietnam Team wordpressvn

🏠
Working from home
View GitHub Profile
@wordpressvn
wordpressvn / gjs-disable-attachment-pages.php
Created January 18, 2024 13:49 — forked from gschoppe/gjs-disable-attachment-pages.php
WordPress plugin to properly disable attachment pages. This is not a redirect or forced 404. Attachment pages will simply not exist, and the slug will remain available for other posts and pages..
<?php if( ! defined( 'ABSPATH' ) ) { die(); }
/**
* Plugin Name: Disable Attachment Pages
* Plugin URI: https://gschoppe.com/wordpress/disable-attachment-pages
* Description: Completely disable attachment pages the right way. No forced redirects or 404s, no reserved slugs.
* Author: Greg Schoppe
* Author URI: https://gschoppe.com/
* Version: 1.0.0
**/
@wordpressvn
wordpressvn / googleurlparams.md
Created November 26, 2023 11:45 — forked from Sauerstoffdioxid/googleurlparams.md
Google/Blogger Image URL Parameters

Google/Blogger Image URL Parameters

This is an effort to document what is known about Google's (Blogger's/Blogspot's) image URL parameters. Some of these options were taken from existing first or third party documentation (see the links at the end of this document), but the majority is based off my own investigations.

Where to use them?

  • On Blogger's image URL's: 2.bp.blogspot.com/-OF7u67HQE1M/VHc8S8qJTDI/AAAAAAAACxI/UD-11c63diQ/s1600/005.png
  • On just about any googleusercontent image URL: https://lh3.googleusercontent.com/Jvmz11cLrvNIHG_LWjVO9B-UV2IN4Cfk1pycbhWZl6IriMgCAGCOFuBRtoHaiZ6xeVGqCugZcCql=w176-h176-n-o

Replace the bolded parts with the parameters.

@wordpressvn
wordpressvn / get-image-urls.js
Created April 10, 2023 02:09 — forked from tobek/get-image-urls.js
Save images from chrome inspector/dev tools network tab
/* open up chrome dev tools (Menu > More tools > Developer tools)
* go to network tab, refresh the page, wait for images to load (on some sites you may have to scroll down to the images for them to start loading)
* right click/ctrl click on any entry in the network log, select Copy > Copy All as HAR
* open up JS console and enter: var har = [paste]
* (pasting could take a while if there's a lot of requests)
* paste the following JS code into the console
* copy the output, paste into a text file
* open up a terminal in same directory as text file, then: wget -i [that file]
*/
@wordpressvn
wordpressvn / woo-product-attributes-bulk-modifier.php
Created February 8, 2023 06:59 — forked from birgire/woo-product-attributes-bulk-modifier.php
WordPress: WooCommerce Product Attributes - Bulk Modifier ( from custom meta attributes to taxonomy attributes)
<?php
/**
* Plugin Name: WooPAM: Woo Product Attributes Modifier
* Description: Bulk update 'custom meta product attributes' to 'taxonomy product attributes' in WooCommerce. Supports the GET variables, like: woopam_mode=run&woopam_from_attribute_meta=colour&woopam_to_attribute_tax=pa_colour&woopam_keep_attribute_meta&woopam_posts_per_page=10&woopam_paged=0&woopam_post_type=product&woopam_post_status=any. WARNING: Backup DB first!!!
* Plugin Author: birgire
* Author URI: https://github.com/birgire
* Plugin URI: https://gist.github.com/birgire/0ed300ae4436fcaf508c
* Version: 1.0.0
* License: GPL2+
* Text Domain: woopam
@wordpressvn
wordpressvn / index.php
Created October 27, 2022 08:38 — forked from vielhuber/index.php
split get content before / after read more tag outside loop #php #wordpress
<?php
// with wordpress native functions
echo get_extended($p->post_content)['main'];
echo get_extended($p->post_content)['extended'];
// with own function (wordpress own function has problems with enabled p tags)
function wp_split_more($content, $type, $more_html = null)
{
$return = [
@wordpressvn
wordpressvn / dropdown-menu-dark-overlay-flatsome.php
Created September 15, 2021 13:05 — forked from Qwans/dropdown-menu-dark-overlay-flatsome.php
[Flatsome] Dark overlay on menu items with children
1. Add code below to your functions.php in your child theme.
add_action('wp_footer', 'qwans_add_darkness_dropdown');
function qwans_add_darkness_dropdown (){
echo '<div class="darkness"></div>';
};
2. Add CSS
@wordpressvn
wordpressvn / my_get_plugin_info.php
Created July 19, 2021 03:30 — forked from butlerblog/my_get_plugin_info.php
Utility to get plugin info
<?php // no need to use this line.
/**
* Utility to get information on installed plugins.
*
* Returns an array of all installed plugins and indicates which are
* plugin are active and which are not. Array is keyed by the plugin's
* folder/slug.php (which is how WP looks at them) and includes the
* name, version, and true/false whether it is active or not.
*
@wordpressvn
wordpressvn / smush-original-images.php
Created July 10, 2021 12:41 — forked from wpmudev-sls/smush-original-images.php
[Smush] - Original Images. Currently has option oly to delete them
<?php
/**
* Plugin Name: [Smush] - Original Images
* Plugin URI: https://premium.wpmudev.org/
* Description: Displays all original images so they can be deleted. Requires Smush
* Author: Panos Lyrakis @ WPMUDEV
* Author URI: https://premium.wpmudev.org/
* License: GPLv2 or later
*/
@wordpressvn
wordpressvn / add-gift-wrap-option-to-woocommerce-cart.php
Created July 10, 2021 12:41 — forked from damiencarbery/add-gift-wrap-option-to-woocommerce-cart.php
Add option for add-on item to WooCommerce cart - A simple way to allow customers add gift wrap or other small add-on to their order. https://www.damiencarbery.com/2020/06/add-option-for-add-on-item-to-woocommerce-cart/
<?php
/*
Plugin Name: Add option for add-on item to WooCommerce cart
Plugin URI: https://www.damiencarbery.com/2020/06/add-option-for-add-on-item-to-woocommerce-cart/
Description: A simple way to allow customers add gift wrap or other small add-on to their order.
Author: Damien Carbery
Version: 0.2
*/
@wordpressvn
wordpressvn / Wordpress snippets.php
Created July 10, 2021 12:41 — forked from AntonLitvin/Wordpress snippets.php
Разные полезные функции и фильтры
=====================================================================
Фильтр по acf полю
<select onchange="location=value">
<option value="" selected="selected">Выбрать район</option>
<option value="?district=1">Район 1</option>
<option value="?district=2">Район 2</option>
<option value="?district=3">Район 3</option>
</select>