May 14, 2014

CORS – Cross-Origin Resource Sharing

CORS – Cross-Origin Resource Sharing How to enable CORS in your website? How to send cross site request through ajax? How to enable cross site jquery post? How to enable cross site jquery get? How to enable cross site jquery request? How to handle cross site requests? Try this in your .htaccess Header set Access-Control-Allow-Origin […]

May 7, 2014

Retrieve remote file size

Retrieve remote file size function retrieve_remote_file_size($url){ $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); curl_setopt($ch, CURLOPT_HEADER, TRUE); curl_setopt($ch, CURLOPT_NOBODY, TRUE); $data = curl_exec($ch); $size = curl_getinfo($ch, CURLINFO_CONTENT_LENGTH_DOWNLOAD); curl_close($ch); return formatSizeUnits($size); } function formatSizeUnits($bytes) { if ($bytes >= 1073741824) { $bytes = number_format($bytes / 1073741824, 2) . ‘ GB’; } elseif ($bytes >= 1048576) { $bytes = number_format($bytes […]

April 17, 2014

How to set cusutom favicon to WordPress admin?

How to set cusutom favicon to WordPress admin? function wdwd_admin_area_favicon() { $favicon = ‘path to favicon’; echo ‘ ‘; } add_action(‘admin_head’, ‘wdwd_admin_area_favicon’); add_action(‘login_head’, ‘imed_admin_area_favicon’ );

Fix for: Canada Shipping Post Add-on for Marketpress

Fix for: Canada Shipping Post Add-on for Marketpress !important: Make sure that you are testing with a product having weight. Filename: mp-canada-post.php Line Number: 613 (or near) Find the following code snippet: $shipping_meta[‘weight’] = (is_numeric($shipping_meta[‘weight’]) ) ? $shipping_meta[‘weight’] : 0; Now observe it that shouldn’t it be inside the foreach? See here foreach ($cart as […]

How to check parent function from the function called?

How to check parent function from the function called? function backtrace($i=1){ $callers=debug_backtrace(); return $callers[$i][‘function’]; }

How to mute WordPress Plugins updates?

How to mute WordPress Plugins updates? add_filter(‘site_transient_update_plugins’, ‘wdwd_remove_update_nag’); function wdwd_remove_update_nag($value) { unset($value->response[ plugin_basename(__FILE__) ]); return $value; }

How to hide WordPress plugins from list?

How to hide WordPress plugins from list? Objective: We have to hide this plugin from activated plugins list. e.g. Plugin Name: marketpress function wdwd_plugins_filter() { global $wp_list_table; $hidearr = array(‘marketpress/marketpress.php’); $myplugins = $wp_list_table->items; foreach ($myplugins as $key => $val) { if (in_array($key,$hidearr)) { unset($wp_list_table->items[$key]); } } } add_action( ‘pre_current_active_plugins’, ‘wdwd_plugins_filter’ );

How activate a WordPress plugin from your php script?

How activate a WordPress plugin from your php script? e.g. Plugin Name: marketpress if(is_admin()){ include_once( ABSPATH . ‘wp-admin/includes/plugin.php’ ); if ( !is_plugin_active( ‘marketpress/marketpress.php’ ) ) { do_action( ‘activate_’ . trim( ‘marketpress’ ) ); } }