Skip to content

Instantly share code, notes, and snippets.

View tivnet's full-sized avatar

Gregory Karpinsky tivnet

View GitHub Profile
@tivnet
tivnet / php7-debug-backtrace-change.php
Created May 19, 2016 03:45
Demonstration of debug_backtrace change in PHP 7.
<?php
/**
* Demonstration of debug_backtrace change in PHP 7.
*
* `call_user_func` and `call_user_func_array` do not appear as separate calls in the trace.
*
* @author Gregory Karpinsky (@tivnet)
*/
main();
@tivnet
tivnet / etc-monit-monitrc.d-redis
Last active May 31, 2022 12:29
Monitoring Redis with Monit : /etc/monit/monitrc.d/redis
check host redis.host with address 127.0.0.1
if failed port 6379 protocol redis then alert
check process redis-server with pidfile "/var/run/redis/redis-server.pid"
start program = "/etc/init.d/redis-server start"
stop program = "/etc/init.d/redis-server stop"
if failed host 127.0.0.1 port 6379 then restart
if 5 restarts within 5 cycles then timeout
@tivnet
tivnet / Xcel.html
Created October 18, 2015 05:06
Xcel.html
<li id="customize-control-wpglobus_xcel-setting-blog-cats" class="customize-control customize-control-text" style="display: block;">
<label>
<span class="customize-control-title">Exclude Blog Categories</span>
<input type="text" class="wpglobus-customize-control" value="" data-customize-setting-link="wpglobus_xcel-setting-blog-cats" id="wpglobus_xcel-setting-blog-cats">
</label>
</li><li id="customize-control-xcel-setting-blog-cats" class="customize-control customize-control-text" style="display: none;">
<label style="display: none;">
<span class="customize-control-title">Exclude Blog Categories</span>
<span class="description customize-control-description">Enter the ID's of the post categories you'd like to EXCLUDE from the Blog, enter only the ID's with a minus sign (-) before them, separated by a comma (,)<br>Eg: "-13, -17, -19"<br>If you enter the ID's without the minus then it'll show ONLY posts in those categories.</span>
<inpu
@tivnet
tivnet / makepot--extract--entry_from_call.php
Last active June 8, 2016 01:48
Makepot: Ignore all strings that are not from our textdomain. `node_modules/grunt-wp-i18n/vendor/wp-i18n-tools/extract.php`
<?php
// .../node_modules/grunt-wp-i18n/vendor/wp-i18n-tools/extract.php
public function entry_from_call( $call, $file_name ) {
/**
* Ignore all strings that are not from our textdomain
*/
if ( $call['args'][ count( $call['args'] ) - 1 ] !== 'my-text-domain' ) {
return null;
}
@tivnet
tivnet / g2s.php
Created July 3, 2015 11:16
Git to SVN for WordPress
#!/usr/local/bin/php -q
<?php
/**
* Git to SVN
* @author Gregory Karpinsky (@tivnet)
*/
/**
* Default values for $_SERVER, because we run as CLI
*/
@tivnet
tivnet / meta_box_cb-bug-demo.php
Last active August 29, 2015 14:08
meta_box_cb bug demo
<?php
/**
* Plugin Name: TIVWP Demo 28033
* Plugin URI: https://gist.github.com/tivnet/c99265e4884f7df5cb0f
* Description: Demonstrates WP bug <a href="https://core.trac.wordpress.org/ticket/28033">#28033</a>
* Version: 14.11.02
* Author: TIV.NET
* Author URI: http://www.tiv.net
* License: GPL2
* Copyright 2014 Gregory Karpinsky (tiv.net), All Rights Reserved
@tivnet
tivnet / SearchWP-patch-class.search.php
Created October 30, 2014 12:40
SearchWP - preserve posts_per_page and offset from original wp query
diff -rupN /tmp/searchwp/includes/class.search.php app/plugins/searchwp/includes/class.search.php
--- /tmp/searchwp/includes/class.search.php 2014-09-29 15:37:54.000000000 +0300
+++ app/plugins/searchwp/includes/class.search.php 2014-10-29 14:46:00.003012356 +0200
@@ -284,6 +284,13 @@ class SearchWPSearch {
$this->order = $args['order'];
$this->load_posts = is_bool( $args['load_posts'] ) ? $args['load_posts'] : true;
+ /** CHANGES BEGIN:
+ Check for offset argument, this allows more precise navigation */
+ if( isset( $args['offset'] ) && !empty( $args['offset'] ) ) {
@tivnet
tivnet / WooCommerce_product_IDs_by_stock_status_and_backorders.sql
Created August 26, 2014 00:19
SQL: WooCommerce product IDs by stock status and backorders
SELECT _stock, _stock_status, _backorders, GROUP_CONCAT( PID )
FROM (
SELECT
post_id AS PID,
meta_value AS _stock,
(
SELECT meta_value
FROM wp_postmeta
@tivnet
tivnet / woocommerce_fix_sorting_by_date.sql
Last active August 29, 2015 14:05
WooCommerce: SQL to fix sorting by date
--
-- When the product "post date" is incorrect
-- (for example, as a result of batch import-export)
-- this SQL will fake the date using the post_ID
--
-- @author Gregory Karpinsky, http://www.tiv.net/
-- @version 14.08.19
--
UPDATE wp_posts
@tivnet
tivnet / woocommerce_category_list.sql
Created May 29, 2014 03:22
WooCommerce category list SQL query
--
-- @author Gregory Karpinsky, http://www.tiv.net/
-- @version 14.05.28
--
SELECT
tp.name Cat,
t.name Subcat
FROM
wp_term_taxonomy tt,
wp_terms t,