Skip to content

Instantly share code, notes, and snippets.

View kafkadev's full-sized avatar
🏠
Working from home

Gokhan Celik kafkadev

🏠
Working from home
View GitHub Profile
<?php
namespace App\Modules\Admin\Middleware;
// First copy this file into your middleware directoy
use Closure;
class CheckRole {
/**
<?php namespace App\Modules;
class ServiceProvider extends \Illuminate\Support\ServiceProvider
{
public function boot()
{
$modules = config("module.modules");
while (list(,$module) = each($modules)) {
if(file_exists(__DIR__.'/'.$module.'/routes.php')) {
include __DIR__.'/'.$module.'/routes.php';
@kafkadev
kafkadev / query-post-type-with-meta.sql
Created January 17, 2018 14:53 — forked from jo-snips/query-post-type-with-meta.sql
Get posts of a certain post type only if a certain meta field is not blank and split names returned in rows into new columns.
SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(wp_posts.post_title, ' ', 1), ' ', -1) as memberfirst,
SUBSTRING_INDEX(SUBSTRING_INDEX(wp_posts.post_title, ' ', 2), ' ', -1) as memberlast,
wp_postmeta.meta_value
FROM wp_posts, wp_postmeta
WHERE wp_posts.ID = wp_postmeta.post_id
AND wp_posts.post_type = 'member'
AND wp_posts.post_status = 'publish'
AND wp_postmeta.meta_key = 'email'
AND wp_postmeta.meta_value != ''
ORDER BY wp_posts.post_date DESC
@kafkadev
kafkadev / Main.php
Created January 17, 2018 14:52 — forked from blakek/Main.php
quick 'n dirty script to return big (2x), static images from Google Maps
<?php
/* file: wp-content/plugins/the-events-calendar/src/Tribe/Main.php */
/**
* Main Tribe Events Calendar class.
*/
// Don't load directly
if ( ! defined( 'ABSPATH' ) ) {
die( '-1' );
}
@kafkadev
kafkadev / woo-price-filter-widget-fix.php
Created January 17, 2018 14:47 — forked from yawalkar/woo-price-filter-widget-fix.php
Fixes WooCommerce price filter widget max price issue
// Override the woocommerce default filter for getting max price for filter widget.
add_filter( 'woocommerce_price_filter_widget_max_amount', 'theme_woocommerce_price_filter_widget_max_amount', 10, 2 );
/**
* Fix max_price issue in price filter widget.
*
* @param int $max_price The price filter form max_price.
* @return int Max price for the filter.
*/
function theme_woocommerce_price_filter_widget_max_amount( $max_price ) {
@kafkadev
kafkadev / MySQL-WordPressActivePlugins.sql
Created January 12, 2018 05:04 — forked from dkittell/MySQL-WordPressActivePlugins.sql
WordPress MySQL Database Information
-- Not a pretty approach but this will help you get a listing of all active plugins
DROP TABLE
IF EXISTS wp_active_plugins;
CREATE TEMPORARY TABLE wp_active_plugins (plugin_file VARCHAR(150));
ALTER TABLE wp_active_plugins ADD UNIQUE INDEX ix_plugin (plugin_file);
INSERT IGNORE
INTO wp_active_plugins
@kafkadev
kafkadev / wp-export-users.sql
Created January 12, 2018 04:26 — forked from samitny/wp-export-users.sql
Wordpress Export Users
SELECT
u.ID AS id,
u.user_login AS login_name,
first_name.meta_value AS first_name,
last_name.meta_value AS last_name,
LOWER(u.user_email) AS email,
created_ip.meta_value AS created_ip,
u.user_registered AS created_at
FROM
wp_users u
@kafkadev
kafkadev / README.md
Created January 12, 2018 03:55 — forked from hofmannsven/README.md
My simply MySQL Command Line Cheatsheet
@kafkadev
kafkadev / ajaxhook.js
Last active November 20, 2017 00:09 — forked from srideepprasad/ajaxhook.js
Ajax Hook.js - A simple Ajax Callback Interceptor
/*
AjaxHook.js - A simple utility library for intercepting Ajax calls.
This may be useful to inject simple interceptors to analyze pr capture Ajax traffic and may be even useful for automation tests to determine when an Ajax response returns.
To use :
1>Create a new AjaxHook object
var hook = new AjaxHook();
@kafkadev
kafkadev / cors.js
Created November 16, 2017 23:35 — forked from balupton/cors.js
Acheiving CORS via a Node HTTP Server
// Create our server
var server;
server = http.createServer(function(req,res){
// Set CORS headers
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Request-Method', '*');
res.setHeader('Access-Control-Allow-Methods', 'OPTIONS, GET');
res.setHeader('Access-Control-Allow-Headers', '*');
if ( req.method === 'OPTIONS' ) {
res.writeHead(200);