Skip to content

Instantly share code, notes, and snippets.

View bwonur's full-sized avatar
☂️
I may be slow to respond.

bwonur

☂️
I may be slow to respond.
View GitHub Profile
@bwonur
bwonur / X-UA-Compatible.html
Created January 7, 2020 12:52
IE X-UA-Compatible Support
<!--[if IE]><meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1'><![endif]-->
@bwonur
bwonur / .htaccess
Created January 7, 2020 07:39
#PHP protection folder
<Files ~ "^.*\.([Pp][Hh][Pp])"> #PHP protection
Order Deny,Allow
Deny from all
</Files>
@bwonur
bwonur / htaccessCRUD.class.php
Created January 7, 2020 07:26
PHP .htaccess CRUD classes
<?php
/**
* .htaccess writer CRUD class
*
* @author Lawrence Cherone
* @version 1.00
*/
class htaccessCRUD
{
public $file;
@bwonur
bwonur / remove-phone-formating.php
Created January 3, 2020 08:48
PHP Phone Format Remover
<?php
$phone = preg_replace('/\D+/', '', $phone);
?>
@bwonur
bwonur / remove-phone-formating.php
Created December 25, 2019 11:36
PHP Remove Phone formating
<?php
$phone = "PHONE FORMAT";
$phone = preg_replace('/\D+/', '', $phone);
@bwonur
bwonur / sublime-change-scroll-bar-indicator-color.md
Last active October 25, 2021 02:51
how to make scroll bar indicator more clear and easy to see?

In your user folder you can override the themes properties you want. In this case there is a minor problem as the scrollbar texture (the image that contains the scrollbar with the top and bottom semicircles) is quite dark, so although you modify the tint you can't get a light color similar to white unless you change that texture (image).

So the solution I pruposse is to create two new images (horizontal and vertical scrollbar) that are lighter, set it in the theme preference overrides and then (optionally) set the tint color you want.

Step by step tutorial

  1. Locate your sublime User folder (Packages/User). The Packages folder can be opened using the sublime menu Preferences>Browse Packages, inside is located the User folder.
  2. Inside User folder create a directory called theme_override. We are going to place here all the files and settings of our theme that we want to override.
@bwonur
bwonur / upload-a-file.MD
Created December 12, 2019 14:22 — forked from ahmadawais/upload-a-file.MD
Upload a file using the WordPress REST API

Upload files

Using the REST API to upload a file to WordPress is quite simple. All you need is to send the file in a POST-Request to the wp/v2/media route.

There are two ways of sending a file. The first method simply sends the file in the body of the request. The following PHP script shows the basic principle:

// left: 37, up: 38, right: 39, down: 40,
// spacebar: 32, pageup: 33, pagedown: 34, end: 35, home: 36
var keys = {37: 1, 38: 1, 39: 1, 40: 1};
function preventDefault(e) {
e = e || window.event;
if (e.preventDefault)
e.preventDefault();
e.returnValue = false;
}
@bwonur
bwonur / update_slug_by_id.php
Last active November 26, 2019 08:30
WP Update Slug by ID. www.pealm.com
<?php
function update_slug_by_id($slug, $id) {
global $wpdb;
// Update slug and make it unique
$slug = (empty($slug)) ? get_the_title($id) : $slug;
$slug = sanitize_title($slug);
$new_slug = wp_unique_post_slug($slug, $id, get_post_status($id), get_post_type($id), null);
(.?.+?)(?:/([0-9]+))?/?$: "index.php?pagename=$matches[1]&page=$matches[2]"
(.?.+?)/(feed|rdf|rss|rss2|atom)/?$: "index.php?pagename=$matches[1]&feed=$matches[2]"
(.?.+?)/comment-page-([0-9]{1,})/?$: "index.php?pagename=$matches[1]&cpage=$matches[2]"
(.?.+?)/embed/?$: "index.php?pagename=$matches[1]&embed=true"
(.?.+?)/feed/(feed|rdf|rss|rss2|atom)/?$: "index.php?pagename=$matches[1]&feed=$matches[2]"
(.?.+?)/page/?([0-9]{1,})/?$: "index.php?pagename=$matches[1]&paged=$matches[2]"
(.?.+?)/trackback/?$: "index.php?pagename=$matches[1]&tb=1"
([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/(feed|rdf|rss|rss2|atom)/?$: "index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&feed=$matches[4]"
([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/?$: "index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]"
([0-9]{4})/([0-9]{1,2})/([0-9]{1,2})/embed/?$: "index.php?year=$matches[1]&monthnum=$matches[2]&day=$matches[3]&embed=true"