Skip to content

Instantly share code, notes, and snippets.

View abachuk's full-sized avatar
✍️
dev manager by day, writing code at night

Alex Bachuk abachuk

✍️
dev manager by day, writing code at night
View GitHub Profile
@abachuk
abachuk / gist:2373381
Created April 13, 2012 03:23
WP example 1
<?php
/**
* Template Name: Business Rankings
* @package WordPress
*/
get_header();
?>
<aside class="right-sidebar">
<ul class="widgets">
<?php class slider_widget extends WP_Widget {
function slider_widget() {
$widget_options = array(
'classname' => 'slider',
'description' => 'add promo slider'
);
parent::WP_Widget(false, 'Promotional Slider', $widget_options);
@abachuk
abachuk / sass mixins
Created July 15, 2012 20:15
SASS Mixins
@mixin box-shadow($shadow) {
-moz-box-shadow: $shadow;
-webkit-box-shadow: $shadow;
box-shadow: $shadow
}
@mixin transition($trans) {
-webkit-transition:$trans;
-moz-transition:$trans;
-o-transition:$trans;
@abachuk
abachuk / Custom Post type meta box for WordPress
Created July 28, 2012 22:58
Custom Post type meta box for WordPress (extension to CPT)
/******* RELATED PAGES METABOX *********/
add_action( 'cmb_render_select_post', 'rrh_cmb_render_select_post', 10, 2 );
function rrh_cmb_render_select_post( $field, $meta ) {
global $posts;
$posts = get_posts( array( 'post_type' => 'page', 'posts_per_page' => -1 ));
echo '<select name="', $field['id'], '" id="', $field['id'], '">';
foreach ($posts as $option) {
echo '<option value="', $option->ID, '"', $meta == $option->ID ? ' selected="selected"' : '', '>', $option->post_title, '</option>';
}
echo '</select>';
@abachuk
abachuk / jqm-hacks
Created July 31, 2012 15:04
jQuery Mobile hacks and fixes
/********** iOS rotation zoom fix **********/
var viewport = $('meta[name="viewport"]');
var nua = navigator.userAgent;
if ((nua.match(/iPad/i)) || (nua.match(/iPhone/i)) || (nua.match(/iPod/i))) {
viewport.attr('content', 'width=device-width, minimum-scale=1.0, maximum-scale=1.0');
$('body')[0].addEventListener("gesturestart", gestureStart, false);
}
function gestureStart() {
@abachuk
abachuk / gist:4478258
Created January 7, 2013 20:49
Outlook background image hack
<!--[if gte mso 9]>
<v:image xmlns:v="urn:schemas-microsoft-com:vml" id="theImage" style='behavior: url(#default#VML); display: inline-block; position: absolute; width: 374px; height: 246px; top: 0; left: 130px; border: 0; z-index: 1;' src="/imgs/myPhoto.png" />
<v:shape xmlns:v="urn:schemas-microsoft-com:vml" id="theText" style='behavior: url(#default#VML); display: inline-block; position: absolute; width: 374px; height: 246px; top: -5; left: 125px; border: 0; z-index: 2;'>
<div>
<![endif]-->
<table style="background: /imgs/myPhoto.png”>
</table>
<!--[if gte mso 9]>
</div>
</v:shape>
@abachuk
abachuk / gist:4703394
Last active December 12, 2015 02:58
meta box code example
$meta_boxes[] = array(
'id' => 'home_page_metabox2',
'title' => 'Preview',
'pages' => array( 'page', ), // Post type
'context' => 'normal',
'priority' => 'high',
'show_names' => true, // Show field names on the left
'show_on' => array( 'key' => 'page-template', 'value' => 'page_home.php' ),
'fields' => array(
array(
@abachuk
abachuk / gist:5485177
Last active December 16, 2015 19:29
WordPress + Backbone
//NAMESPCING APP
var App = {
Models : {},
Collections: {},
Views: {},
Router: {}
};
//DECLARING MODEL
App.Models.Post = Backbone.Model.extend({});
@abachuk
abachuk / Phonegap + jQuery Mobile + android.js
Last active January 2, 2017 21:29
Phonegap + jQuery Mobile + android
/// PHONEGAP + jQUERY MOBILE (page from android app)
$(document).on("pageinit", ".ui-page", function () {
$('input').focus(function(){
$('#signin-footer').hide();
});
$('input').blur(function(){
$('#signin-footer').show();
})
@abachuk
abachuk / ajax polling
Created May 1, 2013 19:43
Ajax Polling
(function(exports, document, $) {
var window = exports;
var RecentGiftsController = function(mediator) {
var mediator = mediator;
var pollingProcess = null;
var url = '/ajax/get-recent-gifts';
var buffer = [];