Skip to content

Instantly share code, notes, and snippets.

View loorlab's full-sized avatar
💻
💥👩‍🚀👨‍🚀💥

LOOR Lab loorlab

💻
💥👩‍🚀👨‍🚀💥
View GitHub Profile
@loorlab
loorlab / include_post_on_static_external_pages_WP.php
Last active August 29, 2015 14:24
Solution: WordPress wp-blog-header.php custom page NetworkError: 404 Not Found via http://www.ballyhooblog.com/wordpress-wp-blog-header-php-custom-page-404/
<?php
/*
Example :
My Site : www.mysite.com (Site built in HTML)
My Blog : www.mysite.com/blog (Site built in WordPress)
Load Post on www.mysite.com from www.mysite.com/blog
Two types of solutions for Bug : NetworkError: 404 Not Found on Firebug
*/
@loorlab
loorlab / kill-trackbacks.php
Last active August 29, 2015 14:25 — forked from chrisguitarguy/kill-trackbacks.php
Kill all WordPress pingback/trackback functionality
<?php
/*
Plugin Name: Kill Trackbacks
Plugin URI: http://pmg.co/category/wordpress
Description: Kill all trackbacks on WordPress
Version: 1.0
Author: Christopher Davis
Author URI: http://pmg.co/people/chris
*/
@loorlab
loorlab / disable_zlib.output_compression
Last active March 30, 2021 12:35
Disable zlib.output_compression on WordPress : Notice: ob_end_flush(): failed to send buffer of zlib output compression (1) in /path/wp-includes/functions.php on line 3282 via https://core.trac.wordpress.org/ticket/18525
SOLUTIONS I have came across so far:
======================== SOLUTION 1 ====================
In plugins (or somewhere) you probably have this code:
ini_set('zlib.output_compression', '1');
so, I replaced that code with
@loorlab
loorlab / get_main_base.php
Last active August 29, 2015 14:26
Get Main or Base URL PHP , solution for sites with folder , for example : www.site.com/folder/ via http://blog.chapagain.com.np/php-how-to-get-main-or-base-url/
<?php /**
* Suppose, you are browsing in your localhost
* http://localhost/myproject/index.php?id=8
*/
function getBaseUrl()
{
// output: /myproject/index.php
$currentPath = $_SERVER['PHP_SELF'];
// output: Array ( [dirname] => /myproject [basename] => index.php [extension] => php [filename] => index )
#RewriteEngine On
#RewriteCond %{HTTP_HOST} ^site\.com$ [OR]
#RewriteCond %{HTTP_HOST} ^www\.site\.com$
#RewriteCond %{REQUEST_URI} !^/folder/
#RewriteRule (.*) /folder/$1 [L]
URL : site.com/wp-admin/options-permalink.php
Change parameters to :
/%category%/%post_id%/%postname%
And Save
Voila!
@loorlab
loorlab / .htaccess
Created August 26, 2015 19:41
Delete extension .html .php for url from server
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
ErrorDocument 404 site/404.php
@loorlab
loorlab / WP_CHMOD
Last active October 13, 2016 22:02
WordPress : Permissions / chmod
Root directory 0755
wp-admin 0755
wp-content 0755
wp-includes 0755
.htaccess 0444
readme.html 0400
wp-config.php 0444
wp-admin/index.php 0644
wp-admin/.htaccess 0640
wp-content/uploads 0757
@loorlab
loorlab / add_categories_for_pages_wp.php
Last active September 15, 2015 17:26
Add Categories & Tags For Pages on WordPress
<?php
/**
* Categories for Pages
*/
function categories_pages() {
// Add tag metabox to page
register_taxonomy_for_object_type('post_tag', 'page');
// Add category metabox to page
register_taxonomy_for_object_type('category', 'page');
}
@loorlab
loorlab / add_excerpts_for_pages_wp.php
Created September 15, 2015 17:25
Add Excerpts for Pages on WordPress
<?php
/**
* Excerpts for Pages
*/
add_action( 'init', 'my_add_excerpts_to_pages' );
function my_add_excerpts_to_pages() {
add_post_type_support( 'page', 'excerpt' );
}
?>