Disable delete for Woocommerce order

I have some problem recently with Woocommerce order being deleted by Admin and we have no idea who did it. And that annoys me. Hence, i went ahead and disable Woocommerce delete for any order for all users. Pretty much i do not want any delete to happen for any order regardless it is intentionally or accidentally.

Disable Woocommerce Delete

In order to disable woocommerce delete for order, you need to hook in to the 2 action hook which is wp_tash_post and before_delete_post as shown below,

// disable delete entirely
function restrict_post_deletion($post_ID){
    $type = get_post_type($post_ID);
    if($type == 'shop_order'){
        echo "You are not authorized to delete this page.";
        exit;
    }
}
add_action('wp_trash_post', 'restrict_post_deletion', 10, 1);
add_action('before_delete_post', 'restrict_post_deletion', 10, 1);

what the above does is to get the post_id of the post you are deleting and see what type it is. If the type if a shop_order, do not allow them to delete by exiting the script entirely and show a message to the user so that they will stop doing silly things.

Share

Woocommerce After Checkout Hook

Here is another Woocommerce hook that i used recently that is directly call after checkout but before an order is made, it is a Woocommerce after checkout hook. In this case, you can add more validation into it to prevent the order from being creating it. To do this, all you need to do is use the hook call 'woocommerce_after_checkout_validation' which gets call after checkout validation is made.

  add_action( 'woocommerce_after_checkout_validation', 'remove_item_cart_session_expired' );
  function remove_item_cart_session_expired(){
    global $woocommerce;
    $data = WC()->session->get('mypersonalsession');
    if(!$data){
      $woocommerce->cart->empty_cart();
      wc_add_notice( __("<strong>ERROR:</strong> Code 1010 - Your session expired. Please reorder again", "test"), "error" );
    }

In this case, the validation is already completed but my session has expired. So i added an error notice so that my team can look into the error code and figure out what has gone wrong with this particular order. Of course, i emepty the cart so that the order cannot be create!

Share

Woocommerce After an Order Before Payment Hook

There are times when you want to do some action like sending the order info to another database or third party integration before payment took place. of course, after payment took place, you might still initial another type of hook which is not explain here, there are tons of them if you google around. However, before a payment is made and after a checkout is place, an order is created. This hook is often ignored and not mention around. And this is the Woocommerce hook i am going to demonstrate here.

2 Woocommerce action hook after an order is made

There are actually two action hook that you can use here which are

woocommerce_checkout_order_processed
woocommerce_new_order

Both this hook, allows you to initial your custom function immediately after an order is made such as the one below,

  add_action( 'woocommerce_checkout_order_processed', 'my_status_pending',  1, 1  );

or

  add_action( 'woocommerce_new_order', 'my_status_pending',  1, 1  );

Do bear in mind that the priority here is placed at the highest as compare to the default 10. If you just use the default priority, the chances of your payment getting directly marked as paid rather than going through the normal process of Woocommerce is high. It happens to me as i couldn't figure out how come all order are being marked as paid without going through any payment selected. It is all due to the action hook used above which you have to take note of the priority to prevent yourself losing money due to unpaid invoice marked as paid automatically.

New order hook

The argument parameter is marked as 1 which is the default since we only really need the order id of the hook as shown below,

add_action( 'woocommerce_new_order', 'my_status_pending',  1, 1  );
function my_status_pending($order_id){
// do your magic here
}

Do remember to NOT place any $woocommerce->cart->empty_cart() sentence within these methods as it will remove the item in the cart and leave other checkout method unable to proceed further. Leave the empty_cart instruction to the payment gateway to handle it.

Share

328 Lines of WordPress Ping List for fastest indexing of new post for 2015

Wondering how each website gets their website indexed by Google and other search engine quick and fast? In WordPress, all you need to do is to place these WordPress ping list to the Settings->Writing->Update Services as shown below,

Screen Shot 2015-09-20 at 2.46.24 PM

then copy the list below and paste it into the textarea


http://rpc.pingomatic.com
http://1470.net/api/ping
http://a2b.cc/setloc/bp.a2b
http://api.feedster.com/ping
http://api.moreover.com/ping
http://api.moreover.com/RPC2
http://api.my.yahoo.co.jp/RPC2
http://api.my.yahoo.com/ping
http://api.my.yahoo.com/RPC2
http://api.my.yahoo.com/rss/ping
http://audiorpc.weblogs.com/RPC2
http://bblog.com/ping.php
http://bing.com/webmaster/ping.aspx
http://bitacoles.net/notificacio.php
http://bitacoles.net/ping.php
http://bitacoras.net/ping
http://blo.gs/ping.php
http://blog.goo.ne.jp
http://blog.goo.ne.jp/XMLRPC
http://blog.with2.net/ping.php
http://blog.youdao.com/ping/RPC2
http://blogbot.dk/io/xml-rpc.php
http://blogdb.jp
http://blogdb.jp/xmlrpc
http://blogdigger.com/RPC2
http://blogmatcher.com/
http://blogmatcher.com/u.php
http://blogoole.com/ping/
http://blogoon.net/ping/
http://blogpeople.net/ping
http://blogpeople.net/servlet/weblogUpdates
http://blogping.unidatum.com/RPC2
http://blogpingr.de/ping/rpc2
http://blogroots.com/tb_populi.blog?id=1
http://blogs.yandex.ru/
http://blogsearch.google.ae/ping/RPC2
http://blogsearch.google.at/ping/RPC2
http://blogsearch.google.be/ping/RPC2
http://blogsearch.google.bg/ping/RPC2
http://blogsearch.google.ca/ping/RPC2
http://blogsearch.google.ch/ping/RPC2
http://blogsearch.google.cl/ping/RPC2
http://blogsearch.google.co.cr/ping/RPC2
http://blogsearch.google.co.hu/ping/RPC2
http://blogsearch.google.co.id/ping/RPC2
http://blogsearch.google.co.il/ping/RPC2
http://blogsearch.google.co.in/ping/RPC2
http://blogsearch.google.co.it/ping/RPC2
http://blogsearch.google.co.jp/ping/RPC2
http://blogsearch.google.co.ma/ping/RPC2
http://blogsearch.google.co.nz/ping/RPC2
http://blogsearch.google.co.th/ping/RPC2
http://blogsearch.google.co.uk/ping/RPC2
http://blogsearch.google.co.ve/ping/RPC2
http://blogsearch.google.co.za/ping/RPC2
http://blogsearch.google.com.ar/ping/RPC2
http://blogsearch.google.com.au/ping/RPC2
http://blogsearch.google.com.br/ping/RPC2
http://blogsearch.google.com.co/ping/RPC2
http://blogsearch.google.com.do/ping/RPC2
http://blogsearch.google.com.mx/ping/RPC2
http://blogsearch.google.com.my/ping/RPC2
http://blogsearch.google.com.pe/ping/RPC2
http://blogsearch.google.com.sa/ping/RPC2
http://blogsearch.google.com.sg/ping/RPC2
http://blogsearch.google.com.tr/ping/RPC2
http://blogsearch.google.com.tw/ping/RPC2
http://blogsearch.google.com.ua/ping/RPC2
http://blogsearch.google.com.uy/ping/RPC2
http://blogsearch.google.com.vn/ping/RPC2
http://blogsearch.google.com/ping/RPC2
http://blogsearch.google.de/ping/RPC2
http://blogsearch.google.es/ping/RPC2
http://blogsearch.google.fi/ping/RPC2
http://blogsearch.google.fr/ping/RPC2
http://blogsearch.google.gr/ping/RPC2
http://blogsearch.google.hr/ping/RPC2
http://blogsearch.google.ie/ping/RPC2
http://blogsearch.google.in/ping/RPC2
http://blogsearch.google.it/ping/RPC2
http://blogsearch.google.jp/ping/RPC2
http://blogsearch.google.ki/ping/RPC2
http://blogsearch.google.kz/ping/RPC2
http://blogsearch.google.la/ping/RPC2
http://blogsearch.google.li/ping/RPC2
http://blogsearch.google.lk/ping/RPC2
http://blogsearch.google.lt/ping/RPC2
http://blogsearch.google.lu/ping/RPC2
http://blogsearch.google.md/ping/RPC2
http://blogsearch.google.mn/ping/RPC2
http://blogsearch.google.ms/ping/RPC2
http://blogsearch.google.mu/ping/RPC2
http://blogsearch.google.mv/ping/RPC2
http://blogsearch.google.mw/ping/RPC2
http://blogsearch.google.nl/ping/RPC2
http://blogsearch.google.no/ping/RPC2
http://blogsearch.google.nr/ping/RPC2
http://blogsearch.google.nu/ping/RPC2
http://blogsearch.google.pl/ping/RPC2
http://blogsearch.google.pn/ping/RPC2
http://blogsearch.google.pt/ping/RPC2
http://blogsearch.google.ro/ping/RPC2
http://blogsearch.google.ru/ping/RPC2
http://blogsearch.google.rw/ping/RPC2
http://blogsearch.google.sc/ping/RPC2
http://blogsearch.google.se/ping/RPC2
http://blogsearch.google.sh/ping/RPC2
http://blogsearch.google.si/ping/RPC2
http://blogsearch.google.sk/ping/RPC2
http://blogsearch.google.sm/ping/RPC2
http://blogsearch.google.sn/ping/RPC2
http://blogsearch.google.st/ping/RPC2
http://blogsearch.google.tk/ping/RPC2
http://blogsearch.google.tl/ping/RPC2
http://blogsearch.google.tm/ping/RPC2
http://blogsearch.google.to/ping/RPC2
http://blogsearch.google.tp/ping/RPC2
http://blogsearch.google.tt/ping/RPC2
http://blogsearch.google.tw/ping/RPC2
http://blogsearch.google.us/ping/RPC2
http://blogsearch.google.vg/ping/RPC2
http://blogsearch.google.vu/ping/RPC2
http://blogsearch.google.ws/ping/RPC2
http://blogshares.com/rpc.php
http://blogsnow.com/ping
http://blogstreet.com/xrbin/xmlrpc.cgi
http://blogupdate.org/ping/
http://bulkfeeds.net
http://bulkfeeds.net/rpc
http://catapings.com/ping.php
http://coreblog.org/ping
http://coreblog.org/ping/
http://effbot.org/rpc/ping.cgi
http://feedburner.google.com/fb/a/pingSubmit?bloglink=http%3A%2F%2Fdomainname.com
http://feedburner.google.com/fb/a/pingSubmit?bloglink=http%3A%2F%2Fyourwebsite.com
http://feedsky.com/api/RPC2
http://fgiasson.com/pings/ping.php
http://geourl.org/ping
http://geourl.org/ping/
http://hamo-search.com/ping.php
http://holycowdude.com/rpc/ping
http://holycowdude.com/rpc/ping/
http://imblogs.net/ping/
http://ipings.com
http://lasermemory.com/lsrpc/
http://mapufacture.com/georss/ping/api
http://mod-pubsub.org
http://mod-pubsub.org/kn_apps/blogchatt
http://mod-pubsub.org/knapps/blogchatt
http://mod-pubsub.org/ping.php
http://news2paper.com/ping
http://newsblog.jungleboots.org/ping.php
http://newsisfree.com/RPCCloud
http://packetmonster.net/xmlrpc.php
http://ping.amagle.com
http://ping.amagle.com/
http://ping.bitacoras.com
http://ping.bitacoras.com/
http://ping.blo.gs
http://ping.blo.gs/
http://ping.blogg.de/
http://ping.bloggers.jp/rpc
http://ping.bloggers.jp/rpc/
http://ping.blogmura.jp/rpc/
http://ping.blogoon.net
http://ping.blogoon.net/
http://ping.blogs.yandex.ru/RPC2
http://ping.cocolog-nifty.com/xmlrpc
http://ping.exblog.jp/xmlrpc
http://ping.fakapster.com/rpc
http://ping.fc2.com
http://ping.fc2.com/
http://ping.feedburner.com
http://ping.feeds.yahoo.com/RPC2/
http://ping.groove-cast.com/ping.php
http://ping.kutsulog.net
http://ping.kutsulog.net/
http://ping.myblog.jp
http://ping.namaan.net/rpc
http://ping.pubsub.com/ping
http://ping.rootblog.com/rpc.php
http://ping.rss.drecom.jp
http://ping.rss.drecom.jp/
http://ping.snap.com/ping/RPC2
http://ping.speenee.com/xmlrpc
http://ping.syndic8.com/xmlrpc.php
http://ping.weblogalot.com
http://ping.weblogalot.com/rpc.php
http://ping.weblogs.se
http://ping.weblogs.se/
http://ping.wordblog.de
http://ping.wordblog.de/
http://pinger.blogflux.com/rpc
http://pingoat.com/
http://pingoat.com/goat/RPC2
http://pingoo.jp/ping/
http://pingqueue.com/rpc/
http://popdex.com/addsite.php
http://r.hatena.ne.jp/rpc
http://rcs.datashed.net
http://rcs.datashed.net/RPC2
http://rcs.datashed.net/RPC2/
http://rcs.salon.com/RPC2
http://rpc.blogbuzzmachine.com/RPC2
http://rpc.bloggerei.de/
http://rpc.bloggerei.de/ping/
http://rpc.blogrolling.com
http://rpc.blogrolling.com/pinger
http://rpc.blogrolling.com/pinger/
http://rpc.britblog.com
http://rpc.britblog.com/
http://rpc.icerocket.com:10080
http://rpc.icerocket.com:10080/
http://rpc.newsgator.com/
http://rpc.odiogo.com/ping/
http://rpc.pingomatic.com
http://rpc.pingomatic.com/
http://rpc.reader.livedoor.com/ping
http://rpc.tailrank.com
http://rpc.tailrank.com/feedburner/RPC2
http://rpc.technorati.com/ping
http://rpc.technorati.com/rpc/ping
http://rpc.technorati.jp/rpc/ping
http://rpc.twingly.com
http://rpc.twingly.com/
http://rpc.urlfan.com/ping
http://rpc.weblogs.com
http://rpc.weblogs.com/pingSiteForm?name=YourWebsite&url=http%3A%2F%2Fyourwebsite.com
http://rpc.weblogs.com/pingSiteForm?name=YourWebsite&url=http%3A%2F%domainname.com
http://rpc.weblogs.com/RPC2
http://rpc.wpkeys.com
http://serenebach.net/rep.cgi
http://services.newsgator.com/ngws/xmlrpcping.aspx
http://signup.alerts.msn.com/alerts-PREP/submitPingExtended.doz
http://snipsnap.org/RPC2
http://submitblogs.com/
http://syndic8.com/xmlrpc.php
http://thingamablog.sourceforge.net/ping.php
http://topicexchange.com
http://topicexchange.com/RPC2
http://topicexchange.com/RPC2eping.php
http://trackback.bakeinu.jp/bakeping.php
http://wasalive.com/ping/
http://weblogues.com/ping/
http://weblogues.com/RPC/
http://www.2bet.com/
http://www.2rss.com
http://www.a2b.cc
http://www.a2b.cc/setloc/bp.a2b
http://www.bitacoles.net/ping.php
http://www.blogarama.com/
http://www.blogbits.com/
http://www.blogcatalog.com/
http://www.blogdex.net/
http://www.blogdigger.com
http://www.blogdigger.com/RPC2
http://www.blogexplosion.com
http://www.bloggernity.com/
http://www.bloglines.com/ping
http://www.blogoole.com/ping/
http://www.blogoon.net/ping
http://www.blogoon.net/ping/
http://www.blogpeople.net
http://www.blogpeople.net/ping
http://www.blogpeople.net/servlet/weblogUpdates
http://www.blogpulse.com/submit.html
http://www.blogroots.com
http://www.blogroots.com/tb_populi.blog?id=1
http://www.blogroots.com/tbpopuli.blog?id=1
http://www.blogsdominicanos.com/ping
http://www.blogsdominicanos.com/ping/
http://www.blogshares.com
http://www.blogshares.com/rpc.php
http://www.blogsnow.com/ping
http://www.blogstreet.com
http://www.blogstreet.com/xrbin/xmlrpc.cgi
http://www.blogwise.com/
http://www.catapings.com/ping.php
http://www.feedblitz.com/f/f.fbz?XmlPing
http://www.feedsky.com/api/RPC2
http://www.feedster.com/
http://www.feedsubmitter.com
http://www.globeofblogs.com/
http://www.holycowdude.com/rpc/ping/
http://www.imblogs.net/ping/
http://www.lasermemory.com
http://www.lasermemory.com/lsrpc
http://www.lasermemory.com/lsrpc/
http://www.linksboy.com/
http://www.lsblogs.com/
http://www.mod-pubsub.org/kn_apps/blogchatter/ping.php
http://www.mod-pubsub.org/knapps/blogchatter/ping.php
http://www.mod-pubsub.org/ping.php
http://www.mod-pubsub.orgping.php
http://www.newsisfree.com
http://www.newsisfree.com/RPC
http://www.newsisfree.com/RPCCloud
http://www.newsisfree.com/xmlrpctest.php
http://www.octora.com/add_rss.php
http://www.ohlinks.com
http://www.pingerati.net
http://www.pingmyblog.com
http://www.popdex.com
http://www.popdex.com/addsite.php
http://www.readablog.com/
http://www.rogerlinks.com/linker/index.shtml
http://www.snipsnap.org
http://www.snipsnap.org/RPC2
http://www.syndic8.com/xmlrpc.php
http://www.wasalive.com/ping/
http://www.weblogalot.com/ping
http://www.weblogs.com/RPC2
http://www.weblogues.com
http://www.weblogues.com/RPC
http://www.weblogues.com/RPC/
http://www.xianguo.com/xmlrpc/ping.php
http://www.zhuaxia.com/rpc/server.php
http://xianguo.com/xmlrpc/ping.php
http://xmlrpc.blogg.de
http://xmlrpc.blogg.de/
http://xmlrpc.bloggernetz.de/RPC2
http://xping.pubsub.com/ping
http://xping.pubsub.com/ping/
http://xping.pubsub.comping/
http://zhuaxia.com/rpc/server.php
http://zing.zingfast.com
https://blogs.yandex.ru/pings/
https://ping.blogs.yandex.ru/RPC2

Once you do this, your WordPress new post will ping all the above list so that other search engines are notify and can come fetch your new content asap!

Share

Top 13 Plugins for debugging WordPress problems

Debugging WordPress problems? There are times when you really want to know what is causing your website to load slowly. Especially when your web hosting provider started to warn you about your server causing problems for others. In this case, what should you do? You can easily debug your problem with the following debugging plugins to assist yourself to find the root cause of your problem!

P3 (Plugin Performance Profiler)

screenshot-2
This plugin creates a profile of your WordPress site's plugins' performance by measuring their impact on your site's load time. Often times, WordPress sites load slowly because of poorly configured plugins or because there are so many of them. By using the P3 plugin, you can narrow down anything causing slowness on your site.

This plugin uses the canvas element for drawing charts and requires requires Firefox, Chrome, Opera, Safari, or IE9 or later. This plugin will not work in IE8 or lower.

Log Deprecated Notices

screenshot-1
This plugin logs the usage of deprecated files, functions, and function arguments. It identifies where the deprecated functionality is being used and offers the alternative if available.

This is a plugin for developers. WP_DEBUG is not needed, though its general usage is strongly recommended. Deprecated notices normally exposed by WP_DEBUG will be logged instead.

This plugin also logs incorrect function usage, which WordPress started reporting in 3.1.

Query Monitor

screenshot-1 (1)
Query Monitor is a debugging plugin for anyone developing with WordPress. It has some advanced features not available in other debugging plugins, including automatic AJAX debugging and the ability to narrow down things by plugin or theme.

Debug Bar

Screen Shot 2015-09-18 at 4.11.02 AM
Adds a debug menu to the admin bar that shows query, cache, and other helpful debugging information.

Activity Log

screenshot-1 (2)
We all know that it’s relatively easy to analyze what your visitors are looking for while browsing your site. But there is really no easy way to know what registered users (say, with an Administrator account or even Editors) are doing on the dashboard of your site. How can you know if a post was deleted? or if a plugin was activated/deactivated? or if the active theme was changed? If you have tens of users or more, you really can’t know who did it. This plugin tries to solve this issue by tracking what users do on the dashboard of your WordPress site.

Debug Bar Slow Actions

screenshot-1
This plugin lists the top 100 slowest actions and filters during a page request in WordPress. It helps you figure out performance bottlenecks in themes and plugins.

Debug This

screenshot-1 (3)
This plugin gives WordPress super admins an easy way to peek under the hood of the front-face of a WordPress installation via the admin bar.

Debug This helps you minimize effort when trying to surface WP/PHP/Server data. Instead of hardcoding debug snippets or writing complex unit tests for small functionality, you can simply surface what you need right from the admin bar. If there's not a debug mode that addresses your need, create one with the functional Debug This API.

Debug Bar Cron

screenshot-1 (4)
Debug Bar Cron adds information about WP scheduled events to a new panel in the Debug Bar. This plugin is an extension for Debug Bar and thus is dependent upon Debug Bar being installed for it to work properly.

Total Security

screenshot-1 (5)
The Total Security plugin is the must-have tool when it comes security of your WordPress installation. The plugin monitors your website for security weaknesses that hackers might exploit and tells you how to easily fix them.

Postman SMTP Mailer/Email Log

screenshot-11
The Connectivity Test and intelligent Setup Wizard scan your SMTP server to detect firewall blocks and eliminate configuration mistakes. The handy Email Log shows which emails failed to send, and why. Even hosts that block the standard SMTP ports, like GoDaddy or Bluehost, can't stop your Gmail as Postman will deliver via HTTPS if it can't use SMTP.

Postman is not another WP Mail SMTP clone like WP Bank or Easy SMTP. It replaces the default WordPress SMTP library, PHPMailer, with the heavy-duty Zend_Mail. Never lose an email to PHP mail() again.

Debug Objects

screenshot-1 (1)
The Plugin Debug Objects provides the user, which has the appropriate rights, normally the administrator, a large number of information: query, cache, cron, constants, hooks, functions and many many more. Values and content get displayed at the frontend and backend of the blog, to analyze errors but also to better understand and develop with/for WordPress.

Debug Bar Transients

screenshot-1 (2)
Debug Bar Transients adds information about WordPress Transients to a new panel in the Debug Bar. This plugin is an extension for Debug Bar and thus is dependent upon Debug Bar being installed for it to work properly.

Debug Bar Post Types

screenshot-1 (6)
Debug Bar Post Types adds a new panel to the Debug Bar that displays detailed information about the registered post types for your site.

Share