本文整理汇总了PHP中MS_Plugin::is_enabled方法的典型用法代码示例。如果您正苦于以下问题:PHP MS_Plugin::is_enabled方法的具体用法?PHP MS_Plugin::is_enabled怎么用?PHP MS_Plugin::is_enabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MS_Plugin
的用法示例。
在下文中一共展示了MS_Plugin::is_enabled方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: to_html
public function to_html()
{
$settings = $this->data['settings'];
$fields = array('plugin_enabled' => array('id' => 'plugin_enabled', 'type' => MS_Helper_Html::INPUT_TYPE_RADIO_SLIDER, 'title' => __('Content Protection', 'membership2'), 'desc' => __('This setting toggles the content protection on this site.', 'membership2'), 'value' => MS_Plugin::is_enabled(), 'data_ms' => array('action' => MS_Controller_Settings::AJAX_ACTION_TOGGLE_SETTINGS, 'setting' => 'plugin_enabled')), 'hide_admin_bar' => array('id' => 'hide_admin_bar', 'type' => MS_Helper_Html::INPUT_TYPE_RADIO_SLIDER, 'title' => __('Hide admin toolbar', 'membership2'), 'desc' => __('Hide the admin toolbar for non administrator users.', 'membership2'), 'value' => $settings->hide_admin_bar, 'data_ms' => array('action' => MS_Controller_Settings::AJAX_ACTION_TOGGLE_SETTINGS, 'setting' => 'hide_admin_bar')));
$fields = apply_filters('ms_view_settings_prepare_general_fields', $fields);
$setup = MS_Factory::create('MS_View_Settings_Page_Setup');
$action_url = esc_url_raw(remove_query_arg(array('msg')));
ob_start();
MS_Helper_Html::settings_tab_header();
?>
<form action="<?php
echo esc_url($action_url);
?>
" method="post" class="cf">
<div class="cf">
<div class="ms-half">
<?php
MS_Helper_Html::html_element($fields['plugin_enabled']);
?>
</div>
<div class="ms-half">
<?php
MS_Helper_Html::html_element($fields['hide_admin_bar']);
?>
</div>
</div>
<?php
MS_Helper_Html::html_separator();
MS_Helper_Html::html_element($setup->html_full_form());
?>
</form>
<?php
return ob_get_clean();
}
示例2: init
/**
* Initialize the Shortcodes after we have determined the current user.
*
* @since 1.0.0
*/
public function init()
{
// By default assume no content for the protected-content code
add_shortcode(MS_Helper_Shortcode::SCODE_PROTECTED, array($this, '__return_null'));
if (MS_Plugin::is_enabled()) {
add_shortcode(MS_Helper_Shortcode::SCODE_REGISTER_USER, array($this, 'membership_register_user'));
add_shortcode(MS_Helper_Shortcode::SCODE_SIGNUP, array($this, 'membership_signup'));
add_shortcode(MS_Helper_Shortcode::SCODE_MS_TITLE, array($this, 'membership_title'));
add_shortcode(MS_Helper_Shortcode::SCODE_MS_PRICE, array($this, 'membership_price'));
add_shortcode(MS_Helper_Shortcode::SCODE_MS_BUY, array($this, 'membership_buy'));
add_shortcode(MS_Helper_Shortcode::SCODE_MS_DETAILS, array($this, 'membership_details'));
add_shortcode(MS_Helper_Shortcode::SCODE_LOGIN, array($this, 'membership_login'));
add_shortcode(MS_Helper_Shortcode::SCODE_LOGOUT, array($this, 'membership_logout'));
add_shortcode(MS_Helper_Shortcode::SCODE_MS_ACCOUNT, array($this, 'membership_account'));
add_shortcode(MS_Helper_Shortcode::SCODE_MS_ACCOUNT_LINK, array($this, 'membership_account_link'));
add_shortcode(MS_Helper_Shortcode::SCODE_MS_INVOICE, array($this, 'membership_invoice'));
add_shortcode(MS_Helper_Shortcode::SCODE_NOTE, array($this, 'ms_note'));
add_shortcode(MS_Helper_Shortcode::SCODE_GREEN_NOTE, array($this, 'ms_green_note'));
add_shortcode(MS_Helper_Shortcode::SCODE_RED_NOTE, array($this, 'ms_red_note'));
add_shortcode(MS_Helper_Shortcode::SCODE_USER, array($this, 'show_to_user'));
add_shortcode(MS_Helper_Shortcode::SCODE_MEMBER_INFO, array($this, 'ms_member_info'));
if (MS_Model_Member::is_normal_admin()) {
add_shortcode(MS_Rule_Shortcode_Model::PROTECT_CONTENT_SHORTCODE, array('MS_Rule_Shortcode_Model', 'debug_protect_content_shortcode'));
}
} else {
$shortcodes = array(MS_Helper_Shortcode::SCODE_REGISTER_USER, MS_Helper_Shortcode::SCODE_SIGNUP, MS_Helper_Shortcode::SCODE_MS_TITLE, MS_Helper_Shortcode::SCODE_MS_PRICE, MS_Helper_Shortcode::SCODE_MS_DETAILS, MS_Helper_Shortcode::SCODE_LOGIN, MS_Helper_Shortcode::SCODE_LOGOUT, MS_Helper_Shortcode::SCODE_MS_ACCOUNT, MS_Helper_Shortcode::SCODE_MS_ACCOUNT_LINK, MS_Helper_Shortcode::SCODE_MS_INVOICE, MS_Helper_Shortcode::SCODE_NOTE, MS_Helper_Shortcode::SCODE_GREEN_NOTE, MS_Helper_Shortcode::SCODE_RED_NOTE);
foreach ($shortcodes as $shortcode) {
add_shortcode($shortcode, array($this, 'ms_no_value'));
}
add_shortcode(MS_Rule_Shortcode_Model::PROTECT_CONTENT_SHORTCODE, array($this, 'hide_shortcode'));
add_shortcode(MS_Helper_Shortcode::SCODE_USER, array($this, 'hide_shortcode'));
}
}
示例3: __construct
/**
* Prepare the metabox.
*
* @since 1.0.0
*/
public function __construct()
{
parent::__construct();
$this->metabox_title = __('Membership Access', 'membership2');
$post_types = array_merge(array('page', 'post', 'attachment'), array());
$this->post_types = apply_filters('ms_controller_membership_metabox_add_meta_boxes_post_types', $post_types);
if (!MS_Plugin::is_enabled()) {
return $this;
}
$this->add_action('add_meta_boxes', 'add_meta_boxes', 10);
$this->add_action('admin_enqueue_scripts', 'admin_enqueue_scripts');
$this->add_ajax_action(self::AJAX_ACTION_TOGGLE_ACCESS, 'ajax_action_toggle_metabox_access');
// Populates the WP editor with default contents of a page
$this->add_action('the_editor_content', 'show_default_content');
}
示例4: __construct
/**
* Prepare for Member registration.
*
* @since 1.0.0
*/
public function __construct()
{
parent::__construct();
if (MS_Plugin::is_enabled()) {
do_action('ms_controller_frontend_construct', $this);
// Process actions like register new account.
$this->add_action('template_redirect', 'process_actions', 1);
// Check if the current page is a Membership Page.
$this->add_action('template_redirect', 'check_for_membership_pages', 2);
// Propagates SSL cookies when user logs in.
$this->add_action('wp_login', 'propagate_ssl_cookie', 10, 2);
// Enqueue scripts.
$this->add_action('wp_enqueue_scripts', 'enqueue_scripts');
// Add classes for all memberships the user is registered to.
$this->add_filter('body_class', 'body_class');
// Clears the shortcode memory at the beginning of the_content
$this->add_filter('the_content', 'clear_content_memory', 1);
// Compact code for output on the front end.
add_filter('ms_compact_code', array('MS_Helper_Html', 'compact_code'));
/**
* This allows WordPress to provide the default register form.
*
* Set the filter response to FALSE to stop Membership2 from
* handling the registration process. WordPress or other plugins can
* register users in that case.
*
* @since 1.0.0
*/
self::$handle_registration = apply_filters('ms_frontend_handle_registration', true);
if (self::$handle_registration) {
// Set the registration URL to the 'Register' Membership Page.
$this->add_filter('wp_signup_location', 'signup_location', 999);
$this->add_filter('register_url', 'signup_location', 999);
}
// Redirect users to their Account page after login.
$this->add_filter('login_redirect', 'login_redirect', 10, 3);
$this->add_action('wp_logout', 'logout_redirect', 10);
}
}
示例5: add_unprotected_node
/**
* Add 'Unprotected' node.
*
* @since 1.0.0
*
*/
private function add_unprotected_node()
{
global $wp_admin_bar;
if (MS_Plugin::is_enabled()) {
return;
}
if (MS_Plugin::is_wizard()) {
return;
}
$link_url = MS_Controller_Plugin::get_admin_url('settings');
$wp_admin_bar->add_node(apply_filters('ms_controller_adminbar_add_unprotected_node', array('id' => 'ms-unprotected', 'title' => __('Content Protection is disabled', 'membership2'), 'href' => $link_url, 'meta' => array('class' => 'ms-unprotected', 'title' => __('Content of this site is unprotected', 'membership2'), 'tabindex' => '1'))));
}
示例6: init_member
/**
* Initialise current member.
*
* Get current member and membership relationships.
* If user is not logged in (visitor), assign a visitor membership.
* If user is logged in but has not any memberships, assign a default membership.
* Deactivated users (active == false) get visitor membership assigned.
*
* @since 1.0.0
*/
public function init_member()
{
do_action('ms_load_member', $this);
$this->member = MS_Model_Member::get_current_member();
if (MS_Plugin::is_enabled()) {
if (!is_user_logged_in()) {
// If a Guest-Membership exists we also assign it to the user.
$ms_guest = MS_Model_Membership::get_guest();
if ($ms_guest->is_valid() && $ms_guest->active) {
$this->member->add_membership($ms_guest->id);
}
} elseif (!$this->member->has_membership()) {
// Apply User-Membership to logged-in users without subscriptions.
$ms_user = MS_Model_Membership::get_user();
if ($ms_user->is_valid() && $ms_user->active) {
$this->member->add_membership($ms_user->id);
}
} elseif (!$this->member->is_member) {
$this->member->subscriptions = array();
}
// No subscription: Assign the base membership, which only denies access.
if (!$this->member->has_membership()) {
$this->member->add_membership(MS_Model_Membership::get_base()->id);
}
}
/**
* At this point the plugin is initialized and we are here:
* - All Add-Ons are registered
* - All Rules are registered
* - Know the current User
* - All Subscriptions/Memberships of the user are loaded
* - System memberships are already assigned (guest/base)
* - Payment gateways are registered
* - Communication settings are loaded
*
* Next we tell everybody that we are ready to get serious!
*
* What happens next:
* 1. All Membership-Rules are initialized/merged
* 2. Front-End Protection is applied
* 3. Admin-Side Protection is applied
*/
do_action('ms_init_done', $this);
}