Does the logged-in user have the required capability?
public is_user_authorized ( ) : boolean | ||
Результат | boolean |
/** * Empty lists cache & fetch lists again. */ public function refresh_mailchimp_lists() { if (!$this->tools->is_user_authorized()) { wp_send_json(false); } $mailchimp = new MC4WP_MailChimp(); $lists = $mailchimp->fetch_lists(); $success = !empty($lists); wp_send_json($success); }
/** * Shows a notice when API key is not set. */ public function show_api_key_notice() { // don't show if on settings page already if ($this->tools->on_plugin_page('')) { return; } // only show to user with proper permissions if (!$this->tools->is_user_authorized()) { return; } // don't show if dismissed if (get_transient('mc4wp_api_key_notice_dismissed')) { return; } // don't show if api key is set already $options = mc4wp_get_options(); if (!empty($options['api_key'])) { return; } echo '<div class="notice notice-warning mc4wp-is-dismissible">'; echo '<p>' . sprintf(__('To get started with MailChimp for WordPress, please <a href="%s">enter your MailChimp API key on the settings page of the plugin</a>.', 'mailchimp-for-wp'), admin_url('admin.php?page=mailchimp-for-wp')) . '</p>'; echo '<form method="post"><input type="hidden" name="_mc4wp_action" value="dismiss_api_key_notice" /><button type="submit" class="notice-dismiss"><span class="screen-reader-text">Dismiss this notice.</span></button></form>'; echo '</div>'; }