Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

file 665 lines (467 sloc) 21.092 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665
<?php
/*
Plugin Name: TF FAQ
Plugin URI: http://twentyfiveautumn.com/our-wordpress-plugins/tf-faq/
Description: An advanced frequently asked questions plugin by twentyfiveautumn.com and released under the MIT license.
Version: 0.1.2
Author: ray peaslee
Author URI: http://twentyfiveautumn.com
License: MIT
License URI: http://opensource.org/licenses/MIT
*/

function tffaq_uninstall() {
global $wpdb;

if (function_exists('is_multisite') && is_multisite()) {
// check if it is a network activation - if so, run the activation function for each blog id
if (isset($_GET['networkwide']) && ($_GET['networkwide'] == 1)) {
$old_blog = $wpdb->blogid;
// Get all blog ids
$blogids = $wpdb->get_col($wpdb->prepare("SELECT blog_id FROM $wpdb->blogs"));
foreach ($blogids as $blog_id) {
switch_to_blog($blog_id);
_tffaq_uninstall();
}
switch_to_blog($old_blog);
return;
}
}
_tffaq_uninstall();
}

function _tffaq_uninstall(){

global $wpdb;
$db_table_name = $wpdb->prefix . "faq_questions";
$sql = 'DROP TABLE IF EXISTS '.$db_table_name;
$wpdb->query( $sql );
$db_table_name = $wpdb->prefix . "faq_categories";
$sql = 'DROP TABLE IF EXISTS '.$db_table_name;
$wpdb->query( $sql );
delete_option( "tffaq_version" );
delete_option( "faq-email" );

} // end uninstall function

/*** our new function to register javascript ***/

function tffaq_register_js(){ // always and them to the footer unless there is a compelling reason not to...

wp_register_script( 'tffaq_jquery_cookie', plugins_url( 'js/jquery.cookie.js' , __FILE__ ),array('jquery-ui-tabs'),'',1);
wp_register_script( 'tffaq_frontend', plugins_url( 'js/tffaq-frontend.js' , __FILE__ ),array('jquery-ui-tabs'),'',1 );
wp_register_script('tffaq_validation', plugins_url('/js/jquery.validate.js', __FILE__), array('jquery'),'1.8.1',1);

/* currently tffaq_validation_extra is not being used so we'll comment it out.
wp_register_script('tffaq_validation_extra', plugins_url('/js/additional-methods.js', __FILE__), array('jquery','tffaq_validation'),'1.8.1',1);
*/

wp_register_script('tffaq_valid_question', plugins_url('/js/tffaq-valid-question.js', __FILE__), array('jquery','tffaq_validation'),'0.0.1', 1);

}
add_action('init','tffaq_register_js');

// end our new function to register javascript

/*** front end stuff ***/

function tffaq_show($questions) {
$new_content = '';
foreach($questions as $question) {
$new_content .= '<p class="tffaq-question" id="tffaq-question-'.$question->id.'"><a style="cursor: pointer;" data-options=\'{"id":'.$question->id.'}\' >'.$question->question.'</a></p>';
$new_content .= '<p class="tffaq-answer sticky" id="tffaq-answer-'.$question->id.'" style="display: none;"> '.$question->answer.' </p>';
}
return $new_content;
}

function add_tffaq_frontend_js() {

wp_enqueue_script('jquery-ui-tabs');

// add jQuery validation here
wp_enqueue_script('tffaq_validation');

/* currently tffaq_validation_extra is not being used so we'll comment it out.
wp_enqueue_script('tffaq_validation_extra');
*/

}
add_action('wp_head','add_tffaq_frontend_js',0);

function tffaq_tabs_loaded() { // for just in time javascript, remove the parent if it has not been used...

wp_dequeue_script('jquery-ui-tabs');
wp_dequeue_script('tffaq_validation');
}
add_action('wp_footer','tffaq_tabs_loaded');

function add_tffaq_frontend_css() {

wp_register_style( 'tffaq_jquery_custom', plugins_url( 'css/jquery-ui-1.8.16.custom.css' , __FILE__ ) );
wp_enqueue_style( 'tffaq_jquery_custom' );

$tffaq_stylesheet_path = (file_exists(get_stylesheet_directory().'/tffaq.css'))? get_stylesheet_directory_uri().'/tffaq.css' : plugins_url( 'css/tffaq-frontend.css' , __FILE__ );
wp_register_style( 'tffaq_frontend', $tffaq_stylesheet_path );
wp_enqueue_style( 'tffaq_frontend' );

}
add_action('wp_head','add_tffaq_frontend_css',0);

