clean() 공개 정적인 메소드

Clean a value for use in class / id
부터: 2.0
public static clean ( $input, $noarray = false, $db_field = false )
예제 #1
0
<?php

$options['data'] = (array) pods_var_raw('data', $options, array(), null, true);
if (1 == pods_var('grouped', $options, 0, null, true)) {
    ?>
<div class="pods-pick-values pods-pick-radio">
    <ul>
<?php 
}
$counter = 1;
$primary_name = $name;
$primary_id = 'pods-form-ui-' . PodsForm::clean($name);
$selection_made = false;
foreach ($options['data'] as $val => $label) {
    if (is_array($label)) {
        if (isset($label['label'])) {
            $label = $label['label'];
        } else {
            $label = $val;
        }
    }
    $attributes = array();
    $attributes['type'] = 'radio';
    $attributes['checked'] = null;
    $attributes['tabindex'] = 2;
    if (!$selection_made && ($val == $value || is_array($value) && in_array($val, $value))) {
        $attributes['checked'] = 'CHECKED';
        $selection_made = true;
    }
    $attributes['value'] = $val;
    $attributes = PodsForm::merge_attributes($attributes, $name, $form_field_type, $options);
예제 #2
0
    /**
     * @param $comment
     * @param $metabox
     */
    public function meta_comment($comment, $metabox)
    {
        wp_enqueue_style('pods-form');
        do_action('pods_meta_' . __FUNCTION__, $comment, $metabox);
        $hidden_fields = array();
        echo PodsForm::field('pods_meta', wp_create_nonce('pods_meta_comment'), 'hidden');
        ?>
    <table class="form-table editcomment pods-metabox">
        <?php 
        $id = null;
        if (is_object($comment)) {
            $id = $comment->comment_ID;
        }
        if (!is_object(self::$current_pod) || self::$current_pod->pod != $metabox['args']['group']['pod']['name']) {
            self::$current_pod = pods($metabox['args']['group']['pod']['name'], $id, true);
        } elseif (self::$current_pod->id() != $id) {
            self::$current_pod->fetch($id);
        }
        $pod = self::$current_pod;
        foreach ($metabox['args']['group']['fields'] as $field) {
            if (false === PodsForm::permission($field['type'], $field['name'], $field, $metabox['args']['group']['fields'], $pod, $id)) {
                if (pods_var('hidden', $field['options'], false)) {
                    $field['type'] = 'hidden';
                } else {
                    continue;
                }
            } elseif (!pods_has_permissions($field['options']) && pods_var('hidden', $field['options'], false)) {
                $field['type'] = 'hidden';
            }
            $value = '';
            if (!empty($pod)) {
                $value = $pod->field(array('name' => $field['name'], 'in_form' => true));
            }
            if ('hidden' == $field['type']) {
                $hidden_fields[] = array('field' => $field, 'value' => $value);
            } else {
                ?>
            <tr class="form-field pods-field <?php 
                echo esc_attr('pods-form-ui-row-type-' . $field['type'] . ' pods-form-ui-row-name-' . PodsForm::clean($field['name'], true));
                ?>
">
                <th scope="row" valign="top"><?php 
                echo PodsForm::label('pods_meta_' . $field['name'], $field['label'], $field['help'], $field);
                ?>
</th>
                <td>
                    <?php 
                echo PodsForm::field('pods_meta_' . $field['name'], $value, $field['type'], $field, $pod, $id);
                ?>
                    <?php 
                echo PodsForm::comment('pods_meta_' . $field['name'], $field['description'], $field);
                ?>
                </td>
            </tr>
        <?php 
            }
        }
        ?>
    </table>
<?php 
        foreach ($hidden_fields as $hidden_field) {
            $field = $hidden_field['field'];
            echo PodsForm::field('pods_meta_' . $field['name'], $hidden_field['value'], 'hidden');
        }
        do_action('pods_meta_' . __FUNCTION__ . '_post', $comment, $metabox);
    }
예제 #3
0
파일: form.php 프로젝트: Ingenex/redesign
    }
    echo apply_filters('pods_meta_default_box_title', $title, $pod, $fields);
    ?>
                                </span>
                            </h3>

                            <div class="inside">
                                <table class="form-table pods-metabox">
                                    <?php 
    foreach ($fields as $field) {
        if ('hidden' == $field['type']) {
            continue;
        }
        ?>
                                        <tr class="form-field pods-field <?php 
        echo 'pods-form-ui-row-type-' . $field['type'] . ' pods-form-ui-row-name-' . PodsForm::clean($field['name'], true);
        ?>
">
                                            <th scope="row" valign="top"><?php 
        echo PodsForm::label('pods_field_' . $field['name'], $field['label'], $field['help'], $field);
        ?>
</th>
                                            <td>
                                                <?php 
        echo PodsForm::field('pods_field_' . $field['name'], $pod->field(array('name' => $field['name'], 'in_form' => true)), $field['type'], $field, $pod, $pod->id());
        ?>
                                                <?php 
        echo PodsForm::comment('pods_field_' . $field['name'], $field['description'], $field);
        ?>
                                            </td>
                                        </tr>
예제 #4
0
<?php

$attributes = array();
$attributes['type'] = 'text';
$attributes['value'] = PodsForm::clean($value, false, true);
$attributes['tabindex'] = 2;
$attributes = PodsForm::merge_attributes($attributes, $name, $form_field_type, $options);
?>
<input<?php 
PodsForm::attributes($attributes, $name, $form_field_type, $options);
?>
 />
<script>
    jQuery( function ( $ ) {
        $( 'input#<?php 
echo $attributes['id'];
?>
' ).change( function () {
            var newval = $( this ).val().toLowerCase().replace( /([- ])/g, '_' ).replace( /([^0-9a-z_])/g, '' ).replace( /(_){2,}/g, '_' ).replace( /_$/, '' );
            $( this ).val( newval );
        } );
    } );
</script>