本文整理汇总了PHP中lib3函数的典型用法代码示例。如果您正苦于以下问题:PHP lib3函数的具体用法?PHP lib3怎么用?PHP lib3使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了lib3函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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().
*
* @todo Could use callback functions to call dynamic methods from within the helper, thus
* creating the navigation with a single method call and passing method pointers in the $tabs array.
*
* @since 1.0.0
*
* @return object
*/
public function to_html()
{
$this->check_simulation();
$items = $this->data['addon']->get_addon_list();
$lang = (object) array('active_badge' => __('ACTIVE', 'membership2'), 'show_details' => __('Details...', 'membership2'), 'close_details' => __('Close', 'membership2'));
$filters = array('all' => __('All', 'membership2'), 'active' => __('Active', 'membership2'), 'inactive' => __('Inactive', 'membership2'), 'options' => __('With options', 'membership2'));
ob_start();
?>
<div class="ms-wrap ms-addon-list">
<h2 class="ms-settings-title">
<i class="wpmui-fa wpmui-fa-puzzle-piece"></i>
<?php
_e('Membership Add-ons', 'membership2');
?>
</h2>
<form action="" method="post">
<?php
lib3()->html->addon_list($items, $lang, $filters);
?>
</form>
</div>
<?php
$html = ob_get_clean();
echo $html;
}
示例2: print_admin_message
public static function print_admin_message()
{
$msg = !empty($_GET['msg']) ? (int) $_GET['msg'] : 0;
$class = $msg > 0 ? 'updated' : 'error';
if ($msg = self::get_admin_message($msg)) {
lib3()->ui->admin_message($msg, $class);
}
}
示例3: prepare_fields
/**
* Prepare fields that are displayed in the form.
*
* @since 1.0.1.0
* @return array
*/
protected function prepare_fields()
{
$api_status = MS_Addon_Mailchimp::get_api_status();
$settings = $this->data['settings'];
$action = MS_Controller_Settings::AJAX_ACTION_UPDATE_CUSTOM_SETTING;
$auto_opt_in = $settings->get_custom_setting('mailchimp', 'auto_opt_in');
$auto_opt_in = lib3()->is_true($auto_opt_in);
$fields = array('mailchimp_api_test' => array('id' => 'mailchimp_api_test', 'type' => MS_Helper_Html::TYPE_HTML_TEXT, 'title' => __('MailChimp API test status: ', 'membership2'), 'value' => $api_status ? __('Verified', 'membership2') : __('Failed', 'membership2'), 'class' => $api_status ? 'ms-ok' : 'ms-nok'), 'mailchimp_api_key' => array('id' => 'mailchimp_api_key', 'name' => 'custom[mailchimp][api_key]', 'type' => MS_Helper_Html::INPUT_TYPE_TEXT, 'title' => __('MailChimp API Key', 'membership2'), 'desc' => sprintf('<div>' . __('Visit <a href="%1$s">your API dashboard</a> to create an API Key.', 'membership2') . '</div>', 'http://admin.mailchimp.com/account/api" target="_blank'), 'value' => $settings->get_custom_setting('mailchimp', 'api_key'), 'class' => 'ms-text-medium', 'ajax_data' => array('group' => 'mailchimp', 'field' => 'api_key', 'action' => $action)), 'separator' => array('type' => MS_Helper_Html::TYPE_HTML_SEPARATOR), 'auto_opt_in' => array('id' => 'auto_opt_in', 'name' => 'custom[mailchimp][auto_opt_in]', 'type' => MS_Helper_Html::INPUT_TYPE_RADIO_SLIDER, 'title' => __('Automatically opt-in new users to the mailing list.', 'membership2'), 'desc' => __('Users will not receive an email confirmation. You are responsible to inform your users.', 'membership2'), 'value' => $auto_opt_in, 'class' => 'inp-before', 'ajax_data' => array('group' => 'mailchimp', 'field' => 'auto_opt_in', 'action' => $action)), 'separator1' => array('type' => MS_Helper_Html::TYPE_HTML_SEPARATOR), 'mail_list_registered' => array('id' => 'mail_list_registered', 'name' => 'custom[mailchimp][mail_list_registered]', 'type' => MS_Helper_Html::INPUT_TYPE_SELECT, 'title' => __('Registered users mailing list (not members)', 'membership2'), 'field_options' => MS_Addon_Mailchimp::get_mail_lists(), 'value' => $settings->get_custom_setting('mailchimp', 'mail_list_registered'), 'ajax_data' => array('group' => 'mailchimp', 'field' => 'mail_list_registered', 'action' => $action)), 'mail_list_members' => array('id' => 'mail_list_members', 'name' => 'custom[mailchimp][mail_list_members]', 'type' => MS_Helper_Html::INPUT_TYPE_SELECT, 'title' => __('Members mailing list', 'membership2'), 'field_options' => MS_Addon_Mailchimp::get_mail_lists(), 'value' => $settings->get_custom_setting('mailchimp', 'mail_list_members'), 'ajax_data' => array('group' => 'mailchimp', 'field' => 'mail_list_members', 'action' => $action)), 'mail_list_deactivated' => array('id' => 'mail_list_deactivated', 'name' => 'custom[mailchimp][mail_list_deactivated]', 'type' => MS_Helper_Html::INPUT_TYPE_SELECT, 'title' => __('Deactivated memberships mailing list', 'membership2'), 'field_options' => MS_Addon_Mailchimp::get_mail_lists(), 'value' => $settings->get_custom_setting('mailchimp', 'mail_list_deactivated'), 'ajax_data' => array('group' => 'mailchimp', 'field' => 'mail_list_deactivated', 'action' => $action)));
return $fields;
}
示例4: set
/**
* Change a setting of the addon
*
* @since 1.0.0
*
* @param string $key
* @param string $value
*/
public function set($key, $value)
{
switch ($key) {
case 'is_live':
// This is a boolean value, not a string.
$value = lib3()->is_true($value);
break;
}
return $this->set_custom_setting(self::GROUP, $key, $value);
}
示例5: get_query_args
private function get_query_args()
{
$defaults = MS_Model_Invoice::get_query_args();
lib3()->array->equip_request('s');
$per_page = $this->get_items_per_page('invoice_per_page', self::DEFAULT_PAGE_SIZE);
$current_page = $this->get_pagenum();
$args = array('posts_per_page' => $per_page, 'offset' => ($current_page - 1) * $per_page);
// Filter by search-term
$search_filter = $_REQUEST['s'];
if (!empty($search_filter)) {
$this->search_string = $search_filter;
}
$args = wp_parse_args($args, $defaults);
return $args;
}
示例6: init
/**
* Initializes the Add-on. Always executed.
*
* @since 1.0.1.0
*/
public function init()
{
if (self::is_active()) {
$this->first_click_free = lib3()->is_true($this->get_setting('first_click_free'));
$this->add_filter('ms_model_membership_is_system', 'is_system', 10, 2);
$this->add_filter('ms_model_membership_is_valid_type', 'is_valid_type', 10, 2);
$this->add_filter('ms_model_membership_get_types', 'get_types');
$this->add_filter('ms_helper_listtable_membership_column_name_actions', 'list_table_actions', 10, 2);
$this->add_filter('ms_helper_listtable_memberships_name_badge', 'list_table_badge', 10, 2);
$this->add_action('ms_init_done', 'apply_membership');
// Last action in the init sequence.
$this->create_membership();
} else {
$this->add_filter('ms_model_membership_get_memberships', 'hide_membership', 10, 2);
}
}
示例7: prepare_fields
protected function prepare_fields()
{
$gateway = $this->data['model'];
$action = MS_Controller_Gateway::AJAX_ACTION_UPDATE_GATEWAY;
$nonce = wp_create_nonce($action);
$fields = array('mode' => array('id' => 'mode', 'title' => __('Mode', 'membership2'), 'type' => MS_Helper_Html::INPUT_TYPE_SELECT, 'value' => $gateway->mode, 'field_options' => $gateway->get_mode_types(), 'class' => 'ms-text-large', 'ajax_data' => array(1)), 'api_login_id' => array('id' => 'api_login_id', 'title' => __('API Login ID', 'membership2'), 'type' => MS_Helper_Html::INPUT_TYPE_TEXT, 'value' => $gateway->api_login_id, 'class' => 'ms-text-large', 'ajax_data' => array(1)), 'api_transaction_key' => array('id' => 'api_transaction_key', 'title' => __('API Transaction Key', 'membership2'), 'type' => MS_Helper_Html::INPUT_TYPE_TEXT, 'value' => $gateway->api_transaction_key, 'class' => 'ms-text-large', 'ajax_data' => array(1)), 'pay_button_url' => array('id' => 'pay_button_url', 'title' => apply_filters('ms_translation_flag', __('Payment button label or URL', 'membership2'), 'gateway-button' . $gateway->id), 'type' => MS_Helper_Html::INPUT_TYPE_TEXT, 'value' => $gateway->pay_button_url, 'class' => 'ms-text-large', 'ajax_data' => array(1)), 'secure_cc' => array('id' => 'secure_cc', 'title' => __('Secure Payments', 'membership2'), 'type' => MS_Helper_Html::INPUT_TYPE_RADIO_SLIDER, 'value' => lib3()->is_true($gateway->secure_cc), 'ajax_data' => array(1)), 'secure_cc_off' => array('id' => 'secure_cc_off', 'type' => MS_Helper_Html::TYPE_HTML_TEXT, 'value' => __('Default payment option: Credit card details need to be entered once and can be reused without entering the CVC number again.', 'membership2'), 'class' => 'hidden secure_cc_off'), 'secure_cc_on' => array('id' => 'secure_cc_on', 'type' => MS_Helper_Html::TYPE_HTML_TEXT, 'value' => __('Secure payment option: The user needs to enter the credit cards CVC number for every transaction - even for saved credit cards and every recurring payment.', 'membership2'), 'class' => 'hidden secure_cc_on'));
// Process the fields and add missing default attributes.
foreach ($fields as $key => $field) {
if (!empty($field['ajax_data'])) {
$fields[$key]['ajax_data']['field'] = $fields[$key]['id'];
$fields[$key]['ajax_data']['_wpnonce'] = $nonce;
$fields[$key]['ajax_data']['action'] = $action;
$fields[$key]['ajax_data']['gateway_id'] = $gateway->id;
}
}
return $fields;
}
示例8: process_form
/**
* Processes a form submit and changes the rule values, if valid form data
* is found.
*
* @since 1.0.0
*/
private function process_form()
{
$action = false;
if (isset($_POST['rule_action'])) {
$action = $_POST['rule_action'];
if (!$this->verify_nonce($action)) {
$action = false;
}
} elseif (isset($_GET['rule_action'])) {
$action = $_GET['rule_action'];
if (!$this->verify_nonce($action, 'GET')) {
$action = false;
}
}
if (empty($action)) {
return;
}
$redirect = false;
switch ($action) {
case self::ACTION_ADD:
lib3()->array->strip_slashes($_POST, 'url_value');
$url = $_POST['url_value'];
$base = MS_Model_Membership::get_base();
$rule = $base->get_rule(self::RULE_ID);
$rule->add_url($url);
$base->set_rule(self::RULE_ID, $rule);
$base->save();
$redirect = true;
break;
case self::ACTION_DELETE:
$id = $_REQUEST['item'];
$base = MS_Model_Membership::get_base();
$rule = $base->get_rule(self::RULE_ID);
$rule->delete_url($id);
$base->set_rule(self::RULE_ID, $rule);
$base->save();
$redirect = true;
break;
}
if ($redirect) {
$target = esc_url_raw(remove_query_arg(array('_wpnonce', 'item', 'rule_action')));
wp_safe_redirect($target);
exit;
}
}
示例9: widget
/**
* Outputs the content of the widget.
*
* @since 1.0.0
*
* @param array $args
* @param array $instance
*/
public function widget($args, $instance)
{
$redirect_login = false;
$redirect_logout = false;
$shortcode_args = '';
if (!empty($instance['redirect_login'])) {
$redirect_login = lib3()->net->expand_url($instance['redirect_login']);
}
if (!empty($instance['redirect_logout'])) {
$redirect_logout = lib3()->net->expand_url($instance['redirect_logout']);
}
if (!empty($instance['shortcode_args'])) {
$shortcode_args = $instance['shortcode_args'];
}
echo $args['before_widget'];
if (!empty($instance['title'])) {
echo $args['before_title'];
echo apply_filters('widget_title', $instance['title']);
echo $args['after_title'];
}
$scode = sprintf('[%1$s header="no" %2$s %3$s %4$s]', MS_Helper_Shortcode::SCODE_LOGIN, $redirect_login ? 'redirect_login="' . $redirect_login . '"' : '', $redirect_logout ? 'redirect_logout="' . $redirect_logout . '"' : '', $shortcode_args);
echo do_shortcode($scode);
echo $args['after_widget'];
}
示例10: set_tax_profile_value
/**
* Internal helper function that saves a user profile value either to DB or
* to the session (depending if the user is logged in or not).
*
* @since 1.0.0
* @internal
*
* @param MS_Model_Member $member
* @param string $key The field key.
* @param mixed $value The value to save
* @return bool True means that the value was set in $member, otherwise it
* was set in the session.
*/
protected static function set_tax_profile_value($member, $key, $value)
{
if (is_object($member) && $member->is_valid()) {
$member->set_custom_data($key, $value);
$need_save = true;
} else {
lib3()->session->get_clear('ms_' . $key);
lib3()->session->add('ms_' . $key, $value);
$need_save = false;
}
return $need_save;
}
示例11: activate_addon
/**
* Adds activation details for a single add-on to the import object
*
* @since 1.0.0
* @param string $name The add-on name
*/
protected function activate_addon($name)
{
$this->data->settings['addons'] = lib3()->array->get($this->data->settings['addons']);
$this->data->settings['addons'][$name] = true;
}
示例12: enqueue_scripts
/**
* Load Membership manager specific scripts.
*
* @since 1.0.0
*/
public function enqueue_scripts()
{
$data = array('ms_init' => array(), 'lang' => array('msg_delete' => __('Do you want to completely delete the membership <strong>%s</strong> including all subscriptions?', 'membership2'), 'btn_delete' => __('Delete', 'membership2'), 'btn_cancel' => __('Cancel', 'membership2'), 'quickedit_error' => __('Error while saving changes.', 'membership2')));
$step = $this->get_step();
switch ($step) {
case self::STEP_WELCOME_SCREEN:
break;
case self::STEP_ADD_NEW:
$data['ms_init'][] = 'view_membership_add';
$data['initial_url'] = MS_Controller_Plugin::get_admin_url();
break;
case self::STEP_OVERVIEW:
$data['ms_init'][] = 'view_membership_overview';
break;
case self::STEP_PAYMENT:
$data['ms_init'][] = 'view_membership_payment';
$data['ms_init'][] = 'view_settings_payment';
break;
case self::STEP_EDIT:
$data['ms_init'][] = 'view_membership_payment';
$tab = $this->get_active_edit_tab();
switch ($tab) {
case self::TAB_TYPE:
add_thickbox();
$data['ms_init'][] = 'view_membership_add';
break;
case self::TAB_UPGRADE:
$data['ms_init'][] = 'view_membership_upgrade';
break;
case self::TAB_MESSAGES:
$data['ms_init'][] = 'view_settings_protection';
break;
case self::TAB_EMAILS:
$data['ms_init'][] = 'view_settings_automated_msg';
break;
}
do_action('ms_controller_membership_enqueue_scripts_tab-' . $tab, $this);
break;
case self::STEP_MS_LIST:
$data['ms_init'][] = 'view_membership_list';
$data['ms_init'][] = 'view_settings_setup';
break;
}
lib3()->ui->data('ms_data', $data);
wp_enqueue_script('ms-admin');
wp_enqueue_script('jquery-validate');
do_action('ms_controller_membership_enqueue_scripts', $this);
do_action('ms_controller_membership_enqueue_scripts-' . $step, $this);
}
示例13: enqueue_scripts
/**
* Load specific scripts.
*
* @since 1.0.0
*/
public function enqueue_scripts()
{
$data = array('ms_init' => array('view_help'));
lib3()->ui->data('ms_data', $data);
wp_enqueue_script('ms-admin');
}
示例14: enqueue_scripts
/**
* Load Membership admin scripts.
*
* @since 1.0.0
*/
public function enqueue_scripts()
{
$active_tab = $this->get_active_tab();
do_action('ms_controller_settings_enqueue_scripts_' . $active_tab);
$plugin_url = MS_Plugin::instance()->url;
$version = MS_Plugin::instance()->version;
$initial_url = MS_Controller_Plugin::get_admin_url();
$data = array('ms_init' => array(), 'initial_url' => $initial_url);
$data['ms_init'][] = 'view_settings';
switch ($active_tab) {
case self::TAB_PAYMENT:
add_thickbox();
$data['ms_init'][] = 'view_settings_payment';
break;
case self::TAB_MESSAGES:
$data['ms_init'][] = 'view_settings_protection';
break;
case self::TAB_EMAILS:
$data['ms_init'][] = 'view_settings_automated_msg';
break;
case self::TAB_GENERAL:
$data['ms_init'][] = 'view_settings_setup';
break;
}
lib3()->ui->data('ms_data', $data);
wp_enqueue_script('ms-admin');
}
示例15: enqueue_scripts
/**
* Enqueues necessary scripts and styles.
*
* Related Action Hooks:
* - wp_enqueue_scripts
* - admin_enqueue_scripts
*
* @since 1.0.0
*/
public function enqueue_scripts()
{
$data = array('ms_init' => array('controller_adminbar'), 'switching_text' => __('Switching...', 'membership2'));
lib3()->ui->add('select');
lib3()->ui->data('ms_data', $data);
wp_enqueue_script('ms-admin');
wp_enqueue_script('jquery-ui-datepicker');
wp_enqueue_style('ms-public');
}