Skip to content

Instantly share code, notes, and snippets.

View koen12344's full-sized avatar

Koen koen12344

View GitHub Profile
@koen12344
koen12344 / snippet_wp_download_manager_tags.php
Created April 28, 2021 13:26
Adds a multitude of data variables from the WP Download Manager plugin to the Post to Google My Business plugin
<?php
/*
This code snippet adds various info about downloads from the WP Download Manager plugin to Post to Google My Business
%wpdm_access%
%wpdm_download_count%
%wpdm_view_count%
%wpdm_version%
%wpdm_link_label%
<?php
/**
Function to change the order of the save_post execution. Change the $priority value to change the priority
lower numbers mean earlier execution.
**/
function pgmb_change_autopost_priority(){
<?php
function pgmb_gf_post_created($post_id, $feed, $entry, $form){
global $post_to_google_my_business_plugin;
$post_type = 'your_post_type';
// -- Do not edit after this
//If this is a different post type, abort
@koen12344
koen12344 / wp-increase-timeout.php
Last active October 5, 2021 12:01 — forked from sudar/wp-increase-timeout.php
Increase the curl timeout in WordPress
<?php
//Copied from http://fatlabmusic.com/blog/2009/08/12/how-to-fix-wp-http-error-name-lookup-timed-out/
//adjustments to wp-includes/http.php timeout values to workaround slow server responses
add_filter('http_request_args', 'pgmb_http_request_args', 100, 1);
function pgmb_http_request_args($r) //called on line 237
{
$r['timeout'] = 15;
return $r;
}
@koen12344
koen12344 / pgmb_rank_math_seo.php
Created November 29, 2021 11:08
Rankmath description variable in Post to Google My Business plugin
<?php
class PGMBRankMathSEOVariables implements \PGMB\Placeholders\VariableInterface {
private $parent_id;
public function __construct($parent_id) {
$this->parent_id = $parent_id;
}
<?php
if(interface_exists('\PGMB\Placeholders\VariableInterface')){
class PGMBYoastSEOVariables implements \PGMB\Placeholders\VariableInterface {
private $parent_id;
public function __construct($parent_id) {
$this->parent_id = $parent_id;
}
@koen12344
koen12344 / snippet_motors_car_data.php
Last active March 3, 2022 08:55
Motors WordPress plugin add car data to Post to Google My Business plugin
<?php
if(interface_exists('\PGMB\Placeholders\VariableInterface')){
class PGMB_Motors_Variables implements \PGMB\Placeholders\VariableInterface {
private $listing_id;
public function __construct($listing_id){
$this->listing_id = $listing_id;
}
/**
<?php
/**
Snippet to create GMB posts from the Advanced Post Creation plugin of Gravity Forms
**/
function pgmb_gf_create_post_advancedpostcreation($post_id, $feed, $entry, $form){
if(!class_exists('\PGMB\PostTypes\SubPost') || !class_exists('\PGMB\FormFields') || !class_exists('\PGMB\Vendor\WeDevsSettingsAPI')){
<?php
function pgmb_add_acf_fields($variables, $parent_post_id){
//Check if the ACF get_fields function is actually available
if(!function_exists('get_fields')){ return $variables; }
$fields = get_fields($parent_post_id);
if($fields){
foreach($fields as $name => $value){
$variables["%acf_{$name}%"] = $value;
@koen12344
koen12344 / pgmb_content_img.php
Created May 17, 2022 12:55
Fetch image from html content
<?php
function pgmb_insert_content_img($localPost, $post_id, $is_autopost, $location){
if(
!class_exists('DOMDocument') ||
!class_exists('\PGMB\Google\MediaItem')
){ return $localPost; }
$form_fields = get_post_meta($post_id, 'mbp_form_fields', true);