Dec 17

Apple in 2013: Five predictions

What will Apple do next? It’s the very secret sauce that keeps the company interesting, along with some very successful products.

Here are five predictions for the next 12 months as Apple heads into one of its most closely watched years yet.

Editor’s note: This is the first in a series of stories looking ahead at what’s to come from a handful of major technology companies, and technology categories. In the coming days CNET will do the same for Google, Facebook, Microsoft, Amazon, and others. Read More…

Dec 17

Hackers hit Westboro Baptist Church after Newtown threat

A group attached to the online hacktivist group Anonymous claims to have hacked the Web site of the Westboro Baptist Church in response to plans by the controversial church to picket the funerals of those massacred Friday at a school in Newtown, Conn.

As part of a campaign dubbed #OpWestBoro, KY Anonymous said yesterday it posted the personal information belonging to members of the extremist organization, which is best known for conducting protests designed to disrupt the funerals of members of the military killed in action. The data dump included the names, phone numbers, e-mail addresses, and physical addresses of dozens of alleged members of the religious organization. The group did not indicate where or how it acquired the data.  Read More…

 

Dec 16

10 Tech CEOs Who Could Be Fired Now

Bangalore: CEOs are at helm of the company and so are credited with all things, good or bad, the company goes through. More than often they have to captain a ship out of mighty storm. Some pull trough and some fizzle out. The CEOs who failed to pull through, had to put up with “hot seat” before they were actually relieved of their positions. Read to know such 10 CEOs who were in hot seats, as compiled by Business Insider. Read More…

Nov 25

WordPress and Ajax calls

WordPress and ajax calls!!! Let me first explain you the situation. You have created one plugin and in this plugin one of your functionality need some ajax functionality mean you want to do something without refreshing the page like voting(like/dislike article), ajax sign in functionality.

After research alot and read several articles I understood that there are several ways to do a ajax call in WordPress like:
1: Use admin-ajax.php file for ajax call.
2: Include wp-load.php file in your ajax call file.
3: Include wp-config.php file with defining ‘SHORTINIT’ as TRUE.

Disadvantage of above ways:

- Site performance decreasing marginally due load the WP environment more than once.

- In first way is_admin() function will always get TRUE  even though you are in front-end.

Related links:
http://wordpress.stackexchange.com/questions/30638/determining-whether-its-a-ajax-call-from-front-end-or-from-back-end
http://codex.wordpress.org/AJAX_in_Plugins#Ajax_on_the_Viewer-Facing_Side
http://ottodestruct.com/blog/2010/dont-include-wp-load-please/

Now let say one situation you are working on a project in which you need several ajax functionality for all these you have created one common .PHP file and include wp-load.php or wp-config.php file and do your job. Now in future someone else going to work on this project and want to create some new ajax functionality as the new developer not aware about your file s/he will create a new .PHP and include wp-load.php or wp-config.php file and do his/her own job. So now What is the status of your site performance? What is the time complexity of your site? Think !!!

So, is there any other way to perform a ajax call without decreasing the site performance. Yes, there is a nice, tricky and easy way to do this.

Let us do a test:

Step1: Login as admin.
Step2: Create a page(say title My Ajax Test).
Step3: Note this page slug here slug is my-ajax-test
or
Step3: Note this page ID.
Step4: Create one file with name page-PAGEID.php or page-PAGESLUG.php and put it in your current theme root directory.
Step5: Provide this created page’s url for ajax functionality.
Step6: Write code in the above created file, in this file you have access to all WordPress functions, for ajax functionality.
Step7: DONE :)

What are you thinking, is not a good and perfect way to do ajax call in WordPress?

Now what if you want to create a plugin in which you need to implement some ajax functionality and plugin needs to be portable?

In this case create a page using code and create a page-PAGEID.php file in your current theme root directory. Place you ajaxed php code in this file using PHP file handeling functions.

I have created one sample plugin which will help you to understand this more clearly.

How to use the above plugin:
- Install the plugin.

- Goto widget section.

- Drag the ‘WordPress Better Ajax’ widget to any sidebar.

- Goto front end and click on ‘Click Me’.

