Skip to content

Instantly share code, notes, and snippets.

@Amitkpr
Amitkpr / Instagram API services
Created February 19, 2019 10:29
Instagram API services
$jsonUrl = "https://api.instagram.com/v1/users/self/media/recent/?access_token=3934716848.1677ed0.b59c86f3247e4705b227cf7a3aa18629";
$json = file_get_contents($jsonUrl);
$obj = json_decode($json);
echo '<pre>';
print_r($obj);
echo '</pre>';
@Amitkpr
Amitkpr / facebook chat option with page
Created February 4, 2019 12:48
facebook chat option with page
<div class="fb-customerchat"
page_id="2237699536499425"
minimized="true">
</div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '2057654290955252',
autoLogAppEvents : true,
xfbml : true,
@Amitkpr
Amitkpr / map plane Animation
Created January 31, 2019 04:13
map plane Animation
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title>Animate a point along a route</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.52.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.52.0/mapbox-gl.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
@Amitkpr
Amitkpr / Query for Featured product in woocommerce
Created January 21, 2019 11:30
Query for Featured product in woocommerce
@Amitkpr
Amitkpr / block wp admin for some roles
Created December 24, 2018 08:01
block wp admin for some roles
function wpse66093_no_admin_access()
{
$redirect = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : home_url( '/your-profile' );
if (
current_user_can( 'volunteer' )
OR current_user_can( 'matrimony' )
OR current_user_can( 'student' )
)
exit( wp_redirect( $redirect ) );
}
@Amitkpr
Amitkpr / addtocart text or link
Created December 6, 2018 10:51
change addtocart text or link in woocommerce
@Amitkpr
Amitkpr / wordpress no html content function
Created October 12, 2018 05:39
wordpress no html content function
wp_filter_nohtml_kses()
@Amitkpr
Amitkpr / Get_week_of_month_and_start_date_and_last_date_of_week.php
Created August 14, 2018 07:22
Get week of month and start date and last date of week
function weekOfMonth($date) {
$ddate = $date;
$duedt = explode("-", $ddate);
$date = mktime(0, 0, 0, $duedt[1], $duedt[2], $duedt[0]);
$week = (int)date('W', $date);
$Y = (int)date('Y', $date);
return array($week,$Y);
}
function getStartAndEndDate($week, $year)
{
@Amitkpr
Amitkpr / check key value in associative arrays function.php
Created July 20, 2018 06:12
check key value in associative arrays function
function is_in_array($array, $key, $key_value){
$within_array = 'no';
foreach( $array as $k=>$v ){
if( is_array($v) ){
$within_array = is_in_array($v, $key, $key_value);
if( $within_array == 'yes' ){
break;
}
} else {
if( $v == $key_value && $k == $key ){
@Amitkpr
Amitkpr / wordpress_post_pagiantion.php
Last active July 3, 2018 11:36
get wordpress post with custom query with pagination
add_action( 'wp_ajax_get_comments_new', 'get_comments_new' );
add_action( 'wp_ajax_nopriv_get_comments_new', 'get_comments_new' );
function get_comments_new(){
$args = array('post_type' => 'course_unit');
$post_obj = new WP_Query($args);
while($post_obj->have_posts() ) : $post_obj->the_post();
//display comments
global $wpdb;