Skip to content

Instantly share code, notes, and snippets.

View rolandinsh's full-sized avatar
🧔
Remote developer (LEMP, Node.js, Neo4j [graph])

Rolands rolandinsh

🧔
Remote developer (LEMP, Node.js, Neo4j [graph])
View GitHub Profile
<?php
if ( ! function_exists( 'ucc_nav_menu_css_class' ) ) {
function ucc_nav_menu_css_class( $classes, $item, $args ) {
$class = sanitize_title( $item->title );
$classes[] = 'menu-item-' . $class;
return $classes;
} }
add_filter( 'nav_menu_css_class', 'ucc_nav_menu_css_class', 10, 3 );
<?php
/*
Better browser detection
with language_attributes() filter in WordPress
http://simplemediacode.info/?p=1006
*/
add_filter('language_attributes','smc_language_attributes');
function smc_language_attributes($content){
global $is_IE;
$browser = $_SERVER['HTTP_USER_AGENT'];
@rolandinsh
rolandinsh / gist:5101022
Created March 6, 2013 17:10
Set WooCommerce Virtual Order Status to Complete After Payment
<?php
add_filter( 'woocommerce_payment_complete_order_status', 'virtual_order_payment_complete_order_status', 10, 2 );
// vai http://www.foxrunsoftware.net/articles/wordpress/how-to-set-woocommerce-virtual-order-status-to-complete-after-payment/
function virtual_order_payment_complete_order_status( $order_status, $order_id ) {
$order = new WC_Order( $order_id );
if ( $order_status == 'processing' &&
( $order->status == 'on-hold' || $order->status == 'pending' || $order->status == 'failed' ) ) {
$virtual_order = true;
@rolandinsh
rolandinsh / gist:5143047
Last active September 8, 2022 15:19
Codeigniter file upload permissions (CHMOD)
<?php
$config['upload_path'] = './uploads/'; // upload path
/* OR any other form, e.g.:
$config['upload_path'] = $_SERVER["DOCUMENT_ROOT"].'/uploads/'; // upload path
$config['upload_path'] = __DIR__.'/uploads/'; // upload path
*/
$config['allowed_types'] = 'zip'; // array or string of file extensions
$config['max_size'] = '100'; // max file size
$this->load->library('upload', $config); // do the job
$zdata = ['upload_data' => $this->upload->data()]; // get data
@rolandinsh
rolandinsh / gist:5186719
Created March 18, 2013 12:04
WordPress "premium" mistakes; Things I "like" to see in WordPress themes
<?php
// Developer has no idea about filters and/or action hooks
?>
<body <?php body_class(roots_body_class()); ?>>
<!-- will upaged -->
@rolandinsh
rolandinsh / gist:5203955
Last active December 15, 2015 04:49
Magic quotes in form for Codeigniter
<?php
$descval = html_entity_decode($task->desc, ENT_QUOTES, 'UTF-8');
// then in form input (in my case textarea):
form_textarea(array(
'name' => 'desc',
'id' => 'desc',
'value' => set_value('desc', $descval),
'rows' => 10,
'cols' => 40,
// other optional attributes
@rolandinsh
rolandinsh / gist:5314706
Last active December 15, 2015 19:58
mass delete custom post types
<?php
// just put in Your footer.php and refresh some times brower.
if(isset($_GET) && $_GET['d41d8cd98f00b']=='8ecf8427e'){
$smc_post_type = 'product'; // $string change to Your own
$smc_posts_per_page = 1000; // (int) can be higer
$mycustomposts = get_posts(
array(
'post_type' => $smc_post_type,
'posts_per_page' => $smc_posts_per_page
)
via http://wordpress.stackexchange.com/questions/2623/include-custom-taxonomy-term-in-search/5404#5404
function atom_search_where($where){
global $wpdb;
if ( is_search() )
$where .= "OR (t.name LIKE '%".get_search_query() . "%' AND {$wpdb->posts} . post_status = 'publish')";
return $where;
}
@rolandinsh
rolandinsh / gist:5420566
Last active December 16, 2015 10:29
SMC_SearcMore custom taxonomy terms
<?php
// based on http://xh.lv/54047577
new SMC_SearchMore;
class SMC_SearchMore{
public function __construct(){
add_filter('posts_where',array( 'SMC_SearchMore', 'search_where' ));
add_filter('posts_join', array( 'SMC_SearchMore', 'search_join' ));
add_filter('posts_groupby', array( 'SMC_SearchMore', 'search_groupby' ));
}
function search_where($where){
@rolandinsh
rolandinsh / gist:5482149
Last active April 16, 2017 14:27
Autortiesības no rolandinsh.lv
<a href="https://umbrovskis.lv/" title="Rolands Umbrovskis">Rolands Umbrovskis</a>
(raksts <a href="https://rolandinsh.lv" title="`rolandinsh`">rolandinsh.lv</a>)
<a href="https://umbrovskis.lv/" title="Rolands Umbrovskis">Rolanda Umbrovska</a>
raksts <a href="https://rolandinsh.lv/blog/2008/11/13/celojums-uz-hanzas-pilsetu-bremeni/"
title="`rolandinsh`: Ceļojums uz Hanzas pilsētu - Brēmeni">Ceļojums uz Hanzas pilsētu - Brēmeni</a>