Skip to content

Instantly share code, notes, and snippets.

@oterox
oterox / snnipets.php
Last active June 13, 2016 09:51
woocommerce snippets
<?php
add_filter('add_to_cart_redirect', 'themeprefix_add_to_cart_redirect');
function themeprefix_add_to_cart_redirect() {
global $woocommerce;
$checkout_url = $woocommerce->cart->get_checkout_url();
return $checkout_url;
}
//Add New Pay Button Text
@oterox
oterox / wp_bck.py
Last active December 14, 2015 10:18
simple python script for WP backups It generates 3 files: - sql dump - theme folder backup - wp-content folder backup
#!/usr/bin/python
import time
import os
username="db_username"
password="db_pass"
hostname="db_host"
filestamp=time.strftime('%Y%m%d-%H%M')
rootfolder="/var/www/www.pixellarylabs.com/public_html/clients/"
@oterox
oterox / px_helper.php
Last active December 14, 2015 04:39
Worpdress extra functions
<?php
/**
* PXHelper by Javier Otero
*
* GNU General Public License, version 2
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*/
// ---------------------------------------------------
@oterox
oterox / wp_bck.sh
Last active December 12, 2015 02:58
bash script to backup WP It generates 3 files: - sql dump - theme folder backup - wp-content folder backup
#!/bin/bash
echo $*
CURRENT_DATE=`date '+%Y%m%d-%Hh%M'`
WP_DATABASE=database_name
WP_FOLDER=wpfolder
WP_THEME=themefoldername
WP_CONTENT_PATH=/var/www/"$WP_FOLDER"/
WP_THEME_PATH=/var/www/"$WP_FOLDER"/wp-content/themes/
#Backup database
@oterox
oterox / px_wp_cpt.sublime-snippet
Created September 25, 2012 19:55
Sublime Text Custom Post Type Snippet
<snippet>
<content><![CDATA[
add_action( 'init', 'register_cpt_${1:test}' );
function register_cpt_${1:test}() {
\$labels = array(
'name' => _x( '${2:Tests}', '${1:test}' ),
'singular_name' => _x( '${3:Test}', '${1:test}' ),
@oterox
oterox / page-template.php
Created August 13, 2015 09:31
Add page template from plugin
class PageTemplater {
/**
* A Unique Identifier
*/
protected $plugin_slug;
/**
* A reference to an instance of this class.
*/
@oterox
oterox / query_results.php
Last active August 29, 2015 14:27
Sorting Query Results by Multiple Meta Keys
<?php
// Query Arguments
$args = array(
'post_type' => 'review',
'posts_per_page' => 10,
'paged' => get_query_var( 'paged', false ),
'meta_query' => array(
'relation' => 'AND',
'be_top_pick' => array(
'key' => 'be_top_pick',
@oterox
oterox / style.css
Created July 22, 2015 11:58
css columns
/* Column Classes
------------------------------------------------------------ */
.five-sixths,
.four-fifths,
.four-sixths,
.one-fifth,
.one-fourth,
.one-half,
.one-sixth,
@oterox
oterox / gist:03c928bca4a9961a24a5
Created March 8, 2015 08:00
mysql create database and user
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'password';
CREATE DATABASE demo;
GRANT ALL PRIVILEGES ON *.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
@oterox
oterox / gist:9b6cc85aa1a3c497074f
Last active August 29, 2015 14:16
Mysql backup all databases to single files
#!/bin/bash
WP_DBUSER=root
WP_DBPASS=password
BCK_FILE_DB=/path/to/backups/
DBS=`mysql -u$WP_DBUSER -h localhost -p$WP_DBPASS -Bse 'show databases'`
for db in $DBS
do
echo 'database:' $db
mysqldump --add-drop-table -h localhost -u $WP_DBUSER -p $db --password=$WP_DBPASS | gzip > $BCK_FILE_DB$db.tar.gz