Skip to content

Instantly share code, notes, and snippets.

View kLOsk's full-sized avatar
:octocat:
back in black

Daniel Klose kLOsk

:octocat:
back in black
View GitHub Profile
<?php
//Remove CPT's
function dk_delete_post_type(){
unregister_post_type( 'beers' );
}
add_action('init','dk_delete_post_type');
//Custom Permalinks and Rewrites
function wpa_show_permalinks( $post_link, $post ){
if ( is_object( $post ) && $post->post_type == 'event' ){
@kLOsk
kLOsk / fridge.ino
Created June 18, 2017 00:54
Arduino Curing Fridge
//Libraries
#include <DHT.h>; //need for temp/hum sensor
//#include <Time.h> //need for timer
//#include <TimeLib.h> //need for timer
//#include <SPI.h>//not sure
#include <Wire.h>//not sure
#include "RTClib.h" //need for clock
#include <Adafruit_SSD1306.h> //need for display
@kLOsk
kLOsk / gist:2b0123c2fca5538eb3f6ab8856411301
Last active October 31, 2017 23:24
WP Post Views for WPEngine - Count Post Views in WordPress without plugin
<?php
if ( ! defined("POST_VIEWS_KEY") ) {
define("POST_VIEWS_KEY", "post_views_count");
}
// function to display number of posts.
function get_post_views( $post_id ){
@kLOsk
kLOsk / polylang_pro_synchronize_wc_product.php
Last active June 4, 2018 21:29
Copy and synchronice a WooCommerce product programmatically with Polylang from frontend
<?php
/**
* I had a hard time accessing the Polylang PLL_Admin methods from the frontend. Instantiating classes manually didnt work.
* Luckily the Polylang boss jumped in and provided this solution. This shold also be working with other Polylang methods
* that can normally only be executed from admin side.
*/
$pll = new PLL_Admin( PLL()->links_model );
$pll->add_filters();
$pll_pro = new Polylang_Pro();
$pll_pro->load_modules( $pll );
$args = array(
'post_type' => array( 'smart-tours' ),
'posts_per_page'=>-1,
'orderby' => 'rand',
'facetwp' => true
);
add_filter( 'facetwp_is_main_query', function( $is_main_query, $query ) {
if ( '' !== $query->get( 'facetwp' ) ) {
$is_main_query = (bool) $query->get( 'facetwp' );
}
return $is_main_query;
}, 10, 2 );
<?php
/*
* Test Redirect for Naver Search Engine
*/
function gogoes_redirect_naver() {
$user_agent = $_SERVER['HTTP_USER_AGENT'];
if(strpos( $user_agent, 'Yeti') !== false) {
wp_redirect( pll_home_url('kr'), 301 );
//header('Location: ' . pll_home_url('kr'), true, 301);
exit;
<?php
add_filter('pll_redirect_home', 'home_redirection', 10);
function home_redirection($redirect) {
//$user_agent = $_SERVER['HTTP_USER_AGENT'];
//if(strpos( $user_agent, 'Yeti') !== false) {
$redirect = 'http://gogoespana.test/kr/';
//}
return $redirect;
//return false;
@kLOsk
kLOsk / functions.php
Created November 6, 2018 05:34
wc vendors PLL rewrite fix test
function DK_pll_rewrite_basic() {
add_rewrite_rule('(en|de)/(dashboard)/(product)/?$', 'index.php?lang=$matches[1]&pagename=dashboard&object=product', 'top');
add_rewrite_rule('(en|de)/(dashboard)/(product)/(edit)/?$', 'index.php?lang=$matches[1]&pagename=dashboard&object=product&action=edit', 'top');
//add_rewrite_rule('(en|ja)/(product-category)/(.+?)/?$', 'index.php?post_type=product&product_cat=$matches[3]', 'top');
}
add_action('init', 'DK_pll_rewrite_basic', 10, 0);
<?php
/**
Plugin Name: WooCommerce Extended Coupon Features PRO Daily Extension
Description: Extends WooCommerce Extended Coupon Features by adding coupons that are only valid on certain days
Author: Daniel Klose
Version: 1.0
Author URI: http://www.daniel-klose.com/
*/
add_action( 'wjecf_init_plugins', 'setup_my_wjecf_example_plugin' );