Skip to content

Instantly share code, notes, and snippets.

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

Auke Jongbloed Auke1810

🏠
Working from home
View GitHub Profile
@Auke1810
Auke1810 / convert-attribute-to-uppercase.php
Last active August 3, 2018 11:26
Convert Attribute to Uppercase
<?php
/**
* Alter Product feed item
* Uppercase a source value (attribute_pa_cup) and combine with an other source value in the size attribute
*/
function alter_feed_item( $attributes, $feed_id, $product_id ) {
// get values
$attribute_pa_band = $attributes['custom_label_0']; //add the attribute_pa_band to attribute "custom_label_0"
@Auke1810
Auke1810 / yoast-seo-aanpassingen-functions.php
Last active September 1, 2018 07:20
Custom aanpassingen aan yoast seo meta robot tag en canonical tag tbv technische optimalisatie van wordpress woocommerce webshop
################# SEO Aanpassingen ###########################################
# https://gist.github.com/Auke1810/9939b52131bdb2af819143798aba60f2
##############################################################################
/**
* add_noindex_tags
* meta robots tag vullen met de juiste instelling per pagina type
* Gepagineerde pagina’s (zonder parameters) moeten index, follow zijn.
* Gepagineerde pagina’s met parameters mogen een noindex, nofollow
*/
@Auke1810
Auke1810 / admin-functions.php
Last active September 1, 2018 07:20
shelflife/functions/admin-funcitons.php aanpassingen aan de file om de breadcrumbs microdata mee te geven voor betere indexering in Google.
<?php
// File Security Check
if ( ! defined( 'ABSPATH' ) ) exit;
?>
<?php
/*-----------------------------------------------------------------------------------
TABLE OF CONTENTS
- woo_image - Get Image from custom field
@Auke1810
Auke1810 / buttons_fullwidth.php
Last active September 1, 2018 07:28
Enfold full width button with event tracking
<?php
/**
* Button
* Displays a button that links to any url of your choice
* Gives a extra field in settings where you can give a Google Events label (line 89).
* When the button is clicked you will find a Event category UX with Action click and the label you have provided.
*/
if ( !class_exists( 'avia_sc_button_full' ) )
{
@Auke1810
Auke1810 / header.php
Last active January 16, 2019 09:18
Easily add the correct structured data using JSON-LD Google Merchant, this includes the missing microdata for condition.
<?php
// Locate the file header.php in your theme
// Before editing header.php, always make a backup so that you can roll back if something goes wrong.
// At the bottom of the header, simple add the code below
// Verify that you have done it correctly by checking the page with Google’s Structured Data Testing Tool
// https://search.google.com/structured-data/testing-tool
if (isset($product)){
$meta = get_post_meta(get_the_ID());
$_product = new WC_Product(get_the_ID());
if ($_product->regular_price!=NULL){
@Auke1810
Auke1810 / gist:202a0a96614f5ae36625516ccd4a0ffc
Created February 13, 2019 22:29
The wppfm_cdata_keys() function makes it possible to add attributes to be included in CDATA bracket.
function expand_cdata_attributes( $cdata_attributes ) {
// price and availability attributes are added to the list of attributes that are included in a CDATA bracket
array_push( $cdata_attributes, 'price', 'availability' );
return $cdata_attributes;
}
add_filter( 'wppfm_cdata_keys', 'expand_cdata_attributes' );
@Auke1810
Auke1810 / gist:827256dfbea142fbed119b892f463d10
Created February 14, 2019 15:14
Remove multiple characters from feed
/**
* Alter Product feed item
* remove multiple characters from attribute
*/
function alter_feed_description_attribute( $attributes, $feed_id, $product_id ) {
global $product;
// Remove multiple characters from attribute
$remove = [",", ":", ";"];
$attributes['description'] = str_replace($remove, '', $attributes['description']);
@Auke1810
Auke1810 / Alter feed items
Last active October 2, 2019 19:23
Example how to use the wppfm_feed_item_value filter for woocommerce product feed manager
<?php
function alter_feed_item( $attributes, $feed_id, $product_id ) {
// The $attributes variable is an array that contains all the product data that goes into the feed. Each item
// can be accessed by it's feed key. So if in the feed file an item has a key like 'description', you
// can access that specific item by $attributes['description'].
// The $feed_id (string) makes it possible to only edit a specific feed. You can find the id of a feed in the
// url of the Feed Editor, right after id=.
// The $product_id (string) makes it possible to select a specific product id that you want to filter.
@Auke1810
Auke1810 / use_original_description.php
Last active April 6, 2020 08:19
use the original description without stripping away all the line breaks and paragraph tags from the description field.
// use the original description without stripping away all the line breaks and paragraph tags from the description field.
function use_original_description( $data, $feed_id, $product_id ) {
// Only use the original description in the feed with the given ID (in this case 2)
// remove if you want this for all feeds.
if($feed_id == 2 ){
// Get the product.
$wc_product = wc_get_product( $product_id );
@Auke1810
Auke1810 / wppfm_xml_element_attribute
Last active June 10, 2020 11:15
Filternaam: wppfm_xml_element_attribute Drie parameters: attribute_value: dit is de standaard waarde die dus gewijzigd kan worden. Is standaard een empty string. xml_key: dit is de naam van het xml element, dus deze parameter kan worden gebruikt om het gewenste xml element te vinden xml_value: de waarde van het xml element. Dus om een attribute …
Function add_attribute_to_xml_tag( $attribute_value, $xml_key, $xml_value ) {
if ( 'bottles' === $xml_key ) {
return 'size=”750 ml”';
} else {
return $attribute_value;
}
}
add_filter( 'wppfm_xml_element_attribute', 'add_attribute_to_xml_tag', 10, 3 );