Skip to content

Instantly share code, notes, and snippets.

View alewolf's full-sized avatar

Aleksandar alewolf

View GitHub Profile
@alewolf
alewolf / block-api-wp-org-requests.php
Last active September 26, 2024 10:11
Block outgoing requests to api.wordpress.org
<?php
add_filter('pre_http_request', 'block_blacklisted_domains', 10, 3);
function block_blacklisted_domains($preempt, $r, $url) {
$blacklisted_domains = array(
'api.wordpress.org',
);
foreach ($blacklisted_domains as $domain) {
RENAME TABLE
wp_actionscheduler_logs TO custom_prefix_actionscheduler_logs,
wp_actionscheduler_groups TO custom_prefix_actionscheduler_groups,
wp_actionscheduler_claims TO custom_prefix_actionscheduler_claims,
wp_actionscheduler_actions TO custom_prefix_actionscheduler_actions
<?php
/**
* If you want to fire the ViewItem event on variable products when
* no variation has been selected yet, then use the following code in
* your functions.php file.
*/
add_action('wp_footer', function () {
?>
<script>
<?php
/**
* Track ViewItem events in Facebook using the WooCommerce Pixel Manager
* Add this to functions.php
*/
add_action('wp_footer', function (){
?>
<script>
<?php
/**
* Track custom add-to-cart conversions using the WooCommerce Pixel Manager
*
* Add this to your functions.php file
*/
add_action('wp_footer', function () {
?>
@alewolf
alewolf / gads-id-for-wc-google-listing-ads.php
Last active May 19, 2023 07:57
Enable product ID output for woopt Pixel Manager Google Ads dynamic remarketing for the WooCommerce Google Listing and Ads plugin
<?php
// Place the following code into your functions.php file in your child theme
add_filter('wooptpm_product_ids', function ($product_ids, $product) {
$product_ids['gla'] = 'gla_' . $product->get_id();
return $product_ids;
}, 10, 2);
(function(){
try {
let observer = new MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
if (mutation.attributeName === "class") {
let attributeValue = jQuery(mutation.target).prop(mutation.attributeName);
if (attributeValue.includes('disabled')) {
jQuery('.fs-modal').find('.button-deactivate').removeClass('disabled');;
}
}
// First you'll need to load the gtag.js library
function load_library(){
echo '<script async src="https://www.googletagmanager.com/gtag/js?id=GA_UA_PROPERTY_ID"></script>';
}
// Then output the conversion tracking scripts
// The Google Ads conversion ID must include the "AW-" in front of the number
function (response)
@alewolf
alewolf / wooptpm-add-custom-dimensions-event-for-ga.php
Created August 3, 2021 09:32
create an event for Google Analytics custom dimensions in woopt WooCommerce Pixel Manager
<?
add_action('wp_head', function () {
?>
<script>
jQuery(document).on('wooptpmAddToCart', function (event, product) {
gtag('event', 'add_to_cart', {
"send_to" : wooptpmDataLayer.pixels.google.analytics.universal.property_id, // this is important to scope it to only GA UA and not send it to other properties
'ecomm_prodid': product.dyn_r_ids[wooptpmDataLayer.pixels.google.analytics.id_type], // you must make sure that the same ID type is being used for GA and Google Ads
'ecomm_pagetype': wooptpmDataLayer.shop.page_type,
@alewolf
alewolf / wooptpm-add-custom-dimensions-to-ga-ua.php
Last active August 3, 2021 09:17
add custom dimensions to Google Universal Analytics in woopt WooCommerce Pixel Manager
<?
add_filter('wooptpm_ga_ua_parameters', function ($analytics_parameters, $analytics_id){
$analytics_parameters['custom_map'] = [
'dimension1' => 'ecomm_prodid',
'dimension2' => 'ecomm_pagetype',
'dimension3' => 'ecomm_totalvalue',
];
return $analytics_parameters;