Skip to content

Instantly share code, notes, and snippets.

💭
Cooking something hot in oven for WordPress

Ram Ratan Maurya mauryaratan

💭
Cooking something hot in oven for WordPress
Block or report user

Report or block mauryaratan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View dabblet.css
#wrapper{
max-width:300px;
margin:30px auto;
padding:0px 20px;
}
.floatleft{
float:left;
}
[class^="smiley-"]{
@mauryaratan
mauryaratan / htaccess-tweaks
Created May 7, 2012
htaccess Gzip Compression and expires to speed up page load time
View htaccess-tweaks
<IfModule mod_deflate.c>
#The following line is enough for .js and .css
AddOutputFilter DEFLATE js css
AddOutputFilterByType DEFLATE text/plain text/xml application/xhtml+xml text/css application/xml application/rss+xml application/atom_xml application/x-javascript application/x-httpd-php application/x-httpd-fastphp text/html
#The following lines are to avoid bugs with some browsers
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>
@mauryaratan
mauryaratan / WP3.5 Media Uploader
Created Dec 14, 2012
WordPress 3.5 media uploader in easier steps. If using other than edit post screen, don't forget to use wp_enqueue_media(); in your functions.php
View WP3.5 Media Uploader
jQuery(document).ready(function($){
var _custom_media = true,
_orig_send_attachment = wp.media.editor.send.attachment;
$('.stag-metabox-table .button').click(function(e) {
var send_attachment_bkp = wp.media.editor.send.attachment;
var button = $(this);
var id = button.attr('id').replace('_button', '');
_custom_media = true;
wp.media.editor.send.attachment = function(props, attachment){
if ( _custom_media ) {
@mauryaratan
mauryaratan / equal-height-columns.js
Last active Oct 14, 2015
100% Column height using jQuery; conditional, applies only on one with less height.
View equal-height-columns.js
var wrap = $('.content');
var col1 = $('.content .primary');
var col2 = $('.content .sidebar');
if (col1.height() < wrap.height()){
col1.css('height', wrap.height()+'px');
}
if (col2.height() < wrap.height()){
col2.css('height', wrap.height()+'px');
@mauryaratan
mauryaratan / SCSS Mixins.scss
Last active Oct 14, 2015
Useful SCSS Mixins
View SCSS Mixins.scss
@mixin md($case){
.#{$case} &{
@content;
}
}
@mixin the-bg($trans: 1){
background: url(assets/img/pixel-#{$trans}.png) repeat;
background: rgba(black, ($trans/10));
}
@mauryaratan
mauryaratan / body_classes.js
Last active Dec 10, 2015
Add body classes for browser, OS and retina display support.
View body_classes.js
$(function() {
var browser, classList, os, platform, retina;
retina = window.devicePixelRatio > 1 ? "retina" : "no-retina";
platform = window.navigator.userAgent;
if (/Chrome/.test(platform)) {
browser = "chrome";
} else if (/Firefox/.test(platform)) {
browser = "firefox";
} else {
browser = "unknown-browser";
@mauryaratan
mauryaratan / WP3.5 Media Upload API.js
Last active Dec 10, 2015
A slightly improved version of WP3.5 Media Uploader than previous version, just to stay safe. Don't forget to use wp_enqueue_media(); to avoid any error.
View WP3.5 Media Upload API.js
// Uploading files
var file_frame;
jQuery('.upload_image_button').live('click', function( event ){
event.preventDefault();
// If the media frame already exists, reopen it.
if ( file_frame ) {
file_frame.open();
@mauryaratan
mauryaratan / Mac-folder-clean.txt
Created Feb 14, 2013
Compress your files without including .DS_Store with single line command.
View Mac-folder-clean.txt
zip -r foo.zip foo -x "*.DS_Store"
To interpret this, we are running the zip executable with the following parameters/arguments:
-r for recursively including all directories underneath the targets we want to zip.
foo.zip is the name of the zip archive we are creating
foo is the target directory we want to zip up
-x "*.DS_Store" excludes all files whose path ends in the string ".DS_Store"
@mauryaratan
mauryaratan / wordpress-functions.php
Created Mar 11, 2013
Useful WordPress functions for random needs.
View wordpress-functions.php
<?php
function is_sidebar_active( $index = 1){
$sidebars = wp_get_sidebars_widgets();
$count = count($sidebars['sidebar-'.$index]);
if($count === 0){
return false;
}else{
return true;
}
@mauryaratan
mauryaratan / custom-file.php
Last active Dec 17, 2015
Custom CSS file generation in WordPress
View custom-file.php
<?php
// OUTPUT CUSTOM CSS FILE
function stag_link_custom_styles(){
$output = '';
if(apply_filters('stag_custom_styles', $output)){
$perma_structure = get_option('permalink_structure');
$url = home_url(). '/stag-custom-styles.css?'.time();
if(!$perma_structure) $url = home_url(). '?page_id=stag-custom-styles.css';
echo '<link rel="stylesheet" href="'.$url.'" type="text/css" media="screen" />';
You can’t perform that action at this time.