Posts

Showing posts from 2013

WPML & Woocommerce: How to select product of other languages in PHP?

If you are looking for a way that, by using PHP, you want to find out what product ID of other languages are, here is the code: if(function_exists('icl_get_languages')){     $available_langs = icl_get_languages('skip_missing=0'); foreach($available_langs as $lang){ $lang_post_id = icl_object_id($existing_post_id, 'product', true, $lang['language_code']); if(empty($lang_post_id) == FALSE){ /** * Do whatever you want here... /**/ } } } Here is how this work: Check if WPML is installed by checking if icl_get_languages exists. I am getting all langs here (skip_missing=0). Use icl_get_languages to get ALL languages Use a loop to check existing language with language code. If that product exists, it will return a product ID, otherwise, it is NULL ( Source ). Use conditional statement to continue processing if $lang_post_id is not NULL Hope it helps someone.

Using wget bypass htaccess username password 401 authorization

Here is the command to access a website where using htaccess username and password to protect itself. wget -O /dev/null --user="_any_htaccess_user_name_" --password="_htaccess_user_password_" http://www.google.com Resource:   http://stackoverflow.com/questions/8841187/wget-and-htaccess-username-only By the way, you can use wget to simulate a visitor access to website.  Often time it is used to trigger a cron job. Another resource: http://pogidude.com/2011/use-linux-cron-to-trigger-wordpress-cron-scheduler/ http://bitswapping.com/2010/10/using-cron-to-trigger-wp-cron-php/ Hope it helps someone.

Wordpress - Separate PHP page call WPML function

If you just like me who need to create a new empty PHP page inside Wordpress, and you need to call that page inside wordpress, together with using WPML, here is the way:  Assume that your brand new PHP file is under wp-content/themes/your-theme/new_file.php This new_file.php will receive data from other wordpress page. Now: # require_once wp-load.php to use all wordpress functions  require_once dirname(dirname(dirname(dirname(__FILE__)))).'/wp-load.php'; if(!function_exists('any_new_function')){      function any_new_function(lang){          $lang = $_POST['lang_from_previous_wordpress_page'];          return $lang;     }      # if you are using WPML 3.0 or later, you will see this icl_set_current_language filter      # I am not sure if version prior to 3.0 will have it or not, just search in sitepress.class.php to find out.      add_filter('icl_set_current_language', 'any_new_function'); }  # Init this plugin, the constructio

In response to "8 Sentences That Drive Bosses Crazy"

In response to this article about "8 Sentences That Drive Bosses Crazy" Every employee said something for a reason and a history behind it.  If your employee said those to your boss, it is (most of the time) the boss problem not (always) employee. Here are why: 1. "Exactly how do you want me to do this?" Boss's best response: "I don't care how you do it, just get it done." Employee replied: Then don't ask me to give you a full report on why I am doing that later on, because you don't care. 2.  "This is my idea so I want full credit for it." Boss's best response: "If you want this to happen, we'll all need to own it." Employee replied: You are stealing my idea and claim that it is "us"?   3.  "I'll try to get it done on time." Boss's best response: "Do. Or do not. There is no try." Employee replied: DO NOT, unless you give us a REASONABLE schedule, or you tell

Definition of Selling - The Dan Sullivan Way

Dan Sullivan definition of Selling: Getting someone to intellectually engaged in the future result that is good for them and getting them to emotionally committed to an action to achieve that result .

Post Affiliate Pro - My Checklist

- Using Multi-tier commission: your affiliate should be associated with a campaign.  i.e. when you login to an affiliate account, you must see a campaign and banner available. - If you are using Private campaign AND multi-tier commission: MAKE SURE the parent aff and sub aff are all IN one private campaign.  Otherwise multi-tier commission would not display correctly.  It will ONLY display the one in that campaign, sub-affiliate is NOT calculated. - Using affiliate ID (a_aid) only without using banner (a_bid) seems not tracking at all.

What is Value? How to add more value to your customer?

I just wrote a blog post about what is value and how to add value to customer. Those are questions that are often told by a lot of marketers but not fully illustrated. Check this out:   What is Value? How do you add more value to your customer?

果皮止咳

果皮 + 瘦肉數條放入飯碗中,加飲用水入飯碗,放入已加水的鑊中。先大火煲滾鑊中水,待水滾後轉慢火煲/燉1小時。

Day 1 of Product marketing

I am responsible for promoting a product that is about cure cirrhosis.  I know that this product has a lot of potential, and therefore I am going to build something around it, using my marketing knowledge. I know that this is a good product, and it truly works.  So when you know that the product is good, the next step will be to let as many people know as possible. I will also use the ILoveMarketing.com 8 profit activators as the main guidance of how the marketing works. Before unit: Target market: People have cirrhosis and in the stage of NASA, and want to recover Ways to drive traffic: - PPC on Adwords, Facebook - Pay for article and share it on social media - Contact book author to write article - List buying? Funnel: Traffic drive to Facebook page Free report > list building 3 steps letter (Dan Kennedy) follow up During unit Direct them to ECommerce site in 3 steps letter Run a product launch after a period of time

