Skip to content

Instantly share code, notes, and snippets.

View koen12344's full-sized avatar

Koen koen12344

View GitHub Profile
<?php
function pgmb_raw_content_variable($variables, $parent_post_id){
$post = get_post($parent_post_id);
$text = wpautop($post->post_content); //Add paragraph tags
//$text = preg_replace("~(?:\[/?)[^\]]+/?\]~s", '', $text); //Strip shortcodes
$text = do_shortcode($text);
$parse_html = new \PGMB\Vendor\Html2Text\Html2Text(
$text,
array(
<?php
function pgmb_do_something_with_api() {
global $post_to_google_my_business;
if(!$post_to_google_my_business->is_loaded()){
return;
}
$container = $post_to_google_my_business->get_container();
@koen12344
koen12344 / pgmb_add_custom_taxonomy.php
Created January 31, 2024 11:10
Add a custom taxonomy to the Post to Google My Business plugin
<?php
/*
* Add a custom taxonomy variable to the Post to Google My Business plugin
*/
function pgmb_add_custom_taxonomy($variables, $parent_post_id){
//Replace name_of_the_taxonomy with the name of your taxonomy
$terms = get_the_terms( $parent_post_id, 'name_of_the_taxonomy' );
if($terms && !is_wp_error($terms) && !empty($terms)){
@koen12344
koen12344 / psfg_clear_image_references.php
Created January 30, 2024 10:04
Clear references to uploaded images in the Product Sync for GBP
<?php
/*
* Clears Product Sync for GPB image references on Google and forces re-upload
*
* Copy snippet into the Code Snippets plugin (https://wordpress.org/plugins/code-snippets/) and set it to only run once, then execute it
*
*/
function psfg_clear_all_image_references(){
$args = [
'post_type' => 'product',
<?php
// Ensure you're in a WordPress context before executing this
// Instantiate the WP_Http class
$http = new WP_Http();
// Define the URL
$url = 'https://eoizizbuz0eynh6.m.pipedream.net';
@koen12344
koen12344 / build-plugin.yml
Created February 6, 2023 10:54
Github action to package & publish WP plugin to Freemius
name: Build plugin
on:
push:
if: startsWith(github.ref, 'refs/tags/v')
branches:
- main
- beta
- pending
jobs:
create-release:
wc_product_price: %wc_product_price%
wc_product_regular_price: %wc_product_regular_price%
wc_product_sale_price: %wc_product_sale_price%
wc_product_price_including_tax: %wc_product_price_including_tax%
wc_currency_symbol: %wc_currency_symbol% (do not use this in the price field!)
wc_variation_min_current_price: %wc_variation_min_current_price%
wc_variation_max_current_price: %wc_variation_max_current_price%
wc_variation_min_regular_price: %wc_variation_min_regular_price%
wc_variation_max_regular_price: %wc_variation_max_regular_price%
wc_variation_min_sale_price: %wc_variation_min_sale_price%
<?php
function pgmb_create_import_autopost( $post_id, $xml_node, $is_update ) {
global $post_to_google_my_business;
if(!$post_to_google_my_business->is_loaded()){
return;
}
$autopost_factory = $post_to_google_my_business->get_autopost_factory();
<?php
function pgmb_publish_all_products(){
if(get_option('pgmb_products_synced')){
return;
}
global $post_to_google_my_business;
if(!$post_to_google_my_business->is_loaded()){
return;
}
@koen12344
koen12344 / pgmb_add_yoast_description.php
Created October 18, 2022 11:24
Add yoast seo description to post to GMB plugin
<?php
function pgmb_add_yoast_description($variables, $parent_post_id){
if(!function_exists('YoastSEO')){ return $variables; }
$description = YoastSEO()->meta->for_post( $parent_post_id )->description;
$variables['%yoast_description%'] = $description;
return $variables;
}
add_filter( 'mbp_placeholder_variables', 'pgmb_add_yoast_description', 10, 2 );