'', 'placeholder' => '', 'class' => '', 'style' => '', 'wrapper_class' => '', 'value' => '', 'name' => $field['id'], 'description' => '', 'type' => 'text', 'limit' => 0, 'conditional_logic' => '', 'show_wrapper' => true, 'custom_attributes' => array(), 'data_type' => '', 'required' => '' ) ); $field['conditional_logic'] = ('' != $field['conditional_logic']) ? json_encode($field['conditional_logic']) : ''; switch ( $field['data_type'] ) { case 'url': $field['class'] .= ' notifier_input_url'; $field['value'] = esc_url( $field['value'] ); break; default: break; } $show_limit_text = ''; if (0 != $field['limit']) { $show_limit_text = '0 / ' . $field['limit'] . ''; $field['custom_attributes']['data-limit'] = $field['limit']; $field['class'] = $field['class'] . ' force-text-limit'; } // Custom attribute handling $custom_attributes = array(); if ( ! empty( $field['custom_attributes'] ) && is_array( $field['custom_attributes'] ) ) { foreach ( $field['custom_attributes'] as $attribute => $value ) { $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"'; } } if ( '' != $field['required'] ) { $custom_attributes[] = 'required="required"'; } $custom_attributes_string = implode( ' ', $custom_attributes ); if ($field['show_wrapper']) { do_action('notifier_before_meta_field_wrapper', $field, $post); echo '

'; } if ( '' != $field['label'] ) { echo ''; } do_action('notifier_before_meta_field', $field, $post); echo ' '; do_action('notifier_after_meta_field', $field, $post); if ( '' != $field['description'] ) { echo '' . wp_kses_post( $field['description'] ) . ''; } do_action('notifier_after_meta_field_description', $field, $post); if ($field['show_wrapper']) { echo '

