Skip to content

Instantly share code, notes, and snippets.

@vevgeniy85
vevgeniy85 / shopify-section-ab.liquid
Created October 24, 2022 15:35 — forked from evulse/shopify-section-ab.liquid
This needs to be installed in your theme as a section
{% javascript %}
function loadSection() {
var elArray = Array.prototype.slice.call(document.querySelectorAll(".shopify-section-ab"));
if (window.parent.ThemeEditor !== undefined) {
elArray.forEach(function(el) {
el.classList.remove("ssab-neither");
el.classList.add("ssab-editor");
});
} else {
var cookie = "";
@vevgeniy85
vevgeniy85 / related-articles.liquid
Created July 20, 2022 09:11 — forked from atikju/related-articles.liquid
Show related articles based on article tags - Shopify
@vevgeniy85
vevgeniy85 / delete_404_attachments.php
Created February 6, 2022 07:58 — forked from sabrina-zeidan/delete_404_attachments.php
Clean Media Library from broken images. Delete attachments which files no longer available and return 404 error [Wordpress]
function delete_404_attachments(){
$attachments = get_posts( array(
'post_type' => 'attachment',
'numberposts' => -1,
'fields' => 'ids'
));
if ($attachments) {
foreach ($attachments as $attachmentID){
$file_url = wp_get_attachment_url( $attachmentID);
$file_headers = @get_headers($file_url);
// import_json_appsscript.js
// https://gist.github.com/allenyllee/c764c86ed722417948fc256b7a5077c4
//
// Changelog:
// (Oct. 16 2019) tag: allenyllee-20191016
// 1. Fixed google script error: urlfetchapp - service invoked too many times https://stackoverflow.com/questions/10598179/google-apps-script-urlfetchapp-service-invoked-too-many-times
// (Jul. 16 2018) tag: allenyllee-20180716
// 1. Fixed the issue "If you try to query /arrayA[k]/arrayB[n]/arrayC[m]/.../member, you will always get /arrayA[k]/arrayB[k]/arrayC[k]/.../member."
// (Nov. 30 2017) tag: allenyllee-20171130
// 1. Add the ability to query array elements by using xpath like "/array[n]/member" where "n" is array index
@vevgeniy85
vevgeniy85 / Event Tracking - Web Tracking (analytics.js)
Last active August 4, 2021 15:41 — forked from adrianengine/new_gist_file
Event Tracking - Web Tracking (analytics.js), In this example, the addEventListener function is a utility to add event listeners across browsers. This function is used to add an event listener to the PDF download link to listen for the click event. When a click event occurs, the event is sent to Google Analytics.Source (https://developers.google…
var downloadLink = document.getElementById('button');
addListener(downloadLink, 'click', function() {
ga('send', 'event', 'button', 'click', 'nav-buttons');
});
/**
* Utility to wrap the different behaviors between W3C-compliant browsers
* and IE when adding event handlers.
*
@vevgeniy85
vevgeniy85 / functions.php
Created October 19, 2020 22:29 — forked from BFTrick/functions.php
Customize the sort by drop down in WooCommerce
<?php
function patricks_woocommerce_catalog_orderby( $orderby ) {
// Add "Sort by date: oldest to newest" to the menu
// We still need to add the functionality that actually does the sorting
$orderby['oldest_to_recent'] = __( 'Sort by date: oldest to newest', 'woocommerce' );
// Change the default "Sort by newness" to "Sort by date: newest to oldest"
$orderby["date"] = __('Sort by date: newest to oldest', 'woocommerce');
// Remove price & price-desc
@vevgeniy85
vevgeniy85 / products_with_category.sql
Created January 24, 2020 13:39 — forked from phlbnks/products_with_category.sql
Select Product name, SKU, price and category from WordPress / WooCommerce with MySQL query
SELECT
wp_posts.post_title AS Product,
wp_postmeta1.meta_value AS SKU,
wp_postmeta2.meta_value AS Price,
GROUP_CONCAT( wp_terms.name ORDER BY wp_terms.name SEPARATOR ', ' ) AS ProductCategories
FROM wp_posts
LEFT JOIN wp_postmeta wp_postmeta1
ON wp_postmeta1.post_id = wp_posts.ID
AND wp_postmeta1.meta_key = '_sku'
LEFT JOIN wp_postmeta wp_postmeta2
@vevgeniy85
vevgeniy85 / export-to-excel.php
Created January 15, 2020 15:17 — forked from riverus-dev/export-to-excel.php
Wordpress plugin to export custom post type data
<?php
/*
Plugin Name: Export To Excel
Description: Export de los Suscriptores
Author: Jorge Rivero
Version: 0.1
*/
//Add Export Submenu / Page
<?php
/*
* Plugin Name: WP REST API Demo
* Plugin URI: https://gist.github.com/wpscholar/693517420ca6c9e29e7719ef24e7e00f
* Description: A developer plugin designed for playing around with the WordPress REST API.
* Version: 1.0
* Author: Micah Wood
* Author URI: https://wpscholar.com
* License: GPL2
@vevgeniy85
vevgeniy85 / create-admin-user.php
Created January 15, 2020 14:12 — forked from wpscholar/create-admin-user.php
Create a new admin user in WordPress via code. Drop this file in the mu-plugins directory and update the variables, then load a page in WordPress to create the user. Remove the file when done.
<?php
add_action( 'init', function () {
$username = 'admin';
$password = 'password';
$email_address = 'webmaster@mydomain.com';
if ( ! username_exists( $username ) ) {
$user_id = wp_create_user( $username, $password, $email_address );