Skip to content

Instantly share code, notes, and snippets.

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

mattiasghodsian

🏠
Working from home
View GitHub Profile
@mattiasghodsian
mattiasghodsian / functions.php
Last active May 23, 2024 21:30
[Wordpress] Remove Media Add new button from admin panel
/**
* Title: Wordpress - Remove Media Add new button
* Author: Mattias Ghodsian
* Description: Remove Media add new button from admin panel
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
* Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5
*/
function remove_submenus() {
global $submenu;
@mattiasghodsian
mattiasghodsian / functions.php
Last active April 28, 2023 08:36
[Wordpress] Set tags for custom post type
/**
* Title: Set tags for custom post type
* Author: Mattias Ghodsian
* Description: Set tags for custom post type
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
* Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5
*/
function cpt_tags( $query ) {
if ( $query->is_tag() && $query->is_main_query() ) {
$query->set( 'post_type', array( 'post', 'movies', 'test', 'world' ) );
@mattiasghodsian
mattiasghodsian / index.html
Created November 10, 2018 11:25
[CSS] Blinking corners
<a href="#">buy now</a>
@mattiasghodsian
mattiasghodsian / functions.php
Last active April 28, 2023 08:36
[Wordpress] Modify/Replace handler source
/**
* Title: Wordpress - Modify/Replace handler source
* Author: Mattias Ghodsian
* Description: This script was writen to solve broken plugin asset urls (.js/.css) with Bedrock/Trellis as environment
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
* Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5
*/
add_filter( 'script_loader_src', 'wp_plugin_assets_path_fix', 10, 2 );
add_filter( 'style_loader_src', 'wp_plugin_assets_path_fix', 10, 2 );
function wp_plugin_assets_path_fix( $src, $handle )
@mattiasghodsian
mattiasghodsian / index.php
Last active April 28, 2023 08:36
[PHP] List any users public gists
/**
* Title: Get gists
* Author: Mattias Ghodsian
* Description: List any users public gists
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
* Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5
*/
$profile_url = "https://api.github.com/users/mattiasghodsian/gists";
$options = array('http' => array('user_agent'=> $_SERVER['HTTP_USER_AGENT']));
@mattiasghodsian
mattiasghodsian / functions.php
Last active April 28, 2023 08:36
[Woocommerce] Add OnSale filter
/**
* Title: [Woocommerce] Add OnSale filter
* Author: Mattias Ghodsian
* Description: Add onsale option to front-end users
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
* Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5
*/
add_filter( 'woocommerce_get_catalog_ordering_args', 'wcs_get_catalog_ordering_args' );
function wcs_get_catalog_ordering_args( $args ) {
@mattiasghodsian
mattiasghodsian / functions.php
Last active October 10, 2024 22:10
[Woocommerce] Product Select2 input field
/**
* Title: [Woocommerce] Product Select2 input field
* Author: Mattias Ghodsian
* Description: Let's users search products in wp-admin / Woocommerce Product data
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
* Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5
*/
function woocommerce_wp_product_select2( $field ) {
global $thepostid, $post, $woocommerce;
$thepostid = empty( $thepostid ) ? $post->ID : $thepostid;
@mattiasghodsian
mattiasghodsian / functions.php
Last active April 28, 2023 08:35
[Woocommerce] Custom user column & searchable meta
/**
* Title: [Woocommerce] Custom user column & searchable meta
* Author: Mattias Ghodsian
* Description: Add new column with meta data & searchable in users.php
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
* Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5
*/
// Create user column
add_filter( 'manage_users_columns', 'new_modify_user_table' );
@mattiasghodsian
mattiasghodsian / functions.php
Last active April 28, 2023 08:35
Image shortcode for ACF
/**
* Title: Get image from ACF Plugin (return value most image ID)
* Author: Mattias Ghodsian
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
* Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5
* -----
* @param array $params
* @return string
*/
function acfImage( $params = [] )
@mattiasghodsian
mattiasghodsian / wsl.conf
Last active July 2, 2019 22:36
Automatically Configuring Windows Subsystem for Linux
# Place wsl.conf in /etc
# Restart LxssManager by executing command Restart-Service LxssManager in PowerShell as admin
# For more options read: https://devblogs.microsoft.com/commandline/automatically-configuring-wsl/
[automount]
enabled = true
root = /mnt/
options = "metadata,umask=22,fmask=11"
mountFsTab = false