Skip to content

Instantly share code, notes, and snippets.

View sinebeef's full-sized avatar
💋
hnnnnggggggg

sinebeef sinebeef

💋
hnnnnggggggg
  • London
View GitHub Profile
'''
parsing CSV into a JSON file using SKU as primary key but also as SKU.
If price is 0 then it must be disabled by putting stock to 0 as well
If weight is 0 then it must also be put to stock 0 to avoid breaking
of the weights based shipping. this will process a json file which can
be used by wpallimport to update existing woocommerce products
@date 20190320
@url https://gist.github.com/sinebeef/fbc1b3232709368cd3558da103e54cd7
@sinebeef
sinebeef / robots.txt
Last active July 20, 2019 23:22
Wordpress ecommerce flavoured robots.txt blocking ? filters
# wordpress ecommerce flavoured robots.txt blocking ? filters
User-agent: *
Disallow: /*?*
Disallow: /blog/author/
Disallow: /comments/
Disallow: /login/
Disallow: /feed/
Disallow: /cart/
Disallow: /checkout/
Disallow: /wp-login.php
@sinebeef
sinebeef / wp-smtp-phpmailer.php
Created March 26, 2019 16:08
wp smtp hardcoded settings
/* @link https://codex.wordpress.org/Plugin_API/Action_Reference/phpmailer_init
*/
add_action( 'phpmailer_init', 'lol_phpmailer_example', 999 );
function lol_phpmailer_example( $phpmailer ) {
$phpmailer->isSMTP();
$phpmailer->Host = 'smtp.mail.com';
$phpmailer->SMTPAuth = true; // Force it to use Username and Password to authenticate
$phpmailer->Port = 465;
$phpmailer->Username = '[email protected]';
@sinebeef
sinebeef / js_csv_to_woo_variations.py
Last active April 1, 2019 19:46
Create woocommerce import for variable products from csv of variations
'''
CSV to JSON for Woocommerce Variation Products via wpallimport.
Woocommerce variable products need a parent product sku to attach to.
This script creates a pseudo parent from a clone of one of the children and
then assigns it a unique/modifed SKU and provides that modified SKU to the
children in the parent column/key.
As the source CSV is exported from a magento site there is a bit of parsing that
/* save to log file of choice
*/
function beef_save_log(){
ob_start();
echo "something";
$result = ob_get_clean();
$up_path = wp_upload_dir();
file_put_contents( $up_path['path'] . '/lol.txt', $result, FILE_APPEND );
}
@sinebeef
sinebeef / Contract Killer 3.md
Created April 7, 2019 15:10
The latest version of my ‘killer contract’ for web designers and developers

Contract Killer

The popular open-source contract for web professionals by Stuff & Nonsense

  • Originally published: 23rd December 2008
  • Revised date: March 15th 2016
  • Original post

@sinebeef
sinebeef / WP_Query.php
Created April 15, 2019 13:03 — forked from Dimasmagadan/WP_Query.php
#WordPress query with args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/query.php
*/
$args = array(
//////Author Parameters - Show posts associated with certain author.
@sinebeef
sinebeef / wp_pre_get_posts.php
Last active June 4, 2019 00:02
WP Modify pre_get_posts
/* Modify $query via pre_get_posts to change sorting
* of certain archive pages.
* @link https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts
*/
add_action( 'pre_get_posts', 'custom_query_vars' );
function custom_query_vars( $query ) {
if ( !is_admin() && $query->is_main_query() ) {
if ( is_product_category('cleats') ) {
$query->set( 'posts_per_page', '-1' );
@sinebeef
sinebeef / cf7-get-page-url-of-sender.php
Created June 8, 2019 13:03
Contact Form 7 GET slug/url hidden
//https://wordpress.stackexchange.com/questions/291855/how-to-get-current-url-in-contact-form-7
//You can use cf7 hidden field shortcodes + get parameters: https://contactform7.com/hidden-field/ https://contactform7.com/getting-default-values-from-the-context/
//In the mail form I use such shortcodes to get these slugs
[hidden utm_source default:get]
[hidden utm_medium default:get]
[hidden utm_campaign default:get]
[hidden utm_content default:get]
@sinebeef
sinebeef / jquery-cheat-sheet.js
Created June 12, 2019 16:51
jQuery Cheat Sheet
(function ($) {
$(document).ready(function () {
console.log("ready!");
$('.left').on("click", function (e) {
e.preventDefault();
console.log('moo');
});
});
})(jQuery);