本文整理汇总了PHP中MS_Factory::load方法的典型用法代码示例。如果您正苦于以下问题:PHP MS_Factory::load方法的具体用法?PHP MS_Factory::load怎么用?PHP MS_Factory::load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MS_Factory
的用法示例。
在下文中一共展示了MS_Factory::load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle_render_callback
/**
* Tells Membership2 Admin to display this form to manage this rule.
*
* @since 1.0.0
*
* @param array $callback (Invalid callback)
* @param array $data The data collection.
* @return array Correct callback.
*/
public function handle_render_callback($callback, $data)
{
$view = MS_Factory::load('MS_Addon_BuddyPress_Rule_View');
$view->data = $data;
$callback = array($view, 'to_html');
return $callback;
}
示例2: save_user_create_event
/**
* Fires only at user creation from admin
* Create even to send notification email.
*
* @since 1.0.2.6
*
* @var int $user_id
*/
public function save_user_create_event($user_id)
{
if (is_admin()) {
$member = MS_Factory::load('MS_Model_Member', $user_id);
MS_Model_Event::save_event(MS_Model_Event::TYPE_MS_REGISTERED, $member);
}
}
示例3: to_html
/**
* Create view output.
*
* @since 1.0.0
* @return string
*/
public function to_html()
{
$list_table = MS_Factory::create('MS_Helper_ListTable_Event');
$list_table->prepare_items();
if (isset($_REQUEST['membership_id'])) {
$membership = MS_Factory::load('MS_Model_Membership', $_REQUEST['membership_id']);
$title = sprintf(__('%s News', 'membership2'), $membership->get_name_tag());
$url = esc_url_raw(add_query_arg(array('step' => MS_Controller_Membership::STEP_OVERVIEW), remove_query_arg(array('paged', 'order', 'post_mime_type', 'detached', 'orderby', 's'))));
$back_link = array('id' => 'back', 'type' => MS_Helper_Html::TYPE_HTML_LINK, 'value' => __('» Back to Overview', 'membership2'), 'url' => $url, 'class' => 'wpmui-field-button button');
} else {
$title = __('Membership News', 'membership2');
$back_link = '';
}
ob_start();
?>
<div class="wrap ms-wrap ms-membership-news">
<?php
MS_Helper_Html::settings_header(array('title' => $title));
MS_Helper_Html::html_element($back_link);
$list_table->search_box();
$list_table->views();
?>
<form action="" method="post">
<?php
$list_table->display();
?>
</form>
</div>
<?php
$html = ob_get_clean();
echo '' . $html;
}
示例4: after_load
/**
* Initialize the object.
*
* @since 1.0.0
*/
public function after_load()
{
parent::after_load();
$this->_api = MS_Factory::load('MS_Gateway_Stripe_Api');
// If the gateway is initialized for the first time then copy settings
// from the Stripe Single gateway.
if (false === $this->test_secret_key) {
$single = MS_Factory::load('MS_Gateway_Stripe');
$this->test_secret_key = $single->test_secret_key;
$this->secret_key = $single->secret_key;
$this->test_publishable_key = $single->test_publishable_key;
$this->publishable_key = $single->publishable_key;
$this->save();
}
$this->id = self::ID;
$this->name = __('Stripe Subscriptions Gateway', MS_TEXT_DOMAIN);
$this->group = 'Stripe';
$this->manual_payment = false;
// Recurring charged automatically
$this->pro_rate = true;
$this->unsupported_payment_types = array(MS_Model_Membership::PAYMENT_TYPE_PERMANENT, MS_Model_Membership::PAYMENT_TYPE_FINITE, MS_Model_Membership::PAYMENT_TYPE_DATE_RANGE);
// Update all payment plans and coupons.
$this->add_action('ms_gateway_toggle_stripeplan', 'update_stripe_data');
// Update a single payment plan.
$this->add_action('ms_saved_MS_Model_Membership', 'update_stripe_data_membership');
// Update a single coupon.
$this->add_action('ms_saved_MS_Addon_Coupon_Model', 'update_stripe_data_coupon');
}
示例5: is_active
/**
* Checks if the current Add-on is enabled
*
* @since 1.0.0
* @return bool
*/
public static function is_active()
{
if (!self::wp_recaptcha_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);
}
示例6: get_model
/**
* Returns the singleton instance of the MS_Model_Pages object
*
* @since 1.0.0
* @return MS_Model_Pages
*/
public static function get_model()
{
static $Model = null;
if (null === $Model) {
$Model = MS_Factory::load('MS_Model_Pages');
}
return $Model;
}
示例7: init
/**
* Initializes the Add-on. Always executed.
*
* @since 1.0.0
*/
public function init()
{
// Always remove bbpress from MS_Rule_CptGroup_Model.
$this->add_filter('ms_rule_cptgroup_model_get_excluded_content', 'exclude_bbpress_cpts');
if (self::is_active()) {
$this->add_filter('ms_controller_protection_tabs', 'rule_tabs');
MS_Factory::load('MS_Addon_Bbpress_Rule');
}
}
示例8: __construct
/**
* Initialize the Add-On.
*
* @since 1.0.0
*/
public function __construct()
{
parent::__construct();
self::$model = MS_Factory::load('MS_Model_Addon');
self::$settings = MS_Factory::load('MS_Model_Settings');
$this->add_filter('ms_model_addon_register', 'register');
$this->add_action('ms_model_addon_initialize', 'init_addon');
$this->add_ajax_action($this->ajax_action(), 'ajax_update_settings');
}
示例9: after_load
/**
* Initialize the object.
*
* @since 1.0.0
* @internal
*/
public function after_load()
{
parent::after_load();
$this->_api = MS_Factory::load('MS_Gateway_Stripe_Api');
$this->id = self::ID;
$this->name = __('Stripe Single Gateway', 'membership2');
$this->group = 'Stripe';
$this->manual_payment = true;
// Recurring billed/paid manually
$this->pro_rate = true;
}
示例10: after_load
/**
* Initialize the object.
*
* @since 1.0.0
* @internal
*/
public function after_load()
{
parent::after_load();
$this->_api = MS_Factory::load('MS_Gateway_Stripe_Api');
$this->id = self::ID;
$this->name = __('Stripe Single Gateway', 'membership2');
$this->group = 'Stripe';
$this->manual_payment = true;
// Recurring billed/paid manually
$this->pro_rate = true;
$this->add_filter('ms_model_pages_get_ms_page_url', 'ms_model_pages_get_ms_page_url_cb', 99, 4);
}
示例11: stripeplan_subscription
/**
* Tests the Stripe Subscription gateway
* @test
*/
function stripeplan_subscription()
{
$gateway = MS_Model_Gateway::factory(MS_Gateway_Stripeplan::ID);
$user_id = TData::id('user', 'editor');
$membership_id = TData::id('membership', 'recurring');
$subscription = TData::subscribe($user_id, $membership_id);
$controller = MS_Factory::load('MS_Controller_Gateway');
$gateway->update_stripe_data();
$data = array('card' => array('number' => '4242424242424242', 'exp_month' => 12, 'exp_year' => date('Y') + 1, 'cvc' => '314'));
$res = M2_Stripe_Token::create($data);
$token = $res->id;
$form_data = array('_wpnonce' => wp_create_nonce($gateway->id . '_' . $subscription->id), 'gateway' => $gateway->id, 'ms_relationship_id' => $subscription->id, 'step' => 'process_purchase', 'stripeToken' => $token, 'stripeTokenType' => 'card', 'stripeEmail' => 'editor@local.dev');
$_POST = $form_data;
$_REQUEST = $_POST;
// Right now the subscription must have status PENDING
$this->assertEquals(MS_Model_Relationship::STATUS_PENDING, $subscription->status);
/*
* This function processes the purchase and will set the subscription
* to active.
*/
$controller->process_purchase();
// Check the subscription status.
$this->assertEquals(MS_Model_Relationship::STATUS_ACTIVE, $subscription->status);
$this->assertEquals(1, count($subscription->payments));
// Modify the expiration date to trigger another payment.
$today = date('Y-m-d');
$subscription->expire_date = $today;
$this->assertEquals($today, $subscription->expire_date);
$this->assertEquals(0, $subscription->get_remaining_period());
// Trigger next payment and validate it.
$subscription->check_membership_status();
$this->assertEquals(2, count($subscription->payments));
// Modify the expiration date to trigger another payment.
$subscription->expire_date = $today;
$this->assertEquals($today, $subscription->expire_date);
$this->assertEquals(0, $subscription->get_remaining_period());
// Trigger next payment and validate it.
// THIS TIME NO PAYMENT SHOULD BE MADE because paycycle_repetitions = 2!
$subscription->check_membership_status();
$this->assertEquals(2, count($subscription->payments));
// Also the subscription should be cancelled at stripe now.
$customer_id = $subscription->get_member()->get_gateway_profile(MS_Gateway_Stripe_Api::ID, 'customer_id');
$customer = M2_Stripe_Customer::retrieve($customer_id);
$invoice = $subscription->get_previous_invoice();
$stripe_sub_id = $invoice->external_id;
$stripe_sub = $customer->subscriptions->retrieve($stripe_sub_id);
$this->assertEquals('active', $stripe_sub->status);
$this->assertTrue($stripe_sub->cancel_at_period_end);
// Clean up.
$customer->delete();
}
示例12: staging_data_is_correct
/**
* Checks if shared-setup was working.
* @test
*/
function staging_data_is_correct()
{
$this->assertFalse(empty(TData::id('user', 'admin')));
wp_set_current_user(TData::id('user', 'admin'));
$this->assertEquals(get_current_user_id(), TData::id('user', 'admin'));
$this->assertFalse(empty(TData::id('user', 'editor')));
$this->assertFalse(empty(TData::id('post', 'sample-page')));
$this->assertEquals('page', get_post_type(TData::id('post', 'sample-page')));
$ms_id = TData::id('membership', 'simple');
$this->assertFalse(empty($ms_id));
$membership = MS_Factory::load('MS_Model_Membership', $ms_id);
$this->assertEquals($ms_id, $membership->id);
$this->assertEquals(29, $membership->price);
}
示例13: get_global_payment_fields
/**
* Prepares a list with field definitions that are required to render the
* payment list/global options (i.e. currency and sender name)
*
* @since 1.0.0
*
* @return array
*/
protected function get_global_payment_fields()
{
$settings = MS_Factory::load('MS_Model_Settings');
$action = MS_Controller_Settings::AJAX_ACTION_UPDATE_SETTING;
$nonce = wp_create_nonce($action);
$fields = array('currency' => array('id' => 'currency', 'type' => MS_Helper_Html::INPUT_TYPE_SELECT, 'title' => __('Select payment currency', MS_TEXT_DOMAIN), 'value' => $settings->currency, 'field_options' => $settings->get_currencies(), 'class' => '', 'class' => 'chosen-select', 'data_ms' => array('field' => 'currency')), 'invoice_sender_name' => array('id' => 'invoice_sender_name', 'type' => MS_Helper_Html::INPUT_TYPE_TEXT, 'title' => __('Invoice sender name', MS_TEXT_DOMAIN), 'value' => $settings->invoice_sender_name, 'data_ms' => array('field' => 'invoice_sender_name')));
foreach ($fields as $key => $field) {
if (is_array($field['data_ms'])) {
$fields[$key]['data_ms']['_wpnonce'] = $nonce;
$fields[$key]['data_ms']['action'] = $action;
}
}
return apply_filters('ms_gateway_view_get_global_payment_fields', $fields);
}
示例14: member_capabilities_rule
/**
* Check member capability add-on.
* @test
*/
function member_capabilities_rule()
{
// We only test the addon as an isolated unit.
$addon = MS_Factory::load('MS_Rule_MemberCaps_Model');
remove_all_filters('user_has_cap');
$addon->protect_admin_content();
wp_set_current_user(TData::id('user', 'admin'));
$this->assertTrue(current_user_can('manage_options'), 'admin');
$this->assertTrue(current_user_can('edit_theme_options'), 'admin');
wp_set_current_user(TData::id('user', 'editor'));
$this->assertFalse(current_user_can('manage_options'), 'editor');
$this->assertFalse(current_user_can('edit_theme_options'), 'editor');
$this->assertTrue(current_user_can('edit_pages'), 'editor');
$this->assertTrue(current_user_can('delete_pages'), 'editor');
}
示例15: did_import
/**
* Checks if the user did import data from this source before.
*
* This information is not entirely reliable, since data could have been
* deleted again after import.
*
* @since 1.0.0
* @return bool
*/
public static function did_import()
{
$settings = MS_Factory::load('MS_Model_Settings');
$did_import = !empty($settings->import[self::KEY]);
/**
* Allow users to manually declare that some M2 subscriptions were
* imported from old Membership plugin.
*
* As a result M2 will additionally listen to the old M1 IPN URL for
* PayPal payment notifications.
*
* @since 1.0.2.4
* @param bool $did_import
*/
return apply_filters('ms_did_import_m1_data', $did_import);
}