__('Hide from admin?'), 'instructions' => 'Only show this field in forms', 'name' => 'hide_admin', 'type' => 'true_false', 'ui' => 1, ), true); } /** * Hide fields with the "Hide from admin?" setting * * @since 1.3.1 * */ function hide_field_from_admin( $field ) { if ( empty( $field['hide_admin'] ) ) { return $field; } if ( $field['hide_admin'] && is_admin() ) { return false; } return $field; } /** * Adds a new location rule type "Form" to ACF * * @since 1.0.0 * */ function add_form_location_type( $choices ) { $choices['Advanced Forms']['af_form'] = 'Form'; return $choices; } /** * Populates the choices for the location rule type "Form" * * @since 1.0.0 * */ function form_location_rule_values( $choices ) { $forms = af_get_forms(); foreach ( $forms as $form ) { $choices[ $form['key'] ] = $form['title']; } return $choices; } function form_location_rule_match( $match, $rule, $options ) { // Match with form object if ( 'af_form' == $rule['param'] && isset( $options['af_form'] ) ) { if( isset( $rule['value'] ) && $rule['value'] == $options['af_form'] ) { $match = true; } } // Match with entry if ( 'af_entry' == $options['post_type'] ) { $entry_form = get_post_meta( $options['post_id'], 'entry_form', true ); if ( $entry_form && $entry_form == $rule['value'] ) { $match = true; } } return $match; } } new AF_ACF_Additions();