当前位置: 首页>>代码示例>>PHP>>正文


PHP mc4wp_get_api函数代码示例

本文整理汇总了PHP中mc4wp_get_api函数的典型用法代码示例。如果您正苦于以下问题:PHP mc4wp_get_api函数的具体用法?PHP mc4wp_get_api怎么用?PHP mc4wp_get_api使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了mc4wp_get_api函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: process

 /**
  * @return bool
  */
 public function process()
 {
     $api = mc4wp_get_api();
     do_action('mc4wp_before_subscribe', $this->data['EMAIL'], $this->data, 0);
     $result = false;
     $email_type = $this->get_email_type();
     // loop through selected lists
     foreach ($this->list_fields_map as $list_id => $list_field_data) {
         // allow plugins to alter merge vars for each individual list
         $list_merge_vars = $this->get_list_merge_vars($list_id, $list_field_data);
         // send a subscribe request to MailChimp for each list
         $result = $api->subscribe($list_id, $this->data['EMAIL'], $list_merge_vars, $email_type, $this->form->settings['double_optin'], $this->form->settings['update_existing'], $this->form->settings['replace_interests'], $this->form->settings['send_welcome']);
         do_action('mc4wp_subscribe', $this->data['EMAIL'], $list_id, $list_merge_vars, $result, 'form', 'form', 0);
     }
     do_action('mc4wp_after_subscribe', $this->data['EMAIL'], $this->data, 0, $result);
     // did we succeed in subscribing with the parsed data?
     if (!$result) {
         $this->message_type = $api->get_error_code() === 214 ? 'already_subscribed' : 'error';
         $this->mailchimp_error = $api->get_error_message();
     } else {
         $this->message_type = 'subscribed';
         // store user email in a cookie
         MC4WP_Tools::remember_email($this->data['EMAIL']);
     }
     $this->success = $result;
     return $result;
 }
开发者ID:kd5ytx,项目名称:Empirical-Wordpress,代码行数:30,代码来源:class-subscribe-request.php

示例2: process

 /**
  * @return bool
  */
 public function process()
 {
     $api = mc4wp_get_api();
     do_action('mc4wp_before_subscribe', $this->user_data['EMAIL'], $this->user_data, 0);
     $result = false;
     $email_type = $this->get_email_type();
     // loop through selected lists
     foreach ($this->map->list_fields as $list_id => $list_field_data) {
         // allow plugins to alter merge vars for each individual list
         $list_merge_vars = $this->get_list_merge_vars($list_id, $list_field_data);
         // send a subscribe request to MailChimp for each list
         $result = $api->subscribe($list_id, $this->user_data['EMAIL'], $list_merge_vars, $email_type, $this->form->settings['double_optin'], $this->form->settings['update_existing'], $this->form->settings['replace_interests'], $this->form->settings['send_welcome']);
         do_action('mc4wp_subscribe', $this->user_data['EMAIL'], $list_id, $list_merge_vars, $result, 'form', 'form', $this->form->ID);
     }
     do_action('mc4wp_after_subscribe', $this->user_data['EMAIL'], $this->user_data, 0, $result);
     // did we succeed in subscribing with the parsed data?
     if (!$result) {
         $this->message_type = $api->get_error_code() === 214 ? 'already_subscribed' : 'error';
         $this->mailchimp_error = $api->get_error_message();
     } else {
         $this->message_type = 'subscribed';
         // store user email in a cookie
         $this->set_email_cookie($this->user_data['EMAIL']);
         // send an email copy if that is desired
         // todo: move this to hook callback
         if ($this->form->settings['send_email_copy']) {
             $email = new MC4WP_Email_Notification($this->form->settings['email_copy_receiver'], $this->form, $this);
             $email->send();
         }
     }
     $this->success = $result;
     return $result;
 }
开发者ID:Ore4444,项目名称:old.backfeed.cc,代码行数:36,代码来源:class-subscribe-request.php

示例3: mc4wp_get_subscriber_count

