Skip to content

Instantly share code, notes, and snippets.

View pietromalerba's full-sized avatar

Pietro Malerba pietromalerba

  • M3
  • Civitanova Marche (MC) - Italy
View GitHub Profile
@Zenger
Zenger / wp_insert_post.php
Created November 11, 2013 11:07
wp_insert_post and WPML
<?php
global $wpdb;
// Insert the original post
$original = wp_insert_post($array, true);
// Insert the translated post
$translated = wp_insert_post($array, true);
// Make some updates to both translations
@pmgarman
pmgarman / delete.sql
Created August 1, 2013 22:35
How to find and delete orphaned product variations from WooCommerce sites.
DELETE o FROM `wp_posts` o
LEFT OUTER JOIN `wp_posts` r
ON o.post_parent = r.ID
WHERE r.id IS null AND o.post_type = 'product_variation'
@RyanBrackett
RyanBrackett / jQuery.Responsive.Classes
Last active November 5, 2019 14:16
How About This...
/*
*
* Originally inspired by: http://designedbythomas.co.uk/blog/how-detect-width-web-browser-using-jquery
*
* Original source by https://gist.github.com/highrockmedia/3710930
*
* My contribution: I re-wrote some code it to fire as one function, so you're only editing values in one place.
*
*/
@ludo237
ludo237 / .htaccess
Last active December 11, 2024 14:30
The ultimate .htaccess file. Please feel free to fork it, edit it and let me know what do you think about it.
# Apache configuration file
# httpd.apache.org/docs/2.2/mod/quickreference.html
# Note .htaccess files are an overhead, this logic should be in your Apache
# config if possible: httpd.apache.org/docs/2.2/howto/htaccess.html
# Techniques in here adapted from all over, including:
# Kroc Camen: camendesign.com/.htaccess
# perishablepress.com/press/2006/01/10/stupid-htaccess-tricks/
# Sample .htaccess file of CMS MODx: modxcms.com
# This is the free sample of .htaccess from 6GO s.r.l.
# @author Claudio Ludovico Panetta (@Ludo237)
/* Media queries used on blog.staydecent.ca by Adrian Unger
check my full source at:
http://blog.staydecent.ca/static/css/style-0.1.6.css */
@media only screen and (min-width:768px) and (max-width:1269px) {
/* In my particular design, I used a fluid grid limited to a
max-width of 1140px, while (if there is enough room)
pushing the menu outside of layout, requiring a total
limit of at least 1270px.
So, this first query applies to any screen-width less
@pietromalerba
pietromalerba / app.js
Created March 28, 2013 21:54 — forked from dasher/app.js
Titanium.UI.setBackgroundColor('#000');
// Create a window
var win = Titanium.UI.createWindow({
title:'Web Test',
backgroundColor:'#fff'
});
// and now a webView
var webview1 = Titanium.UI.createWebView({url:'somePage.html'});
@acarabott
acarabott / gist:4635408
Created January 25, 2013 15:47
Wordpress - Add default menu_order to custom post type, optional terms
<?php
// Add to functions.php
// Make sure your custom post type has 'page-attributes' in its supports array
// Adjust the 'typeN's to your custom post types
// the first type
add_filter( 'wp_insert_post_data', 'set_menu_order', 10, 2 );
function set_menu_order( $data, $postarr ) {
global $post;
$pt = $data['post_type'];
@simonlk
simonlk / Woocommerce - show empty categories
Created October 21, 2012 06:33
Show empty categories within Woocommerce. Paste this in to your theme's functions file. It's just a copy and paste of a function within woocommerce-template.php and changing value of hide_empty to 0
// Paste this in to your theme's functions file
// Redefine sub category display to output empty categories
function woocommerce_product_subcategories( $args = array() ) {
global $woocommerce, $wp_query, $_chosen_attributes;
$defaults = array(
'before' => '',
'after' => '',
'force_display' => false
);
@Synchro
Synchro / gist:3749394
Created September 19, 2012 12:31
PHP script to report and/or extract sections from apache and icecast log files by date ranges
#!/usr/bin/env php
<?php
/**
* Extract a section of an apache or icecast log file between two dates
* Assumes that log lines are in chronological order
* Start and end dates can be in any format that strtotime can handle
* Reads from stdin, outputs to stdout, stats to stderr
* @author Marcus Bointon <[email protected]>
* @link https://gist.github.com/3749394
* Example usage. Report the range of dates in a log file
@MrMaz
MrMaz / ab-modal.php
Created September 18, 2012 13:50
WordPress Admin Bar: Modal Window Link
<?php
/**
* Setup admin bar item which opens URL in a thickbox window
*
* @param WP_Admin_Bar $wp_admin_bar
*/
function admin_bar_menu_modal_window( $wp_admin_bar )
{
// add "tools" node