This file contains hidden or 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 select field. | |
array( | |
... | |
'type' => 'select', | |
// If you have custom list of option then you can pass array directly. | |
'options' => array( | |
'select-1' => __( 'Select option label 1' ), | |
'select-2' => __( 'Select option label 2' ), | |
), |
This file contains hidden or 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 radio field. | |
array( | |
... | |
'type' => 'radio', | |
'options' => array( | |
'radio-1' => __( 'Radio for something' ), | |
'radio-2' => __( 'Radio for otherthing ), | |
), | |
... |
This file contains hidden or 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 checkbox field. | |
array( | |
... | |
'type' => 'checkbox', | |
// If you have only one checkbox then you dont need to pass | |
// options args. | |
'options' => array( | |
'check-1' => __( 'Checkbox for something' ), | |
'check-2' => __( 'Checkbox for otherthing ), |
This file contains hidden or 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 textarea field. | |
array( | |
... | |
'type' => 'textarea', | |
'attr' => array( | |
'rows' => 10, | |
), | |
... | |
); |
This file contains hidden or 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 form text field example. | |
$fields['key_of_field'] => array( | |
'type' => 'input', | |
'subtype' => 'text', | |
'label' => __( 'Custom text field' ), | |
'attr' => array( // custom HTML tag attributes. | |
'placeholder' => __( 'Placeholder text goes here' ), | |
'class' => 'css-class', | |
), |
This file contains hidden or 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 | |
// Url field. | |
$form['fields']['website'] = array( | |
'label' => __( 'Your website' ), | |
'desc' => __( 'Enter link to your website.' ), | |
'subtype' => 'url', // Default type is set to input. | |
'attr' => array( | |
'placeholder' => 'https://mydomain.com/', | |
), |
This file contains hidden or 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 | |
/** | |
* Add custom fields to AnsPress question form. | |
* | |
* This hook will add two new fields in ask form. | |
* | |
* @param array $form Form arguments. | |
* @return void | |
*/ | |
function my_custom_question_field( $form ) { |
This file contains hidden or 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 | |
/** | |
* Register a custom form by "sample_form" name in AnsPress. | |
* | |
* @return array | |
*/ | |
function my_custom_form_in_ap() { | |
$form = array( | |
'fields' => array( | |
'input_field_1' => array( // This is a unique key for field. |
This file contains hidden or 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 | |
/** | |
* Login dropdown in header. | |
* @since 2.0 | |
*/ | |
?> | |
<ul id="login-sign" class="nav navbar-nav navbar-right"> | |
<li class="dropdown"> | |
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><?php _e('Login', 'ab'); ?></a> |
This file contains hidden or 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 | |
// Thsi query will order users by reputation by default. | |
$user_args = array( | |
'ap_query' => true, | |
'role__not_in' => [ 'administrator', 'ap_moderator' ], | |
'number' => $number, | |
); | |
$ap_user_query = get_users( $user_args ); |