本文整理汇总了PHP中lib2函数的典型用法代码示例。如果您正苦于以下问题:PHP lib2函数的具体用法?PHP lib2怎么用?PHP lib2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了lib2函数的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', MS_TEXT_DOMAIN), 'show_details' => __('Details...', MS_TEXT_DOMAIN), 'close_details' => __('Close', MS_TEXT_DOMAIN));
$filters = array('all' => __('All', MS_TEXT_DOMAIN), 'active' => __('Active', MS_TEXT_DOMAIN), 'inactive' => __('Inactive', MS_TEXT_DOMAIN), 'options' => __('With options', MS_TEXT_DOMAIN));
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', MS_TEXT_DOMAIN);
?>
</h2>
<form action="" method="post">
<?php
lib2()->html->plugin_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)) {
lib2()->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 = lib2()->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: ', MS_TEXT_DOMAIN), 'value' => $api_status ? __('Verified', MS_TEXT_DOMAIN) : __('Failed', MS_TEXT_DOMAIN), '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', MS_TEXT_DOMAIN), 'desc' => sprintf('<div>' . __('Visit <a href="%1$s">your API dashboard</a> to create an API Key.', MS_TEXT_DOMAIN) . '</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.', MS_TEXT_DOMAIN), 'desc' => __('Users will not receive an email confirmation. You are responsible to inform your users.', MS_TEXT_DOMAIN), '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)', MS_TEXT_DOMAIN), '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', MS_TEXT_DOMAIN), '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', MS_TEXT_DOMAIN), '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 = lib2()->is_true($value);
break;
}
return $this->set_custom_setting(self::GROUP, $key, $value);
}
示例5: __construct
/**
* Constructor is private -> singleton.
*
* @since 2.0
*/
private function __construct()
{
if (is_admin()) {
// in_widget_form: Add our button inside each widget.
add_action('in_widget_form', array($this, 'admin_widget_button'), 10, 3);
// in_widget_form: Update data of widget-group (see notes below).
add_action('in_widget_form', array($this, 'update_widget_group'), 10, 3);
// When the widget is saved (via Ajax) we save our options.
add_filter('widget_update_callback', array($this, 'admin_widget_update'), 9999, 4);
// Load the javascript support file for this module.
lib2()->ui->add(CSB_JS_URL . 'cs-cloning.min.js', 'widgets.php');
lib2()->ui->add(CSB_CSS_URL . 'cs-cloning.css', 'widgets.php');
}
}
示例6: get_query_args
private function get_query_args()
{
$defaults = MS_Model_Invoice::get_query_args();
lib2()->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;
}
示例7: Incsub
/**
Plugin Name: WordPress PopUp
Plugin URI: http://premium.wpmudev.org/project/the-pop-over-plugin/
Description: Allows you to display a fancy PopUp to visitors sitewide or per blog. A *very* effective way of advertising a mailing list, special offer or running a plain old ad.
Version: 4.7.1.1
Author: WPMU DEV
Author URI: http://premium.wpmudev.org
Textdomain: popover
WDP ID: 123
Copyright 2007-2013 Incsub (http://incsub.com)
Author - Barry (Incsub)
Contributors - Marko Miljus (Incsub), Ve Bailovity (Incsub)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License (Version 2 - GPLv2) as published by
the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
function inc_popup_free_init()
{
// Check if the PRO plugin is present and activated.
if (defined('PO_VERSION') && 'pro' == PO_VERSION) {
return false;
}
if (!defined('PO_LANG')) {
// Used for more readable i18n functions: __( 'text', PO_LANG );
define('PO_LANG', 'popover');
define('PO_VERSION', '4.7');
/**
* The current DB/build version. NOT THE SAME AS THE PLUGIN VERSION!
* Increase this when DB structure changes, migration code is required, etc.
* See IncPopupDatabase: db_is_current() and db_update()
*/
define('PO_BUILD', 6);
$plugin_dir = trailingslashit(dirname(__FILE__));
$plugin_dir_rel = trailingslashit(dirname(plugin_basename(__FILE__)));
$plugin_url = plugin_dir_url(__FILE__);
define('PO_LANG_DIR', $plugin_dir_rel . 'lang/');
define('PO_TPL_DIR', $plugin_dir . 'css/tpl/');
define('PO_INC_DIR', $plugin_dir . 'inc/');
define('PO_JS_DIR', $plugin_dir . 'js/');
define('PO_CSS_DIR', $plugin_dir . 'css/');
define('PO_VIEWS_DIR', $plugin_dir . 'views/');
define('PO_TPL_URL', $plugin_url . 'css/tpl/');
define('PO_JS_URL', $plugin_url . 'js/');
define('PO_CSS_URL', $plugin_url . 'css/');
define('PO_IMG_URL', $plugin_url . 'img/');
// Include function library.
require_once PO_INC_DIR . 'external/wpmu-lib/core.php';
lib2()->translate_plugin(PO_LANG, PO_LANG_DIR);
require_once PO_INC_DIR . 'external/wdev-frash/module.php';
// Register the current plugin.
do_action('wdev-register-plugin', plugin_basename(__FILE__), 'WordPress PopUp', '/plugins/wordpress-popup/', __('Get Tips!', PO_LANG), '');
// All done!
require_once PO_INC_DIR . 'config-defaults.php';
if (is_admin()) {
// Defines class 'IncPopup'.
require_once PO_INC_DIR . 'class-popup-admin.php';
} else {
// Defines class 'IncPopup'.
require_once PO_INC_DIR . 'class-popup-public.php';
}
// Initialize the plugin as soon as we have identified the current user.
IncPopup::instance();
}
}
示例8: __construct
/**
* Constructor is private -> singleton.
*
* @since 2.0
*/
private function __construct()
{
if (is_admin()) {
// in_widget_form: Add our button inside each widget.
add_action('in_widget_form', array($this, 'admin_widget_button'), 10, 3);
// When the widget is saved (via Ajax) we save our options.
add_filter('widget_update_callback', array($this, 'admin_widget_update'), 10, 3);
lib2()->ui->add(CSB_JS_URL . 'cs-visibility.min.js', 'widgets.php');
lib2()->ui->add(CSB_CSS_URL . 'cs-visibility.css', 'widgets.php');
// Custom Sidebars Ajax request.
add_action('cs_ajax_request_get', array($this, 'handle_ajax'));
} else {
// Filters the list of widget-areas and their widgets
add_filter('sidebars_widgets', array($this, 'sidebars_widgets'));
}
}
示例9: init
/**
* Initializes the Add-on. Always executed.
*
* @since 1.0.1.0
*/
public function init()
{
if (self::is_active()) {
$this->first_click_free = lib2()->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);
}
}
示例10: init_public
/**
* Enqueue the anonymous script.
* Action: `popup-init-loading-method`
*
* @since 4.6
* @param string $method The option saved on the settings screen.
* @param IncPopup $handler Public IncPopup object that called the action.
*/
public static function init_public($method, $handler)
{
if (self::METHOD != $method) {
return false;
}
// Generate a random Script URL.
$slug = self::$_slug;
$val = self::_rot(time(), rand(1, 22));
$script_url = esc_url_raw(add_query_arg(array($slug => $val), lib2()->net->current_url()));
// The script is the home URL with a special URL-param.
wp_enqueue_script($slug, $script_url, array('jquery'));
// Enable animations in 'Anonymous Script'
lib2()->ui->add(PO_CSS_URL . 'animate.min.css', 'front');
// This checks if the current URL contains the special URL-param.
// If the param is found then the PopUp details are output instead of the page.
add_action('template_redirect', array(__CLASS__, 'apply'));
}
示例11: 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:
lib2()->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;
}
}
示例12: Incsub
/**
Plugin Name: PopUp Pro
Plugin URI: http://premium.wpmudev.org/project/the-pop-over-plugin/
Description: Allows you to display a fancy PopUp to visitors sitewide or per blog. A *very* effective way of advertising a mailing list, special offer or running a plain old ad.
Version: 4.7.1.1
Author: WPMU DEV
Author URI: http://premium.wpmudev.org
Textdomain: popover
WDP ID: 123
Copyright 2007-2013 Incsub (http://incsub.com)
Author - Barry (Incsub)
Contributors - Marko Miljus (Incsub), Ve Bailovity (Incsub)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License (Version 2 - GPLv2) as published by
the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
function inc_popup_pro_init()
{
if (!defined('PO_LANG')) {
// Used for more readable i18n functions: __( 'text', PO_LANG );
define('PO_LANG', 'popover');
define('PO_VERSION', 'pro');
/**
* The current DB/build version. NOT THE SAME AS THE PLUGIN VERSION!
* Increase this when DB structure changes, migration code is required, etc.
* See IncPopupDatabase: db_is_current() and db_update()
*/
define('PO_BUILD', 6);
$plugin_dir = trailingslashit(dirname(__FILE__));
$plugin_dir_rel = trailingslashit(dirname(plugin_basename(__FILE__)));
$plugin_url = plugin_dir_url(__FILE__);
define('PO_LANG_DIR', $plugin_dir_rel . 'lang/');
define('PO_TPL_DIR', $plugin_dir . 'css/tpl/');
define('PO_INC_DIR', $plugin_dir . 'inc/');
define('PO_JS_DIR', $plugin_dir . 'js/');
define('PO_CSS_DIR', $plugin_dir . 'css/');
define('PO_VIEWS_DIR', $plugin_dir . 'views/');
define('PO_TPL_URL', $plugin_url . 'css/tpl/');
define('PO_JS_URL', $plugin_url . 'js/');
define('PO_CSS_URL', $plugin_url . 'css/');
define('PO_IMG_URL', $plugin_url . 'img/');
// Include function library.
require_once PO_INC_DIR . 'external/wpmu-lib/core.php';
lib2()->translate_plugin(PO_LANG, PO_LANG_DIR);
require_once PO_INC_DIR . 'config-defaults.php';
if (is_admin()) {
// Defines class 'IncPopup'.
require_once PO_INC_DIR . 'class-popup-admin.php';
} else {
// Defines class 'IncPopup'.
require_once PO_INC_DIR . 'class-popup-public.php';
}
// Initialize the plugin as soon as we have identified the current user.
IncPopup::instance();
}
}
示例13: init
/**
* Initializes the Add-on. Always executed.
*
* @since 1.0.0
*/
public function init()
{
if (self::is_active()) {
$this->buddypress_registration = lib2()->is_true($this->get_setting('buddypress_registration'));
$this->add_filter('ms_controller_protection_tabs', 'rule_tabs');
MS_Factory::load('MS_Addon_BuddyPress_Rule');
/*
* Using the BuddyPress registration form is optional.
* These actions are only needed when the BuddyPress registration
* form is used instead of the M2 registration form.
*/
if ($this->buddypress_registration) {
$this->add_filter('ms_frontend_custom_registration_form', 'registration_form');
$this->add_action('ms_controller_frontend_register_user_before', 'prepare_create_user');
$this->add_action('ms_controller_frontend_register_user_complete', 'save_custom_fields');
}
// Disable BuddyPress Email activation.
add_filter('bp_core_signup_send_activation_key', '__return_false');
add_filter('bp_registration_needs_activation', '__return_false');
$this->add_action('bp_core_signup_user', 'disable_validation');
}
}
示例14: 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 = lib2()->net->expand_url($instance['redirect_login']);
}
if (!empty($instance['redirect_logout'])) {
$redirect_logout = lib2()->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'];
}
示例15: validate_shortcodes
/**
* Parses the specified content and looks for shortcodes that are not
* compatible with the current PopUp loading method.
*
* The function does not return a value, but if incompatible shortcodes are
* detected a new Admin Notification will be generated which is displayed to
* the user after the page has finished loading.
*
* @since 4.7.0
* @param string $content
*/
public static function validate_shortcodes($content)
{
$settings = IncPopupDatabase::get_settings();
$method = isset($settings['loadingmethod']) ? $settings['loadingmethod'] : 'ajax';
// Check for specific/frequently used shortcodes.
if ('footer' !== $method && preg_match('#\\[gravityforms?(\\s.*?\\]|\\])#', $content)) {
lib2()->ui->admin_message(sprintf(__('You are using Gravity Forms inside this PopUp. It is best to switch to the <a href="%s">loading method</a> "Page Footer" to ensure the form works as expected.', PO_LANG), 'edit.php?post_type=' . IncPopupItem::POST_TYPE . '&page=settings'), 'err');
}
// General check for shortcode incompatibility
switch ($method) {
case 'ajax':
case 'anonymous':
// Check if the content contains any of the Front-Shortcodes:
$check = IncPopupAddon_HeaderFooter::check();
$content = do_shortcode($content);
foreach ($check->shortcodes as $code) {
$match = array();
if (preg_match('#\\[' . $code . '(\\s.*?\\]|\\])#', $content, $match)) {
lib2()->ui->admin_message(sprintf(__('Shortcode <code>%s</code> requires a different <a href="%s">loading method</a> to work.<br />Try "Page Footer", though sometimes the method "Custom AJAX" also works (please test the result)', PO_LANG), $match[0], 'edit.php?post_type=' . IncPopupItem::POST_TYPE . '&page=settings'), 'err');
}
}
break;
case 'footer':
case 'front':
// Nothing needs to be validated here...
break;
default:
//lib2()->ui->admin_message( 'Shortcode-Check not defined for: ' . $method );
}
}