WPML How to translate value in OptionTree?

WPML is a plugin that is used to translate wordpress text to different language. Warning: To understand how to translate values in OptionTree, you need to write PHP code, which means, you need to know how to program using PHP, how Wordpress Plugin works, and ideally, how to write a wordpress plugin.  Otherwise you will find very difficult to understand what the below content means. I am using WPML 2.8.2. And if you normally buy theme from ThemeForest.net, chance are you will see some themes that is using OptionTree to save theme value. However, there are situation when, you enter some display text in admin panel, and you want to translate those text. As of this writing, according to this reply , WPML is not compatible with OptionTree.  Although you can use some workarounds as described in that post, that workaround is actually OUTDATED and may not be applicable to you. To understand the solution, you need to understand how OptionTree works first. How OptionTree works?

TCPDF How to show/display Chinese Character?

Thanks to this article (in Simplified Chinese, updated new link), there is a way to embed a TTF that can display Chinese (Traditional and Simplify, and possibly Japanese). Environment:  TCPDF 6.0.020 PHP 5.3.8 Windows 7 The problem: If you follow this post that said: using cid0cs or cid0ct to display Chinese, it can display the character correctly, only to the extend that user installed a correct font package.  However, chances are other users who didn't install that package cannot view that PDF since there are several packages and versions of PDF viewer (mainly Adobe).  And even worse: even if user installed certain CJK font package, the PDF still not displayed correctly (show empty page). And according to the official TCPDF documentation about font : The fonts that could be not embedded are only the standard core fonts and CID-0 fonts . The solution: Again, thanks to the post above (in simplified Chinese), now developer can use a font that: Can display Chines

SSL and javascript from other site

Here's to confirm that, if your website is protected under SSL, while at the same time, you include javascript file from another website, that JS file will NOT be included (blocked). So if you found that your SSL-protected e-commerce website does not track statistic properly, chance are your javascript from another website is being blocked.  To verify, simply open javascript console to see the log. To avoid this problem: 1. Disable SSL in main site 2. Add SSL in another site 3. Move your JS file to SSL main site. If you are using PostAffiiatePro with WooCommerce, I recommended that you install PAP in e-commerce site.

[轉貼]天安門母親:“希望”已漸漸消失,“絕望”正漸漸逼近

Reference/Copied From:  http://iso.hrichina.org/hk/content/6711 天安門母親:“希望”已漸漸消失,“絕望”正漸漸逼近 ——紀念“六四”慘案二十四周年 天安門母親 今年2月28日天安門母親致函兩代會,題目是: “這是一個希望,但願它不再成為一次絕望” 。這表達了“六四”難屬的一個良好祈願。寫這句話到現在僅僅過去三個月, 但“希望”已漸漸消失,“絕望”正漸漸逼近。 中國社會如今瀰漫著一種普遍的絕望感。有論者指出:這個社會已經​​沒有一種信任了,誰是我們信賴的?領導人,我們不相信,領導人說的話我們不大相信。行業協會,我們不相信。報紙,我們也不相信。網絡,說什麼的都有,我們也不知道信誰的。知識分子,也是這個樣子。所以最後的結果就是,這個國家已經變成了一種普遍的信任喪失狀態。  “一個國家走到今天​​這一步,如果讓自己的國民都有這樣一種絕望感,實在是太可怕了” (賀衛方教授語)。 事實表明,在已經過去的將近四分之一世紀裡,中國的最高領導人從來都不是真正的 政治改革家 ,江澤民不是,胡錦濤不是,今天剛上台的習近平也不是。他們一個接著一個,像走馬燈似的,越走越遠,越走越離譜,一種瀰漫著的絕望感正從四面八方向國人襲來。從習近平先生在中共十八大後所表述的“ 兩個不能否定” ,我們看不到他對前三十年毛式共產主義原罪有過任何一點反思與懺悔,我們也看不到他對後三十年鄧式“跛腳改革”有過任何一點批評和問責,我們看到的恰恰是他大踏步地退回到毛式正統。他將前三十年與後三十年中最不得人心、最需要否定的東西糅合起來,要國人奉為圭臬,視若根本。這使得原先對他抱有政治改革期待的人們,頓時陷入了失望與絕望之中。 現在說一千,道一萬,都是多餘的。再過幾天就要到“六四”慘案二十四周年了。在這漫長的二十四年裡,我們天安門母親自1995年開始接連寫了36份致兩代會和國家領導人的公開信,以及公告、祭文, 至今石沉大海,沒有一句回應 。 在1995這一年,我們向兩代會提出:重新調查“六四”事件,公佈死者人數、死者名單;就每一位死者向其家屬作出個案交待,依法給予賠償;對“六四”慘案立案偵查、追究責任者刑責”(即 “真相、賠償、問責” )。這三項訴求始終沒有得到任何答复。 “六四”十週年的時候,我們向最高人民檢察院控告了大屠殺