/**
* Returns number of subscribers on given lists.
*
* @param array $list_ids of list id's.
* @return int Sum of subscribers for given lists.
*/
function mc4wp_get_subscriber_count($list_ids)
{
    $list_counts = get_transient('mc4wp_list_counts');
    if (false === $list_counts) {
        // make api call
        $api = mc4wp_get_api();
        $lists = $api->get_lists();
        $list_counts = array();
        if ($lists) {
            foreach ($lists as $list) {
                $list_counts["{$list->id}"] = $list->stats->member_count;
            }
            $transient_lifetime = apply_filters('mc4wp_lists_count_cache_time', 1200);
            // 20 mins by default
            set_transient('mc4wp_list_counts', $list_counts, $transient_lifetime);
            set_transient('mc4wp_list_counts_fallback', $list_counts, 3600 * 24);
            // 1 day
        } else {
            // use fallback transient
            $list_counts = get_transient('mc4wp_list_counts_fallback');
            if (!$list_counts) {
                return 0;
            }
        }
    }
    // start calculating subscribers count for all list combined
    $count = 0;
    foreach ($list_ids as $id) {
        $count += isset($list_counts[$id]) ? $list_counts[$id] : 0;
    }
    return apply_filters('mc4wp_subscriber_count', $count);
}
开发者ID:sydneyDAD,项目名称:cardguys.com,代码行数:38,代码来源:template.php

示例4: 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

示例5: process

 /**
  * @return bool
  */
 public function process()
 {
     $api = mc4wp_get_api();
     $result = false;
     foreach ($this->get_lists() as $list_id) {
         $result = $api->unsubscribe($list_id, $this->user_data['EMAIL']);
     }
     if (!$result) {
         $this->mailchimp_error = $api->get_error_message();
         $this->message_type = in_array($api->get_error_code(), array(215, 232)) ? 'not_subscribed' : 'error';
     } else {
         $this->message_type = 'unsubscribed';
     }
     $this->success = $result;
     return $result;
 }
开发者ID:olechka1505,项目名称:hungrylemur,代码行数:19,代码来源:class-unsubscribe-request.php

