Created
April 3, 2021 12:38
-
-
Save passatgt/334e49eea963f943d1a641d4c9b7de30 to your computer and use it in GitHub Desktop.
jQuery way to add custom storage management links in WooCommerce dashboard
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Theres is a guide here to do this properly: https://developer.woocommerce.com/2021/03/17/adding-your-own-store-management-links/ | |
//Since my extension is not a javascript project, it was easier just to insert the link without the need to import the additional wordpress libraries to my project | |
if(window.location.search.indexOf('page=wc-admin') > -1) { | |
var waitForEl = function(selector, callback) { | |
if (!jQuery(selector).size()) { | |
setTimeout(function() { | |
window.requestAnimationFrame(function(){ waitForEl(selector, callback) }); | |
}, 100); | |
}else { | |
callback(); | |
} | |
}; | |
waitForEl('.woocommerce-quick-links__category', function() { | |
var sampleLink = $('.woocommerce-quick-links__item').last(); | |
var category = sampleLink.parent(); | |
var newLink = sampleLink.clone(); | |
newLink.find('div').text('custom title'); | |
newLink.find('a').attr('href', 'some url'); | |
newLink.find('svg').html('<path d="M18.3165537,3 ...."></path>'); | |
category.append(newLink); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment