0, 'label' => '--choose--' ); $arg = array('posts_per_page' => -1); $agensy_posts = get_posts($arg); foreach ($agensy_posts as $agensy_post) : $agensy_postlist[$agensy_post->ID] = array( 'value' => $agensy_post->ID, 'label' => $agensy_post->post_title ); endforeach; extract($widget_field); switch ($agensy_widgets_field_type) { // Standard text field case 'text' : ?>



/>

'; foreach ($agensy_widgets_field_options as $athm_option_name => $athm_option_title) { ?> />





get_field_id($agensy_widgets_name); $class = ''; $int = ''; $value = $athm_field_value; $name = $instance->get_field_name($agensy_widgets_name); if ($value) { $class = ' has-file'; } $output .= '
'; $output .= '
'; $output .= '' . "\n"; if (function_exists('wp_enqueue_media')) { $output .= '' . "\n"; } else { $output .= '

' . esc_html__('Upgrade your version of WordPress for full media support.', 'agensy') . '

'; } $output .= '
' . "\n"; if ($value != '') { $remove = 'Remove'; $attachment_id = attachment_url_to_postid($value); $image_array = wp_get_attachment_image_src($attachment_id, 'medium'); $image = preg_match('/(^.*\.jpg|jpeg|png|gif|ico*)/i', $value); if ($image) { $output .= '' . $remove; } else { $parts = explode("/", $value); for ($i = 0; $i < sizeof($parts); ++$i) { $title = $parts[$i]; } // No output preview if it's not an image. $output .= ''; // Standard generic output if it's not an image. $title = esc_html__('View File', 'agensy'); $output .= ''; } } $output .= '
' . "\n"; echo $output; break; } } function agensy_widgets_updated_field_value($widget_field, $new_field_value) { extract($widget_field); // Allow only integers in number fields if ($agensy_widgets_field_type == 'number') { return absint($new_field_value); // Allow some tags in textareas } elseif ($agensy_widgets_field_type == 'textarea') { // Check if field array specifed allowed tags if (!isset($agensy_widgets_allowed_tags)) { // If not, fallback to default tags $agensy_widgets_allowed_tags = '

'; } return strip_tags($new_field_value, $agensy_widgets_allowed_tags); // No allowed tags for all other fields } elseif ($agensy_widgets_field_type == 'url') { return esc_url_raw($new_field_value); } else { return strip_tags($new_field_value); } }