WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Trying to make a multi-instance widget (3 posts)

  1. zhumar
    Member
    Posted 1 year ago #

    I want my widget to have the ability to have multiple instances on the same page. Right now, if I have 2 instances on one page, the first will load and the second will be blank. It uses AJAX, but I do have a unique ID system in place that uses the number from the widget ID found in $args. I imagine it has something to do with registering the widget or something, but I'm not sure.

    Here is my code:
    joomconnect_quick_ticket_lite.php - initial file

    <?php
    /*
    Plugin Name: JoomConnect Quick Ticket Lite
    Plugin URI: http://www.joomconnect.com/joomconnect/qt-lite.html
    Description: Creates a widget which allows users to create tickets in your ConnectWise using the email connectors you set up in the widget settings.
    Author: Directive
    Version: 1.0.0
    Author URI: http://www.joomconnect.com
    */
    
    class jc_qtlite {
    
    	function jc_qtlite(){
    
    		if(!is_admin()){
    			// Header styles
    			add_action( 'wp_head', array('jc_qtlite', 'header') );
    
    		}
    		add_action( 'wp_footer', array('jc_qtlite', 'footer') );
    	}
    
    	function header(){
    		echo "\n\t<link rel=\"stylesheet\" type=\"text/css\" href=\"".jc_qtlite::get_plugin_directory()."/css/emailconnector.css\" media=\"screen\" />";
    
    		// Scripts
    		wp_enqueue_script( 'jquery' );
    		wp_enqueue_script( 'ajax', jc_qtlite::get_plugin_directory() . '/js/ajax.js', array('jquery') );
    		wp_enqueue_script( 'jquerymin', jc_qtlite::get_plugin_directory() . '/js/jquery.min.js', array('jquery') );
    
    	}
    
    	function footer(){
    		//echo "\n\t";
    	}
    
    	function options(){}
    
    	function get_plugin_directory(){
    		return WP_PLUGIN_URL . '/joomconnect-quick-ticket-lite';
    	}
    
    };
    
    // Include the widget
    include_once('joomconnect_quick_ticket_lite_widget.php');
    
    // Initialize the plugin.
    $jc_qtlite = new jc_qtlite();
    
    // Register the widget
    add_action('widgets_init', create_function('', 'return register_widget("jc_qtlite_widget");'));
    
    ?>

    joomconnect_quick_ticket_lite_widget.php - main widget file

    <?php
    
    class jc_qtlite_widget extends WP_Widget {
        /** constructor */
        function jc_qtlite_widget() {
    
    		$name =		'JoomConnect Quick Ticket Lite';
    		$desc = 		'Offer a form for users to submit tickets using your configured email connectors';
    		$id_base = 		'jc_qtlite_widget';
    		$css_class = 	'';
    		$alt_option = 	'widget_jc_quick_ticket_lite';
    
    		$widget_ops = array(
    			'classname' => $css_class,
    			'description' => __( $desc, 'jc-quick-ticket-lite' ),
    		);
    		parent::WP_Widget( 'nav_menu', __('Custom Menu'), $widget_ops );
    
    		$this->WP_Widget($id_base, __($name, 'jcqtlite'), $widget_ops);
    		$this->alt_option_name = $alt_option;
    
    		//add_action( 'wp_head', array(&$this, 'styles'), 10, 1 );
    		//add_action( 'wp_footer', array(&$this, 'footer'), 10, 1 );
    
    		$this->defaults = array(
    			'title' => '',
    			'pretext' => '',
    			'posttext' => '',
    			'fullnamelabel' => '',
    			'emaillabel' => '',
    			'showbuttonimage' => '',
    			'subjectlabel' => '',
    			'descriptionlabel' => '',
    			'serviceboard' => '',
    			'imagepath' => '',
    			'buttontext' => '',
    			'successmessage' => '',
    			'textsize' => '',
    			'rowsfortextarea' => '',
    			'colsfortextarea' => '',
    			'fieldlayout' => ''
    		);
    	}
    
    	function widget($args, $instance) {
    		//extract($args, EXTR_SKIP);
     		extract($args);
    
    		echo $before_widget;
    		$title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
    
    		if (!empty($title))
    			echo $before_title . $title . $after_title;;
    
    		/** Widget actions start **/
    
    		include('joomconnect_quick_ticket_lite_front.php');
    
    		/** End widget actions **/
    
    		echo $after_widget;
    	}
    
        /** @see WP_Widget::update */
        function update( $new_instance, $old_instance ) {
    		$instance['title'] = strip_tags( stripslashes($new_instance['title']) );
    		$instance['pretext'] = strip_tags( stripslashes($new_instance['pretext']) );
    		$instance['posttext'] = strip_tags( stripslashes($new_instance['posttext']) );
    		$instance['fullnamelabel'] = strip_tags( stripslashes($new_instance['fullnamelabel']) );
    		$instance['emaillabel'] = strip_tags( stripslashes($new_instance['emaillabel']) );
    		$instance['showbuttonimage'] = $new_instance['showbuttonimage'];
    		$instance['subjectlabel'] = strip_tags( stripslashes($new_instance['subjectlabel']) );
    		$instance['descriptionlabel'] = strip_tags( stripslashes($new_instance['descriptionlabel']) );
    		$instance['serviceboard'] = strip_tags( stripslashes($new_instance['serviceboard']) );
    		$instance['imagepath'] = strip_tags( stripslashes($new_instance['imagepath']) );
    		$instance['buttontext'] = strip_tags( stripslashes($new_instance['buttontext']) );
    		$instance['successmessage'] = strip_tags( stripslashes($new_instance['successmessage']) );
    		$instance['textsize'] = strip_tags( stripslashes($new_instance['textsize']) );
    		$instance['rowsfortextarea'] = strip_tags( stripslashes($new_instance['rowsfortextarea']) );
    		$instance['colsfortextarea'] = strip_tags( stripslashes($new_instance['colsfortextarea']) );
    		$instance['fieldlayout'] = $new_instance['fieldlayout'];
    
    		return $instance;
    	}
    
        /** @see WP_Widget::form */
        function form($instance) {
    		$title = isset( $instance['title'] ) ? $instance['title'] : '';
    		$pretext = isset( $instance['pretext'] ) ? $instance['pretext'] : '';
    		$posttext = isset( $instance['posttext'] ) ? $instance['posttext'] : '';
    		$fullnamelabel = isset( $instance['fullnamelabel'] ) ? $instance['fullnamelabel'] : '';
    		$emaillabel = isset( $instance['emaillabel'] ) ? $instance['emaillabel'] : '';
    		$showbuttonimage = isset( $instance['showbuttonimage'] ) ? $instance['showbuttonimage'] : '';
    		$subjectlabel = isset( $instance['subjectlabel'] ) ? $instance['subjectlabel'] : '';
    		$descriptionlabel = isset( $instance['descriptionlabel'] ) ? $instance['descriptionlabel'] : '';
    		$serviceboard = isset( $instance['serviceboard'] ) ? $instance['serviceboard'] : '';
    		$imagepath = isset( $instance['imagepath'] ) ? $instance['imagepath'] : '';
    		$buttontext = isset( $instance['buttontext'] ) ? $instance['buttontext'] : '';
    		$successmessage = isset( $instance['successmessage'] ) ? $instance['successmessage'] : '';
    		$textsize = isset( $instance['textsize'] ) ? $instance['textsize'] : '';
    		$rowsfortextarea = isset( $instance['rowsfortextarea'] ) ? $instance['rowsfortextarea'] : '';
    		$colsfortextarea = isset( $instance['colsfortextarea'] ) ? $instance['colsfortextarea'] : '';
    		$fieldlayout = isset( $instance['fieldlayout'] ) ? $instance['fieldlayout'] : '';
    
    		$widget_options = wp_parse_args( $instance, $this->defaults );
    		extract( $widget_options, EXTR_SKIP );
    
    		//Set tooltip strings
    		$titletip = 'The widget title that will show on the frontend of your site.';
    		$pretexttip = 'This text will appear above the form';
    		$posttexttip = 'This text will appear below the form';
    		$fullnamelabeltip = 'Label for the Name field on the form';
    		$emaillabeltip = 'Label for the Email field on the form';
    		$showbuttonimagetip = 'Select whether you would like to use a standard submit button or an image for your submit button';
    		$subjectlabeltip = 'Label for the Subject field on the form';
    		$descriptionlabeltip = 'Label for the Problem Description field on the form';
    		$serviceboardtip = 'Service board name(s) and email(s). Enter one per line. Name and email should be separated by - only. Example: Support-support@domain.com';
    		$imagepathtip = 'The full path to the image you wish to use as your form submit button';
    		$buttontexttip = 'The text to display in the submit button';
    		$successmessagetip = 'The text to display after the form is submitted';
    		$textsizetip = 'Set the size of text box fields';
    		$rowsfortextareatip = 'Set the rows/height of the text area field';
    		$colsfortextareatip = 'Set the columns/width of the text area field';
    		$fieldlayouttip = 'Select Full Form to better display this form inside a large content area. Select Slim Line for a better display on the sidebar.';
    
    		?>
    
    <link rel='stylesheet' href='/wp-content/plugins/joomconnect-quick-ticket-lite/css/emailconnector.css' type='text/css' media='all' />
    <script type='text/javascript' src='/wp-content/plugins/joomconnect-quick-ticket-lite/js/tooltip.js'></script>
    
    <table>
    	<tr><td>
    		<label for="<?php echo $this->get_field_id('title'); ?>" onmouseover="tooltip.show('<?php echo $titletip; ?>', 230);" onmouseout="tooltip.hide();"><?php _e('Title:') ?></label>
    	</td><td>
    		<input type="text" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo $title; ?>" />
    	</td></tr>
    
    	<tr><td>
    		<label for="<?php echo $this->get_field_id('pretext'); ?>" onmouseover="tooltip.show('<?php echo $pretexttip; ?>', 230);" onmouseout="tooltip.hide();"><?php _e('Pre-text:') ?></label>
    	</td><td>
    		<textarea rows="3" cols="17" id="<?php echo $this->get_field_id('pretext'); ?>" name="<?php echo $this->get_field_name('pretext'); ?>"><?php echo $pretext; ?></textarea>
    	</td></tr>
    
    	<tr><td>
    		<label for="<?php echo $this->get_field_id('posttext'); ?>" onmouseover="tooltip.show('<?php echo $posttexttip; ?>', 230);" onmouseout="tooltip.hide();"><?php _e('Post-text:') ?></label>
    	</td><td>
    		<textarea rows="3" cols="17" id="<?php echo $this->get_field_id('posttext'); ?>" name="<?php echo $this->get_field_name('posttext'); ?>"><?php echo $posttext; ?></textarea>
    	</td></tr>
    
    	<tr><td>
    		<label for="<?php echo $this->get_field_id('fullnamelabel'); ?>" onmouseover="tooltip.show('<?php echo $fullnamelabeltip; ?>', 230);" onmouseout="tooltip.hide();"><?php _e('Full Name Label:') ?></label>
    	</td><td>
    		<input type="text" id="<?php echo $this->get_field_id('fullnamelabel'); ?>" name="<?php echo $this->get_field_name('fullnamelabel'); ?>" value="<?php echo $fullnamelabel; ?>" />
    	</td></tr>
    
    	<tr><td>
    		<label for="<?php echo $this->get_field_id('emaillabel'); ?>" onmouseover="tooltip.show('<?php echo $emaillabeltip; ?>', 230);" onmouseout="tooltip.hide();"><?php _e('Email Label:') ?></label>
    	</td><td>
    		<input type="text" id="<?php echo $this->get_field_id('emaillabel'); ?>" name="<?php echo $this->get_field_name('emaillabel'); ?>" value="<?php echo $emaillabel; ?>" />
    	</td></tr>
    
    	<tr><td>
    		<label for="<?php echo $this->get_field_id('subjectlabel'); ?>" onmouseover="tooltip.show('<?php echo $subjectlabeltip; ?>', 230);" onmouseout="tooltip.hide();"><?php _e('Subject Label:') ?></label>
    	</td><td>
    		<input type="text" id="<?php echo $this->get_field_id('subjectlabel'); ?>" name="<?php echo $this->get_field_name('subjectlabel'); ?>" value="<?php echo $subjectlabel; ?>" />
    	</td></tr>
    
    	<tr><td>
    		<label for="<?php echo $this->get_field_id('descriptionlabel'); ?>" onmouseover="tooltip.show('<?php echo $descriptionlabeltip; ?>', 230);" onmouseout="tooltip.hide();"><?php _e('Description Label:') ?></label>
    	</td><td>
    		<input type="text" id="<?php echo $this->get_field_id('descriptionlabel'); ?>" name="<?php echo $this->get_field_name('descriptionlabel'); ?>" value="<?php echo $descriptionlabel; ?>" />
    	</td></tr>
    
    	<tr><td>
    		<label for="<?php echo $this->get_field_id('serviceboard'); ?>" onmouseover="tooltip.show('<?php echo $serviceboardtip; ?>', 230);" onmouseout="tooltip.hide();"><?php _e('Service Board Name & Email Connector:') ?></label>
    	</td><td>
    		<textarea rows="3" cols="17" id="<?php echo $this->get_field_id('serviceboard'); ?>" name="<?php echo $this->get_field_name('serviceboard'); ?>"><?php echo $serviceboard; ?></textarea>
    	</td></tr>
    
    	<tr><td>
    		<label for="<?php echo $this->get_field_id('showbuttonimage'); ?>" onmouseover="tooltip.show('<?php echo $showbuttonimagetip; ?>', 230);" onmouseout="tooltip.hide();"><?php _e('Show Button/Image:') ?></label>
    	</td><td>
    		<?php
    		$pos = strpos($showbuttonimage, 'Button');
    		if($pos === false){ ?>
    			<input type="radio" id="<?php echo $this->get_field_id('showbuttonimage'); ?>" name="<?php echo $this->get_field_name('showbuttonimage'); ?>" value="Button"> Button
    			<input type="radio" id="<?php echo $this->get_field_id('showbuttonimage'); ?>" name="<?php echo $this->get_field_name('showbuttonimage'); ?>" value="Image" checked> Image
    		<?php }else{ ?>
    			<input type="radio" id="<?php echo $this->get_field_id('showbuttonimage'); ?>" name="<?php echo $this->get_field_name('showbuttonimage'); ?>" value="Button" checked> Button
    			<input type="radio" id="<?php echo $this->get_field_id('showbuttonimage'); ?>" name="<?php echo $this->get_field_name('showbuttonimage'); ?>" value="Image"> Image
    		<?php } ?>
    	</td></tr>
    
    	<tr><td>
    		<label for="<?php echo $this->get_field_id('imagepath'); ?>" onmouseover="tooltip.show('<?php echo $imagepathtip; ?>', 230);" onmouseout="tooltip.hide();"><?php _e('Image Path:') ?></label>
    	</td><td>
    		<input type="text" id="<?php echo $this->get_field_id('imagepath'); ?>" name="<?php echo $this->get_field_name('imagepath'); ?>" value="<?php echo $imagepath; ?>" />
    	</td></tr>
    
    	<tr><td>
    		<label for="<?php echo $this->get_field_id('buttontext'); ?>" onmouseover="tooltip.show('<?php echo $buttontexttip; ?>', 230);" onmouseout="tooltip.hide();"><?php _e('Button Text:') ?></label>
    	</td><td>
    		<input type="text" id="<?php echo $this->get_field_id('buttontext'); ?>" name="<?php echo $this->get_field_name('buttontext'); ?>" value="<?php echo $buttontext; ?>" />
    	</td></tr>
    
    	<tr><td>
    		<label for="<?php echo $this->get_field_id('successmessage'); ?>" onmouseover="tooltip.show('<?php echo $successmessagetip; ?>', 230);" onmouseout="tooltip.hide();"><?php _e('Success Message:') ?></label>
    	</td><td>
    		<input type="text" id="<?php echo $this->get_field_id('successmessage'); ?>" name="<?php echo $this->get_field_name('successmessage'); ?>" value="<?php echo $successmessage; ?>" />
    	</td></tr>
    
    	<tr><td>
    		<label for="<?php echo $this->get_field_id('textsize'); ?>" onmouseover="tooltip.show('<?php echo $textsizetip; ?>', 230);" onmouseout="tooltip.hide();"><?php _e('Text Field Size:') ?></label>
    	</td><td>
    		<input type="text" id="<?php echo $this->get_field_id('textsize'); ?>" name="<?php echo $this->get_field_name('textsize'); ?>" value="<?php echo $textsize; ?>" />
    	</td></tr>
    
    	<tr><td>
    		<label for="<?php echo $this->get_field_id('rowsfortextarea'); ?>" onmouseover="tooltip.show('<?php echo $rowsfortextareatip; ?>', 230);" onmouseout="tooltip.hide();"><?php _e('Rows for Text Area:') ?></label>
    	</td><td>
    		<input type="text" id="<?php echo $this->get_field_id('rowsfortextarea'); ?>" name="<?php echo $this->get_field_name('rowsfortextarea'); ?>" value="<?php echo $rowsfortextarea; ?>" />
    	</td></tr>
    
    	<tr><td>
    		<label for="<?php echo $this->get_field_id('colsfortextarea'); ?>" onmouseover="tooltip.show('<?php echo $colsfortextareatip; ?>', 230);" onmouseout="tooltip.hide();"><?php _e('Columns for Text Area:') ?></label>
    	</td><td>
    		<input type="text" id="<?php echo $this->get_field_id('colsfortextarea'); ?>" name="<?php echo $this->get_field_name('colsfortextarea'); ?>" value="<?php echo $colsfortextarea; ?>" />
    	</td></tr>
    
    	<tr><td>
    		<label for="<?php echo $this->get_field_id('fieldlayout'); ?>" onmouseover="tooltip.show('<?php echo $fieldlayouttip; ?>', 230);" onmouseout="tooltip.hide();"><?php _e('Form Field Layout:') ?></label>
    	</td><td>
    		<?php //1 = full 	2 = slim
    		if($fieldlayout == 2){ ?>
    			<select id="<?php echo $this->get_field_id('fieldlayout'); ?>" name="<?php echo $this->get_field_name('fieldlayout'); ?>">
    			  <option value="1"> Full Form </option>
    			  <option value="2" selected>Slim Line </option>
    			</select>
    		<?php }else{ ?>
    			<select id="<?php echo $this->get_field_id('fieldlayout'); ?>" name="<?php echo $this->get_field_name('fieldlayout'); ?>">
    			  <option value="1" selected>Full Form </option>
    			  <option value="2">Slim Line </option>
    			</select>
    		<?php } ?>
    	</td></tr>
    </table>
    <?php
    	}
    } // class jc_qtlite_widget

    joomconnect_quick_ticket_lite_front.php - frontend display

    <?php
    
    $pretext = isset( $instance['pretext'] ) ? $instance['pretext'] : '';
    $posttext = isset( $instance['posttext'] ) ? $instance['posttext'] : '';
    if(empty($instance['fullnamelabel']))
    	$fullnamelabel = 'Full Name';
    else
    	$fullnamelabel = $instance['fullnamelabel'];
    if(empty($instance['emaillabel']))
    	$emaillabel = 'Email';
    else
    	$emaillabel = $instance['emaillabel'];
    $showbuttonimage = isset( $instance['showbuttonimage'] ) ? $instance['showbuttonimage'] : 'Button';
    if(empty($instance['subjectlabel']))
    	$subjectlabel = 'Subject';
    else
    	$subjectlabel = $instance['subjectlabel'];
    if(empty($instance['descriptionlabel']))
    	$descriptionlabel = 'Problem Description';
    else
    	$descriptionlabel = $instance['descriptionlabel'];
    $serviceboard = isset( $instance['serviceboard'] ) ? $instance['serviceboard'] : '';
    $imagepath = isset( $instance['imagepath'] ) ? $instance['imagepath'] : '';
    if(empty($instance['buttontext']))
    	$buttontext = 'Submit';
    else
    	$buttontext = $instance['buttontext'];
    if(empty($instance['successmessage']))
    	$successmessage = 'Email has been sent';
    else
    	$successmessage = $instance['successmessage'];
    $textsize = isset( $instance['textsize'] ) ? $instance['textsize'] : '25';
    $rowsfortextarea = isset( $instance['rowsfortextarea'] ) ? $instance['rowsfortextarea'] : '5';
    $colsfortextarea = isset( $instance['colsfortextarea'] ) ? $instance['colsfortextarea'] : '';
    $fieldlayout = isset( $instance['fieldlayout'] ) ? $instance['fieldlayout'] : '2';
    
    $styletextarea = '';
    if(isset($colsfortextarea) && $colsfortextarea == ''){
    	$colsfortextarea = '18';
    	$styletextarea = 'style="width:100%;"';
    }
    $array_emailids = explode("\n",$serviceboard);
    
    $user = wp_get_current_user();
    //echo '<pre>'; print_r($user); //user_login
    $userid = $user->ID;
    
    $emailids .= ',';
    //$uniqueid = rand();
    $widgetID = $args['widget_id'];
    $widgetID = explode('-', $widgetID);
    $uniqueid = $widgetID[1];
    $string = '<div class="free_emailconnector_div"><div class="jcemailconnector_pos1">'.$pretext.'</div>';
    if($fieldlayout == '1' || $fieldlayout == 1){
    	$string .= '<form name="free_emailconnector_form_'.$uniqueid.'" action="#" method="post">';
    	$string .= '<table cellspacing="2px" cellpadding="2px" border="0" width="100%"><tbody>';
    	$string .= '<tr class="row"><td class="column_1">Select Service Board<span class="red">*</span></td>
    	<td class="column_2"><select name="service_board_emailid_'.$uniqueid.'" id="service_board_emailid_'.$uniqueid.'"><option value="all">Choose Service Board</option>';
    	foreach($array_emailids as $k => $v){
    		$exp2 = explode("-",$v);
    		if(isset($exp2) && is_array($exp2) && count($exp2) > 1){
    			$string .= '<option value="'.base64_encode(trim($exp2[1])).'">'.trim($exp2[0]).'</option>';
    			$admin_emails[] = base64_encode(trim($exp2[1]));
    		}
    		else{
    			$string .= '<option value="'.base64_encode(trim($exp2[0])).'">'.trim($exp2[0]).'</option>';
    			$admin_emails[] = base64_encode(trim($exp2[0]));
    		}
    	}
    	$string .= '</select><input type="hidden" name="free_emailconnector_emailid_'.$uniqueid.'" id="free_emailconnector_emailid_'.$uniqueid.'" value="'.implode(",",$admin_emails).','.'" /></td></tr>';
    	if($userid > 0){
    		$name = $user->user_firstname.' '.$user->user_lastname;
    		if($name == ' '){
    			$string .= '<div class="row"><input type="hidden" size="'.$textsize.'" name="username_'.$uniqueid.'" id="username_'.$uniqueid.'" value="'.$user->user_login.'" /><input type="hidden" size="'.$textsize.'" name="email_'.$uniqueid.'" id="email_'.$uniqueid.'" value="'.$user->user_email.'" /></div>';
    		}else{
    			$string .= '<div class="row"><input type="hidden" size="'.$textsize.'" name="username_'.$uniqueid.'" id="username_'.$uniqueid.'" value="'.$name.'" /><input type="hidden" size="'.$textsize.'" name="email_'.$uniqueid.'" id="email_'.$uniqueid.'" value="'.$user->user_email.'" /></div>';
    		}
    	}
    	else{
    		$string .= '<tr class="row"><td class="column_1">'.$fullnamelabel.'<span class="red">*</span></td><td class="column_2"><input type="text" size="'.$textsize.'" name="username_'.$uniqueid.'" id="username_'.$uniqueid.'" /></td></tr>';
    		$string .= '<tr class="row"><td class="column_1">'.$emaillabel.'<span class="red">*</span></td><td class="column_2"><input type="text" size="'.$textsize.'" name="email_'.$uniqueid.'" id="email_'.$uniqueid.'" /></td></tr>';
    	}
    	$string .= '<tr class="row"><td class="column_1">'.$subjectlabel.'<span class="red">*</span></td><td class="column_2"><input type="text" size="'.$textsize.'" name="subject_emailconnector_'.$uniqueid.'" id="subject_emailconnector_'.$uniqueid.'" /></td></tr>';
    	$string .= '<tr class="row"><td class="column_1">'.$descriptionlabel.'<span class="red">*</span></td><td class="column_2"><textarea id="message_emailconnector_'.$uniqueid.'" name="message_emailconnector_'.$uniqueid.'" cols="'.$colsfortextarea.'" '.$styletextarea.' rows="'.$rowsfortextarea.'"></textarea></td></tr>';
    	$string .= '<tr class="row"><td class="column_1">
    <input type="hidden" name="successmessage_'.$uniqueid.'" id="successmessage_'.$uniqueid.'" value="'.$successmessage.'" /></td><td class="column_2">';
    	if($showbuttonimage == '1' || $showbuttonimage == 1)
    	{
    		$string .= '<input type="button" name="free_emailconnector_button_'.$uniqueid.'" onclick="return callAjax('.$uniqueid.')" value="'.$buttontext.'" />';
    	}
    	else{
    		if($imagepath == ''){
    			$string .= '<input type="button" name="free_emailconnector_button_'.$uniqueid.'" onclick="return callAjax('.$uniqueid.')" value="'.$buttontext.'" />';
    		}
    		else{
    			$string .= '<img src="'.$imagepath.'" onclick="return callAjax('.$uniqueid.')" />';
    		}
    	}
    	$string .= '<div class="loadingimg_free_'.$uniqueid.'" style="display:none;"><img src="/wp-content/plugins/joomconnect-quick-ticket-lite/images/loading3.gif" /></td></tr>';
    	$string .= '</tbody></table>';
    
    }
    else{
    	$string .= '<form name="free_emailconnector_form_'.$uniqueid.'" action="#" method="post">';
    	$string .= '<div class="row"><div class="column_1">Select Service Board<span class="red">*</span></div><div class="column_2"><select name="service_board_emailid_'.$uniqueid.'" id="service_board_emailid_'.$uniqueid.'"><option value="all">Choose Service Board</option>';
    	foreach($array_emailids as $k => $v){
    		$exp2 = explode("-",$v);
    		if(isset($exp2) && is_array($exp2) && count($exp2) > 1){
    			$string .= '<option value="'.base64_encode(trim($exp2[1])).'">'.trim($exp2[0]).'</option>';
    			$admin_emails[] = base64_encode(trim($exp2[1]));
    		}
    		else{
    			$string .= '<option value="'.base64_encode(trim($exp2[0])).'">'.trim($exp2[0]).'</option>';
    			$admin_emails[] = base64_encode(trim($exp2[0]));
    		}
    	}
    	$string .= '</select><input type="hidden" name="free_emailconnector_emailid_'.$uniqueid.'" id="free_emailconnector_emailid_'.$uniqueid.'" value="'.implode(",",$admin_emails).','.'" />';
    	$string .= '</div>
    					</div>';
    	if($userid > 0){
    		$name = $user->user_firstname.' '.$user->user_lastname;
    		if($name == ' '){
    			$string .= '<div class="row"><input type="hidden" size="'.$textsize.'" name="username_'.$uniqueid.'" id="username_'.$uniqueid.'" value="'.$user->user_login.'" /><input type="hidden" size="'.$textsize.'" name="email_'.$uniqueid.'" id="email_'.$uniqueid.'" value="'.$user->user_email.'" /></div>';
    		}else{
    			$string .= '<div class="row"><input type="hidden" size="'.$textsize.'" name="username_'.$uniqueid.'" id="username_'.$uniqueid.'" value="'.$name.'" /><input type="hidden" size="'.$textsize.'" name="email_'.$uniqueid.'" id="email_'.$uniqueid.'" value="'.$user->user_email.'" /></div>';
    		}
    	}
    	else{
    		$string .= '<div class="row">
    						<div class="column_1">'.$fullnamelabel.'
    							<span class="red">*</span>
    						</div>
    						<div class="column_2">
    							<input type="text" size="'.$textsize.'" name="username_'.$uniqueid.'" id="username_'.$uniqueid.'" />
    						</div>
    					</div>';
    		$string .= '<div class="row">
    						<div class="column_1">'.$emaillabel.'
    							<span class="red">*</span>
    						</div>
    						<div class="column_2">
    							<input type="text" size="'.$textsize.'" name="email_'.$uniqueid.'" id="email_'.$uniqueid.'" />
    						</div>
    					</div>';
    	}
    	$string .= '<div class="row">
    					<div class="column_1">'.$subjectlabel.'
    						<span class="red">*</span>
    					</div>
    					<div class="column_2">
    						<input type="text" size="'.$textsize.'" name="subject_emailconnector_'.$uniqueid.'" id="subject_emailconnector_'.$uniqueid.'" />
    					</div>
    				</div>';
    	$string .= '<div class="row">
    					<div class="column_1">'.$descriptionlabel.'
    						<span class="red">*</span>
    					</div>
    					<div class="column_2">
    	<textarea id="message_emailconnector_'.$uniqueid.'" name="message_emailconnector_'.$uniqueid.'" cols="'.$colsfortextarea.'" '.$styletextarea.' rows="'.$rowsfortextarea.'"></textarea>
    					</div>
    				</div>';
    	$string .= '<div class="row">
    					<div class="column_1">
    						<input type="hidden" name="free_emailconnector_emailid_'.$uniqueid.'" id="free_emailconnector_emailid_'.$uniqueid.'" value="'.$emailids.'" />
    						<input type="hidden" name="successmessage_'.$uniqueid.'" id="successmessage_'.$uniqueid.'" value="'.$successmessage.'" />
    					</div>
    					<div class="column_2">';
    	if($showbuttonimage == '1' || $showbuttonimage == 1){
    		$string .= '<input type="button" name="free_emailconnector_button_'.$uniqueid.'" onclick="return callAjax('.$uniqueid.')" value="'.$buttontext.'" />';
    	}
    	else{
    		if($imagepath == ''){
    			$string .= '<input type="button" name="free_emailconnector_button_'.$uniqueid.'" onclick="return callAjax('.$uniqueid.')" value="'.$buttontext.'" />';
    		}
    		else{
    			$string .= '<img src="'.$imagepath.'" onclick="return callAjax('.$uniqueid.')" />';
    		}
    	}
    	$string .= '<div class="loadingimg_free_'.$uniqueid.'" style="display:none;"><img src="/wp-content/plugins/joomconnect-quick-ticket-lite/images/loading3.gif" /></div></div></div>';
    }
    $string .= '</form><div class="success_msg_'.$uniqueid.'"></div><div class="jcemailconnector_pos1">'.$posttext.'</div></div>';
    echo $string;
    ?>
  2. zhumar
    Member
    Posted 1 year ago #

    Anybody?

  3. zhumar
    Member
    Posted 1 year ago #

    I just went to my development site and my widget was showing multiple instances. Not sure why it's working now, but that's good. I guess I'm all set here. :)

Topic Closed

This topic has been closed to new replies.

About this Topic