/**
 * GMW Tools page function - Display tools page tabs
 * 
 * @since 2.5
 * @author Original function written by Pippin Williamson and modified for the needs of GEO my WP
 * 
 */
function gmw_tools_page_output()
{
    $active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'import_export';
    ?>
    	<div class="wrap">
    		
            <h2 class="gmw-wrap-top-h2">
                <i class="fa fa-wrench"></i>
                <?php 
    echo _e('GEO my WP Tools', 'GMW');
    ?>
                <?php 
    gmw_admin_support_button();
    ?>
            </h2>

            <div class="clear"></div>

    		<h2 class="nav-tab-wrapper" style=margin-bottom:20px;">
    			<?php 
    foreach (gmw_get_tools_tabs() as $tab_id => $tab_name) {
        $tab_url = admin_url('admin.php?page=gmw-tools&tab=' . $tab_id);
        $active = $active_tab == $tab_id ? ' nav-tab-active' : '';
        echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">' . esc_html($tab_name) . '</a>';
    }
    ?>
    		</h2>
    		<div class="gmw-tools metabox-holder">
    			<?php 
    do_action('gmw_tools_tab_' . $active_tab);
    ?>
    		</div><!-- .metabox-holder -->
    	</div><!-- .wrap -->
	<?php 
}
    /**
     * output list of forms
     *
     * @access public
     * @return void
     */
    public function output()
    {
        $this->addons = get_option('gmw_addons');
        $nextFormID = 1;
        if (!empty($this->forms)) {
            $nextFormID = max(array_keys($this->forms)) + 1;
        }
        //$gmw_forms = get_option( 'gmw_forms' );
        ?>
        <div class="wrap">

            <h2 class="gmw-wrap-top-h2">
                <i class="fa fa-map-marker"></i>
                <?php 
        echo _e('GEO my WP Forms', 'GMW');
        ?>
                <?php 
        echo self::new_form_list();
        ?>
                <?php 
        gmw_admin_support_button();
        ?>
            </h2>

            <div class="clear"></div>

            <table class="widefat" style="margin-top: 10px">
                <thead>
                    <tr>
                        <th scope="col" id="cb" class="manage-column column-cb check-column" style="width:50px;padding:11px 10px"><?php 
        _e('ID', 'GMW');
        ?>
</th>
                        <th scope="col" id="id" class="manage-column"><?php 
        _e('Type', 'GMW');
        ?>
</th>
                        <th scope="col" id="id" class="manage-column"><?php 
        _e('Name', 'GMW');
        ?>
</th>
                        <th scope="col" id="id" class="manage-column"><?php 
        _e('Action', 'GMW');
        ?>
</th>
                        <th scope="col" id="active" class="manage-column"><?php 
        _e('Usage', 'GMW');
        ?>
</th> 

                    </tr>
                </thead>
                <tbody class="list:user user-list">

                    <?php 
        if (!empty($this->forms)) {
            ?>

                        <?php 
            $rowNumber = 0;
            ?>

			            <?php 
            foreach ($this->forms as $key => $option) {
                ?>

			                <?php 
                if (!empty($option['addon']) && !empty($this->addons[$option['addon']]) && $this->addons[$option['addon']] == 'active') {
                    ?>
			
			                    <?php 
                    $alternate = $rowNumber % 2 == 0 ? 'alternate' : '';
                    ?>
								
								<?php 
                    $formName = !empty($option['name']) ? $option['name'] : 'form_id_' . $option['ID'];
                    ?>
								
                                <tr class="<?php 
                    echo $alternate;
                    ?>
" style="height:50px;">
                                    <td>
                                        <span><?php 
                    echo $option['ID'];
                    ?>
</span>
                                    </td>
                                    <td>
                                        <span><a title="<?php 
                    __('Edit this form', 'GMW');
                    ?>
" href="admin.php?page=gmw-forms&gmw_action=edit_form&gmw_form_title=<?php 
                    echo $option['form_title'];
                    ?>
&gmw_form_prefix=<?php 
                    echo $option['prefix'];
                    ?>
&form_type=<?php 
                    echo $option['form_type'];
                    ?>
&formID=<?php 
                    echo $option['ID'];
                    ?>
"><?php 
                    echo $option['form_title'];
                    ?>
</a></span>
                                    </td>
									<td>
                                        <span>
                                        	<a title="<?php 
                    echo $formName;
                    ?>
" href="admin.php?page=gmw-forms&gmw_action=edit_form&gmw_form_title=<?php 
                    echo $option['form_title'];
                    ?>
&gmw_form_prefix=<?php 
                    echo $option['prefix'];
                    ?>
&form_type=<?php 
                    echo $option['form_type'];
                    ?>
&formID=<?php 
                    echo $option['ID'];
                    ?>
&gmw_form_name=<?php 
                    echo $formName;
                    ?>
""><?php 
                    echo $formName;
                    ?>
</a></span>
                                    </td>
                                    <td>		
                                        <span class="edit">
                                            <a title="<?php 
                    __('Edit this form', 'GMW');
                    ?>
" href="admin.php?page=gmw-forms&gmw_action=edit_form&gmw_form_title=<?php 
                    echo $option['form_title'];
                    ?>
&gmw_form_prefix=<?php 
                    echo $option['prefix'];
                    ?>
&form_type=<?php 
                    echo $option['form_type'];
                    ?>
&formID=<?php 
                    echo $option['ID'];
                    ?>
"><?php 
                    _e('Edit', 'GMW');
                    ?>
</a> | 
                                        </span>
                                        <span class="edit">
                                            <a title="<?php 
                    __('Duplicate this form', 'GMW');
                    ?>
" href="admin.php?page=gmw-forms&gmw_action=duplicate_form&form_type=<?php 
                    echo $option['form_type'];
                    ?>
&formID=<?php 
                    echo $option['ID'];
                    ?>
&gmw_form_id=<?php 
                    echo $nextFormID;
                    ?>
"><?php 
                    _e('Duplicate', 'GMW');
                    ?>
</a> | 
                                        </span>
                                        <span class="edit">
                                            <a title="<?php 
                    __('Delete this form', 'GMW');
                    ?>
" href="admin.php?page=gmw-forms&gmw_action=delete_form&formID=<?php 
                    echo $option['ID'];
                    ?>
" onclick="return confirm( 'sure?' ); "><?php 
                    _e('Delete', 'GMW');
                    ?>
</a>                                                    
                                        </span>	
                                    </td>
                                    <td class="column-title" style="padding: 5px 0px;">
                                        <code>[gmw form="<?php 
                    echo $option['ID'];
                    ?>
"]</code>
                                    </td>
                                </tr>
	
                            <?php 
                }
                ?>
			
			                <?php 
                $rowNumber++;
                ?>
			
			            <?php 
            }
            ?>
				
			        <?php 
        } else {
            ?>

                        <tr class="<?php 
            echo $alternate;
            ?>
" style="height:50px;">
                            <td>
                                <span></span>
                            </td>
                            <td>
                                <span><?php 
            _e("You don't have any forms yet.", "GMW");
            ?>
</span>
                            </td>
                            <td class="column-title" style="padding: 5px 0px;">

                            </td>
                            <td>		

                            </td>			          
                        </tr>

			        <?php 
        }
        ?>
		                
	                </tbody>
	                <tfoot>
	                    <tr>
	                        <th scope="col" id="cb" class="manage-column  column-cb check-column" style="width:50px;padding:11px 10px"><?php 
        _e('ID', 'GMW');
        ?>
</th>
	                        <th scope="col" id="id" class="manage-column"><?php 
        _e('Type', 'GMW');
        ?>
</th>
	                        <th scope="col" id="id" class="manage-column"><?php 
        _e('Name', 'GMW');
        ?>
</th>
	                        <th scope="col" id="active" class="manage-column"><?php 
        _e('Usage', 'GMW');
        ?>
</th> 
	                        <th scope="col" id="id" class="manage-column"><?php 
        _e('Action', 'GMW');
        ?>
</th>
	                    </tr>
	                </tfoot>        
	            </table>	
	        </div>
	        
        <?php 
    }
    /**
     * output edit form page.
     *
     * @access public
     * @return void
     */
    public function output()
    {
        $this->form_settings = $this->init_form_settings();
        $gmw_forms = get_option('gmw_forms');
        $formID = $_GET['formID'];
        $gmw_form = $gmw_forms[$formID];
        $form_type = $_GET['form_type'];
        ?>
        <div class="wrap">
        
            <h2 class="gmw-wrap-top-h2">
            	<i class="fa fa-pencil"></i>
                <?php 
        echo _e('GEO my WP Edit Form Page', 'GMW');
        ?>
                <?php 
        gmw_admin_support_button();
        ?>
            </h2>

            <div class="clear"></div>
            
            <?php 
        if (!empty($_GET['settings-updated'])) {
            echo '<div class="updated" style="clear:both"><p>' . __('Form successfully updated', 'GMW') . '</p></div>';
        }
        ?>
            
            <form method="post" action="options.php">

	            <?php 
        echo '<input type="hidden" name="gmw_forms[' . $formID . '][ID]" 			value="' . $gmw_form['ID'] . '" 		  />';
        ?>
	            <?php 
        echo '<input type="hidden" name="gmw_forms[' . $formID . '][addon]" 		value="' . $gmw_form['addon'] . '" 	  />';
        ?>
	            <?php 
        echo '<input type="hidden" name="gmw_forms[' . $formID . '][form_title]" 	value="' . $gmw_form['form_title'] . '" />';
        ?>
	            <?php 
        echo '<input type="hidden" name="gmw_forms[' . $formID . '][form_type]" 	value="' . $gmw_form['form_type'] . '"  />';
        ?>
	            <?php 
        echo '<input type="hidden" name="gmw_forms[' . $formID . '][prefix]" 		value="' . $gmw_form['prefix'] . '" 	  />';
        ?>
	            <?php 
        echo '<input type="hidden" name="gmw_forms[' . $formID . '][ajaxurl]" 	value="' . GMW_AJAX . '" 				  />';
        ?>
				
	            <?php 
        settings_fields($this->forms_group);
        ?>
				
                <div class="gmw-form-details-panel" style="display:block !important">

                    <table class="widefat">
                    	<thead>
                        	<tr>
                            	<th scope="col" id="cb" class="manage-column column-cb check-column" style="width:18% !important;padding:11px 10px"><?php 
        _e('Form Details', 'GMW');
        ?>
</th>
                            	<th></th>
                            </tr>
                       	</thead>
						<tbody>
							<tr valign="top">
	                        	<td class="gmw-form-feature-desc">
	                        		<label><?php 
        _e('Form ID', 'GMW');
        ?>
</label>	              	                         		
                            	</td>
	                        	<td class="gmw-form-feature-settings">
	                        		<?php 
        echo $formID;
        ?>
	                        	</td>
	                        </tr>
	                        <tr valign="top">
	                        	<td class="gmw-form-feature-desc">
	                        		<label><?php 
        _e('Form Type', 'GMW');
        ?>
</label>	              	                         		
                            	</td>
	                        	<td class="gmw-form-feature-settings">
	                        		<?php 
        echo $gmw_forms[$formID]['form_title'];
        ?>
	                        	</td>
	                        </tr>
	                        <tr valign="top">
	                        	<td class="gmw-form-feature-desc">
	                        		<label><?php 
        _e('Form Name', 'GMW');
        ?>
</label>	              	                         		
                            	</td>
	                        	<td class="gmw-form-feature-settings">
	                        		<input type="text" name="gmw_forms[<?php 
        echo $formID;
        ?>
][name]" value="<?php 
        echo isset($gmw_forms[$formID]['name']) && !empty($gmw_forms[$formID]['name']) ? $gmw_forms[$formID]['name'] : 'form_id_' . $gmw_forms[$formID]['ID'];
        ?>
" />                                                        	
	                        		<span style="margin-left: 5px">
	                        			<input type="submit" class="button-primary" value="<?php 
        _e('Save Changes', 'GMW');
        ?>
" />
	                        		</span>
	                        	</td>
	                        </tr>
	                        <tr valign="top">
	                        	<td class="gmw-form-feature-desc">
	                        		<label><?php 
        _e('Actions', 'GMW');
        ?>
</label>	              	                         		
                            	</td>
	                        	<td class="gmw-form-feature-settings">
	                            	<span style="margin-left: 5px">
	                            		<a class="button action" title="<?php 
        __('Delete this form', 'GMW');
        ?>
" href="admin.php?page=gmw-forms&gmw_action=delete_form&formID=<?php 
        echo $formID;
        ?>
" onclick="return confirm('sure?');"><?php 
        _e('Delete This Form', 'GMW');
        ?>
</a>                                                               
	                            	</span>
	                            	<span style="margin-left: 5px">
	                            		<a class="button action" title="<?php 
        __('Go back to list of forms', 'GMW');
        ?>
" href="<?php 
        echo admin_url('admin.php?page=gmw-forms');
        ?>
" ><?php 
        _e('Go Back To List of Forms', 'GMW');
        ?>
</a>                                                               
	                            	</span>
	                            	<span>
	                            		<?php 
        echo GMW_Forms::new_form_list();
        ?>
	                            	</span>
	                        	</td>
	                        </tr>
						</tbody>
					</table>

				</div>
               
				                
				<h2 style="margin:20px 0px 10px"><?php 
        _e('Form Editor', 'GMW');
        ?>
</h2>

				<!-- Form tabs -->
                <div class="gmw-tabs-table gmw-edit-form-page-nav-tabs gmw-nav-tab-wrapper">
                	<?php 
        foreach ($this->form_settings as $key => $section) {
            if (empty($section[1])) {
                continue;
            }
            if ($key != 'hidden') {
                echo '<a  href="#settings-' . sanitize_title($key) . '" id="' . sanitize_title($key) . '" class="gmw-nav-tab gmw-nav-trigger">' . esc_html($section[0]) . '</a>';
            }
        }
        echo '<a href="#settings-form-usage" id="form-usage" class="gmw-nav-tab gmw-nav-trigger" style="float:right;margin-bottom: -2px">' . __('Form Usage', 'GMW') . '</a>';
        ?>
   	   
                </div>
               
                <?php 
        foreach ($this->form_settings as $key => $section) {
            if (empty($section[1])) {
                continue;
            }
            ?>

                    <div id="settings-<?php 
            echo sanitize_title($key);
            ?>
" class="gmw-settings-panel">
	                    <table class="widefat">
	                    	<thead>
	                        	<tr>
	                            	<th scope="col" id="cb" class="manage-column column-cb check-column" style="width:18% !important;padding:11px 10px"><?php 
            _e('Feature', 'GMW');
            ?>
</th>
	                            	<th scope="col" id="cb" class="manage-column column-cb check-column" style="width:57%;padding:11px 10px">
	                            		<?php 
            _e('Settings', 'GMW');
            ?>
	                            		<input type="submit" class="button-primary" style="float:right" value="<?php 
            _e('Save Changes', 'GMW');
            ?>
" />
	                            	</th>
	                            </tr>
	                       	</thead>
							<tbody>
							
							<?php 
            do_action('form_editor_tab_start', $key, $section, $formID, $gmw_forms[$formID]);
            $rowNumber = 0;
            foreach ($section[1] as $sec => $option) {
                if ($option['name'] == 'tab_top_message' || $option['name'] == 'tab_bottom_message') {
                    echo '<div style="background: white;border:1px solid #ddd;padding:5px;">';
                    echo '<' . $option['tag'] . ' style="' . implode(';', $option['attributes']) . '">' . $option['message'] . '</' . $option['tag'] . '>';
                    echo '</div>';
                    continue;
                }
                $placeholder = !empty($option['placeholder']) ? 'placeholder="' . $option['placeholder'] . '"' : '';
                $class = !empty($option['class']) ? $option['class'] : '';
                $value = isset($gmw_forms[$formID][$key][$option['name']]) && !empty($gmw_forms[$formID][$key][$option['name']]) ? $gmw_forms[$formID][$key][$option['name']] : $option['std'];
                $option['type'] = !empty($option['type']) ? $option['type'] : '';
                $attributes = array();
                $checkboxDefault = isset($option['std']) && !empty($option['std']) ? $option['std'] : 1;
                if (!empty($option['attributes']) && is_array($option['attributes'])) {
                    foreach ($option['attributes'] as $attribute_name => $attribute_value) {
                        $attributes[] = esc_attr($attribute_name) . '="' . esc_attr($attribute_value) . '"';
                    }
                }
                //$alternate = ( $rowNumber % 2 == 0 ) ? 'alternate' : '';
                $alternate = '';
                echo '<tr valign="top" id="sort-search-form-' . $option['name'] . '-tr" class="gmw-item-sort ' . $class . ' ' . $alternate . '" >';
                echo '<td class="gmw-form-feature-desc">';
                echo '<label for="setting-' . $option['name'] . '" >' . $option['label'] . '</label>';
                if (!empty($option['desc'])) {
                    echo ' <p class="description">' . $option['desc'] . '</p>';
                }
                echo '</td>';
                echo '<td class="gmw-form-feature-settings ' . $option['type'] . '">';
                switch ($option['type']) {
                    case "function":
                        $function = isset($option['function']) && !empty($option['function']) ? $option['function'] : $option['name'];
                        do_action('gmw_' . $_GET['form_type'] . '_form_settings_' . $function, $gmw_forms, $formID, $key, $option);
                        do_action('gmw_form_settings_' . $function, $gmw_forms, $formID, $key, $option);
                        break;
                    case "multicheckbox":
                        foreach ($option['options'] as $keyVal => $name) {
                            ?>
<p><label><input id="setting-<?php 
                            echo $key . '-' . $option['name'] . '-' . $keyVal;
                            ?>
" class="setting-<?php 
                            echo $option['name'];
                            ?>
" name="<?php 
                            echo 'gmw_forms[' . $formID . '][' . $key . '][' . $option['name'] . '][' . $keyVal . ']';
                            ?>
" type="checkbox" value="<?php 
                            echo $checkboxDefault;
                            ?>
" <?php 
                            if (isset($gmw_forms[$formID][$key][$option['name']][$keyVal]) && $gmw_forms[$formID][$key][$option['name']][$keyVal] == $checkboxDefault) {
                                echo 'checked="checked"';
                            }
                            ?>
 /> <?php 
                            echo $name;
                            ?>
</label></p> <?php 
                        }
                        break;
                    case "multicheckboxvalues":
                        foreach ($option['options'] as $keyVal => $name) {
                            ?>
<p><label><input id="setting-<?php 
                            echo $key . '-' . $option['name'] . '-' . $keyVal;
                            ?>
" class="setting-<?php 
                            echo $option['name'];
                            ?>
 setting-<?php 
                            echo $key . '-' . $option['name'];
                            ?>
" name="<?php 
                            echo 'gmw_forms[' . $formID . '][' . $key . '][' . $option['name'] . '][]';
                            ?>
" type="checkbox" value="<?php 
                            echo $keyVal;
                            ?>
" <?php 
                            if (!empty($gmw_forms[$formID][$key][$option['name']]) && in_array($keyVal, $gmw_forms[$formID][$key][$option['name']])) {
                                echo 'checked="checked"';
                            }
                            ?>
 /> <?php 
                            echo $name;
                            ?>
</label></p> <?php 
                        }
                        break;
                    case "checkbox":
                        ?>
<p><label><input id="setting-<?php 
                        echo $key . '-' . $option['name'];
                        ?>
" class="setting-<?php 
                        echo $option['name'];
                        ?>
" name="<?php 
                        echo 'gmw_forms[' . $formID . '][' . $key . '][' . $option['name'] . ']';
                        ?>
" type="checkbox" value="<?php 
                        echo $checkboxDefault;
                        ?>
" <?php 
                        echo implode(' ', $attributes);
                        ?>
 <?php 
                        checked($checkboxDefault, $value);
                        ?>
 /> <?php 
                        echo $option['cb_label'];
                        ?>
</label></p><?php 
                        break;
                    case "textarea":
                        ?>
<textarea id="setting-<?php 
                        echo $key . '-' . $option['name'];
                        ?>
" class="large-text" cols="50" rows="3" name="<?php 
                        echo 'gmw_forms[' . $formID . '][' . $key . '][' . $option['name'] . ']';
                        ?>
" <?php 
                        echo implode(' ', $attributes);
                        ?>
 <?php 
                        echo $placeholder;
                        ?>
><?php 
                        echo esc_textarea($value);
                        ?>
</textarea><?php 
                        break;
                    case "radio":
                        $rc = 1;
                        foreach ($option['options'] as $keyVal => $name) {
                            $checked = $rc == 1 ? 'checked="checked"' : checked($value, $keyVal, false);
                            echo '<span id="setting-' . $key . '-' . $option['name'] . '-' . $keyVal . '-wrapper"><input type="radio" id="setting-' . $key . '-' . $option['name'] . '-' . $keyVal . '" class="setting-' . $option['name'] . '" name="gmw_forms[' . $formID . '][' . $key . '][' . $option['name'] . ']" value="' . esc_attr($keyVal) . '" ' . $checked . ' />' . $name . ' </span>';
                            $rc++;
                        }
                        break;
                    case "select":
                        ?>
<select id="setting-<?php 
                        echo $key . '-' . $option['name'];
                        ?>
" class="regular-text" name="<?php 
                        echo 'gmw_forms[' . $formID . '][' . $key . '][' . $option['name'] . ']';
                        ?>
" <?php 
                        echo implode(' ', $attributes);
                        ?>
><?php 
                        foreach ($option['options'] as $keyVal => $name) {
                            echo '<option value="' . esc_attr($keyVal) . '" ' . selected($value, $keyVal, false) . '>' . esc_html($name) . '</option>';
                        }
                        ?>
</select><?php 
                        break;
                    case "multiselect":
                        ?>
<select multiselect id="setting-<?php 
                        echo $key . '-' . $option['name'];
                        ?>
" class="regular-text" name="<?php 
                        echo 'gmw_forms[' . $formID . '][' . $key . '][' . $option['name'] . '][]';
                        ?>
" <?php 
                        echo implode(' ', $attributes);
                        ?>
><?php 
                        foreach ($option['options'] as $keyVal => $name) {
                            $selected = in_array($keyVal, $value) ? 'selected="selected"' : '';
                            echo '<option value="' . esc_attr($keyVal) . '" ' . $selected . '>' . esc_html($name) . '</option>';
                        }
                        ?>
</select><?php 
                        break;
                    case "password":
                        ?>
<input id="setting-<?php 
                        echo $key . '-' . $option['name'];
                        ?>
" class="regular-text" type="password" name="<?php 
                        echo 'gmw_forms[' . $formID . '][' . $key . '][' . $option['name'] . ']';
                        ?>
" value="<?php 
                        esc_attr_e($value);
                        ?>
" <?php 
                        echo implode(' ', $attributes);
                        ?>
 <?php 
                        echo $placeholder;
                        ?>
 /><?php 
                        break;
                    case "hidden":
                        ?>
<input id="setting-<?php 
                        echo $key . '-' . $option['name'];
                        ?>
" class="gmw-form-hidden-field" id="setting-<?php 
                        echo $option['name'];
                        ?>
" class="regular-text" type="hidden" name="<?php 
                        echo 'gmw_forms[' . $formID . '][' . $key . '][' . $option['name'] . ']';
                        ?>
" value="<?php 
                        echo $value;
                        ?>
" /><?php 
                        break;
                    default:
                        ?>
<input id="setting-<?php 
                        echo $key . '-' . $option['name'];
                        ?>
" class="regular-text" type="text" name="<?php 
                        echo 'gmw_forms[' . $formID . '][' . $key . '][' . $option['name'] . ']';
                        ?>
" value="<?php 
                        esc_attr_e($value);
                        ?>
" <?php 
                        echo implode(' ', $attributes);
                        ?>
 <?php 
                        echo $placeholder;
                        ?>
 /><?php 
                        break;
                }
                echo '</td>';
                echo '</tr>';
                $rowNumber++;
            }
            do_action('form_editor_tab_end', $key, $section, $formID, $gmw_forms[$formID]);
            ?>
							</tbody>
                        	<tfoot>
                        		<tr style="height:40px;">
                            		<th scope="col" id="cb" class="manage-column  column-cb check-column" style="width:50px;padding:11px 10px">
                                		<input type="submit" class="button-primary" value="<?php 
            _e('Save Changes', 'GMW');
            ?>
" />
                            		</th>
                              		<th scope="col" id="id" class="manage-column"></th>	
                            	</tr>
                        	</tfoot>
                    	</table>
                    </div>
                <?php 
        }
        ?>

                <!-- form usage -->
            	<div id="settings-form-usage" class="gmw-settings-panel">
	                <table class="widefat">
	                	<thead>
	                    	<tr>
	                        	<th scope="col" id="cb" class="manage-column column-cb check-column" style="width:20% !important;padding:11px 10px"><?php 
        _e('Post/Page Content', 'GMW');
        ?>
</th>
	                        	<th scope="col" id="cb" class="manage-column column-cb check-column" style="width:40% !important;padding:11px 10px"><?php 
        _e('Tempalte file', 'GMW');
        ?>
</th>
	                        	<th scope="col" id="cb" class="manage-column column-cb check-column" style="width:40%;padding:11px 10px"><?php 
        _e('Description', 'GMW');
        ?>
</th>
	                    	</tr>
	                	</thead>
	             
	                	<tbody>
	                		<?php 
        if ($gmw_form['addon'] == 'global_maps') {
            ?>
	                			<tr>
		                			<td>
		                				<code>[gmw form="<?php 
            echo $formID;
            ?>
"]</code>
		                			</td>
		                			<td>
		                				<code><?php 
            echo '&#60;&#63;php echo do_shortcode(\'[gmw form="' . $formID . '"]\'); &#63;&#62;';
            ?>
</code>
		                			</td>
		                			<td>
		                				<?php 
            _e('Use this shortcode to display the global map anywhere on the page.', 'GMW');
            ?>
		                			</td>
		                		</tr>
	             			<?php 
        } else {
            ?>

	                		<tr>
	                			<td>
	                				<code>[gmw form="<?php 
            echo $formID;
            ?>
"]</code>
	                			</td>
	                			<td>
	                				<code><?php 
            echo '&#60;&#63;php echo do_shortcode(\'[gmw form="' . $formID . '"]\'); &#63;&#62;';
            ?>
</code>
	                			</td>
	                			<td>
	                				<?php 
            _e('Use this shortcode to display the search form and search results of this form.', 'GMW');
            ?>
	                			</td>
	                		</tr>
	                		<tr>
	                			<td>
	                				<code>[gmw search_form="<?php 
            echo $formID;
            ?>
"]</code>
	                			</td>
	                			<td>
	                				<code><?php 
            echo '&#60;&#63;php echo do_shortcode(\'[gmw search_form="' . $formID . '"]\'); &#63;&#62;';
            ?>
</code>
	                			</td>
	                			<td>
	                				<?php 
            _e('Use this shortcode to display only the search form of this form.', 'GMW');
            ?>
	                			</td>
	                		</tr>
	                		<tr>
	                			<td>
	                				<code>[gmw search_results="<?php 
            echo $formID;
            ?>
"]</code>
	                			</td>
	                			<td>
	                				<code><?php 
            echo '&#60;&#63;php echo do_shortcode(\'[gmw search_results="' . $formID . '"]\'); &#63;&#62;';
            ?>
</code>
	                			</td>
	                			<td>
	                				<?php 
            _e('Use this shortcode to display only the search results of this form.', 'GMW');
            ?>
	                			</td>
	                		</tr>
	                		<tr>
	                			<td>
	                				<code>[gmw map="<?php 
            echo $formID;
            ?>
"]</code>
	                			</td>
	                			<td>
	                				<code><?php 
            echo '&#60;&#63;php echo do_shortcode(\'[gmw map="' . $formID . '"]\'); &#63;&#62;';
            ?>
</code>
	                			</td>
	                			<td>
	                				<?php 
            _e('Use this shortcode to display the results map anywhere on a page. By default, the form you create will display the map above the list of results. Using this shortcode you can display the map anywhere else on the page. Note that this shortcode must go together with one of the results shortocdes mentioned above. You also need to set the "Display Map" feature ( "Search Results" tab ) to "using shortcode".', 'GMW');
            ?>
	                			</td>
	                		</tr>
	                		<tr>
	                			<td>
	                				<code>[gmw form="results"]</code>
	                			</td>
	                			<td>
	                				<code><?php 
            echo '&#60;&#63;php echo do_shortcode(\'[gmw form="results"]\'); &#63;&#62;';
            ?>
</code>
	                			</td>
	                			<td>
	                				<?php 
            _e('Use this shortcode in the page where you would like to display the search results. That is in case that you choose to display the search results in a different page than the search form or when using "GMW Form" widget.', 'GMW');
            ?>
	                			</td>
	                		</tr>
	                		<?php 
        }
        ?>
	                	</tbody>
	              	</table>
	        	</div>
				<br />
            </form>
            
            <?php 
        $current_tab = isset($_COOKIE['gmw_admin_tab']) ? $_COOKIE['gmw_admin_tab'] : false;
        ?>
            
            <script type="text/javascript">
			jQuery(document).ready(function($) {
		        //jQuery(document).ready(function($) {
			        
		        //	$("#settings-search_form table tbody").sortable({
				//		items:'.gmw-item-sort',
		        //        opacity: 0.5,
		       //         cursor: 'pointer',
		       //         axis: 'y',
		       //         update: function() {
		      //              jQuery.post(
		    	//                    ajaxurl, 
		    	//                    { 
			    //	                  action: 'list_update_order', 
			   // 	                  order: jQuery(this).sortable('serialize') 
			   // 	                }, 
		    	//                    function(response){
		       //                 		console.log(response);
		       //             		}
			 	//            );
		       //         }
		      //    });
		      //  });
	        
	        	if ( jQuery('#setting-page_load_results-display_posts').is(':checked') ) {
					jQuery("#setting-page_load_results-display_map-results-wrapper").show();
				} else {
					jQuery("#setting-page_load_results-display_map-results-wrapper").hide();
					if ( jQuery("#setting-page_load_results-display_map-results").is(":checked") ) {
						jQuery("#setting-page_load_results-display_map-shortcode").attr("checked","checked");
					}
				}
				
	        	jQuery('#setting-page_load_results-display_posts').change(function() {
					if ( jQuery(this).is(':checked') ) {
						jQuery("#setting-page_load_results-display_map-results-wrapper").show();
					} else {
						jQuery("#setting-page_load_results-display_map-results-wrapper").hide();
						if ( jQuery("#setting-page_load_results-display_map-results").is(":checked") ) {
							jQuery("#setting-page_load_results-display_map-shortcode").attr("checked","checked");
						}
					}
	        	});
	        	
	            jQuery('.gmw-form-hidden-field').each(function() {
	                jQuery(this).closest('tr').hide();
	            });
	
				if ( '<?php 
        echo $current_tab;
        ?>
' != false ) { 
	         		jQuery('#<?php 
        echo $current_tab;
        ?>
').click();
	         	}
	         	
	            jQuery('#form-usage-trigger').click(function() {
					jQuery('#usage-table-wrapper').slideToggle();
					
	            });
	
	            if ( jQuery( '#settings-search_form #setting-form_template' ).val() == 'no_form' ) {
	            	jQuery("#settings-search_form :input").attr("disabled", true);
	            	jQuery("#settings-search_form #setting-form_template").attr("disabled", false);
	            	jQuery("#settings-search_form .manage-column .button-primary").attr("disabled", false);              	
	            } 
	            
	            jQuery('#settings-search_form #setting-form_template').change(function() {
	                if ( jQuery(this).val() == 'no_form' ) {
	                	jQuery("#settings-search_form :input").attr("disabled", true);
	                	jQuery("#settings-search_form #setting-form_template").attr("disabled", false);
	                	jQuery("#settings-search_form .manage-column .button-primary").attr("disabled", false);              	
	                } else {
	                	jQuery("#settings-search_form :input").attr("disabled", false);
	                }
	            });
			});
        </script>
        </div>            
        <?php 
    }
Beispiel #4
0
        /**
         * output function.
         *
         * @access public
         * @return void
         */
        public function output()
        {
            $updater = get_option('gmw_updater_disabled');
            //get installed plugins
            $plugins = get_plugins();
            //get remote addons data from geomywp.com
            $remote_addons = self::get_feed_addons();
            $addons_data = $this->addons_data;
            //verify feed. if feed ok merge it with the addons array
            if (!empty($remote_addons)) {
                //merge remote add-ons with local addons data
                $addons_data = array_replace_recursive($addons_data, $remote_addons);
            }
            //sort add-ons by add-on name
            $inst = $title = array();
            foreach ($addons_data as $key => $row) {
                $title[$key] = $row['title'];
            }
            array_multisort($title, SORT_ASC, $addons_data);
            //move the core add-ons to the beggining of the list
            $addons_data = array('posts' => $addons_data['posts'], 'friends' => $addons_data['friends'], 'single_location' => $addons_data['single_location'], 'current_location' => $addons_data['current_location'], 'sweetdate_geolocation' => $addons_data['sweetdate_geolocation']) + $addons_data;
            ?>
        <!-- Addons page wrapper -->
        <div class="wrap">
            
            <!-- Title -->
            <h2 class="gmw-wrap-top-h2">
                <i class="fa fa-puzzle-piece"></i>
                <?php 
            _e('GEO my WP Add-ons', 'GMW');
            ?>
                <?php 
            gmw_admin_support_button();
            ?>
            </h2>

            <div class="clear"></div>

            <!-- add-ons page information -->
            <div class="gmw-addons-page-top-area">
            	<div></span><h3 style="display:inline-block;margin:2px 0px"><?php 
            _e("Add-ons usage", "GMW");
            ?>
</h3> - <a href="#" id="addons-info-toggle" onclick="jQuery('#addons-info-wrapper').slideToggle();"><?php 
            _e("Show info", "GMW");
            ?>
</a></div>
            	<ol id="addons-info-wrapper" style="display:none">
            		<li><?php 
            _e("<strong>Add-ons installation</strong> - GEO my WP add-ons ( Except the free add-ons \"Posts Locator\" and \"Members Locator\" ) are WordPress plug-ins and need to be installed just as any other WordPress plug-ins via the plug-ins page of your site's dashboard. See <a href=\"http://codex.wordpress.org/Managing_Plugins\" target=\"_blank\">this post</a> for information about plug-ins installation.", "GMW");
            ?>
</li>
            		<li><?php 
            _e("<strong>Add-ons activation</strong> - after installation please activate your add-ons. Activation can be done via the WordPress's Plug-ins page or from this Add-ons page of GEO my WP.", "GMW");
            ?>
</li>
            		<li><?php 
            _e("<strong>License activation</strong> - If any of your add-ons require a license key please enter it in the license key input box and click \"Activate\".", "GMW");
            ?>
            		    <?php 
            _e(" The license key provided to you after a purchase of an add-on via the purchase receipt which should be sent to your email address. You can also retrieve and manage any of your license keys via your <a href=\"http://geomywp.com/purchase-history\" target=\"_blank\">Purchase History page</a>.", "GMW");
            ?>
            		    <?php 
            _e(" Note that the license key must be valid and activated in order to receive automatic updates and support for its add-on.", "GMW");
            ?>
</li>
            		<li><?php 
            _e("<strong>License deactivation</strong> - To deactivate a license simply click on \"Deactivate License\".", "GMW");
            ?>
</li>
            		<li><?php 
            _e("<strong>Add-ons deactivation</strong> - deactivation can be done from this Add-ons page of GEO my WP or via the plugins.", "GMW");
            ?>
            			<?php 
            _e(" Please note, the license of an add-on must be deactivated before you could deactivate its add-on. This is done to prevent conflicts with any license keys you might have.", "GMW");
            ?>
</li>         	
            	</ol>     
            </div>
            
            <!-- updater form -->
            <form method="post" action="" style="text-align:center">
            	
            	<div class="gmw-addons-page-top-area <?php 
            echo !empty($updater) ? 'updater-disabled' : 'updater-enabled';
            ?>
">
            	
	            	<p class="description" style="margin-bottom: 10px;border-bottom: 1px solid #e5e5e5;padding-bottom: 10px;">
	            		<?php 
            _e('Disable/enable the premium add-ons auto-updating system. The system can cause a slow load of the plugins.php/update.php pages of your site when checking for new version of the premium add-ons.', 'GMW');
            ?>
	            		<?php 
            _e('You can temporary disable the system when working in the admin area and enable it again when you are ready to check for add-ons update. This can be useful when working on a development site and there is no need to check for updates.', 'GMW');
            ?>
	            	</p>
            			
	            	<?php 
            if (!empty($updater)) {
                ?>
            			<div>
            				<p class="description" style="color:red"><?php 
                _e('The add-ons updater is disabled and will not check for new updates.', 'GMW');
                ?>
</p>    
            				<input type="submit" name="gmw_enable_updater" class="button-primary" value="<?php 
                _e('Enable Updater', 'GMW');
                ?>
" />
            				<input type="hidden" name="gmw_updater_action" value="enabled" />          				       				
            			</div>
	            	<?php 
            } else {
                ?>
            			<div>
            				<p class="description" style="color:green"><?php 
                _e('The add-ons updater is enabled and will check for updates when needed. You will be notified when new updates are avalible.', 'GMW');
                ?>
</p>              				
            				<input type="submit" name="gmw_disable_updater" class="button-secondary" value="<?php 
                _e('Disable Updater', 'GMW');
                ?>
" />
            				<input type="hidden" name="gmw_updater_action" value="disabled" />         				       				
            			</div>
	            	<?php 
            }
            ?>
	            	
				</div>
				<input type="hidden" name="gmw_action" value="updater_action" />
            	<?php 
            wp_nonce_field('gmw_addon_updater_nonce', 'gmw_addon_updater_nonce');
            ?>
            	
            </form>
                    
                <ul class="widefat fixed">
          	
                    <?php 
            $addOnsArray = array();
            ?>

                    <?php 
            foreach ($addons_data as $addon) {
                ?>
                
                        <?php 
                //Reset some variables
                $addon['update_avaliable'] = '0';
                //check for some data in permium add-ons
                if (empty($addon['core'])) {
                    //Reset some variables
                    $addon['installed'] = false;
                    $addon['activated'] = false;
                    $addon['license'] = true;
                    $addon['version'] = !empty($addon['current_version']) ? $addon['current_version'] : '1.0';
                    //create basename if not exist
                    if (empty($addon['basename'])) {
                        $addon['basename'] = plugin_basename($addon['file']);
                    }
                    //create file if doesnt exist
                    if (empty($addon['file'])) {
                        $addon['file'] = ABSPATH . 'wp-content/plugins/' . $addon['basename'];
                    }
                    //if add-on installed
                    if (isset($plugins[$addon['basename']])) {
                        $addon['installed'] = true;
                        $addon['version'] = $plugins[$addon['basename']]['Version'];
                        //if add-on activated
                        if (is_plugin_active($addon['basename'])) {
                            $addon['activated'] = true;
                            //check if update avaliable and required
                            if (!empty($addon['required_version']) && version_compare($addon['version'], $addon['required_version'], '<')) {
                                $addon['update_avaliable'] = '1';
                                //check if update available but not required
                            } elseif (!empty($addon['current_version']) && version_compare($addon['version'], $addon['current_version'], '<')) {
                                $addon['update_avaliable'] = '2';
                            }
                        }
                    }
                }
                ?>

                        <!-- addon wrapper -->
                        <li class="gmw-single-addon-wrapper <?php 
                echo $addon['name'];
                ?>
 first">	
                            
                            <!-- ribbons -->

                            <!-- free add-on -->
                            <?php 
                if (!empty($addon['core']) && empty($addon['activated'])) {
                    ?>
    
                                <div class="gmw-ribbon-wrapper"><div class="gmw-ribbon free"><?php 
                    _e('Free Add-on', 'GMW');
                    ?>
</div></div>
                            <?php 
                }
                ?>

                            <!-- New add-on -->
                            <?php 
                if (empty($addon['installed']) && !empty($addon['new_addon'])) {
                    ?>
                        
                                <div class="gmw-ribbon-wrapper"><div class="gmw-ribbon blue"><?php 
                    _e('New Add-on', 'GMW');
                    ?>
</div></div>   
                            <?php 
                }
                ?>

                            <!-- GMW version is too low -->
                            <?php 
                if (!empty($addon['gmw_required'])) {
                    ?>
                                <div class="gmw-ribbon-wrapper"><div class="gmw-ribbon red"><?php 
                    _e('Incompatible', 'GMW');
                    ?>
</div></div>   
                            <!-- Add-on new version is available and requires update  -->
                            <?php 
                } elseif ($addon['update_avaliable'] == 1) {
                    ?>
                        
                                <div class="gmw-ribbon-wrapper"><div class="gmw-ribbon red"><?php 
                    _e('Update Required', 'GMW');
                    ?>
</div></div>   
                            <!-- Add-on new version is available but not required  -->
                            <?php 
                } elseif ($addon['update_avaliable'] == 2) {
                    ?>
                                <div class="gmw-ribbon-wrapper"><div class="gmw-ribbon green"><?php 
                    _e('Update Available', 'GMW');
                    ?>
</div></div>  
                            <?php 
                }
                ?>

                            <!-- addon title -->
                            <div class="gmw-addon-top-wrapper">
                                <h2 class="gmw-addon-title">
                                    <?php 
                echo esc_attr($addon['title']);
                ?>
                               
                                    <span style="float:right;">
                                        <?php 
                if (isset($addon['version'])) {
                    echo esc_attr($addon['version']);
                }
                ?>
                                    </span>
                                </h2>
                            </div>

                            <div class="gmw-addon-content-wrapper">

                                <!-- Image -->
                                <div class="gmw-addon-image-wrapper">
                                    <?php 
                //get image from add-on
                //if ( isset( $addon['image'] ) && $addon['image'] != false ) {
                //echo '<img src="' . $addon['image'] . '" />';
                //get no-image image
                //} else
                //if ( empty( $addon['image'] ) ) {
                //    echo '<img src="https://geomywp.com/wp-content/uploads/2014/01/no-featured-image.png" />';
                //get image from GEO my WP server
                // } else {
                echo '<img src="https://geomywp.com/wp-content/uploads/addons-images/' . esc_attr($addon['name']) . '.png" />';
                //}
                ?>
                                </div>

                                <!-- description -->
                                <div class="gmw-addon-desc-wrapper">
                                    
                                    <div class="gmw-addon-desc-inner">
                                        <em><?php 
                esc_attr_e($addon['desc']);
                ?>
</em> 
                                        
                                        <!-- Notices -->
                                        <?php 
                if (!empty($addon['gmw_required'])) {
                    ?>
                                            <div class="gmw-addon-update-required-wrapper">
                                                <em><?php 
                    echo $addon['gmw_required_message'];
                    ?>
 <?php 
                    echo GMW_Admin::update_addon_link($plugins[$addon['basename']]['Name']);
                    ?>
</em>
                                            </div>
                                        <?php 
                } elseif ($addon['update_avaliable'] == 1) {
                    ?>
     
                                            <div class="gmw-addon-update-required-wrapper">
                                                <em><?php 
                    echo $addon['required_message'];
                    ?>
 <?php 
                    echo GMW_Admin::update_addon_link($plugins[$addon['basename']]['Name']);
                    ?>
</em>
                                            </div>
                                        <?php 
                } elseif ($addon['update_avaliable'] == 2) {
                    ?>
     
                                            <div class="gmw-addon-update-available-wrapper">
                                                <em>New version of <?php 
                    esc_attr_e($addon['title']);
                    ?>
 <?php 
                    esc_attr_e($addon['current_version']);
                    ?>
 is available for update. <?php 
                    echo GMW_Admin::update_addon_link($plugins[$addon['basename']]['Name']);
                    ?>
</em>.
                                            </div>
                                        <?php 
                }
                ?>
                                     </div>
                                 </div>
                            </div>

                            <!-- when add-on is deactivated -->
                            <?php 
                if (!isset($this->addons) || !isset($this->addons[$addon['name']]) || $this->addons[$addon['name']] == 'inactive') {
                    ?>
								
								<?php 
                    if ($addon['license']) {
                        ?>
								
									<table>
										<tr class="gmw-license-key-wrapper">
			
											<td class="plugin-update" colspan="3">
												
												<div class="gmw-license-key-fields-wrapper">
													
													<form method="post" action="">
																						
														<div class="gmw-license-wrapper gmw-license-invalid-wrapper addon-deactivated">
															
															<span><?php 
                        _e('License Key:', 'GMW');
                        ?>
</span>
															<input 
																class="gmw-license-key-input-field" 
																disabled="disabled" 
																type="text" 
																size="30"
																value=""
																placeholder="license Key" />
																
															<button 
																disabled="disabled"
																type="submit"
																class="gmw-license-key-button button-secondary activate-license-btn button-primary"
																name="gmw_license_key_activate"
																title="<?php 
                        _e('Activate License Key', 'GMW');
                        ?>
"
																style="padding: 0 8px !important;"
																value="<?php 
                        echo $this->license_name;
                        ?>
"><?php 
                        _e('Activate License', 'GMW');
                        ?>
</button>
																										
															<p class="description"><?php 
                        _e('Please activate the add-on to be able to enter and activate the license key.', 'GMW');
                        ?>
</p>
														</div> <!-- if status invalid -->												
													
													</form>	
												</div>
											</td>
										</tr>
									</table>
									
								<?php 
                    } else {
                        ?>
									
									<table>
										<tr class="active gmw-license-key-wrapper">
			
											<td class="plugin-update" colspan="3">
												
												<div class="gmw-license-key-fields-wrapper">
													
													<form method="post" action="">
																						
														<div class="gmw-license-wrapper gmw-license-invalid-wrapper addon-deactivated">
															
															<span>License Key: </span>
															<input 
																class="gmw-license-key-input-field" 
																disabled="disabled" 
																type="text" 
																size="30"
																value=""
																placeholder="license Key" />
												
															<p class="description"><?php 
                        _e('This is a free add-on and does not require a license key. Please activate the add-on to start using it.', 'GMW');
                        ?>
</p>
														</div> <!-- if status invalid --> 	
													</form>	
												</div>
											</td>
										</tr>
									</table>
								<?php 
                    }
                    ?>
									
                                <div class="gmw-addon-license-wrapper gmw-license-invalid gmw-addon-deactivate <?php 
                    if (empty($addon['installed'])) {
                        echo 'not-installed';
                    }
                    ?>
">

                                    <?php 
                    if (!empty($addon['installed'])) {
                        ?>
							                                    
    									<form method="post" action="">
    	                                    <!-- activate add-on button -->
    	                                    <input type="submit" class="button-secondary button-primary gmw-addon-activation-btn" value="<?php 
                        _e('Activate Add-on', 'GMW');
                        ?>
" />
    	                                    <input type="hidden" name="gmw_addon_basename" value="<?php 
                        echo plugin_basename(esc_attr($addon['file']));
                        ?>
" />
    										<input type="hidden" name="gmw_action" value="activate_addon" />
    										<input type="hidden" name="gmw_addon_activated" value="<?php 
                        echo esc_attr($addon['name']);
                        ?>
" />										
    										<?php 
                        wp_nonce_field($addon['name'] . '_activate_addon_nonce', $addon['name'] . '_activate_addon_nonce');
                        ?>
 	
    									</form>

                                    <?php 
                    } else {
                        ?>
                                        <a href="<?php 
                        echo esc_url($addon['premalink']);
                        ?>
" class="button-secondary button-primary gmw-addon-activation-btn" target="_blank" title="Get add-on"><?php 
                        _e('Get Add-on', 'GMW');
                        ?>
</a>
                                    <?php 
                    }
                    ?>
									
                                </div>
                               
                            <?php 
                } else {
                    ?>
																		
								<?php 
                    if ($addon['license']) {
                        ?>
									<table>
										<?php 
                        if (class_exists('GMW_License_Key')) {
                            //display license key box
                            $gmw_license_key = new GMW_License_Key($addon['file'], $addon['item'], $addon['name']);
                            $gmw_license_key->license_key_output();
                        }
                        ?>
									</table>								
								<?php 
                    } else {
                        ?>
									
									<table>
										<tr class="active gmw-license-key-wrapper">
			
											<td class="plugin-update" colspan="3">
												
												<div class="gmw-license-key-fields-wrapper">
													
													<form method="post">
																						
														<div class="gmw-license-wrapper gmw-license-valid-wrapper">
															
															<span>License Key: </span>
															<input 
																class="gmw-license-key-input-field" 
																disabled="disabled" 
																type="text" 
																size="30"
																value=""
																placeholder="license Key" />
												
															<p class="description"><?php 
                        _e('This is a free add-on and does not require a license key. Thank you for using GEO my WP.', 'GMW');
                        ?>
</p>
														</div> <!-- if status invalid --> 	
													</form>	
												</div>
											</td>
										</tr>
									</table>
								<?php 
                    }
                    ?>
								
								<?php 
                    if (isset($addon['name'])) {
                        ?>

									<?php 
                        $deactivation_message = __('Please deactivate the license key before deactivating the plugin', 'GMW');
                        ?>

	                                 <div class="gmw-addon-license-wrapper gmw-addon-activate">   
	                                 
	                                 	<form method="post" action="">
		                                                 																
		                                    <input 
		                                    	type="submit"
		                                    	title="<?php 
                        esc_attr_e($deactivation_message);
                        ?>
"
		                                    	<?php 
                        if (gmw_is_license_valid($addon['name'])) {
                            ?>
		                                    		onclick="alert('<?php 
                            esc_attr_e($deactivation_message);
                            ?>
'); return false;"
		                                    	<?php 
                        }
                        ?>
	
		                                    	class="button-secondary gmw-addon-activation-btn btn-disabled" 
		                                    	value="<?php 
                        _e('Deactivate Add-on', 'GMW');
                        ?>
" />
		                                    	
		                                    <input type="hidden" name="gmw_addon_basename" value="<?php 
                        echo plugin_basename(esc_attr($addon['file']));
                        ?>
" />
		                                    <input type="hidden" name="gmw_action" value="deactivate_addon" />
		                                    <input type="hidden" name="gmw_addon_deactivated" value="<?php 
                        echo esc_attr($addon['name']);
                        ?>
" />										
											<?php 
                        wp_nonce_field($addon['name'] . '_deactivate_addon_nonce', $addon['name'] . '_deactivate_addon_nonce');
                        ?>
	                                    	
	                                    </form>  									
	                                </div>
	                            <?php 
                    }
                    ?>
														
                            <?php 
                }
                ?>

                        </li>

                    <?php 
            }
            ?>
                </ul>          
        </div>
        <?php 
        }
    /**
     * display settings 
     *
     * @access public
     * @return void
     */
    public function output()
    {
        $this->shortcodes = self::get_shortcodes();
        ?>
        <div class="wrap">

            <h2 class="gmw-wrap-top-h2">
                <?php 
        echo _e('Shortcodes', 'GMW');
        ?>
                <?php 
        gmw_admin_support_button();
        ?>
            </h2>

            <div class="clear"></div>
            
            <form method="post" action="options.php">

                <div class="gmw-tabs-table gmw-shortcodes-page-nav-tabs gmw-nav-tab-wrapper">
               		<?php 
        foreach ($this->shortcodes as $key => $options) {
            echo '<span><a href="#settings-' . sanitize_title($key) . '" title="' . esc_html($options['name']) . '"  class="gmw-nav-tab">' . esc_html($options['name']) . '</a></span>';
        }
        ?>
				</div>

                <?php 
        foreach ($this->shortcodes as $key => $options) {
            ?>

                    <div id="settings-<?php 
            echo sanitize_title($key);
            ?>
" class="gmw-settings-panel">
                                        
                    <table class="widefat fixed" style="margin-bottom:5px;margin-top: -2px;">
                        <thead>
                            <tr>
                                <th scope="col" id="cb" class="manage-column column-cb check-column" style="width:20%;padding:11px 10px;">
                                	<label><?php 
            _e('Post/Page Content Usage', 'GMW');
            ?>
</label>
                               	</th>
                               	<th scope="col" id="cb" class="manage-column column-cb check-column" style="width:40%;padding:11px 10px;">
                                	<label><?php 
            _e('Template File Usage', 'GMW');
            ?>
</label>
                               	</th>
                                <th scope="col" id="cb" class="manage-column column-cb check-column" style="width:40%;padding:11px 10px;">
                                	<label><?php 
            _e('Description', 'GMW');
            ?>
</label>
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                        	<tr>
                        		<td style="color: #555;border-bottom:1px solid #eee;min-width:400px;vertical-align: top">
                        			<lablel><code><?php 
            echo $options['basic_usage'];
            ?>
</code></lablel>
                        		</td>
                        		<td style="color: #555;border-bottom:1px solid #eee;min-width:400px;vertical-align: top">
                        			<lablel><code><?php 
            echo $options['template_usage'];
            ?>
</code></lablel>
                        		</td>
                        		<td style="color: #555;border-bottom:1px solid #eee;min-width:400px;vertical-align: top">
                        			<p class="description"><?php 
            echo $options['desc'];
            ?>
</p>
                        		</td>
                        	</tr>
                        </tbody>
                    </table>
                    
                    <table class="widefat fixed" style="margin-top:10px;">
                        <thead>
                            <tr>
                                <th scope="col" id="cb" class="manage-column column-cb check-column" style="text-align:center;padding:11px 10px;"><?php 
            _e('Shortcode Attributes', 'GMW');
            ?>
</th>
                            </tr>
                        </thead>
                    </table>
                    
                    <table class="widefat fixed" style="margin-top:-2px">
                        <thead  style="background-color:#f9f9f9;">
                            <tr valign="top" >
                                <th scope="col" id="cb" class="manage-column column-cb check-column" style="width:50px;padding:11px 10px"><?php 
            _e('Attribute', 'GMW');
            ?>
</th>
                                <th scope="col" id="cb" class="manage-column column-cb check-column" style="width:50px;padding:11px 10px"><?php 
            _e('Values Accepted', 'GMW');
            ?>
</th>
                                <th scope="col" id="cb" class="manage-column column-cb check-column" style="width:50px;padding:11px 10px"><?php 
            _e('Default Value', 'GMW');
            ?>
</th>
                                <th scope="col" id="cb" class="manage-column column-cb check-column" style="width:50px;padding:11px 10px"><?php 
            _e('Additional Information', 'GMW');
            ?>
</th> 
                            </tr>
                        </thead>
                        <tbody>
                        	<?php 
            $rowNumber = 1;
            foreach ($options['attributes'] as $attr) {
                $alternate = $rowNumber % 2 == 0 ? 'alternate' : '';
                ?>
	                        	<tr valign="top">
	                        		<th scope="row" style="color: #555;border-bottom:1px solid #eee;"><label for="setting-google_api"><?php 
                echo $attr['attr'];
                ?>
</label></th>
	                        		<td style="color: #555;border-bottom:1px solid #eee;min-width:400px;vertical-align: top">
	                        		
	                        		<?php 
                $rowCount = 1;
                ?>
	                        		<?php 
                foreach ($attr['values'] as $value) {
                    ?>
                        		
	                        			<p class="description"><?php 
                    echo $rowCount++ . ')' . ' ' . $value;
                    ?>
</p>
	                        		<?php 
                }
                ?>
	                        		</td>
	                        		<?php 
                $default = isset($attr['default']) ? $attr['default'] : __('N/A', 'GMW');
                ?>
	                        		<td style="color: #555;border-bottom:1px solid #eee;min-width:400px;vertical-align: top"><p class="description"><?php 
                echo $default;
                ?>
</p></td>
	                        		<td style="color: #555;border-bottom:1px solid #eee;min-width:400px;vertical-align: top"><p class="description"><?php 
                echo $attr['desc'];
                ?>
</p></td>
	                        	</tr>
                        		<?php 
                $rowNumber++;
            }
            ?>
                        </tbody>
                    </table>
                    
                    <table class="widefat fixed" style="margin-top:10px;">
                        <thead>
                            <tr>
                                <th scope="col" id="cb" class="manage-column column-cb check-column" style="text-align:center;padding:11px 10px;"><?php 
            _e('Shortcode Examples', 'GMW');
            ?>
</th>
                            </tr>
                        </thead>
                    </table>
                    
                    <?php 
            if (isset($options['examples']) && !empty($options['examples'])) {
                ?>
	                    <table class="widefat fixed" style="margin-top:-2px">
	                        <thead  style="background-color:#f9f9f9;">
	                            <tr valign="top">
	                                <th scope="col" id="cb" class="manage-column column-cb check-column" style="width:50px;padding:11px 10px"><?php 
                _e('Usage', 'GMW');
                ?>
</th>
	                                <th scope="col" id="cb" class="manage-column column-cb check-column" style="width:50px;padding:11px 10px"><?php 
                _e('Description', 'GMW');
                ?>
</th>
	                            </tr>
	                        </thead>
	                        <tbody>
	                        	<?php 
                $rowNumber = 1;
                foreach ($options['examples'] as $example) {
                    $alternate = $rowNumber % 2 == 0 ? 'alternate' : '';
                    ?>
		                        	<tr valign="top">
		                        		<th scope="row" style="color: #555;border-bottom:1px solid #eee;"><label for="setting-google_api"><code><?php 
                    echo $example['example'];
                    ?>
</code></label></th>
		                        		<td style="color: #555;border-bottom:1px solid #eee;min-width:400px;vertical-align: top"><p class="description"><?php 
                    echo $example['desc'];
                    ?>
</p></td>
		                        	</tr>
	                        		<?php 
                    $rowNumber++;
                }
                ?>
	                        </tbody>
	                    </table>
	               	<?php 
            }
            ?>
           
            </div>
            <?php 
        }
        ?>
        </form>
        </div>
        <script type="text/javascript">
            jQuery('.gmw-nav-tab-wrapper a').click(function() {
                jQuery('.gmw-settings-panel').hide();
                jQuery('.gmw-nav-tab-active').css('background', '#f7f7f7');
                jQuery('.gmw-nav-tab-active').removeClass('gmw-nav-tab-active');

                jQuery(jQuery(this).attr('href')).show();
                jQuery(this).addClass('gmw-nav-tab-active');

                return false;
            });

            jQuery('.gmw-nav-tab-wrapper a:first').click();
        </script>
        <?php 
    }
    /**
     * display settings 
     *
     * @access public
     * @return void
     */
    public function output()
    {
        self::init_settings();
        $gmw_options = get_option('gmw_options');
        ?>
        <div class="wrap">

            <h2 class="gmw-wrap-top-h2">
                <i class="fa fa-cog"></i>
                <?php 
        echo _e('GEO my WP Settings', 'GMW');
        ?>
                <?php 
        gmw_admin_support_button();
        ?>
            </h2>

            <div class="clear"></div>
            
            <form method="post" action="options.php">

                <?php 
        settings_fields($this->settings_group);
        ?>

                <?php 
        if (!empty($_GET['settings-updated'])) {
            echo '<div class="updated fade" style="clear:both"><p>' . __('Settings successfully saved', 'GMW') . '</p></div>';
        }
        ?>

                <div class="gmw-tabs-table gmw-settings-page-nav-tabs gmw-nav-tab-wrapper">
                	<?php 
        foreach ($this->settings as $key => $section) {
            echo '<span><a href="#settings-' . sanitize_title($key) . '" id="' . sanitize_title($key) . '" title="' . esc_html($section[0]) . '"  class="gmw-nav-tab">' . esc_html($section[0]) . '</a></span>';
        }
        ?>
                </div>

                <?php 
        foreach ($this->settings as $key => $section) {
            ?>

                    <div id="settings-<?php 
            echo sanitize_title($key);
            ?>
" class="gmw-settings-panel">
                    
	                    <table class="widefat">
	                        <thead>
	                            <tr>
	                                <th scope="col" id="cb" class="manage-column column-cb check-column" style="width:20%;padding:11px 10px"><?php 
            _e('Feature', 'GMW');
            ?>
</th>
	                                <th scope="col" id="cb" class="manage-column column-cb check-column" style="width:35%;padding:11px 10px"><?php 
            _e('Settings', 'GMW');
            ?>
</th>
	                            </tr>
	                        </thead>
                            <tbody>
    	                        <?php 
            $rowNumber = 0;
            foreach ($section[1] as $option) {
                $placeholder = !empty($option['placeholder']) ? 'placeholder="' . $option['placeholder'] . '"' : '';
                $class = !empty($option['class']) ? $option['class'] : '';
                $value = !empty($gmw_options[$key][$option['name']]) ? $gmw_options[$key][$option['name']] : $option['std'];
                $option['type'] = !empty($option['type']) ? $option['type'] : '';
                $attributes = array();
                if (!empty($option['attributes']) && is_array($option['attributes'])) {
                    foreach ($option['attributes'] as $attribute_name => $attribute_value) {
                        $attributes[] = esc_attr($attribute_name) . '="' . esc_attr($attribute_value) . '"';
                    }
                }
                echo '<tr valign="top" class="' . $class . '">';
                echo '<td class="gmw-form-feature-desc">';
                echo '<label for="setting-' . $option['name'] . '">' . $option['label'] . '</label>';
                if ($option['desc']) {
                    echo ' <p class="description">' . $option['desc'] . '</p>';
                }
                echo '</td>';
                echo '<td class="gmw-form-feature-settings">';
                switch ($option['type']) {
                    case "function":
                        $function = !empty($option['function']) ? $option['function'] : $option['name'];
                        do_action('gmw_main_settings_' . $function, $gmw_options, $key, $option);
                        break;
                    case "checkbox":
                        ?>
<label><input class="setting-<?php 
                        echo $option['name'];
                        ?>
" name="<?php 
                        echo 'gmw_options[' . $key . '][' . $option['name'] . ']';
                        ?>
" type="checkbox" value="1" <?php 
                        echo implode(' ', $attributes);
                        ?>
 <?php 
                        checked('1', $value);
                        ?>
 /> <?php 
                        echo $option['cb_label'];
                        ?>
</label><?php 
                        break;
                    case "multicheckbox":
                        foreach ($option['options'] as $keyVal => $name) {
                            ?>
<label><input class="setting-<?php 
                            echo $option['name'];
                            ?>
" name="<?php 
                            echo 'gmw_options[' . $key . '][' . $option['name'] . '][' . $keyVal . ']';
                            ?>
" type="checkbox" value="1" <?php 
                            if (isset($gmw_options[$key][$option['name']][$keyVal]) && $gmw_options[$key][$option['name']][$keyVal] == 1) {
                                echo 'checked="checked"';
                            }
                            ?>
 /> <?php 
                            echo $name;
                            ?>
</label><br /> <?php 
                        }
                        break;
                        //needs improvment
                        /*                                 
                        case "multicheckboxvalues" :
                            foreach ($option['options'] as $keyVal => $name) {
                                ?><p><label><input id="setting-<?php echo $option[ 'name' ]; ?>" class="setting-<?php echo $option['name']; ?>"  name="<?php echo 'gmw_options['.$key.']['.$option['name'].']['.$keyVal.']'; ?>" type="checkbox" value="<?php echo $keyVal; ?>" <?php if ( isset( $gmw_options[ $key ][ $option[ 'name' ] ][ $keyVal ] ) && $gmw_options[ $key ][ $option[ 'name' ] ][ $keyVal ] == 1 ) echo 'checked="checked"'; ?> /> <?php echo $name; ?></label><br /> <?php
                            }
                        break;
                        */
                    //needs improvment
                    /*                                 
                    case "multicheckboxvalues" :
                        foreach ($option['options'] as $keyVal => $name) {
                            ?><p><label><input id="setting-<?php echo $option[ 'name' ]; ?>" class="setting-<?php echo $option['name']; ?>"  name="<?php echo 'gmw_options['.$key.']['.$option['name'].']['.$keyVal.']'; ?>" type="checkbox" value="<?php echo $keyVal; ?>" <?php if ( isset( $gmw_options[ $key ][ $option[ 'name' ] ][ $keyVal ] ) && $gmw_options[ $key ][ $option[ 'name' ] ][ $keyVal ] == 1 ) echo 'checked="checked"'; ?> /> <?php echo $name; ?></label><br /> <?php
                        }
                    break;
                    */
                    case "textarea":
                        ?>
<textarea id="setting-<?php 
                        echo $option['name'];
                        ?>
" class="large-text" cols="50" rows="3" name="<?php 
                        echo 'gmw_options[' . $key . '][' . $option['name'] . ']';
                        ?>
" <?php 
                        echo implode(' ', $attributes);
                        ?>
 <?php 
                        echo $placeholder;
                        ?>
><?php 
                        echo esc_textarea($value);
                        ?>
</textarea><?php 
                        break;
                    case "radio":
                        $rc = 1;
                        foreach ($option['options'] as $keyVal => $name) {
                            $checked = $rc == 1 ? 'checked="checked"' : checked($value, $keyVal, false);
                            echo '<input type="radio" class="setting-' . $option['name'] . '" name="gmw_options[' . $key . '][' . $option['name'] . ']" value="' . esc_attr($keyVal) . '" ' . $checked . ' />' . $name . ' ';
                            $rc++;
                        }
                        break;
                    case "select":
                        ?>
        	                                	<select id="setting-<?php 
                        echo $option['name'];
                        ?>
" class="regular-text" name="<?php 
                        echo 'gmw_options[' . $key . '][' . $option['name'] . ']';
                        ?>
" <?php 
                        echo implode(' ', $attributes);
                        ?>
>
        	                             			<?php 
                        foreach ($option['options'] as $keyVal => $name) {
                            ?>
        	                                			<?php 
                            echo '<option value="' . esc_attr($keyVal) . '" ' . selected($value, $keyVal, false) . '>' . esc_html($name) . '</option>';
                            ?>
        											<?php 
                        }
                        ?>
        	                                	</select>
        	                                	<?php 
                        break;
                    case "password":
                        ?>
        	                                    <input id="setting-<?php 
                        echo $option['name'];
                        ?>
" class="regular-text" type="password" name="<?php 
                        echo 'gmw_options[' . $key . '][' . $option['name'] . ']';
                        ?>
" value="<?php 
                        esc_attr_e($value);
                        ?>
" <?php 
                        echo implode(' ', $attributes);
                        ?>
 <?php 
                        echo $placeholder;
                        ?>
 />
        	                                    <?php 
                        break;
                    default:
                        ?>
        	                                	<input id="setting-<?php 
                        echo $option['name'];
                        ?>
" class="regular-text" type="text" name="<?php 
                        echo 'gmw_options[' . $key . '][' . $option['name'] . ']';
                        ?>
" value="<?php 
                        esc_attr_e($value);
                        ?>
" <?php 
                        echo implode(' ', $attributes);
                        ?>
 <?php 
                        echo $placeholder;
                        ?>
 />
        	                                	<?php 
                        break;
                }
                echo '</td>';
                echo '</tr>';
                $rowNumber++;
            }
            ?>
                            </tbody>
	                        <tfoot>
	                            <tr style="height:40px;">
	                                <th scope="col" id="cb" class="manage-column  column-cb check-column" style="width:50px;padding:11px 10px">
	                                    <input type="submit" class="button-primary" value="<?php 
            _e('Save Changes', 'GMW');
            ?>
" />
	                                </th>
	                                <th scope="col" id="id" class="manage-column">--</th>
	                            </tr>
	                        </tfoot>
	                    </table>
                    </div>
            	<?php 
        }
        ?>
        	</form>
        </div>
        <?php 
        $current_tab = isset($_COOKIE['gmw_admin_tab']) ? $_COOKIE['gmw_admin_tab'] : false;
        ?>
        <script type="text/javascript">
        jQuery(document).ready(function($) {
        	if ( '<?php 
        echo $current_tab;
        ?>
' != false ) { 
         		jQuery('#<?php 
        echo $current_tab;
        ?>
').click();
         	}
        });
        </script>
        <?php 
    }