-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refeito plugin de FAQ e alteradas permissões gerais
- Loading branch information
Showing
103 changed files
with
193 additions
and
181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
nbproject/* | ||
src/nbproject/* |
Empty file.
Empty file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,65 +1,80 @@ | ||
<?php | ||
/** | ||
* @since 1.0 | ||
*/ | ||
|
||
include_once 'core/faq-core.php'; | ||
global $current_user; | ||
|
||
$cabecalho = '<h3>Bem vindo(a) ao cadastro de perguntas e respostas.</h3>'; | ||
$botao = 'Gravar'; | ||
|
||
if(!empty($_GET['id_faq']) && is_numeric($_GET['id_faq'])) | ||
{ | ||
$cabecalho = '<h3>Alterando Pergunta com ID '.(int)$_GET['id_faq'].'</h3>'; | ||
if (!empty($_GET['id_faq']) && is_numeric($_GET['id_faq'])) { | ||
$cabecalho = '<h3>Alterando Pergunta com ID ' . (int) $_GET['id_faq'] . '</h3>'; | ||
$botao = 'Gravar alterações'; | ||
} | ||
|
||
$idFaq = isset($_GET['id_faq']) ? (int)$_GET['id_faq'] : '' ; | ||
$id_faq = isset($_GET['id_faq']) ? (int) $_GET['id_faq'] : ''; | ||
$dados_faq = null; | ||
|
||
$Faq = new Faq(); | ||
if ( !empty($id_faq) ) { | ||
$dados_faq = get_post($id_faq); | ||
} | ||
|
||
if (isset($_POST['pergunta']) && !empty($_POST['pergunta']) && isset($_POST['solucao']) && !empty($_POST['pergunta'])) { | ||
|
||
$dadosFaq = $Faq->detalhesFaq($idFaq); | ||
$post = array( | ||
'menu_order' => '0', | ||
'comment_status' => 'closed', | ||
'ping_status' => 'open', | ||
'post_author' => $current_user->ID, | ||
'post_content' => sanitize_text_field($_POST['solucao']), | ||
'post_excerpt' => substr(sanitize_text_field($_POST['solucao']), 0, 200), | ||
'post_name' => sanitize_title($_POST['pergunta']), | ||
'post_status' => 'publish', | ||
'post_title' => $_POST['pergunta'], | ||
'post_type' => 'faq', | ||
); | ||
|
||
if(isset($_POST['solucao']) && isset($_POST['pergunta'])) | ||
{ | ||
$dadosFaq->pergunta = addslashes(isset($_POST['pergunta']) ? $_POST['pergunta'] : ''); | ||
$dadosFaq->solucao = addslashes(isset($_POST['solucao']) ? $_POST['solucao'] : ''); | ||
$dadosFaq->idFaq = addslashes(isset($_POST['id_faq']) ? $_POST['id_faq'] : ''); | ||
if ( isset($_POST['id_faq']) && !empty($_POST['id_faq']) ) { | ||
$post['ID'] = (int) $_POST['id_faq']; | ||
} | ||
|
||
if( $Faq->verificaExistenciaFaq($dadosFaq) ) | ||
{ | ||
echo "<meta http-equiv='refresh' content='1; ?page=faq/perguntas.php' ><div class='update-nag' style='background: green; color: white; font-size: 16px;'>Dados do FAQ gravados com sucesso!</div>"; | ||
if ( wp_update_post($post) ) { | ||
echo '<script>alert("Faq atualizado com sucesso!"); window.location.href="?page=faq/nova-pergunta.php";</script>'; | ||
} | ||
else | ||
{ | ||
echo "<div class='update-nag' style='background: orange; font-size: 16px;'>Não foi possível salvar os dados do FAQ, por favor preencha os campos obrigatórios</div>"; | ||
if (wp_insert_post($post)) { | ||
echo '<script>alert("Faq cadastrado com sucesso!"); window.location.href="?page=faq/nova-pergunta.php";</script>'; | ||
} | ||
|
||
} | ||
?> | ||
<br /> | ||
|
||
<form action="" method="post"> | ||
<table class="wp-list-table widefat fixed pages" cellspacing="0" style="width:95%;"> | ||
<thead> | ||
<tr> | ||
<th> | ||
<?php echo $cabecalho; ?> | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td> | ||
<input type="hidden" name="id_faq" value="<?php echo $idFaq; ?>" /> | ||
Pergunta<br /> | ||
<input type="text" name="pergunta" maxlength="255" value="<?php echo @$dadosFaq->pergunta; ?>" style="width: 90%"/> | ||
<br /><br /> | ||
Solução<br /> | ||
<textarea style="width: 90%; height: 100px;" name="solucao"><?php echo @$dadosFaq->solucao; ?></textarea> | ||
<br /><br /> | ||
<input type="submit" value="<?php echo @$botao; ?>" class="button-primary"/> | ||
<br /> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</form> | ||
<thead> | ||
<tr> | ||
<th> | ||
<?php echo $cabecalho; ?> | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td> | ||
<input type="hidden" name="id_faq" value="<?php echo @$dados_faq->ID; ?>" /> | ||
Pergunta<br /> | ||
<input type="text" name="pergunta" maxlength="255" value="<?php echo @$dados_faq->post_title; ?>" style="width: 90%"/> | ||
<br /><br /> | ||
|
||
Solução<br /> | ||
<textarea style="width: 90%; height: 100px;" name="solucao"><?php echo @$dados_faq->post_content; ?></textarea> | ||
<br /><br /> | ||
|
||
<input type="submit" value="<?php echo @$botao; ?>" class="button button-primary"/> | ||
<br /> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,104 +1,48 @@ | ||
<?php | ||
/** | ||
* @since 1.0 | ||
*/ | ||
|
||
include_once 'core/faq-core.php'; | ||
|
||
$Faq = new Faq(); | ||
|
||
if(isset($_GET['acao']) && is_numeric($_GET['id_faq'])) | ||
{ | ||
if($_GET['acao'] == 'remover') | ||
{ | ||
$idRemover = (int)$_GET['id_faq']; | ||
if( $Faq->remover($idRemover) ) | ||
{ | ||
?> | ||
<script type="text/javascript"> | ||
alert('Pergunta removida com sucesso!'); | ||
window.location.href="?page=faq/perguntas.php"; | ||
</script> | ||
<?php | ||
} | ||
if (isset($_GET['id_faq']) && !empty($_GET['id_faq']) && $_GET['acao'] == 'remover') { | ||
if (wp_delete_post($_GET['id_faq'])) { | ||
echo '<script>alert("Faq removido com sucesso!"); window.location.href="?page=faq/perguntas.php";</script>'; | ||
} | ||
} | ||
|
||
$ordenacaoBusca->campo = 'id'; | ||
$ordenacaoBusca->ordem = 'desc'; | ||
|
||
if( $dadosFaq = $Faq->obterListaFaq($ordenacaoBusca) ) | ||
{ | ||
?> | ||
if ($dadosFaq = get_posts(array('post_type' => 'faq'))) : ?> | ||
|
||
<h3>Listando as Perguntas e respostas (FAQ) já cadastradas</h3> | ||
<br /> | ||
<h3>Listando as Perguntas e respostas (FAQ) já cadastradas</h3> | ||
<br /> | ||
|
||
<table class="wp-list-table widefat fixed pages" cellspacing="0" style="width:95%;"> | ||
<thead> | ||
<tr> | ||
<th> | ||
ID | ||
</th> | ||
<th> | ||
Pergunta | ||
</th> | ||
<th> | ||
Solução | ||
</th> | ||
<th> | ||
Ações | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<?php | ||
foreach($dadosFaq as $dadosFaq){ | ||
|
||
$imagem = '../wp-content/plugins/faq/sources/images/no-image.png'; | ||
if( $dadosFaq->imagem != '' ) | ||
{ | ||
$imagem = 'wp-content/uploads/faq/'.$dadosFaq->imagem; | ||
} | ||
?> | ||
<thead> | ||
<tr> | ||
<th>Pergunta</th> | ||
<th>Solução</th> | ||
<th>Ações</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<?php foreach ($dadosFaq as $dadosFaq) { ?> | ||
<tr> | ||
<td> | ||
<?php echo (int)$dadosFaq->id ; ?> | ||
<?php echo $dadosFaq->post_title; ?> | ||
</td> | ||
<td> | ||
<?php echo $dadosFaq->pergunta ; ?> | ||
<?php echo $dadosFaq->post_content; ?> | ||
</td> | ||
<td> | ||
<?php echo $dadosFaq->solucao ; ?> | ||
<a href="?page=faq/nova-pergunta.php&id_faq=<?php echo (int) $dadosFaq->ID; ?>">Editar</a> | | ||
<a href="?page=faq/perguntas.php&acao=remover&id_faq=<?php echo (int) $dadosFaq->ID; ?>" | ||
onclick="return confirm('Deseja realmente remover este FAQ?')">Remover</a> | ||
</td> | ||
<!--<td> | ||
<img src="<?php echo $imagem ; ?>" width="64" /> | ||
</td> --> | ||
<td> | ||
<a href="?page=faq/nova-pergunta.php&id_faq=<?php echo (int)$dadosFaq->id; ?>">Editar</a> | | ||
<a href="?page=faq/perguntas.php&acao=remover&id_faq=<?php echo (int)$dadosFaq->id; ?>" onclick="return confirmaRemocao();">Remover</a> | ||
</td> | ||
</tr> | ||
<?php | ||
} | ||
?> | ||
</tbody> | ||
</table> | ||
<?php | ||
} | ||
else | ||
{ | ||
echo "<h3>No momento não há Perguntas e respostas (FAQ) cadastradas</h3>"; | ||
} | ||
?> | ||
<script type="text/javascript"> | ||
function confirmaRemocao() | ||
{ | ||
var decisao = confirm('Deseja realmente remover esta pergunta??'); | ||
if(decisao) | ||
{ | ||
return true; | ||
} | ||
else | ||
{ | ||
return false; | ||
} | ||
} | ||
</script> | ||
</tr> | ||
<?php | ||
} | ||
?> | ||
</tbody> | ||
</table> | ||
<?php | ||
else : | ||
echo "<h3>No momento não há Perguntas e respostas (FAQ) cadastradas</h3>"; | ||
endif; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,62 @@ | ||
<?php | ||
|
||
<?php | ||
/* | ||
* Plugin Name: Perguntas e respostas | ||
* Description: O plugin Perguntas e respostas facilita o cadastro de perguntas frequentes em seu Blog/Site | ||
* Author: Redsuns Design e Tecnologia Web | ||
* Author URI: http://www.redsuns.com.br | ||
* Date: 2012-10-04 | ||
* Version: 1.0 | ||
* Date: 2013-07-22 | ||
* Version: 2.0 | ||
*/ | ||
|
||
|
||
function menuFAQ() | ||
/** | ||
* @since 2.0 | ||
*/ | ||
function codex_custom_init() | ||
{ | ||
add_menu_page('Perguntas e respostas', 'Perguntas e respostas', 7, 'faq/perguntas.php','','../wp-content/plugins/faq/sources/images/question.png'); | ||
add_submenu_page('faq/perguntas.php', 'Nova pegunta','Nova pergunta', 7, 'faq/nova-pergunta.php'); | ||
$args = array('public' => true, 'label' => 'Faq'); | ||
register_post_type('faq', $args); | ||
} | ||
|
||
// adding menu | ||
add_action('admin_menu', 'menuFAQ'); | ||
add_action('init', 'codex_custom_init'); | ||
|
||
include_once 'sources/schemas/default-schema-for-faq.php'; | ||
|
||
$url = get_bloginfo('url'); | ||
$themePath = str_replace($url,'..',get_bloginfo('template_url')); | ||
|
||
if(!file_exists($themePath.'/page-faq.php')) | ||
/** | ||
* @#since 2.0 | ||
*/ | ||
function faq() | ||
{ | ||
@copy('../wp-content/plugins/faq/theme-pages/page-faq.php',$themePath.'/page-faq.php'); | ||
show_faq(); | ||
} | ||
|
||
?> | ||
add_shortcode('faq', 'faq'); | ||
|
||
|
||
/** | ||
* @since 2.0 | ||
*/ | ||
function show_faq() | ||
{ | ||
$faqs = get_posts(array('post_type' => 'faq', 'orderby' => 'post_date', 'order' => 'ASC')); | ||
|
||
if (!empty($faqs)) : | ||
?> | ||
<div class="faq"> | ||
<ul> | ||
<?php foreach ($faqs as $faq) : ?> | ||
<li> | ||
<div class="content" id="<?php echo $faq->ID; ?>"> | ||
<a href="#" class="content-link" id="<?php echo $faq->ID; ?>"><h4><?php echo $faq->post_title; ?></h4></a> | ||
<div class="answer" id="content_<?php echo $faq->ID; ?>" style="display:none;"> | ||
<p> <?php echo $faq->post_content; ?></p> | ||
</div> | ||
</div> | ||
</li> | ||
<?php endforeach; ?> | ||
</ul> | ||
</div> | ||
|
||
<?php else : ?> | ||
<h4>Não há perguntas e respostas cadastradas</h4> | ||
<?php endif; ?> | ||
<?php } |
Oops, something went wrong.