/*** end front end ***/

/*** let's move the admin stuff into it's own folder ***/

if(is_admin()) {

require_once(plugin_dir_path(__FILE__).'admin/admin.php');
}

/***** tffaq functions *****/

function faq_get_first_category() {
global $wpdb;
$first_cat = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."faq_categories ORDER BY id ASC LIMIT 0,1");
return $first_cat[0];
}

function faq_get_questions($category) {
global $wpdb;
$questions = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."faq_questions WHERE category='".$category."' AND answer!='' ORDER BY id DESC");
return $questions;
}

function tffaq_unanswered_questions() {
global $wpdb;
$questions = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."faq_questions WHERE answer='' ORDER BY id DESC");
return $questions;
}

function tffaq_get_categories() {
global $wpdb;
$categories = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."faq_categories ORDER BY id ASC");
return $categories;
}

function faq_get_category($id) {
global $wpdb;
$the_cat = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."faq_categories WHERE id='".$id."'");

/*** returns 0 for an invalid category ***/
return empty($the_cat) ? 0 : $the_cat[0];

}

function faq_category_by_name($category) {
global $wpdb;
$the_cat = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."faq_categories WHERE category='".$category."'");
return $the_cat[0];
}

function faq_get_question($id) {
global $wpdb;
$the_question = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."faq_questions WHERE id='".$id."'");
if(!empty($the_question[0])) {
return $the_question[0];
}
return;
}

function tffaq_category_validation() {
global $wpdb;
$valid_categories = $wpdb->get_results("SELECT id, category FROM ".$wpdb->prefix."faq_questions");

foreach($valid_categories as $category) {

$valid = faq_get_category($category->category);

// 0 means it's not a vaild category so let's move the question to the first valid category.

if(!$valid){

$valid_id = faq_get_first_category();
$valid_id = $valid_id->id;
$status = $wpdb->query("UPDATE ".$wpdb->prefix."faq_questions SET category='".$valid_id."' WHERE id='".$category->id."'");

} /*** end if($valid == 0 ) ***/

} /*** end foreach($valid_categories as $category) ***/

} /*** end function tffaq_category_validation ***/

/*** new shortcodes ***/

/*** start tffaq_search ***/

function tffaq_search() {

wp_print_scripts(array('tffaq_frontend', 'tffaq_valid_question'));


global $wpdb;
$string = isset($_POST['tffaq-search'])? esc_attr($_POST['tffaq-search']):'';

if(!isset($_POST['tffaq-search'])) {

$new_content ='';
$new_content .= '
<div class="tffaq-search">
<form method="post" id="tffaq_search_form" name="tffaq_search_form" action="" >
<h4 class="tffaq-header">'.__('Search FAQ','tf-faq').'</h4>
<input type="text" name="tffaq-search" id="tffaq-search" value="'.$string.'" minlength="3" />
<select name="tffaq-cat" id="tffaq-cat">';
$categories = tffaq_get_categories();
$new_content .= '<option value="0">'.__('All','tf-faq').'</option>';

$selected = '';
foreach($categories as $category) {

if(isset($_POST['tffaq-cat'])){ $selected = $_POST['tffaq-cat'] == absint($category->id)? ' selected="selected"':''; }

/*** does the category have answered questions ? ***/

$count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(id) FROM ".$wpdb->prefix."faq_questions WHERE category = %d AND answer !='' ", $category->id));

/*** if it does show it, if not skip it ***/

if($count != '0') {

$new_content .= '<option '.$selected.'value="'.$category->id.'">'.$category->category.'</option>';

} /*** end if($count != '0') ***/


} /*** end foreach($categories as $category) ***/

$new_content .= '</select>
<input type="submit" name="tffaq-search-btn" id="tffaq-search-btn" value="'.__('Search','tf-faq').'" /></form></div>';

} else {

/*** do the search if the search string is at least 3 characters long ***/

if(strlen($string) > 2) {

$questions =(!empty($_POST['tffaq-cat']))? $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."faq_questions WHERE category=".absint($_POST['tffaq-cat'])." AND question LIKE '%".$string."%' OR category=".absint($_POST['tffaq-cat'])." AND answer LIKE '%".$string."%'") : $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."faq_questions WHERE question LIKE '%".$string."%' OR answer LIKE '%".$string."%'");

} /*** end do the search ***/

$new_content = ''; // TODO maybe add the javascript here?

$new_content .= '<div class="tffaq-category"><h4 class="tffaq-header">Search results for: '.$string.'</h4>';

$new_content .= (!empty($wpdb->last_result)) ? tffaq_show($questions) : __('no search results were found: ','tf-faq');

