Пример #1
0
    /**
     * Back-end widget form.
     *
     * @see WP_Widget::form()
     *
     * @param array $instance Previously saved values from database.
     * @return string|void
     */
    public function form($instance)
    {
        $select = $instance ? esc_attr($instance['select']) : '';
        $style = $instance ? esc_attr($instance['style']) : '';
        $api_key = get_option($this->GrOptionDbPrefix . 'api_key');
        if (!empty($api_key)) {
            $api = new GetResponseIntegration($api_key);
            $campaigns = $api->getCampaigns();
            if (!empty($campaigns)) {
                $campaign_id = array();
                foreach ($campaigns as $cid => $campaign) {
                    $campaign_id[$cid] = $campaign->name;
                }
                $webforms = $api->getWebforms();
                $webforms = Gr_Integration::SortByKeyValue($webforms, 'name');
            }
        }
        ?>

		<?php 
        if ($api_key) {
            ?>
		<p>
			<?php 
            if (!empty($webforms) and false === (is_array($webforms) and isset($webforms['type']) and $webforms['type'] == 'error')) {
                ?>
			<label for="<?php 
                echo $this->get_field_id('select');
                ?>
"><?php 
                _e('Web Form:');
                ?>
</label>
			<select name="<?php 
                echo $this->get_field_name('select');
                ?>
" id="<?php 
                echo $this->get_field_id('select');
                ?>
" class="widefat">
				<?php 
                foreach ($webforms as $webform) {
                    echo '<option value="' . $webform->id . '" id="' . $webform->id . '"', $select == $webform->id ? ' selected="selected"' : '', '>', $webform->name . ' (' . $campaign_id[$webform->campaign] . ')', '</option>';
                }
                ?>
			</select>
			<?php 
            } else {
                _e('No Webforms', 'Gr_Integration');
            }
            ?>
		</p>
		<p>
			<input id="<?php 
            echo $this->get_field_id('style');
            ?>
" name="<?php 
            echo $this->get_field_name('style');
            ?>
" type="checkbox" value="1" <?php 
            checked('1', $style);
            ?>
 />
			<label for="<?php 
            echo $this->get_field_id('style');
            ?>
"><?php 
            _e('Use Wordpress CSS styles', 'Gr_Integration');
            ?>
</label>
		</p>
		<?php 
        } else {
            ?>
		<p><?php 
            _e('API key is not set.', 'Gr_Integration');
            ?>
</p>
		<?php 
        }
    }
Пример #2
0
    /**
     * Display GetResponse MCE buttons
     */
    function GrJsShortcodes()
    {
        $GrOptionDbPrefix = 'GrIntegrationOptions_';
        $api_key = get_option($GrOptionDbPrefix . 'api_key');
        if (!empty($api_key)) {
            $api = new GetResponseIntegration($api_key);
            $campaigns = $api->getCampaigns();
            $webforms = $api->getWebforms();
            // check if no errors
            if (!empty($webforms) and false === (is_array($webforms) and isset($webforms['type']) and $webforms['type'] == 'error')) {
                $webforms = $this->SortByKeyValue($webforms, 'name');
            } else {
                $campaigns = null;
                $webforms = null;
            }
            $my_campaigns = json_encode($campaigns);
            $my_webforms = json_encode($webforms);
            ?>
			<script type="text/javascript">
				var my_webforms = <?php 
            echo $my_webforms;
            ?>
;
				var my_campaigns = <?php 
            echo $my_campaigns;
            ?>
;
			</script>
	<?php 
        }
    }
    /**
     * Display GetResponse MCE buttons
     */
    function GrJsShortcodes()
    {
        $GrOptionDbPrefix = 'GrIntegrationOptions_';
        $api_key = get_option($GrOptionDbPrefix . 'api_key');
        $api_url = get_option($GrOptionDbPrefix . 'api_url');
        $api_domain = get_option($GrOptionDbPrefix . 'api_domain');
        $webforms = null;
        $forms = null;
        $campaingns = null;
        if (!empty($api_key)) {
            $api = new GetResponseIntegration($api_key, $api_url, $api_domain, is_ssl());
            $webforms = $api->getWebforms(array('sort' => array('name' => 'asc')));
            $forms = $api->getForms(array('sort' => array('name' => 'asc')));
            $api_key = 'true';
            $campaingns = $api->getCampaigns();
            // for 3.8 version
        } else {
            $api_key = 'false';
        }
        if (strlen($api_domain) > 0) {
            $webforms = $this->setGetResponse360domainToWebFormUrl($webforms, $api_domain);
            $forms = $this->setGetResponse360domainToWebFormUrl($forms, $api_domain);
        }
        $webforms = json_encode($webforms);
        $forms = json_encode($forms);
        $campaingns = json_encode($campaingns);
        // for 3.8 version
        ?>
		<script type="text/javascript">
			var my_webforms = <?php 
        echo $webforms;
        ?>
;
			var my_forms = <?php 
        echo $forms;
        ?>
;
			var my_campaigns = <?php 
        echo $campaingns;
        // for 3.8 version
        ?>
;
			var text_forms = '<?php 
        echo __('New Forms', 'Gr_Integration');
        ?>
';
			var text_webforms = '<?php 
        echo __('Old Web Forms', 'Gr_Integration');
        ?>
';
			var text_no_forms = '<?php 
        echo __('No Forms', 'Gr_Integration');
        ?>
';
			var text_no_webforms = '<?php 
        echo __('No Web Forms', 'Gr_Integration');
        ?>
';
			var api_key = <?php 
        echo $api_key;
        ?>
;
		</script>
		<?php 
    }