C:\xampp\htdocs\landing\wp-content\plugins\penci-framework\lib\meta-box\inc\clone.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php
/**
 * The clone module, allowing users to clone (duplicate) fields.
 *
 * @package Meta Box
 */

/**
 * The clone class.
 */
class RWMB_Clone {
    
/**
     * Get clone field HTML.
     *
     * @param mixed $meta  The meta value.
     * @param array $field The field parameters.
     *
     * @return string
     */
    
public static function html$meta$field ) {
        
$field_html '';

        
/**
         * Note: $meta must contain value so that the foreach loop runs!
         *
         * @see meta()
         */
        
foreach ( $meta as $index => $sub_meta ) {
            
$sub_field               $field;
            
$sub_field['field_name'] = $field['field_name'] . "[{$index}]";
            if ( 
$index ) {
                if ( isset( 
$sub_field['address_field'] ) ) {
                    
$sub_field['address_field'] = $field['address_field'] . "_{$index}";
                }
                
$sub_field['id'] = $field['id'] . "_{$index}";

                if ( ! empty( 
$sub_field['attributes']['id'] ) ) {
                    
$sub_field['attributes']['id'] = $sub_field['attributes']['id'] . "_{$index}";
                }
            }

            if ( 
in_array$sub_field['type'], array( 'file''image' ), true ) ) {
                
$sub_field['file_input_name'] = $field['file_input_name'] . "[{$index}]";
            } elseif ( 
$field['multiple'] ) {
                
$sub_field['field_name'] .= '[]';
            }

            
// Wrap field HTML in a div with class="rwmb-clone" if needed.
            
$class     "rwmb-clone rwmb-{$field['type']}-clone";
            
$sort_icon '';
            if ( 
$field['sort_clone'] ) {
                
$class .= ' rwmb-sort-clone';
                
$sort_icon "<a href='javascript:;' class='rwmb-clone-icon'></a>";
            }
            
$input_html "<div class='$class'>" $sort_icon;

            
// Call separated methods for displaying each type of field.
            
$input_html .= RWMB_Field::call$sub_field'html'$sub_meta );
            
$input_html RWMB_Field::filter'html'$input_html$sub_field$sub_meta );

            
// Remove clone button.
            
$input_html .= self::remove_clone_button$sub_field );
            
$input_html .= '</div>';

            
$field_html .= $input_html;
        } 
// End foreach().

        
return $field_html;
    }

    
/**
     * Set value of meta before saving into database
     *
     * @param mixed $new     The submitted meta value.
     * @param mixed $old     The existing meta value.
     * @param int   $post_id The post ID.
     * @param array $field   The field parameters.
     *
     * @return mixed
     */
    
public static function value$new$old$post_id$field ) {
        if ( ! 
is_array$new ) ) {
            
$new = array();
        }

        if ( 
in_array$field['type'], array( 'file''image' ), true ) ) {
            return 
RWMB_Field::call$field'value'$new''$post_id );
        }

        foreach ( 
$new as $key => $value ) {
            
$old_value = isset( $old$key ] ) ? $old$key ] : null;
            
$value     RWMB_Field::call$field'value'$value$old_value$post_id );
            
$new$key ] = RWMB_Field::filter'sanitize'$value$field );
        }

        return 
$new;
    }

    
/**
     * Add clone button.
     *
     * @param array $field Field parameters.
     * @return string $html
     */
    
public static function add_clone_button$field ) {
        if ( ! 
$field['clone'] ) {
            return 
'';
        }
        
$text RWMB_Field::filter'add_clone_button_text'$field['add_button'], $field );
        return 
'<a href="#" class="rwmb-button button-primary add-clone">' esc_html$text ) . '</a>';
    }

    
/**
     * Remove clone button.
     *
     * @param array $field Field parameters.
     * @return string $html
     */
    
public static function remove_clone_button$field ) {
        
$text RWMB_Field::filter'remove_clone_button_text''<i class="dashicons dashicons-minus"></i>'$field );
        return 
'<a href="#" class="rwmb-button remove-clone">' $text '</a>';
    }
}
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586