Skip to content

Instantly share code, notes, and snippets.

View buraksahin59's full-sized avatar
:atom:
React Native

Burak buraksahin59

:atom:
React Native
View GitHub Profile
@buraksahin59
buraksahin59 / rs_upload_from_url.php
Created August 11, 2023 12:18 — forked from RadGH/rs_upload_from_url.php
Upload a file from a URL to the WordPress media gallery. Supports images, PDFs, and other file types.
<?php
/**
* This function uploads from a URL.
* To upload from a local file path instead
* @see: https://gist.github.com/RadGH/3b544c827193927d1772
*
* Example usage: Upload photo from URL, display the attachment as as html <img>
* $attachment_id = rs_upload_from_url( "http://example.com/images/photo.png" );
* echo wp_get_attachment_image( $attachment_id, 'large' );

Codestar Framework

A Lightweight and easy-to-use WordPress Options Framework. It is a free framework for building theme options. Save your time!

Screenshot

Codestar Framework Screenshot

Read the documentation for details documentation

Installation

@buraksahin59
buraksahin59 / ip_in_range.php
Created May 28, 2020 12:35 — forked from tott/ip_in_range.php
php check if IP is in given network range
/**
* Check if a given ip is in a network
* @param string $ip IP to check in IPV4 format eg. 127.0.0.1
* @param string $range IP/CIDR netmask eg. 127.0.0.0/24, also 127.0.0.1 is accepted and /32 assumed
* @return boolean true if the ip is in this range / false if not.
*/
function ip_in_range( $ip, $range ) {
if ( strpos( $range, '/' ) == false ) {
$range .= '/32';
}
@buraksahin59
buraksahin59 / wordpress_remote_images
Created March 16, 2020 09:34 — forked from bjorn2404/wordpress_remote_images
WordPress load remote images if they don't exist on the local development server htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/wp-content/uploads/(.*)$
RewriteCond %{DOCUMENT_ROOT}/wp-content/uploads/%1 !-f
RewriteRule ^wp-content/uploads/(.*)$ http://www.remotesite.com/wp-content/uploads/$1 [R=301,L]
</IfModule>
@buraksahin59
buraksahin59 / example-wp-list-table.php
Created March 14, 2020 22:28 — forked from paulund/example-wp-list-table.php
An example code of using the WP_List_Table class. With Pagination.
<?php
/*
* Plugin Name: Paulund WP List Table Example
* Description: An example of how to use the WP_List_Table class to display data in your WordPress Admin area
* Plugin URI: http://www.paulund.co.uk
* Author: Paul Underwood
* Author URI: http://www.paulund.co.uk
* Version: 1.0
* License: GPL2
*/
@buraksahin59
buraksahin59 / jQuery sort JSON by value
Created January 7, 2019 16:55 — forked from boy3vil/jQuery sort JSON by value
jQuery sort JSON by value
<script type="text/javascript">
var arr = [
{ "ID": 135, "Name": "Fargo Chan", "Address": "34, Baker Street" },
{ "ID": 432, "Name": "Aaron Luke", "Address": "BLDG 1, J Street" },
{ "ID": 252, "Name": "Dilip Singh", "Address": "Hotel J, SE" }
];
// Before Sorting
document.write("<b>Before Sorting </b><br/>");
for (var n = 0; n < arr.length; n++) {
// Get The Page ID You Need
get_option( 'woocommerce_shop_page_id' );
get_option( 'woocommerce_cart_page_id' );
get_option( 'woocommerce_checkout_page_id' );
get_option( 'woocommerce_pay_page_id' );
get_option( 'woocommerce_thanks_page_id' );
get_option( 'woocommerce_myaccount_page_id' );
get_option( 'woocommerce_edit_address_page_id' );
get_option( 'woocommerce_view_order_page_id' );
get_option( 'woocommerce_terms_page_id' );
@buraksahin59
buraksahin59 / php-html-css-js-minifier.php
Created January 7, 2017 10:44 — forked from taufik-nurrohman/php-html-css-js-minifier.php
PHP Function to Minify HTML, CSS and JavaScript
<?php
// Based on <https://github.com/mecha-cms/extend.minify>
define('MINIFY_STRING', '"(?:[^"\\\]|\\\.)*"|\'(?:[^\'\\\]|\\\.)*\'');
define('MINIFY_COMMENT_CSS', '/\*[\s\S]*?\*/');
define('MINIFY_COMMENT_HTML', '<!\-{2}[\s\S]*?\-{2}>');
define('MINIFY_COMMENT_JS', '//[^\n]*');
define('MINIFY_PATTERN_JS', '\b/[^\n]+?/[gimuy]*\b');
define('MINIFY_HTML', '<[!/]?[a-zA-Z\d:.-]+[\s\S]*?>');
@buraksahin59
buraksahin59 / custom_posttype_glance.php
Created December 6, 2015 01:03 — forked from feryardiant/custom_posttype_glance.php
Adding Custom post type counts in 'Right now' Dashboard widget in Wordpress 3.8 or above
<?php
/**
* Adding Custom post type counts in 'Right now' Dashboard widget.
* Acording this changes :
* - https://core.trac.wordpress.org/ticket/26571
* - https://core.trac.wordpress.org/ticket/26495
* now you can't use 'right_now_*' action API to show your custom post type count from your Dashboard.
* But if you running WP 3.8 or above, you can use 'dashboard_glance_items' instead.
*
* @package Wordpress
@buraksahin59
buraksahin59 / wppb.login.php
Created November 30, 2015 21:07 — forked from abachuk/wppb.login.php
WP User Frontend Login with Email
<?php
/* wp_signon can only be executed before anything is outputed in the page because of that we're adding it to the init hook */
global $wppb_login;
$wppb_login = false;
function wppb_signon(){
global $error;
global $wppb_login;