本文整理汇总了PHP中mc4wp函数的典型用法代码示例。如果您正苦于以下问题:PHP mc4wp函数的具体用法?PHP mc4wp怎么用?PHP mc4wp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mc4wp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mc4wp_load_plugin
/**
* Loads the MailChimp for WP plugin files
*
* @return boolean True if the plugin files were loaded, false otherwise.
*/
function mc4wp_load_plugin()
{
global $mc4wp;
// don't load plugin if user has the premium version installed and activated
if (defined('MC4WP_VERSION')) {
return false;
}
// load autoloader
require_once dirname(__FILE__) . '/vendor/autoload_52.php';
// define some constants
require dirname(__FILE__) . '/bootstrap.php';
// Initialize the plugin and store an instance in the global scope
$mc4wp = mc4wp();
$mc4wp->init();
if (is_admin() && (!defined('DOING_AJAX') || !DOING_AJAX)) {
// load admin class
$admin = new MC4WP_Admin(__FILE__);
$admin->add_hooks();
$admin->load_translations();
// load promotional elements
$promotional_elements = new MC4WP_Admin_Ads();
$promotional_elements->add_hooks();
}
return true;
}
示例2: _mc4wp_load_plugin
/**
* Bootstrap the MailChimp for WordPress plugin
*
* @ignore
* @access private
* @return bool
*/
function _mc4wp_load_plugin()
{
global $mc4wp;
// Don't run if MailChimp for WP Pro 2.x is activated
if (defined('MC4WP_VERSION')) {
return false;
}
// bootstrap the core plugin
define('MC4WP_VERSION', '4.0.9');
define('MC4WP_PLUGIN_DIR', dirname(__FILE__) . '/');
define('MC4WP_PLUGIN_URL', plugins_url('/', __FILE__));
define('MC4WP_PLUGIN_FILE', __FILE__);
// load autoloader if function not yet exists (for compat with sitewide autoloader)
if (!function_exists('mc4wp')) {
require_once MC4WP_PLUGIN_DIR . 'vendor/autoload_52.php';
}
/**
* @global MC4WP_Container $GLOBALS['mc4wp']
* @name $mc4wp
*/
$mc4wp = mc4wp();
$mc4wp['api'] = 'mc4wp_get_api_v3';
$mc4wp['request'] = array('MC4WP_Request', 'create_from_globals');
$mc4wp['log'] = 'mc4wp_get_debug_log';
// forms
$mc4wp['forms'] = new MC4WP_Form_Manager();
$mc4wp['forms']->add_hooks();
// integration core
$mc4wp['integrations'] = new MC4WP_Integration_Manager();
$mc4wp['integrations']->add_hooks();
// bootstrap custom integrations
require_once MC4WP_PLUGIN_DIR . 'integrations/bootstrap.php';
// Doing cron? Load Usage Tracking class.
if (defined('DOING_CRON') && DOING_CRON) {
MC4WP_Usage_Tracking::instance()->add_hooks();
}
// Initialize admin section of plugin
if (is_admin()) {
$admin_tools = new MC4WP_Admin_Tools();
if (defined('DOING_AJAX') && DOING_AJAX) {
$ajax = new MC4WP_Admin_Ajax($admin_tools);
$ajax->add_hooks();
} else {
$messages = new MC4WP_Admin_Messages();
$mc4wp['admin.messages'] = $messages;
$mailchimp = new MC4WP_MailChimp();
$admin = new MC4WP_Admin($admin_tools, $messages, $mailchimp);
$admin->add_hooks();
$forms_admin = new MC4WP_Forms_Admin($messages, $mailchimp);
$forms_admin->add_hooks();
$integrations_admin = new MC4WP_Integration_Admin($mc4wp['integrations'], $messages, $mailchimp);
$integrations_admin->add_hooks();
}
}
return true;
}
示例3: __mc4wp_load_plugin
/**
* Bootstrap the MailChimp for WordPress plugin
*
* @ignore
* @access private
* @return bool
*/
function __mc4wp_load_plugin()
{
global $mc4wp;
// Don't run if MailChimp for WP Pro 2.x is activated
if (defined('MC4WP_VERSION')) {
return false;
}
// bootstrap the core plugin
define('MC4WP_VERSION', '3.0.11-dev');
define('MC4WP_PLUGIN_DIR', dirname(__FILE__) . '/');
define('MC4WP_PLUGIN_URL', plugins_url('/', __FILE__));
define('MC4WP_PLUGIN_FILE', __FILE__);
// load autoloader
require_once MC4WP_PLUGIN_DIR . 'vendor/autoload_52.php';
/**
* @global MC4WP_Container $GLOBALS['mc4wp']
* @name $mc4wp
*/
$mc4wp = mc4wp();
$mc4wp['api'] = 'mc4wp_get_api';
$mc4wp['request'] = array('MC4WP_Request', 'create_from_globals');
// forms
$mc4wp['forms'] = new MC4WP_Form_Manager();
$mc4wp['forms']->add_hooks();
// integration core
$mc4wp['integrations'] = new MC4WP_Integration_Manager();
$mc4wp['integrations']->add_hooks();
// visitor tracking
$mc4wp['tracking'] = new MC4WP_Visitor_Tracking();
$mc4wp['tracking']->add_hooks();
// bootstrap custom integrations
require_once MC4WP_PLUGIN_DIR . 'integrations/bootstrap.php';
// Doing cron? Load Usage Tracking class.
if (defined('DOING_CRON') && DOING_CRON) {
MC4WP_Usage_Tracking::instance()->add_hooks();
}
// Initialize admin section of plugin
if (is_admin() && (!defined('DOING_AJAX') || !DOING_AJAX)) {
$messages = new MC4WP_Admin_Messages();
$mailchimp = new MC4WP_MailChimp();
$admin = new MC4WP_Admin($messages, $mailchimp);
$admin->add_hooks();
$forms_admin = new MC4WP_Forms_Admin($messages, $mailchimp);
$forms_admin->add_hooks();
$integrations_admin = new MC4WP_Integration_Admin($mc4wp['integrations'], $messages, $mailchimp);
$integrations_admin->add_hooks();
}
return true;
}
示例4: show_generals_setting_page
/**
* Show the API settings page
*/
public function show_generals_setting_page()
{
$opts = mc4wp_get_options();
$connected = mc4wp('api')->is_connected();
$lists = $this->mailchimp->get_lists();
require MC4WP_PLUGIN_DIR . 'includes/views/general-settings.php';
}
示例5: get_log
/**
* @return MC4WP_Debug_Log
*/
protected function get_log()
{
return mc4wp('log');
}
示例6: get_email
/**
* @return string
*/
public function get_email()
{
// first, try request
$request = mc4wp('request');
$email = $request->params->get('EMAIL', '');
if ($email) {
return $email;
}
// then , try logged-in user
if (is_user_logged_in()) {
$user = wp_get_current_user();
return $user->user_email;
}
// then, try visitor tracking
return mc4wp('tracking')->get_field('EMAIL', '');
}
示例7: mc4wp_deregister_integration
/**
* Deregister a previously registered integration with MailChimp for WordPress
*
* @since 3.0
* @access public
*
* @param string $slug
*
* @return void
*/
function mc4wp_deregister_integration($slug)
{
return mc4wp('integrations')->deregister_integration($slug);
}
示例8: mc4wp_guess_merge_vars
/**
* Guesses merge vars based on given data & current request.
*
* @since 3.0
* @access public
*
* @param array $merge_vars
*
* @return array
*/
function mc4wp_guess_merge_vars($merge_vars = array())
{
// maybe guess first and last name
if (isset($merge_vars['NAME'])) {
if (!isset($merge_vars['FNAME']) && !isset($merge_vars['LNAME'])) {
$strpos = strpos($merge_vars['NAME'], ' ');
if ($strpos !== false) {
$merge_vars['FNAME'] = trim(substr($merge_vars['NAME'], 0, $strpos));
$merge_vars['LNAME'] = trim(substr($merge_vars['NAME'], $strpos));
} else {
$merge_vars['FNAME'] = $merge_vars['NAME'];
}
}
}
// set ip address
if (empty($merge_vars['OPTIN_IP'])) {
$optin_ip = mc4wp('request')->get_client_ip();
if (!empty($optin_ip)) {
$merge_vars['OPTIN_IP'] = $optin_ip;
}
}
/**
* Filters merge vars which are sent to MailChimp
*
* @param array $merge_vars
*/
$merge_vars = (array) apply_filters('mc4wp_merge_vars', $merge_vars);
return $merge_vars;
}
示例9: __construct
/**
* MC4WP_MailChimp constructor.
*/
public function __construct()
{
$this->api = mc4wp('api');
}
示例10: get_api
/**
* @return MC4WP_API_v3
*/
protected function get_api()
{
return mc4wp('api');
}
示例11: defined
<?php
defined('ABSPATH') or exit;
$tags = mc4wp('forms')->get_tags();
?>
<h2><?php
_e('Add dynamic form variable', 'mailchimp-for-wp');
?>
</h2>
<p>
<?php
echo sprintf(__('The following list of variables can be used to <a href="%s">add some dynamic content to your form or success and error messages</a>.', 'mailchimp-for-wp'), 'https://mc4wp.com/kb/using-variables-in-your-form-or-messages/') . ' ' . __('This allows you to personalise your form or response messages.', 'mailchimp-for-wp');
?>
</p>
<table class="widefat striped">
<?php
foreach ($tags as $tag => $config) {
$tag = !empty($config['example']) ? $config['example'] : $tag;
?>
<tr>
<td>
<input type="text" class="widefat" value="<?php
echo esc_attr(sprintf('{%s}', $tag));
?>
" readonly="readonly" onfocus="this.select();" />
<p class="help" style="margin-bottom:0;"><?php
echo esc_html($config['description']);
?>
</p>
</td>
</tr>
示例12: show_form_settings
/**
* Show the forms settings page
*/
public function show_form_settings()
{
$opts = mc4wp()->forms->options;
$lists = MC4WP_MailChimp_Tools::get_lists();
require MC4WP_PLUGIN_DIR . 'src/views/form-settings.php';
}
示例13: load_settings
/**
* @return array
*/
public function load_settings()
{
return mc4wp()->forms->options;
}
示例14: get_request
/**
* @return MC4WP_Request
*/
private function get_request()
{
return mc4wp('request');
}
示例15: get_subscriber_counts
/**
* Get an array of list_id => number of subscribers
*
* @return array
*/
public function get_subscriber_counts()
{
// get from transient
$list_counts = get_transient($this->list_counts_transient_name);
if (is_array($list_counts)) {
return $list_counts;
}
// transient not valid, fetch from API
$api = mc4wp('api');
$lists = $api->get_lists();
$list_counts = array();
if (is_array($lists)) {
// we got a valid response
foreach ($lists as $list) {
$list_counts["{$list->id}"] = $list->stats->member_count;
}
$seconds = 1200;
/**
* Filters the cache time for MailChimp lists configuration. Defaults to 1200.
*
* @since 2.0
* @param int $seconds
*/
$transient_lifetime = (int) apply_filters('mc4wp_lists_count_cache_time', $seconds);
set_transient($this->list_counts_transient_name, $list_counts, $transient_lifetime);
// bail
return $list_counts;
}
// api call failed, get from stored lists
$lists = $this->get_lists(true);
foreach ($lists as $list) {
$list_counts["{$list->id}"] = $list->subscriber_count;
}
return $list_counts;
}