Skip to main content

Posts

Showing posts from 2015

Get Google Calendar Event List in WordPress

<a href="https://console.cloud.google.com/apis/credentials">Get Your Api Credentials Here</a> <a href="https://calendar.google.com/calendar">Get your Calender ID</a> <?php include_once("wp-load.php"); function  get_calender_events() { $params = array(); /*Get current date*/ $current_date  = date('Y-m-d H:i:s'); /*Convert it to google calendar's rfc_format */ $rfc_format = date("c", strtotime($current_date)); $params[] = 'orderBy=startTime'; $params[] ='maxResults=100'; $params[] = 'timeMin='.urlencode($rfc_format); $url_param = ''; foreach($params as $param) { $url_param.= '&'.$param; } $calender_id = "calender_id"; $client_key =  "client_key"; $url = "https://www.googleapis.com/calendar/v3/calendars/".$calender_id."/events?key=".$client_key."&singleEvents=true".$url_param; $list_events = wp_remote_post($url,

CKEDITOR in PHP

<script src="http://www.dooleyproperties.com/wp-content/themes/dooleyproperties/js/ckeditor/ckeditor.js"></script> <script> if ( CKEDITOR.env.ie && CKEDITOR.env.version < 9 ) CKEDITOR.tools.enableHtml5Elements( document ); CKEDITOR.config.height = 150; CKEDITOR.config.width = 'auto'; var initSample = ( function() { var wysiwygareaAvailable = isWysiwygareaAvailable(), isBBCodeBuiltIn = !!CKEDITOR.plugins.get( 'bbcode' ); return function() { var editorElement = CKEDITOR.document.getById( 'txtContent' ); if ( isBBCodeBuiltIn ) { editorElement.setHtml( 'Hello world!\n\n' + 'I\'m an instance of [url=http://ckeditor.com]CKEditor[/url].' ); } if ( wysiwygareaAvailable ) { CKEDITOR.replace( 'txtContent' ); } else { editorElement.setAttribute( 'contenteditable', 'true' ); CKEDITOR.inline( 'txtContent' ); } }; fun

Array Multisort in Wordpress Code

<?php                 $sql = "SELECT * FROM property_details order by address"; $pageposts = $wpdb->get_results($sql);           foreach ($pageposts as $singlepost)  { $pos=strpos($singlepost->address, " "); if ($pos !== false) {    $snum= substr($singlepost->address, 0, $pos);    //pr($street_number);pr($key);    $sname = substr($singlepost->address, $pos+1, strlen($singlepost->address));    //pr($street_name);        $pos2=strpos($snum,"-");    if($pos2 !== false){ $snum2 = substr($snum,$pos2+1,strlen($snum));     $snum= substr($snum, 0, $pos);        } $value['street_number']=$snum; $value['street_number2']=$snum2;    $value['street_name']=$sname;                     $value['prop_id']=$singlepost->id;    $property[$singlepost->id]['street_number']=ucfirst($snum);    

Create json file in php

 include('dbconnection/db_config.php'); $role = $_GET['role']; $mobile = $_GET['mobile']; $rs = "select * from tbl_users where role='$role' and mobile_number='$mobile'"; $result = mysqli_query($con,$rs); $data = mysqli_num_rows($result); $response = array(); if($data >= 1) {  if(($_GET['role']!=""|| $_GET['role']!= null) && ($_GET['mobile']!=""|| $_GET['mobile']!= null))    {  while($results = mysqli_fetch_assoc($result))  { $role = $results['role']; $username = $results['username']; $firstname = $results['firstname']; $lastname = $results['lastname']; $password = $results['password']; $age = $results['age']; $email = $results['email']; $gender = $results['gender'];  }

Add image upload in ajax in WP

php file  <form id='edit_register' action='' method='post' enctype='multipart/form-data' /> <div class="form-row">                 <label>Upload Profile picture:</label>                 <span> <div id="image_preview"><img id="previewing" height="250" width="230" src="<?php if($events->picture==""){ echo site_url();?>/wp-content/themes/snappysitter/images/noimage.png" <?php } else { echo site_url();?>/wp-content/themes/snappysitter/images/profile/<?php echo $events->picture; ?>" <?php }?> /></div>                 <input type="file" name="file" id="file"  />                 </span> </div> </form>   <script> $(document).ready(function (e) { // Function to preview image after validation $(function() { $("#file").chang

Google Calender Event Plugin

<?php /*   Plugin Name: Google Calender Event Plugin   Plugin URI:   Description: This plugin provides add event on google calender   Version: 1.0   Author: Samrat   Author URI: http://www.edreamztech.com  */  global $samrat_db_version; $samrat_db_version = '1.0'; function samrat_install() {  global $wpdb;  global $samrat_db_version;  $charset_collate = $wpdb->get_charset_collate();  $sql = "CREATE TABLE IF NOT EXISTS `wp_google_calender_event_list` (   `id` int(11) NOT NULL AUTO_INCREMENT,   `google_event_id` varchar(255) NOT NULL,   `booking_id` int(11) NOT NULL,   `booking_type` int(11) NOT NULL,   PRIMARY KEY (`id`) ) $charset_collate;";  require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );  dbDelta( $sql );  add_option( 'samrat_db_version', $samrat_db_version ); } register_activation_hook( __FILE__, 'samrat_install' ); //add_menu_page( $page_title, $menu_title, $capability, $menu_slug, $function, $icon_url, $position );  

Add CS and JavaScript On WP admin Header

function samrat_admin_scripts() {             wp_register_style('main_admin', get_bloginfo('stylesheet_directory') . '/css/main_admin.css');             wp_register_style('jquery_ui_css', get_bloginfo('stylesheet_directory') . '/css/jquery-ui.css');             wp_register_script('jquery_ui_js', get_bloginfo('stylesheet_directory') . '/js/jquery-ui.js');             wp_register_script('custom_admin_js', get_bloginfo('stylesheet_directory') . '/js/custom-admin.js', array('jquery'));             wp_enqueue_style('main_admin');             wp_enqueue_style('thickbox');             wp_enqueue_script('thickbox');             wp_enqueue_style('jquery_ui_css');             wp_enqueue_script('jquery_ui_js');             wp_enqueue_script('custom_admin_js');             wp_localize_script('custom_admin_js', 'ajax_obj', array(

Add static block in left side in magento

Add below code Design->Layout Update XML <remove name="left.navigation.callout" /> <remove name="flash.header" /> <reference name="left">   <block type="cms/block" name="left.navigation.home.callout" before="left-callout">     <action method="setBlockId"><block_id>pochettes-category</block_id></action>   </block> </reference>

Create sidebar and widget in WordPress

<?php /**  * Contains all the functions related to sidebar and widget.  *  */ add_action( 'widgets_init', 'spacious_widgets_init'); /**  * Function to register the widget areas(sidebar) and widgets.  */ function spacious_widgets_init() {  // Registering main right sidebar  register_sidebar( array(   'name'     => __( 'Right Sidebar', 'spacious' ),   'id'      => 'spacious_right_sidebar',   'description'    => __( 'Shows widgets at Right side.', 'spacious' ),   'before_widget'  => '<aside id="%1$s" class="widget %2$s">',   'after_widget'   => '</aside>',   'before_title'   => '<h3 class="widget-title"><span>',   'after_title'    => '</span></h3>'  ) );  // Registering main left sidebar  register_sidebar( array(   'name'     => __( 'Left S