unset($string);
$new_content .= '<a href="">Search Again</a></div>';

} /***** end if(!isset($_POST['faq-search'])) *****/

return $new_content;

} /*** end tffaq_search ***/

add_shortcode('faq_search', 'tffaq_search'); /*** will be depreciated ***/
add_shortcode('tffaq_search', 'tffaq_search');

function faq_ask() {

global $wpdb;
wp_print_scripts('tffaq_valid_question');

if(isset($_POST['tffaq-new-question']) and isset($_POST['tffaq-question'])) {

$question = wp_kses_data($_POST['tffaq-question']);
$q_email = sanitize_email($_POST['tffaq-email']);
$category = absint($_POST['tffaq-category']);
$table_name = $wpdb->prefix.'faq_questions';

         $wpdb->insert( $table_name, array( 'category' => $category, 'question' => $question, 'answer' => '', 'email' => $q_email ) );

$message = __('Your question has been submitted. Thank you.','tf-faq');

$faq_email = get_option('faq-email');

if($faq_email) { /*** send e-mail notification that a question was asked ***/

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset="UTF-8"' . "\r\n";
$cat = faq_get_category($category);
$subject = $cat->category.' '.__('question','tf-faq');
$email = '
<html>
<body>
<h2>&quot;'.$cat->category.'&quot; '.__('question','tf-faq').'</h2>
<p>'.__('Someone asked this question on: ','tf-faq').' <a href="'.get_option('siteurl').'">'.get_option('siteurl').'</a></p>
<p><strong>'.__('Category').'</strong>: '.$cat->category.'</p>
<p><strong>'.__('Question').'</strong>: '.$question.'</p>
<p><a href="'.admin_url('admin.php?page=tffaq-answers','admin').'">click here to answer the question</a></p>
</body>
</html>
';

$email = stripslashes($email);

wp_mail($faq_email,$subject,$email,$headers);
}

}

$new_content = '';

if(isset($message)) { $new_content .= '<p class="tffaq-message ui-state-highlight ui-corner-all">'.$message.'</p>'; }

$new_content .= '

<div class="tffaq-ask-question">
<form name="tffaq-questionForm" id="tffaq-questionForm" method="post" action="">
<h4 class="tffaq-header">'.__('Ask a question','tf-faq').'</h4>
<p class="tffaq-ask-label"><label for="tffaq-category">'.__('Select a Category for your question.','tf-faq').'</label></p>
<p><select class="required" name="tffaq-category" id="tffaq-category">';

$categories = tffaq_get_categories();
foreach($categories as $category) {

$new_content .= '<option value="'.$category->id.'">'.$category->category.'</option>';

}

$new_content .= '</select></p>
<p class="tffaq-ask-label"><label for="tffaq-question">'.__('What is your question?','tf-faq').'</label></p>
<p><textarea class="required" id="tffaq-question" name="tffaq-question" rows="" cols=""></textarea></p>
<p class="tffaq-ask-label"><label for="tffaq-email">'.__('Email address to send the answer to:','tf-faq').'</label></p>
<p><input type="text" class="required" id="tffaq-email" name="tffaq-email" /></p>
<input type="submit" value="'.__('Ask Question','tf-faq').'" id="tffaq-new-question" name="tffaq-new-question" />
</form>
</div>';

return $new_content;

} /***** end [faq_ask] *****/

add_shortcode('faq_ask', 'faq_ask');

function faq_one_category( $atts, $content = null ) { // this is really get category by id so maybe re-name? TODO

wp_print_scripts('tffaq_frontend');
   extract( shortcode_atts( array(
      'id' => '1',
      ), $atts ) );

$new_content = '';
$category = faq_get_category($id);
$new_content .= '<div class="tffaq-category"><h4 class="tffaq-header">'.$category->category.'</h4>';
$questions = faq_get_questions($category->id);
$new_content .= stripslashes(tffaq_show($questions));
$new_content .= '</div>';

return $new_content;
}

add_shortcode('faq', 'faq_one_category');

/***** get category by name *****/

function faq_category_name( $atts, $content = null ) {

   wp_print_scripts('tffaq_frontend');
   extract( shortcode_atts( array(
      'name' => 'General',
      ), $atts ) );

$new_content = '';
$category = faq_category_by_name($name);
$new_content .= '<div class="tffaq-category"><h4 class="tffaq-header">'.$category->category.'</h4>';
$questions = faq_get_questions($category->id);
$new_content .= stripslashes(tffaq_show($questions));
$new_content .= '</div>';

return $new_content;
}

