本文整理汇总了PHP中MS_Model_Addon::is_enabled方法的典型用法代码示例。如果您正苦于以下问题:PHP MS_Model_Addon::is_enabled方法的具体用法?PHP MS_Model_Addon::is_enabled怎么用?PHP MS_Model_Addon::is_enabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MS_Model_Addon
的用法示例。
在下文中一共展示了MS_Model_Addon::is_enabled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: is_enabled
/**
* Add a dependency check to this add-on: It can only be enabled when the
* parent Add-on "Media" is also enabled.
*
* Filter: 'ms_model_addon_is_enabled_addon_mediafiles'
*
* @since 1.0.0
* @internal
*
* @param bool $enabled State of this add-on
* (without considering the parent add-on)
* @return bool The actual state of this add-on.
*/
public function is_enabled($enabled)
{
if ($enabled) {
$enabled = MS_Model_Addon::is_enabled(MS_Model_Addon::ADDON_MEDIA);
}
return $enabled;
}
示例2: is_active
/**
* Checks if the current Add-on is enabled
*
* @since 1.0.0
* @return bool
*/
public static function is_active()
{
if (!self::buddypress_active() && MS_Model_Addon::is_enabled(self::ID)) {
$model = MS_Factory::load('MS_Model_Addon');
$model->disable(self::ID);
}
return MS_Model_Addon::is_enabled(self::ID);
}
示例3: get_columns
/**
* Get list table columns.
*
* @since 1.0.0
*
* @return array {
* Returns array of $id => $title.
*
* @type string $id The list table column id.
* @type string $title The list table column title.
* }
*/
public function get_columns()
{
$columns = array('cb' => '<input type="checkbox" />', 'username' => __('Username', MS_TEXT_DOMAIN), 'email' => __('E-mail', MS_TEXT_DOMAIN), 'membership' => __('Membership', MS_TEXT_DOMAIN), 'infos' => ' ');
if (!MS_Model_Addon::is_enabled(MS_Model_Addon::ADDON_TRIAL)) {
unset($columns['trial']);
}
return apply_filters('ms_helper_listtable_member_get_columns', $columns);
}
示例4: get_fields
/**
* Prepares fields for the edit form.
*
* @since 1.0.1.0
* @return array
*/
protected function get_fields()
{
$args = array('include_guest' => false);
$memberships = MS_Model_Membership::get_memberships($args);
$membership = $this->data['membership'];
$action = MS_Controller_Membership::AJAX_ACTION_UPDATE_MEMBERSHIP;
$nonce = wp_create_nonce($action);
$fields = array();
/*
* The value of "allow_val" is negated, because the radio-slider is
* reversed. So allow_val == false means that upgrading is allowed.
*
* This is just a UI tweak, the function ->update_allowed() returns true
* when upgrading is allowed.
*/
$list = array();
$list['guest'] = array('allow' => __('Users without Membership can subscribe', 'membership2'), 'allow_val' => !$membership->update_allowed('guest'));
foreach ($memberships as $item) {
if ($item->id == $membership->id) {
continue;
}
$list[$item->id] = array('allow' => sprintf(__('Members of %s can subscribe', 'membership2'), $item->get_name_tag()), 'allow_val' => !$membership->update_allowed($item->id));
if (MS_Model_Addon::is_enabled(MS_Model_Addon::ADDON_MULTI_MEMBERSHIPS)) {
$list[$item->id]['replace'] = sprintf(__('Cancel %s on subscription', 'membership2'), $item->get_name_tag());
$list[$item->id]['replace_val'] = $membership->update_replaces($item->id);
}
}
foreach ($list as $id => $data) {
$fields[] = array('id' => 'deny_update[' . $id . ']', 'type' => MS_Helper_Html::INPUT_TYPE_RADIO_SLIDER, 'title' => $data['allow'], 'value' => $data['allow_val'], 'before' => __('Allow', 'membership2'), 'after' => __('Deny', 'membership2'), 'class' => 'reverse', 'wrapper_class' => 'ms-block inline-label ms-allow', 'ajax_data' => array(1));
if (!empty($data['replace'])) {
if (MS_Addon_Prorate::is_active()) {
$after_label = __('Cancel and Pro-Rate', 'membership2');
} else {
$after_label = __('Cancel', 'membership2');
}
$fields[] = array('id' => 'replace_update[' . $id . ']', 'type' => MS_Helper_Html::INPUT_TYPE_RADIO_SLIDER, 'title' => $data['replace'], 'value' => $data['replace_val'], 'before' => __('Keep', 'membership2'), 'after' => $after_label, 'class' => 'reverse', 'wrapper_class' => 'ms-block inline-label ms-update-replace', 'ajax_data' => array(1));
}
$fields[] = array('type' => MS_Helper_Html::TYPE_HTML_SEPARATOR);
}
foreach ($fields as $key => $field) {
if (!empty($field['ajax_data'])) {
if (!empty($field['ajax_data']['action'])) {
continue;
}
if (!isset($fields[$key]['ajax_data']['field'])) {
$fields[$key]['ajax_data']['field'] = $fields[$key]['id'];
}
$fields[$key]['ajax_data']['_wpnonce'] = $nonce;
$fields[$key]['ajax_data']['action'] = $action;
$fields[$key]['ajax_data']['membership_id'] = $membership->id;
}
}
return $fields;
}
示例5: protect_content
/**
* Set initial protection.
*
* Add [ms-protect-content] shortcode to protect membership content inside post.
*
* @since 1.0.0
*/
public function protect_content()
{
parent::protect_content();
self::$membership_ids[] = $this->membership_id;
add_shortcode(self::PROTECT_CONTENT_SHORTCODE, array(__CLASS__, 'protect_content_shortcode'));
if (MS_Model_Addon::is_enabled(MS_Model_Addon::ADDON_SHORTCODE)) {
global $shortcode_tags;
$exclude = MS_Helper_Shortcode::get_membership_shortcodes();
foreach ($shortcode_tags as $shortcode => $callback_funciton) {
if (in_array($shortcode, $exclude)) {
continue;
}
if (!parent::has_access($shortcode)) {
$shortcode_tags[$shortcode] = array(&$this, 'do_protected_shortcode');
}
}
}
}
示例6: get_views
/**
* This list has no views.
*
* @since 1.0.2.0
*
* @return array
*/
public function get_views()
{
$views = array();
$args = array();
$count = 0;
$views['label'] = array('label' => __('Subscription Status:', 'membership2'));
if (empty($_REQUEST['membership_id'])) {
// All users
$url = esc_url_raw(add_query_arg('status', 'all'));
$views['all'] = array('url' => $url, 'label' => __('All users', 'membership2'));
} else {
$args['membership_id'] = $_REQUEST['membership_id'];
}
// Active, Trial, Cancelled
$url = esc_url_raw(remove_query_arg('status'));
$args['subscription_status'] = MS_Model_Relationship::STATUS_ACTIVE;
$count = MS_Model_Member::get_members_count($args);
$views['active'] = array('url' => $url, 'label' => __('Active subscription', 'membership2'), 'count' => $count);
// Cancelled
$url = esc_url_raw(add_query_arg('status', MS_Model_Relationship::STATUS_CANCELED));
$args['subscription_status'] = MS_Model_Relationship::STATUS_CANCELED;
$count = MS_Model_Member::get_members_count($args);
$views['cancelled'] = array('url' => $url, 'label' => __('Cancelled', 'membership2'), 'count' => $count);
// Trial
if (MS_Model_Addon::is_enabled(MS_Model_Addon::ADDON_TRIAL)) {
$url = esc_url_raw(add_query_arg('status', MS_Model_Relationship::STATUS_TRIAL));
$args['subscription_status'] = MS_Model_Relationship::STATUS_TRIAL;
$count = MS_Model_Member::get_members_count($args);
$views['trial'] = array('url' => $url, 'label' => __('Trial', 'membership2'), 'count' => $count);
}
// Expired, Trial-Expired
$url = esc_url_raw(add_query_arg('status', 'expired'));
$args['subscription_status'] = 'expired';
$count = MS_Model_Member::get_members_count($args);
$views['expired'] = array('url' => $url, 'label' => __('Expired', 'membership2'), 'count' => $count);
return $views;
}
示例7: get_contents
/**
* Returns the contens of the dialog
*
* @since 1.0.0
*
* @return object
*/
public function get_contents($data)
{
$member = $data['model'];
$currency = MS_Plugin::instance()->settings->currency;
$show_trial = MS_Model_Addon::is_enabled(MS_Model_Addon::ADDON_TRIAL);
$all_subscriptions = MS_Model_Relationship::get_subscriptions(array('user_id' => $member->id, 'status' => 'all', 'meta_key' => 'expire_date', 'orderby' => 'meta_value', 'order' => 'DESC'));
// Prepare the form fields.
$inp_dialog = array('type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'name' => 'dialog', 'value' => 'View_Member_Dialog');
$inp_id = array('type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'name' => 'member_id', 'value' => $member->id);
$inp_nonce = array('type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'name' => '_wpnonce', 'value' => wp_create_nonce(self::ACTION_SAVE));
$inp_action = array('type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'name' => 'dialog_action', 'value' => self::ACTION_SAVE);
$inp_save = array('type' => MS_Helper_Html::INPUT_TYPE_SUBMIT, 'value' => __('Save', 'membership2'), 'class' => 'ms-submit-form', 'data' => array('form' => 'ms-edit-member'));
$inp_cancel = array('type' => MS_Helper_Html::INPUT_TYPE_BUTTON, 'value' => __('Close', 'membership2'), 'class' => 'close');
ob_start();
?>
<div>
<form class="ms-form wpmui-ajax-update ms-edit-member" data-wpmui-ajax="<?php
echo esc_attr('save');
?>
">
<div class="ms-form wpmui-form wpmui-grid-8">
<table class="widefat">
<thead>
<tr>
<th class="column-membership">
<?php
_e('Membership', 'membership2');
?>
</th>
<th class="column-status">
<?php
_e('Status', 'membership2');
?>
</th>
<th class="column-start">
<?php
_e('Subscribed on', 'membership2');
?>
</th>
<th class="column-expire">
<?php
_e('Expires on', 'membership2');
?>
</th>
<?php
if ($show_trial) {
?>
<th class="column-trialexpire">
<?php
_e('Trial until', 'membership2');
?>
</th>
<?php
}
?>
<th class="column-payments">
<?php
_e('Payments', 'membership2');
?>
</th>
</tr>
</thead>
<tbody>
<?php
foreach ($all_subscriptions as $subscription) {
$membership = $subscription->get_membership();
$payments = $subscription->get_payments();
$num_payments = count($payments);
$amount_payments = 0;
foreach ($payments as $payment) {
$amount_payments += $payment['amount'];
}
$subscription_info = array('subscription_id' => $subscription->id);
$update_info = array('subscription_id' => $subscription->id, 'statuscheck' => 'yes');
?>
<tr>
<td class="column-membership">
<?php
$membership->name_tag();
?>
</td>
<td class="column-status">
<?php
printf('<a href="#" data-ms-dialog="View_Member_Subscription" data-ms-data="%2$s">%1$s</a>
<a href="#" data-ms-dialog="View_Member_Subscription" data-ms-data="%3$s" title="%5$s">%4$s</a>', $subscription->status, esc_attr(json_encode($subscription_info)), esc_attr(json_encode($update_info)), '<i class="dashicons dashicons-update"></i>', __('Check and update subscription status', 'membership2'));
?>
</td>
<td class="column-start">
<?php
echo $subscription->start_date;
?>
</td>
<td class="column-expire">
//.........这里部分代码省略.........
示例8: has_rule_for_current_page
/**
* Checks if the current page is a special page and if the special page is
* protected by this rule.
*
* @since 1.0.0
*
* @return bool
*/
public function has_rule_for_current_page()
{
if (null === $this->_has_rule) {
if (!MS_Model_Addon::is_enabled(MS_Model_Addon::ADDON_SPECIAL_PAGES)) {
$this->_has_rule = false;
} else {
$base = $this->get_membership()->get_base();
$base_rule = $base->get_rule($this->rule_type);
$this->_has_rule = $this->check_current_page($base_rule->rule_value);
}
}
return $this->_has_rule;
}
示例9: is_active
/**
* Returns the active flag for a specific rule.
* State depends on Add-on
*
* @since 1.0.0
* @return bool
*/
public static function is_active()
{
return MS_Model_Addon::is_enabled(MS_Model_Addon::ADDON_ADMINSIDE);
}
示例10: get_fields
/**
* Prepares fields for the edit form.
*
* @since 1.0.1.0
* @return array
*/
protected function get_fields()
{
$membership = $this->data['membership'];
$action = MS_Controller_Membership::AJAX_ACTION_UPDATE_MEMBERSHIP;
$nonce = wp_create_nonce($action);
$fields = array();
// Prepare the form fields.
$fields['name'] = array('id' => 'name', 'type' => MS_Helper_Html::INPUT_TYPE_TEXT, 'title' => apply_filters('ms_translation_flag', __('Name:', MS_TEXT_DOMAIN), 'membership-name'), 'value' => $membership->name, 'ajax_data' => array(1));
$fields['description'] = array('id' => 'description', 'type' => MS_Helper_Html::INPUT_TYPE_TEXT_AREA, 'title' => apply_filters('ms_translation_flag', __('Description:', MS_TEXT_DOMAIN), 'membership-name'), 'value' => $membership->description, 'ajax_data' => array(1));
$fields['active'] = array('id' => 'active', 'type' => MS_Helper_Html::INPUT_TYPE_RADIO_SLIDER, 'title' => __('This membership is active', MS_TEXT_DOMAIN), 'before' => __('No', MS_TEXT_DOMAIN), 'after' => __('Yes', MS_TEXT_DOMAIN), 'class' => 'ms-active', 'value' => $membership->active, 'ajax_data' => array(1));
$fields['public'] = array('id' => 'public', 'type' => MS_Helper_Html::INPUT_TYPE_RADIO_SLIDER, 'title' => __('This membership is public', MS_TEXT_DOMAIN), 'desc' => __('Users can see it listed on your site and can register for it', MS_TEXT_DOMAIN), 'before' => __('No', MS_TEXT_DOMAIN), 'after' => __('Yes', MS_TEXT_DOMAIN), 'class' => 'ms-public', 'value' => $membership->public, 'ajax_data' => array(1));
$fields['paid'] = array('id' => 'is_paid', 'type' => MS_Helper_Html::INPUT_TYPE_RADIO_SLIDER, 'title' => __('This is a paid membership', MS_TEXT_DOMAIN), 'before' => __('No', MS_TEXT_DOMAIN), 'after' => __('Yes', MS_TEXT_DOMAIN), 'class' => 'ms-paid', 'value' => $membership->is_paid, 'ajax_data' => array(1));
$priority_list = array();
$args = array('include_guest' => 0);
$count = MS_Model_Membership::get_membership_count($args);
for ($i = 1; $i <= $count; $i += 1) {
$priority_list[$i] = $i;
}
$priority_list[$membership->priority] = $membership->priority;
$fields['priority'] = array('id' => 'priority', 'type' => MS_Helper_Html::INPUT_TYPE_SELECT, 'title' => __('Membership order', MS_TEXT_DOMAIN), 'desc' => __('This defines the display order on the Membership Page.', MS_TEXT_DOMAIN), 'class' => 'ms-priority', 'before' => __('Order', MS_TEXT_DOMAIN), 'value' => $membership->priority, 'field_options' => $priority_list, 'ajax_data' => array(1));
if (MS_Model_Addon::is_enabled(MS_Model_Addon::ADDON_MULTI_MEMBERSHIPS)) {
$fields['priority']['desc'] .= '<br>' . __('It also controlls which Protection Message is used in case a member has multiple memberships (the lowest value wins)', MS_TEXT_DOMAIN);
}
foreach ($fields as $key => $field) {
if (!empty($field['ajax_data'])) {
if (!empty($field['ajax_data']['action'])) {
continue;
}
if (!isset($fields[$key]['ajax_data']['field'])) {
$fields[$key]['ajax_data']['field'] = $fields[$key]['id'];
}
$fields[$key]['ajax_data']['_wpnonce'] = $nonce;
$fields[$key]['ajax_data']['action'] = $action;
$fields[$key]['ajax_data']['membership_id'] = $membership->id;
}
}
return $fields;
}
示例11: get_communication_types
/**
* Get communication types.
*
* @since 1.0.0
*
* @return array The communication types.
*/
public static function get_communication_types()
{
static $Types = null;
if (null === $Types) {
if (MS_Model_Addon::is_enabled(MS_Model_Addon::ADDON_AUTO_MSGS_PLUS)) {
$Types = array(self::COMM_TYPE_REGISTRATION, self::COMM_TYPE_REGISTRATION_FREE, self::COMM_TYPE_SIGNUP, self::COMM_TYPE_RENEWED, self::COMM_TYPE_INVOICE, self::COMM_TYPE_BEFORE_FINISHES, self::COMM_TYPE_FINISHED, self::COMM_TYPE_AFTER_FINISHES, self::COMM_TYPE_CANCELLED, self::COMM_TYPE_BEFORE_TRIAL_FINISHES, self::COMM_TYPE_INFO_UPDATE, self::COMM_TYPE_CREDIT_CARD_EXPIRE, self::COMM_TYPE_FAILED_PAYMENT, self::COMM_TYPE_BEFORE_PAYMENT_DUE, self::COMM_TYPE_AFTER_PAYMENT_DUE);
} else {
$Types = array(self::COMM_TYPE_REGISTRATION, self::COMM_TYPE_INVOICE, self::COMM_TYPE_FINISHED, self::COMM_TYPE_CANCELLED, self::COMM_TYPE_INFO_UPDATE, self::COMM_TYPE_CREDIT_CARD_EXPIRE, self::COMM_TYPE_FAILED_PAYMENT);
}
}
return apply_filters('ms_model_communication_get_communication_types', $Types);
}
示例12: can_access_file
/**
* Checks if the current user can access the specified attachment.
*
* @since 1.0.0
* @param int $attachment_id
* @return bool
*/
public function can_access_file($attachment_id)
{
$access = false;
if (MS_Model_Member::is_normal_admin()) {
return true;
}
if (!MS_Model_Addon::is_enabled(MS_Addon_Mediafiles::ID)) {
/*
* Default protection mode:
* Protect Attachments based on the parent post.
*/
$parent_id = get_post_field('post_parent', $attachment_id);
if (!$parent_id) {
$access = true;
} else {
$member = MS_Model_Member::get_current_member();
foreach ($member->subscriptions as $subscription) {
$membership = $subscription->get_membership();
$access = $membership->has_access_to_post($parent_id);
if ($access) {
break;
}
}
}
} else {
/*
* Advanced protection mode (via Add-on):
* Each Attachment can be protected individually.
*/
$member = MS_Model_Member::get_current_member();
foreach ($member->subscriptions as $subscription) {
$rule = $subscription->get_membership()->get_rule(MS_Rule_Media::RULE_ID);
$access = $rule->has_access($attachment_id);
if ($access) {
break;
}
}
}
return apply_filters('ms_rule_media_can_access_file', $access, $attachment_id);
}
示例13: handle_download_protection
/**
* Handle protected media access.
*
* Search for masked file and show the proper content, or no access image if don't have access.
*
* Realted Action Hooks:
* - parse_request
*
* @since 1.0.0
*
* @param WP_Query $query The WP_Query object to filter.
*/
public function handle_download_protection($query)
{
do_action('ms_rule_media_model_handle_download_protection_before', $query, $this);
$the_file = false;
$requested_item = false;
$download_settings = MS_Plugin::instance()->settings->downloads;
$protection_type = $download_settings['protection_type'];
if (!MS_Model_Addon::is_enabled(MS_Model_Addon::ADDON_MEDIA)) {
return;
}
if (!empty($query->query_vars['protectedfile'])) {
$requested_item = explode('/', $query->query_vars['protectedfile']);
$requested_item = array_pop($requested_item);
} elseif (!empty($_GET['ms_file']) && self::PROTECTION_TYPE_HYBRID == $protection_type) {
$requested_item = $_GET['ms_file'];
}
if (!empty($requested_item)) {
// At this point we know that the requested post is an attachment.
$f_info = $this->extract_file_info($requested_item);
switch ($protection_type) {
case self::PROTECTION_TYPE_COMPLETE:
case self::PROTECTION_TYPE_HYBRID:
// Work out the post_id again
$attachment_id = preg_replace('/^' . self::FILE_PROTECTION_PREFIX . '/', '', $f_info->filename);
$attachment_id -= (int) self::FILE_PROTECTION_INCREMENT;
$the_file = $this->restore_filename($attachment_id, $f_info->size_extension);
break;
default:
case self::PROTECTION_TYPE_BASIC:
$home = untrailingslashit(get_option('home'));
$attachment_id = $this->get_attachment_id($home . $f_info->filename);
$the_file = $this->restore_filename($attachment_id, $f_info->size_extension);
break;
}
if (!empty($the_file) && !empty($attachment_id) && is_numeric($attachment_id)) {
if ($this->can_access_file($attachment_id)) {
$upload_dir = wp_upload_dir();
$file = trailingslashit($upload_dir['basedir']) . $the_file;
$this->output_file($file);
} else {
$this->show_no_access_image();
}
}
}
do_action('ms_rule_media_model_handle_download_protection_after', $query, $this);
}
示例14: prepare_fields_edit
/**
* Input fields displayed in the "Edit Member" screen.
*
* @since 1.0.1.0
* @return array
*/
public function prepare_fields_edit()
{
$action_update = MS_Controller_Member::ACTION_UPDATE_MEMBER;
$action_modify = MS_Controller_Member::ACTION_MODIFY_SUBSCRIPTIONS;
$user_id = $this->data['user_id'];
$user = MS_Factory::load('MS_Model_Member', $user_id);
$unused_memberships = array();
$temp_memberships = MS_Model_Membership::get_memberships(array('include_guest' => 0));
foreach ($temp_memberships as $membership) {
$unused_memberships[$membership->id] = $membership;
}
$fields = array();
$fields['editor'] = array('title' => array('type' => MS_Helper_Html::TYPE_HTML_TEXT, 'class' => 'group-title', 'value' => __('Basic Profile details', MS_TEXT_DOMAIN)), 'username' => array('id' => 'username', 'type' => MS_Helper_Html::INPUT_TYPE_TEXT, 'title' => __('Username', MS_TEXT_DOMAIN), 'value' => $user->username, 'class' => 'ms-text-medium', 'config' => array('disabled' => 'disabled')), 'email' => array('id' => 'email', 'type' => MS_Helper_Html::INPUT_TYPE_TEXT, 'title' => __('Email', MS_TEXT_DOMAIN), 'value' => $user->email, 'class' => 'ms-text-medium'), 'first_name' => array('id' => 'first_name', 'type' => MS_Helper_Html::INPUT_TYPE_TEXT, 'title' => __('First Name', MS_TEXT_DOMAIN), 'value' => $user->first_name, 'class' => 'ms-text-medium'), 'last_name' => array('id' => 'last_name', 'type' => MS_Helper_Html::INPUT_TYPE_TEXT, 'title' => __('Last Name', MS_TEXT_DOMAIN), 'value' => $user->last_name, 'class' => 'ms-text-medium'), 'displayname' => array('id' => 'displayname', 'type' => MS_Helper_Html::INPUT_TYPE_TEXT, 'title' => __('Display Name', MS_TEXT_DOMAIN), 'value' => $user->get_user()->display_name, 'class' => 'ms-text-medium'), 'sep' => array('type' => MS_Helper_Html::TYPE_HTML_SEPARATOR), 'user_id' => array('id' => 'user_id', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $user->id), 'button' => array('id' => 'btn_save', 'type' => MS_Helper_Html::INPUT_TYPE_SUBMIT, 'value' => __('Save', MS_TEXT_DOMAIN)), 'profile' => array('id' => 'user_profile', 'type' => MS_Helper_Html::TYPE_HTML_LINK, 'value' => __('Full User Profile', MS_TEXT_DOMAIN) . ' »', 'url' => admin_url('user-edit.php?user_id=' . $user->id), 'class' => 'button wpmui-field-input'), 'action' => array('id' => 'action', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $action_update), '_wpnonce' => array('id' => '_wpnonce', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => wp_create_nonce($action_update)));
$fields['subscriptions'] = array();
// Section: Edit existing subscriptions.
$fields['subscriptions'][] = array('type' => MS_Helper_Html::TYPE_HTML_TEXT, 'class' => 'group-title', 'value' => __('Manage Subscriptions', MS_TEXT_DOMAIN));
if ($user->subscriptions) {
$gateways = MS_Model_Gateway::get_gateway_names(false, true);
foreach ($user->subscriptions as $subscription) {
if (MS_Model_Relationship::STATUS_DEACTIVATED == $subscription->status) {
continue;
}
$the_membership = $subscription->get_membership();
unset($unused_memberships[$the_membership->id]);
$status_options = array(MS_Model_Relationship::STATUS_PENDING => __('Pending (activate on next payment)', MS_TEXT_DOMAIN), MS_Model_Relationship::STATUS_WAITING => __('Waiting (activate on start date)', MS_TEXT_DOMAIN), MS_Model_Relationship::STATUS_TRIAL => __('Trial Active', MS_TEXT_DOMAIN), MS_Model_Relationship::STATUS_ACTIVE => __('Active', MS_TEXT_DOMAIN), MS_Model_Relationship::STATUS_CANCELED => __('Cancelled (deactivate on expire date)', MS_TEXT_DOMAIN), MS_Model_Relationship::STATUS_TRIAL_EXPIRED => __('Trial Expired (activate on next payment)', MS_TEXT_DOMAIN), MS_Model_Relationship::STATUS_EXPIRED => __('Expired (no access) ', MS_TEXT_DOMAIN), MS_Model_Relationship::STATUS_DEACTIVATED => __('Deactivated (no access)', MS_TEXT_DOMAIN));
if (!$the_membership->has_trial()) {
unset($status_options[MS_Model_Relationship::STATUS_TRIAL]);
unset($status_options[MS_Model_Relationship::STATUS_TRIAL_EXPIRED]);
}
if (isset($gateways[$subscription->gateway_id])) {
$gateway_name = $gateways[$subscription->gateway_id];
} elseif (empty($subscription->gateway_id)) {
$gateway_name = __('- No Gateway -', MS_TEXT_DOMAIN);
} else {
$gateway_name = '(' . $subscription->gateway_id . ')';
}
$field_start = array('name' => 'mem_' . $the_membership->id . '[start]', 'type' => MS_Helper_Html::INPUT_TYPE_DATEPICKER, 'value' => $subscription->start_date);
$field_expire = array('name' => 'mem_' . $the_membership->id . '[expire]', 'type' => MS_Helper_Html::INPUT_TYPE_DATEPICKER, 'value' => $subscription->expire_date);
$field_status = array('name' => 'mem_' . $the_membership->id . '[status]', 'type' => MS_Helper_Html::INPUT_TYPE_SELECT, 'value' => $subscription->status, 'field_options' => $status_options);
$fields['subscriptions'][] = array('name' => 'memberships[]', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $the_membership->id);
$fields['subscriptions'][] = array('title' => $the_membership->get_name_tag(), 'type' => MS_Helper_Html::TYPE_HTML_TABLE, 'value' => array(array(__('Subscription ID', MS_TEXT_DOMAIN), $subscription->id), array(__('Payment Gateway', MS_TEXT_DOMAIN), $gateway_name), array(__('Payment Type', MS_TEXT_DOMAIN), $subscription->get_payment_description(null, true)), array(__('Start Date', MS_TEXT_DOMAIN) . ' <sup>*)</sup>', MS_Helper_Html::html_element($field_start, true)), array(__('Expire Date', MS_TEXT_DOMAIN) . ' <sup>*)</sup>', MS_Helper_Html::html_element($field_expire, true)), array(__('Status', MS_TEXT_DOMAIN) . ' <sup>*)</sup>', MS_Helper_Html::html_element($field_status, true))), 'field_options' => array('head_col' => true));
}
} else {
$fields['subscriptions'][] = array('type' => MS_Helper_Html::TYPE_HTML_TEXT, 'value' => __('This user does not have any subscriptions yet.', MS_TEXT_DOMAIN));
}
// Section: Add new subscription.
if (count($unused_memberships)) {
$options = array();
if (MS_Model_Addon::is_enabled(MS_Model_Addon::ADDON_MULTI_MEMBERSHIPS)) {
$field_type = MS_Helper_Html::INPUT_TYPE_CHECKBOX;
$group_title = __('Add Subscriptions', MS_TEXT_DOMAIN);
} else {
$field_type = MS_Helper_Html::INPUT_TYPE_RADIO;
$group_title = __('Set Subscription', MS_TEXT_DOMAIN);
}
$fields['subscriptions'][] = array('type' => MS_Helper_Html::TYPE_HTML_SEPARATOR);
$fields['subscriptions'][] = array('type' => MS_Helper_Html::TYPE_HTML_TEXT, 'class' => 'group-title', 'value' => $group_title);
foreach ($unused_memberships as $the_membership) {
$options[$the_membership->id] = $the_membership->get_name_tag();
}
$fields['subscriptions'][] = array('id' => 'subscribe', 'type' => $field_type, 'field_options' => $options);
$fields['subscriptions'][] = array('id' => 'user_id', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $user->id);
}
if ($user->subscriptions) {
$fields['subscriptions'][] = array('type' => MS_Helper_Html::TYPE_HTML_SEPARATOR);
$fields['subscriptions'][] = array('type' => MS_Helper_Html::TYPE_HTML_TEXT, 'value' => '<sup>*)</sup> ' . __('Subscription Dates and Status are validated when saved and might result in a different value then the one specified above.', MS_TEXT_DOMAIN), 'class' => 'info-field');
}
$fields['subscriptions'][] = array('id' => 'btn_modify', 'type' => MS_Helper_Html::INPUT_TYPE_SUBMIT, 'value' => __('Save Changes', MS_TEXT_DOMAIN));
$fields['subscriptions'][] = array('id' => 'history', 'type' => MS_Helper_Html::TYPE_HTML_LINK, 'value' => '<i class="dashicons dashicons-id"></i>' . __('History and logs', MS_TEXT_DOMAIN), 'url' => '#history', 'class' => 'button wpmui-field-input', 'config' => array('data-ms-dialog' => 'View_Member_Dialog', 'data-ms-data' => array('member_id' => $user->id)));
$fields['subscriptions'][] = array('id' => 'action', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $action_modify);
$fields['subscriptions'][] = array('id' => '_wpnonce', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => wp_create_nonce($action_modify));
return apply_filters('ms_view_member_editor_fields_edit', $fields);
}
示例15: has_access
/**
* Verify access to the current content.
*
* @since 1.0.0
*
* @param string $id The content id to verify access.
* @return bool|null True if has access, false otherwise.
* Null means: Rule not relevant for current page.
*/
public function has_access($id, $admin_has_access = true)
{
$has_access = null;
// Only verify permission if ruled by cpt post by post.
if (MS_Model_Addon::is_enabled(MS_Model_Addon::ADDON_CPT_POST_BY_POST)) {
if (empty($id)) {
$id = $this->get_current_post_id();
}
if (!empty($id)) {
$post_type = get_post_type($id);
$mspt = MS_Rule_CptGroup_Model::get_ms_post_types();
$cpt = MS_Rule_CptGroup_Model::get_custom_post_types();
if (in_array($post_type, $mspt)) {
// Always allow access to Membership2 pages.
$has_access = true;
} elseif (in_array($post_type, $cpt)) {
// Custom post type
$has_access = parent::has_access($id, $admin_has_access);
} else {
// WordPress core pages are ignored by this rule.
$has_access = null;
}
}
}
return apply_filters('ms_rule_custom_post_type_has_access', $has_access, $id, $this);
}