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 April 28, 2023 08:38
[YITH] Change product-brands slug name
/**
* Title: [YITH] Change product-brands slug name
* Author: Mattias Ghodsian
* Description: Change product-brands slug name
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
* Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5
**/
function yith_brand_slug_rewrite() {
return 'varumarke';
}
@mattiasghodsian
mattiasghodsian / functions.php
Last active April 28, 2023 08:37
[Woocommerce] Add product attribute to menu
/**
* Title: [Woocommerce] Add product attribute to menu
* Author: Mattias Ghodsian
* Description: Add product attribute to menu
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
* Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5
**/
add_filter('woocommerce_attribute_show_in_nav_menus', 'wc_attr_in_menu', 1, 2);
function wc_attr_in_menu( $register, $name = '' ) {
if ( $name == 'pa_smakprofil' ) $register = true;
@mattiasghodsian
mattiasghodsian / functions.php
Last active April 28, 2023 08:37
[Wordpress] Append text before comment form
/**
* Title: Append text before comment form
* Author: Mattias Ghodsian
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
* Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5
**/
add_action('comment_form_before', 'text_before_comment_form');
function text_before_comment_form() {
echo '<h4>Hello world</h4>';
}
@mattiasghodsian
mattiasghodsian / addsite.sh
Last active April 28, 2023 08:37
Auto make site for nginx (localhost only)
#!/bin/bash
###
# Title: add site (experimental)
# Author: Mattias Ghodsian
# Description: Auto make site for nginx (run with sudo)
# Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
# Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5
###
@mattiasghodsian
mattiasghodsian / ratsit.php
Last active April 28, 2023 08:37
Ratsit API
<?php
/**
* Title: Ratsit
* Author: Mattias Ghodsian
* Docs: https://api.ratsit.se/swagger/ui/index.html#/
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
* Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5
**/
class RATSIT
@mattiasghodsian
mattiasghodsian / cmc.php
Last active April 28, 2023 08:37
Fetch crypto exchanges with coins they offer from coinmarketcap.com (Don't use for live sites, this is experimental and for practise)
/**
* Title: coinmarketcap exchanges
* Author: Mattias Ghodsian
* Description: Fetch Coin exchanges with coins they offer (Don't use for live sites, this is experimental and for practise)
* Site: https://coinmarketcap.com/exchanges/volume/24-hour/all/
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
* Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5
**/
function getExchangeData($exchanges, $coins){
$data = ['meta' => ['source' => 'coinmarketcap.com', 'datatype' => 'exchanges', 'interval' => '24h', 'version' => 'alpha (practise)', 'created' => '9/05/2018', 'developer' => 'Mattias Ghodsian'] ];
@mattiasghodsian
mattiasghodsian / functions.php
Last active April 28, 2023 08:37
Add YITH Brand to Schema on Product page
/**
* Title: Add YITH Brand to Schema on Product page
* Author: Mattias Ghodsian
* Description: This is for yith-woocommerce-brands-add-on-premium plugin
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
* Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5
**/
function yith_brand_schema() {
if ( is_product() ) {
@mattiasghodsian
mattiasghodsian / functions.php
Last active April 28, 2023 08:37
[Wordpress] Filter bad words in comments
/**
* Title: Filter bad words in comments
* Author: Mattias Ghodsian
* Description: Filter bad words in comments
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
* Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5
**/
function filter_text( $comment_text, $comment = null )
{
$words = ['grym', 'great', 'awesome', 'good'];
@mattiasghodsian
mattiasghodsian / functions.php
Last active April 28, 2023 08:37
Remove yoast bredcrumb ld+json
/**
* Title: Remove yoast bredcrumb ld+json
* Author: Mattias Ghodsian
* Description: This removes the schema (json+ld) from yoast
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
* Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5
**/
function remove_yoast_breadcrumb_json_ld($data)
{
if ( $data['@type'] == 'BreadcrumbList') {
@mattiasghodsian
mattiasghodsian / functions.php
Last active April 28, 2023 08:36
Custom Wordpress Dropdown
/**
* Title: Custom Wordpress Dropdown
* Author: Mattias Ghodsian
* Description: Custom wordpress dropdown for taxonomy terms
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
* Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5
*
*
* @param array $taxonomy