function sp_type_box($type, $css_class = '')
{
    global $seopress_plugin_url;
    $autocomplete_script = $seopress_plugin_url . 'admin/get_tags.php?type=' . $type;
    $fields['title'] = array('name' => $type . '-title', 'title' => __('Title', 'seopress'), 'field-type' => 'textfield', '' => '');
    $fields['description'] = array('name' => $type . '-description', 'title' => __('Description', 'seopress'), 'field-type' => 'textfield');
    $fields['keywords'] = array('name' => $type . '-keywords', 'title' => __('Keywords', 'seopress'), 'field-type' => 'textfield');
    $fields = apply_filters('sp_types_fields', $fields);
    $html .= '<table width="100%" class="form-table"><tbody>';
    foreach ($fields as $key => $field) {
        if ($field['field-type'] == 'textfield') {
            register_setting('sp-settings', $field['name']);
            $html .= '<tr><td width="200"><lable for="' . $field['name'] . '">' . $field['title'] . '</lable></td><td>';
            $html .= tk_wp_jqueryui_autocomplete($field['name'], 'seopress_seo_settings', $field['name'], $autocomplete_script, 'onfocus="this.style.color=\'#000\'" onblur="this.style.color=\'#CCC\'" style="width:100%;color:#CCC;"');
            $html .= '</td></tr>';
            $html = apply_filters('type-box-filter-' . $key, $html, $type);
            $html = apply_filters($field['name'] . '-filter', $html, $type);
        }
        $html = apply_filters('sp_type_box_field_loop', $html, $type);
    }
    $html .= '<tr><td width="200"><lable for="' . $type . '-noindex">' . __('Ban searchengines', 'seopress') . '</lable></td><td>';
    $html .= tk_wp_form_checkbox($type . '-noindex', 'seopress_seo_settings', 'noindex');
    $html .= '</td></tr>';
    $html = apply_filters('sp_type_box_field_html', $html, $type);
    $html .= '</tbody></table>';
    return $html;
}
/**
 * Configuration tab for general seo settings
 *
 * @package SeoPress
 * @author Sven Wagener
 * @copyright Copyright (C) Themekraft
 **/
