- Timestamp:
- 04/16/2021 05:29:26 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-xprofile/classes/class-bp-xprofile-field.php
r12868 r12885 139 139 */ 140 140 public $do_autolink; 141 142 /** 143 * The signup position of the field into the signups form. 144 * 145 * @since 8.0.0 146 * @var int 147 */ 148 public $signup_position; 141 149 142 150 /** … … 861 869 862 870 /** 871 * Get the field's signup position. 872 * 873 * @since 8.0.0 874 * 875 * @return int the field's signup position. 876 * 0 if the field has not been added to the signup form. 877 */ 878 public function get_signup_position() { 879 if ( ! isset( $this->signup_position ) ) { 880 $this->signup_position = (int) bp_xprofile_get_meta( $this->id, 'field', 'signup_position' ); 881 } 882 883 return $this->signup_position; 884 } 885 886 /** 863 887 * Get whether the field values should be auto-linked to a directory search. 864 888 * … … 1278 1302 $this->required_metabox(); 1279 1303 1304 // Output signup position metabox. 1305 $this->signup_position_metabox(); 1306 1280 1307 // Output the Member Types metabox. 1281 1308 $this->member_type_metabox(); … … 1346 1373 $supports = array( 1347 1374 'switch_fieldtype' => true, 1348 ' allow_required'=> true,1349 ' allow_autolink'=> true,1375 'required' => true, 1376 'do_autolink' => true, 1350 1377 'allow_custom_visibility' => true, 1351 1378 'member_types' => true, 1379 'signup_position' => true, 1352 1380 ); 1353 1381 … … 1503 1531 * 1504 1532 * @since 2.4.0 1533 * 1534 * @return void If default field or if the field does not support the feature. 1505 1535 */ 1506 1536 private function member_type_metabox() { 1507 1537 1508 1538 // The primary field is for all, so bail. 1509 if ( 1 === (int) $this->id|| ! $this->field_type_supports( 'member_types' ) ) {1539 if ( true === $this->is_default_field() || ! $this->field_type_supports( 'member_types' ) ) { 1510 1540 return; 1511 1541 } … … 1557 1587 * @since 2.3.0 1558 1588 * 1559 * @return void If default field id 1.1589 * @return void If default field or if the field does not support the feature. 1560 1590 */ 1561 1591 private function visibility_metabox() { … … 1606 1636 * @since 2.3.0 1607 1637 * 1608 * @return void If default field .1638 * @return void If default field or if the field does not support the feature. 1609 1639 */ 1610 1640 private function required_metabox() { … … 1633 1663 * @since 2.5.0 1634 1664 * 1635 * @return void If default field id 1.1665 * @return void If the field does not support the feature. 1636 1666 */ 1637 1667 private function autolink_metabox() { … … 1704 1734 1705 1735 <?php 1736 } 1737 1738 /** 1739 * Output the metabox for setting the field's position into the signup form. 1740 * 1741 * @since 8.0.0 1742 * 1743 * @return void If default field or if the field does not support the feature. 1744 */ 1745 private function signup_position_metabox() { 1746 // Field types not supporting the feature cannot be added to signups form. 1747 if ( ! $this->field_type_supports( 'signup_position' ) || true === $this->is_default_field() ) { 1748 return; 1749 } 1750 1751 $next_signup_position = 1; 1752 $signup_position = $this->get_signup_position(); 1753 1754 if ( 0 === $signup_position ) { 1755 $signup_fields_order = bp_xprofile_get_signup_field_ids(); 1756 $next_signup_position = count( $signup_fields_order ) + 1; 1757 } else { 1758 $next_signup_position = $signup_position; 1759 } 1760 ?> 1761 1762 <div class="postbox" id="field-signup-position-metabox"> 1763 <h2><label for="default-visibility"><?php esc_html_e( 'Signups', 'buddypress' ); ?></label></h2> 1764 <div class="inside"> 1765 <div> 1766 <ul> 1767 <li> 1768 <input type="checkbox" id="has-signup-position" name="signup-position" value="<?php echo esc_attr( $next_signup_position ); ?>" <?php checked( $signup_position, $next_signup_position ); ?> /> 1769 <label for="has-signup-position"><?php esc_html_e( 'Use the field into the registration form.', 'buddypress' ); ?></label> 1770 </li> 1771 </ul> 1772 </div> 1773 </div> 1774 </div> 1775 <?php 1706 1776 } 1707 1777 … … 1755 1825 'value' => 'textbox', 1756 1826 ), 1827 array( 1828 'name' => 'signup-position', 1829 'id' => 'has-signup-position', 1830 'value' => $this->get_signup_position(), 1831 ), 1757 1832 ); 1758 1833 }
Note: See TracChangeset
for help on using the changeset viewer.