If you are building a WordPress plugin, you can use these API functions to easily integrate CashTippr into your plugin. This gives you the capability to automatically hide/show contents and includes all of CashTippr’s advanced features such as daily/weekly/monthly full-access passes.
Functions:
|
1
2
3
4
5
6
7
8
9
|
/** * Get a tip button from within your own plugin code. * @param float $amount the amount the button will show. 0.0 means the default value from WP settings. * @param boolean $canEdit true if the user can edit the amount, default false * @param string $beforeBtnText Write a custom text before the button. You may use the {words} tag to to insert the * number of hidden words on this posts. Defaults to the text from WP settings if empty. * @return string the tip button HTML */function cashtippr_button(float $amount = 0.0, $canEdit = false, $beforeBtnText = ''): string |
|
1
2
|
<h1>My donation page</h1><div><?php echo cashtippr_button_hide('my text to hide', get_the_ID(), 2.5);?></div> |
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
/** * Get a tip button hiding text. This function is to be called within your own functions/plugins. * @param string $text the text to hide * @param int $postID The ID of the post/page you are currently showing. You can use get_the_ID(). * If this is not an actual post, but some dynamic content you want to hide, you must use * a self-generated unique ID. CashTippr needs this to check if the user has already paid for this hidden content. * @param float $amount the amount required to make the hidden content visible. 0.0 means the default value from WP settings. * @param boolean $canEdit true if the user can edit (increase) the amount, default false * @param string $beforeBtnText Write a custom text before the button. You may use the {words} tag to to insert the * number of hidden words. Defaults to the text from WP settings if empty. * @return string the tip button HTML */function cashtippr_button_hide(string $text, int $postID, float $amount = 0.0, $canEdit = false, $beforeBtnText = ''): string |
|
1
2
3
4
5
6
7
8
9
10
11
12
|
/** * Get a tip button blurring one or mre images. This function is to be called within your own functions/plugins. * @param string $imageText the HTML text of image(s) to blur * @param int $postID The ID of the post/page you are currently showing. You can use get_the_ID(). * If this is not an actual post, but some dynamic content you want to blur, you must use * a self-generated unique ID. CashTippr needs this to check if the user has already paid for this hidden content. * @param float $amount the amount required to make the blurred content visible. 0.0 means the default value from WP settings. * @param boolean $canEdit true if the user can edit (increase) the amount, default false * @param string $beforeBtnText Write a custom text before the button. Defaults to the text from WP settings if empty. * @return string the tip button HTML */function cashtippr_image_blur(string $imageText, int $postID, float $amount = 0.0, $canEdit = false, $beforeBtnText = ''): string |
|
1
2
3
4
5
6
7
|
/** * Shows a text shout form to post to Twitter. * @param float $amount the amount the button will show. 0.0 means the default value from WP settings. * @param string $title The title above the form where users can post. * @return string the form */function cashtippr_tweet(float $amount = 0.0, string $title = ''): string |
|
1
2
3
4
5
6
7
8
|
/** * Shows a text shout form and list with the most recent shouts. * @param float $amount the amount the button will show. 0.0 means the default value from WP settings. * @param string $title The title above the form where users can post. * @param string $listTitle The title above the list of the most recent shouts. * @return string the form and list HTML */function cashtippr_shout(float $amount = 0.0, string $title = '', string $listTitle = ''): string |
|
1
2
3
4
5
6
7
8
|
/** * Shows an image shout form and list with the most recent shouts. * @param float $amount the amount the button will show. 0.0 means the default value from WP settings. * @param string $title The title above the form where users can post. * @param string $listTitle The title above the list of the most recent shouts. * @return string the form and list HTML */function cashtippr_shout_image(float $amount = 0.0, string $title = '', string $listTitle = ''): string |
Hooks:
Actions:
|
1
2
3
4
|
do_action('cashtippr_admin_menu', CashtipprAdmin $admin);/*Fired after the admin menu in WP navbar is added.*/ |
|
1
2
3
4
|
do_action('cashtippr_admin_notices');/*Fired before showing admin notices (messages/warnings in /wp-admin/). Use this hook to add your own messages by just printing their HTML.*/ |
|
1
2
3
4
5
6
|
do_action('cashtippr_adblock_detected');/*Fired when a visitor has AdBlock enabled. The hook is fired in the context of the user,so you can access variables such as $_SERVER etc. to get more information about the user.Use this hook to take server-side actions/statistics for AdBlock.*/ |
Filters:
|
1
2
3
4
5
|
apply_filters('show_tippr_button', false, array $btnConf, array $attrs, string $content, string $tag);/*Fired when showing your own tip shortocde you registered to array(Cashtippr::getInstance(), 'showTipprButton').This filter must return true if the shortcode has been processed.*/ |
|
1
2
3
4
5
|
apply_filters('cashtippr_restrict_post_before', string $content, bool $containsButton, bool $hasFullAccessPass, bool $reachedDonationGoal, bool $isTippedPost);/*Fired when automatically limiting the post by the max number of words setting.This filter must return the processed/restricted content.*/ |
|
1
2
3
4
5
|
apply_filters('cashtippr_js_config', array $cfg);/*Fired before the JavaScript variable cashtipprCfg is added to the HTML output.$cfg is an associative array where you can add your own data.*/ |
|
1
2
3
4
5
|
apply_filters('cashtippr_default_settings', array $defaults);/*Here you can add default settings for your addon.$defaults is an associative array with the setting-name as key and the default value as value.*/ |
|
1
2
3
4
5
6
|
apply_filters('cashtippr_settings_sanitizer', array $sanitizer, CTIP_Sanitizer $defaultSanitizer, CTIP_TemplateEngine $tpl, array $defaults, CTIP_Settings $settings);/*A filter to add optional sanitizers for your settings.Each array item must have the setting-name as key and a PHP callable tosanitize the input as value: function(mixed $newValue, string $settingName): mixed*/ |
JavaScript events:
|
1
2
3
4
|
window.ctipAdblockDetected = function () {/*your code*/};/*Called when the current vistor has AdBlock enabled. Implement this function to add custom messages, banners, etc. for those users.*/ |
