MC4WP_Admin::enqueue_assets PHP Method

enqueue_assets() public method

Load scripts and stylesheet on MailChimp for WP Admin pages
public enqueue_assets ( ) : boolean
return boolean
    public function enqueue_assets()
    {
        global $wp_scripts;
        if (!$this->tools->on_plugin_page()) {
            return false;
        }
        $opts = mc4wp_get_options();
        $page = $this->tools->get_plugin_page();
        $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
        // css
        wp_register_style('mc4wp-admin', MC4WP_PLUGIN_URL . 'assets/css/admin-styles' . $suffix . '.css', array(), MC4WP_VERSION);
        wp_enqueue_style('mc4wp-admin');
        // js
        wp_register_script('es5-shim', MC4WP_PLUGIN_URL . 'assets/js/third-party/es5-shim.min.js', array(), MC4WP_VERSION);
        $wp_scripts->add_data('es5-shim', 'conditional', 'lt IE 9');
        // TODO: eventually get rid of jQuery here
        wp_register_script('mc4wp-admin', MC4WP_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array('jquery', 'es5-shim'), MC4WP_VERSION, true);
        wp_enqueue_script(array('jquery', 'es5-shim', 'mc4wp-admin'));
        wp_localize_script('mc4wp-admin', 'mc4wp_vars', array('mailchimp' => array('api_connected' => !empty($opts['api_key']), 'lists' => $this->mailchimp->get_cached_lists()), 'countries' => MC4WP_Tools::get_countries(), 'i18n' => array('pro_only' => __('This is a pro-only feature. Please upgrade to the premium version to be able to use it.', 'mailchimp-for-wp'), 'renew_mailchimp_lists' => __('Renew MailChimp lists', 'mailchimp-for-wp'), 'fetching_mailchimp_lists' => __('Fetching MailChimp lists', 'mailchimp-for-wp'), 'fetching_mailchimp_lists_done' => __('Done! MailChimp lists renewed.', 'mailchimp-for-wp'), 'fetching_mailchimp_lists_can_take_a_while' => __('This can take a while if you have many MailChimp lists.', 'mailchimp-for-wp'))));
        /**
         * Hook to enqueue your own custom assets on the MailChimp for WordPress setting pages.
         *
         * @since 3.0
         *
         * @param string $suffix
         * @param string $page
         */
        do_action('mc4wp_admin_enqueue_assets', $suffix, $page);
        return true;
    }