Skip to content

Instantly share code, notes, and snippets.

View sunnyluthra's full-sized avatar

Sunny Luthra sunnyluthra

View GitHub Profile
@sunnyluthra
sunnyluthra / API Example
Last active August 29, 2015 14:01
API Example
{
foundPosts: "51",
totalPages: 13,
places:
[{
id: 202,
title: "Al-Bake",
description: "Al-Bake Shawarma, Afghani Chicken, Chicken Changezi, Malai Kofta, Chicken Talumin Soup",
smallPic: "http://10.23.2.207:8080/501/server/htdocs/content/uploads/2014/05/Al-Bake-84x84.jpg",
coverPic: "http://10.23.2.207:8080/501/server/htdocs/content/uploads/2014/05/Al-Bake-945x215.jpg",
@sunnyluthra
sunnyluthra / woocommerce-hide-price-logged-out.php
Created October 5, 2014 07:58
woocommerce-hide-price-logged-out.php
add_action('after_setup_theme', 'show_price_logged');
function show_price_logged($price) {
if (!is_user_logged_in()) {
remove_action('woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart');
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_price', 10);
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30);
remove_action('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10);
}
}
@sunnyluthra
sunnyluthra / redirect-android-ios.php
Created October 31, 2014 05:57
Redirect to playstore or appstore
define("PLAYSTORE_LINK", "");
define("APPSTORE_LINK", "");
sny_os_redirect();
function sny_os_redirect() {
if(sny_if_android() && PLAYSTORE_LINK){
header("Location: " . PLAYSTORE_LINK);
}elseif(sny_if_ios() && APPSTORE_LINK){
header("Location: ".APPSTORE_LINK);
require_once( ABSPATH . 'wp-admin/includes/file.php' );
require_once( ABSPATH . 'wp-admin/includes/image.php' );
$uploadedfile = $_FILES['file'];
$upload_overrides = array( 'test_form' => false );
$movefile = wp_handle_upload( $uploadedfile, $upload_overrides );
if ( $movefile ) {
$wp_filetype = $movefile['type'];
$filename = $movefile['file'];
$wp_upload_dir = wp_upload_dir();
{
"bold_folder_labels": true,
"caret_extra_width": 1,
"caret_style": "phase",
"close_windows_when_empty": false,
"color_scheme": "Packages/User/SublimeLinter/Seti_orig (SL).tmTheme",
"copy_with_empty_selection": false,
"detect_slow_plugins": false,
"drag_text": false,
"draw_centered": false,
@sunnyluthra
sunnyluthra / wpmu_new_blog.php
Created April 15, 2015 07:04
Alter WP Multisite table after new blog creation
<?php
function alter_table(){
global $wpdb;
$sql = "ALTER TABLE ".$wpbd -> posts." ADD `likes_count` INT( 11 ) NOT NULL DEFAULT '0'"
$wpdb -> query($sql);
}
function on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) {
switch_to_blog( $blog_id );
alter_table();
restore_current_blog();
@sunnyluthra
sunnyluthra / deletePendingPosts.js
Last active March 1, 2016 04:36
It will delete all the pending posts
var deleteSpam = {
count: 0,
list: null,
timeout: 500,
//Selector of cross(x) link
crossSelector: '.userContentWrapper [aria-label="Delete"]',
//Selector for buttons wrapper in overlay box which appears when we click on cross icon
overlayPresenseSelector: '.uiOverlayFooter',
//Delete button selector on overlay box
confirmDeleteButtonSelector: 'button.layerConfirm',
@sunnyluthra
sunnyluthra / random_token.php
Last active August 29, 2015 14:27
Generate Random Token
function generate_token() {
return bin2hex(openssl_random_pseudo_bytes($this->token_length));
}
@sunnyluthra
sunnyluthra / verify_android_push_notification_token.php
Created August 25, 2015 18:49
verify_android_push_notification_token.php
function verify_notification_token($token) {
$fields = array(
'dry_run' => true,
'to' => $token,
);
$headers = array(
'Authorization: key=' . GOOGLE_API_SERVER_KEY,
'Content-Type: application/json',
);
$ch = curl_init();
@sunnyluthra
sunnyluthra / padding-margin.sass
Created September 9, 2015 07:53
Padding Class Generator
@mixin class-generator($classNamespace, $fromValue, $toValue, $multiple, $property, $unit) {
@for $i from $fromValue to $toValue {
.#{$classNamespace}#{$i*$multiple} {
#{$property}: #{$i*$multiple}#{$unit};
}
}
}
@include class-generator(pt, 0, 25, 5, padding-top, px);