Skip to content

Instantly share code, notes, and snippets.

View ionurboz's full-sized avatar

Onur ionurboz

View GitHub Profile
@ionurboz
ionurboz / README.md
Created March 4, 2024 11:34 — forked from abelcallejo/README.md
The missing is_posts_page() function of WordPress

is_posts_page()

Returns boolean whether the current page is the posts page as set from the dashboard.

@ionurboz
ionurboz / wp_log_http_requests.php
Created February 7, 2024 07:29 — forked from hinnerk-a/wp_log_http_requests.php
WordPress filter hook for logging WP HTTP requests
<?php
function wp_log_http_requests( $response, $args, $url ) {
// set your log file location here
$logfile = plugin_dir_path( __FILE__ ) . '/http_requests.log';
// parse request and response body to a hash for human readable log output
$log_response = $response;
if ( isset( $args['body'] ) ) {
@ionurboz
ionurboz / replace-wp-dashboard.php
Created January 30, 2024 13:55 — forked from wpscholar/replace-wp-dashboard.php
Replace the default WordPress dashboard with a custom one
<?php
/**
* Plugin Name: Replace WordPress Dashboard
* Description: Replaces the default WordPress dashboard with a custom one.
* Author: Micah Wood
* Author URI: http://micahwood.me
* Version: 0.1
* License: GPL3
*/
@ionurboz
ionurboz / advanced-cache.php
Created September 25, 2023 13:38 — forked from chrisguitarguy/advanced-cache.php
Copied/modified batcache to learn how it worked.
<?php
/**
* Plugin Name: Ratcache
* Description: An advanced caching plugin that uses an external object cache to store full pages.
* Author: Christopher Davis
* Author URI: http://christopherdavis.me
* Version: 0.1
*
* Place this file in your `wp-content` directory and add
* `define('WP_CACHE', true)` to your wp config file.
<?php
/**
* Plugin Name: Ratcache
* Description: An advanced caching plugin that uses an external object cache to store full pages.
* Author: Christopher Davis
* Author URI: http://christopherdavis.me
* Version: 0.1
*
* Place this file in your `wp-content` directory and add
* `define('WP_CACHE', true)` to your wp config file.
@ionurboz
ionurboz / get-browser-language.php
Created May 3, 2023 14:23 — forked from joke2k/get-browser-language.php
PHP: Detect Browser Language
<?php
/**
* Get browser language, given an array of avalaible languages.
*
* @param [array] $availableLanguages Avalaible languages for the site
* @param [string] $default Default language for the site
* @return [string] Language code/prefix
*/
function get_browser_language( $available = [], $default = 'en' ) {
if ( isset( $_SERVER[ 'HTTP_ACCEPT_LANGUAGE' ] ) ) {
@ionurboz
ionurboz / .htaccess
Created April 3, 2023 11:53 — forked from gapple/.htaccess
htaccess gzip/brotli-bomb
<IfModule mod_rewrite.c>
RewriteEngine On
<IfModule mod_headers.c>
RewriteCond %{HTTP:Accept-encoding} br
RewriteCond %{REQUEST_FILENAME} wp-login.php
RewriteRule ^(.*)$ bomb-32G.brotli [QSA]
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{REQUEST_FILENAME} wp-login.php
@ionurboz
ionurboz / ajaxListener.js
Created February 16, 2023 14:32 — forked from icodejs/ajaxListener.js
JS: Listen to ajax calls from Javascript
var open = window.XMLHttpRequest.prototype.open,
send = window.XMLHttpRequest.prototype.send,
onReadyStateChange;
function openReplacement(method, url, async, user, password) {
var syncMode = async !== false ? 'async' : 'sync';
console.warn(
'Preparing ' +
syncMode +
' HTTP request : ' +
@ionurboz
ionurboz / debug-wpmail.php
Created November 13, 2022 15:02 — forked from Bobz-zg/debug-wpmail.php
Debug wp_mail function. Display errors on screen
<?php
/**
* Display errors
*/
if ( ! function_exists('debug_wpmail') ) :
function debug_wpmail( $result = false ) {
if ( $result )
return;
@ionurboz
ionurboz / sanitize.php
Created September 10, 2022 08:55 — forked from weartstudio/sanitize.php
WordPress: Sanitize elements for WP Customizr. Sanitize functions. Image upload, adsense box, checkbox, text, select
<?php
//sanitize adsense box adsense codes
function weart_sanitize_adsense( $input ) {
esc_js($input);
$input = str_replace(array("\r", "\n"), '', $input);
return $input;
}
//sanitize checkbox