本文整理汇总了PHP中MS_Plugin类的典型用法代码示例。如果您正苦于以下问题:PHP MS_Plugin类的具体用法?PHP MS_Plugin怎么用?PHP MS_Plugin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MS_Plugin类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: to_html
/**
* Returns the HTML code of the view.
*
* @since 1.0.0
* @api
*
* @return string
*/
public function to_html()
{
$model = MS_Factory::create('MS_Model_Import_Membership');
$model->prepare();
$view = MS_Factory::create('MS_View_Settings_Import');
$view->data = array('model' => $model, 'compact' => true);
$msg = __('Tip: You can also import your data later by visiting the Admin page <b>Membership2 > Settings > Import Tool</b>.', 'membership2');
ob_start();
// Render tabbed interface.
?>
<div class="ms-wrap wrap">
<h2>
<?php
_e('Import Your Membership Data To Membership2', 'membership2');
?>
</h2>
<?php
if (MS_Plugin::is_network_wide()) {
$msg .= '<br><br>' . __('You have enabled Network Wide Protection. We will import Membership data from your main blog.', 'membership2');
}
lib3()->ui->admin_message($msg, 'info');
?>
<div class="ms-settings-import">
<?php
echo $view->to_html();
?>
</div>
</div>
<?php
return ob_get_clean();
}
示例2: get_columns
public function get_columns()
{
$currency = MS_Plugin::instance()->settings->currency;
$columns = apply_filters('ms_helper_listtable_billing_columns', array('cb' => '<input type="checkbox" />', 'invoice' => __('Invoice #', 'membership2'), 'user' => __('User', 'membership2'), 'membership' => __('Membership', 'membership2'), 'status' => __('Status', 'membership2'), 'total' => __('Total', 'membership2'), 'due_date' => __('Due date', 'membership2'), 'gateway_id' => __('Gateway', 'membership2')));
$columns = apply_filters('ms_helper_listtable_billing_get_columns', $columns, $currency);
return $columns;
}
示例3: prepare_fields
/**
* Prepare html fields.
*
* @since 1.0.0
*
* @return array
*/
function prepare_fields()
{
$invoice = $this->data['invoice'];
$currency = MS_Plugin::instance()->settings->currency;
$user_name = '';
$transaction_link = '';
$user_id = 0;
$user_list = array();
if ($invoice->id) {
$member = $invoice->get_member();
$user_id = $member->id;
$user_name = $member->name;
$transaction_link = sprintf('<a href="%s" target="_blank">%s</a>', MS_Controller_Plugin::get_admin_url('billing', array('show' => 'logs', 'invoice' => $invoice->id)), __('Show Transactions', 'membership2'));
} else {
$user_list = MS_Model_Member::get_usernames(null, MS_Model_Member::SEARCH_ALL_USERS);
}
$fields = array('link_transactions' => array('id' => 'link_transactions', 'title' => $transaction_link, 'type' => MS_Helper_Html::TYPE_HTML_TEXT, 'wrapper_class' => 'ms-transactions-link'), 'txt_user' => array('id' => 'txt_user', 'title' => __('Invoice for member', 'membership2'), 'type' => MS_Helper_Html::TYPE_HTML_TEXT, 'value' => sprintf('<a href="%s">%s</a>', MS_Controller_Plugin::get_admin_url('add-member', array('user_id' => $user_id)), $user_name)), 'txt_membership' => array('id' => 'txt_membership', 'title' => __('Payment for membership', 'membership2'), 'type' => MS_Helper_Html::TYPE_HTML_TEXT), 'txt_created' => array('id' => 'txt_created', 'title' => __('Invoice created on', 'membership2'), 'type' => MS_Helper_Html::TYPE_HTML_TEXT), 'txt_separator' => array('type' => MS_Helper_Html::TYPE_HTML_SEPARATOR), 'status' => array('id' => 'status', 'title' => __('Invoice status', 'membership2'), 'type' => MS_Helper_Html::INPUT_TYPE_SELECT, 'field_options' => MS_Model_Invoice::get_status_types(true), 'value' => $invoice->status), 'user_id' => array('id' => 'user_id', 'title' => __('Invoice for member', 'membership2'), 'type' => MS_Helper_Html::INPUT_TYPE_SELECT, 'value' => $invoice->user_id, 'field_options' => $user_list), 'membership_id' => array('id' => 'membership_id', 'title' => __('Payment for membership', 'membership2'), 'type' => MS_Helper_Html::INPUT_TYPE_SELECT, 'value' => $invoice->membership_id, 'field_options' => $this->data['memberships']), 'amount' => array('id' => 'amount', 'title' => sprintf(__('Amount (%s)', 'membership2'), $currency), 'type' => MS_Helper_Html::INPUT_TYPE_NUMBER, 'value' => MS_Helper_Billing::format_price($invoice->amount), 'config' => array('step' => 'any', 'min' => 0)), 'discount' => array('id' => 'discount', 'title' => sprintf(__('Discount (%s)', 'membership2'), $currency), 'type' => MS_Helper_Html::INPUT_TYPE_NUMBER, 'value' => MS_Helper_Billing::format_price($invoice->discount), 'config' => array('step' => 'any', 'min' => 0)), 'due_date' => array('id' => 'due_date', 'title' => __('Due date', 'membership2'), 'type' => MS_Helper_Html::INPUT_TYPE_DATEPICKER, 'value' => $invoice->due_date), 'description' => array('id' => 'description', 'title' => __('Description', 'membership2'), 'type' => MS_Helper_Html::INPUT_TYPE_TEXT, 'class' => 'widefat', 'value' => $invoice->description), 'notes' => array('id' => 'notes', 'title' => __('Notes', 'membership2'), 'type' => MS_Helper_Html::INPUT_TYPE_TEXT_AREA, 'class' => 'widefat', 'value' => $invoice->get_notes_desc()), 'invoice_id' => array('id' => 'invoice_id', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $invoice->id), '_wpnonce' => array('id' => '_wpnonce', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => wp_create_nonce($this->data['action'])), 'action' => array('id' => 'action', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $this->data['action']), 'separator' => array('type' => MS_Helper_Html::TYPE_HTML_SEPARATOR), 'execute' => array('id' => 'execute', 'title' => __('Execute status change actions on Save (add/remove membership)', 'membership2'), 'type' => MS_Helper_Html::INPUT_TYPE_CHECKBOX, 'value' => true), 'cancel' => array('id' => 'cancel', 'type' => MS_Helper_Html::TYPE_HTML_LINK, 'title' => __('Cancel', 'membership2'), 'value' => __('Cancel', 'membership2'), 'url' => esc_url_raw(remove_query_arg(array('action', 'invoice_id'))), 'class' => 'wpmui-field-button button'), 'submit' => array('id' => 'submit', 'type' => MS_Helper_Html::INPUT_TYPE_SUBMIT, 'value' => __('Save Changes', 'membership2')));
if ($invoice->id > 0) {
$fields['user_id']['type'] = MS_Helper_Html::INPUT_TYPE_HIDDEN;
$fields['membership_id']['type'] = MS_Helper_Html::INPUT_TYPE_HIDDEN;
$fields['txt_membership']['value'] = $this->data['memberships'][$invoice->membership_id];
$fields['txt_created']['value'] = MS_Helper_Period::format_date($invoice->invoice_date);
} else {
unset($fields['txt_user']);
unset($fields['txt_membership']);
unset($fields['txt_created']);
unset($fields['txt_separator']);
}
return apply_filters('ms_view_billing_edit_prepare_fields', $fields, $this);
}
示例4: get_columns
/**
* Defines the columns of the list table
*
* @since 1.0.0
* @return array
*/
public function get_columns()
{
$currency = MS_Plugin::instance()->settings->currency;
$columns = apply_filters('ms_helper_listtable_transactionlog_columns', array('id' => __('ID', 'membership2'), 'date' => __('Time', 'membership2'), 'status' => '', 'method' => '', 'gateway' => __('Gateway', 'membership2'), 'amount' => __('Amount', 'membership2'), 'invoice' => __('Invoice', 'membership2'), 'note' => __('Details', 'membership2')));
$columns = apply_filters('ms_helper_listtable_transactionlog_get_columns', $columns, $currency);
return $columns;
}
示例5: 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();
}
示例6: option_key
/**
* validates and prepares the option key before it is used to read/write
* a value in the database.
*
* @since 1.0.0
* @api Used by MS_Factory
*
* @return string
*/
public function option_key()
{
// Option key should be all lowercase.
$key = strtolower(get_class($this));
// Network-wide mode uses different options then single-site mode.
if (MS_Plugin::is_network_wide()) {
$key .= '-network';
}
return substr($key, 0, 64);
}
示例7: set_gateway
/**
* Sets the parent gateway of the API object.
*
* The parent gateway object is used to fetch the API keys.
*
* @since 1.0.1.0
* @param MS_Gateway $gateway The parent gateway.
*/
public function set_gateway($gateway)
{
static $Stripe_Loaded = false;
if (!$Stripe_Loaded) {
require_once MS_Plugin::instance()->dir . '/lib/stripe-php/lib/Stripe.php';
do_action('ms_gateway_stripe_load_stripe_lib_after', $this);
$Stripe_Loaded = true;
}
$this->_gateway = $gateway;
$secret_key = $this->_gateway->get_secret_key();
M2_Stripe::setApiKey($secret_key);
}
示例8: column_discount
public function column_discount($item)
{
$html = '';
if (MS_Addon_Coupon_Model::TYPE_VALUE == $item->discount_type) {
$html = sprintf('%s %s', MS_Plugin::instance()->settings->currency, MS_Helper_Billing::format_price($item->discount));
} elseif (MS_Addon_Coupon_Model::TYPE_PERCENT == $item->discount_type) {
$html = $item->discount . ' %';
} else {
$html = apply_filters('ms_addon_coupon_helper_listtable_column_discount', $item->discount);
}
return $html;
}
示例9: process_item
/**
* Processes a single import command.
*
* @since 1.0.0
* @param array $item The import command.
*/
protected function process_item($item, $source)
{
$res = false;
lib2()->array->equip($item, 'task', 'data');
$task = $item['task'];
$data = $item['data'];
$model = MS_Factory::create('MS_Model_Import');
$model->source_key = $source;
// Set MS_STOP_EMAILS modifier to suppress any outgoing emails.
MS_Plugin::set_modifier('MS_STOP_EMAILS', true);
// Possible tasks are defined in ms-view-settings-import.js
switch ($task) {
case 'start':
lib2()->array->equip($item, 'clear');
$clear = lib2()->is_true($item['clear']);
$model->start($clear);
$res = true;
break;
case 'import-membership':
// Function expects an object, not an array!
$data = (object) $data;
$model->import_membership($data);
$res = true;
break;
case 'import-member':
// Function expects an object, not an array!
$data = (object) $data;
$model->import_member($data);
$res = true;
break;
case 'import-settings':
lib2()->array->equip($item, 'setting', 'value');
$setting = $item['setting'];
$value = $item['value'];
$model->import_setting($setting, $value);
$res = true;
break;
case 'done':
$model->done();
$res = true;
break;
}
/**
* After the import action was complated notify other objects and
* add-ons.
*
* @since 1.0.0
*/
do_action('ms_import_action_' . $task, $item);
return $res;
}
示例10: __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');
}
示例11: prepare_fields
/**
* Prepare html fields.
*
* @since 1.0.0
*
* @return array
*/
function prepare_fields()
{
$invoice = $this->data['invoice'];
$currency = MS_Plugin::instance()->settings->currency;
$fields = array('txt_user' => array('id' => 'txt_user', 'title' => __('Username', MS_TEXT_DOMAIN), 'type' => MS_Helper_Html::TYPE_HTML_TEXT, 'value' => $this->data['users'][$invoice->user_id]), 'txt_membership' => array('id' => 'txt_membership', 'title' => __('Membership', MS_TEXT_DOMAIN), 'type' => MS_Helper_Html::TYPE_HTML_TEXT), 'txt_separator' => array('type' => MS_Helper_Html::TYPE_HTML_SEPARATOR), 'status' => array('id' => 'status', 'title' => __('Status', MS_TEXT_DOMAIN), 'type' => MS_Helper_Html::INPUT_TYPE_SELECT, 'field_options' => MS_Model_Invoice::get_status_types(), 'value' => $invoice->status), 'user_id' => array('id' => 'user_id', 'title' => __('Username', MS_TEXT_DOMAIN), 'type' => MS_Helper_Html::INPUT_TYPE_SELECT, 'value' => $invoice->user_id, 'field_options' => $this->data['users']), 'membership_id' => array('id' => 'membership_id', 'title' => __('Membership', MS_TEXT_DOMAIN), 'type' => MS_Helper_Html::INPUT_TYPE_SELECT, 'value' => $invoice->membership_id, 'field_options' => $this->data['memberships']), 'description' => array('id' => 'description', 'title' => __('Description', MS_TEXT_DOMAIN), 'type' => MS_Helper_Html::INPUT_TYPE_TEXT, 'value' => $invoice->description), 'amount' => array('id' => 'amount', 'title' => sprintf(__('Amount (%s)', MS_TEXT_DOMAIN), $currency), 'type' => MS_Helper_Html::INPUT_TYPE_TEXT, 'value' => $invoice->amount), 'discount' => array('id' => 'discount', 'title' => sprintf(__('Discount (%s)', MS_TEXT_DOMAIN), $currency), 'type' => MS_Helper_Html::INPUT_TYPE_TEXT, 'value' => $invoice->discount), 'due_date' => array('id' => 'due_date', 'title' => __('Due date', MS_TEXT_DOMAIN), 'type' => MS_Helper_Html::INPUT_TYPE_DATEPICKER, 'value' => $invoice->due_date), 'notes' => array('id' => 'notes', 'title' => __('Notes', MS_TEXT_DOMAIN), 'type' => MS_Helper_Html::INPUT_TYPE_TEXT_AREA, 'value' => $invoice->get_notes_desc()), 'invoice_id' => array('id' => 'invoice_id', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $invoice->id), '_wpnonce' => array('id' => '_wpnonce', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => wp_create_nonce($this->data['action'])), 'action' => array('id' => 'action', 'type' => MS_Helper_Html::INPUT_TYPE_HIDDEN, 'value' => $this->data['action']), 'separator' => array('type' => MS_Helper_Html::TYPE_HTML_SEPARATOR), 'execute' => array('id' => 'execute', 'title' => __('Execute status change actions on Save (add/remove membership)', MS_TEXT_DOMAIN), 'type' => MS_Helper_Html::INPUT_TYPE_CHECKBOX, 'value' => true), 'cancel' => array('id' => 'cancel', 'type' => MS_Helper_Html::TYPE_HTML_LINK, 'title' => __('Cancel', MS_TEXT_DOMAIN), 'value' => __('Cancel', MS_TEXT_DOMAIN), 'url' => esc_url_raw(remove_query_arg(array('action', 'invoice_id'))), 'class' => 'wpmui-field-button button'), 'submit' => array('id' => 'submit', 'type' => MS_Helper_Html::INPUT_TYPE_SUBMIT, 'value' => __('Save Changes', MS_TEXT_DOMAIN)));
if ($invoice->id > 0) {
$fields['user_id']['type'] = MS_Helper_Html::INPUT_TYPE_HIDDEN;
$fields['membership_id']['type'] = MS_Helper_Html::INPUT_TYPE_HIDDEN;
$fields['txt_membership']['value'] = $this->data['memberships'][$invoice->membership_id];
} else {
unset($fields['txt_user']);
unset($fields['txt_membership']);
unset($fields['txt_separator']);
}
return apply_filters('ms_view_billing_edit_prepare_fields', $fields, $this);
}
示例12: get_tabs
/**
* Get available tabs.
*
* @since 1.0.0
*
* @return array The tabs configuration.
*/
public function get_tabs()
{
$tabs = array('general' => array('title' => __('General', MS_TEXT_DOMAIN)), 'shortcodes' => array('title' => __('Shortcodes', MS_TEXT_DOMAIN)), 'network' => array('title' => __('Network-Wide Protection', MS_TEXT_DOMAIN)), 'advanced' => array('title' => __('Advanced Settings', MS_TEXT_DOMAIN)), 'api' => array('title' => __('API Docs', MS_TEXT_DOMAIN), 'url' => MS_Plugin::instance()->url . 'docs/namespaces/default.html', 'target' => '_blank'));
if (!is_multisite()) {
unset($tabs['network']);
}
lib2()->array->equip_get('page');
$def_key = MS_Controller_Plugin::MENU_SLUG . '-help';
$page = sanitize_html_class($_GET['page'], $def_key);
foreach ($tabs as $key => $tab) {
if (empty($tabs[$key]['url'])) {
$tabs[$key]['url'] = sprintf('admin.php?page=%1$s&tab=%2$s', esc_attr($page), esc_attr($key));
}
}
return apply_filters('ms_controller_help_get_tabs', $tabs, $this);
}
示例13: to_html
/**
* Overrides parent's to_html() method.
*
* Creates an output buffer, outputs the HTML and grabs the buffer content before releasing it.
* Creates a wrapper 'ms-wrap' HTML element to contain content and navigation. The content inside
* the navigation gets loaded with dynamic method calls.
* e.g. if key is 'settings' then render_settings() gets called, if 'bob' then render_bob().
*
* @since 1.0.0
* @api
*
* @return string
*/
public function to_html()
{
$form_fields = $this->prepare_fields();
$setup_url = MS_Controller_Plugin::get_admin_url('setup');
ob_start();
// Render tabbed interface.
?>
<div class="ms-wrap wrap">
<form class="ms-welcome-box" action="<?php
echo esc_url($setup_url);
?>
" method="POST">
<h2 class="ms-welcome-title">
<?php
_e('Welcome!', MS_TEXT_DOMAIN);
?>
</h2>
<div class="ms-welcome-text">
<?php
_e('Hello and welcome to <strong>Membership2</strong> by WPMU DEV. Please follow this simple set-up<br />wizard to help us determine the settings that are most relevant to your needs. Don\'t worry, you<br />can always change these settings in the future.', MS_TEXT_DOMAIN);
?>
</div>
<div class="ms-welcome-image-box">
<img src="<?php
echo esc_attr(MS_Plugin::instance()->url);
?>
app/assets/images/welcome.png" class="ms-welcome-image" />
</div>
<?php
foreach ($form_fields as $field) {
MS_Helper_Html::html_element($field);
}
?>
</form>
</div>
<?php
return ob_get_clean();
}
示例14: init
/**
* Adds the hooks to integrate with Membership2.
*
* This function is called when Membership2 is active and initializtion
* is done.
*
* @since 1.0.0
* @param MS_Controller_Api $api The API instance.
*/
public function init($api)
{
$this->api = $api;
if (MS_Plugin::is_network_wide()) {
$affiliate_plugin = 'affiliate/affiliate.php';
if (!function_exists('is_plugin_active_for_network')) {
require_once ABSPATH . '/wp-admin/includes/plugin.php';
}
if (!is_plugin_active_for_network($affiliate_plugin) && current_user_can('manage_options')) {
lib2()->ui->admin_message(__('Membership2 uses network-wide protection.<br>Please network activate the Affiliate plugin to avoid problems with the Membership2 integration for Affiliates.', 'affiliate'), 'err');
}
}
// -- Frontend integration
// Reward for the referrer of the member.
add_action('ms_invoice_paid', array($this, 'payment_processed'), 10, 2);
// -- Admin integration
// Display Affiliate settings on the Membership payment options page.
add_action('ms_view_membership_payment_form', array($this, 'form'), 10, 2);
// Save Affiliate settings via Ajax request.
add_action('wp_ajax_' . self::AJAX_ACTION, array($this, 'save'));
}
示例15: is_current_site
/**
* Checks if the specified rule-key defines a rule that is relevant for the
* current site in the network.
*
* If network-wide protection is disabled this function always returns true.
*
* @since 1.0.0
* @param string $key
* @return bool
*/
public static function is_current_site($key)
{
$res = true;
$site_id = 0;
if (MS_Plugin::is_network_wide()) {
$parts = explode(':', $key);
// Some rules have no site_id prefix (like URL rules)
if (2 == count($parts)) {
list($site_id, $type) = $parts;
$site_id = intval($site_id);
$res = MS_Factory::current_blog_id() == $site_id;
}
}
return $res;
}