INTRO
Several times ago, my Smells Like Facebook theme was suspended from being updated in WordPress Theme Directory. It’s still being available to download, but I can’t submit a new version, therefore the theme users can’t get a notification and auto update from their dashboard.
So I try how to override WordPress auto update check routine and make it check the latest version of Smells Like Facebook to my own server. Here’s how:
THE CODE
1. Exclude your theme from the auto update check
I took this from Mark Jaquith blog. This piece of code will exclude your theme when WordPress does a check to WordPress API server. In Smells Like Facebook 2.7, it looks like this:
function slf_prevent_wp_update($r, $url) { if ( 0 !== strpos( $url, 'http://api.wordpress.org/themes/update-check' ) ) return $r; $themes = unserialize( $r['body']['themes'] ); unset( $themes[ 'smells-like-facebook' ] ); $r['body']['themes'] = serialize( $themes ); return $r; } add_filter( 'http_request_args', 'slf_prevent_wp_update', 5, 2 );
Change the ‘smells-like-facebook’ to your own theme name. Usually it’s a slug name of the theme name.
2. Create the ‘API’ server
Before creating the updating service, first you need to create a URL on your site that will provide the information of current version of your theme / plugin. Note that this page have to provide the link to download the new version.
As the example, for Smells Like Facebook, I create a URL in http://api.nazieb.com/smells-like-facebook/check_update which will show these:
2.7|https://nazieb.com/download/smells-like-facebook-2.7.zip
That line show 2 things; the current stable version of Smells Like Facebook and the link to download it. It’s separated by a pipeline (‘|’) because it will be exploded by the update function.
3. Make your own update check routine
After your theme is excluded from WordPress check routine, you have to make your own one. To do this, you have to know about WordPress pseudo-cron scheduling.
This piece of code will make your own schedule routine:
$next = wp_next_scheduled('slf_check_routine'); if ($next === false) wp_schedule_event(time(), 'hourly', 'slf_check_routine');
Explanation:
– the first line will check whether your routine has been scheduled. ‘slf_check_routine’ is the name of your routine action. The updating function will be hooked to this action.
– and then the second line will register your routine hourly if your routine isn’t scheduled yet
And then the main update function is:
function slf_check_update() { global $wp_version; if ( defined( 'WP_INSTALLING' ) ) return false; if(!function_exists('get_theme_data')) require_once( ABSPATH . 'wp-includes/theme.php' ); $theme = get_theme_data(WP_CONTENT_DIR . '/themes/smells-like-facebook/style.css'); $options = array( 'timeout' => ( ( defined('DOING_CRON') && DOING_CRON ) ? 30 : 3), 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' ) ); $response = wp_remote_get( "http://api.nazieb.com/smells-like-facebook/check_update/", $options ); list($version, $url) = explode('|', $response['body']); if($theme['Version'] == $version) return false; $theme_transient = get_site_transient('update_themes'); $theme_transient->response['smells-like-facebook'] = array( 'new_version' => $version, 'url' => 'http://smells-like-facebook.nazieb.com', 'package' => $url ); set_site_transient('update_themes', $theme_transient); } add_action('slf_check_routine', 'slf_check_update');
Note:
– The ‘url’ in theme transient is not the URL to download the new version. It’s the URL of information page of your theme / plugin. The URL to download is set to ‘package’
– To read more about WordPress Transient, read here
– Don’t forget to hook the function to your routine action
That’s all. Confusing huh? Sorry for my bad explanation, if you have any question leave it in comments.
50 replies on “How to Make Your Own Plugins/Themes Updating Service”
Knapa theme nya bisa di suspend? Menyalahi aturan kah?
LikeLike
@adit-nya niez
Katanya sih menyalahi license-nya Facebook 😐
LikeLike
@nazieb Emangnya menyalahi license-nya Facebook kerna judul tema ini punya trademark Facebook seperti yang dinyatakan pada terms yg ke-5.6 seperti berikut:
“6. You will not use our copyrights or trademarks (including Facebook, the Facebook and F Logos, FB, Face, Poke, Wall and 32665), or any confusingly similar marks, without our written permission.”
source: https://www.facebook.com/terms.php
LikeLike
wah…bisa buat nambah pngetahuan nih…. ^^
thx for the info…
sukses selalu…
Kunjungi juga website kami di http://www.hajarabis.com
Telp : 0341 – 8441777
“We make you online..!”
LikeLike
[…] still has a lot of things to do anyway. But don’t worry, using its own Upgrade Feature which is separated from WordPress default routine, you’ll be notified when a new version is […]
LikeLike
mas nazib, aduh gmana sih supaya loading blognya ceepet aku juga wpOrg user
pake super cache kok ke frozen
mohon bantuan
xabduh.com
LikeLike
Love all the info. Thanks for being informative.
LikeLike
Artikel yang menarik 🙂
LikeLike
Sounds like a very cool theme, and thanks for the coding. I’ll be sure to check it out.
LikeLike
i like this terms
LikeLike
cantik banget blog ni mas. Easy to load and user friendly.
salam kenal sob. ^_^
I also have created a new wordpress plugin. Please leave me some feedback or suggestion about my new wordpress plugin. makasih ya mas 🙂
LikeLike
[…] without TwentyTen.It still has a lot of things to do anyway. But don’t worry, using its own Upgrade Feature which is separated from WordPress default routine, you’ll be notified when a new version is […]
LikeLike
mantap bener nih,, thanks tutornya
LikeLike
Thanks for the useful info. I’ve been looking into making this kind of service for a while now.
LikeLike
Wah, infonya keren Gan, izin belajar… Semoga semakin maju Gan…
LikeLike
I love to read and visit this kind of blog. When I read this kind of article, it seems that I was there and I feel the place. Someday, when I have time to visit the places they have mentioned then I will already know what to do. Also, there are sites who post directions and advises when going in a the features place.
LikeLike
I am starting building a site and I always browse to the internet to search on how to build a site. Thanks for this information and I realize that I need to build my own plugins and themes to have a unique and interesting site.
LikeLike
wah tambah pengetahuan ne kawan….makasih ya…
LikeLike
like the post….
LikeLike
it’s a great article to read n give so much information
LikeLike
artikel yang menarik ne, menambah pengetahuan juga…makasih ya buat infonya….harus belajar dulu ne…
LikeLike
Thx ya uda berbagi ilmunya ne….
LikeLike
[…] Link Posted on December 13, 2012 by admin in Uncategorized. […]
LikeLike
Mantap komandan… 🙂
LikeLike
kereen mas, tambah trus postingan – postingan yang berguna…
naju terus blogger Indonesia…
Jasa Desain Grafis | Jasa Pembuatan Website | Jasa Animasi
LikeLike
yes, I’m already try to it, and than its simple do it. great..
LikeLike
Sukses..
LikeLike
エミネムと のコンサート、実はアメリカのコンサート、け大物ア、前ですNY TIMESにもそれについで掲載されていました。
LikeLike
tambah pengetahuan nih. terimakasih..
LikeLike
makasih informasinya mas nazieb
LikeLike
oo ternyata bisa di suspend toh pluginnya..
makasih sob, berguna bangeet
LikeLike
Info yg keren mas…saya pengguna wp mas…untuk pengaturan seo yang paling update apa mas..caranya gmn ya?
LikeLike
Very good information to be able to add to my knowledge little by little thanks you all want to share information about a knowledge of this ..
LikeLike
sebuah info sangat bagus mempunyai makna dan isi yang menarik untuk di pelajari..
LikeLike
untuk pengaturan tema yang kita inginkan misalnya seperti design webnya itu juga seperti itu??? supaya bisa menarik pengunjung tetap stay di situs kita. untuk pengaturan tema yang kita inginkan itu seperti gimana ya.,. tolong di buatkan artikel yang caranya buat design thema gmna?? sebelumnya thanks buat pelajaran yang sangat power full ini., 🙂 saya tunggu updatannya . salam senyum 🙂
LikeLike
Test Comment Sorry Boss
LikeLike
informasi bagus untuk menambah pengetahuan dan bisa diterapkan dalam blog masing-masing
thanks sudah berbagi
LikeLike
enaknya pake wordpress bisa di custom apaan aja. hadeeeh sy malah baru tau kasusnya mas nazieb… terus semangat berkarya mas.
LikeLike
Hey all, only started to be responsive to your current blog site as a result of Yahoo and google, and discovered that it is genuinely educational. My business is going to watch out for the city. I’ll be grateful if you continue on that later on. Appear as healthy is going to be benefited from the composing. Many thanks!
LikeLike
makasih banyak infonya yaa
LikeLike
makasih banyak infonya yaa. semoga sukses
LikeLike
Nice Post…
LikeLike
trims info nya gan…
LikeLike
info yg menarik trmksh..
LikeLike
terimakasih mas tutornya..
LikeLike
ga ngerti 😦
LikeLike
nice post
LikeLike
great post
LikeLike
info yg menarik, Obat Hammer Of Thor
LikeLike
is this still working now?
LikeLike