function sp_admin_settings_tab()
{
    global $seopress_plugin_url;
    $html .= sp_admin_tab_header(__('Global Seo options', 'seopress'), __('Setup the global settings of the Seo part of the plugin.', 'seopress'), $seopress_plugin_url . 'includes/images/logo-wordpress.png');
    $html .= '<table class="widefat">';
    $html .= '<tbody>';
    $html .= '<tr>';
    $html .= '<td colspan="2"><div class="components_extend" colspan="2"><strong>' . __('Title', 'seopress') . '</strong></td>';
    $html .= '</tr>';
    $html .= '<tr>';
    $html .= '<td><div class="components_extend">' . __('Show pagination', 'seopress') . '</div></td>';
    $html .= '<td><div class="components_extend">' . tk_wp_form_checkbox('show_pagination', 'seopress_options', 'show_pagination') . '</div></td>';
    $html .= '</tr>';
    $html .= '<tr>';
    $html .= '<td><div class="components_extend">' . __('Standard length of title', 'seopress') . '</div></td>';
    // $html.= '<td><div class="components_extend"><input type="text" name="bp_seo_metadesc_length" length="4" size="3" value="' . get_option('bp_seo_metadesc_length') . '" /> (' . __('number of chars', 'seopress' ) . ')</div></td>';
    $html .= '<td><div class="components_extend">' . tk_wp_form_textfield('std_title_legth', 'seopress_options', 'std_title_legth') . ' (' . __('number of chars', 'seopress') . ')</div></td>';
    $html .= '</tr>';
    $html .= '<tr>';
    $html .= '<td><div class="components_extend">' . __('Standard length of meta description', 'seopress') . '</div></td>';
    // $html.= '<td><div class="components_extend"><input type="text" name="bp_seo_metadesc_length" length="4" size="3" value="' . get_option('bp_seo_metadesc_length') . '" /> (' . __('number of chars', 'seopress' ) . ')</div></td>';
    $html .= '<td><div class="components_extend">' . tk_wp_form_textfield('std_metadesc_legth', 'seopress_options', 'std_metadesc_legth') . ' (' . __('number of chars', 'seopress') . ')</div></td>';
    $html .= '</tr>';
    $html .= '<tr>';
    $html .= '<td colspan="2"><div class="components_extend" colspan="2"><strong>' . __('Meta boxes in posts and pages', 'seopress') . '</strong></td>';
    $html .= '</tr>';
    $html .= '<tr>';
    $html .= '<td><div class="components_extend">' . __('Hide meta boxes in posts:', 'seopress') . '</div></td>';
    // $html.= '<td><div class="components_extend"><input type="checkbox" name="bp_seo_meta_box_post" ' . $meta_box_post_checked . ' value="1" /></div></td>';
    $html .= '<td><div class="components_extend">' . tk_wp_form_checkbox('metabox_post', 'seopress_options', 'metabox_post') . '</div></td>';
    $html .= '</tr>';
    $html .= '<tr>';
    $html .= '<td><div class="components_extend">' . __('Hide meta boxes in pages:', 'seopress') . '</div></td>';
    // $html.= '<td><div class="components_extend"><input type="checkbox" name="bp_seo_meta_box_page" ' . $meta_box_page_checked . ' value="1" /></div></td>';
    $html .= '<td><div class="components_extend">' . tk_wp_form_checkbox('metabox_page', 'seopress_options', 'metabox_page') . '</div></td>';
    $html .= '</tr>';
    do_action('seopress_seo_options');
    $html .= '</tbody>';
    $html .= '</table>';
    $button = '<p class="submit"><input class="button-primary" type="submit" name="save" value="' . __('Save', 'seopress') . '" /></p>';
    $html .= $button;
    return $html;
}
function seopress_component_config($bp_component)
{
    $bp_components = sp_get_bp_components();
    $content = '<h4>' . sprintf(__('Please config your "%s" plugin:', 'seopress'), str_replace('_', ' ', ucwords(strtolower($bp_component)))) . '</h4>';
    $content .= '<table class="widefat">';
    $content .= '<tbody>';
    $content .= '<tr>';
    $content .= '<td width="50%"><div class="components_extend"><strong>' . sprintf(__('"%s" has a directory page:', 'seopress'), str_replace('_', ' ', ucwords(strtolower($bp_component)))) . '</strong></div></td>';
    // $content.= '<td width="50%"><div class="components_extend"><input name="componentspage-types[' . $bp_component . '][directory]" type="checkbox" '.$checked.' value="1"></div></td>';
    $content .= '<td width="50%"><div class="components_extend">' . tk_wp_form_checkbox('bp-componentspage-types-' . $bp_component . '-directory', 'seopress_seo_settings') . '</div></td>';
    $content .= '</tr>';
    $content .= '<tr>';
    $content .= '<td colspan="2"><div class="components_extend"><strong>' . sprintf(__('"%s" creating pages in following components:', 'seopress'), str_replace('_', ' ', ucwords(strtolower($bp_component)))) . '</strong></div>';
    // $content.= '<input name="componentspage-types[' . $bp_component . '][slug]" type="hidden" ' . $checked . ' value="' . $bp_component . '" /></td>' ;
    $content .= '<input name="seopress_values[bp-componentspage-types-' . $bp_component . '-slug]" type="hidden" ' . $checked . ' value="' . $bp_component . '" /></td>';
    $content .= '</tr>';
    $bp_main_component = $bp_component;
    // Runnung all extendable components of this component
    foreach ($bp_components as $sub_comp) {
        if ($sub_comp != 'messages' && $sub_comp != 'settings' && $sub_comp != 'blogs' && $sub_comp != $bp_component) {
            $component_name = ucwords(strtolower(str_replace('_', ' ', $sub_comp)));
            $content .= '<tr>';
            $content .= '<td><div class="components_extend"><lable for="componentspage-types[' . $bp_main_component . '][plugin_extends][]">' . $component_name . '</lable></div></td>';
            // $content.= '<td><div class="components_extend"><input name="componentspage-types[' . $bp_main_component . '][plugin_extends][]" id="componentspage-types[' . $bp_main_component . '][plugin_extends][]"  type="checkbox" '.$checked.'  value="' . $bp_sub_component . '" /></div></td>';
            $content .= '<td><div class="components_extend">' . tk_wp_form_checkbox('bp-componentspage-types-' . $bp_main_component . '-' . $sub_comp . '', 'seopress_seo_settings') . '</div></td>';
            $content .= '</tr>';
        }
        $checked = '';
    }
    $content .= '</tbody>';
    $content .= '</table>';
    return $content;
}
function sp_page_metabox()
{
    $mb = new TK_WP_METABOX('sp_post_metabox', __('SeoPress Settings', 'seopress'), 'page');
    $title_field = apply_filters('sp_page_metabox_title', $title_field);
    $description_field = apply_filters('sp_page_metabox_description', $description_field);
    $keywords_field = apply_filters('sp_page_metabox_keywords', $keywords_field);
    $noindex_field = apply_filters('sp_page_metabox_noindex', $noindex_field);
    $post_metabox_table = apply_filters('sp_page_metabox_table', $post_metabox_table);
    $tabs = new TK_WP_JQUERYUI_TABS();
    $html = '<p class="sp_metabox_description">' . __('Leave fields blank if you want to use standard values.', 'seopress') . '</p>';
    $html .= '<table class="form-table">
				<tbody>
					<tr>
						<td width="200" valign="top"><label for="seopress_title">' . __('Title', 'seopress') . ':</label></td>
						<td>' . tk_wp_form_textfield('title', 'sp_post_metabox', 'title', ' style="width:99%"') . $title_field . '</td>
					</tr>
					<tr>
						<td valign="top"><label for="seopress_description">' . __('Description', 'seopress') . ':</label></td>
						<td>' . tk_wp_form_textfield('description', 'sp_post_metabox', 'description', ' style="width:99%"') . $description_field . '</td>
					</tr>
					<tr>
						<td valign="top"><label for="seopress_keywords">' . __('Keywords', 'seopress') . ':</label></td>
						<td>' . tk_wp_form_textfield('keywords', 'sp_post_metabox', 'keywords', ' style="width:99%"') . $keywords_field . '</td>
					</tr>
					<tr>
						<td valign="top"><label for="seopress_noindex">' . __('Ban searchengines', 'seopress') . ':</label></td>
						<td>' . tk_wp_form_checkbox('noindex', 'sp_post_metabox', 'noindex') . $noindex_field . '</td>
					</tr>
					' . $page_metabox_table . '
				</tbody>
			</table>';
    $html = apply_filters('sp_page_metabox_html', $html);
    $tabs->add_tab('cap_post_seo', __('SEO', 'seopress'), $html);
    do_action('sp_page_metabox_tabs', $tabs);
    $html = $tabs->get_html();
    $mb->add_element($html);
    $mb->create();
}