Skip to content

Instantly share code, notes, and snippets.

View sunnyluthra's full-sized avatar

Sunny Luthra sunnyluthra

View GitHub Profile
<?php
/*
Plugin Name: Bot For WP
Description: Messenger bot for WordPress
Plugin URI: http://snypd.com/
Author: Sunny Luthra
Author URI: http://#
Version: 1.0
License: GPL2
*/
@sunnyluthra
sunnyluthra / find_user_with_skills.php
Created October 27, 2015 08:55
Find wordpress user by meta values
<?php
$args = array(
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'skill',
'value' => 'php',
'compare' => '='
),
@sunnyluthra
sunnyluthra / get_user_id_by_meta.php
Last active October 8, 2015 06:39
WordPress get user by metakey and value
<?php
function get_user_id_by_meta($key, $value) {
if (!$key && !$value) {
return false;
}
$args = array(
'meta_key' => $key,
'meta_value' => $value,
'fields' => 'ids',
'count_total' => false,
@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);
@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 / 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 / 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 / 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();
{
"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,
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();