add_shortcode('faq_name', 'faq_category_name');


function faq_all(){

wp_print_scripts('tffaq_frontend');
global $wpdb;
$categories = tffaq_get_categories();

$new_content = '';
foreach($categories as $category) {
$category = faq_get_category($category->id);

/*** does the category have answered questions ? ***/

$count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(id) FROM ".$wpdb->prefix."faq_questions WHERE category = %d AND answer !='' ", $category->id));

/*** if it does show it, if not skip it ***/

if($count != '0') {

$new_content .= '<div class="tffaq-category"><h4 class="tffaq-header">'.$category->category.'</h4>';
$questions = faq_get_questions($category->id);
$new_content .= stripslashes(tffaq_show($questions));
$new_content .= '</div>';

} /*** end if($count != '0') ***/

} /*** end foreach($categories as $category) ***/

return $new_content;
}

add_shortcode('faq_all', 'faq_all');

function tffaq_tabs(){

 wp_print_scripts('tffaq_jquery_cookie');

$new_content = '';

$new_content .= '<div id="tffaq-tabs">
<ul>
<li><a href="#tffaq-tabs-1">'.__('Frequently Asked Questions','tf-faq').'</a></li>
<li><a href="#tffaq-tabs-2">'.__('Search','tf-faq').'</a></li>
<li><a href="#tffaq-tabs-3">'.__('Ask A Question','tf-faq').'</a></li>
</ul>

<div id="tffaq-tabs-1">';

$new_content .= do_shortcode('[faq_all]');

$new_content .= '</div>

<div id="tffaq-tabs-2" >';

$new_content .= do_shortcode('[tffaq_search]');

$new_content .= '</div>

<div id="tffaq-tabs-3">';

$new_content .= do_shortcode('[faq_ask]');

$new_content .= '</div></div>';

return $new_content;
}

add_shortcode('tffaq_tabs', 'tffaq_tabs');

/*** end new shortcodes ***/

/*** support for depreciated shortcodes ***/

function tfa_tabs(){

$new_content = '';

$new_content .= do_shortcode('[tffaq_tabs]');

return $new_content;
}
add_shortcode('tfa_tabs', 'tfa_tabs');

/*** end support for depreciated shortcodes ***/

/*** end FAQ functions ***/

/*** install and create the database tables ***/

register_activation_hook( __FILE__, 'tffaq_install' );

function tffaq_install() {
   global $wpdb;

    register_uninstall_hook( __FILE__, 'tffaq_uninstall' );

if (function_exists('is_multisite') && is_multisite()) {
// check if it is a network activation - if so, run the activation function for each blog id
if (isset($_GET['networkwide']) && ($_GET['networkwide'] == 1)) {
$old_blog = $wpdb->blogid;
// Get all blog ids
$blogids = $wpdb->get_col($wpdb->prepare("SELECT blog_id FROM $wpdb->blogs"));
foreach ($blogids as $blog_id) {
switch_to_blog($blog_id);
_tffaq_install();
}
switch_to_blog($old_blog);
return;
}
}
_tffaq_install();
}

function _tffaq_install() {

   global $wpdb;

   $table_name = $wpdb->prefix . "faq_questions";
   if($wpdb->get_var("show tables like '$table_name'") != $table_name) {

      $sql = "CREATE TABLE " . $table_name . " (
id mediumint(9) NOT NULL AUTO_INCREMENT,
category int(9) DEFAULT '0' NOT NULL,
question text NOT NULL,
answer text NOT NULL,
email VARCHAR(56) NOT NULL,
hits int DEFAULT '0' NOT NULL,
UNIQUE KEY id (id)
);";

      require_once(ABSPATH.'wp-admin/includes/upgrade.php');
      dbDelta($sql);
    }

   $table_name = $wpdb->prefix . "faq_categories";
   if($wpdb->get_var("show tables like '$table_name'") != $table_name) {

      $sql = "CREATE TABLE " . $table_name . " (
id mediumint(9) NOT NULL AUTO_INCREMENT,
category VARCHAR(50) NOT NULL,
UNIQUE KEY id (id)
);";

      require_once(ABSPATH.'wp-admin/includes/upgrade.php');
      dbDelta($sql);

      $insert = "INSERT INTO ".$table_name." (category) "."VALUES ('".__('General','tf-faq')."')";
      $results = $wpdb->query( $insert );
    }

    /*** update the version ***/
$tffaq_version = "0.0.9";
if(!add_option("tffaq_version",$tffaq_version)) {
update_option("tffaq_version",$tffaq_version);
}

