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 / htaccess-security.php
Created February 10, 2020 08:47 — forked from bUxEE/htaccess-security.php
htaccess security settings
# START SECURITY
# Don't show errors which contain full path diclosure (FPD)
# Use that line only if PHP is installed as a module and not per CGI
# try using a php.ini in that case.
# Change mod_php5.c to mod_php7.c if you are running PHP7
<IfModule mod_php5.c>
php_flag display_errors Off
</IfModule>
# Don't list directories
@bwonur
bwonur / .htaccess
Created February 10, 2020 06:21 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@bwonur
bwonur / gist:8f78b78a9108ffca42a5d7494f12236e
Created January 27, 2020 13:13 — forked from oswaldoacauan/gist:7580474
jQuery - Serialize Form with File inputs
(function($) {
$.fn.serializeFiles = function() {
var form = $(this),
formData = new FormData()
formParams = form.serializeArray();
$.each(form.find('input[type="file"]'), function(i, tag) {
$.each($(tag)[0].files, function(i, file) {
formData.append(tag.name, file);
});
@bwonur
bwonur / fa-icons-list.txt
Created January 22, 2020 14:39 — forked from antoineMoPa/fa-icons-list.txt
Font-Awesome Icons List for version 4.3.0
fa-glass
fa-music
fa-search
fa-envelope-o
fa-heart
fa-star
fa-star-o
fa-user
fa-film
fa-th-large
@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:

@bwonur
bwonur / wp-custom-table.md
Created November 20, 2019 06:02 — forked from ionurboz/wp-custom-table.md
WordPress ADD CUSTOM TABLE + INSERT DATA + GET DATA

Creating or Updating the Table

The next step is to actually create the database table. Rather than executing an SQL query directly, we'll use the dbDelta function in wp-admin/includes/upgrade.php (we'll have to load this file, as it is not loaded by default). The dbDelta function examines the current table structure, compares it to the desired table structure, and either adds or modifies the table as necessary, so it can be very handy for updates (see wp-admin/upgrade-schema.php for more examples of how to use dbDelta). Note that the dbDelta function is rather picky, however. For instance:

  • You must put each field on its own line in your SQL statement.
  • You must have two spaces between the words PRIMARY KEY and the definition of your primary key.
  • You must use the key word KEY rather than its synonym INDEX and you must include at least one KEY.
  • KEY must be followed by a SINGLE SPACE then the key name then a space then open parenthesis with the field name then a closed parenthesis.
  • You must not use a
@bwonur
bwonur / gist:987ed676b28c037019d603e2483b10cc
Created August 29, 2019 07:01 — forked from danielbachhuber/gist:8af274e2b7f21c8c3bb6
Post-style permalinks for your custom post types
<?php
/**
* Post-style permalinks for your custom post types
* e.g. %year%/%monthnum%/%day%/%postname%
*/
function dbx_get_post_types() {
return array(
// replace with your custom post types
'my-custom-post-type'
);
@bwonur
bwonur / wp_rewrite_rules.log
Created August 28, 2019 10:45 — forked from thenbrent/wp_rewrite_rules.log
Default WordPress Rewrite Rules
[rules] => Array (
[category/(.+?)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?category_name=$matches[1]&feed=$matches[2]
[category/(.+?)/(feed|rdf|rss|rss2|atom)/?$] => index.php?category_name=$matches[1]&feed=$matches[2]
[category/(.+?)/page/?([0-9]{1,})/?$] => index.php?category_name=$matches[1]&paged=$matches[2]
[category/(.+?)/?$] => index.php?category_name=$matches[1]
[tag/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?tag=$matches[1]&feed=$matches[2]
[tag/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?tag=$matches[1]&feed=$matches[2]
[tag/([^/]+)/page/?([0-9]{1,})/?$] => index.php?tag=$matches[1]&paged=$matches[2]
[tag/([^/]+)/?$] => index.php?tag=$matches[1]
[type/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?post_format=$matches[1]&feed=$matches[2]
@bwonur
bwonur / whois.php
Created August 6, 2019 10:38
PHP code to get WHOIS information of a domain
<?php
/*************************************************************************
php easy :: whois lookup script
==========================================================================
Author: php easy code, www.phpeasycode.com
Web Site: http://www.phpeasycode.com
Contact: [email protected]
*************************************************************************/
$domain = $_GET['domain'];
@bwonur
bwonur / Revert sublime text 3 to a fresh state.md
Created July 31, 2019 15:02 — forked from math2001/Revert sublime text 3 to a fresh state.md
Revert Sublime Text 3 to a fresh state step by step 🙂

How do I revert Sublime Text 3 to a fresh state

This little gist will walk you through the process of reverting your Sublime Text installation to a fresh state.

This simply means to get Sublime Text to exactly as it was by default.

Hum... Will I lose all my setup?

No. You can go back to how you were really easily, and it's explained at the bottom. 😉