'; do_action('notifier_after_meta_field_wrapper', $field, $post); } } /** * Output a hidden input box. * * @param array $field */ function notifier_wp_hidden_input( $field ) { global $post; $field = apply_filters ('notifier_wp_hidden_input', $field, $post); $field = wp_parse_args( $field, array( 'class' => '', 'value' => '' ) ); do_action('notifier_before_meta_field', $field, $post); echo ' '; do_action('notifier_after_meta_field', $field, $post); } /** * Output a textarea input box. * * @param array $field */ function notifier_wp_textarea_input( $field ) { global $post; $field = apply_filters ('notifier_wp_textarea_input', $field, $post); $field = wp_parse_args( $field, array( 'label' => '', 'placeholder' => '', 'class' => '', 'style' => '', 'wrapper_class' => '', 'value' => '', 'name' => $field['id'], 'description' => '', 'limit' => 0, 'conditional_logic' => '', 'show_wrapper' => true, 'custom_attributes' => array(), 'rows' => 2, 'cols' => 20, 'required' => '' ) ); $field['conditional_logic'] = ('' != $field['conditional_logic']) ? json_encode($field['conditional_logic']) : ''; $show_limit_text = ''; if ($field['limit'] != 0) { $show_limit_text = '0 / ' . $field['limit'] . ''; $field['custom_attributes']['data-limit'] = $field['limit']; $field['class'] = $field['class'] . ' force-text-limit'; } // Custom attribute handling $custom_attributes = array(); if ( ! empty( $field['custom_attributes'] ) && is_array( $field['custom_attributes'] ) ) { foreach ( $field['custom_attributes'] as $attribute => $value ) { $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"'; } } if ( '' != $field['required'] ) { $custom_attributes[] = 'required="required"'; } $custom_attributes_string = implode( ' ', $custom_attributes ); if ($field['show_wrapper']) { do_action('notifier_before_meta_field_wrapper', $field, $post); echo '

'; } if ( '' != $field['label'] ) { echo ''; } do_action('notifier_before_meta_field', $field, $post); echo ' '; do_action('notifier_after_meta_field', $field, $post); if ( '' != $field['description'] ) { echo '' . wp_kses_post( $field['description'] ) . ''; } do_action('notifier_after_meta_field_description', $field, $post); if ($field['show_wrapper']) { echo '

'; do_action('notifier_after_meta_field_wrapper', $field, $post); } } /** * Output a checkbox input box. * * @param array $field */ function notifier_wp_checkbox( $field ) { global $post; $field = apply_filters ('notifier_wp_checkbox', $field, $post); $field = wp_parse_args( $field, array( 'label' => '', 'class' => '', 'style' => '', 'wrapper_class' => '', 'value' => '', 'cbvalue' => 'yes', 'name' => $field['id'], 'description' => '', 'conditional_logic' => '', 'show_wrapper' => true, 'custom_attributes' => array(), 'required' => '' ) ); $field['conditional_logic'] = ('' != $field['conditional_logic']) ? json_encode($field['conditional_logic']) : ''; // Custom attribute handling $custom_attributes = array(); if ( ! empty( $field['custom_attributes'] ) && is_array( $field['custom_attributes'] ) ) { foreach ( $field['custom_attributes'] as $attribute => $value ) { $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"'; } } $custom_attributes_string = implode( ' ', $custom_attributes ); if ($field['show_wrapper']) { do_action('notifier_before_meta_field_wrapper', $field, $post); echo '

'; } if ( '' != $field['label'] ) { echo ''; } do_action('notifier_before_meta_field', $field, $post); echo ' '; do_action('notifier_after_meta_field', $field, $post); if ( '' != $field['description'] ) { echo '' . wp_kses_post( $field['description'] ) . ''; } do_action('notifier_after_meta_field_description', $field, $post); if ($field['show_wrapper']) { echo '

'; do_action('notifier_after_meta_field_wrapper', $field, $post); } } /** * Output a select input box. * * @param array $field Data about the field to render. */ function notifier_wp_select( $field ) { global $post; $field = apply_filters ('notifier_wp_select', $field, $post); $field = wp_parse_args( $field, array( 'label' => '', 'class' => '', 'style' => '', 'wrapper_class' => '', 'value' => '', 'name' => $field['id'], 'description' => '', 'conditional_logic' => '', 'show_wrapper' => true, 'custom_attributes' => array() ) ); $field['conditional_logic'] = ('' != $field['conditional_logic']) ? json_encode($field['conditional_logic']) : ''; // Custom attribute handling $custom_attributes = array(); if ( ! empty( $field['custom_attributes'] ) && is_array( $field['custom_attributes'] ) ) { foreach ( $field['custom_attributes'] as $attribute => $value ) { $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"'; } } $custom_attributes_string = implode( ' ', $custom_attributes ); $description = ! empty( $field['description'] ) ? $field['description'] : ''; if ($field['show_wrapper']) { do_action('notifier_before_meta_field_wrapper', $field, $post); echo '

'; } if ( '' != $field['label'] ) { echo ''; } do_action('notifier_before_meta_field', $field, $post); echo ''; do_action('notifier_after_meta_field', $field, $post); if ( '' != $field['description'] ) { echo '' . wp_kses_post( $field['description'] ) . ''; } do_action('notifier_after_meta_field_description', $field, $post); if ($field['show_wrapper']) { echo '

'; do_action('notifier_after_meta_field_wrapper', $field, $post); } } /** * Output a radio input box. * * @param array $field */ function notifier_wp_radio( $field ) { global $post; $field = apply_filters ('notifier_wp_radio', $field, $post); $field = wp_parse_args( $field, array( 'label' => '', 'class' => '', 'style' => '', 'wrapper_class' => '', 'value' => '', 'name' => $field['id'], 'description' => '', 'conditional_logic' => '', 'show_wrapper' => true, 'custom_attributes' => array() ) ); $field['conditional_logic'] = ('' != $field['conditional_logic']) ? json_encode($field['conditional_logic']) : ''; // Custom attribute handling $custom_attributes = array(); if ( ! empty( $field['custom_attributes'] ) && is_array( $field['custom_attributes'] ) ) { foreach ( $field['custom_attributes'] as $attribute => $value ) { $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"'; } } $custom_attributes_string = implode( ' ', $custom_attributes ); if ($field['show_wrapper']) { do_action('notifier_before_meta_field_wrapper', $field, $post); echo '
'; } if ( '' != $field['label'] ) { echo '' . wp_kses_post( $field['label'] ) . ''; } do_action('notifier_before_meta_field', $field, $post); echo ''; do_action('notifier_after_meta_field', $field, $post); if ( '' != $field['description'] ) { echo '' . wp_kses_post( $field['description'] ) . ''; } do_action('notifier_after_meta_field_description', $field, $post); if ($field['show_wrapper']) { echo '
'; do_action('notifier_after_meta_field_wrapper', $field, $post); } } /** * Output a file upload input box. * * @param array $field */ function notifier_wp_file_input( $field ) { global $post; $field = apply_filters ('notifier_wp_text_input_args', $field, $post); $field = wp_parse_args( $field, array( 'label' => '', 'placeholder' => '', 'class' => '', 'wrapper_class' => '', 'value' => '', 'name' => $field['id'], 'description' => '', 'conditional_logic' => '', 'show_wrapper' => true, 'custom_attributes' => array(), 'uploader_title' => 'Upload media', 'uploader_button_text' => 'Select', 'uploader_supported_file_types' => array() ) ); $field['conditional_logic'] = ('' != $field['conditional_logic']) ? json_encode($field['conditional_logic']) : ''; $image_thumb = ''; $video_url = ''; $show_image = 'hide'; $show_video = 'hide'; $value = isset($field['value']) ? $field['value'] : ''; echo ''; if ( '' != $value ) { $file_type = $field['uploader_supported_file_types']; switch ($file_type) { case 'image': case 'image/jpeg': case 'image/png': case 'application/pdf': $image_thumb = wp_get_attachment_thumb_url( $value ); $file_mime_type = get_post_mime_type($value); $file_mime_type = explode('/', $file_mime_type); $show_image = ''; $show_video = 'hide'; $field['custom_attributes']['data-type'] = $file_mime_type[0]; $field['custom_attributes']['data-subtype'] = $file_mime_type[1]; $field['custom_attributes']['data-url'] = $image_thumb; break; case 'video/mp4': $video_url = wp_get_attachment_url( $value ); $show_image = 'hide'; $show_video = ''; $field['custom_attributes']['data-type'] = 'video'; $field['custom_attributes']['data-subtype'] = 'mp4'; $field['custom_attributes']['data-url'] = $video_url; break; default: $show_image = 'hide'; $show_video = 'hide'; } } // Custom attribute handling $custom_attributes = array(); if ( ! empty( $field['custom_attributes'] ) && is_array( $field['custom_attributes'] ) ) { foreach ( $field['custom_attributes'] as $attribute => $value ) { $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $value ) . '"'; } } $custom_attributes_string = implode( ' ', $custom_attributes ); if ($field['show_wrapper']) { do_action('notifier_before_meta_field_wrapper', $field, $post); echo '

'; } if ( '' != $field['label'] ) { echo ''; } do_action('notifier_before_meta_field', $field, $post); echo ''; echo '
'; echo ''; echo ' '; echo ''; echo '
'; do_action('notifier_after_meta_field', $field, $post); if ( '' != $field['description'] ) { echo '' . wp_kses_post( $field['description'] ) . ''; } do_action('notifier_after_meta_field_description', $field, $post); if ($field['show_wrapper']) { echo '

'; do_action('notifier_after_meta_field_wrapper', $field, $post); } }