Skip to content

Instantly share code, notes, and snippets.

@j4ckielord
Created March 11, 2014 10:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save j4ckielord/9482836 to your computer and use it in GitHub Desktop.
Save j4ckielord/9482836 to your computer and use it in GitHub Desktop.
Display a modal before ask question (Only Compatible with DW Question & Answer Plugin and Bootstrap)
function your_theme_ask_question_modal(){
global $dwqa_options;
if( isset($dwqa_options['pages']['submit-question']) && is_page( $dwqa_options['pages']['submit-question'] ) ){
?>
<div id="dw-skip-ads" class="modal hide fade" data-backdrop="static">
<div class="modal-header">
<button type="button" class="close hide" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3 style="text-transform: none;">For better and faster support, please read our golden rules first <span class="countdown pull-right">(5)</span></h3>
</div>
<div class="modal-body">
<ol>
<li><strong>Guideline</strong>: make sure you have checked our <a href="http://www.designwall.com/guide">documentation</a> as it could have had covered your issue</li>
<li><strong>Search</strong>: try to search for the issue as someone might have had posted a similar issue and the answer is already out there</li>
<li><strong>Ask</strong>: write a brief question title, informative question description and provide as much details as possible</li>
</ol>
</div>
</div>
<script type="text/javascript">
jQuery(document).ready(function($) {
var path = "<?php echo get_permalink($dwqa_options['pages']['submit-question']); ?>";
var cookie = $.cookie('dwqa_ads_once_time');
if( ! cookie ) {
$('#dw-skip-ads').modal('show');
$.cookie('dwqa_ads_once_time', true, { expires: 210, path: path });
var time = 5;
var loop = setInterval(function(){
$('#dw-skip-ads .modal-header h3 .countdown').text( '(' + time-- +')');
if( time < 0 ) {
clearInterval(loop);
$('#dw-skip-ads .modal-header h3 .countdown').remove();
$('#dw-skip-ads .modal-header .close').show();
return false;
}
},1000);
}
});
</script>
<?php
}
}
add_action( 'dwqa_after_page', 'your_theme_ask_question_modal' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment