PHP : File upload using Rest API in ShairePoint

To upload the file in share point we are using auth-client service for authentication and through that, we will have access token which will help us to communicate to the Sharepoint

1. Register the app into SharePoint.

· Navigate to https://your_site_name.com/_layouts/15/appregnew.aspx or https://your_site_name.sharepoint.com/sites/sitename/_layouts/15/appregnew.aspx
· Click Generate for Client Id and Client Secret. Continue reading

Advertisements

jQuery : Form auto Scroll Top on Focus


$('body').on("focus", ':input, select, textarea', function(){
 var center = $(window).height()/2;
 var top = $(this).offset().top ;
 if (top > center){
 var dif = top-center;
 var scroll = (dif > 250 ) ? dif : 250;
 var body = $("html, body");
 body.stop().animate({scrollTop:scroll}, 500, 'swing');
 }
 });

PHP : Get all Timezones

<?php

$tzlist = DateTimeZone::listIdentifiers(DateTimeZone::ALL);

foreach($tzlist as $val){

$date = new DateTime(date(‘Y-m-d H:i:s’), new DateTimeZone($val));
$tz[] = $date->format(‘P’);
echo $val .” == “. $date->format(‘P’);

}

//print_r(array_unique($tz));

$date = new DateTime(date(‘Y/m/j H:i:s’), new DateTimeZone(‘Asia/Kolkata’));
echo $date->format(‘Y/m/j H:i:sP’) . “<br/>”;

$timezone¬† = “+05:30”;
echo gmdate(“Y/m/j H:i:s”, time() + 3600*($timezone+date(“I”)));

WordPress : Custom roles Users in post author drop down

// Filter to fix the Post Author Dropdown
function author_override( $output ) {
    global $post, $user_ID;

    // return if this isn't the theme author override dropdown
    if (!preg_match('/post_author_override/', $output)) return $output;

    // return if we've already replaced the list (end recursion)
    if (preg_match ('/post_author_override_replaced/', $output)) return $output;

    // replacement call to wp_dropdown_users
      $output = wp_dropdown_users(array(
        'echo' => 0,
        'name' => 'post_author_override_replaced',
        'selected' => empty($post->ID) ? $user_ID : $post->post_author,
        'include_selected' => true
      ));

      // put the original name back
      $output = preg_replace('/post_author_override_replaced/', 'post_author_override', $output);

    return $output;
}
add_filter('wp_dropdown_users', 'author_override');