示例6: subscribe

    /**
     * Makes a subscription request
     *
     * @param string $email
     * @param array $merge_vars
     * @param int $related_object_ID
     * @return string|boolean
     */
    protected function subscribe($email, array $merge_vars = array(), $type = '', $related_object_ID = 0)
    {
        $type = '' !== $type ? $type : $this->type;
        $api = mc4wp_get_api();
        $opts = $this->get_options();
        $lists = $this->get_lists();
        if (empty($lists)) {
            // show helpful error message to admins, but only if not using ajax
            if ($this->show_error_messages()) {
                wp_die('
					<h3>MailChimp for WP - Error</h3>
					<p>Please select a list to subscribe to in the <a href="' . admin_url('admin.php?page=mailchimp-for-wp-checkbox-settings') . '">checkbox settings</a>.</p>
					<p style="font-style:italic; font-size:12px;">This message is only visible to administrators for debugging purposes.</p>
					', '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'] = sanitize_text_field($_SERVER['REMOTE_ADDR']);
        }
        $result = false;
        /**
         * @filter `mc4wp_merge_vars`
         * @expects array
         * @param array $merge_vars
         * @param string $type
         *
         * Use this to filter the final merge vars before the request is sent to MailChimp
         */
        $merge_vars = apply_filters('mc4wp_merge_vars', $merge_vars, $type);
        /**
         * @filter `mc4wp_merge_vars`
         * @expects string
         * @param string $email_type
         *
         * Use this to change the email type this users should receive
         */
        $email_type = apply_filters('mc4wp_email_type', 'html');
        /**
         * @action `mc4wp_before_subscribe`
         * @param string $email
         * @param array $merge_vars
         *
         * Runs before the request is sent to MailChimp
         */
        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'], $opts['update_existing'], true, $opts['send_welcome']);
            do_action('mc4wp_subscribe', $email, $list_id, $merge_vars, $result, 'checkbox', $type, $related_object_ID);
        }
        /**
         * @action `mc4wp_after_subscribe`
         * @param string $email
         * @param array $merge_vars
         * @param boolean $result
         *
         * Runs after the request is sent to MailChimp
         */
        do_action('mc4wp_after_subscribe', $email, $merge_vars, $result);
        // if result failed, show error message (only to admins for non-AJAX)
        if ($result !== true && $api->has_error() && $this->show_error_messages()) {
            wp_die('<h3>MailChimp for WP - Error</h3>
					<p>The MailChimp server returned the following error message as a response to our sign-up request:</p>
					<pre>' . $api->get_error_message() . "</pre>\n\t\t\t\t\t<p>This is the data that was sent to MailChimp: </p>\n\t\t\t\t\t<strong>Email</strong>\n\t\t\t\t\t<pre>{$email}</pre>\n\t\t\t\t\t<strong>Merge variables</strong>\n\t\t\t\t\t<pre>" . print_r($merge_vars, true) . '</pre>
					<p><small>This message is only visible to administrators for debugging purposes.</small></p>
					', 'Error - MailChimp for WP', array('back_link' => true));
        }
        return $result;
    }
开发者ID:Infernosaint,项目名称:WPSetupTest2,代码行数:88,代码来源:class-integration.php

示例7: subscribe

 /**
  * Makes a subscription request
  *
  * @param string $email
  * @param array $merge_vars
  * @param string $type
  * @param int $related_object_id
  * @return string|boolean
  */
 protected function subscribe($email, array $merge_vars = array(), $type = '', $related_object_id = 0)
 {
     $type = '' !== $type ? $type : $this->type;
     $api = mc4wp_get_api();
     $opts = $this->get_options();
     $lists = $this->get_lists();
     if (empty($lists)) {
         // show helpful error message to admins, but only if not using ajax
         if ($this->show_error_messages()) {
             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=mailchimp-for-wp-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';
     }
     $merge_vars = MC4WP_Tools::guess_merge_vars($merge_vars);
     // set ip address
     if (!isset($merge_vars['OPTIN_IP'])) {
         $merge_vars['OPTIN_IP'] = MC4WP_Tools::get_client_ip();
     }
     $result = false;
     /**
      * @filter `mc4wp_merge_vars`
      * @expects array
      * @param array $merge_vars
      * @param string $type
      *
      * Use this to filter the final merge vars before the request is sent to MailChimp
      */
     $merge_vars = apply_filters('mc4wp_merge_vars', $merge_vars, $type);
     /**
      * @filter `mc4wp_merge_vars`
      * @expects string
      * @param string $email_type
      *
      * Use this to change the email type this users should receive
      */
     $email_type = apply_filters('mc4wp_email_type', 'html');
     /**
      * @action `mc4wp_before_subscribe`
      * @param string $email
      * @param array $merge_vars
      *
      * Runs before the request is sent to MailChimp
      */
     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'], $opts['update_existing'], true, $opts['send_welcome']);
         do_action('mc4wp_subscribe', $email, $list_id, $merge_vars, $result, 'checkbox', $type, $related_object_id);
     }
     /**
      * @action `mc4wp_after_subscribe`
      * @param string $email
      * @param array $merge_vars
      * @param boolean $result
      *
      * Runs after the request is sent to MailChimp
      */
     do_action('mc4wp_after_subscribe', $email, $merge_vars, $result);
     // if result failed, show error message (only to admins for non-AJAX)
     if ($result !== true && $api->has_error()) {
         // log error
         error_log(sprintf('MailChimp for WordPres (%s): %s', date('Y-m-d H:i:s'), $this->type, $api->get_error_message()));
         if ($this->show_error_messages()) {
             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:alons182,项目名称:sonnsolar,代码行数:76,代码来源:class-integration.php

示例8: subscribe

 /**
  * Subscribes the given email and additional list fields
  *
  * @param array $lists_data
  * @return bool
  */
 private function subscribe($lists_data)
 {
     $api = mc4wp_get_api();
     do_action('mc4wp_before_subscribe', $this->data['EMAIL'], $this->data, 0);
     $result = false;
     $email_type = $this->get_email_type();
     // loop through selected lists
     foreach ($lists_data as $list_id => $list_field_data) {
         // allow plugins to alter merge vars for each individual list
         $list_merge_vars = $this->get_list_merge_vars($list_id, $list_field_data);
         // send a subscribe request to MailChimp for each list
         $result = $api->subscribe($list_id, $this->data['EMAIL'], $list_merge_vars, $email_type, $this->form_options['double_optin'], $this->form_options['update_existing'], $this->form_options['replace_interests'], $this->form_options['send_welcome']);
         do_action('mc4wp_subscribe', $this->data['EMAIL'], $list_id, $list_merge_vars, $result, 'form', 'form', 0);
     }
     do_action('mc4wp_after_subscribe', $this->data['EMAIL'], $this->data, 0, $result);
     if ($result !== true) {
         // subscribe request failed, store error.
         $this->success = false;
         $this->error_code = $result;
         $this->mailchimp_error = $api->get_error_message();
         return false;
     }
     // subscription succeeded
     // store user email in a cookie
     $this->set_email_cookie($this->data['EMAIL']);
     // Store success result
     $this->success = true;
     return true;
 }
开发者ID:jimmitjoo,项目名称:mnh,代码行数:35,代码来源:class-form-request.php

示例9: get_mailchimp_lists

 /**
  * Get MailChimp lists
  * Try cache first, then try API, then try fallback cache.
  */
 private function get_mailchimp_lists()
 {
     $cached_lists = get_transient('mc4wp_mailchimp_lists');
     $refresh_cache = isset($_POST['renew-cached-data']);
     if ($refresh_cache || !$cached_lists || empty($cached_lists)) {
         // make api request for lists
         $api = mc4wp_get_api();
         $lists = array();
         $lists_data = $api->get_lists();
         if ($lists_data) {
             $lists = array();
             foreach ($lists_data as $list) {
                 $lists["{$list->id}"] = (object) array('id' => $list->id, 'name' => $list->name, 'subscriber_count' => $list->stats->member_count, 'merge_vars' => array(), 'interest_groupings' => array());
                 // get interest groupings
                 $groupings_data = $api->get_list_groupings($list->id);
                 if ($groupings_data) {
                     $lists["{$list->id}"]->interest_groupings = array_map(array($this, 'strip_unnecessary_grouping_properties'), $groupings_data);
                 }
             }
             // get merge vars for all lists at once
             $merge_vars_data = $api->get_lists_with_merge_vars(array_keys($lists));
             if ($merge_vars_data) {
                 foreach ($merge_vars_data as $list) {
                     // add merge vars to list
                     $lists["{$list->id}"]->merge_vars = array_map(array($this, 'strip_unnecessary_merge_vars_properties'), $list->merge_vars);
                 }
             }
             // cache renewal triggered manually?
             if (isset($_POST['renew-cached-data'])) {
                 if ($lists) {
                     add_settings_error("mc4wp", "cache-renewed", 'Renewed MailChimp cache.', 'updated');
                 } else {
                     add_settings_error("mc4wp", "cache-renew-failed", 'Failed to renew MailChimp cache - please try again later.');
                 }
             }
             // store lists in transients
             set_transient('mc4wp_mailchimp_lists', $lists, 24 * 3600);
             // 1 day
             set_transient('mc4wp_mailchimp_lists_fallback', $lists, 1209600);
             // 2 weeks
             return $lists;
         } else {
             // api request failed, get fallback data (with longer lifetime)
             $cached_lists = get_transient('mc4wp_mailchimp_lists_fallback');
             if (!$cached_lists) {
                 return array();
             }
         }
     }
     return $cached_lists;
 }
开发者ID:donwea,项目名称:nhap.org,代码行数:55,代码来源:class-admin.php

示例10: process

 /**
  * Process the request
  *
  * @return bool
  */
 public function process()
 {
     $api = mc4wp_get_api();
     if ($this->type === 'subscribe') {
         $success = $api->subscribe($this->list_id, $this->email, $this->merge_vars, $this->config['email_type'], $this->config['double_optin'], $this->config['update_existing'], $this->config['replace_interests'], $this->config['send_welcome']);
     } else {
         $success = $api->unsubscribe($this->list_id, $this->email, $this->config['send_goodbye'], $this->config['send_notification'], $this->config['delete_member']);
     }
     if ($success) {
         // store user email in a cookie
         // todo: decouple this
         MC4WP_Tools::remember_email($this->email);
     }
     // convert API response to our own response object
     $response = new MC4WP_API_Response($this->type, $success, $api->get_last_response());
     $this->response = $response;
     /**
      * @api
      * @action 'mc4wp_request_processed'
      *
      * @param Request
      * @param Response
      */
     do_action('mc4wp_request_processed', $this, $response);
     return $response;
 }
开发者ID:hchouhan,项目名称:mailchimp-for-wordpress,代码行数:31,代码来源:Request.php

示例11: subscribe

 /**
  * Makes a subscription request
  *
  * @param string $email
  * @param array  $merge_vars
  * @param string $type
  * @param null   $related_object_id
  *
  * @return bool
  */
 protected function subscribe($email, array $merge_vars = array(), $type = '', $related_object_id = null)
 {
     $type = '' !== $type ? $type : $this->type;
     $api = mc4wp_get_api();
     $opts = $this->get_options();
     $lists = $this->get_lists();
     if (empty($lists)) {
         if ($this->show_error_messages()) {
             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=mailchimp-for-wp-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'] = sanitize_text_field($_SERVER['REMOTE_ADDR']);
     }
     $result = false;
     /**
      * @filter `mc4wp_merge_vars`
      * @expects array
      * @param array $merge_vars
      * @param string $type
      *
      * Use this to filter the final merge vars before the request is sent to MailChimp
      */
     $merge_vars = apply_filters('mc4wp_merge_vars', $merge_vars, $type);
     /**
      * @filter `mc4wp_merge_vars`
      * @expects string
      * @param string $email_type
      *
      * Use this to change the email type this users should receive
      */
     $email_type = apply_filters('mc4wp_email_type', 'html');
     /**
      * @action `mc4wp_before_subscribe`
      * @param string $email
      * @param array $merge_vars
      *
      * Runs before the request is sent to MailChimp
      */
     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, $opts['send_welcome']);
         do_action('mc4wp_subscribe', $email, $list_id, $merge_vars, $result, 'checkbox', $type, $related_object_id);
     }
     /**
      * @action `mc4wp_after_subscribe`
      * @param string $email
      * @param array $merge_vars
      * @param boolean $result
      *
      * Runs after the request is sent to MailChimp
      */
     do_action('mc4wp_after_subscribe', $email, $merge_vars, $result);
     // check if result succeeded, show debug message to administrators (only in NON-AJAX requests)
     if ($result !== true && $api->has_error() && $this->show_error_messages()) {
         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:jimmitjoo,项目名称:mnh,代码行数:81,代码来源:class-integration.php

示例12: get_response_html

 /**
  * Returns the HTML for success or error messages
  *
  * @return string
  */
 public function get_response_html()
 {
     // get all form messages
     $messages = $this->get_form_messages();
     // retrieve correct message
     $type = $this->is_successful() ? 'success' : $this->get_error_code();
     $message = isset($messages[$type]) ? $messages[$type] : $messages['error'];
     /**
      * @filter mc4wp_form_error_message
      * @deprecated 2.0.5
      * @use mc4wp_form_messages
      *
      * Used to alter the error message, don't use. Use `mc4wp_form_messages` instead.
      */
     $message['text'] = apply_filters('mc4wp_form_error_message', $message['text'], $this->get_error_code());
     $html = '<div class="mc4wp-alert mc4wp-' . $message['type'] . '">' . $message['text'] . '</div>';
     // show additional MailChimp API errors to administrators
     if (false === $this->is_successful() && current_user_can('manage_options')) {
         // show MailChimp error message (if any) to administrators
         $api = mc4wp_get_api();
         if ($api->has_error()) {
             $html .= '<div class="mc4wp-alert mc4wp-error"><strong>' . __('MailChimp Error:', 'mailchimp-for-wp') . '</strong><br />' . $api->get_error_message() . '</div>';
         }
     }
     return $html;
 }
开发者ID:shubham79,项目名称:Jhintaak,代码行数:31,代码来源:class-form-request.php

示例13: show_api_settings

 /**
  * Show the API settings page
  */
 public function show_api_settings()
 {
     $opts = mc4wp_get_options('general');
     $connected = mc4wp_get_api()->is_connected();
     // cache renewal triggered manually?
     $force_cache_refresh = isset($_POST['mc4wp-renew-cache']) && $_POST['mc4wp-renew-cache'] == 1;
     $mailchimp = new MC4WP_MailChimp();
     $lists = $mailchimp->get_lists($force_cache_refresh);
     if ($force_cache_refresh) {
         if (false === empty($lists)) {
             add_settings_error("mc4wp", "mc4wp-cache-success", __('Renewed MailChimp cache.', 'mailchimp-for-wp'), 'updated');
         } else {
             add_settings_error("mc4wp", "mc4wp-cache-error", __('Failed to renew MailChimp cache - please try again later.', 'mailchimp-for-wp'));
         }
     }
     require MC4WP_LITE_PLUGIN_DIR . 'includes/views/api-settings.php';
 }
开发者ID:shubham79,项目名称:Jhintaak,代码行数:20,代码来源:class-admin.php

示例14: show_general_settings

 /**
  * Show general settings page
  */
 public function show_general_settings()
 {
     $opts = mc4wp_get_options('general');
     $connected = mc4wp_get_api()->is_connected();
     if (!$connected) {
         add_settings_error('mc4wp', 'invalid-api-key', sprintf(__('Please make sure the plugin is connected to MailChimp. <a href="%s">Provide a valid API key.</a>', 'mailchimp-for-wp'), admin_url('?page=mailchimp-for-wp')), 'updated');
     }
     // cache renewal triggered manually?
     $force_cache_refresh = isset($_POST['mc4wp-renew-cache']) && $_POST['mc4wp-renew-cache'] == 1;
     $mailchimp = new MC4WP_MailChimp();
     $lists = $mailchimp->get_lists($force_cache_refresh);
     if ($force_cache_refresh) {
         if (false === empty($lists)) {
             add_settings_error('mc4wp', 'mc4wp-cache-success', __('Renewed MailChimp cache.', 'mailchimp-for-wp'), 'updated');
         } else {
             add_settings_error('mc4wp', 'mc4wp-cache-error', __('Failed to renew MailChimp cache - please try again later.', 'mailchimp-for-wp'));
         }
     }
     require MC4WP_PLUGIN_DIR . 'includes/views/pages/admin-general-settings.php';
 }
开发者ID:ajay786singh,项目名称:emc,代码行数:23,代码来源:class-admin.php

示例15: get_form_message_html

	/**
	 * Returns the HTML for success or error messages
	 *
	 * @return string
	 */
	private function get_form_message_html( $form_id = 0 ) {

		// don't show message if form wasn't submitted
		if( ! is_object( $this->form_request ) ) {
			return '';
		}

		// get all form messages
		$messages = $this->get_form_messages( $form_id );

		// retrieve correct message
		$type = ( $this->form_request->is_successful() ) ? 'success' : $this->form_request->get_error_code();
		$message = ( isset( $messages[ $type ] ) ) ? $messages[ $type ] : $messages['error'];

		/**
		 * @filter mc4wp_form_error_message
		 * @deprecated 2.0.5
		 * @use mc4wp_form_messages
		 *
		 * Used to alter the error message, don't use. Use `mc4wp_form_messages` instead.
		 */
		$message['text'] = apply_filters('mc4wp_form_error_message', $message['text'], $this->form_request->get_error_code() );

		$html = '<div class="mc4wp-alert mc4wp-'. $message['type'].'">' . $message['text'] . '</div>';

		// show additional MailChimp API errors to administrators
		if( false === $this->form_request->is_successful() && current_user_can( 'manage_options' ) ) {
			// show MailChimp error message (if any) to administrators
			$api = mc4wp_get_api();
			if( $api->has_error() ) {
				$html .= '<div class="mc4wp-alert mc4wp-error"><strong>Admin notice:</strong> '. $api->get_error_message() . '</div>';
			}
		}

		return $html;
	}
开发者ID:kevinreilly,项目名称:mendelements.com,代码行数:41,代码来源:class-form-manager.php


注:本文中的mc4wp_get_api函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。