Advantages:

- This procedure will not decrease your site performance.

- In a single file you can do all your ajax calls.

- If you directly access this page then it will give you a message indicating that you are in  wrong place.

Please comment what you are think about this.

Nov 22

How to create a order In Drupal programmatically

Today I got one strange requirement from my client and that is he has a Drupal website which is combined with NetSuite(NS), and he wants that if he create any order at NS end then this order will be create at Drupal end using web-services. So now the first question  ”How to create a order In Drupal programmatically”.

Following are the steps:

Step1: Create an new order with the help of below code:

// Create the new order in checkout status.
$order = commerce_order_new($uid, 'pending');

Step2: Load products which you want to add in your news order with the help of below code:

$product = commerce_product_load($product_id);
$line_item = commerce_product_line_item_new($product, 1, $order->order_id, array());
commerce_line_item_save($line_item);

Note: You can do the same for multiple products in a single order.

Step3: Wrap up the order with the help of below code:

$order_wrapper = entity_metadata_wrapper('commerce_order', $order);
$order_wrapper->commerce_line_items[] = $line_item;

Step4: Save the order to database:

commerce_order_save($order);

Step5: Done :)

Code together:

$uid = 'USER_ID';
$product_id = 'PRODUCT_ID';

$order = commerce_order_new($uid, ‘pending’);

$product = commerce_product_load($product_id);
$line_item = commerce_product_line_item_new($product, 1, $order->order_id, array());
commerce_line_item_save($line_item);

$order_wrapper = entity_metadata_wrapper(‘commerce_order’, $order);
$order_wrapper->commerce_line_items[] = $line_item;

commerce_order_save($order);

Summery:

Create one link using hook_menu() and call a custom ‘page callback’ function and add the above code in this custome function and execute the newly created link in browser.

Nov 09

How to make compatible nextgen gallery with AWS plugin

From few peoples I heard that nextgen gallery plugin is not working with AWS plugin as it should and asking me How to make compatible nextgen gallery with AWS plugin? So I have work around it and come out with some solution explaining below:

- Create gallery and add images as per the rule of NGG.
- Show your created gallery as per the rule of NGG.
- Now find out the ID of the div in which all your gallery images are present.
- Put this ID in “AWS Options” admin form’s first field named “No ajax container IDs”.

- Now add the below code in AWS plugins ajaxify.js file just before the "$body.removeClass('loading');"(at line 179)
scriptNode = document.createElement('script');
contentNode.appendChild(scriptNode);
scriptNode.setAttribute('src', rootUrl + 'wp-content/plugins/nextgen-gallery/js/jquery.cycle.all.min.js');

scriptNode = document.createElement(‘script’);
contentNode.appendChild(scriptNode);
scriptNode.setAttribute(‘src’, rootUrl + ‘wp-content/plugins/nextgen-gallery/js/ngg.slideshow.min.js’);

scriptNode = document.createElement(‘script’);
contentNode.appendChild(scriptNode);
scriptNode.setAttribute(‘src’, rootUrl + ‘wp-content/plugins/nextgen-gallery/shutter/shutter-reloaded.js’);

that’s it :)
- Example site link: http://www.youngtechleads.com/development/ngg-aws/

Nov 07

How to access Drupal functions and sesions in a stand alone PHP script

If you want to access Drupal functions and sessions in your stand alone PHP scripts which is present any where in your project directory then how you will do this?

Let say you are going to create one websevices in drupal thats mean you have to create one PHP stand alone file then how you will access the Drupal functions?

First of all I am clearing this that this solution is for Drupal 7, not sure this will work in Drupal 6 or not, as I have not tested this in Drupal 6 environment.

Below are the code you have to write in you PHP stand alone file.

$path = getcwd();
$pos = strpos($path, 'sites');
$path = substr($path, 0, $pos);
$path = explode('\\', $path);

$length = sizeof($path);
unset($path[$length - 1]);
$path = implode('/', $path);

// Get the base path
define('DRUPAL_ROOT', $path);

//Include the bootstrap file for using the DRUPLA function in our file
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

Now you can access any function of Drupal 7 in this stand alone PHP file :)