Freemius WordPress SDK
======================
[Monetization](https://freemius.com/wordpress/), [analytics](https://freemius.com/wordpress/insights/), and marketing automation platform for plugin & theme developers. Freemius empower developers to create prosperous subscription based businesses.
You can see some of the WordPress.org plugins & themes that are utilizing the power of Freemius here:
https://includewp.com/freemius/#focus
If you are a WordPress plugin or theme developer and you are interested to monetize with Freemius you can [sign-up here for free](https://dashboard.freemius.com/register/):
https://dashboard.freemius.com/register/
**Below you'll find the integration instructions for our WordPress SDK.**
## Code Documentation
You can find the SDK's documentation here:
https://freemius.com/help/documentation/wordpress-sdk/
## Initializing the SDK
Copy the code below and paste it into the top of your main plugin's PHP file, right after the plugin's header comment:
```php
<?php
// Create a helper function for easy SDK access.
function my_prefix_fs() {
global $my_prefix_fs;
if ( ! isset( $my_prefix_fs ) ) {
// Include Freemius SDK.
require_once dirname(__FILE__) . '/freemius/start.php';
$my_prefix_fs = fs_dynamic_init( array(
'id' => '1234',
'slug' => 'my-plugin-slug',
'menu_slug' => 'my_menu_slug', // You can also use __FILE__
'public_key' => 'pk_MY_PUBLIC_KEY',
'is_live' => true,
'is_premium' => true,
'has_addons' => false,
'has_paid_plans' => false,
// Set the SDK to work in a sandbox mode (for development & testing).
// IMPORTANT: MAKE SURE TO REMOVE SECRET KEY BEFORE DEPLOYMENT.
'secret_key' => 'sk_MY_SECRET_KEY',
) );
}
return $my_prefix_fs;
}
// Init Freemius.
my_prefix_fs();
?>
```
- **1234** - Replace with your plugin's ID.
- **pk_MY_PUBLIC_KEY** - Replace with your plugin's public key.
- **sk_MY_SECRET_KEY** - Replace with your plugin's secret key.
- **my-plugin-slug** - Replace with your plugin's WordPress.org slug.
- **my_menu_slug** - Replace with your admin dashboard settings menu slug.
## Usage example
You can call the SDK by using the shortcode function:
```php
<?php my_prefix_fs()->get_upgrade_url(); ?>
```
Or when calling Freemius multiple times in a scope, it's recommended to use it with the global variable:
```php
<?php
global $my_prefix_fs;
$my_prefix_fs->get_account_url();
?>
```
## Adding license based logic examples
Add marketing content to encourage your users to upgrade for your paid version:
```php
<?php
if ( my_prefix_fs()->is_not_paying() ) {
echo '<section><h1>' . esc_html__('Awesome Premium Features', 'my-plugin-slug') . '</h1>';
echo '<a href="' . my_prefix_fs()->get_upgrade_url() . '">' .
esc_html__('Upgrade Now!', 'my-plugin-slug') .
'</a>';
echo '</section>';
}
?>
```
Add logic which will only be available in your premium plugin version:
```php
<?php
// This "if" block will be auto removed from the Free version.
if ( my_prefix_fs()->is__premium_only() ) {
// ... premium only logic ...
}
?>
```
To add a function which will only be available in your premium plugin version, simply add __premium_only as the suffix of the function name. Just make sure that all lines that call that method directly or by hooks, are also wrapped in premium only logic:
```php
<?php
class My_Plugin {
function init() {
...
// This "if" block will be auto removed from the free version.
if ( my_prefix_fs()->is__premium_only() ) {
// Init premium version.
$this->admin_init__premium_only();
add_action( 'admin_init', array( &$this, 'admin_init_hook__premium_only' );
}
...
}
// This method will be only included in the premium version.
function admin_init__premium_only() {
...
}
// This method will be only included in the premium version.
function admin_init_hook__premium_only() {
...
}
}
?>
```
Add logic which will only be executed for customers in your 'professional' plan:
```php
<?php
if ( my_prefix_fs()->is_plan('professional', true) ) {
// .. logic related to Professional plan only ...
}
?>
```
Add logic which will only be executed for customers in your 'professional' plan or higher plans:
```php
<?php
if ( my_prefix_fs()->is_plan('professional') ) {
// ... logic related to Professional plan and higher plans ...
}
?>
```
Add logic which will only be available in your premium plugin version AND will only be executed for customers in your 'professional' plan (and higher plans):
```php
<?php
// This "if" block will be auto removed from the Free version.
if ( my_prefix_fs()->is_plan__premium_only('professional') ) {
// ... logic related to Professional plan and higher plans ...
}
?>
```
Add logic only for users in trial:
```php
<?php
if ( my_prefix_fs()->is_trial() ) {
// ... logic for users in trial ...
}
?>
```
Add logic for specified paid plan:
```php
<?php
// This "if" block will be auto removed from the Free version.
if ( my_prefix_fs()->is__premium_only() ) {
if ( my_prefix_fs()->is_plan( 'professional', true ) ) {
// ... logic related to Professional plan only ...
} else if ( my_prefix_fs()->is_plan( 'business' ) ) {
// ... logic related to Business plan and higher plans ...
}
}
?>
```
## Excluding files and folders from the free plugin version
There are two ways to exclude files from your free version.
1. Add `__premium_only` just before the file extension. For example, functions__premium_only.php will be only included in the premium plugin version. This works for all type of files, not only PHP.
2. Add `@fs_premium_only` a sepcial meta tag to the plugin's main PHP file header. Example:
```php
<?php
/**
* Plugin Name: My Very Awesome Plugin
* Plugin URI: http://my-awesome-plugin.com
* Description: Create and manage Awesomeness right in WordPress.
* Version: 1.0.0
* Author: Awesomattic
* Author URI: http://my-awesome-plugin.com/me/
* License: GPLv2
* Text Domain: myplugin
* Domain Path: /langs
*
* @fs_premium_only /lib/functions.php, /premium-files/
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// ... my code ...
?>
```
The file `/lib/functions.php` and the directory `/premium-files/` will be removed from the free plugin version.
# WordPress.org Compliance
Based on [WordPress.org Guidelines](https://wordpress.org/plugins/about/guidelines/) you are not allowed to submit a plugin that has premium code in it:
> All code hosted by WordPress.org servers must be free and fully-functional. If you want to sell advanced features for a plugin (such as a "pro" version), then you must sell and serve that code from your own site, we will not host it on our servers.
Therefore, if you want to deploy your free plugin's version to WordPress.org, make sure you wrap all your premium code with `if ( my_prefix_fs()->{{ method }}__premium_only() )` or the other methods provided to exclude premium features & files from the free version.
## Deployment
Zip your plugin's root folder and upload it in the Deployment section in the *Freemius Developer's Dashboard*.
The plugin will be scanned and processed by a custom developed *PHP Processor* which will auto-generate two versions of your plugin:
1. **Premium version**: Identical to your uploaded version, including all code (except your `
没有合适的资源?快使用搜索试试~ 我知道了~
【WordPress插件】2022年最新版完整功能demo+插件v1.3.1.zip
共184个文件
php:130个
css:12个
mo:12个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 140 浏览量
2022-04-04
05:30:00
上传
评论
收藏 1MB ZIP 举报
温馨提示
"【WordPress插件】2022年最新版完整功能demo+插件v1.3.1 Gravity Forms Import Entries 重力形成导入条目" ---------- 泰森云每天更新发布最新WordPress主题、HTML主题、WordPress插件、shopify主题、opencart主题、PHP项目源码、安卓项目源码、ios项目源码,更有超10000个资源可供选择,如有需要请站内联系。
资源推荐
资源详情
资源评论
收起资源包目录
【WordPress插件】2022年最新版完整功能demo+插件v1.3.1.zip (184个子文件)
dialog-boxes.css 13KB
add-ons.css 12KB
connect.css 10KB
common.css 5KB
account.css 4KB
customizer.css 3KB
affiliation.css 2KB
style.css 2KB
debug.css 657B
plugins.css 514B
gdpr-optin-notice.css 323B
checkout.css 83B
loader.gif 20KB
script.js 16KB
script.js 15KB
bootbox.min.js 10KB
nojquery.ba-postmessage.js 5KB
postmessage.js 4KB
nojquery.ba-postmessage.min.js 1KB
package.json 841B
README.md 8KB
README.md 3KB
freemius-ta.mo 86KB
freemius-ru_RU.mo 69KB
freemius-ja.mo 58KB
freemius-fr_FR.mo 57KB
freemius-es_ES.mo 56KB
freemius-he_IL.mo 56KB
freemius-it_IT.mo 55KB
freemius-nl_NL.mo 55KB
freemius-cs_CZ.mo 55KB
freemius-hu_HU.mo 54KB
freemius-da_DK.mo 53KB
freemius-en.mo 53KB
class-freemius.php 900KB
Importer.php 89KB
fs-plugin-info-dialog.php 77KB
account.php 60KB
class-fs-plugin-updater.php 58KB
i18n.php 50KB
fs-core-functions.php 48KB
connect.php 40KB
debug.php 34KB
license-activation.php 33KB
affiliation.php 28KB
class-fs-admin-menu-manager.php 26KB
add-ons.php 23KB
addon.php 21KB
site.php 20KB
class-fs-storage.php 20KB
form.php 20KB
FreemiusWordPress.php 20KB
class-fs-api.php 18KB
start.php 18KB
class-fs-logger.php 17KB
class-fs-options.php 16KB
class-fs-admin-notice-manager.php 16KB
class-fs-option-manager.php 15KB
fs-essential-functions.php 14KB
config.php 14KB
class-freemius-abstract.php 13KB
billing.php 13KB
optout.php 12KB
subscription-cancellation.php 11KB
user-change.php 11KB
checkout.php 11KB
class-fs-admin-notices.php 11KB
class-fs-key-value-storage.php 10KB
class-fs-cache-manager.php 9KB
class-fs-plugin-license.php 8KB
premium-versions-upgrade-handler.php 8KB
data-debug-mode.php 8KB
auto-installation.php 7KB
resend-key.php 7KB
tabs.php 7KB
class-fs-site.php 6KB
FreemiusBase.php 6KB
class-fs-gdpr-manager.php 6KB
pricing.php 6KB
trial-start.php 5KB
class-fs-customizer-upsell-control.php 5KB
api-calls.php 5KB
class-fs-plugin-manager.php 5KB
network-activation.php 5KB
contact.php 4KB
class-fs-affiliate-terms.php 4KB
scheduled-crons.php 4KB
class-fs-payment.php 4KB
class-fs-plugin.php 4KB
features.php 4KB
class-fs-subscription.php 3KB
gf-entries-import.php 3KB
class-fs-user-lock.php 3KB
class-fs-entity.php 3KB
class-fs-plan-manager.php 3KB
class-fs-pricing.php 3KB
require.php 3KB
class-fs-plugin-plan.php 3KB
plugins-themes-sync.php 3KB
class-fs-customizer-support-section.php 3KB
共 184 条
- 1
- 2
资源评论
Lee达森
- 粉丝: 966
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功