/***** add email address column if it's not already there regardless of version *****/
/*** current version is 0.0.9 may be able to remove this in the future ***/

if(!$wpdb->get_col_info($wpdb->prefix.'faq_questions',4)) {

$sql = 'ALTER TABLE '.$wpdb->prefix.'faq_questions ADD email VARCHAR(56) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;';

$wpdb->query($sql);

} /***** end if(!$wpdb->get_col_info *****/
}

add_action( 'wpmu_new_blog', 'tf_new_blog', 10, 6);

function tf_new_blog($blog_id, $user_id, $domain, $path, $site_id, $meta ) {
global $wpdb;

if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
}

if (is_plugin_active_for_network('tf-faq/tf-faq.php')) {
$old_blog = $wpdb->blogid;
switch_to_blog($blog_id);
_tffaq_install();
switch_to_blog($old_blog);
}
}

/***** tffaq category dropdown *****/

function tffaq_category_dropdown() {
?>
<select name="tffaq_category" id="tffaq_category" onchange="window.location='?page=tffaq-questions&amp;cat='+this.value">
<?php
$cur_category = absint($_GET['cat']);
$categories = tffaq_get_categories();
foreach($categories as $category) {
$selected = '';
if($category->id == $cur_category) $selected = ' selected="selected" ';
echo '<option'.$selected.' value="'.$category->id.'">'.$category->category.'</option>';
}
?>
</select>
<?php
}

/***** end tffaq category dropdown *****/

/***** end show category dropdown *****/

/*** meta boxes ***/

function faq_categoryname_meta_box() { // TODO: this meta box needs namespacing corrections...

$category_id = isset($_GET['id']) ? absint($_GET['id']) : '';

if($category_id) { $edit_category = faq_get_category($category_id); }
?>
<input type="hidden" name="faq_category_id" value="<?php echo $category_id?>" />
Name: <input type="text" name="faq_category_name" value="

<?php if(isset($edit_category)) { echo $edit_category->category; } ?>

" class="regular-text" />
<?php
} /*** end faq_categoryname_meta_box ***/

/*** new tffaq_question_metabox ***/

function tffaq_question_metabox() {

$tf_title = esc_attr($_GET['tf_title']);
$edit_question = isset($_GET['id']) ? faq_get_question(absint($_GET['id'])) : 0 ;
$cur_category = (empty($_GET['cat'])) ? faq_get_first_category():faq_get_category(absint($_GET['cat']));
$tffaq_mail = (empty($edit_question->email)) ? '': $edit_question->email ;
$tffaq_id = (empty($edit_question->id)) ? '': $edit_question->id ;
?>
<form method="post" action="?page=tffaq-questions">
<input type="hidden" id="tffaq_mail" name="tffaq_mail" value="<?php echo $tffaq_mail ?>" />
<p>
<h3><strong>"<?php echo $cur_category->category; ?>"</strong></h3>
<input type="hidden" id="tffaq_question_id" name="tffaq_question_id" value="<?php echo $tffaq_id ?>" />
<input type="hidden" id="tffaq_category" name="tffaq_category" value="<?php echo $cur_category->id?>" />
</p>

<p>
<label for="tffaq_question"><h4><?php _e('Question: ','tf-faq');?></h4></label>
<textarea id="tffaq_question" name="tffaq_question" class="large-text">
<?php if(!empty($edit_question)) { echo trim(stripslashes($edit_question->question)); } ?>
</textarea>

</p>

<p>
<label for="tffaq_answer"><h4><?php _e('Answer: ','tf-faq');?></h4></label>

<?php
if(user_can_richedit()) {
$tffaq_answer = (!empty($edit_question))? trim(stripslashes($edit_question->answer)):'';
wp_editor( stripslashes($tffaq_answer), 'tffaq_answer' );
}else{
?>
<textarea id="tffaq_answer" name="tffaq_answer" class="large-text">
<?php if(!empty($edit_question)) { echo trim(stripslashes($edit_question->answer)); } ?>
</textarea>

<?php } ?>

</p>

<input type="submit" value="<?php echo $tf_title.__(' this Question ','tf-faq');?>" name="tffaq_submit_question" id="tffaq_submit_question" class="button-secondary" />
<span><?php _e('or Select a Different Category','tf-faq'); tffaq_category_dropdown(); ?></span>
</form>
<?php
}

/*** end new tffaq_question_metabox ***/

/*** Add translation ***/

function tffaq_loadtranslation() {
load_plugin_textdomain('tf-faq', false,'tf-faq/languages');
}

add_action('init', 'tffaq_loadtranslation');
?>
Something went wrong with that request. Please try again.