Woocommerce how to get order status?

If you are writing plugin (like me) under Woocommerce 2.0 to get a list of order of particular order status, you will find that it does not exists in wp_posts and wp_postmeta. Simply put: All order status strings (e.g. completed, failed, on-hold etc) are stored in wp_terms Using wp_terms.term_id, you can find your order ID in wp_term_relationships.  In this table, order ID is called "object_id" You can now do a search on wp_posts using wp_term_relationships.object_id (wp_term_relationships.object_id is now post_id) You don't need to write SQL to do the above 3 steps, Wordpress has already provided similar functions to do this.  They are  get_term_by and get_objects_in_term .  Sample code below: $status = get_term_by( 'slug', sanitize_title( $_POST['order_status'] ), 'shop_order_status' ); $s = get_objects_in_term($status->term_id, 'shop_order_status'); var_dump($s); It will return order IDs in array, like: array

MaryEllen Tribby 10 Keys To A Great Offer

Some notes from this podcast in ILoveMarketing.com .  The 10 keys to a GREAT OFFER by MaryEllen Tribby : Ask yourself, is your offer: Specific Exclusive Valuable Unique Useful Relevant Possible Easy to acquire Urgent Guarantee If your offer matches all 10 keys here, you have a great offer. Always write your copy first, write all your ideas down, and create your product.

[Repost] The PCAT Formula for Helping People Make Changes with Hypnosis

Source:  http://conversational-hypnosis.com/articles/a69.html Conversational Hypnosis is an art for helping others to live happier, healthier and overall better lives.  One of the tools that you can use to help people to do this is called the PCAT Formula.  The PCAT Formula is a simple formula that you can use in any conversation to assist in making a change in the person you are talking to.  It is used for many different reasons but the base of those reasons is to overcome a hard time, or get past a hurdle in their lives. One of the most convenient aspects of the PCAT Formula is that it can be used in almost any conversation.  It is very simple to transition from a normal everyday conversation into the PCAT Formula.  This is helpful in that many times in normal everyday conversations you will be talking to a friend, client or family member and they will automatically tell you about what it is that is limiting them in their lives and then you can go to work undetected. You have

Application Loader doesn't let me choose my app to upload??

My config: XCode Version 4.6 (4H127) Mac OSX: 10.7.5 (Lion) GameSalad: 0.10.2 If you found that, you cannot select your exported app and upload it using Application Uploader, here is the trick: When you export, it should probably be a gray "ban" icon that cannot be opened.   You just need to zip it and make your app a ZIP file, and you upload that zip file in Application Uploader, and you should be fine. Don't complicate things: Right click the gray app icon and click "Compress <your_app_file>".  That's it! Then you upload the zip file instead of the app file.

Wordpress Custom Post Type created post not found?

If you use custom_post_type in wordpress, and you find that you can successfully create a custom post type in your back-end admin area, while you can also create a custom post in back-end  but you cannot see your created post, please check the following: In your  register_post_type  function, there is an argument called " publicly_queryable ", if you set it to false, you will find that you cannot see your page (return 404 not found). So set it to true to see your post. Update: It seems that another reason of 404 error is because of the permalink problem.  Please use register_activation_hook and register_deactivation_hook to call the function: flush_rewrite_rules(), it will help. Reference:  http://wordpress.org/support/topic/permalinks-404-with-custom-post-type?replies=40

host file windows 7

Here it is: C:\Windows\System32\drivers\etc or %systemroot%\system32\drivers\etc\ File name is: hosts You need to open notepad first and then choose the "hosts" file in order to edit it.

javascript check valid date (Pure javascript)

If you want to use pure javascript to check a date, here it is: The idea is coming from this post . Date.isValidDate= function(y,m,d){ if(typeof y != 'number') y = new Date().getFullYear(); if(typeof m != 'number') m = new Date().getMonth(); if(typeof d != 'number') d = new Date().getDate(); switch(m){ case 0: case 2: case 4: case 6: case 7: case 9: case 11: return new Date(y, m, d).getDate() <= 31; break; case 3: case 5: case 8: case 10: return new Date(y, m, d).getDate() <= 30; break; case 1: return new Date(y, m, d).getDate() <= 29; break; default: return false; break; } } Usage: Date.isValidDate(2012, 1, 29) => True    //Feb 29, 2012 Date.isValidDate(2012, 0, 31) => True    //Jan 31, 2012 Date.isValidDate(2013, 1, 29) => False    //Feb 29, 2013 Date.isValidDate(2012, 3, 31) => False    //Apr 31, 2013 Remind: m - Month in Javascript, ranging fro