function chimpy_lite_form($allowed_forms = array()) { $opt = get_option('chimpy_lite_options', $results); // Check if integration is enabled if (!$opt || !is_array($opt) || empty($opt) || !isset($opt['chimpy_lite_api_key']) || !$opt['chimpy_lite_api_key']) { return; } // Check if at least one form is defined if (!isset($opt['forms']) || empty($opt['forms'])) { return; } $form = ChimpyLite::select_form_by_conditions($opt['forms'], $allowed_forms); require_once CHIMPY_LITE_PLUGIN_PATH . '/includes/chimpy-lite-prepare-form.inc.php'; $html = chimpy_lite_prepare_form($form, $opt, 'shortcode', null, true); echo $html; }
/** * Frontend display of widget * * @access public * @param array $args * @param array $instance * @return void */ public function widget($args, $instance) { // Check if integration is enabled if (!$this->opt['chimpy_lite_api_key'] || !isset($this->opt['forms']) || empty($this->opt['forms'])) { return; } // Get allowed forms $allowed_forms = isset($instance['allowed_forms']) && is_array($instance['allowed_forms']) && !empty($instance['allowed_forms']) ? $instance['allowed_forms'] : array(); // Select form that match the conditions best $form = ChimpyLite::select_form_by_conditions($this->opt['forms'], $allowed_forms); if (!$form) { return; } require_once CHIMPY_LITE_PLUGIN_PATH . '/includes/chimpy-lite-prepare-form.inc.php'; $form_html = chimpy_lite_prepare_form($form, $this->opt, 'widget', $args); echo $form_html; }