Skip to main content

Posts

Showing posts from May, 2016

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,

Auto suggestion using Ajax, jQuery and PHP

jQuery PHP Ajax Autosuggest Search.html <input type="text" class="searchfield search_keyword"  placeholder="Search For Stocks" id="search_keyword_id">  <div id="result"></div>           <script type="text/javascript" src="//code.jquery.com/jquery-1.8.0.min.js"></script> <script type="text/javascript"> function set_item(x,y,z) {  var c = x+"    "+ y;  $('#search_keyword_id').val(c);  $('#stockcode').val(x);  $('#exchangeId').val(z); } $(function(){ $(".search_keyword").keyup(function() {     var search_keyword_value = $(this).val();     var dataString = 'search_keyword='+ search_keyword_value;     if(search_keyword_value!='')     {         $.ajax({             type: "POST",             url: "search.php",             data: dataString,             cache: false,        

Magento: How to select, insert, update, and delete data?

Magento: How to select, insert, update, and delete data? Magento execute custom query to insert data // fetch write database connection that is used in Mage_Core module $write = Mage::getSingleton('core/resource')->getConnection('core_write'); // now $write is an instance of Zend_Db_Adapter_Abstract $write->query("INSERT INTO tablename VALUES ('111','aaa','abc123')"); Execute custom query to fetch data $write = Mage::getSingleton('core/resource')->getConnection('core_write'); // now $write is an instance of Zend_Db_Adapter_Abstract $result = $write->query("SELECT * FROM  `pepitashop_catalog_product_entity` LIMIT 0 , 30 "); while ($row = $result->fetch() ) {  $categoryIds[] = $row['id']; //insert into an array } Getting data into phtml files/view files Method-1 // GETTING DATA FROM ANOTHER METHOD $resource = Mage::getSingleton('core/resource'); $readConnection = $resource-&

Folder download in zip format in php

<?php class zip {    private $zip;    public function __construct( $file_name, $zip_directory)    {         $this->zip = new ZipArchive();         $this->path = dirname( __FILE__ ) . $zip_directory . $file_name . '.zip';         $this->zip->open( $this->path, ZipArchive::CREATE );     }          /**      * Get the absolute path to the zip file      * @return string      */     public function get_zip_path()     {         return $this->path;     }              /**      * Add a directory to the zip      * @param $directory      */     public function add_directory( $directory )     {         if( is_dir( $directory ) && $handle = opendir( $directory ) )         {             $this->zip->addEmptyDir( $directory );             while( ( $file = readdir( $handle ) ) !== false )             {                 if (!is_file($directory . '/' . $file))                 {                     if (!in_array($file, array('.', '..')))   

For create custom post type and taxonomy with hierarchical url structure in WordPress

//For create custom post type and taxonomy with hierarchical url structure in WordPress need below plug-in with /%types%/%postname%/ //https://wordpress.org/plugins/custom-post-type-permalinks/  function crunchify_deals_custom_post_type() {  $labels = array(   'name'                => __( 'Deals' ),   'singular_name'       => __( 'Deal'),   'menu_name'           => __( 'Deals'),   'parent_item_colon'   => __( 'Parent Deal'),   'all_items'           => __( 'All Deals'),   'view_item'           => __( 'View Deal'),   'add_new_item'        => __( 'Add New Deal'),   'add_new'             => __( 'Add New'),   'edit_item'           => __( 'Edit Deal'),   'update_item'         => __( 'Update Deal'),   'search_items'        => __( 'Search Deal'),   'not_found'           => _