/**
 * Action target that displays the popup to insert a form to a post/page
 */
function eventspot_add_mce_popup()
{
    global $pagenow;
    if (empty($pagenow) || !in_array($pagenow, array('post-new.php', 'post.php'))) {
        return;
    }
    echo kws_ob_include(EVENTSPOT_FILE_PATH . 'views/embed-form.php');
}
 function add_help()
 {
     global $plugin_page, $pagenow;
     $screen = get_current_screen();
     $tabs = array();
     $tabs[] = array('id' => 'ctct-insert-form', 'title' => __('Constant Contact: Add a Form to Post or Page', 'ctct'), 'content' => kws_ob_include(CTCT_DIR_PATH . 'views/help/insert-form.html'));
     $tabs[] = array('id' => 'ctct-insert-event', 'title' => __('Constant Contact: Add an Event', 'ctct'), 'content' => kws_ob_include(CTCT_DIR_PATH . 'views/help/insert-event.html'));
     $tabs[] = array('id' => 'ctct-insert-settings-spam', 'title' => __('Constant Contact: Settings > Spam Prevention', 'ctct'), 'content' => kws_ob_include(CTCT_DIR_PATH . 'views/help/settings-spam.phtml'));
     $tabs = apply_filters('constant_contact_help_tabs', $tabs, $screen);
     if (!empty($tabs) && is_object($screen)) {
         foreach ($tabs as $tab) {
             // Wrap the contents in a .wrap class
             $screen->add_help_tab($tab);
             if (!empty($tab['sidebar'])) {
                 $screen->set_help_sidebar($tab['sidebar']);
             }
         }
     }
     return;
 }
 /**
  * Output events.
  *
  * Pass $args as an array with the following settings.
  * 'id' // REQUIRED if you want to show a single event! The ID is the ID of the event. Looks like a18g4v1b611561nn40b. If empty, show a list of events.
  * 'limit' // If you want to embed a list of events, limit the list to this number. You can set the limit to 0 and have it show all events (not ideal if you have a bunch of events). Default: 3; Type: number
  * 'showtitle' // Show the title of the event. Default: true
  * 'showdescription' // Show the description of the event. Default: true
  * 'datetime' // Show the date and time of the event. Default: true
  * 'location' // Show the location of the event. Default: false
  * 'map' // Show a link to the map. Default: false
  * 'calendar' // Show a link to add the event to calendar. Default: false
  * 'style' // Style the event listing with some basic styles? Default: true
  * 'newwindow' // Open the links in a new window? Default: false
  * 'onlyactive' // Only show active events? Default: true
  * 'mobile' // If users are on mobile devices, link to a mobile-friendly registration page? Default: true,
  * 'no_events_text' // Text to display when there are no events shown.
  * @param  array   $args    Output settings. See function description.
  * @param  boolean $echo    Echo or return events output
  * @return [type]           [description]
  */
 function events_output($args = array(), $echo = false)
 {
     $settings = shortcode_atts(array('limit' => 3, 'showtitle' => true, 'showdescription' => true, 'datetime' => true, 'location' => false, 'calendar' => false, 'style' => true, 'id' => false, 'newwindow' => false, 'map' => false, 'onlyactive' => true, 'sidebar' => false, 'mobile' => true, 'class' => 'cc_event', 'no_events_text' => __('There are no active events.', 'ctct')), $args);
     foreach ($settings as $key => $arg) {
         if (strtolower($arg) == 'false' || empty($arg)) {
             $settings["{$key}"] = false;
         }
     }
     if (empty($settings['id'])) {
         $settings['events'] = constant_contact_old_api_get_all('Events', $this->old_api);
         $settings['class'] .= ' multiple_events';
     } else {
         $settings['class'] .= ' single_event';
         $settings['events'] = array(CTCT_EventSpot::getInstance()->old_api->getEventDetails(new Event(array('link' => sprintf('/ws/customers/%s/events/%s', CTCT_USERNAME, $settings['id'])))));
     }
     $this->settings = $settings;
     $output = kws_ob_include(EVENTSPOT_FILE_PATH . 'shortcode.php', $this);
     if ($echo) {
         echo $output;
     } else {
         return $output;
     }
 }
    /**
     * Generate the settings page layout and settings fields
     *
     * @filter CTCT_Settings_array
     * @action CTCT_Settings_sections
     * @uses register_setting()
     * @uses add_settings_section()
     * @uses add_settings_field()
     * @return array Array of settings to be shown in the admin.
     */
    function settings_init()
    {
        global $plugin_page;
        register_setting('ctct_settings', 'ctct_settings');
        if ($plugin_page !== 'constant-contact-api') {
            return;
        }
        // We don't need this yet unless it's configured.
        if (!$this->cc->isConfigured()) {
            return;
        }
        add_settings_section('setup', '<i class="dashicons dashicons-admin-settings"></i> ' . __('Setup', 'ctct'), '', 'constant-contact-api');
        // Hook in here for more tabs.
        do_action('ctct_settings_sections');
        add_settings_section('registration', '<i class="dashicons dashicons-forms"></i> ' . __('Registration Form', 'ctct'), '<h3>' . esc_html__('Configure how users sign up.', 'ctct') . '</h3>', 'constant-contact-api');
        add_settings_section('comments', '<i class="dashicons dashicons-admin-comments
"></i> ' . __('Comment Form', 'ctct'), '<h3>' . esc_html__('Configure how users sign up.', 'ctct') . '</h3>', 'constant-contact-api');
        add_settings_section('spam', '<i class="dashicons dashicons-trash"></i> ' . __('Spam Prevention', 'ctct'), '<h3>' . esc_html__('How do you want to prevent spam?', 'ctct') . '</h3>', 'constant-contact-api');
        $groups = array('setup' => array(array('type' => 'html', 'content' => kws_ob_include(CTCT_DIR_PATH . 'views/admin/view.setup.php', $this)), array('id' => 'eventspot', 'type' => 'checkbox', 'desc' => __('Enable EventSpot Integration', 'ctct'), 'label' => __('Enable integration with Constant Contact Events (EventSpot)?', 'ctct')), array('type' => 'checkboxes', 'id' => 'logging', 'options' => array('activity' => __('Log Constant Contact Activity', 'ctct'), 'error' => __('Log Errors & Exceptions', 'ctct'), 'debug' => __('Detailed Debugging Logs (Do not leave enabled! Server-intensive.)', 'ctct')), 'desc' => __('Activity Logs', 'ctct'), 'label' => __('Log different activity from the plugin, including form submissions and the results ("Constant Contact Activity").', 'ctct'))), 'registration' => array(array('type' => 'heading', 'desc' => __('WordPress Registration Form', 'ctct'), 'label' => sprintf(__('Add signup options to WordPress\' <a href="%s" rel="external">registration form.</a>', 'ctct'), site_url('wp-login.php?action=register'))), array('type' => 'radio', 'id' => 'register_page_method', 'options' => array('none' => __('Disabled', 'ctct'), 'checkbox' => __('Single Checkbox - show users a checkbox which, if ticked, will automatically subscribe them to the lists you select below in the "Active Contact Lists" section.', 'ctct'), 'checkboxes' => __('List of Checkboxes - show a bullet list with the name of the list and a checkbox option for them to sign up', 'ctct'), 'dropdown' => __('Dropdown List', 'ctct')), 'toggle' => 'registration', 'desc' => __('User Subscription Method', 'ctct')), array('id' => 'default_opt_in', 'togglegroup' => 'registration_checkbox registration_checkboxes', 'type' => 'checkbox', 'desc' => __('Opt-in users by default?', 'ctct'), 'label' => __('Should the opt-in checkbox(es) be checked by default? If using the "List Selection" method, should lists be pre-selected by default.', 'ctct')), array('type' => 'lists', 'id' => 'registration_checkbox_lists', 'togglegroup' => 'registration_checkbox', 'desc' => __('Lists for Registration', 'ctct'), 'label' => __('<strong>Checkbox:</strong> What lists will users be added to when checking the opt-in box?<br />Others: What lists will users be presented with?', 'ctct'), 'options' => KWSContactList::outputHTML('all', array('type' => 'checkboxes', 'format' => '%%name%%', 'name_attr' => 'ctct_settings[registration_checkbox_lists]', 'id_attr' => 'constant-contact-api_registration_checkbox_lists_%%id%%', 'checked' => self::get('registration_checkbox_lists'), 'class' => 'toggle_registration_checkbox toggle_registration_checkboxes toggle_registration_dropdown')), 'help' => __('When users sign up for your newsletter while registering for a WordPress account, they will be added to the following lists.', 'ctct')), array('id' => 'signup_description', 'togglegroup' => 'registration_checkbox registration_checkboxes registration_dropdown', 'type' => 'textarea', 'desc' => __('Signup Description', 'ctct'), 'label' => __('Signup form description text displayed on the registration screen and user profile setting, if enabled. HTML is allowed. Paragraphs will be added automatically like in posts.', 'ctct')), array('type' => 'radio', 'togglegroup' => 'registration_checkbox registration_checkboxes registration_dropdown', 'id' => 'signup_description_position', 'options' => array('before' => __('Before the Opt-in', 'ctct'), 'after' => __('After the Opt-in', 'ctct')), 'desc' => __('Signup Description Position', 'ctct')), array('id' => 'signup_title', 'togglegroup' => 'registration_checkbox registration_checkboxes registration_dropdown', 'type' => 'text', 'desc' => __('Signup Title', 'ctct'), 'label' => __('Title for the signup form displayed on the registration screen and user profile settings if enabled.', 'ctct')), array('type' => 'text', 'togglegroup' => 'registration_dropdown', 'id' => 'default_select_option_text', 'desc' => __('Default Option Text', 'ctct'), 'label' => __('If "Opt-in users by default" (below) is not checked, this will be the default option in the dropdown menu. Leave blank to not show this option.', 'ctct')), array('type' => 'heading', 'desc' => __('Profile Page', 'ctct')), array('type' => 'checkbox', 'id' => 'profile_page_form', 'label' => __('Allow users to modify their subscription on their WordPress profile page', 'ctct'), 'desc' => __('Show Form on Profile Page?', 'ctct'), 'help' => __('Do you want users to be able to update their subscriptions inside WordPress?', 'ctct'))), 'comments' => array(array('type' => 'heading', 'desc' => __('Comment Form', 'ctct')), array('type' => 'checkbox', 'id' => 'comment_form_signup', 'label' => __('Add a checkbox for subscribing to a newsletter below a comment form', 'ctct'), 'toggle' => 'comment_form', 'desc' => __('Comment Form Signup', 'ctct')), array('togglegroup' => 'comment_form', 'type' => 'checkbox', 'id' => 'comment_form_default', 'desc' => __('Checked by default?', 'ctct'), 'label' => __('Should the checkbox be checked by default?', 'ctct')), array('type' => 'lists', 'id' => 'comment_form_lists', 'togglegroup' => 'comment_form', 'desc' => __('Lists for Comment Form', 'ctct'), 'label' => __('What lists will users be added to when signing up with the Comment Form?', 'ctct'), 'options' => KWSContactList::outputHTML('all', array('type' => 'checkboxes', 'format' => '%%name%%', 'name_attr' => 'ctct_settings[comment_form_lists]', 'id_attr' => 'constant-contact-api_comment_form_lists_%%id%%', 'class' => 'toggle_comment_form', 'checked' => self::get('comment_form_lists')))), array('togglegroup' => 'comment_form', 'type' => 'text', 'id' => 'comment_form_check_text', 'desc' => __('Subscribe Message', 'ctct')), array('togglegroup' => 'comment_form', 'type' => 'text', 'id' => 'comment_form_subscribed_text', 'desc' => __('Already Subscribed Message', 'ctct')), array('togglegroup' => 'comment_form', 'type' => 'checkbox', 'id' => 'comment_form_clear', 'label' => __('Uncheck if this causes layout issues', 'ctct'), 'desc' => __('Add a CSS \'clear\' to the checkbox?', 'ctct'))), 'spam' => array(array('type' => 'checkboxes', 'id' => 'spam_methods', 'toggle' => 'spam_methods', 'options' => array('datavalidation' => __('Verify Email Addresses with <a href="http://katz.si/datavalidation" rel="external">DataValidation.com</a>', 'ctct') . constant_contact_tip(__('DataValidation.com is the best way to verify that when users submit a form, the submitted email address is valid.', 'ctct'), false), 'akismet' => __('Akismet', 'ctct') . self::get_plugin_status_message('akismet'), 'wangguard' => __('WangGuard WordPress Plugin', 'ctct') . self::get_plugin_status_message('wangguard'), 'smtp' => __('Validate Email Addresses Via SMTP (<a href="http://katz.si/smtpvalidation" rel="external">See the project</a>)', 'ctct') . constant_contact_tip(__('Uses server methods to verify emails: checks for a valid domain, then sends a request for a read receipt.', 'ctct'), false)), 'desc' => __('What services do you want to use to prevent spam submissions of your forms?', 'ctct')), array('type' => 'heading', 'togglegroup' => 'spam_methods_datavalidation', 'desc' => __('DataValidation.com Settings', 'ctct')), array('type' => 'text', 'togglegroup' => 'spam_methods_datavalidation', 'id' => 'datavalidation_api_key', 'desc' => __('DataValidation.com: API Key', 'ctct'), 'label' => sprintf(__('Enter your DataValidation.com API key. %sSign up for a key here%s.', 'ctct'), '<a href="https://developer.datavalidation.com" rel="external">', '</a>')), array('type' => 'checkbox', 'togglegroup' => 'spam_methods_datavalidation', 'id' => 'datavalidation_prevent_ambiguous', 'desc' => __('DataValidation.com: Should "ambiguous" responses be blocked?', 'ctct'), 'label' => __('Ambiguous Responses basically mean that the email looks good, it has valid DNS, it has a valid MX record, it even has an email server, but for a myriad of reasons it does not accept any connections to it. Could be connection refused, could be the server is down, etc.', 'ctct'))), 'forms' => array(array('type' => 'checkboxes', 'id' => 'forms', 'options' => array('formstack' => __('<a href="http://www.formstack.com/r/31575458">Formstack</a>', 'ctct'), 'after' => __('After the Opt-in', 'ctct')), 'desc' => __('Forms', 'ctct'))));
        $groups = apply_filters('ctct_settings_array', $groups);
        $i = 0;
        if (empty($groups)) {
            return;
        }
        foreach ($groups as $group => $settings) {
            foreach ($settings as $setting) {
                $i++;
                $setting['page'] = isset($setting['page']) ? $setting['page'] : 'constant-contact-api';
                $setting['callback'] = isset($setting['callback']) ? $setting['callback'] : array('CTCT_Settings', 'setting_input_generator');
                $setting['desc'] = isset($setting['desc']) ? $setting['desc'] : '';
                if (isset($setting['type']) && $setting['type'] === 'heading') {
                    $setting['id'] = sanitize_title($setting['desc']);
                }
                $setting['id'] = isset($setting['id']) ? $setting['id'] : '';
                extract($setting);
                unset($setting['callback']);
                add_settings_field($id, $desc, $callback, $page, $group, $setting);
            }
        }
    }
 function page()
 {
     parent::page();
     if (!$this->cc->isConfigured()) {
         echo kws_ob_include(CTCT_DIR_PATH . 'views/admin/view.connect-account.php', $this);
     }
 }