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
<?php | |
/** | |
* Adds a PDF field to AnsPress question form. | |
* | |
* @param array $form Form arguments. | |
* @return void | |
*/ | |
function my_custom_question_field( $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
<?php | |
/** | |
* Filter select field. | |
* | |
* Check if select field options are terms and then change orderby and order value. | |
* This filter will work only with AnsPress 4.1.0 | |
*/ | |
function my_category_field_filter( $args, $form ) { | |
if ( 'select' === $args['type'] && 'terms' === $args['options'] ) { | |
$args['terms_args']['orderby'] = 'orderby'; |
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
<?php | |
// AnsPress upload field. | |
array( | |
'label' => __( 'Prove that you are a human', 'anspress-question-answer' ), | |
'type' => 'captcha', | |
'order' => 100, // Make sure to keep it at bottom | |
); |
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
<?php | |
/** | |
* Save custom form "sample_form". | |
* | |
* @return void | |
*/ | |
function my_custom_ap_form() { | |
$form = anspress()->get_form( 'sample_form' ); | |
// Get all sanitized values. |
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
<?php | |
// AnsPress upload field. | |
array( | |
'html' => '<div class=""><h3>A simple header</h3></div>', | |
); |
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
<?php | |
// AnsPress repeatable field. | |
array( | |
... | |
'type' => 'repeatable', | |
'fields' => array( | |
'image-title' => array( | |
'label' => __( 'Image title' ), | |
'type' => 'input', | |
), |
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
<?php | |
// AnsPress group field. | |
array( | |
... | |
'type' => 'group', | |
'toggleable' => true, // Checkbox for showing and hiding group. | |
'fields' => array( | |
'child-1' => array( | |
'label' => __( 'A simple child text field' ), | |
'type' => 'input', |
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
<?php | |
// AnsPress upload field. | |
array( | |
... | |
'type' => 'upload', | |
'upload_options' => array( | |
'allowed_mimes' => ap_allowed_mimes(), // Or you can allow your own types. | |
'max_files' => 1, // Numbers of files allowed to upload. | |
'multiple' => false, // This must be true if you wish to upload multiple files. | |
'label_deny_type' => __( 'This file type is not allowed to upload.', 'anspress-question-answer' ), |
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
<?php | |
// AnsPress upload field. | |
array( | |
... | |
'type' => 'editor', | |
'editor_args' => array( | |
// Pass tinyMce options. | |
), | |
'upload_options' => array( | |
// Pass upload field options. |