Jetpack::get_active_plan PHP Method

get_active_plan() public static method

Get the plan that this Jetpack site is currently using
public static get_active_plan ( ) : array
return array Active Jetpack plan details
    public static function get_active_plan()
    {
        $plan = get_option('jetpack_active_plan');
        // Set the default options
        if (!$plan) {
            $plan = array('product_slug' => 'jetpack_free', 'supports' => array());
        }
        // Define what paid modules are supported by personal plans
        $personal_plans = array('jetpack_personal', 'jetpack_personal_monthly');
        if (in_array($plan['product_slug'], $personal_plans)) {
            $plan['supports'] = array('akismet');
        }
        // Define what paid modules are supported by premium plans
        $premium_plans = array('jetpack_premium', 'jetpack_premium_monthly');
        if (in_array($plan['product_slug'], $premium_plans)) {
            $plan['supports'] = array('videopress', 'akismet', 'vaultpress');
        }
        // Define what paid modules are supported by professional plans
        $business_plans = array('jetpack_business', 'jetpack_business_monthly');
        if (in_array($plan['product_slug'], $business_plans)) {
            $plan['supports'] = array('videopress', 'akismet', 'vaultpress', 'seo-tools');
        }
        // Make sure we have an array here in the event database data is stale
        if (!isset($plan['supports'])) {
            $plan['supports'] = array();
        }
        return $plan;
    }

Usage Example

コード例 #1
0
ファイル: class.jetpack.php プロジェクト: automattic/jetpack
 /**
  * Determine whether the active plan supports a particular feature
  *
  * @uses Jetpack::get_active_plan()
  *
  * @access public
  * @static
  *
  * @return bool True if plan supports feature, false if not
  */
 public static function active_plan_supports($feature)
 {
     $plan = Jetpack::get_active_plan();
     if (in_array($feature, $plan['supports'])) {
         return true;
     }
     return false;
 }
Jetpack