Skip to content

Instantly share code, notes, and snippets.

@nurbek-ab
nurbek-ab / supress_notices.php
Created October 15, 2015 09:39
Supress all notices and warnings in wordpress.
<?php
// place this to mu-plugins folder under wp-content
// set WP_DEBUG to true in wp_config.php to see all other errors
error_reporting(E_ALL & ~( E_NOTICE | E_USER_NOTICE | E_STRICT | E_DEPRECATED | E_USER_DEPRECATED | E_WARNING | E_CORE_WARNING | E_USER_WARNING | E_COMPILE_WARNING | E_PARSE ));
function isScrolledIntoView(elem)
{
var $elem = $(elem);
var $window = $(window);
var docViewTop = $window.scrollTop();
var docViewBottom = docViewTop + $window.height();
var elemTop = $elem.offset().top;
var elemBottom = elemTop + $elem.height();
@nurbek-ab
nurbek-ab / functions.php
Last active April 5, 2021 10:59
Change wordpress search results permalink (base url, search base).
<?php
function nice_search_redirect() {
global $wp_rewrite;
if ( !isset( $wp_rewrite ) || !is_object( $wp_rewrite ) || !$wp_rewrite->using_permalinks() )
return;
$search_base = $wp_rewrite->search_base;
if ( is_search() && !is_admin() && strpos( $_SERVER['REQUEST_URI'], "/{$search_base}/" ) === false ) {
wp_redirect( home_url( "/{$search_base}/" . urlencode( get_query_var( 's' ) ) ) );
exit();
@nurbek-ab
nurbek-ab / replace-tag.js
Last active June 19, 2023 07:43
Replace element's tag name with another tag name using jQuery
function replaceElementTag(targetSelector, newTagString) {
$(targetSelector).each(function(){
var newElem = $(newTagString, {html: $(this).html()});
$.each(this.attributes, function() {
newElem.attr(this.name, this.value);
});
$(this).replaceWith(newElem);
});
}
@nurbek-ab
nurbek-ab / no-gutters.css
Last active September 24, 2015 09:14
Bootstrap no gutters
.container.no-gutters {
padding-left: 0;
padding-right: 0;
}
.container.no-gutters .row {
margin-right: 0;
margin-left: 0;
}
@nurbek-ab
nurbek-ab / web.config
Last active March 28, 2023 12:28 — forked from lennart/gist:3787187
IIS rewrite rule for Symfony 2 (use at root directory)
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<clear />
<rule name="TempRewriteToWeb" stopProcessing="false">
<match url="^(web/)?(.*)$" />
<action type="Rewrite" url="web/{R:2}" logRewrittenUrl="true" />
</rule>
@nurbek-ab
nurbek-ab / five-column.css
Created March 23, 2015 06:56
Bootstrap five column layout
.col-xs-five,
.col-sm-five,
.col-md-five,
.col-lg-five {
position: relative;
min-height: 1px;
padding-right: 10px;
padding-left: 10px;
}
@nurbek-ab
nurbek-ab / button.css
Last active August 14, 2017 17:45
Bootstrap 3 button with transparent background
/**
* Tested on Bootstrap 3.3.2
* Usage: <button class="btn btn-transparent" type="button">Click me</button>
*/
.btn-transparent {
background: transparent;
color: #F2F2F2;
-webkit-transition: background .2s ease-in-out, border .2s ease-in-out;
-moz-transition: background .2s ease-in-out, border .2s ease-in-out;
-o-transition: background .2s ease-in-out, border .2s ease-in-out;
@nurbek-ab
nurbek-ab / delete.bat
Created January 25, 2015 16:47
Reset folder permissions on Windows 7 after system reinstall
SET DIRECTORY_NAME="C:\OldWindows"
TAKEOWN /f %DIRECTORY_NAME% /r /d y
ICACLS %DIRECTORY_NAME% /reset /T
PAUSE
@nurbek-ab
nurbek-ab / text-align.css
Created January 21, 2015 08:48
Bootstrap text-align for different screen sizes
.text-xs-left {
text-align: left !important;
}
.text-xs-right {
text-align: right !important;
}
.text-xs-center {
text-align: center !important;