本文整理汇总了PHP中mc4wp_get_options函数的典型用法代码示例。如果您正苦于以下问题:PHP mc4wp_get_options函数的具体用法?PHP mc4wp_get_options怎么用?PHP mc4wp_get_options使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mc4wp_get_options函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: mc4wp_get_form_settings
/**
* @param int $form_id
* @param bool $inherit
*
* @return array
*/
function mc4wp_get_form_settings($form_id, $inherit = false)
{
$inherited_settings = mc4wp_get_options('form');
$form_settings = array();
// set defaults
$form_settings['lists'] = array();
$form_settings['email_copy_receiver'] = get_bloginfo('admin_email');
// fill optional meta keys with empty strings
$optional_meta_keys = array('double_optin', 'update_existing', 'replace_interests', 'send_welcome', 'ajax', 'hide_after_success', 'redirect', 'text_success', 'text_error', 'text_invalid_email', 'text_already_subscribed', 'send_email_copy', 'text_invalid_captcha', 'text_required_field_missing');
foreach ($optional_meta_keys as $meta_key) {
if ($inherit) {
$form_settings[$meta_key] = $inherited_settings[$meta_key];
} else {
$form_settings[$meta_key] = '';
}
}
$meta = get_post_meta($form_id, '_mc4wp_settings', true);
if (is_array($meta)) {
foreach ($meta as $key => $value) {
// only add meta value if not empty
if ($value != '') {
$form_settings[$key] = $value;
}
}
}
return $form_settings;
}
开发者ID:Infernosaint,项目名称:WPSetupTest2,代码行数:33,代码来源:general.php
示例2: mc4wp_get_api
/**
* Gets the MailChimp for WP API class and injects it with the API key
*
* @deprecated 4.0
* @use mc4wp_get_api_v3
*
* @since 1.0
* @access public
*
* @return MC4WP_API
*/
function mc4wp_get_api()
{
_deprecated_function(__FUNCTION__, '4.0', 'mc4wp_get_api_v3');
$opts = mc4wp_get_options();
$instance = new MC4WP_API($opts['api_key']);
return $instance;
}
开发者ID:dannyvankooten,项目名称:mailchimp-for-wordpress,代码行数:18,代码来源:functions.php
示例3: get_options
/**
* Get the checkbox options
*
* @return array
*/
public function get_options()
{
if ($this->options === null) {
$this->options = mc4wp_get_options('checkbox');
}
return $this->options;
}
开发者ID:jimmitjoo,项目名称:mnh,代码行数:12,代码来源:class-integration.php
示例4: __construct
/**
* Constructor
*
* Hooks into the `init` action to start the process of subscribing the person who filled out the form
*/
public function __construct()
{
// store number of submitted form
$this->form_instance_number = absint($_POST['_mc4wp_form_instance']);
// store form options
$this->form_options = mc4wp_get_options('form');
add_action('init', array($this, 'act'));
}
开发者ID:shubham79,项目名称:Jhintaak,代码行数:13,代码来源:class-form-request.php
示例5: get_api
/**
* @return MC4WP_Lite_API
*/
public function get_api()
{
if ($this->api === null) {
$opts = mc4wp_get_options();
$this->api = new MC4WP_Lite_API($opts['general']['api_key']);
}
return $this->api;
}
开发者ID:shubham79,项目名称:Jhintaak,代码行数:11,代码来源:class-plugin.php
示例6: load_stylesheet
/**
* Loads the checkbox stylesheet
*/
public function load_stylesheet()
{
$opts = mc4wp_get_options('checkbox');
if ($opts['css'] == false) {
return false;
}
wp_enqueue_style('mailchimp-for-wp-checkbox', MC4WP_LITE_PLUGIN_URL . 'assets/css/checkbox.css', array(), MC4WP_LITE_VERSION, 'all');
return true;
}
开发者ID:sydneyDAD,项目名称:cardguys.com,代码行数:12,代码来源:class-checkbox-manager.php
示例7: load_stylesheet
/**
* Loads the checkbox stylesheet
*/
public function load_stylesheet()
{
$opts = mc4wp_get_options('checkbox');
if ($opts['css'] == false) {
return false;
}
$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
wp_enqueue_style('mailchimp-for-wp-checkbox', MC4WP_LITE_PLUGIN_URL . 'assets/css/checkbox' . $suffix . '.css', array(), MC4WP_LITE_VERSION, 'all');
return true;
}
开发者ID:shubham79,项目名称:Jhintaak,代码行数:13,代码来源:class-checkbox-manager.php
示例8: CF7_pre_send
function CF7_pre_send($cf7)
{
if (isset($_POST['is_subcribe']) && count($_POST['is_subcribe']) > 0) {
$option = mc4wp_get_options('form');
$api = mc4wp_get_api();
foreach ($option['lists'] as $v) {
$api->subscribe($v, $cf7->mail['recipient']);
}
}
}
开发者ID:IdDevGroup,项目名称:Identifid-Website,代码行数:10,代码来源:functions.php
示例9: get_tracked_options
/**
* @return array
*/
public function get_tracked_options()
{
$checkbox_options = mc4wp_get_options('checkbox');
$form_options = mc4wp_get_options('form');
// make sure these keys are always stripped
$ignored_options = array('api_key', 'license_key', 'lists');
// filter options
$checkbox_options = array_diff_key($checkbox_options, array_flip($ignored_options));
$form_options = array_diff_key($form_options, array_flip($ignored_options));
// merge options
$options = array('checkbox' => $checkbox_options, 'form' => $form_options);
return $options;
}
开发者ID:JaneJieYing,项目名称:HiFridays,代码行数:16,代码来源:class-usage-tracking.php
示例10: initialize
/**
* Initializes the Form functionality
*
* - Registers scripts so developers can override them, should they want to.
*/
public function initialize()
{
$this->options = mc4wp_get_options('form');
$this->register_shortcodes();
// has a MC4WP form been submitted?
if (isset($_POST['_mc4wp_form_submit'])) {
$this->form_request = new MC4WP_Lite_Form_Request($_POST);
}
// frontend only
if (!is_admin()) {
// load checkbox css if necessary
add_action('wp_head', array($this, 'print_css'), 90);
add_action('wp_enqueue_scripts', array($this, 'load_stylesheet'));
$this->register_scripts();
}
}
开发者ID:jimmitjoo,项目名称:mnh,代码行数:21,代码来源:class-form-manager.php
示例11: __construct
/**
* Constructor
*/
public function __construct()
{
$this->options = mc4wp_get_options('checkbox');
// load checkbox css if necessary
add_action('wp_enqueue_scripts', array($this, 'load_stylesheet'));
add_action('login_enqueue_scripts', array($this, 'load_stylesheet'));
// Load WP Comment Form Integration
if ($this->options['show_at_comment_form']) {
$this->integrations['comment_form'] = new MC4WP_Comment_Form_Integration();
}
// Load WordPress Registration Form Integration
if ($this->options['show_at_registration_form']) {
$this->integrations['registration_form'] = new MC4WP_Registration_Form_Integration();
}
// Load BuddyPress Integration
if ($this->options['show_at_buddypress_form']) {
$this->integrations['buddypress_form'] = new MC4WP_BuddyPress_Integration();
}
// Load MultiSite Integration
if ($this->options['show_at_multisite_form']) {
$this->integrations['multisite_form'] = new MC4WP_MultiSite_Integration();
}
// Load bbPress Integration
if ($this->options['show_at_bbpress_forms']) {
$this->integrations['bbpress_forms'] = new MC4WP_bbPress_Integration();
}
// Load CF7 Integration
if (function_exists('wpcf7_add_shortcode')) {
$this->integrations['contact_form_7'] = new MC4WP_CF7_Integration();
}
// Load Events Manager integration
if (defined('EM_VERSION')) {
$this->integrations['events_manager'] = new MC4WP_Events_Manager_Integration();
}
// Load WooCommerce Integration
if ($this->options['show_at_woocommerce_checkout']) {
$this->integrations['woocommerce'] = new MC4WP_WooCommerce_Integration();
}
// Load EDD Integration
if ($this->options['show_at_edd_checkout']) {
$this->integrations['easy_digital_downloads'] = new MC4WP_EDD_Integration();
}
// load General Integration on POST requests
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$this->integrations['general'] = new MC4WP_General_Integration();
}
}
开发者ID:tlandn,项目名称:akvo-sites-zz-template,代码行数:50,代码来源:class-checkbox-manager.php
示例12: __construct
/**
* Constructor
*
* @param array $form_data
*/
public function __construct($form_data)
{
$this->data = $this->normalize_form_data($form_data);
// store number of submitted form
$this->form_instance_number = absint($this->data['_MC4WP_FORM_INSTANCE']);
$this->form_options = mc4wp_get_options('form');
$this->is_valid = $this->validate();
if ($this->is_valid) {
// add some data to the posted data, like FNAME and LNAME
$this->data = $this->guess_missing_fields($this->data);
// map fields to corresponding MailChimp lists
if ($this->map_data($this->data)) {
// subscribe using the processed data
$this->success = $this->subscribe($this->lists_fields_map);
}
}
// send HTTP response
$this->send_http_response();
return $this->success;
}
开发者ID:jimmitjoo,项目名称:mnh,代码行数:25,代码来源:class-form-request.php
示例13: initialize
/**
* Initialize form stuff
*
* - Registers post type
* - Registers scripts
*/
public function initialize()
{
$this->options = mc4wp_get_options('form');
// register post type
register_post_type('mc4wp-form', array('labels' => array('name' => 'MailChimp Sign-up Forms', 'singular_name' => 'Sign-up Form', 'add_new_item' => 'Add New Form', 'edit_item' => 'Edit Form', 'new_item' => 'New Form', 'all_items' => 'All Forms', 'view_item' => null), 'public' => false, 'show_ui' => true, 'show_in_menu' => false));
$this->register_shortcodes();
// has a form been submitted, either by ajax or manually?
if (isset($_POST['_mc4wp_form_submit'])) {
$this->form_request = new MC4WP_Form_Request($_POST);
}
// frontend only
if (!is_admin()) {
add_action('wp_head', array($this, 'print_css'), 90);
add_action('wp_enqueue_scripts', array($this, 'load_stylesheet'));
$this->register_scripts();
if (isset($_GET['_mc4wp_css_preview'])) {
$this->show_form_preview();
die;
}
}
}
开发者ID:Infernosaint,项目名称:WPSetupTest2,代码行数:27,代码来源:class-form-manager.php
示例14: act
/**
* Acts on the submitted data
* - Validates internal fields
* - Formats email and merge_vars
* - Sends off the subscribe request to MailChimp
* - Returns state
*
* @return bool True on success, false on failure.
*/
public function act() {
// store number of submitted form
$this->form_instance_number = absint( $_POST['_mc4wp_form_instance'] );
// store form options
$this->form_options = mc4wp_get_options( 'form' );
// validate form nonce
if ( ! isset( $_POST['_mc4wp_form_nonce'] ) || ! wp_verify_nonce( $_POST['_mc4wp_form_nonce'], '_mc4wp_form_nonce' ) ) {
$this->error_code = 'invalid_nonce';
return false;
}
// ensure honeypot was not filed
if ( isset( $_POST['_mc4wp_required_but_not_really'] ) && ! empty( $_POST['_mc4wp_required_but_not_really'] ) ) {
$this->error_code = 'spam';
return false;
}
// check if captcha was present and valid
if( isset( $_POST['_mc4wp_has_captcha'] ) && $_POST['_mc4wp_has_captcha'] == 1 && function_exists( 'cptch_check_custom_form' ) && cptch_check_custom_form() !== true ) {
$this->error_code = 'invalid_captcha';
return false;
}
/**
* @filter mc4wp_valid_form_request
*
* Use this to perform custom form validation.
* Return true if the form is valid or an error string if it isn't.
* Use the `mc4wp_form_messages` filter to register custom error messages.
*/
$valid_form_request = apply_filters( 'mc4wp_valid_form_request', true );
if( $valid_form_request !== true ) {
$this->error_code = $valid_form_request;
return false;
}
// get entered form data (sanitized)
$this->sanitize_form_data();
$data = $this->get_posted_data();
// validate email
if( ! isset( $data['EMAIL'] ) || ! is_email( $data['EMAIL'] ) ) {
$this->error_code = 'invalid_email';
return false;
}
// setup merge_vars array
$merge_vars = $data;
// take email out of $data array, use the rest as merge_vars
$email = $merge_vars['EMAIL'];
unset( $merge_vars['EMAIL'] );
// validate groupings
if( isset( $data['GROUPINGS'] ) && is_array( $data['GROUPINGS'] ) ) {
$merge_vars['GROUPINGS'] = $this->format_groupings_data( $data['GROUPINGS'] );
}
// subscribe the given email / data combination
$this->success = $this->subscribe( $email, $merge_vars );
// do stuff on success
if( true === $this->success ) {
// check if we want to redirect the visitor
if ( ! empty( $this->form_options['redirect'] ) ) {
wp_redirect( $this->form_options['redirect'] );
exit;
}
// return true on success
return true;
}
// return false on failure
return false;
}
开发者ID:kevinreilly,项目名称:mendelements.com,代码行数:89,代码来源:class-form-request.php
示例15: on_activation
/**
* Runs on plugin activation
* Transfers settings from MC4WP Lite
*/
public function on_activation()
{
// delete transients
delete_transient('mc4wp_mailchimp_lists');
delete_transient('mc4wp_mailchimp_lists_fallback');
// check if PRO option exists and contains data entered by user
if (($o = get_option('mc4wp')) != false && (!empty($o['api_key']) || !empty($o['license_key']))) {
return;
}
// user entered no PRO options in the past, let's see if we can transfer from LITE
$lite_settings = array('general' => (array) get_option('mc4wp_lite'), 'checkbox' => (array) get_option('mc4wp_lite_checkbox'), 'form' => (array) get_option('mc4wp_lite_form'));
$default_options = mc4wp_get_options();
foreach ($default_options as $group_key => $options) {
foreach ($options as $option_key => $option_value) {
if (isset($lite_settings[$group_key][$option_key]) && !empty($lite_settings[$group_key][$option_key])) {
$default_options[$group_key][$option_key] = $lite_settings[$group_key][$option_key];
}
}
}
$forms = get_posts(array('post_type' => 'mc4wp-form'));
if (!$forms) {
// no forms found, try to transfer from lite.
$form_markup = isset($lite_settings['form']['markup']) ? $lite_settings['form']['markup'] : $this->get_default_form_markup();
$form_ID = wp_insert_post(array('post_type' => 'mc4wp-form', 'post_title' => 'Sign-Up Form #1', 'post_content' => $form_markup, 'post_status' => 'publish'));
$lists = isset($lite_settings['form']['lists']) ? $lite_settings['form']['lists'] : array();
update_post_meta($form_ID, '_mc4wp_settings', array('lists' => $lists));
update_option('mc4wp_default_form_id', $form_ID);
}
// store options
update_option('mc4wp', $default_options['general']);
update_option('mc4wp_checkbox', $default_options['checkbox']);
update_option('mc4wp_form', $default_options['form']);
}
开发者ID:donwea,项目名称:nhap.org,代码行数:37,代码来源:class-admin.php
示例16: mc4wp_get_api
/**
* Gets the MailChimp for WP API class and injects it with the API key
*
* @staticvar $instance
*
* @since 1.0
* @access public
*
* @return MC4WP_API
*/
function mc4wp_get_api()
{
$opts = mc4wp_get_options();
$instance = new MC4WP_API($opts['api_key']);
return $instance;
}
开发者ID:petersuhm,项目名称:mailchimp-for-wordpress,代码行数:16,代码来源:functions.php
示例17: get_form_messages
/**
* Returns the various error and success messages in array format
*
* Example:
* array(
* 'invalid_email' => array(
* 'type' => 'css-class',
* 'text' => 'Message text'
* ),
* ...
* );
*
* @return array
*/
public function get_form_messages( $form_id = 0 ) {
$opts = mc4wp_get_options( 'form' );
$messages = array(
'already_subscribed' => array(
'type' => 'notice',
'text' => $opts['text_already_subscribed']
),
'error' => array(
'type' => 'error',
'text' => $opts['text_error']
),
'invalid_email' => array(
'type' => 'error',
'text' => $opts['text_invalid_email']
),
'success' => array(
'type' => 'success',
'text' => $opts['text_success']
),
'invalid_captcha' => array(
'type' => 'error',
'text' => $opts['text_invalid_captcha']
),
'required_field_missing' => array(
'type' => 'error',
'text' => $opts['text_required_field_missing']
)
);
/**
* @filter mc4wp_form_messages
*
* Allows registering custom form messages, useful if you're using custom validation using the `mc4wp_valid_form_request` filter.
*/
$messages = apply_filters( 'mc4wp_form_messages', $messages );
return $messages;
}
开发者ID:kevinreilly,项目名称:mendelements.com,代码行数:54,代码来源:class-form-manager.php
示例18: load_settings
/**
* @return array
*/
public function load_settings()
{
return mc4wp_get_options('form');
}
开发者ID:radscheit,项目名称:unicorn,代码行数:7,代码来源:class-form.php
示例19: subscribe
/**
* Makes a subscription request
*
* @param string $email
* @param array $merge_vars
* @param string $signup_type
* @param int $comment_ID
* @return boolean
*/
protected function subscribe($email, array $merge_vars = array(), $signup_type = 'comment', $comment_id = null)
{
$api = mc4wp_get_api();
$opts = mc4wp_get_options('checkbox');
$lists = $this->get_lists();
if (empty($lists)) {
if ((!defined('DOING_AJAX') || !DOING_AJAX) && current_user_can('manage_options')) {
wp_die('<h3>' . __('MailChimp for WordPress - Error', 'mailchimp-for-wp') . '</h3>' . '<p>' . sprintf(__('Please select a list to subscribe to in the <a href="%s">checkbox settings</a>.', 'mailchimp-for-wp'), admin_url('admin.php?page=mc4wp-lite-checkbox-settings')) . '</p>' . '<p style="font-style:italic; font-size:12px;">' . __('This message is only visible to administrators for debugging purposes.', 'mailchimp-for-wp') . '</p>', __('MailChimp for WordPress - Error', 'mailchimp-for-wp'), array('back_link' => true));
}
return 'no_lists_selected';
}
// maybe guess first and last name
if (isset($merge_vars['NAME']) && !isset($merge_vars['FNAME']) && !isset($merge_vars['LNAME'])) {
$strpos = strpos($merge_vars['NAME'], ' ');
if ($strpos !== false) {
$merge_vars['FNAME'] = substr($merge_vars['NAME'], 0, $strpos);
$merge_vars['LNAME'] = substr($merge_vars['NAME'], $strpos);
} else {
$merge_vars['FNAME'] = $merge_vars['NAME'];
}
}
// set ip address
if (!isset($merge_vars['OPTIN_IP']) && isset($_SERVER['REMOTE_ADDR'])) {
$merge_vars['OPTIN_IP'] = $_SERVER['REMOTE_ADDR'];
}
$result = false;
$merge_vars = apply_filters('mc4wp_merge_vars', $merge_vars, $signup_type);
$email_type = apply_filters('mc4wp_email_type', 'html');
do_action('mc4wp_before_subscribe', $email, $merge_vars);
foreach ($lists as $list_id) {
$result = $api->subscribe($list_id, $email, $merge_vars, $email_type, $opts['double_optin'], false, true);
}
do_action('mc4wp_after_subscribe', $email, $merge_vars, $result);
if ($result === true) {
$from_url = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '';
do_action('mc4wp_subscribe_checkbox', $email, $lists, $signup_type, $merge_vars, $comment_id, $from_url);
}
// check if result succeeded, show debug message to administrators (only in NON-AJAX requests)
if ($result !== true && $api->has_error() && current_user_can('manage_options') && (!defined('DOING_AJAX') || !DOING_AJAX) && (!isset($_POST['_wpcf7_is_ajax_call']) || $_POST['_wpcf7_is_ajax_call'] != 1)) {
wp_die('<h3>' . __('MailChimp for WordPress - Error', 'mailchimp-for-wp') . '</h3>' . '<p>' . __('The MailChimp server returned the following error message as a response to our sign-up request:', 'mailchimp-for-wp') . '</p>' . '<pre>' . $api->get_error_message() . '</pre>' . '<p>' . __('This is the data that was sent to MailChimp:', 'mailchimp-for-wp') . '</p>' . '<strong>' . __('Email address:', 'mailchimp-for-wp') . '</strong>' . '<pre>' . esc_html($email) . '</pre>' . '<strong>' . __('Merge variables:', 'mailchimp-for-wp') . '</strong>' . '<pre>' . esc_html(print_r($merge_vars, true)) . '</pre>' . '<p style="font-style:italic; font-size:12px;">' . __('This message is only visible to administrators for debugging purposes.', 'mailchimp-for-wp') . '</p>', __('MailChimp for WordPress - Error', 'mailchimp-for-wp'), array('back_link' => true));
}
return $result;
}
开发者ID:shubham79,项目名称:Jhintaak,代码行数:52,代码来源:class-integration.php
示例20: show_form_settings
/**
* Show the forms settings page
*/
public function show_form_settings()
{
$opts = mc4wp_get_options('form');
$mailchimp = new MC4WP_MailChimp();
$lists = $mailchimp->get_lists();
require MC4WP_LITE_PLUGIN_DIR . 'includes/views/form-settings.php';
}
开发者ID:tlandn,项目名称:akvo-sites-zz-template,代码行数:10,代码来源:class-admin.php
注:本文中的mc4wp_get_options函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论